RPG – FOR

FOR is used to setup a loop where an index can be set and changed by the setting on the FOR conditions.
ENDFOR or END is used to define the end of the group of operations within the loop.

The starting value of the index is set via an assignment on the FOR row.
BY can be used to set an incremental value. The default value is 1.
TO or DOWNTO is set to define if the incrementation should go up or down and to define what value the index should have to end the loop.

Example

Example RPGIV Fixed Format