Defining files to the operating system
For all files that you process in your COBOL program, you need to define the files to the operating system with an appropriate system data definition.
About this task
Depending on the operating system, this system data definition can take any of the following forms:
DD
statement for MVS JCL.ALLOCATE
command under TSO.- Environment variable for z/OS® or z/OS UNIX. The contents can define either an MVS data set or a file in the z/OS UNIX file system.
The following examples show the
relationship of a FILE-CONTROL
entry to the system
data definition and to the FD
entry in the FILE
SECTION
:
- JCL
DD
statement:(1) //OUTFILE DD DSNAME=MY.OUT171,UNIT=SYSDA,SPACE=(TRK,(50,5)) /*
- Environment variable (
export
command):(1) export OUTFILE=DSN(MY.OUT171),UNIT(SYSDA),SPACE(TRK,(50,5))
- COBOL code:
ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT CARPOOL ASSIGN TO OUTFILE (1) ORGANIZATION IS SEQUENTIAL. . . . DATA DIVISION. FILE SECTION. FD CARPOOL (2) LABEL RECORD STANDARD BLOCK CONTAINS 0 CHARACTERS RECORD CONTAINS 80 CHARACTERS
- (1)
- The assignment-name in the
ASSIGN
clause points to the ddnameOUTFILE
in theDD
statement or the environment variableOUTFILE
in theexport
command://OUTFILE DD DSNAME=OUT171 . . .
, orexport OUTFILE= . . .
- (2)
- When you specify a file file-name in a
FILE-CONTROL
entry, you must describe the file in anFD
entry:SELECT CARPOOL . . . FD CARPOOL