Transmitting fixed-length or variable-length records

STD and BIN format pipes can transmit either fixed- or variable-length records. They are the only data pipe formats that use the SPAREA SPMAXLEN and SPRECLEN properties. SPMAXLEN sets the maximum length for data records to be passed through a data pipe; SPRECLEN specifies the actual length of a particular data record.


Using input pipes

When you define an input pipe to handle fixed-length records, you set SPMAXLEN. The RSP needs to read SPMAXLEN only once. SPRECLEN is not required and is set by MainframeConnect.

For every record sent through an input pipe, MainframeConnect places the record length in SPRECLEN, overwriting the existing SPRECLEN value. You must check this value (record length) for each record after every GETPIPE.

The following table explains how to set input pipes for fixed- or variable-length records.

Table 2-4: Setting input pipes

Fixed-length data

Set SPMAXLEN on the OPENPIPE command to the length of a single data record.

Variable-length data

Set SPMAXLEN; then after each GETPIPE, check SPRECLEN and process the incoming record accordingly. Check SPRECLEN only if it is possible that the client application passes variable-length records.


Using output pipes

For every record sent through an output pipe—that is, before every PUTPIPE—the RSP must place the record length in SPRECLEN. The following table explains how to set output pipes for fixed- or variable-length records.

Table 2-5: Setting output pipes

Fixed-length data

Set SPMAXLEN with the OPENPIPE command.

Variable-length data

Set SPMAXLEN with the OPENPIPE command, then set SPRECLEN with every PUTPIPE.


Using concurrent input and output pipes

If both an input pipe and an output pipe are open simultaneously, the RSP needs to know whether the value in SPMAXLEN reflects the input or output pipe. In addition, depending on whether the data is fixed- or variable-length, the RSP may need to reset or restore and reread the SPRECLEN value for every output data record. The following table summarizes how you set fixed- and variable-length data for concurrent input and output pipes.

Table 2-6: Setting concurrent input and output pipes

Input and output pipes both fixed-length data

If both data records are the same length:

  1. Set SPMAXLEN with each OPENPIPE command.

  2. Check SPRECLEN only if it is possible that the client application passes variable-length records. If this occurs, reset the SPRECLEN value for subsequent PUTPIPE commands.

If the data records are different lengths:

  1. Set SPMAXLEN with each OPENPIPE command. Then set SPRECLEN with each PUTPIPE command.

  2. Check SPRECLEN only if it is possible that the client application passes variable-length records. If this occurs, check the SPRECLEN value for that GETPIPE command, then restore it for subsequent PUTPIPE or GETPIPE commands.

Input and output pipes both variable-length data

  1. Set SPMAXLEN with each OPENPIPE command.

  2. Check SPRECLEN before each GETPIPE and place the value in the GETPIPE command.

  3. Reset SPRECLEN with each PUTPIPE.

Input pipe fixed-length; Output pipe variable- length

Handle as if they were both fixed-length, and of the length set in the output pipe SPMAXLEN.

Input pipe variable- length; Output pipe fixed-length

Handle as if they were both variable-length.