logic cycle

The RPG Logic Cycle

AttachmentSize
RPG_Logic_Cycle.pdf11.82 KB

The logic cycle is the backbone of the RPG programming language. Perhaps it's use has faded in recent years but it can still be used as effectively in modern RPG language as it could in RPG2... if you feel the urge  ;)

So, regardless of wether you want to code modern or *cough* old styley.... lets see what the 'logic cycle' offers:

Tthe first and last time the program goes through the cycle is slightly different from all the in-between cycle runs:

Before the first record is read the first time through the cycle, the program resolves any parameters passed to it, writes the records conditioned by the First Page (1P) indicator, does file and data initialization, and processes any heading or detail output operations. This may also include printing heading lines.

During the last time a program goes through the cycle, when no more records are available, the LR (last record) indicator and L1 through L9 (control level) indicators are set on, and file and data area cleanup is done.

At the most basic level think of the logic cycle as a simple tool for handling all file reading for you. As simple breakdown of the cycle is this:

 

 

 

 

 

 1 
All heading and detail lines (H or D in position 17 of the output specifications) are processed.
 2 
The next input record is read and the record identifying and control level indicators are set on.
 3 
Total calculations are processed. They are conditioned by an L1 through L9 or LR indicator, or an L0 entry.
 4 
All total output lines are processed. (identified by a T in position 17 of the output specifications).
 5 
It is determined if the LR indicator is on. If it is on, the program is ended.
 6 
The fields of the selected input records are moved from the record to a processing area. Field indicators are set on.
 7 
All detail calculations are processed (those not conditioned by control level indicators in positions 7 and 8 of the calculation specifications) on the data from the record read at the beginning of the cycle.

Before you get too scared

Realistically no body would use the logic cycle anymore... not since the mid 90's anwyay....  modularized approach is obviously the favoured technique. Phew I hear you say. But if you want to see more then a more detailed breakdown of the cycle is attached.

 

Subscribe to RSS - logic cycle

Some Bloke

Projex dot com is the cyber home of Nick Litten an AS400 IBMi developer, RPG programmer, SOA code enthusiast, website tinkerer, information technology evangelist, early adopter, proponent of open source and hopeless technology addict...

Nick Litten looking dazed while refactoring some RPG2 code to kick it into this century

Born and raised in Rainy England, now enjoying programming in the sunshine of Southern USA. Founder of SOFTWARE PROJEX.

Clustermap

Locations of visitors to this page

glqxz9283 sfy39587stf02 mnesdcuix8
sfy39587stf03
sfy39587stf04