I have two steps in JCL. In first step, the program creates a dynamically allocated output file and the second step has to take that dynamically allocated file in the previous step as input. How to extract the dataset name of the dynamically allocated file. Also I've seen in JESYSMSG of the joblog, we could get the dataset name of dynamically allocated file. But in JCL how to extract it and use it for second step?
Please see the example
//STEP1 EXEC PGM1
//*****SYS061 IS DYNAMICALLY ALLOCATED OUTPUT FILE OF PGM1
//*****LET'S SAY DSNAME OF SYS061 = NOS.SYS061.STEP2.OUTPUT
//STEP2 EXEC PGM2
//SYS010 DD DSN=NOS.SYS061.STEP2.OUTPUT,DIPS=SHR
//*****SYS010 IS THE INPUT OF PGM2 WHICH IS THE OUTPUT OF PREV. STEP
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix
I'm with expat, but if you must do something like this, you could modify the code that dynamically creates the dataset to also write the dataset name into a new PS output file (preferable a jcl statement that would look like "//ddname DD DSN=dynamic.dsn,"). The next step, read the PS file with the dynamically created dataset name DD and write a job thru the internal reader with the "dynamic" dsn in the submitted jcl. This submitted job would be the original "second" step.
This "submitter" could be an IEBGENER or SORT that would copy 3 concatenated jcl files to the internal reader:
File1 - JOB statement and any jcl up to the "dsn" DD statement
File2 - The "dsn" DD statement
File3 - The remainder of the jcl for the submitted job
And now the "second" step will run with the "dynamic dsn".