Creating macro methods

You use macro methods to implement simple COBOL bodies by using COBOL expressions or statements.

About this task

You use macro methods to implement simple COBOL bodies by using COBOL expressions or statements. You add macro methods to a BOM class.

You create a macro method by creating a method in Rule Designer and then implementing the COBOL code for the method. Then, when you generate the COBOL code for rule execution, the generated code can exchange data with the COBOL calling program.

Procedure

To create a macro method:

  1. In Rule Designer, in the Rule Explorer, open the BOM editor for the required class.
  2. On the Class page, in the Members section and then click New.
  3. In the New Member dialog, on the Member page, make the following entries:
    1. Select the Method radio button.
    2. In the Name field, type a name for the method.
    3. Select the required Java™ Type for the method.

      For example, to write a test in a rule if x is greater than y, you add the following method:

      public boolean isGreaterThan

  4. Click Finish to close the New Member dialog.
  5. In the BOM Editor, in the Member verbalization section, type a navigation phrase in the Template field.
  6. Save your work.
  7. To implement the method in COBOL code:
    1. In the Rule Explorer, double-click the new method.
    2. On the Member tab, scroll down to the COBOL method area and then click Create a macro method.
    3. In the COBOL Method Body Editor, write the COBOL code to implement the method.

      A macro method can be only a single line COBOL statement. For example: x > y

      Create macro method
  8. Save your work.

Results

The method is included in the generated COBOL code, and the generated code can exchange data with the COBOL calling program. In the above example, the generated COBOL code becomes: x > y

A common usage for this type of method is the IS ALPHABETIC check described in Example: Creating a macro method to check data types.

Attention:

Take care when implementing a macro method, because the implementation might in some cases generate incorrect COBOL code. For example, MOVE 1+1 TO varItem is the same as MOVE 2 TO varItem. However, TableItem(2, 1) is not equal to TableItem(1+1, 1) because 1+1 is not a valid index in a table data item.

If you are not sure that the macro method code generates correct COBOL code, use a mapped method instead.