The DD statement enables you to write C source programs that are independent of the files and input/output devices they will use. You can modify the parameters of a file (such as LRECL, BLKSIZE, and RECFM) or process different files without recompiling your program.
//STOCK DD DSN=PARTS.INSTOCK, . . .
//STOCK DD PATH='/u/parts.instock',
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=(SIRWXU,SIRWXO,SIRWXG)
When defining DD, do not use DD … FREE=CLOSE for unallocating DD statements. The C library may close files to perform some file operations such as freopen(), and the DD statement will be unallocated.
For more information on writing DD statements, refer to the JCL manuals listed in z/OS Information Roadmap.
ALLOCATE FILE(STOCK) DATASET('PARTS.INSTOCK')
ALLOC FI(stock) PATH('/used/parts.stock') PATHOPTS(OWRONLY,OCREAT)
PATHMODE(sirwxu,sirwxo,sirwxg)
See z/OS Information Roadmap for more information on TSO ALLOCATE.
You can also use the z/OS® XL C/C++ library functions svc99() and dynalloc() to allocate ddnames. See z/OS XL C/C++ Runtime Library Reference for more information about these functions.
You do not always need to describe the characteristics of the data in files both within the program and outside it. There are, in fact, advantages to describing the characteristics of your data in only one place.
Opening a file by ddname may require the merging of information internal and external to the program. If any conflict is detected that will prevent the opening of a file, fopen() returns a NULL pointer to indicate that the file cannot be opened. See z/OS XL C/C++ Runtime Library Reference for more information on fopen().