To execute your ruleset, you call the RuleApp from your
COBOL application and pass the ruleset parameters to the rule engine
that is running inside an instance of zRule Execution Server for z/OS.
About this task
This tutorial includes a code sample that you can use to
call a RuleApp from a COBOL application. The following procedure explains
each part of the client code and the steps to follow. You can find
the sample COBOL application in <InstallDir>/studio/tutorials/cobol/bomstartrez/answer/SharingZMiniloan-execution/cobol/HBRMTUT2.COBOL where <InstallDir> is
the Decision Server installation
directory.
Procedure
- Copy in the zRule Execution Server for z/OS runtime
copybooks:
01 WS-REASON-CODES.
COPY HBRC.
COPY HBRWS.
HBRC contains constants
that you can use in your application.
HBRWS contains
the working storage structure used for calling HBRCONN, HBRRULE,
and HBRDISC.
- Add the ruleset parameters:
MOVE LENGTH OF Borrower to HBRA-RA-DATA-LENGTH(1)
MOVE "Borrower“ to HBRA-RA-PARAMETER-NAME(1)
SET HBRA-RA-DATA-ADDRESS(1) to address of Borrower
MOVE LENGTH OF Loan to HBRA-RA-DATA-LENGTH(2)
MOVE "Loan“ to HBRA-RA-PARAMETER-NAME(2)
SET HBRA-RA-DATA-ADDRESS(2) to address of Loan
- Specify the ruleset to call:
MOVE '<your_rule_project_name>' to HBRA-CONN-RULEAPP-PATH
- Connect to zRule Execution Server for z/OS:
call 'HBRCONN' using
HBRA-CONN-AREA
- Call the ruleset and check the return codes:
call 'HBRRULE' using
HBRA-CONN-AREA
IF HBRA-CONN-COMPLETION-CODE = HBR-CC-OK THEN
DISPLAY 'Successful call'
ELSE
DISPLAY 'Error '
HBRA-CONN-COMPLETION-CODE
HBRA-CONN-REASON-CODE
- Disconnect from zRule Execution Server for z/OS:
call 'HBRDISC' using
HBRA-CONN-AREA