List dataset using wildcards



IBM's Command List programming language & Restructured Extended Executor

List dataset using wildcards

Postby Prasanna G » Tue May 10, 2016 5:24 pm

Hi

My requirement is to read a list of HLQs with wildcard and list out the dataset names.
I tried to use the below code. But when a dataset does not exists, the below code exits the rexx because of the Leave command.
Is there a way to write the dataset does not exist message against the HLQ to the output file and proceed reading the next record in the input and list the files under the HLQ till end of the input file?


"ALLOC F(INPUT1) DA('"XX.XXX"') SHR "                             /* XX.XXX holds the list of  qualifiers for which DSN need to be fetched */
  "EXECIO * DISKR INPUT1 (STEM HLQ. FINIS"                        
  "FREE F(INPUT1)"                                                
                                                                                                                   
DROPBUF 0                                                        
                                                                 
DO I=1 TO HLQ.0                                                  
                                                                 
QUALIFIER=STRIP(HLQ.I) /* FIND THE QUALIFIER FOR WHICH */        
STAR='*'                            /* DS NEED TO BE FETCHED */  
QUAL=QUALIFIER||STAR                                              
                                                                 
CALL PULLDSN QUAL                                                
                                                                 
END                  

  N=QUEUED()                          
                                     
"ALLOC F(OUTDD) DA('"YY.YYY"') SHR "  
 "EXECIO" N "DISKW OUTDD (FINIS"      
 "FREE F(OUTDD)"                      

/************************ SUBROUTINE **************************************/

PULLDSN:                                                              
                                                                       
ARG QUAL                                                              
                                                                       
                                 
                                                                       
/* PULL THE LIST OF DATA SETS BASED ON THE QUALIFIER */                
                                                                       
"ISPEXEC LMDINIT LISTID(IDV) LEVEL(&QUAL)"                            
                                                                       
DO FOREVER
                                                                       
 "ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR) STATS(YES)"
                                                                                                                                             
   IF RC = 0 THEN SAY DSVAR                                            
   ELSE LEAVE                                                          

 END /* END OF FOREVER LOOP */    

"ISPEXEC LMDFREE LISTID("IDV")"  
                                 
   QUEUE DSVAR                    
                                 
RETURN    
 


Thanks
Prasanna G.
User avatar
Prasanna G
 
Posts: 68
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: List dataset using wildcards

Postby enrico-sorichetti » Tue May 10, 2016 5:36 pm

"FREE F(OUTDD)"                      

/************************ SUBROUTINE **************************************/

PULLDSN:          



first fix ...

the code as written fall thru
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: List dataset using wildcards

Postby Prasanna G » Tue May 10, 2016 5:50 pm

Hi Enrico

Below is the exact code.


/*  REXX */                                            
   "ALLOC F(INPUT1) DA('"TRWTRTC.FILE.IN.LIST1"') SHR "
     "EXECIO * DISKR INPUT1 (STEM HLQ. FINIS"          
     "FREE F(INPUT1)"                                  
                                                       
   DROPBUF 0                                          
                                                       
   DO I=1 TO HLQ.0                                    
                                                       
   QUAL=STRIP(HLQ.I) /* FIND THE QUALIFIER FOR WHICH */
                                                       
   CALL PULLDSN QUAL                                  
                                                       
   END                                                
     N=QUEUED()                                        
                                                       
   "ALLOC F(OUTDD) DA('"ZK83PXJ.DATASET.REPORT"') SHR "
    "EXECIO" N "DISKW OUTDD (FINIS"                    
     "FREE F(OUTDD)"                                  
/************************ SUBROUTINE *****************/
PULLDSN:                                                              
                                                                       
ARG QUAL                                                              
/* PULL THE LIST OF DATA SETS BASED ON THE QUALIFIER */                
                                                                       
"ISPEXEC LMDINIT LISTID(IDV) LEVEL(&QUAL)"                            
                                                                       
DO FOREVER                                                            
                                                                       
 "ISPEXEC LMDLIST LISTID("IDV") OPTION(LIST) DATASET(DSVAR) STATS(YES)"
                                                                       
   IF RC = 0 THEN SAY DSVAR                                            
   ELSE LEAVE                                                          
 END /* END OF FOREVER LOOP */                                        
"ISPEXEC LMDFREE LISTID("IDV")"                                        
    QUEUE DSVAR                                                        
                                                                       
 RETURN                                                                
 
User avatar
Prasanna G
 
Posts: 68
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: List dataset using wildcards

Postby enrico-sorichetti » Tue May 10, 2016 5:57 pm

and the error is still there
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: List dataset using wildcards

Postby Prasanna G » Tue May 10, 2016 6:12 pm

Yes.. I get the dataset names displayed as there is a Say command. But only one dataset name is written to the output report file.
This is what I have in the input file. First record available. Second record not available.

TRWTRTC.SORT.GEN180P*.SORTINP*
TRWTRTC.OHTR.GEN180P*.SORTINP*
 


This is what I get displayed in the screen

TRWTRTC.SORT.GEN180PA.SORTINP1.DX160781
TRWTRTC.SORT.GEN180PB.SORTINP1.DX160781
TRWTRTC.SORT.GEN180PC.SORTINP1.DX160781
TRWTRTC.SORT.GEN180P4.SORTINP1.DX160781
 


This is the error message that I get after the rexx execution


                               ISPF Dialog Error                              
 Command ===>                                                                  
                                                                    More:     +
 ******************************************************************************
 * ISRLD000                                                                   *
 *                                                                            *
 * Missing parameters                                                         *
 * One or both of level and volume must be specified for LMDINIT.             *
 *                                                                            *
 *                                                                            *
 *                                                                            *
 *                                                                            *
 *                                                                            *
 *                                                                            *
 * Current dialog statement:                                                  *
 * LMDINIT LISTID(IDV) LEVEL()                                                *
 *                                                                            *
 * Enter HELP command for further information regarding this error.           *
 * Press ENTER key to terminate the dialog.                                   *
 *                                                                            *
 *                                                                            *
 *                                                                            *
 

This is what gets written on the output file

TRWTRTC.SORT.GEN180P4.SORTINP1.DX160781
 
User avatar
Prasanna G
 
Posts: 68
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: List dataset using wildcards

Postby enrico-sorichetti » Tue May 10, 2016 6:48 pm

WHAT IS THAT YOU DO NOT UNDERSTAND

when I tell You that with the code You posted

  "ALLOC F(OUTDD) DA('"ZK83PXJ.DATASET.REPORT"') SHR "
    "EXECIO" N "DISKW OUTDD (FINIS"                    
     "FREE F(OUTDD)"                                  
/************************ SUBROUTINE *****************/
PULLDSN:                                                              
       


after having written the output file
the script will fall thu and will execute the next instruction
inside the PULLDSN:
code sequence

with all the disgaraceful consequences
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: List dataset using wildcards

Postby Prasanna G » Tue May 10, 2016 7:21 pm

I am extremely sorry.
I have coded

EXIT(0)  


after

  "FREE F(OUTDD)"  

Now I get in the output file.

TRWTRTC.SORT.GEN180P4.SORTINP1.DX160781
TRWTRTC.SORT.GEN180P4.SORTINP1.DX160781
 


Thanks
Prasanna G.
User avatar
Prasanna G
 
Posts: 68
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: List dataset using wildcards

Postby Prasanna G » Tue May 10, 2016 7:35 pm

I actually need the output as

TRWTRTC.SORT.GEN180PA.SORTINP1.DX160781
TRWTRTC.SORT.GEN180PB.SORTINP1.DX160781
TRWTRTC.SORT.GEN180PC.SORTINP1.DX160781
TRWTRTC.SORT.GEN180P4.SORTINP1.DX160781
TRWTRTC.OHTR.GEN180P*.SORTINP* - Not Found
 


Thanks
Prasanna G.
User avatar
Prasanna G
 
Posts: 68
Joined: Tue Apr 12, 2011 9:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: List dataset using wildcards

Postby enrico-sorichetti » Tue May 10, 2016 7:59 pm

if You had cared to read the manulas about the lmdlist return codes
we would not be here wasting time ...
You checked for 0...

but as the manual tells

0
One of these:
LIST option - Normal completion. The name of next data set in the list is returned in the variable specified in keyword DATASET. Data set statistics are returned, if requested.
FREE option - Normal completion. The internal storage associated with the data set list has been freed.
SAVE option - Normal completion. The data set list has been successfully written to a data set. The total number of tracks and datasets are returned to dialog variables in the function pool, if requested.
SAVEC option - Normal completion. The data set list has been successfully written to a data set. The total number of tracks and datasets are returned to dialog variables in the function pool, if requested.
TOTALS option - Normal completion. No list has been written to a dataset. The total number of tracks and datasets are returned into dialog variables in the function pool.
4
No data sets matched specified search criteria (the values for keywords LEVEL and VOLUME on the LMDINIT service).
8
End of data set list.


You had handled things correctly You would not have asked
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post