[Top] [Previous] [Next] [End of Book]

# Appendix E . Sample IMS Client and Server Transactions

BEA Connect TCP for IMS client and server transactions are ordinary IMS MPP transactions that can be written in any application programming language supported by IMS. Source code for the sample transactions in this appendix can be found in the BEA Connect TCP for IMS SOURCE distribution library.

## BEASVR01 - A Sample IMS Server Transaction

An IMS server transaction is one that offers a specified service and processes client requests for that service. A server request takes place according to the following sequence of events:

1. A client transaction running on a remote system makes a request for a service offered by the IMS gateway. The remote gateway forwards the request to the IMS gateway, which formats and inserts a server request message into the IMS Message Queue. The server request message is destined for the IMS server transaction that offers the service (the service name is the transaction code of the IMS server transaction).

2. IMS schedules the specified server transaction, which retrieves the server request message from the IMS Message Queue and performs whatever processing is appropriate. If a response is required, the server transaction formats a server response message (similar in format to the original server request message) and inserts it into the IMS Message Queue destined for the BEA Connect TCP for IMS BMP.

3. BEA Connect TCP for IMS retrieves the server response message from the IMS Message Queue and returns the response to the remote system making the request.

The sample IMS server transaction shown below is a simple echo transaction; that is, it simply returns a response consisting of whatever request data it received.

>     CBL APOST      *****************************************************************
>     FILE:      BEASVR01
>     PURPOSE:   SAMPLE IMS SERVER TRANSACTION FOR USE WITH
>                BEA CONNECT TCP FOR IMS
>     COMMENTS:  THIS IS A SIMPLE ECHO SERVER TRANSACTION THAT ISSUES A
>                RESPONSE CONSISTING OF THE SAME DATA AS RECEIVED.
>     LANGUAGE:  COBOL
>     COPYRIGHT  (C) 1997 BEA SYSTEMS, INC. ALL RIGHTS RESERVED
>     *****************************************************************

>     IDENTIFICATION DIVISION.
>     PROGRAM-ID. BEASVR01.
>     ENVIRONMENT DIVISION.
>     CONFIGURATION SECTION.
>     SOURCE-COMPUTER. IBM-370.
>     OBJECT-COMPUTER. IBM-370.
>     DATA DIVISION.
>     WORKING-STORAGE SECTION.

>     77 GU      PIC X(04) VALUE 'GU '.
>     77 CHNG    PIC X(04) VALUE 'CHNG'.
>     77 ISRT    PIC X(04) VALUE 'ISRT'.
>     77 PURG    PIC X(04) VALUE 'PURG'.

>     01 BEABMP  PIC X(08) VALUE 'BEATCPI '.

>     *****************************************************************
>     *            REQUEST MESSAGE                                   *
>     *****************************************************************
>         01   REQUEST-MESSAGE.
>     (1)      COPY SERVER.
>              05 USER-DATA           PIC X(512).
>     *****************************************************************
>     *                  RESPONSE MESSAGE                             *
>     *****************************************************************
>         01   REQUEST-MESSAGE.
>     (1)      COPY SERVER.
>              05 USER-DATA           PIC X(512).
>            LINKAGE SECTION.
>     ****************************************************************
>     *                  I/O PCB                                     *
>     ****************************************************************
>     01   01 IOPCB.
>          05 LTERM                   PIC X(08).
>          05 FILLER                  PIC X(02).
>          05 IOPCB-STATUS            PIC X(02).
>          05 FILLER                  PIC X(28).
>        *****************************************************************
>     *                  MODIFIABLE ALTERNATE PCB                 *
>     *****************************************************************
>     01   ALTPCB.
>          05 ALTPCB-DEST             PIC X(08).
>          05 FILLER                  PIC X(02).
>          05 ALTPCB-STATUS           PIC X(02).
>          05 FILLER                  PIC X(10).

>          PROCEDURE DIVISION.
>                ENTRY 'DLITCBL' USING IOPCB, ALTPCB.
>                PERFORM IOPCB-GET    THRU IOPCB-GET-EXIT.
>                PERFORM ECHO-MSG     THRU ECHO-MSG-EXIT.
>                PERFORM ISRT-MSG     THRU ISRT-MSG-EXIT.
>                GO TO 9999-RETURN.

>     *****************************************************************
>     *       RETRIEVE THE REQUEST MESSAGE FROM THE IMS QUEUE         *
>     *****************************************************************
>           IOPCB-GET.
>     (2)   CALL 'CBLTDLI' USING GU, IOPCB, REQUEST-MESSAGE.
>           IF IOPCB-STATUS NOT = SPACES
>                    GO TO 9999-RETURN.

>            IOPCB-GET-EXIT.
>     	      EXIT.
>     *****************************************************************
>     *         COMPOSE THE RESPONSE MESSAGE                     *
>     *****************************************************************
>               ECHO-MSG.
>     * THE RESPONSE MESSAGE HAS THE SAME BASIC FORMAT AS
>     * THE REQUEST MESSAGE. WE CHANGE THE TRAN CODE TO THAT
>     * OF THE DESTINATION (BEA BMP). NOTE THAT THE FIELD
>     * BEA-RESERVED MUST BE COPIED INTACT FROM THE
>     * REQUEST MESSAGE TO THE RESPONSE MESSAGE. FOR RE-
>     * SPONSE DATA, WE SIMPLY RETURN THE REQUEST DATA.
>     * HENCE THIS IS AN ECHO TRANSACTION.

>     (4,5)     MOVE REQUEST-MESSAGE TO RESPONSE-MESSAGE.
>     (6)       MOVE BEABMP          TO TRAN-CODE IN RESPONSE-MESSAGE.

>            ECHO-MSG-EXIT.
>                EXIT.
>     *****************************************************************
>     *        INSERT RESPONSE MESSAGE TO IMS QUEUE             *
>     *****************************************************************
>            ISRT-MSG.
>     * IF THE ORIGIN OF A MESSAGE IS A BMP (SUCH AS BEA
>     * CONNECT TCP FOR IMS), THERE WILL BE NO ASSOCIATED
>     * LTERM. IN THIS CASE, THE RESPONSE IS RETURNED TO
>     * THE BMP USING AN ALTERNATE PCB.

>      (3)    IF LTERM = SPACES OR LOW-VALUES
>                 PERFORM ALTPCB-ISRT THRU ALTPCB-ISRT-EXIT
>             ELSE
>                 CALL 'CBLTDLI' USING ISRT, IOPCB, RESPONSE-MESSAGE.
>             IF IOPCB-STATUS NOT = SPACES
>                 GO TO 9999-RETURN.
>     ISRT-MSG-EXIT.
>              EXIT.
>     *****************************************************************
>     *         INSERT RESPONSE MESSAGE TO ALTERNATE PCB              *
>     *****************************************************************
>           ALTPCB-ISRT.
>           *    CHANGE DESTINATION OF MODIFIABLE ALTERNATE PCB TO
>           *    THE TRAN CODE OF THE BEA CONNECT TCP FOR IMS BMP
>      (7,8)     CALL 'CBLTDLI' USING CHNG, ALTPCB, BEABMP.
>                IF ALTPCB-STATUS NOT = SPACES
>                       GO TO 9999-RETURN.
>           *    INSERT THE RESPONSE MESSAGE INTO THE IMS QUEUE
>      (9)       CALL 'CBLTDLI' USING ISRT, ALTPCB, RESPONSE-MESSAGE.
>                IF ALTPCB-STATUS NOT = SPACES
>                       GO TO 9999-RETURN.
>           ALTPCB-ISRT-EXIT.
>                  EXIT.
>            9999-RETURN.
>                   GOBACK.

### Notes

1. The format of the BEA Connect TCP for IMS Server Request/Response Message Header is supplied by a COBOL copybook, SERVER. The equivalent C language header is provided by the BEATCPI.H header file. Both are available in the BEA Connect TCP for IMS INCLUDE distribution library.

2. A GU (Get Unique) call is issued to retrieve the request message from the IMS Message Queue. A server request message is always formatted as a single message segment, so a GN (Get Next) call is not strictly required.

3. Because the request message was generated by a BMP (BEA Connect TCP for IMS), the LTERM field of the IOPCB will be spaces. This is a conventional way of determining that an input message came from a BMP (as opposed to a terminal).

4. The BEA Connect message header is copied from the request message to the response message. Note that the contents of the BEA-RESERVED field must be preserved intact.

5. The USER-DATA (user-defined request data) is simply copied from the request message to the response message.

6. The TRAN-CODE in the response message is set to that of the BEA Connect TCP for IMS BMP (in this example, "BEATCPI"; the name may be different in your installation).

7. Because the response message must be returned to the BEA Connect TCP for IMS BMP, a modifiable Alternate PCB must be used to insert the response message into the IMS Message Queue.

8. A CHNG (Change) call is issued to explicitly set the destination of the response message to the BEA Connect TCP for IMS BMP (i.e., "BEATCPI").

9. An ISRT (Insert) call is issued to insert the message into the IMS Message Queue, returning the response to BEA Connect TCP for IMS.

10. In cases where no response is required, the Server Transaction simply performs any processing required by the request and returns to IMS (without sending a response message to BEA Connect TCP for IMS).

## IMS Client Transactions

An IMS Client Transaction is one that issues a request for a specified remote service made available through BEA Connect TCP for IMS. IMS Client Requests (unlike server requests) are processed in two distinct "phases": a request phase, followed by a response phase. The request and response must be processed by two separate transaction executions (i.e., T1 and T2). A client request takes place according to the following scenario:

### Request Phase

1. The request transaction, T1, executing as an IMS MPP, issues a request for a service provided by a remote gateway by inserting a client request message into the IMS Message Queue. The client request message is destined for the BEA Connect TCP for IMS BMP, and must specify the name (transaction code) of a response transaction (T2).

2. BEA Connect TCP for IMS retrieves the client request message and forwards the request to a remote system which offers the requested service.

### Response Phase

1. When the response (if required) is received, a client response message is formatted and inserted into the IMS Message Queue. The client response message is destined for the specified response transaction (T2).

2. The response transaction is scheduled by IMS and retrieves the client response message from the IMS Message Queue. The client response message contains sufficient information to enable the response transaction to correlate the response with the original request.

## BEACRQ01 - A Sample IMS Client Request Transaction

The sample IMS Client Request Transaction shown below makes a request for a service called TOUPPER, provided by a remote system. The TOUPPER service returns a response consisting of the request data translated to upper-case.

>     CBL APOST
>            IDENTIFICATION DIVISION.
>            PROGRAM-ID. BEACRQ01.
>            ENVIRONMENT DIVISION.
>            CONFIGURATION SECTION.
>            SOURCE-COMPUTER. IBM-370.
>            OBJECT-COMPUTER. IBM-370.
>            DATA DIVISION.
>           WORKING-STORAGE SECTION.

>     77 GU        PIC X(04) VALUE 'GU '.
>     77 CHNG      PIC X(04) VALUE 'CHNG'.
>     77 ISRT      PIC X(04) VALUE 'ISRT'.
>     77 PURG      PIC X(04) VALUE 'PURG'.

>     01 MSG-IN.
>        05 MI-LL        PIC S9(04) COMP VALUE +0.
>        05 MI-ZZ        PIC S9(04) COMP VALUE +0.
>        05 MI-TRANCODE  PIC X(08) VALUE SPACES.
>        05 FILLER       PIC X(01) VALUE SPACES.
>        05 MI-AREA.     PIC X(91) VALUE SPACES.
>        10 MI-DATA

>     (1)    01 CLIENT-REQUEST.
>            05 CRR-LL                 PIC 9(04) COMP VALUE 0.
>            05 CRR-ZZ                 PIC 9(04) COMP VALUE 0.
>            05 CRR-TRANCODE           PIC X(08) VALUE SPACES.
>            05 FILLER                 PIC X(01) VALUE SPACES.
>            05 BEA-RESERVED-1         PIC X(03) VALUE LOW-VALUES.
>            05 CRR-HEADER-LEN         PIC 9(08) COMP.
>            05 CRR-CONTEXT-DATA-LEN   PIC 9(08) COMP.
>            05 CRR-REQUEST-DATA-LEN   PIC 9(08) COMP.
>            05 CRR-MAX-RESPONSE-LEN   PIC 9(08) COMP.
>            05 CRR-REQUEST-TYPE       PIC 9(08) COMP.
>            05 CRR-RESPONSE-FORMAT    PIC 9(08) COMP.
>            05 CRR-ERROR-CODE         PIC 9(08) COMP.
>            05 CRR-REASON-CODE        PIC 9(08) COMP.
>            05 CRR-SERVICE-NAME       PIC X(16) VALUE LOW-VALUES.
>            05 CRR-RESPONSE-TRAN      PIC X(08) VALUE LOW-VALUES.
>            05 CRR-ORIGIN-TERMINAL    PIC X(08) VALUE LOW-VALUES.
>            05 BEA-RESERVED-2         PIC X(16) VALUE LOW-VALUES.
>            05 CRR-CONTEXT-AREA.
>               10 CRR-CONTEXT-DATA    PIC X(31) VALUE SPACES.
>            05 CRR-REQUEST-AREA.
>               10 CRR-REQUEST-DATA    PIC X(100) VALUE SPACES.

>     LINKAGE SECTION.
>     01 IOPCB.
>        05 LTERM          PIC   X(08).
>        05 FILLER         PIC   X(02).
>        05 IOPCB-STATUS   PIC   X(02).
>        05 FILLER         PIC   X(28).
>        01 ALTPCB.
>        05 ALTPCB-DEST    PIC   X(08).
>        05 FILLER         PIC   X(02).
>        05 ALTPCB-STATUS  PIC   X(02).
>        05 FILLER         PIC   X(10).

>           PROCEDURE DIVISION.
>           ENTRY 'DLITCBL' USING IOPCB, ALTPCB.

>     (2)   CALL 'CBLTDLI' USING GU, IOPCB, MSG-IN.
>           IF IOPCB-STATUS NOT = SPACES
>           GO TO 9999-RETURN.

>     (3)   MOVE 'BEATCPI' TO CRR-TRANCODE.
>           MOVE 96 TO CRR-HEADER-LEN.
>           MOVE 1 TO CRR-REQUEST-TYPE.
>           MOVE 0 TO CRR-RESPONSE-FORMAT.
>           MOVE LTERM TO CRR-ORIGIN-TERMINAL.
>           MOVE 'TOUPPER' TO CRR-SERVICE-NAME.
>           MOVE 'BEACRP01' TO CRR-RESPONSE-TRAN.
>           MOVE ALL 'A' TO CRR-REQUEST-DATA.
>           MOVE LENGTH OF CRR-REQUEST-AREA TO
>                CRR-REQUEST-DATA-LEN.
>           MOVE CRR-REQUEST-DATA-LEN TO CRR-MAX-RESPONSE-LEN.

>     (4)   MOVE ALL 'B' TO CRR-CONTEXT-DATA.
>           MOVE LENGTH OF CRR-CONTEXT-AREA TO CRR-CONTEXT-DATA-LEN.

>     (5)   COMPUTE CRR-LL = CRR-REQUEST-DATA-LEN +
>           CRR-CONTEXT-DATA-LEN +
>           CRR-HEADER-LEN.

>     (6,7) CALL 'CBLTDLI' USING CHNG, ALTPCB, CRR-TRANCODE.
>           IF ALTPCB-STATUS NOT = SPACES
>           GO TO 9999-RETURN.

>     (8)   CALL 'CBLTDLI' USING ISRT, ALTPCB, CLIENT-REQUEST.
>           IF ALTPCB-STATUS NOT = SPACES
>           GO TO 9999-RETURN.

>     (9)   CALL 'CBLTDLI' USING PURG, ALTPCB.
>           IF ALTPCB-STATUS NOT = SPACES
>           GO TO 9999-RETURN.

>           9999-RETURN.

>           GOBACK.

### Notes

1. Although not used in the above example, the format of the BEA Connect TCP for IMS Client Request/Response Message Header is supplied by a COBOL copybook, CLIENT. The equivalent C language header is provided by the BEATCPI.H header file. Both are available in the BEA Connect TCP for IMS INCLUDE distribution library.

2. A GU (Get Unique) call is issued to retrieve the terminal input message from the IMS Message Queue.

3. The Client Request Header is initialized as follows:

   - CRR-TRANCODE is set to the transaction code of the BEA Connect TCP for IMS BMP (in this example, "BEATCPI"; the name may be different in your installation).

   - BEA-RESERVED-1 must be initialized to binary zero.

   - CRR-HEADER-LEN is set to the length of the Client Request Header (96 bytes).

   - CRR-REQUEST-TYPE is set to 1, specifying that a response is required.

   - CRR-RESPONSE-FORMAT is set to 0, specifying that the response is to be returned as a single message segment.

   - CRR-ORIGIN-TERMINAL is set to the name of the requesting terminal (LTERM), obtained from the IOPCB.

   - CRR-SERVICE-NAME is set to the name of the service being requested ("TOUPPER"). Note that this must be the name of the service as locally defined to BEA Connect TCP for IMS. This may (or may not) be the same as the name of the service as defined on the remote system which offers the service.

   - CRR-RESPONSE-TRAN is set to the name of the designated response transaction ("BEACRP01").

   - CRR-REQUEST-DATA-LEN is set to the length of user-defined Request Data being sent.

   - CRR-CONTEXT-DATA-LEN is set to the length of any user-defined Context Data included.

   - CRR-MAX-RESPONSE-LEN is set to the maximum amount of Response Data that can be accommodated.

   - BEA-RESERVED-2 must be initialized to binary zero.

4. Context Data is optional and can be any data desired. Typically, Context Data is used by the response transaction to correlate the response with the original request.

5. The length of the message segment (LL) is set to the overall length of the client request message (Header + Context Data + Request Data).

6. Because the client request message is being sent to the BEA Connect TCP for IMS BMP, a modifiable Alternate PCB must be used to insert the message into the IMS Message Queue.

7. A CHNG (Change) call is issued to set the destination to the transaction code of the BEA Connect TCP for IMS BMP (in this example, "BEATCPI"; the name may be different in your installation).

8. An ISRT (Insert) call is issued to insert the client request message into the IMS Message Queue. Although the client request message is formatted as a single message segment in this example, the client request message may be formatted as multiple message segments, if desired.

9. A PURG call is issued to signal that the message is complete; i.e., there are no additional message segments.

10. The requesting transaction does not "wait" on the response. Rather, the specified response transaction will be scheduled by BEA Connect TCP for IMS when processing of the request is complete.

## BEACRP01 - A Sample IMS Client Response Transaction

The sample IMS client response transaction shown below processes the response from a request for a service called TOUPPER, provided by a remote system. The TOUPPER service returns a response consisting of the request data translated to upper-case.

>     CBL APOST
>            IDENTIFICATION DIVISION.
>            PROGRAM-ID. BEACRP01.
>            ENVIRONMENT DIVISION.
>            CONFIGURATION SECTION.
>            SOURCE-COMPUTER. IBM-370.
>            OBJECT-COMPUTER. IBM-370.
>           DATA DIVISION.

>     WORKING-STORAGE SECTION.
>          77 GU     PIC X(04) VALUE 'GU'.
>          77 CHNG   PIC X(04) VALUE 'CHNG'.
>          77 ISRT   PIC X(04) VALUE 'ISRT'.
>          77 PURG   PIC X(04) VALUE 'PURG'.

>     1 MSG-OUT.
>         05 MO-LL                 PIC S9(04) COMP VALUE +0.
>         05 MO-ZZ                 PIC S9(04) COMP VALUE +0.
>         05 MO-TRANCODE           PIC X(08) VALUE SPACES.
>         05 FILLER                PIC X(01) VALUE SPACES.
>         05 MO-AREA
>            10 MO-DATA            PIC X(91) VALUE SPACES.
>     (1) 01 CLIENT-RESPONSE.
>         05 CRR-LL                PIC 9(04) COMP VALUE 0.
>         05 CRR-ZZ                PIC 9(04) COMP VALUE 0.
>         05 CRR-TRANCODE          PIC X(08) VALUE SPACES.
>         05 FILLER                PIC X(01) VALUE SPACES.
>         05 BEA-RESERVED-1        PIC X(03) VALUE LOW-VALUES.
>         05 CRR-HEADER-LEN        PIC 9(08) COMP.
>         05 CRR-CONTEXT-DATA-LEN  PIC 9(08) COMP.

>     (7) 05 CRR-RESPONSE-DATA-LEN PIC 9(08) COMP.
>     (7) 05 CRR-MAX-RESPONSE-LEN  PIC 9(08) COMP.
>         05 CRR-REQUEST-TYPE      PIC 9(08) COMP.
>     (3) 05 CRR-RESPONSE-FORMAT   PIC 9(08) COMP.
>         05 CRR-ERROR-CODE        PIC S9(08) COMP.
>         05 CRR-REASON-CODE       PIC S9(08) COMP.
>         05 CRR-SERVICE-NAME      PIC X(16) VALUE LOW-VALUES.
>         05 CRR-RESPONSE-TRAN     PIC X(08) VALUE LOW-VALUES.
>         05 CRR-ORIGIN-TERMINAL   PIC X(08) VALUE LOW-VALUES.
>         05 BEA-RESERVED-2        PIC X(16) VALUE LOW-VALUES.
>     (6) 05 CRR-CONTEXT-AREA.
>            10 CRR-CONTEXT-DATA   PIC X(31) VALUE SPACES.
>         05 CRR-RESPONSE-AREA.
>            10 CRR-RESPONSE-DATA  PIC X(100) VALUE SPACES.

>         LINKAGE SECTION.

>         01 IOPCB.
>         05 LTERM                 PIC   X(08).
>         05 FILLER                PIC   X(02).
>         05 IOPCB-STATUS          PIC   X(02).
>         05 FILLER                PIC   X(28).
>         01 ALTPCB
>         05 ALTPCB-DEST           PIC   X(08).
>         05 FILLER                PIC   X(02).
>         05 ALTPCB-STATUS         PIC   X(02).
>         05 FILLER                PIC   X(10).
>         01 IOPCB.

>         PROCEDURE DIVISION.
>         ENTRY 'DLITCBL' USING IOPCB, ALTPCB.

>     (2) CALL 'CBLTDLI' USING GU, IOPCB, CLIENT-RESPONSE.
>         IF IOPCB-STATUS NOT = SPACES
>         GO TO 9999-RETURN.

>     (4) IF CRR-ERROR-CODE EQUAL 0 AND

>     (5) CRR-REASON-CODE EQUAL 0
>         THEN MOVE 'PASSED' TO MO-DATA
>         ELSE MOVE 'FAILED' TO MO-DATA.
>         MOVE CRR-TRANCODE TO MO-TRANCODE.
>         MOVE 84 TO MO-LL.

>         CALL 'CBLTDLI' USING CHNG, ALTPCB, CRR-ORIGIN-TERMINAL.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO 9999-RETURN.

>     (8) CALL 'CBLTDLI' USING ISRT, ALTPCB, MSG-OUT.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO 9999-RETURN.

>         CALL 'CBLTDLI' USING PURG, ALTPCB.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO 9999-RETURN.

>         9999-RETURN.

>         GOBACK.

### Notes

1. Although not used in the above example, the format of the BEA Connect TCP for IMS Client Request/Response Message Header is supplied by a COBOL copybook, CLIENT. The equivalent C language header is provided by the BEATCPI.H header file. Both are available in the BEA Connect TCP for IMS INCLUDE distribution library.

2. A GU (Get Unique) call is issued to retrieve the client response message from the IMS Message Queue.

3. CRR-RESPONSE-FORMAT indicates the response format: single segment or multiple-segment, as specified in the original request. If multi-segment response format is specified, the response message consists of three segments: response header, context data, and response data.

4. CRR-ERROR-CODE indicates whether or not an error occurred. If this field is zero, it indicates that the request was successfully processed. Otherwise, an error occurred and the error code identifies the type of error. The error code should always be checked before processing a response.

5. CRR-REASON-CODE may provide additional information when an error is indicated. A value of zero indicates that no additional information is available.

6. Context Data, if present, is preserved from the original request message. Typically, the Context Data is used by the response transaction to correlate the response with the original request.

7. CRR-RESPONSE-DATA-LEN contains the length of any Response Data returned. However, if a truncation error occurred, this field contains the actual (pre-truncated) length of the Response Data. The amount of Response Data returned is truncated to the length specified by CRR-MAX-RESPONSE-LEN.

8. A response indicating success or failure (based on the Error and Reason Codes) is written to the original (requesting) terminal, using the LTERM preserved in CRR-ORIGIN-TERMINAL. Note that a modifiable, Alternate PCB must be used for this purpose.

## BEACRR01 - A Sample IMS Client Request/Response Transaction

If desired, the functionality of the IMS Client Request and Response transactions can be combined into a single application transaction. However, logic must be added to perform the appropriate (request or response) processing based upon the dynamic execution context.

>     CBL APOST
>        IDENTIFICATION DIVISION.
>        PROGRAM-ID. BEACRR01.
>        ENVIRONMENT DIVISION.
>        CONFIGURATION SECTION.
>        SOURCE-COMPUTER. IBM-370.
>        OBJECT-COMPUTER. IBM-370.
>        DATA DIVISION.
>        WORKING-STORAGE SECTION.

>        77 GU          PIC X(04) VALUE 'GU '.
>        77 CHNG        PIC X(04) VALUE 'CHNG'.
>        77 ISRT        PIC X(04) VALUE 'ISRT'.
>        77 PURG        PIC X(04) VALUE 'PURG'.

>     01 MSG-IN.
>        05 MI-LL       PIC S9(04) COMP VALUE +0.
>        05 MI-ZZ       PIC S9(04) COMP VALUE +0.
>        05 MI-TRANCODE PIC X(08) VALUE SPACES.
>        05 FILLER      PIC X(01) VALUE SPACES.
>        05 MI-AREA.
>           10 MI-DATA  PIC X(91) VALUE SPACES.
>      01 MSG-OUT.
>        05 MO-LL       PIC S9(04) COMP VALUE +0.
>        05 MO-ZZ       PIC S9(04) COMP VALUE +0.
>        05 MO-TRANCODE PIC X(08) VALUE SPACES.
>        05 FILLER      PIC X(01) VALUE SPACES.
>        05 MO-AREA.
>           10 MO-DATA  PIC X(91) VALUE SPACES.

>     (1) 01 CLIENT-REQUEST-RESPONSE.
>         05 CRR-LL               PIC 9(04) COMP VALUE 0.
>         05 CRR-ZZ               PIC 9(04) COMP VALUE 0.
>         05 CRR-TRANCODE         PIC X(08) VALUE SPACES.
>         05 FILLER               PIC X(01) VALUE SPACES.
>         05 BEA-RESERVED-1       PIC X(03) VALUE LOW-VALUES.
>         05 CRR-HEADER-LEN       PIC 9(08) COMP.
>         05 CRR-CONTEXT-DATA-LEN PIC 9(08) COMP.
>         05 CRR-REQUEST-DATA-LEN PIC 9(08) COMP.
>         05 CRR-MAX-RESPONSE-LEN PIC 9(08) COMP.
>         05 CRR-REQUEST-TYPE     PIC 9(08) COMP.
>         05 CRR-RESPONSE-FORMAT  PIC 9(08) COMP.
>         05 CRR-ERROR-CODE       PIC 9(08) COMP.
>         05 CRR-REASON-CODE      PIC 9(08) COMP.
>         05 CRR-SERVICE-NAME     PIC X(16) VALUE LOW-VALUES.
>         05 CRR-RESPONSE-TRAN    PIC X(08) VALUE LOW-VALUES.
>         05 CRR-ORIGIN-TERMINAL  PIC X(08) VALUE LOW-VALUES.
>         05 BEA-RESERVED-2       PIC X(16) VALUE LOW-VALUES.
>         05 CRR-CONTEXT-AREA.
>            10 CRR-CONTEXT-DATA  PIC X(31) VALUE SPACES.
>         05 CRR-REQUEST-AREA.
>            10 CRR-REQUEST-DATA  PIC X(100) VALUE SPACES.

>         LINKAGE SECTION.
>     01  IOPCB.
>         05 LTERM                PIC   X(08).
>         05 FILLER               PIC   X(02).
>         05 IOPCB-STATUS         PIC   X(02).
>         05 FILLER               PIC   X(28).
>     01  01 ALTPCB.
>         05 ALTPCB-DEST          PIC   X(08).
>         05 FILLER               PIC   X(02).
>         05 ALTPCB-STATUS        PIC   X(02).
>         05 FILLER               PIC   X(10).

>         PROCEDURE DIVISION.
>         ENTRY 'DLITCBL' USING IOPCB, ALTPCB.
>     (3) IF LTERM = SPACES OR LOW-VALUES
>         THEN PERFORM RESPONSE-MESSAGE THRU RESPONSE-MESSAGE-EXIT
>         ELSE PERFORM REQUEST-MESSAGE THRU REQUEST-MESSAGE-EXIT.

>         9999-RETURN.
>              GOBACK.

>     (4) REQUEST-MESSAGE.
>         CALL 'CBLTDLI' USING GU, IOPCB, MSG-IN.
>         IF IOPCB-STATUS NOT = SPACES
>         GO TO REQUEST-MESSAGE-EXIT.

>         MOVE 'BEATCPI' TO CRR-TRANCODE.
>         MOVE 96 TO CRR-HEADER-LEN.
>         MOVE 1 TO CRR-REQUEST-TYPE.
>         MOVE 0 TO CRR-RESPONSE-FORMAT.
>         MOVE LTERM TO CRR-ORIGIN-TERMINAL.
>         MOVE 'TOUPPER' TO CRR-SERVICE-NAME.
>         MOVE MI-TRANCODE TO CRR-RESPONSE-TRAN.
>         MOVE ALL 'A' TO CRR-REQUEST-DATA.
>         MOVE LENGTH OF CRR-REQUEST-AREA TO CRR-REQUEST-DATA-LEN.
>         MOVE CRR-REQUEST-DATA-LEN TO CRR-MAX-RESPONSE-LEN.
>         MOVE ALL 'B' TO CRR-CONTEXT-DATA.
>         MOVE LENGTH OF CRR-CONTEXT-AREA TO CRR-CONTEXT-DATA-LEN.
>         COMPUTE CRR-LL = CRR-REQUEST-DATA-LEN +
>                          CRR-CONTEXT-DATA-LEN +
>                          CRR-HEADER-LEN.

>         CALL 'CBLTDLI' USING CHNG, ALTPCB, CRR-TRANCODE.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO REQUEST-MESSAGE-EXIT.

>         CALL 'CBLTDLI' USING ISRT, ALTPCB,CLIENT-REQUEST-RESPONSE.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO REQUEST-MESSAGE-EXIT.

>         CALL 'CBLTDLI' USING PURG, ALTPCB.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO REQUEST-MESSAGE-EXIT.

>         REQUEST-MESSAGE-EXIT.
>         EXIT.

>     (5) RESPONSE-MESSAGE.

>         CALL 'CBLTDLI' USING GU, IOPCB, CLIENT-REQUEST-RESPONSE.
>         IF IOPCB-STATUS NOT = SPACES
>         GO TO RESPONSE-MESSAGE-EXIT.
>         IF CRR-ERROR-CODE EQUAL 0 AND
>         CRR-REASON-CODE EQUAL 0
>         THEN MOVE 'PASSED' TO MO-DATA
>         ELSE MOVE 'FAILED' TO MO-DATA.
>         MOVE CRR-TRANCODE TO MO-TRANCODE.
>         MOVE 84 TO MO-LL.

>         CALL 'CBLTDLI' USING CHNG, ALTPCB, CRR-ORIGIN-TERMINAL.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO RESPONSE-MESSAGE-EXIT.

>         CALL 'CBLTDLI' USING ISRT, ALTPCB, MSG-OUT.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO RESPONSE-MESSAGE-EXIT.

>         CALL 'CBLTDLI' USING PURG, ALTPCB.
>         IF ALTPCB-STATUS NOT = SPACES
>         GO TO RESPONSE-MESSAGE-EXIT.

>         RESPONSE-MESSAGE-EXIT.
>         EXIT.

### Notes

1. Although not used in the above example, the format of the BEA Connect TCP for IMS Client Request/Response Message Header is supplied by a COBOL copybook, CLIENT. The equivalent C language header is provided by the BEATCPI.H header file. Both are available in the BEA Connect TCP for IMS INCLUDE distribution library.

2. Because this transaction handles both the request and response, the message may either be from an input terminal (in which case request processing should be performed), or from the BEA Connect TCP for IMS BMP (in which case response processing should be performed). The LTERM field of the IOPCB is used to determine the appropriate processing to be performed.

3. If the LTERM is non-blank, it implies that the message is from a terminal and request processing is indicated. Otherwise (that is, the LTERM is spaces or binary zero), the message is from the BEA Connect TCP for IMS BMP and response processing is indicated.

4. The actual request processing is otherwise identical to that performed by BEACRQ01.

5. The actual response processing is otherwise identical to that performed by BEACRP01.

[Top] [Previous] [Next] [End of Book]