CTBCONALLOC

Description

Allocates a connection handle.

Syntax

COPY CTPUBLIC.
01 CONTEXT PIC S9(9) COMP SYNC.
01 RETCODE PIC S9(9) COMP SYNC.
01 CONNECTION PIC S9(9) COMP SYNC.
CALL 'CTBCONAL' USING CONTEXT RETCODE CONNECTION.

Parameters

CONTEXT

(I) A context structure. The context structure is defined in the program call CSBCTXALLOC. The context structure corresponds to the IHANDLE in the Open ServerConnect Gateway-Library.

If this value is invalid or nonexistent, CTBCONALLOC fails.

RETCODE

(O) Variable where the result from an executed function returns. Its value is one of the codes listed under “Return value,” in this section.

CONNECTION

(O) Handle for this connection. All subsequent Client-Library calls using this connection must use this same name in their CONNECTION argument. The connection handle corresponds to the TDPROC handle in the Open ServerConnect Gateway-Library.

This is the same value used to define the connection to the Open ClientConnect Connection Table.

In case of error, CTBCONALLOC returns LOW-VALUES to this argument.

Returns

CTBCONALLOC returns one of the following values listed in Table 3-7.

Table 3-7: CTBCONALLOC return values

Value

Meaning

CS-SUCCEED (-1)

The routine completed successfully.

CS-FAIL (-2)

The routine failed.

The most common reason for a CTBCONALLOC failure is a lack of adequate memory.

TDS-SOS (-257)

Memory shortage. The mainframe subsystem was unable to allocate enough memory for the control block that CTBCONALLOC was trying to create. The operation failed.

TDS-GWLIB-NO-STORAGE (-17)

Could not get DSA for Gateway-Library.

Examples

Example 1

The following code fragment demonstrates the use of CTBCONALLOC. It is taken from the sample program SYCTSAA5 in Appendix A, “Sample Language Requests”.

    *========================================================
	*==                                                    ==
	*== Subroutine to process input data                   ==
	*==                                                    ==
	*========================================================
        PROCESS-INPUT.
       *********************************
       * ALLOCATE A CONNECTION HANDLE. *
       *********************************
            MOVE ZERO TO CSL-CON-HANDLE.
            CALL 'CTBCONAL' USING CSL-CTX-HANDLE
                                  CSL-RC
                                  CSL-CON-HANDLE.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                 MOVE SPACES TO MSGSTR
                 STRING 'CTBCONAL failed' DELIMITED BY SIZE INTO MSGSTR
                 PERFORM PRINT-MSG
                 PERFORM ALL-DONE
            END-IF.
  
       *******************
       * SET THE USER ID *
       *******************
            CALL 'CTBCONPR' USING CSL-CON-HANDLE
                                  CSL-RC
                                  CS-SET
                                  CS-USERNAME
                                  PF-USER
                                  PF-USER-SIZE
                                  CS-FALSE
                                  OUTLEN.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                 MOVE SPACES TO MSGSTR
                 STRING 'CTBCONPR for user-id failed' DELIMITED BY SIZE
                                                      INTO MSGSTR
                 PERFORM PRINT-MSG
                 PERFORM ALL-DONE
            END-IF.
       ********************
       * SET THE PASSWORD *
       ********************
            CALL 'CTBCONPR' USING CSL-CON-HANDLE
                                  CSL-RC
                                  CS-SET
                                  CS-PASSWORD
                                  PF-PWD
                                  PF-PWD-SIZE
                                  CS-FALSE
                                  OUTLEN.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                 MOVE SPACES TO MSGSTR
                 STRING 'CTBCONPR for password failed' DELIMITED BY SIZE
                                                       INTO MSGSTR
                 PERFORM PRINT-MSG
                 PERFORM ALL-DONE
            END-IF.
       ********************
       * SET THE TRAN NAME *
       ********************
            IF PF-TRAN-SIZE IS NOT EQUAL TO ZEROES THEN
                CALL 'CTBCONPR' USING CSL-CON-HANDLE
                                      CSL-RC
                                      CS-SET
                                      CS-TRANSACTION-NAME
                                      PF-TRAN
                                      PF-TRAN-SIZE
                                      CS-FALSE
                                      OUTLEN
                IF CSL-RC NOT EQUAL CS-SUCCEED
                  THEN
                     MOVE SPACES TO MSGSTR
                     STRING 'CTBCONPR for TRAN name failed'
                            DELIMITED BY SIZE INTO MSGSTR
                     PERFORM PRINT-MSG
                     PERFORM ALL-DONE
                  END-IF
            END-IF.
       *******************************
       * SET THE NET DRIVER PROPERTY *
       *******************************
            IF PF-NETDRV = SPACES OR PF-NETDRV = 'LU62'                X
                                  OR PF-NETDRV = 'lu62'
                MOVE CS-LU62 TO NETDRIVER
            ELSE
              IF PF-NETDRV = 'IBMTCPIP' OR PF-NETDRV = 'ibmtcpip'
                MOVE CS-TCPIP TO NETDRIVER
            ELSE
              IF PF-NETDRV = 'INTERLIN' OR PF-NETDRV = 'interlin'
                MOVE CS-INTERLINK TO NETDRIVER
            ELSE
              IF PF-NETDRV = 'CPIC' OR PF-NETDRV = 'cpic'
                MOVE CS-NCPIC TO NETDRIVER
            END-IF.
            IF PF-DRV-SIZE IS NOT EQUAL TO ZEROES THEN
                CALL 'CTBCONPR' USING CSL-CON-HANDLE
                                      CSL-RC
                                      CS-SET
                                      CS-NET-DRIVER
                                      NETDRIVER
                                      CS-UNUSED
                                      CS-FALSE
                                      OUTLEN
                IF CSL-RC NOT EQUAL CS-SUCCEED
                  THEN
                     MOVE SPACES TO MSGSTR
                     STRING 'CTBCONPR for network driver failed'
                            DELIMITED BY SIZE INTO MSGSTR
                     PERFORM PRINT-MSG
                     PERFORM ALL-DONE
                  END-IF
            END-IF.
       ********************************
       * SET FOR MAINFRAME EXTRA INFO *
       ********************************
            CALL 'CTBCONPR' USING CSL-CON-HANDLE
                                  CSL-RC
                                  CS-SET
                                  CS-EXTRA-INF
                                  CS-TRUE
                                  CS-UNUSED
                                  CS-FALSE
                                  CS-UNUSED.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                 MOVE SPACES TO MSGSTR
                 STRING 'CTBCONPR for extra info failed'
                                    DELIMITED BY SIZE INTO MSGSTR
                 PERFORM PRINT-MSG
                 PERFORM ALL-DONE
            END-IF.
       ***********************************
       * SETUP retrieval of All Messages *
       ***********************************
            CALL 'CTBDIAG' USING CSL-CON-HANDLE,
                                 CSL-RC,
                                 CS-UNUSED,
                                 CS-INIT,
                                 CS-ALLMSG-TYPE,
                                 CS-UNUSED,
                                 CS-UNUSED.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                MOVE SPACES TO MSGSTR
                STRING 'CTBDIAG CS-INIT failed' DELIMITED BY SIZE
                                                       INTO MSGSTR
                PERFORM PRINT-MSG
                PERFORM ALL-DONE
            END-IF.
       *********************************************
       * set the upper limit of number of messages *
       *********************************************
            MOVE 5 TO PF-MSGLIMIT.
            CALL 'CTBDIAG' USING CSL-CON-HANDLE,
                                 CSL-RC,
                                 CS-UNUSED,
                                 CS-MSGLIMIT,
                                 CS-ALLMSG-TYPE,
                                 CS-UNUSED,
                                 PF-MSGLIMIT.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                MOVE SPACES TO MSGSTR
                STRING 'CTBDIAG CS-MSGLIMIT failed' DELIMITED BY SIZE
                                                       INTO MSGSTR
                PERFORM PRINT-MSG
                PERFORM ALL-DONE
            END-IF.
       *************************
       * CONNECT TO THE SERVER *
       *************************
            CALL 'CTBCONNE' USING CSL-CON-HANDLE
                                  CSL-RC
                                  PF-SERVER
                                  PF-SERVER-SIZE
                                  CS-FALSE.
            IF CSL-RC NOT EQUAL CS-SUCCEED
              THEN
                 MOVE SPACES TO MSGSTR
                 STRING 'CTBCONNE failed' DELIMITED BY SIZE INTO MSGSTR
                 PERFORM PRINT-MSG
                 PERFORM ALL-DONE
            END-IF.
            IF NO-ERRORS
              THEN
                PERFORM SEND-COMMAND
            END-IF.

Usage

See also

Related functions