A typical usage of a COBOL macro method is to include an
external paragraph file in the generated COBOL code.
About this task
Deprecated feature:
The COBOL code generation feature
is deprecated in V8.5. This feature will be removed in a future release
of the product. Use the COBOL Generation Project Migration wizard
to migrate your Rules for COBOL project to a zRule
Execution Server for z/OS® compatible
rule project. See Deprecated features for migration
details.
You
can use COBOL mapped method to include an external paragraph file
in the generated COBOL code and perform actions in your rules that
are defined in an external COBOL file. If you want to perform actions
in your rules that are defined in an external COBOL file, you can
include the file in the PROCEDURE SECTION of the generated COBOL code.
You include an external paragraph file using a macro method.
Procedure
To include an external paragraph file:
- Define the required paragraph or paragraphs in an external
file. For example, a file named EXTERNAL-PARA has
two paragraphs:
PARAGRAPH-1.
IF AMOUNT > 2000
MOVE 1 TO FLAG
END-IF.
PARAGRAPH-2.
IF TYPES ='DOLLAR'
MOVE 1 TO ACCEPTED
END-IF.
- In Rule
Designer,
create methods to include the paragraphs you have defined. For example,
using the paragraphs in Step 1, add the following methods:
- Scroll down to the COBOL Method section
of the BOM Editor.
- To implement the performAmountCheck () method:
- In the Outline view, click Create a macro
method.
- In the COBOL Method Body Editor, add the following line
of COBOL code to implement the method.
PERFORM
PARAGRAPH-1
- To implement the performTypeCheck () method,
create it as a macro method and then add the following code:
PERFORM
PARAGRAPH-2
- Save your work.
You can now write the action
part of the rule as follows:
then
perform Amount Check ;
perform Type Check ;
- When you generate the COBOL code, specify the external
filename to include the file in the PROCEDURE SECTION of the COBOL
code. You specify the external filename as a project property:
- In the Rule Explorer, right-click the rule project and
then select Properties > .
- On the COBOL Code Generation properties
page, in the Procedure Copy field, enter the
name of the external file.
- Click OK to close the Properties page.
Results
In the following example, the PROCEDURE DIVISION of the
generated COBOL code includes an external file named EXTERNAL-PARA:
PROCEDURE DIVISION.
* Rule testExternalParagraph
RULE-1TESTEXTERNALPARAGRAPH.
PERFORM PARAGRAPH-1.
PERFORM PARAGRAPH-2.
.
.
.
COPY EXTERNAL-PARA
.
.
.