DDM example 2: Description of ORDERENT program
Initially, the ORDERENT program exists only in library PGMLIB on the central server (in Philadelphia).
This program does the following items:
- When an order entry operator enters a customer number, ORDERENT reads the customer number, then reads the first member of file CUSTMST2 in the PGMLIB library to find the customer name, address, and other information. The retrieved information is displayed to the operator, and the program asks for an item number and quantity desired.
- When the operator enters an item number and quantity desired and presses the Enter key, the program changes the corresponding primary item in the first member of the INVEN file, and it adds a record to the DETAIL file for each item and quantity entered. The program continues asking for another item number and quantity until the operator ends the program.
- When the operator ends the program, the file CUSTMAST is changed with the information for the entire order. (See the pseudocode of ORDERENT for details.)
For the following examples, it is assumed that all users on the remote servers who need to access CUSTMAST in Philadelphia already have authority to do so, and that those who do not need authority do not have it. In these examples, the iSeries™ server in Chicago does not have a compiler.
If we want this program to be used at all the remote locations that also stock a physical inventory, the program needs to be sent to each of the remote servers. We can assume that each of the remote servers has its own inventory and primary files INVEN, DETAIL, and CUSTMST2 (which is a copy of CUSTMAST). How the program can be sent to a remote server is described in DDM example 2: Transfer a program to a target server.
By using the code examples, you agree to the terms of the Code license and disclaimer information.
Pseudocode for ORDERENT Program • • • DECLARE CUSTMAST CHANGE * Declare file CUSTMAST and allow changing. DECLARE CUSTMST2 READ * Declare file CUSTMST2 as read only. DECLARE INVEN CHANGE * Declare inventory file INVEN and allow changing. DECLARE DETAIL OUTPUT * Declare file DETAIL as output only. • • • Open CUSTMAST, CUSTMST2, INVEN, and DETAIL files * Begin program. Show order entry display asking for CUSTNO. * Order entry operator enters CUSTNO. If function key, go to End. Read CUSTNO from display. For CUSTNO, return NAME, ADDR, and other information from CUSTMST2 file. Show NAME, ADDR, and other information on display. LOOP: Display 'Item Number ___ Quantity Desired ____'. * Order entry operator enters item number and quantity. Read ITEMNO and Quantity Desired from display. If ITEMNO = 0 then go to LOOPEND. Change INVEN with ITEMNO and Quantity Desired. Write an item record to the DETAIL file. Go to LOOP. LOOPEND: For CUSTNO, change CUSTMAST using information in file INVEN. End * Program has ended. Close CUSTMAST, CUSTMST2, INVEN, and DETAIL files. RETURN
Parent topic:
DDM example 2: ORDERENT application