//EXER2A   JOB (),'<name>',REGION=0M,
//   MSGCLASS=H,NOTIFY=&SYSUID
//* ***************************************************************
//* The following code is sample code created by IBM Corporation. 
//* This sample code is not part of any standard IBM product and  
//* is provided to you solely for the purpose of assisting you in 
//* the development of your applications.  The code is provided   
//* 'as is', without warranty or condition of any kind.  IBM shall
//* not be liable for any damages arising out of your use of the  
//* sample code, even if IBM has been advised of the possibility  
//* of such damages.                                              
//* ***************************************************************
//MYPROCS JCLLIB ORDER=SYS1.ECOBOL.SIGYPROC
//*
//COBOL EXEC IGYWCL,
//     PARM.COBOL='NODYNAM,LIST,DATA(31),RENT',
//     PARM.LKED='LIST,XREF,LET,MAP,AMODE(31),RMODE(ANY),CALL'
/*
//COBOL.SYSIN  DD  *
       IDENTIFICATION DIVISION.
       PROGRAM-ID. EXER2A.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
      * REG and URG parms
       01 daemongroup                  PIC X(8) VALUE LOW-VALUES.
       01 node-name                    PIC X(8).
       01 server-name                  PIC X(8).
       01 register-name                PIC X(12) VALUE SPACES.
       01 minconn                      PIC 9(8) COMP VALUE 1.
       01 maxconn                      PIC 9(8) COMP VALUE 10.
       01 regopts                      PIC 9(8) COMP VALUE 0.
       01 urgopts                      PIC 9(8) COMP VALUE 0.
       01 rc                           PIC 9(8) COMP VALUE 0.
       01 rsn                          PIC 9(8) COMP VALUE 0.
       01 rv                           PIC 9(8) COMP VALUE 0.
      * INV parms
       01 service-name                 PIC X(255).
       01 service-name-length          PIC 9(8) COMP.
       01 rqst-area                    PIC X(100) VALUE SPACES.
       01 rqst-area-addr               USAGE POINTER.
       01 rqst-area-length             PIC 9(8) COMP VALUE 100.
       01 resp-area                    PIC X(100) VALUE SPACES.
       01 resp-area-addr               USAGE POINTER.
       01 resp-area-length             PIC 9(8) COMP VALUE 100.
       01 wait-time                    PIC 9(8) USAGE BINARY.
       01 rqst-type                    PIC 9(8) COMP VALUE 1.
      * Working Variables
       01 text-msg                     PIC X(40) VALUE SPACES.

      * Procedures Section
       PROCEDURE DIVISION.
       MAINLINE SECTION.
           MOVE 'EXER2A'                       TO register-name.
           MOVE 'cccccc'                       TO daemongroup.
           MOVE 'nnnnnnn'                      TO node-name.
           MOVE 'sssssss'                      TO server-name.
           MOVE 'This is a test message'       TO text-msg.
           MOVE 'ejb/com/ibm/ola/olasample1_echoHome'
                TO service-name.

           INSPECT daemongroup CONVERTING ' ' to LOW-VALUES.

           CALL 'BBOA1REG' USING
                 daemongroup,
                 node-name,
                 server-name,
                 register-name,
                 minconn,
                 maxconn,
                 regopts,
                 rc,
                 rsn.

           IF rc > 0 THEN
             DISPLAY "OLA - BBOA1REG problem -- rc/rsn : " rc "/" rsn
             GO TO Bad-RC
           ELSE
             DISPLAY "Successfully registered into " daemongroup
           END-IF.

           MOVE text-msg TO rqst-area.
           MOVE LENGTH OF rqst-area TO rqst-area-length.
           MOVE rqst-area-length TO resp-area-length.
           SET rqst-area-addr TO ADDRESS OF rqst-area.
           SET resp-area-addr TO ADDRESS OF resp-area.
           INSPECT service-name CONVERTING ' ' to LOW-VALUES.

           CALL 'BBOA1INV' USING
               register-name,
               rqst-type,
               service-name,
               service-name-length,
               rqst-area-addr,
               rqst-area-length,
               resp-area-addr,
               resp-area-length,
               wait-time,
               rc,
               rsn,
               rv.

           IF rc > 0 THEN
             DISPLAY "OLA - BBOA1INV problem, rc/rsn: " rc "/" rsn
             GO TO Bad-RC
           ELSE
             DISPLAY "Message sent: " rqst-area
             DISPLAY "Message back: " resp-area
           END-IF.

           CALL 'BBOA1URG' USING
               register-name,
               urgopts,
               rc,
               rsn.

           IF rc > 0 THEN
             DISPLAY "OLA - BBOA1URG problem -- rc/rsn: " rc "/" rsn
             GO TO Bad-RC
           ELSE
             DISPLAY "Successfully unregistered from " daemongroup
           END-IF.

           GOBACK.

      *  Section used to exit batch if any API returned RC>0

       Bad-RC.
           DISPLAY "OLA - EXITING program due to non-RC=0."
           GOBACK.

/*
//LKED.SYSLIB DD DSN=<your hlq.SCEELKED>,DISP=SHR
//            DD DSN=<your WOLA module loadlib,DISP=SHR
//LKED.SYSLMOD DD DSN=<your_loadlib>(EXER2A),DISP=SHR
//LKED.SYSPRINT DD SYSOUT=*
//LKED.SYSIN  DD  *
  NAME EXER2A(R)
/*
