An RPG program once typically started off with File Specifications, listing all files being written to, read from or updated, followed by
Data Definition Specifications containing program elements such as Data Structures and dimensional arrays, much like a "Working-Storage" section of a COBOL program or "var" statements in
Pascal. This is followed by Calculation Specifications, which contain the executable instructions. Output Specifications can follow which can be used to determine the layout of other files or reports. Alternatively files, some
data structures and reports can be defined externally, mostly eliminating the need to hand code input and output ("
In the early days of RPG, its major strength was known as the program cycle: every RPG program executes within an implied
loop, which can apply the program to every record of a file. At that time each record (individual punched card) would be compared to each line in the program, which would act upon the record, or not, based upon whether that line had an "indicator" turned "on" or "off" — from a set of logical variables numbered 01–99 for user-defined purposes, or other smaller sets based upon record, field, or report processing functions. The concept of level breaks and matching records is unique to the RPG II language, and was originally developed with card readers in mind.
Since the introduction of the
System 38 in 1979 most RPG programmers discontinued use of the cycle in favor of controlling program flow with standard looping constructs, although IBM has continued to provide backward compatibility for the cycle.