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:
DDstatement for MVS JCL.ALLOCATEcommand 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
DDstatement:(1) //OUTFILE DD DSNAME=MY.OUT171,UNIT=SYSDA,SPACE=(TRK,(50,5)) /* - Environment variable (
exportcommand):(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
ASSIGNclause points to the ddnameOUTFILEin theDDstatement or the environment variableOUTFILEin theexportcommand://OUTFILE DD DSNAME=OUT171 . . ., orexport OUTFILE= . . .
- (2)
- When you specify a file file-name in a
FILE-CONTROLentry, you must describe the file in anFDentry:SELECT CARPOOL . . . FD CARPOOL