Maintaining Macros in relation to specific code lines

To maintain the Macros, you must understand how the Macro line numbers are managed in relation to specific code lines. You must also know the rules to replace a Macro with another Macro. If the initial location of specific code lines no longer exists after your updates, warnings are generated. You must then know how to manage them with quick fixes.

Simple case of specific code line insertions

If a specific code line is inserted into the generated COBOL code of a Program, Screen, or Server that calls the Macro, this line is displayed in the Generated code structure view. It remains in the same place upon the next generations between the tag that precedes it and the tag that follows it.
Example: Macro AAASQ2 contains, in subfunction F56BB, a code line 100100 and a code line 200200. In the Program that calls the Macro, a specific code line is added between these two code lines. The content of this new line is displayed as a specific code line in the Generated code structure, between the two tags (F56BB100100 and F56BB210200) that correspond to the two code lines between which the line was inserted.
Figure 1. Specific code line between two Macro lines in the calling Program
This example shows a Macro in the Rational Programming Patterns editor, the Macro lines in the calling Program, and the Generated code structure view. Their contents are described in the preceding explanations.
If you insert lines inside an existing line number, these lines do not create any new tags in the Generated code structure view. The tag of the inserted line then corresponds to the existing lines and the inserted lines. If specific code lines exist in the calling instance, they remain at the same place.
Example: Macro AAASQ2 contains, in subfunction F56BB, a condition line 010 and a code line 100100. In the previous step, a specific code line was added under line 100100 in the COBOL code of the Program that calls the Macro. Now, you add a condition line under line 010 and a code line under line 100100 in the Macro, without specifying any line number. After the calling Program is generated again, the new condition line is generated under line 010. The next condition line comes from another Macro that is merged in the Program. The new code line is generated under line 100100. In the Generated code structure view, the new condition line is included in the F56BB010 tag and the new code line is included in the F56BB100100 tag. The specific code line remains at the same place. There is no nesting problem with the Macros.
Figure 2. Insertion of a condition line and a code line in a Macro
This example shows a Macro in the Rational Programming Patterns editor, the Macro lines in the calling Program, and the Generated code structure view. Their contents are described in the preceding explanations.

Dispatching Macro Lines inside a specific code block

To dispatch Macro lines inside a specific code block of a Program, Screen, or Server, you must insert tags in this specific code. You use these tags to frame the specific code lines and guide the placement of the Macro lines. You can then make sure that the Macro lines are correctly placed in the specific code when Macros are dispatched, even after a Macro call has been added, replaced, or modified. These tags prevent reconciliation errors when the instance is generated or when the Macros are merged.

To indicate that a specific code block must be located before a Macro line, you must frame this block by two lines. On the first line, you enter the tag *{BEFORE FFFSSLIN, where FFSS is the function or subfunction code and LIN is the line number on 3 or 6 characters. On the last line, you enter the tag *}. The specific code block that is framed by these tags will then be displayed before the line LIN of the subfunction FFSS that is indicated in the Macro.

To indicate that a specific code block must be located after a Macro line, you must frame this block by two lines. On the first line, you enter the tag *{AFTER FFFSSLIN, where FFSS is the function or subfunction code and LIN is the line number on 3 or 6 characters. On the last line, you enter the tag *}. The specific code block that is framed by these tags will then be displayed after the line LIN of the subfunction FFSS that is indicated in the Macro.

Example: Macro CLMACR inserts a line 100 in subfunction F33RC. This line 100 is displayed in the generated COBOL code of Program CLPROG, which calls this Macro. A specific code block that contains two lines is inserted in the subfunction F33RC of the Program, after the line that comes from the Macro.
Figure 3. Call of a Macro in a Program that contains a specific code block in the same subfunction
This example shows the Macro source code and the generated code of the Program. Their contents are described in the preceding explanations.
You add a line 200 in the Macro.
Figure 4. New Macro line
This example shows the Macro source code with the new line.
To insert this line 200 between the two specific code lines of the Program, you must insert tags in the specific code. You indicate that the first specific code line must appear before the line 200 of the Macro in the specific code. So, you frame this first specific code line by the tags *{BEFORE F33RC200 and *}. You also indicate that the second specific code line must appear after the line 200 of the Macro in the specific code. So, you frame this second specific code line by the tags *{AFTER F33RC200 and *}.
Figure 5. Insertion of tags in the specific code
This example shows the insertion of the tags in the Program code. The content is described in the preceding explanations.
When you generate the Program again, the line 200 from the Macro is then correctly located between the two specific code lines.
Figure 6. Display of the Macro line inside the specific code block
This example shows that the Macro line 200 is displayed inside the specific code block of the Program. The content is described in the preceding explanations.

Replacing a Macro

This action is not recommended because it can cause inconsistencies when the calling instance is generated again. However, if you must do it, you must select a new Macro whose content is close to the content of the initial Macro. If you replace a Macro that inserts code lines in a subfunction, you must use, in the new Macro, the same line numbers as in the initial Macro, for the lines that frame any specific code lines.

To replace a Macro, open the -CP Lines tab of the calling instance and replace a Macro call with another Macro call directly from the Macro column.. The parameters of the initial Macro are then kept in the new Macro. The specific code lines in the calling instance remain at the same place after a new generation if the new Macro contains the same line numbers as the initial Macro.
Example: Macro AAASQ2 is called in a Program. Macros AAASQ2 and AAASQ6 both insert lines in subfunction F56BB. They both contain two code lines 100100 and a code line 200200.
Figure 7. Replacing a Macro
This example shows two Macros in the Rational Programming Patterns editor. Their contents are described in the preceding explanations.
A specific code line is inserted in the generated code of the calling Program, between the lines that correspond to the code lines 100100 and 200200 of Macro AAASQ2. The specific code line is then placed between tags F56BB100100 and F56BB200200 in the Generated code structure view.
Figure 8. Generated code before the replacement
This example shows the generated code of the subfunction in the Program and the tags in the Generated code structure. Their contents are described in the preceding explanations.
The call to Macro AAASQ2 is replaced by the call to Macro AAASQ6 in the Program. After the replacement and a new generation, the lines that correspond to code lines 100100 and 200200 are now the lines of Macro AAASQ6. The specific code line is in the same place, between tags F56BB100100 and F56BB200200 in the Generated code structure view.
Figure 9. Generated code after the replacement
This example shows the generated code of the subfunction in the Program and the tags in the Generated code structure. Their contents are described in the preceding explanations.

Using the quick fix to replace specific code lines

Problems are detected if the initial place of some specific code lines no longer exists. Such is the case when Macro tags have been modified (subfunction code or line number). The Problems view then displays a warning for each block of misplaced specific code. The warning indicates that the user modifications cannot be carried over to the reconciled code because the initial place no longer exists. The same warning is also displayed in the PDP COBOL editor on the lines of the misplaced specific code block.

To correct the problem, proceed as follows:
  • Move the cursor to the warning. To do that, double-click the warning in the Problems view. You can also access the warning directly in the PDP COBOL editor. In both cases, the warning symbol is adorned with the quick fix symbol Quick fix for the migration reconciliation warnings.
  • Click the warning. The list of the quick fixes is displayed. Double-click Insert the user code with its context here. The specific code block is inserted.
  • Cut and paste the lines to move them to the right place. In the Problems view, the line number of the warning is modified.
  • Click the warning and double-click the quick fix Leave the code as is (Remove the problem). The warning is then removed.
You must proceed likewise for all the warnings with this type.

Feedback