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. lv10
*N26CB. NOTE *75001 CASE *.IT
F26CB. IF WW00-COVIL = lv15
"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. lv10
*N26CB. NOTE *75001 CASE *.IT
F26CB. IF WW01-COVIL = lv15
"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. lv15
IF WW00-COVIL =
"75004"
NEXT SENTENCE ELSE GO TO F26CE-FN
MOVE "PARIS 04" TO WW00-LIVIL
F26CE-FN. EXIT.
You can transform the dependent subfunctions of a CASE OF execution condition into an EVALUATE COBOL statement if all these subfunctions are specific. The CO loop can be written entirely with specific code (without a micropattern in this case) or can consist in a call to the CO micropattern in a Macro with all the dependent subfunctions written with specific code.
To transform a CO loop into an EVALUATE statement, open the Generated Code Structure view of the Program, Screen, or Server that calls the Macro. Right-click the subfunction that contains the CO and select . This choice can be selected only if the Generated language in the Definition tab of the Library of the Program, Screen, or Server is D: COBOL II, 85, LE. The variable is then tested for all the dependent subfunctions of the CO and a branching to the processing of each subfunction is added.
- In the subfunction that contains the CO, the following statements are inserted:
- EVALUATE <variable>. In this statement, variable represents the variable that is the target of the CASE OF condition.
- WHEN. Such a statement is inserted for each dependent subfunction. It is inserted as WHEN <value> PERFORM <Fffss> THRU <Fffss-FN>. In this line, Fffss is the code of the dependent subfunction and value is the value that is tested in this subfunction.
- WHEN OTHER. This statement is inserted for the last dependent subfunction that processes the other cases. If this subfunction does not exist, the statement is not inserted.
- END-EVALUATE.
- GO TO <Fffss> -FN, where Fffss is the code of the current subfunction.
- In the dependent subfunctions of the CO loop, the following elements are deleted:
- IT after the subfunction title,
- Condition lines (IF...NEXT SENTENCE ...),
- Line -900.
*N26BB. NOTE *TEST ON TOWN CODE *.
F26BB. lv10
EVALUATE WW00-COVIL
WHEN ‘75001’
PERFORM F26CB THRU F26CB-FN
END-EVALUATE.
GO TO F26BB-FN.
*N26CB. NOTE *75001 CASE *.
F26CB. lv15
MOVE "PARIS 01" TO WW00-LIVIL. .
F26CB-FN. EXIT.
*F26BB. EXIT.
- The dependent subfunctions of the CASE OF come from specific code and Macros.
- The variable that is the target of the CASE OF cannot be identified.
- The structure of the CASE OF is not respected. Such is the case, for example, when a condition on several lines in a dependent subfunction makes it impossible to write the EVALUATE statement.
If a CASE OF micropattern is defined in a Macro and if all its dependent subfunctions are written with specific code, the code is transformed. However, the CO micropattern is irrelevant in the Macro. A warning is displayed upon the generation to inform the user.