IBM AS/400 Frozen Dessert Maker User Manual


 
Example of an ILE RPG Program
The TRANSACT file is defined as the Input Primary file. The ILE RPG program
cycle controls the reading of records from this file.
The EMPLOYEE file is defined as the Input Full-Procedure file. The reading of
records from this file is controlled by operations in the calculation specifications.
The QSYSPRT file is defined as the Output Printer file.
Definition Specifications
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+...
D+Name++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++++++
D Pay S 8P 2
D Heading1 C 'NUMBER NAME RATE H-
D OURS BONUS PAY '
D Heading2 C '______ ________________ ______ _-
D ____ _______ __________'
D CalcPay PR 8P 2
D Rate 5P 2 VALUE
D Hours 10U 0 VALUE
D Bonus 5P 2 VALUE
Using the definition specifications, declare a variable called "Pay" to hold an
employees' weekly pay and two constants "Heading1" and "Heading2" to aid in the
printing of the report headings.
Calculation Specifications
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+...
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq..
C TRN_NUMBER CHAIN EMP_REC 99
C IF NOT *IN99
C EVAL PAY = CalcPay(EMP_RATE : TRN_HOURS :
C TRN_BONUS)
C ENDIF
The coding entries on the calculation specifications include:
Using the CHAIN operation code, the field TRN_NUMBER from the transaction
file is used to find the record with the same employee number in the employee
file.
If the CHAIN operation is successful (that is, indicator 99 is off), the pay for that
employee is evaluated. The result is "rounded" and stored in the variable called
Pay.
Output Specifications
8 ILE RPG for AS/400 Programmer's Guide