COBOL methods

The generated COBOL program uses methods to exchange data with the COBOL calling program, or to carry out special execution or processing either before or after rule execution.

When you generate a BOM, the BOM contains classes, and the classes have fields (attributes), but classes have no methods. For COBOL code generation you must add them manually.

You use methods to specify conditions and actions in your rules. For example, you might want to calculate the difference between two dates where the answer to the date calculation affects which rules execute or which rule conditions are met. BOM methods operate on the parameters and return values.

When you add a method, you must also implement it in COBOL if you intend to execute your rules using a generated COBOL program. You need this implementation so that the generated COBOL program can call the method. The generated COBOL program uses methods to exchange data with the COBOL calling program, and to carry out special execution or processing either before or after rule execution.

Note:

You do not implement the BOM methods in COBOL if you intend to deploy to zRule Execution Server for z/OS® for rule execution.

You can implement either macro or mapped methods for COBOL:

You can implement COBOL methods using a combination of COBOL code and placeholders. You use placeholders, for example, to keep a place for a COBOL field whose name varies, or for more complex logic. COBOL code generator replaces the placeholder with its matching COBOL code when you generate the COBOL code for rule execution.

You can use the {} placeholder to refer to a COBOL expression. For example:

You can also use the <> placeholder to refer to automatically generated COBOL data items. You can use the <> placeholder only in mapped methods, not in macro methods. See Placeholders, arrays, and nested arrays.

Note:

The COBOL copybook importer automatically creates and implements methods for conditional variables for Level 88 items, so you do not need to implement them manually. For information about how the COBOL importer handles Level 88 data items, see Level 88 data items.