Example: Creating a macro method to check data types
A typical usage for a COBOL macro method is to check data types, such as whether an item is alphabetic, numeric, or a space.
About this task
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.
In COBOL, you use the IS ALPHABETIC clause to test whether a data item is numeric. The predefined method Util.isAlphabetic performs this check. This method is verbalized as {0} is Alphabetic.
For example, in the following COBOL item definition, age is a numeric data item:
01 Customer.
05 age PIC 9(3).
To check whether or not the AGE item has been initialized, you can write the following rule:
if
the age of 'the customer' is Numeric
then
set the age of 'the customer' to 30;
You can also add customized Util methods to support other clauses such as IS NUMERIC and IS SPACE.
To use IS NUMERIC, you must first import the cobol_extension BOM into your rule project. To import the extension, right-click the bom folder and then click .
The following procedure describes how to enable alphabetic checks during rule authoring. The principle is the same for enabling space or numeric checking.
Procedure
To add IS ALPHABETIC checking:
Results
You can now include in your rules a test for whether or not a data item is alphabetic.