Page 1 of 1

Allocate dsname in REXX from JCL

PostPosted: Tue Feb 17, 2015 3:11 am
by mig123
Hi.
I insert the date selected from a DB2 table to a file name, for example AAA.BBB.DYYMMDD.
The JCL is difficult.
I wanted to do it in REXX, but I do not know how to pass the filename to the next step.
If I create a set of REXX example.
"ALLOC FILE (MVSF) DA ('' DSName" ') "
and in the JCL
// DD DSN = MVSF && MVSF, UNIT = SYSDA, SPACE = (TRK, (10:10), RLSE)
// DISP = (MOD, PASS), DCB = (RECFM = VB, LRECL = 70, DSORG = PS)
I get an error allocation set RC = 12.
In REXX read the date from the table.

Re: Allocate dsname in REXX from JCL

PostPosted: Tue Feb 17, 2015 4:35 am
by Robert Sample
This is not JCL and will not work, ever:
// DD DSN = MVSF && MVSF, UNIT = SYSDA, SPACE = (TRK, (10:10), RLSE)
// DISP = (MOD, PASS), DCB = (RECFM = VB, LRECL = 70, DSORG = PS)
Furthermore, depending upon what you are expecting to have happen, what you want to do may not be possible at all. Once submitted to the system, JCL cannot be changed -- PERIOD. Hence your desire to pass a data set name from one step to the next requires you to write the data set name to a file and then read that file in the next step (using dynamic allocation on the data set). If you want the data set name in your JCL, you can create a job and submit it through the internal reader to the system -- but it becomes a new job with absolutely no connection to the job that submitted it.

Re: Allocate dsname in REXX from JCL

PostPosted: Tue Feb 17, 2015 2:14 pm
by mig123
Robert, thank for your reply.
I saved to a temp file dsname from REXX.
How to "read that file in the next step (using dynamic allocation on the data set)" ?

Re: Allocate dsname in REXX from JCL

PostPosted: Tue Feb 17, 2015 10:35 pm
by Pedro
I saved to a temp file dsname from REXX.

Show us your JCL.
How to "read that file in the next step (using dynamic allocation on the data set)" ?

In the first step, use NEW,PASS. In the second step, use OLD,PASS. Specify the same temp data set name:
//SUPERC  EXEC PGM=ISRSUPC,PARM=(DELTAL,LINECMP,'','')         
//NEWDD  DD DSN=&SYSUID..OLDFILE,DISP=SHR   
//OLDDD  DD DSN=&SYSUID..NEWFILE,DISP=SHR   
//OUTDD  DD DSN=&&TEMP0,UNIT=SYSVIO,DISP=(NEW,PASS)
//*                                                 
//STEP2    EXEC  PGM=IEBGENER                       
//SYSPRINT DD SYSOUT=*                             
//SYSUT1   DD DISP=(OLD,PASS),DSN=&&TEMP0           
//SYSUT2   DD SYSOUT=H                             
//SYSIN    DD DUMMY                                   

It is not clear how you were planning on reading it: however you do it, you need to refer to the DD name. In the above example, you would need to refer to SYSUT1.

Re: Allocate dsname in REXX from JCL

PostPosted: Wed Feb 18, 2015 1:48 pm
by mig123
OK. In first step of my JCL REXX return dsname with date from database.
//SETDSN EXEC PGM=IKJEFT01,
// PARM='SETDSN &PFILE &DB2 &QULIF &INAME 167'
//SYSPROC DD DISP=SHR,DSN=&XLIB
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD DUMMY
//MVSF DD DSN=&&MVSF,UNIT=SYSDA,SPACE=(TRK,1),DISP=(NEW,PASS)

REXX (selected snippet of code):
/* rexx */
PARSE ARG PREF DB2SYS TABPREF FNAME RLEN
call SELECT_IEP_DATE
say ' DATEP='datep
datez='D'!!substr(datep,3,2)!!substr(datep,6,2)!!substr(datep,9,2) /* DYYMMDD */
mvsfile=pref!!'.'!!datez!!'.'!!fname
QUEUE mvsfile
"EXECIO * DISKW MVSF (FINIS"
exit

In the second step JCL, I would put &&MVSF as filename.
//RUNPROG EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//OUT DD DSN=&&MVSF,DISP=SHR
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DB2A)
...

Re: Allocate dsname in REXX from JCL

PostPosted: Wed Feb 18, 2015 8:41 pm
by prino
You're confusing filename with contents of file. What you want will not work. You need TWO jobs, as you already have been told!

Re: Allocate dsname in REXX from JCL

PostPosted: Thu Feb 19, 2015 10:37 pm
by Pedro
It is not clear to me how the name of the data set will be used. Please elaborate.

Recalling Robert's suggestion:
your desire to pass a data set name from one step to the next requires
1. you to write the data set name to a file and
2. then read that file in the next step (using dynamic allocation on the data set).


Your two step example did #1 above, but did not do #2. How about this, in the second step:
//RUNPROG EXEC PGM=IKJEFT01
//SYSPROC DD DISP=SHR,DSN=&XLIB
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//OUT DD DSN=&&MVSF,DISP=(OLD,PASS)
//SYSUDUMP DD SYSOUT=*
//SYSTSIN DD *
 %GETMYDSN DD(OUT)  /*  rexx exec to read the name */
DSN SYSTEM(DB2A)
...

Where 'GETMYDSN' uses EXECIO on the OUT file to read the name of the actual data set, then uses the ALLOC command to allocate that data set for use in this step?