DDnames
- DD:
- dd:
- dD:
- Dd:
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.
- How to create a DDname under MVS™ batch
To create a ddname under MVS batch, you must write a JCL DD statement. For the C file PARTS.INSTOCK, you would write a JCL DD statement similar to the following:
//STOCK DD DSN=PARTS.INSTOCK, . . .
UNIX file system files can be allocated with a DD card, as shown in the following example://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 V2R2 Information Roadmap.
- How to create a DDname under TSO
To create a ddname under TSO, you must write an ALLOCATE command. For the declaration shown above for the C file STOCK, you should write a TSO ALLOCATE statement similar to the following:
ALLOCATE FILE(STOCK) DATASET('PARTS.INSTOCK')
You can also allocate UNIX file system files with TSO ALLOCATE commands. For example:ALLOC FI(stock) PATH('/used/parts.stock') PATHOPTS(OWRONLY,OCREAT) PATHMODE(sirwxu,sirwxo,sirwxg)
See z/OS V2R2 Information Roadmap for more information on TSO ALLOCATE.
- How to create a DDname in source code
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().