The access method SAM processes files sequentially. This includes searching for a record, updating the record, and writing it back to the file.
As SAM is a record-oriented access method, it carries out the blocking, deblocking and buffering of the records for the user. If two I/O areas are available in the user program, exchange buffer operation can be used. If only one I/O area is provided, no overlapped processing is possible.
SAM is virtually device-independent and permits the processing of files on disks and tapes; tape cartridges are essentially handled like normal magnetic tapes.
Block formats
The SAM access method is capable of processing files with different block formats (see section "Block formats for disk files", and section "Block formats for tape files"). The BLKCTRL operand of the FILE and FCB macros and the BLOCK-CONTROL-INFO operand of the ADD-FILE-LINK command can be used to specify whether a K file or an NK file is to be processed:
BLKCTRL=PAMKEY or BLOCK-CONTROL-INFO=*PAMKEY: A K-SAM file is to be processed.
K-SAM files (Key SAM files) have the conventional "PAMKEY" block format: they are characterized by the fact that DMS management information for each PAM page is held in a separate PAM key located outside the page.
BLKCTRL=DATA/NO or BLOCK-CONTROL-INFO=*WITHIN-DATA-BLOCK/*NO specifies an NK-SAM file.
NK-SAM files (non-key SAM files) have the block format “DATA” or “NO”: They do not contain separate PAM keys. With the block format “DATA”, the DMS management information is kept in a block control field within the PAM page. With SAM, block format “NO” only exists for tape files. No such block-specific management information is supported for the block format “NO”.
With respect to the functional scope, there is no difference between K-SAM and NK-SAM files. When planning files, however, the user must remember that part of each logical block in an NK-SAM file is needed for the block control field and is thus not available for user data (for further details, see section "Logical block in a K-SAM file" and section "Logical block in an NK-SAM file").
SAM functions
SAM supports file processing in both move mode and locate mode. In move mode the system takes responsibility for moving the data records between buffers and the user input/output area. In locate mode the records are processed directly in the input/output buffer and the individual user is responsible for correctly addressing his/her data records. In locate mode it is possible to obtain direct access to a record using the retrieval address which DMS contains in the FCB when the file is created (see section "FCB retrieval address").
The following action macros are available in SAM to control file processing:
Macro | Brief description |
---|---|
GET | Sequential read: the records are returned sequentially; SAM expects that the records will be required in the order in which they were written. |
PUT | Sequential write operations: in move mode the logical routines of the access method carry out the blocking of the records; this means that output to the volume is delayed until the output buffer is full. The buffers are managed automatically by the system. In locate mode the user must deal with the blocking himself/herself. |
PUTX | Write an updated record back to disk (only in locate mode for disk files). |
RELSE | Closes a data block., i.e. for input files the next GET macro will read the next data block, and for output files the next PUT macro will write the contents of the buffer as a data block, and the next record will become the first record in the next data block. (This is necessary in locate mode if the following record does not fit into the current buffer.) |
SETL | Position to a specific block within the file. |
FEOV | For tape files: initiate a tape swap. |
If files are opened as output files (OPEN OUTPUT/EXTEND), SAM interprets each PUT or SETL macro as an end-of-file (EOF) indicator. The last PUT or SETL macro prior to a CLOSE macro for a file thus automatically indicates EOF to the system. If the user wishes to delete all records after a specific record in a file, he/she can use the SETL macro to position to the desired point in the file, and then issue a CLOSE macro to close the file.
For direct access, a retrieval address is made available to the user. The format of this retrieval address is described in detail in section "FCB retrieval address". When a record is written, its retrieval address is made available in the FCB. If the user wishes, he/she can create a new file from this retrieval address data to serve as a basis for subsequent non-sequential processing of this file. The retrieval address is also made available in the FCB after execution of a GET macro. In this case too, therefore, even if the user did not create the file, he/she can still create a secondary file from the retrieval addresses in order to perform subsequent non-sequential processing of the file.
If, in move mode with two output buffers, physical end-of-volume is detected when a data block is written to a tape file, the other buffer (which contains only one record) is written to the other tape. A tape swap is not executed until this has been done.
If a file is to be created in locate mode (OPEN OUTPUT/EXTEND), the start address of the first record to be written is returned to the user, after OPEN, in the register specified in the operand IOREG in the FCB macro. After execution of the PUT macro, this register contains the address for the next higher record. In the case of a file with variable-length records (RECFORM=V), the user also always receives the number of free bytes in the current block: this information is passed in the register he/she specified in the VARBLD operand of the FCB macro.