When your COBOL program will write records to a new file which is made
available before the program is run, ensure that the file attributes you specify
in the DD statement or the allocation do not conflict with the attributes
you have specified in your program. In most cases, you only need to specify
a minimum of parameters when predefining your files, as illustrated in the
following example of a DD statement related to the FILE-CONTROL and FD entries
in your program:
Figure 1. Example
of JCL, FILE-CONTROL entry, and FD entryJCL DD Statement:
1
//OUTFILE DD DSNAME=OUT171,UNIT=SYSDA,SPACE=(TRK,(50,5)),
// DCB=(BLKSIZE=400)
/*
Enterprise COBOL Program Code:
ENVIRONMENT DIVISION.
INPUT─OUTPUT SECTION.
FILE─CONTROL.
SELECT CARPOOL 2
ASSIGN TO OUTFILE 1
ORGANIZATION IS SEQUENTIAL
ACCESS IS SEQUENTIAL.
.
.
.
DATA DIVISION.
FILE SECTION.
FD CARPOOL 2
LABEL RECORD STANDARD
BLOCK CONTAINS 0 CHARACTERS
RECORD CONTAINS 80 CHARACTERS
Where:
- 1
- The ddname in the DD statement corresponds to
the assignment-name in the ASSIGN clause:
//OUTFILE DD DSNAME=OUT171 …
This
assignment-name points to the
ddname of
OUTFILE in the DD statement.
ASSIGN TO OUTFILE
- 2
- When you specify a file in your COBOL FILE-CONTROL entry, the file must
be described in an FD entry for file-name.
SELECT CARPOOL
FD CARPOOL
If you do need to explicitly specify a length attribute for the data set
(for example, you are using an ISPF allocation panel or if your DD statement
is for a batch job in which the program uses RECORD CONTAINS 0), use the following
rules:
- For format-V and format-S files, specify a length attribute that is 4
bytes larger than what is defined in the program.
- For format-F and format-U files, specify a length attribute that is the
same as what is defined in the program.
- If you open your file as OUTPUT and write it to a printer, the compiler
might add one byte to the record length to account for the carriage control
character, depending on the ADV compiler option and the COBOL language used
in your program. In such a case, take the added byte into account when specifying
the LRECL.
For example, if your program contains the following code for a file with
variable-length records:
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).
The LRECL in your DD statement or allocation should be 54.