Page 1 of 1

REXX Code to find if PDS JCL member has how many DD

PostPosted: Tue Sep 14, 2021 11:17 am
by abhilashanaik
Hi All,

I have a requirement where I need to code REXX program giving input as PDS library(which will be JCLlib) and for each member how many DD statement it has
and there corresponding file names and for each step which program is used . I need output report. Can someone help.?

Thank you

Re: REXX Code to find if PDS JCL member has how many DD

PostPosted: Tue Sep 14, 2021 2:51 pm
by willy jensen
I choose to assume that your problem is with reading the members..
A couple of possibilities springs to mind.
- combine all members to one sequential dataset using i.e. program PDSPRINT from file 316 at http://www.cbttape.org, then parse the dataset.
- do a TSO LISTDS .. MEMBERS then do your own ALLOCATE and EXECIO to read each member for parsing.
- use the following REXX pgm DOALL to run an edit macro to do the actual parse.
/*                                                               rexx  
  Run an edit macro against all members of a library                    
  Adapted from DOALL from Lionel B. Dyck                                
 */                                                                    
                                                                       
 arg dsn exec . /* libraryname and editmacro name                     */
                /* libname must be the full name, quotes are optional */
 dsn=requote(dsn)                                                      
                                                                       
 x = outtrap("lm.","*")                                                
 "LISTD" dsn "MEMBERS"                                                  
 x = outtrap("off")                                                    
                                                                       
 do i = 1 to lm.0 while lm.i<>'--MEMBERS--'                            
 end                                                                    
 dsn=unquote(dsn)                                                      
 do n = i+1 to lm.0                                                    
   parse value lm.n with mem .                                          
   Address ISPEXEC "EDIT DATASET('"dsn"("mem")') MACRO("exec")"        
 end                                                                    
 exit                                                                  
Requote: if arg(1)='' then return '';else return "'"Unquote(arg(1))"'"  
Unquote: return strip(space(translate(arg(1)," ","'")))                

Re: REXX Code to find if PDS JCL member has how many DD

PostPosted: Tue Sep 14, 2021 3:25 pm
by abhilashanaik
My requirement is :

I need to fetch below details for each JCL in pds member.
For each step
Program
DD name
Dataset

Re: REXX Code to find if PDS JCL member has how many DD

PostPosted: Tue Sep 14, 2021 4:01 pm
by willy jensen
I see, so are new to REXX and don't know how to parse a text?
You have to read the manual, specifically the POS and SUBSTR functions, and the PARSE command for starters.
What have you done so far?
I'll give you a sample, looking for a DDname in string text.n:
if left(text.n,2)='//' & word(text.n,2)='DD' then ddname=substr(word(text.n,1),3)

Re: REXX Code to find if PDS JCL member has how many DD

PostPosted: Tue Sep 14, 2021 6:09 pm
by sergeyken
You also need to take into account:

0) maybe, some members are not JCL at all?
1) either a member has JOB statement(s) in it, or not?
2) maybe, a single member has multiple JOBs inside of it? (This is possible, though not used too often)
3) maybe, there are internal JCL PROCedures as part of any job?
4) maybe, the member itself is an external JCL procedure?
5) maybe, some JOB/EXEC/DD/PROC statements are obsolete, and just commented out with //*?
6) maybe, there are concatenated DD statements (e.g. formal DD looking as no-name statements)?
7) maybe, some good-looking JCL sequences are coded as input stream, e.g. between // DD DATA, and /* ?
8) many other tricks and gimmicks are possible.

As for myself, I would create a flat listing of the library (using an utility like IEBPTPCH, or SUPERC, or any other available), end then would produce a regular report grouped by member/job/step/DD - using one of SORT utilities. The creation of a correct hierarchical report in REXX would require some experience in programming. While using SORT utility, much less experience may be needed.

Re: REXX Code to find if PDS JCL member has how many DD

PostPosted: Wed Sep 15, 2021 6:02 am
by sergeyken
abhilashanaik wrote:My requirement is :

I need to fetch below details for each JCL in pds member.
For each step
Program
DD name
Dataset

Don’t be so rude re-assigning to others the task you are supposed to do, and which you are (highly likely) paid for?

Demonstrate that you are able to do at least a minor first step by yourself, before begging for help.