Using Free-Format Calcs with Cycle Programs
August 5, 2009 Hey, Ted
|
I use free-format calculations for new development and for existing cycle-less RPG programs. However, I have responsibility for some old programs that use the RPG cycle. Is it possible for me to use free-format calcs in those programs? –Bill Yes, Bill. In the detail calculations (calcs with no level indicator in columns 7 and 8), use the /FREE and /END-FREE directives as you normally would. In the following example, I have added free-format calcs that are to be executed at L1 detail time (before a new control group) and at detail time (for each input record).
C L1 MOVE *ZERO COUNT1
C L1 MOVE *ZERO BALDU1
/free
if *inL1;
cdtdu1 = *zero;
endif;
/end-free
**
C ADD 1 COUNT1 3 0
C ADD BALDUE BALDU1 8 2
/free
cdtdu1 += cdtdue;
/end-free
C INIT CAT LSTNAM:1 CUSNAM 20
For total-time calcs (those with a level indicator in columns 7 and 8), you will need at least one fixed-format calc spec preceding the /FREE directive. The free-format calcs must test the proper control-level indicators. Here I’ve added a free-format calc at L1 total time (i.e., after a control group has been processed).
CL1 ADD COUNT1 COUNTR 3 0
CL1 ADD BALDU1 BALDUR 8 2
/free
if *inL1;
cdtdur += cdtdu1;
endif;
/end-free
If there are no fixed-format total calculations in the program, add a dummy tag, conditioned to the L0 indicator, before the free-format calcs.
CL0 TotalCalcs tag
/free
if *inLR;
status = 'ALLOK';
except LRLine;
endif;
/end-free
–Ted
|

