Using QSAM for File Handling

Our Assembler support includes QSAM-style processing of files with the data set organizations PS and PSU. You define your file with the DCB macro and process it with the OPEN, CLOSE, GET and PUT request macros. QSAM file handling is identified in the DCB by the MACRF options of G, P, or G,P for GET, PUT or GET/PUT. The two-byte COBOL ANSI 85 file status code is available after every file operation at byte 6 in the data control block (DCB).

Your files can have fixed, variable or Micro Focus line sequential record formats. The length of the last record read or written is always available in the LRECL field of the DCB.

In the case of variable-length records, each record is prefixed by a four-byte mainframe-compatible record descriptor word (RDW)

To use Micro Focus line sequential file organization, specify RECFM=T in the DCB. All records are variable length and, whether read or written, must end with ANSI carriage-return and line-feed characters (x"0D0A").

Some of the sample programs provided with our Assembler support illustrate the use of QSAM-style file handling. All of these files are located by default in the %PUBLIC%\Documents\Micro Focus\Enterprise Developer\Samples\Mainframe\Assembler\Classic\QSAM directory:

Program Summary
pgasm04.mlc Uses the input/ouput macro statements to copy a line sequential file. The input file is mf370get.dat; the new output file is mf370put.dat. The program displays the records on the screen as it copies them.
qsamex4.mlc Reads an ANSI text file (line sequential format ) and writes the records to an EBCDIC PS file of 80-character fixed length records. This sample program is very useful for converting ASCII text files into 80-byte EBCDIC card-images to be read by other Assembler programs.