Chapter 3. Getting started with business rules 69
To deploy rule artifacts to zRule Execution Server for z/OS, follow these steps:
1. Double-click the sharinginsuranceApp project to open the RuleApp editor. Then, in the
Deployment pane, click Deploy to deploy the RuleApp to zRule Execution Server for z/OS.
2. For the deployment type, accept the “Increment RuleApp major version” default option,
and then click Next.
3. Select the “Create a temporary Rule Execution Server configuration” option, and enter the
following details:
URL: http://<your.server.address>:<PORT>/res
Login: resAdmin
Password: resAdmin
4. Click Finish.
Your artifacts are deployed to zRule Execution Server for z/OS. You can build a COBOL
application to invoke the rule execution.
3.3.4 Building a COBOL application for rule execution
You deployed the rule artifacts to zRule Execution Server for z/OS. You can use the
generated copybook to build a COBOL application for rule execution on z/OS, as described in
the following sections.
Generated copybook sample
First, you must know the structure of the generated copybook, as shown in Example 3-6.
Example 3-6 Generated copybook INSSHAR.cpy
01 request.
02 driver.
03 age pic S9(5).
03 first-name pic X(20) value SPACE.
03 house-num pic S9(10).
03 last-name pic X(20) value SPACE.
03 lic-date pic 9(8).
03 lic-status pic X.
88 BoolValue value 'T'.
03 number-accidents pic S9(5).
03 zipcode pic X(20) value SPACE.
02 vehicle.
03 make pic X(20) value SPACE.
03 model pic X(20) value SPACE.
03 vec-id pic X(20) value SPACE.
03 vec-type pic X(20) value SPACE.
03 vec-value usage COMP-1.
01 response.
02 approved pic X.
88 BoolValue value 'T'.
02 base-price usage COMP-2.
02 dis-price usage COMP-2.
02 messages-Num pic 9(9).
02 messages pic X(60) value SPACE Occurs 10 Times.
70 Flexible Decision Automation for Your zEnterprise with Business Rules and Events
COBOL application sample
Now, you can build a COBOL application according to the generated copybook, as shown in
Example 3-7.
Example 3-7 COBOL application INSSHAR.cbl
IDENTIFICATION DIVISION.
PROGRAM-ID. "INSSHAR".
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
* include the generated copybook
COPY INSSHAR.
01 WS-REASON-CODES.
COPY HBRC.
COPY HBRWS.
PROCEDURE DIVISION.
* Init ruleset parameter data
MOVE 'John' TO FIRST-NAME
MOVE 17 TO AGE
MOVE 4 TO NUMBER-ACCIDENTS
……
* Move ruleset path to table HBRA-RA-PARMETERS
……
MOVE "/sharinginsuranceApp/sharinginsurancerules"
TO HBRA-CONN-RULEAPP-PATH
* move ruleset parameter for request and response
MOVE 'request' TO HBRA-RA-PARAMETER-NAME(1)
……
MOVE 'response' TO HBRA-RA-PARAMETER-NAME(2)
……
* Get connection to rule execution server
CALL 'HBRCONN' USING HBRA-CONN-AREA.
……
* Invoke rule execution server
CALL 'HBRRULE' USING HBRA-CONN-AREA
……
* Get disconnect to rule execution server
CALL 'HBRDISC' USING HBRA-CONN-AREA
……
* Display result
DISPLAY "RESPONSE APPROVED: " APPROVED
……
STOP RUN.
Rule execution result
You can compile and run the COBOL application on z/OS. The COBOL application sample in
Example 3-7 on page 70 produces the results that are shown in Example 3-8.
Additional resources: You can find this sample in the additional information that is
included in this book. Refer to Appendix A, “Additional material” on page 259.
Chapter 3. Getting started with business rules 71
Example 3-8 Result of compiling and running the COBOL application
********** EXECUTION RESULT *********
DRIVER NAME: John
RESPONSE APPROVED: F
Reject messages:
Accidents number exceeds the maximum
The age exceeds the maximum or minimum
**************************************
72 Flexible Decision Automation for Your zEnterprise with Business Rules and Events

Get Flexible Decision Automation for Your zEnterprise with Business Rules and Events now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.