Processing new files
If your COBOL program writes records to a new file that
will be made available before the program runs, ensure that the file
attributes in the DD
statement, the environment variable,
or the allocation do not conflict with the attributes in the program.
Usually you need to code only a minimum of parameters
when predefining files. But if you need to explicitly set a length
attribute for the data set (for example, you are using an ISPF allocation
panel, or your DD
statement is for a batch job in
which the program uses RECORD CONTAINS 0
), follow
these guidelines:
- For format-V and format-S files, set a length attribute that is 4 bytes larger than that defined in the program.
- For format-F and format-U files, set a length attribute that is the same as that defined in the program.
- If you open the file as
OUTPUT
and write it to a printer, the compiler might add 1 byte to the record length to account for the carriage-control character, depending on theADV
compiler option and the language used in your program. In such a case, take the added byte into account when coding theLRECL
value.
For example, if your program contains the following code
for a file that has variable-length records, the LRECL
value
in the DD
statement or allocation should be 54.
FILE SECTION.
FD COMMUTER-FILE-MST
RECORDING MODE IS V
RECORD CONTAINS 10 TO 50 CHARACTERS.
01 COMMUTER-RECORD-A PIC X(10).
01 COMMUTER-RECORD-B PIC X(50).
related tasks
Processing existing files
Requesting fixed-length format
Requesting variable-length format
Requesting undefined format
Opening QSAM files
Dynamically creating QSAM files
Processing existing files
Requesting fixed-length format
Requesting variable-length format
Requesting undefined format
Opening QSAM files
Dynamically creating QSAM files