Posted: Tue Aug 24, 2004 3:35 pm Post subject: Allocate dataset
I run a REXX EXEC in batch mode to perform EXECIO DISKR on an INPFILE. I can either allocate the input dataset in the JCL or issue a "TSO ALLOC" in the EXEC. Which way is more efficient?
If I allocate a dataset in the JCL, I can get the dataset corresponding to the DSNAME inside the EXEC using TSO LISTALC. Is there a easier way?
TEST1 EXEC:
/* REXX */
/* Get the dataset correpsonding to the DSNAME INPFILE
allocated in JCL */
address TSO
Alloc_DSName = 'INPFILE'
xx = outtrap('REC.')
'LISTALC STATUS'
xx = outtrap("OFF")
InputFile = ''
Do I = Rec.0 to 1 by -1
parse var Rec.I DSName .
If have_file = 1 then do
InputFile = DSName
leave
End
If DSName = Alloc_DSName then have_file = 1
End
say 'Dataset for' Alloc_DSNAME 'is' InputFile
Exit
Output from the JCL:
Dataset for INPFILE is USERID.TEST
I'm from the old school, where the datasets are always allocated in the JCL, rarely within a REXX exec. Usually, I reserve dataset allocations to only those situations that cannot be accomplished in the JCL, such as generating dynamic SYSIN cards. I also tend to code exec's to run as pure REXX (PGM=IRXJCL) as opposed to running under TSO (PGM=IKJEFT01), but again, it's a personal preference, and, the situations I tend to work in mandate it.
I think that you will find that the LISTDSI command is much better suited to your needs. It will return, for an allocated DD, the fully-qualified dataset name associated with the DD, along with a whole bunch of other information about the dataset.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum