IBM AS/400 Frozen Dessert Maker User Manual


 
Example of an ILE RPG Program
Each RPG IV indicator has a two-character name (for example, LR, 01, H3), and is
referred to in some entries of some specifications just by the two-character name,
and in others by the special name *INxx where xx is the two-character name. You
can use several types of these indicators; each type signals something different.
The positions on the specification in which you define an indicator determine the
use of the indicator. Once you define an indicator in your program, it can limit or
control calculation and output operations.
Indicator variables can be used any place an indicator of the form *INxx may be
used with the exception of the OFLIND and EXTIND keywords on the file
description specifications.
An RPG program sets and resets certain indicators at specific times during the
program cycle. In addition, the state of indicators can be changed explicitly in calcu-
lation operations.
Operation Codes
The RPG IV programming language allows you to do many different types of oper-
ations on your data. Operation codes, entered on the calculation specifications,
indicate what operations will be done. For example, if you want to read a new
record, you could use the READ operation code. The following is a list of the types of
operations available.
Arithmetic operations Indicator-setting operations
Array operations Information operations
Bit operations Initialization operations
Branching operations Memory Management Operations
Call operations Message operation
Compare operations Move operations
Data-Area operations String operations
Date/Time/Timestamp operations Structured programming operations
Declarative operations Subroutine operations
File operations Test operations
Example of an ILE RPG Program
This section illustrates a simple ILE RPG program that performs payroll calcu-
lations.
Problem Statement
The payroll department of a small company wants to create a print output that lists
employees' pay for that week. Assume there are two disk files, EMPLOYEE and
TRANSACT, on the system.
The first file, EMPLOYEE, contains employee records. The figure below shows the
format of an employee record:
EMP_NUMBER
EMP_REC
1 6 22 27
EMP_NAME EMP_RATE
6 ILE RPG for AS/400 Programmer's Guide