z/OS DFSMS Using Data Sets
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


QSAM in an Application

z/OS DFSMS Using Data Sets
SC23-6855-00

The term simple buffering refers to the relationship of segments within the buffer. All segments in a simple buffer are together in storage and are always associated with the same data set. Each record must be physically moved from an input buffer segment to an output buffer segment. The record can be processed within either segment or in a work area.

If you use simple buffering, records of any format can be processed. New records can be inserted and old records deleted as required to create a new data set. The following examples of using QSAM use buffers that could have been constructed in any way previously described.

GET-locate, PUT-move, PUTX-output. Processed in an input buffer and moved to an output buffer.

GET-move, PUT-locate. Moved from an input buffer to an output buffer where it can be processed.

GET-move, PUT-move. Moved from an input buffer to a work area where it can be processed and moved to an output buffer.

GET-locate, PUT-locate. Processed in an input buffer, copied to an output buffer, and possibly processed some more.

GET-locate, PUTX-update. Processed in an input buffer and returned to the same data set.

GET-locate, PUT-move/PUTX-output. The GET macro (step A, Figure 1) locates the next input record to be processed.
Figure 1. Simple Buffering with MACRF=GL and MACRF=PM

GET returns a record address in register 1. This address remains valid until the next GET or CLOSE for the DCB. Your program passes the address to the PUT macro in register 0. PUT copies the record synchronously.

The PUTX-output macro can be used in place of the PUT-move macro.

GET-move, PUT-locate. The PUT macro locates the address of the next available output buffer. PUT returns its address in register 1 and your program passes it to the GET macro in register 0.

On the GET macro you specify the address of the output buffer into which the system moves the next input record.

A filled output buffer is not written until the next PUT macro is issued. PUT returns a buffer address before GET moves a record. This means that when GET branches to the end-of-data routine because all data has been read, the output buffer still needs a record. Your program should replace the unpredictable output buffer content with another record, which you might set to blanks or zeros. The next PUT or CLOSE macro writes the record.

GET-move, PUT-move. The GET macro (step A, Figure 2) specifies the address of the work area into which the system moves the next record from the input buffer.
Figure 2. Simple Buffering with MACRF=GM and MACRF=PM

The PUT macro (step B, Figure 2) specifies the address of the work area from which the system moves the record into the next output buffer.

GET-locate, PUT-locate. The GET macro (step A, Figure 3) locates the address of the next available input buffer. GET returns the address in register 1.
Figure 3. Simple Buffering with MACRF=GL and MACRF=PL

The PUT macro (step B, Figure 3) locates the address of the next available output buffer. PUT returns its address in register 1. You must then move the record from the input buffer to the output buffer (step C, Figure 3). Your program can process each record either before or after the move operation.

A filled output buffer is not written until the next PUT, TRUNC or CLOSE macro is issued.

Be careful not to issue an extra PUT before issuing CLOSE or FEOV. Otherwise, when the CLOSE or FEOV macro tries to write your last record, the extra PUT will write a meaningless record or produce a sequence error.

UPDAT mode. When a data set is opened with UPDAT specified (Figure 4), only GET-locate and PUTX-update are supported.
Figure 4. Simple Buffering with MACRF=GL and MACRF=PM-UPDAT Mode

The GET macro locates the next input record to be processed and returns its address in register 1. You can update the record and issue a PUTX macro that will cause the block to be written back in its original location in the data set after all the logical records in that block have been processed.

If you modify the contents of a buffer but do not issue a PUTX macro for that record, the system can still write the modified record block to the data set. This happens with blocked records when you issue a PUTX macro for one or more other records in the buffer.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014