Skip to main content

Reading QSAM Files of Different Record Lengths from the same Cobol program

  • March 23, 2015
  • 0 replies
  • 0 views

We would like to read different QSAM datasets from the same Cobol program but the record lengths in each dataset are of varying lengths. Is this possible?
 
 
 The same Cobol program can be used both on the mainframe and with Micro Focus to do this for QSAM datasets. IBM has supported this since VS Cobol II. Micro Focus has supported this since the days of Mainframe Express. The key is the 'Record Contains 0 Characters' clause. It is an IBM extension to the Cobol Standards. They document it as follows:
                   -----------
Enterprise COBOL for z/OS 5.2.0>Language Reference>Data division>DATA DIVISION--file description entries>RECORD clause>Format 1
http://www-01.ibm.com/support/knowledgecenter/SS6SG3_5.2.0/com.ibm.cobol52.ent.doc/PGandLR/ref/rlfdere1.html#rlfdere1

Format 1 specifies the number of bytes for fixed-length records.

    ___ Format 1 ___________________________________________________________
   |                                                                        |
   | >>__RECORD__ __________ __integer-3__ ____________ _________________>< |
   |             |_CONTAINS_|             |_CHARACTERS_|                    |
   |                                                                        |
  
integer-3
 
Must be an unsigned integer that specifies the number of bytes contained in each record in the file.

The RECORD CONTAINS 0 CHARACTERS clause can be specified for input QSAM files containing fixed-length records; the record size is determined at run time from the DD statement parameters or the data set label. If, at run time, the actual record is larger than the 01 record description, then only the 01 record length is available. If the actual record is shorter, then only the actual record length can be referred to. Otherwise, uninitialized data or an addressing exception can be produced.

Usage note: If the RECORD CONTAINS 0 clause is specified, then the SAME AREA, SAME RECORD AREA, or APPLY WRITE-ONLY clauses cannot be specified.

Do not specify the RECORD CONTAINS 0 clause for an SD entry.
                   -----------
 
Attached to this KB is an Enterprise Developer project using a batch program reading in two QSAM files. One is 500 bytes in length and the other is 32,000 bytes in length. The program opens the files and reads them using their actual record sizes and then it closes the files. It then opens and reads the 500 byte file as if it were a 32K byte file. The reads are processed as IBM documents above and then the file is closed. The program then opens the 32K file and reads it as if it were a 500 byte file, then the file is closed. There is an export of the test server used for defining and running this program using the Eclipse IDE with JIT (Just In Time) debugging available. If you wish to use JIT, just point to the empty Workspace, JITE, in the sub-directory of the project directory structure created from the unzip. Although the test path used was 'c:\\idoitall\\readany', it can be modified to any path once unzipped and the Server's System Directory and the path definition for the environment variable 'a1' under ES-Environment are changed to the new location. The test server can be started from an Enterprise Developer Command Prompt using the sr.bat file if Eclipse JIT debugging is used.

Readany.Zip


#MFDS
#EnterpriseDeveloper

0 replies

Be the first to reply!