Optional: Adding API calls to a z/OS client application to send batched requests

Instead of sending a single set of parameters, you can send a batch of parameters from a COBOL client application to the zRule Execution Server for z/OS®.

About this task

Use the HBRA-CONN-AREA data area to pass the RuleApp path and multiple sets of input parameters and to receive the outputs of the ruleset execution for each set of the parameters provided.

The following data set members contain the information that you need to code the API calls:
  • ++HBRHLQ++.SHBRCOBC(HBRWS) contains the HBRA-CONN-AREA data area
  • ++HBRHLQ++.SHBRCOBC(HBRC) contains the copybook for the completion codes and the reason codes

The steps in the procedure include examples that are taken from the source code for the Miniloan sample application. The Miniloan application executes a set of loan eligibility rules against financial data for a batch of borrowers. A message then states whether their loans are approved or disapproved. To view the COBOL source code for the entire application, refer to the following ++HBRHLQ++.SHBRCOBS data set members: HBRMINBB

Procedure

  1. Include the required z/OS data models. For example, the following code includes the reason codes from the HBRC data set member and the working storage variables from the HBRWS data set member.
    01 WS-REASON-CODES.
     COPY HBRC.
     COPY HBRWS.
  2. Connect to an instance of IBM Decision Server for z/OS:
    call 'HBRCONN' using
       HBRA-CONN-AREA.
  3. Initialize the values to be passed to the Decision Server for z/OS instance. For example, the following code sets the RuleApp path and the ruleset parameters for a batch of 100 Borrower(s) and Loan(s):
            MOVE "/MiniLoanDemoRuleApp/MiniLoanDemo" TO
               HBRA-CONN-RULEAPP-PATH
    
            PERFORM UNTIL WS-PCOUNT = 100
    
                 CALL 'HBRPUTN' USING HBRA-CONN-AREA
    
                 CALL 'HBRPUTP' USING HBRA-CONN-AREA, BORROWER(WS-PCOUNT), BY CONTENT LENGTH OF BORROWER(WS-PCOUNT), Z"borrower"
    
                 COMPUTE WS-LOAN-LENGTH = LENGTH OF LOAN(WS-PCOUNT) + (LENGTH OF MESSAGES OF LOAN(WS-PCOUNT) * 99)
    
                 CALL 'HBRPUTP' USING HBRA-CONN-AREA, LOAN(WS-PCOUNT), WS-LOAN-LENGTH, BY CONTENT Z"loan".
    
                 ADD 1              TO WS-PCOUNT
              END-PERFORM
    Note: You must always call HBRPUTN before you call HBRPUTP for the next set of parameters.
  4. Execute the ruleset by using the HBRA-CONN-AREA data area to specify inputs.
    call 'HBRRULE' using
       HBRA-CONN-AREA.

    If you are using a zRule Execution Server for z/OS server group member, the HBRA-CONN-SSID field returns the subsystem ID of the server that completed the execution of the ruleset. If ruleset execution cannot complete, this field is set to blanks.

  5. If an API call executes successfully, IBM® Decision Server for z/OS returns the following outputs:
    • Execution results
    • A completion code of HBR-CC-OK in HBRA-CONN-COMPLETION-CODE
    • A reason code of HBR-RC-NONE in HBRA-CONN-REASON-CODE

    For example, in the following code zRule Execution Server for z/OS returns the status of the loan requests along with the name of the Borrower.Example for COBOL:

                PERFORM UNTIL WS-GCOUNT = 100
    
                 CALL 'HBRGETN' USING HBRA-CONN-AREA
                 
                 IF  HBRA-CONN-COMPLETION-CODE = HBR-CC-ERROR OR
                     HBRA-CONN-COMPLETION-CODE = HBR-CC-SEVERE THEN
             
                    DISPLAY WS-PROGRAM ' --'
                     '-CC->'  HBRA-CONN-COMPLETION-CODE
                     '-RC->'  HBRA-CONN-REASON-CODE
                     '-MSG->' HBRA-RESPONSE-MESSAGE
                 ELSE
                    CALL 'HBRGETP' USING HBRA-CONN-AREA, LOAN(WS-GCOUNT), BY CONTENT Z"loan"          
    
                   DISPLAY WS-PROGRAM  '-'
                    '-name->' name
                    ' -loan amount->' amount
                    ' -approved->' approved
                 END-IF
    
                ADD 1              TO WS-GCOUNT
              END-PERFORM

    If an API call does not execute successfully, IBM Decision Server for z/OS returns a non-zero completion code and response code. If additional diagnostic information is available, IBM Decision Server for z/OS also returns a response message in HBRA-RESPONSE-MESSAGE.

    Note: You must always call HBRGETN before you call HBRGETP to get the next set of parameters
  6. Disconnect from the IBM Decision Server for z/OS instance:
    call 'HBRDISC' using
       HBRA-CONN-AREA.