Page 1 of 1

DSLIST in REXX program in Batch mode.

PostPosted: Sun May 29, 2011 10:49 am
by magesh123
My requirement is to list the datasets like the below When i specify the partial dataset qualifier

ex: INPUT --> USERID.CHAM*.PS*

OUTPUT DATASET USERID.DATASET.REPORT should contains
TSCH050.CHAMP.PS1
TSCH050.CHAMP.PS2
TSCH050.CHAMP.PS3
TSCH050.CHAMPION2.PS
TSCH050.CHAMPION1.PS1

i have used to below code(not in batch mode) for listing multiple datasets and i am getting the expected result.

PDS ='USERID.DATASET.REPORT'                   
DATA = SYSDSN("'"PDS"'")                       
IF DATA = 'OK' THEN                             
DO                                             
X = MSG('OFF')                                 
"DELETE ('"PDS"')"                             
X = MSG('ON')                                   
END                                             
/* ALLOCATE DATASET */                         
"ALLOC DD(DDIN) DA('"PDS"')",                   
" NEW LRECL(80) RECFM(F B) DSORG(PS) REUSE",   
"SPACE(2,1) TRA"                               
DS=STRIP("USERID.CHAM*.PS*")                                 
"ISPEXEC LMDINIT LISTID(IDV) LEVEL(&DS)"                     
DO FOREVER                                                   
"ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR)"   
IF RC = 0 THEN                                               
DO                                                           
SAY DSVAR                                                     
QUEUE " "DSVAR                                               
N = QUEUED()                                                 
"ALLOC F(OUT) DS('"PDS"') MOD REUSE"                         
"EXECIO" N "DISKW OUT(FINIS "                                 
"FREE F(OUT)"                                                 
END                                                           
ELSE LEAVE                                                   
END                                                           
"ISPEXEC LMDLIST LISTID("IDV") OPTION(FREE)"


My output dataset contains:

USERID.DATASET.REPORT
~~~~~~~~~~~~~~~~~~~~~~
TSCH050.CHAMP.PS1
TSCH050.CHAMP.PS2
TSCH050.CHAMP.PS3
TSCH050.CHAMPION2.PS
TSCH050.CHAMPION1.PS1

But when i submit the rexx program using Batch mode(IKJEFT01) i am getting "Dataset USERID.DATASET.REPORT" in use
message. I didnt change any code from the above.

Since i am new to rexx pragram please tell me how to rectify the problem and give idea to list multiple datasets
using JCL(DSLIST...)/REXX program if possible.

Thank you,
Magesh.

Re: DSLIST in REXX program in Batch mode.

PostPosted: Sun May 29, 2011 12:48 pm
by NicC
Suggest you issue a FREE for the dataset before allocating it and making sure that it is not allocated to your TSO session. Also, if you do not need to run the program in foreground, take all the dataset allocation/frww stuff out of the program and use JCL DD statements for your dataset(s). If you need to run in foreground as well then have 2 versions - one with ALLOC/FREE and one without.

Re: DSLIST in REXX program in Batch mode.

PostPosted: Sun May 29, 2011 6:22 pm
by MrSpock
I agree with Nic. You should place your dataset allocations outside in the JCL stream when possible.

As far as your exec, it seems to me that you made it way more complex than it needs to be. It could be much smaller:

                               
DS = STRIP("USERID.CHAM*.PS*")                                 
"ISPEXEC LMDINIT LISTID(IDV) LEVEL("DS")"     
DO FOREVER                                                   
  "ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR)"   
  IF RC <> 0 THEN LEAVE                                                   
  SAY DSVAR                                                     
  QUEUE " "DSVAR
END
"ISPEXEC LMDLIST LISTID("IDV") OPTION(FREE)"                   
"EXECIO "QUEUED()" DISKW OUT (FINIS"                                                     

Re: DSLIST in REXX program in Batch mode.

PostPosted: Mon May 30, 2011 10:52 am
by magesh123
Hi MrSpock,

I have tried with the above code with the Main JCL specfied below. but still
my dataset USERID.DATASET.REPORT is empty. Can you please tell me whether the exact
problem is.

//STEP3    EXEC PGM=IKJEFT01,                                           
// PARM='LOGREAD1'                                                     
//SYSEXEC  DD DSN=userid.REXX.MAIN,DISP=SHR                     
//SYSPRINT DD SYSOUT=*                                                 
//SYSTSPRT DD SYSOUT=*                                                 
//SYSTSIN  DD DUMMY                                                   
//OUT    DD   DSN=userid.DATASET.REPORT,                           
//             DISP=(,CATLG,DELETE),                               
//             UNIT=3390,SPACE=(TRK,(1,1),RLSE),                       
//             RECFM=FB,LRECL=80

Thank you,
Magesh.

Re: DSLIST in REXX program in Batch mode.

PostPosted: Mon May 30, 2011 5:35 pm
by MrSpock
DSLIST is an ISPF Service, yet nowhere in your job are you showing that you've initiated ISPF and provided for all of the required supporting DD statements. Where is your ISPSTART command? Where are the allocations for all of the necessary libraries?

See this previous topic for the same issue.