What are control levels?
In my program there is I Spec with control levels L1, L2 , AND L3 are associated with three fields of a file as follows
IXXRE 01
I FIELD1L3
I FIELD2L2
I FIELD3L1
*
And further two subroutines are getting invoke depending upon the level value i.e
L1 EXSR xxdsp (L1 at conditional indicator position)
L1 EXSR yydsp (L1 at level position)
What does it mean?
Software/Hardware used:
ASKED:
November 12, 2008 11:00 AM
UPDATED:
November 14, 2008 8:15 PM
Hi,
The L0-L9 indicators are “Level Break” indicators. These indicators are set on when the value in the field in your input specs changes. They are/were commonly used for subtotals and totals in reports.
The reason for the two EXSR statements is the RPG cycle – the EXSR with L1 in the conditional indicator position will be performed each time the statement is encountered and L1 is set on. The EXSR with the L1 at level position (which is probably in your main routine, just before *INLR is seton or the RETURN opcode) will only be performed at “Total time”.
The RPG reference contains more information on the RPG cycle – this is a fairly complex subject on it’s own. Most programmers avoid it these days, but in the days of System/34 and System/36 it was standard practice.
Regards,
Martin Gilbert.
So, in your example, the L1 indicator is turned on when the value in field3 changes. The EXSR with the L1 in the level column will then execute, BEFORE the input fields are read into memory. Usually this outputs totals of some kind. The the input buffer is loaded with the next record (with the “new” field3 value), and the rest of the calc (with no level indicator) runs. The L1 indicator is still on while the first record in this group gets processed. Thus the EXSR with the conditioning L1 and no level get executed on the first record of the new group.
The L2 and L3 work the same way, except that they also turn on all lower indicators. So when field2 changes, both L2 and L1 are seton (even if field3 doesn’t change) and get processed. When field1 changes, L3, L2, L1 all get turned on. The LR indicator that gets turned on at last record, turns on all the “L” indicators, so all totals get processed.
You might also take a look at this flowchart:
RPG Cycle
It is the official RPG logic cycle flow. In your example field1, field2 and field3 are “control fields” for the purposes of this flowchart.
-Phil C