IBM AS/400 Frozen Dessert Maker User Manual


 
RPG IV Overview
2 RPG reads the next record and sets on the record identifying and
control level indicators.
3 RPG processes total calculations (conditioned by control level indicators
L1 through L9, an LR indicator, or an L0 entry).
4 RPG processes all total output lines (identified by a T in position 17 of
the output specifications).
5 RPG determines if the LR indicator is on. If it is on, the program ends.
6 The fields of the selected input records move from the record to a proc-
essing area. RPG sets on field indicators.
7 RPG processes all detail calculations (not conditioned by control level
indicators in positions 7 and 8 of the calculation specifications). It uses
the data from the record at the beginning of the cycle.
The first cycle
The first and last time through the program cycle differ somewhat from other cycles.
Before reading the first record the first time through the cycle, the program does
three things:
handles input parameters, opens files, initializes program data
writes the records conditioned by the 1P (first page) indicator
processes all heading and detail output operations.
For example, heading lines printed before reading the first record might consist of
constant or page heading information, or special fields such as PAGE and *DATE.
The program also bypasses total calculations and total output steps on the first
cycle.
The last cycle
The last time a program goes through the cycle, when no more records are avail-
able, the program sets the LR (last record) indicator and the L1 through L9 (control
level) indicators to
on
. The program processes the total calculations and total
output, then all files are closed, and then the program ends.
Subprocedure logic
The general flow of a subprocedure is much simpler: the calculations of a subpro-
cedure are done once, and then the subprocedure returns. There is no cycle code
generated for a subprocedure.
Indicators
An indicator is a one-byte character field that is either set on ('1') or off ('0'). It is
generally used to indicate the result of an operation or to condition (control) the
processing of an operation. Indicators are like switches in the flow of the program
logic. They determine the path the program will take during processing, depending
on how they are set or used.
Indicators can be defined as variables on the definition specifications. You can
also use RPG IV indicators, which are defined either by an entry on a specification
or by the RPG IV program itself.
Chapter 1. Overview of the RPG IV Programming Language 5