TDGETREQ

Description

Accepts the next request in a long-running transaction.

Syntax

%INCLUDE SYGWPLI;
01 TDPROC       PTR,
01 RETCODE      FIXED BIN(31),
01 WAIT_OPTION  FIXED BIN(31),
01 REQUEST_TYPE FIXED BIN(31),
01 TRAN_NAME    CHAR(n);
CALL TDGETREQ (TDPROC, RETCODE, WAIT_OPTION,
                REQUEST_TYPE, TRAN_NAME);

Parameters

TDPROC

(I) Handle for this client/server connection. This must be the same value specified in the associated TDACCEPT call. The TDPROC handle corresponds to the connection and command handles in Open Client Client-Library.

RETCODE

(O) Variable where the result of function execution is returned. Its value is one of the codes listed in Table 3-9.

WAIT_OPTION

(I) Wait/do not wait indicator. Indicates what the application should do after a TDGETREQ if no request is present: (1) wait for a new request to arrive, or (2) terminate immediately.

Assign this argument one of the following values:

TDS_TRUE (1)

Wait for input.

TDS_FALSE (0)

Do not wait for input.

Under CICS and MVS: We recommend always coding TDS_FALSE. Coding TDS_FALSE ends the transaction and frees resources if there is nothing left to do. Coding TDS_TRUE causes the transaction to wait.

Under IMS TM: The WAIT_OPTION tells the transaction what to do when the message queue is empty: wait for another request to appear on the queue, or end the transaction.

NoteTo use TDGETREQ properly under the IMS TM implicit API, the transaction must be a WPI transaction, or the message region that the transaction runs in must have PWFI=Y (Pseudo-Wait-For-Input) specified.

REQUEST_TYPE

(O) Type of request to be accepted. Returns one of the following values:

TDS_LANGUAGE_EVENT (1)

Current request is a language request.

TDS_RPC_EVENT (3)

Current request is an RPC.

TDS_DYNAMIC_EVENT (4)

Current request is a dynamic SQL request.

TDS_CURSOR_EVENT (5)

Current request is a cursor request.

TDINFPGM and TDINFRPC also return this information.

NoteThese are new values. The old values (TDS_START_SQL and TDS_START_RPC) still work, but you should use the new values from now on.

TRAN_NAME

(O) Variable where the name of the current CICS, MVS or IMS TM transaction is returned.

Returns

The RETCODE argument can contain any of the return values listed in Table 3-9.

Table 3-9: TDGETREQ return values

Return value

Meaning

TDS_OK (0)

Function completed successfully.

TDS_CONNECTION_FAILED (-4998)

Connection abended. The client/server connection abnormally ended (for example, the LU 6.2 session crashed or the remote transaction abended).

TDS_CONNECTION_TERMINATED (-4997)

Connection closed. The remote partner closed (deallocated) the client/server connection.

TDS_INVALID_PARAMETER (-4)

Invalid parameter value. The value assigned to one or more of the arguments supplied in the call is not valid. The operation failed.

TDS_INVALID_TDPROC (-18)

Error in specifying a value for the TDPROC argument.

TDS_SOS (-257)

Memory shortage. The host subsystem was unable to allocate enough memory for the control block that Gateway-Library tried to create. The operation failed.

Examples

Example 1

The following code fragment illustrates the use of TDGETREQ in a program that uses the IMS TM implicit API. This example is taken from the sample program SYIPSAM1, listed in Appendix E, “Sample RPC Application for IMS TM (Implicit).”

 	/*------------------------------------------------------------------*/
  	/*        WORK AREAS                                                */
  	/*------------------------------------------------------------------*/
          DCL                                                           
              01  GW_LIB_MISC_FIELDS,                                   
                  05  GWL_SPA_PTR           PTR,                        
                  05  GWL_PROC              PTR,                        
                  05  GWL_INIT_HANDLE       PTR,                        
                  05  GWL_RC                FIXED BIN(31),              
                  05  GWL_WAIT_OPTION       FIXED BIN(31),              
                  05  GWL_REQ_TYPE          FIXED BIN(31),              
                  05  GWL_PROG_TYPE         CHAR(04) INIT(‘MPP ‘),      
                  05  GWL_RPC_NAME          CHAR(30); 
	 [rest of work areas] 
  	/*      ------------------------------------------------------------*/
  	/*      set program type to MPP                                     */
  	/*      ------------------------------------------------------------*/
          CALL TDSETPT (GWL_INIT_HANDLE, GWL_RC, GWL_PROG_TYPE,         
                        GWL_SPA_PTR, TDS_NULL, TDS_NULL); .                                   
	 [check return code] 
  	/*      ------------------------------------------------------------*/
  	/*      accept first client request                                 */
  	/*      ------------------------------------------------------------*/
          CALL TDACCEPT (GWL_PROC, GWL_RC, GWL_INIT_HANDLE,             
                         SNA_CONNECTION_NAME, SNA_SUBC); .                                   
	 [check return code; process request] 
	DO WHILE(MORE_MSGS);                                                  
	 [prepare to send results; send reply rows] 
  	/*------------------------------------------------------------------*/
	SEND_DONE:                                                            
  	/*------------------------------------------------------------------*/
	CALL TDSNDDON (GWL_PROC, GWL_RC, TDS_DONE_COUNT,              
                         CTR_ROWS, TDS_ZERO, TDS_ENDRPC); 
	 [check return code] 
          IF PARM_NR_ROWS = 0 THEN                                      
              MORE_MSGS = FALSE;                                        
          ELSE                                                          
             DO;                                                        
                GWL_WAIT_OPTION = TDS_TRUE;                             
                GWL_REQ_TYPE = 0;                                       
                GWL_RPC_NAME = ‘ ‘;                                     
                                                                        
                CALL TDGETREQ (GWL_PROC, GWL_RC,                        
                               GWL_WAIT_OPTION,                         
                               GWL_REQ_TYPE,                            
                               GWL_TRAN_NAME);                           
                                                                        
                SELECT (GWL_RC);                                        
                  WHEN(TDS_OK);                                         
                  WHEN(TDS_CONNECTION_TERMINATED)                       
                         MORE_MSGS = FALSE;                             
                  WHEN(TDS_RESULTS_COMPLETE)                            
                         MORE_MSGS = FALSE;                             
                  OTHERWISE                                             
                      DO;                                               
                         MORE_MSGS = FALSE;                             
                         CALL_NAME = ‘TDGETREQ’;                        
                         CALL DISP_ERROR;                               
                      END;                                              
                 END;  /* SELECT */                                     
             END;    /* END ELSE */                                     
                                                                        
  END;  /* DO WHILE MORE_MSGS = TRUE */                                 

Example 2

The following code fragment illustrates the use of TDGETREQ in a program that uses the IMS TM explicit API. This example is taken from the sample program SYIXSAM1, listed in Appendix D, “Sample RPC Application for IMS TM (Explicit).”

 	/*------------------------------------------------------------------*/
  	/*        WORK AREAS                                                */
  	/*------------------------------------------------------------------*/
          DCL                                                           
              01  GW_LIB_MISC_FIELDS,                                   
                  05  GWL_SPA_PTR           PTR,                        
                  05  GWL_PROC              PTR,                        
                  05  GWL_INIT_HANDLE       PTR,                        
                  05  GWL_RC                FIXED BIN(31),              
                  05  GWL_WAIT_OPTION       FIXED BIN(31),              
                  05  GWL_REQ_TYPE          FIXED BIN(31),              
                  05  GWL_PROG_TYPE         CHAR(04) INIT(‘MPP ‘),      
                  05  GWL_TRAN_NAME         CHAR(30); 
	 [rest of work areas] 
  	/*      ------------------------------------------------------------*/
  	/*      set program type to EXPL                                    */
  	/*      ------------------------------------------------------------*/
          GWL_PROG_TYPE = ‘EXPL’;                                       
                                                                        
          CALL TDSETPT (GWL_INIT_HANDLE, GWL_RC, GWL_PROG_TYPE,         
                        GWL_SPA_PTR, TDS_NULL, TDS_NULL); 
	[check return code]                                
	 /*      ------------------------------------------------------------*/
  	/*      accept first client request                                 */
  	/*      ------------------------------------------------------------*/
          CALL TDACCEPT (GWL_PROC, GWL_RC, GWL_INIT_HANDLE,             
                         SNA_CONNECTION_NAME, SNA_SUBC); 
	 [check return code; process request] 
	DO WHILE(MORE_MSGS); 
	 [prepare to send results; send reply rows] 
  	/*------------------------------------------------------------------*/
	SEND_DONE:                                                            
  	/*------------------------------------------------------------------*/
          IF PARM_NR_ROWS = 0 THEN                                      
             DO;                                                        
               MORE_MSGS = FALSE;                                       
               GWL_SEND_DONE = TDS_ENDRPC;                              
             END;                                                       
          ELSE                                                          
             GWL_SEND_DONE = TDS_ENDREPLY;                              
                                                                        
          CALL TDSNDDON (GWL_PROC, GWL_RC, TDS_DONE_COUNT,              
                         CTR_ROWS, TDS_ZERO, GWL_SEND_DONE); 
	 [check return code]     
	IF PARM_NR_ROWS = 0 THEN                                      
             DO;                                                        
                GWL_WAIT_OPTION = TDS_TRUE;                             
                GWL_REQ_TYPE = 0;                                       
                GWL_RPC_NAME = ‘ ‘;                                     
                                                                        
                CALL TDGETREQ (GWL_PROC, GWL_RC,                        
                               GWL_WAIT_OPTION,                         
                               GWL_REQ_TYPE,                            
                               GWL_TRAN_NAME);                           
                 SELECT (GWL_RC);                                        
                  WHEN(TDS_OK);                                         
                  WHEN(TDS_CONNECTION_TERMINATED)                       
                    DO;                                                 
                       MORE_MSGS = FALSE;                               
                       CALL FREE_STORAGE;                               
                    END;                                                
                WHEN(TDS_RESULTS_COMPLETE)                              
                    DO;                                                 
                       MORE_MSGS = FALSE;                               
                       CALL FREE_STORAGE;                               
                    END;                                                
                OTHERWISE                                               
                    DO;                                                 
                       MORE_MSGS = FALSE;                               
                       CALL_NAME = ‘TDGETREQ’;                          
                       CALL DISP_ERROR;                                 
                    END;                                                
               END;    /* SELECT */                                     
                                                                        
        END;  /* IF */                                                  
                                                                        
     END;    /* DO WHILE MORE_MSGS = TRUE */                            

Usage


TDGETREQ

Use this function in long-running transactions to determine whether more requests are arriving. If more requests are arriving, TDGETREQ:

TDACCEPT cannot be used more than once in an application, and it is always used to accept the first client request received. When a long-running transaction or WFI transaction accepts multiple client requests, the transaction uses TDACCEPT to accept the first request and TDGETREQ to accept subsequent requests. Because all requests do not need to be the same type, TDGETREQ also indicates the type of request. For example, one may be an RPC, the next may be a SQL language request.

For IMS TM users

The implicit API:

The explicit API:

See also

Related functions

Related topics