DocBag

Back issue

Reusing a temporary dataset in the same step

For historical reasons, a passed temporary dataset is only intended to be "received" once in the same job step. For example: //S1 EXEC PGM=somepgm //OUT1 DD DISP=(,PASS),UNIT=SYSDA,DSN=&&DSN,SPACE=.... //S2 EXEC PGM=otherpgm //IN2 DD DISP=(OLD,PASS),DSN=&&DSN //IN3 DD DISP=(OLD,PASS),DSN=&&DSN The temporary dataset &&DSN will not be found for the second DD statement IN3 in step S2 because it has already been used once by DD statement IN2.

However, by referring to the information from IN2, it is possible to use the same temporary dataset again in the same step:

//S1 EXEC PGM=somepgm //OUT1 DD DISP=(,PASS),UNIT=SYSDA,DSN=&&DSN,SPACE=.... //S2 EXEC PGM=otherpgm //IN2 DD DISP=(OLD,PASS),DSN=&&DSN //IN3 DD DISP=(OLD,PASS),DSN=*.IN2,VOL=REF=*.IN2 This technique can also be used to refer to a temporary dataset created within the same job step: //S1 EXEC PGM=somepgm //OUT1 DD DISP=(,PASS),UNIT=SYSDA,DSN=&&DSN,SPACE=.... //IN1 DD DISP=(OLD,PASS),DSN=*.OUT1,VOL=REF=*.OUT1 Here, the temporary dataset created on DD statement OUT1 can be reused as an input in the same job step via DD statement IN1.

Other examples of the use of this technique can be found in the samples of the use of the DFSORT SPLICE operator found in the document linked from the page Smart DFSORT Tricks

Feedback

Comments or suggestions can be sent to the author.

Last Month's Issue

Big Iron