Sends a request to the server.
COPY CTPUBLIC.
01 COMMAND PIC S9(9) COMP SYNC. 01 RETCODE PIC S9(9) COMP SYNC.
CALL ‘CTBSEND' USING COMMAND RETCODE.
(I) Handle for this client/server operation. This handle is defined in the associated CTBCMDALLOC call.
(O) Variable where the result from an executed function returns. Its value is one of the codes listed under “Return value,” in this section.
CTBSEND returns one of the following values:
Value |
Meaning |
---|---|
CS-SUCCEED (-1) |
The routine completed successfully. |
CS-FAIL (-2) |
The routine failed. This result can indicate that SNA sessions will not come up. |
CS-CANCELLED (-202) |
The routine was cancelled.
|
The following code fragment demonstrates the use of CTBSEND. It is taken from the sample program SYCTSAR5 in Appendix B, “Sample RPC Application.”
*======================================================== *== == *== Subroutine to allocate, send, and process commands == *== == *======================================================== SEND-PARAM. ***************************** * NOW GET A COMMAND HANDLE. * ***************************** MOVE ZERO TO CSL-CMD-HANDLE. CALL 'CTBCMDAL' USING CSL-CON-HANDLE CSL-RC CSL-CMD-HANDLE. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBCMDAL failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF.
************************************************************ * INITIATE THE STORED PROCEDURE "SYR2". THE DATA WILL BE * * RETURNED FROM THE TABLE SYBASE.SAMPLETB. THIS CAN EITHER * * BE A DB2 OR A Adaptive SERVER TABLE DEPENDING ON WHETHER* * THE RPC IS SENT TO A CICS REGION OR A Adaptive SERVER. * ************************************************************ MOVE LOW-VALUES TO CMDSTR. MOVE 4 TO INTARG. STRING 'SYR2' DELIMITED BY SIZE INTO CMDSTR. CALL 'CTBCOMMA' USING CSL-CMD-HANDLE CSL-RC CS-RPC-CMD CMDSTR INTARG CS-UNUSED. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBCOMMAND failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF. ***************************** * SET UP THE RPC PARAMETERS * ***************************** MOVE '@parm1' TO NM-PARM. MOVE 6 TO NMLEN-PARM. MOVE CS-FMT-NULLTERM TO FORMT-PARM. MOVE CS-RETURN TO FMTSTATUS-PARM. MOVE CS-INT-TYPE TO DATATYPE-PARM. MOVE LENGTH OF PARM1 TO DATALEN. MOVE 0 TO PARM1. CALL 'CTBPARAM' USING CSL-CMD-HANDLE CSL-RC DATAFMT-PARM PARM1 DATALEN INDIC. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBPARAM CS-INT-TYPE parm1 failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF. MOVE '@parm2' TO NM-PARM. MOVE 6 TO NMLEN-PARM. MOVE CS-FMT-NULLTERM TO FORMT-PARM. MOVE CS-INPUTVALUE TO FMTSTATUS-PARM. MOVE CS-VARCHAR-TYPE TO DATATYPE-PARM. MOVE PF-DEPT TO PARR-RET. MOVE PF-DEPT-SIZE TO DATALEN. MOVE 255 TO MAXLENGTH-PARM. CALL 'CTBPARAM' USING CSL-CMD-HANDLE CSL-RC DATAFMT-PARM PARM2 DATALEN INDIC. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBPARAM CS-VARCHAR-TYPE parm2 failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF. *************************************** * SEND THE COMMAND AND THE PARAMETERS * *************************************** CALL 'CTBSEND' USING CSL-CMD-HANDLE CSL-RC. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBSEND failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF. SEND-PARAM-EXIT. EXIT.
The following code fragment demonstrates the use of ct_send. It is taken from the sample program SYCTSAA5 in Appendix A, “Sample Language Requests.”
*======================================================== *== == *== Subroutine to allocate, send, and process commands == *== == *======================================================== SEND-COMMAND. *-------------------------------------------------------------- * find out what the maximum number of connections is *-------------------------------------------------------------- CALL 'CTBCONFI' USING CSL-CTX-HANDLE, CSL-RC, CS-GET, CS-MAX-CONNECT, CF-MAXCONNECT, CF-FOUR, CS-FALSE, CF-OUTLEN. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBCONFI CS-GET failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF. *-------------------------------------------------------------- * allocate a command handle *-------------------------------------------------------------- CALL 'CTBCMDAL' USING CSL-CON-HANDLE, CSL-RC, CSL-CMD-HANDLE. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBCMDAL failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF.
*-------------------------------------------------------------- * prepare the language request *-------------------------------------------------------------- MOVE CF-LANG2-SIZE TO PF-STRLEN. CALL 'CTBCOMMA' USING CSL-CMD-HANDLE, CSL-RC, CS-LANG-CMD, CF-LANG2, PF-STRLEN, CS-UNUSED. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBCOMMA CS-LANG-CMD failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF.
*------------------------------------------------------------- * send the language request *------------------------------------------------------------- CALL 'CTBSEND' USING CSL-CMD-HANDLE, CSL-RC. IF CSL-RC NOT EQUAL CS-SUCCEED THEN MOVE SPACES TO MSGSTR STRING 'CTBSEND failed' DELIMITED BY SIZE INTO MSGSTR PERFORM PRINT-MSG PERFORM ALL-DONE END-IF. SEND-COMMAND-EXIT. EXIT.
CTBSEND signals the end of the data to be sent to a server (no more parameters, data, messages) and sends a request to the server.
Sending a request to a server is a three-step process. To send a request to a server, an application:
Initiates the request by calling CTBCOMMAND, which initiates a language request, RPC, or message stream to send to the server.
Describes parameters for the request, using CTBPARAM.
Not all requests require parameters. For example, a remote procedure call may or may not require parameters, depending on the stored procedure or transaction being called.
Calls CTBSEND to send the request stream to the server.
CTBSEND does not wait for a response from the server. An application must call CTBRESULTS to verify the success of the request and to set up the results for processing.
Related functions