IBM AS/400 Manuel D’Utilisation

Page de 489
 
RPG IV Overview
 
 
 Cycle Programming
When a system processes data, it must do the processing in a particular order.
This logical order is provided by:
¹
The ILE RPG compiler
¹
The program code
The logic the compiler supplies is called the program cycle. When you let the
compiler provide the logic for your programs, it is called cycle programming.
The program cycle is a series of steps that your program repeats until an end-of-file
condition is reached. Depending on the specifications you code, the program may
or may not use each step in the cycle.
If you want to have files controlled by the cycle, the information that you code on
RPG specifications in your source program need not specify when records for these
files are read. The compiler supplies the logical order for these operations, and
some output operations, when your source program is compiled.
If you do not want to have files controlled by the cycle, you must end your program
some other way, either by creating an end-of-file condition by setting on the last
record (LR) indicator, by creating a return condition by setting on the return (RT)
indicator, or by returning directly using the RETURN operation.
Note:  No cycle code is generated for subprocedures or when NOMAIN is speci-
fied on the control specification.
Figure 1 shows the specific steps in the general flow of the RPG program cycle.
Write
heading and
detail lines
Get input
record
Perform
total
calculations
Write
total
output
Perform
detail
calculations
LR on
Move fields
Start
Yes
No
End of
program
Figure  1.  RPG Program Logic Cycle
.1/
RPG processes all heading and detail lines (H or D in position 17 of the
output specifications).
4
ILE RPG for AS/400 Programmer's Guide