10.07.2015 Views

Enterprise COBOL for z/OS V4.2 Programming Guide

Enterprise COBOL for z/OS V4.2 Programming Guide

Enterprise COBOL for z/OS V4.2 Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Environment variable values that are in effect at the time of the OPEN statement areused <strong>for</strong> associating <strong>COBOL</strong> file-names to the system file-names (including anypath specifications).The name that you use in the assignment-name of the ASSIGN clause must be thesame as the ddname in the DD statement or the environment variable in the exportcommand.The file-name that you use in the SELECT clause (such as SELECT MASTER) must be thesame as in the FD file-name entry.Two files should not use the same ddname or environment variable name in theirSELECT clauses; otherwise, results could be unpredictable. For example, if DISPLAYoutput is directed to SYSOUT, do not use SYSOUT as the ddname or environmentvariable name in the SELECT clause <strong>for</strong> a file.Example: using different input files:This example shows that you use the same <strong>COBOL</strong> program to access differentfiles by coding a DD statement or an export command be<strong>for</strong>e the programs runs.Consider a <strong>COBOL</strong> program that contains the following SELECT clause:SELECT MASTER ASSIGN TO DA-3330-S-MASTERAAssume the three possible input files are MASTER1, MASTER2, and MASTER3. Be<strong>for</strong>erunning the program, code one of the following DD statements in the job step thatcalls <strong>for</strong> program execution, or issue one of the following export commands fromthe same shell from which you run the program://MASTERA DD DSNAME=MY.MASTER1,. . .export MASTERA=DSN(MY.MASTER1),. . .//MASTERA DD DSNAME=MY.MASTER2,. . .export MASTERA=DSN(MY.MASTER2),. . .//MASTERA DD DSNAME=MY.MASTER3,. . .export MASTERA=DSN(MY.MASTER3),. . .Any reference in the program to MASTER will there<strong>for</strong>e be a reference to the filecurrently assigned to the ddname or environment-variable name MASTERA.Notice that in this example, you cannot use the PATH(path) <strong>for</strong>m of the exportcommand to reference a line-sequential file in the HFS, because you cannot specifyan organization field (S- or AS-) with a line-sequential file.Optimizing buffer and device spaceUse the APPLY WRITE-ONLY clause to make optimum use of buffer and device spacewhen you create a sequential file with blocked variable-length records.With APPLY WRITE-ONLY specified, a buffer is truncated only when the next recorddoes not fit in the unused portion of the buffer. Without APPLY WRITE-ONLYspecified, a buffer is truncated when it does not have enough space <strong>for</strong> amaximum-size record.The APPLY WRITE-ONLY clause has meaning only <strong>for</strong> sequential files that havevariable-length records and are blocked.12 <strong>Enterprise</strong> <strong>COBOL</strong> <strong>for</strong> z/<strong>OS</strong> <strong>V4.2</strong> <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!