Particular cases of the DO and CO loops
The specific code that is written in Pacbase can contain DO and CO loops. These loops cannot be inserted like the other condition types (DW and IT for example) with the Rational® Programming Patterns subfunction creation wizard. However, they are migrated and you must know how to maintain them.
The DO loop
This loop can be indicated in a subfunction only. It runs a processing between two bounds according to a positive or negative step. The bounds are required whereas the step is optional. An index represents the subfunction code in the work areas.
A SF LIN OPE OPERANDS LVTY CONDITION
BD N COMPATIBILITY VERIFICATION 15DO 1 ITA00M
BD 100 M ZERO T-TA00-00540 (J48BDR)
When the Program that includes this DO subfunction is generated and migrated to Rational Programming Patterns, the following lines are displayed in the COBOL editor:
*N48BD. NOTE *COMPATIBILITY VERIFICATION *.DO
F48BD.
MOVE 1 TO J48BDR
GO TO F48BD-B.
F48BD-A.
ADD 1 TO J48BDR.
F48BD-B.
IF J48BDR > ITA00M
GO TO F48BD-FN.
MOVE ZERO TO T-TA00-00540 (J48BDR).
F48BD-900. GO TO F48BD-A.
F48BD-FN. EXIT.
05 J48BDR PICTURE S9(4) VALUE ZERO.
- Modify the starting bound. This bound is displayed in the first
processing line of the subfunction.Example:
In this example, 1 is the starting bound.MOVE 1 TO J48BDR
- Modify the ending bound. This bound is displayed before the line
that branches to the end of the subfunction.Example:
In this example, ITA00M is the ending bound.IF J48BDR > ITA00M
- Modify the step, if it was indicated. The step is displayed on
the line that starts with ADD or SUBTRACT. Example:
In this example, 1 is the step. It is preceded by ADD because it has a positive value.ADD 1 TO J48BDR.
- Move the subfunction.You can copy and paste it to another location in the code. You must then replace all the references to the old subfunction code with the new subfunction code. You must also create the new JffssR index in the work areas and remove the old index from the following area:
01 INDICES COMPUTATIONAL SYNC.
You can complete these actions with the find and replace wizard. You find the old subfunction and replace it with the new code.
- Create another DO loop.
You can copy and paste an existing DO subfunction. However, to indicate that a processing must be run in a repetitive way, you are advised to insert the Loop insertion snippet. This snippet is available from the Snippets view, in the RPP Snippets category. This snippet inserts a PERFORM COBOL statement.
The CO loop
- The CO loop does not generate anything where it is called. It inserts the variable that is indicated in the condition on all the subfunctions with the nearest lower level.
- The subfunctions that contain the running conditions can be located in various Macros.
A SF LIN OPE OPERANDS LVTY CONDITION
BB N TEST ON TOWN CODE 10CO $1-COVIL
- -- --- --- ----------------------------- ---- ---------
CB N 75001 CASE 15IT "75001"
CB 100 M "PARIS 01" $1-LIVIL
F26BB
000 *N26BB. NOTE *TEST ON TOWN CODE *.
*LV=10
010 *!CO "$1-COVIL"
F26CB
000 *N26CB. NOTE *75001 CASE *.
*IT LV15
"75001"
100 MOVE "PARIS 01" TO $1-LIVIL
*N26BB. NOTE *TEST ON TOWN CODE *.
*F26BB. EXIT.
*N26CB. NOTE *75001 CASE *.IT
F26CB. IF WW00-COVIL =
"75001"
NEXT SENTENCE ELSE GO TO F26CB-FN
MOVE "PARIS 01" TO WW00-LIVIL.
F26CB-900. GO TO F26BB-FN.
F26CB-FN. EXIT.
*N26BB. NOTE *TEST ON TOWN CODE *.
*F26BB. EXIT.
*N26CB. NOTE *75001 CASE *.IT
F26CB. IF WW01-COVIL =
"75001"
NEXT SENTENCE ELSE GO TO F26CB-FN
MOVE "PARIS 01" TO WW01-LIVIL.
F26CB-900. GO TO F26BB-FN.
F26CB-FN. EXIT.
*N26CE. NOTE *TEST ON SPECIFIC CODE *.IT
F26CE.
IF WW00-COVIL =
"75004"
NEXT SENTENCE ELSE GO TO F26CE-FN
MOVE "PARIS 04" TO WW00-LIVIL
F26CE-FN. EXIT.