The DSN (or DSNAME) parameter specifies the name of a data set that a job step is creating or accessing. It identifies the specific data set to be allocated or processed by the program. The DSN parameter is one of the most fundamental parameters on the DD statement, as it establishes the connection between a program and the data it needs to process.
12//ddname DD DSN=dataset.name,other-parameters //ddname DD DSNAME=dataset.name,other-parameters
1//ddname DD DSN=&&tempname,other-parameters
1//ddname DD DSN=dataset.name(member),other-parameters
123//ddname DD DSN=gdg.name(+1),other-parameters //ddname DD DSN=gdg.name(0),other-parameters //ddname DD DSN=gdg.name(-1),other-parameters
Format | Description | Example |
---|---|---|
Standard | Normal data set name | DSN=SYS1.PROCLIB |
Temporary | Temporary data set with double ampersands | DSN=&&TEMP |
Member | Member of a partitioned data set (PDS) | DSN=SYS1.PROCLIB(IEFBR14) |
GDG | Generation Data Group with relative generation number | DSN=ACCT.MASTER(+1) |
Concatenation | Multiple data sets combined (no DSN on continuation) | Multiple DD statements without ddnames |
Referback | Reference to previous DSN | DSN=*.stepname.ddname |
1//INFILE DD DSN=SYS1.PAYROLL.DATA,DISP=SHR
Refers to the cataloged data set SYS1.PAYROLL.DATA
1234//OUTFILE DD DSN=USER.NEW.DATASET, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,5)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920)
Creates a new data set USER.NEW.DATASET with the specified attributes
1234//TEMPFILE DD DSN=&&TEMPDS, // DISP=(NEW,DELETE), // SPACE=(TRK,(5,1)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800)
Creates a temporary data set that exists only for the duration of the job
1//MEMBER DD DSN=SYS1.PARMLIB(IEAIPS00),DISP=SHR
Refers to member IEAIPS00 in the partitioned data set SYS1.PARMLIB
1234//GDGFILE DD DSN=PROD.SALES.DATA(+1), // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(50,10)), // DCB=(RECFM=FB,LRECL=200,BLKSIZE=27800)
Creates a new generation (+1) in the GDG PROD.SALES.DATA
123//INPUTALL DD DSN=PROD.CURRENT.DATA,DISP=SHR // DD DSN=PROD.HISTORY.DATA,DISP=SHR // DD DSN=PROD.ARCHIVE.DATA,DISP=SHR
Concatenates three data sets to be processed sequentially by the program
123456//STEP1 EXEC PGM=SORT //SORTIN DD DSN=INPUT.DATA,DISP=SHR //SORTOUT DD DSN=SORTED.DATA,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,5)),DCB=(*.SORTIN) //STEP2 EXEC PGM=REPORT //INPUT DD DSN=*.STEP1.SORTOUT,DISP=SHR
STEP2 refers back to the data set created in STEP1
Format | Refers to | Example |
---|---|---|
*.stepname.ddname | Data set name from a DD in a previous step | DSN=*.STEP1.OUTPUT |
*.stepname.procstepname.ddname | Data set name from a DD in a procedure step | DSN=*.STEP1.PROC1.OUTPUT |
*.ddname | Data set name from a DD in the same step | DSN=*.INPUT |
Temporary data sets are identified using double ampersands (&&) and exist only for the duration of the job. They are automatically deleted at the end of the job.
123//TEMP DD DSN=&&TEMPDS,DISP=(NEW,PASS),SPACE=(TRK,(1,1)) //STEP2 EXEC PGM=PROG2 //INPUT DD DSN=&&TEMPDS,DISP=(OLD,DELETE)
If DSN is omitted for a NEW data set, the system generates a unique name. This is not recommended for most situations as it makes the data set difficult to identify.
1//SYSUT1 DD DISP=(NEW,DELETE),SPACE=(TRK,(1,1)) // System-generated name
Data set names can include symbolic parameters that are resolved during job execution.
123456//PROCSTEP PROC DATE=20230101 //OUTFILE DD DSN=PROD.DATA.D&DATE,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(10,5)) // PEND //* //STEP1 EXEC PROCSTEP,DATE=20240515
The final data set name would be PROD.DATA.D20240515
Pattern | Purpose | Example |
---|---|---|
High-level qualifier (HLQ) | Organization by owner/project | SYS1.xxxxx , USER.xxxxx |
Application identifiers | Group data sets by application | PAYROLL.MASTER , INVENTRY.DATA |
Date/time qualifiers | Time-based organization | SALES.D20240101 , BACKUP.MONTHLY.JAN |
Function identifiers | Purpose of the data set | ACCT.MASTER.BACKUP , SALES.REPORT.INPUT |
Environment qualifiers | Indicate system environment | DEV.PAYROLL.DATA , PROD.SALES.HISTORY |
1//INVALID DD DSN=USER.FILE-NAME!,DISP=SHR // ! is not valid
1//TOOLONG DD DSN=USER.VERYLONGQUAL.DATA,DISP=SHR // VERYLONGQUAL exceeds 8 chars
1//NUMSTART DD DSN=1DATA.FILE,DISP=SHR // Cannot start with a number
1//BADTEMP DD DSN=&TEMP,DISP=(NEW,DELETE) // Should be &&TEMP
1//NOPAREN DD DSN=SYS1.PARMLIB.MEMBER1,DISP=SHR // Should be SYS1.PARMLIB(MEMBER1)
1//BADGDG DD DSN=ACCOUNT.MASTER+1,DISP=OLD // Should be ACCOUNT.MASTER(+1)