Number rounding

If you intend to execute your rules using generated COBOL code, the method Util.Rounded supports the COBOL ROUNDED clause for rule authoring.

Deprecated feature:

Deprecation icon 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.

The method Util.Rounded supports the COBOL ROUNDED clause for rule authoring. It is defined in the cobol_extension BOM.

In COBOL, when a calculation results in a number that exceeds the number of places provided for its storage, truncation occurs unless you use the ROUNDED clause. When you specify ROUNDED, the least significant digit of the excess is rounded up to the next whole number if the digit is greater than or equal to 5.

For example, if in COBOL you have a COBOL item definition Item, defined as:

01 Item PIC 9V9.

You then write the following rule:

set the value of item to rounded (2.39 + 2.1) ; 

In this example the generated COBOL code is: COMPUTE Item ROUNDED = 4.49, and the value assigned to Item is 4.5.

To use number rounding, you must first import the cobol_extension BOM into your rule project:

  1. In your rule project, right-click the bom folder.

  2. Click COBOL Code Generation > Add COBOL Extension BOM.

The cobol_extension BOM is added to the bom folder in the Rule Explorer.