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.

This loop cannot be created in Rational Programming Patterns but it is migrated. It is represented by the Fffss subfunction, which contains the generated code of the loop, and by the associated JffssR index in the work areas. In the PDP COBOL editor and the Macro COBOL editor, it is preceded by a comment line with a *.DO annotation. The next lines contain the generated code.
Example: A DO loop is indicated in subfunction 48BD in the following way in Pacbase:
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.
In the work areas, the associated index is generated under 01 INDICES on the following line:
Example:
05        J48BDR PICTURE S9(4) VALUE   ZERO.
You can update the generated code of the subfunction in the following ways:
  • Modify the starting bound. This bound is displayed in the first processing line of the subfunction.
    Example:
      MOVE        1                        TO J48BDR
    In this example, 1 is the starting bound.
  • Modify the ending bound. This bound is displayed before the line that branches to the end of the subfunction.
    Example:
      IF          J48BDR                   >  ITA00M 
    In this example, ITA00M is the ending bound.
  • Modify the step, if it was indicated. The step is displayed on the line that starts with ADD or SUBTRACT.
    Example:
      ADD         1                        TO J48BDR.
    In this example, 1 is the step. It is preceded by ADD because it has a positive value.
  • 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

This loop can be indicated in a subfunction only. It runs instructions that are exclusive of one another and that depend on the possible values of a variable. Only the variable name is indicated in the CO subfunction. The instructions are described on the following lines on IT subfunctions with a lower level. The condition is the value of the variable that corresponds to each instruction.
Note: A subfunction is considered to be of a lower level if its level number is greater.
The CO loop is retrieved in Rational Programming Patterns as a CO micropattern, in Macros only. The following reasons explain this restriction:
  • 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.
Example: In Pacbase, a CO loop is indicated in the subfunction 26BB of a Macro. It is followed by IT subfunctions. In the following example, only the first IT subfunction is indicated. This IT subfunction will be run if the $1-COVIL variable has a 75001 value:
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
This CO loop is retrieved in Rational Programming Patterns by the *!CO "$1-COVIL" line, where CO is a micropattern:
 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 
When the Program that calls the Macro is generated, the CO micropattern is expanded and the following lines appear in the code in the COBOL editor:
 *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. 
The CO micropattern inserts the value to be tested only on subfunctions with the nearest lower level in the Macro. It never modifies the specific code.
Example: In the previous example, a specific F26CE subfunction is created and the value of the $1 parameter is modified. After a new generation, the CO loop recognizes the new parameter but the specific F26CE subfunction is not modified.
 *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.

Feedback