Site icon AS400 ISeries

ILE RPG, RPG IV Specifications (H, F, D, I, C, O and P)

Specifications in RPGLE

The first thing you should know in RPG IV is that RPG IV is a positional language. This means that we are allowed to write code at specific columns only. In RPGLE every line of code begins with the declaration of specifications. Actually in RPG IV all types of statements have been categorized. The specification tells the compiler which category the coming statement falls into. That’s the RPGLE compiler interprets a specific line of code on the basis of the specification. In RPG IV we have the following main specifications. All these specifications begin on the 6th column.
There are the following specifications in RPG IV (ILE RPG) .

Advertisements

The specifications must appear in the order given above, but it is not necessary to code all the specifications. A module could contain just a single C spec.

Most RPG specifications contain the specification type in column 6. The exception is free-form calculation specifications which are coded between /FREE and /END-FREE directives. Free-form calculations have blanks in column 6 and 7. The examples given in chapter 1 all used free-form calculations.

RPG cycle

RPG was originally created to handle files. The intention was that the program would read a record from the “primary file” and for each record, it would perform the calculations. When it reached the last record, it would close the file and end the program.

To artificially create the “last record” situation, the program could set on the “Last Record” indicator, called *INLR.

For programs that do not have a primary file, it is still necessary to stop the program from looping through the calculations. This can be done two ways:

  1. By using the RETURN operation.
  2. By setting on the Last Record indicator.
       *inlr = '1';

There are subtle differences in these two mechanisms that you will learn in later

Exit mobile version