Output pipes

The RSP uses output pipes to return multiple rows of data to the client application. The following code example shows how an RSP uses the SPAREA fields to define an output pipe, then opens, writes to, and closes the output pipe:

MOVE 'OUTPUT' TO SPMODE
 MOVE 'DB2' TO SPFORMAT
 SET ADDRESS OF SPSQLDA TO SQLDA
 CALL 'OPENPIPE' USING SPAREA
 PROGRAM GETS DATA
CALL 'PUTPIPE' USING SPAREA
 CALL 'CLOSPIPE' USING SPAREA
 CALL ‘MESSAGE’ USING SPAREA
 CALL 'STATUS' USING SPAREA

– defines the output pipe – defines output pipe as DB2 format – sets a pointer to the SQLDA – opens the pipewhere your code processes data – writes the record – closes the pipe – writes messages – sends the return code and returns messages and data

For a DB2 format pipe, the SQLDA describes the location and length of the data columns. However, a STD or BIN format pipe requires that the SPRECLEN field contains the length of the data record. It cannot exceed the SPMAXLEN that was specified when the pipe was opened.

An output pipe uses the DB2, STD or Binary format. The DB2 format requires data structure information.

DB2

With the DB2 format, include a SQLDA definition in your RSP when you return data to the client application. You can use these formats to transmit any type of data, not just data from DB2.

The SQLDA is a standard data structure used to define a multi-column result passed to Open ServerConnect. It describes the content of the transmitted data records and, as such, it handles much of the data definition logic that the client application would otherwise have to provide. All files are exchanged between the RSP and MainframeConnect using the SQLDA.

As the RSP programmer, you must define the SQLDA for the data you send to the client and provide a pointer to the SQLDA when you open a data pipe for output. The data structure information passes to Open ServerConnect when the pipe opens. DirectConnect sends this information, in CT-Library format, to the client application.

NoteA SQLDA definition is required for all data pipes in DB2 format.

For DB2 output pipes, the RSP must create a SQLDA definition and pass its address to Open ServerConnect through the SPSQLDA field in the SPAREA.

For sample COBOL-language and C-language SQLDA declarations for DB2 datatypes and more information about the SQLDA, see Appendix G, “The SQLDA” For an extensive discussion of the SQLDA, see the IBM reference manual for DB2 SQL.

For information about STD and BIN output pipes, see “Using output pipes” and “Using concurrent input and output pipes”.