Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newbie question - how to build JCL on 2 lines

Status
Not open for further replies.

JMBREXX

Programmer
Jun 7, 2011
2
US
Hi, everyone. I'm new to this forum, and I have a (hopefully) easy question. Below is a REXX procedure that parses a PDS member for a list of program names and inserts each program name into a JCL member, which will then compare that program in two different libraries. A former coworker (who has since passed away) gave me this REXX procedure before he retired, and I use it all of the time (but I haven't programmed in REXX).

However, now I'd like to use this logic to do a new task. In the parsed member, I'd like for it to read the first 8 positions as it does now and place that data into the JCL, and also read the next 8 positions on that same line and place it somewhere else in the JCL (call it "YYYYYYYY").

For example, I have a PDS member with a G0000V00 number in positions 1-8 followed by the date that the G0000V00 was created:

G0000V0012312010
G0015V0001122011
G0030V0002152011

Can someone throw something together for me? I'll be forever grateful. 8)

(Sorry this didn't paste better.)

/* REXX */
/* This proc reads a PDS member containing compile/assembler JCL, */
/* and a PDS member that contains a list of module names left */
/* justified. The proc wraps the JCL from PDS1 around each member */
/* in PDS2 and submits the JCL. */
/* ALLOC DDNAME(SYSEXEC) DSNAME('GSPJMB.EXEC') SHR REUSE */
/* AWB - 05/10/01 */
/* "TS" */ /* uncomment to trace */
/*====================================================================*/
/* PART 1 */
/* Put JCL in a compound variable */
/*====================================================================*/
apst="'"
say "Enter dsn and member of compare JCL"
/* e.g. TEST.GSPjmb.JCL(jclpdscp) */
/* inproc = parse upper pull */
/* pull dsn1 */
pull dsn1
dsn1=apst||dsn1||apst
"free ddname(dd1)"
"allocate dsname("dsn1") ddname(dd1) shr"
if rc = 0 then
nop
else
do
say "Unable to open file - " dsn1
say "Return Code = " rc
exit
end
/* end-if */

/* read the jcl into a compound variable - jclline */
jclline.="" /* initialize compound variable to null */
"EXECIO * DISKR dd1 (stem jclline."/* read the jcl into jclline */
"free ddname(dd1)"
fndline=0 /* line number containing XXXXXXXX */
lastline=0 /* number of JCL lines */
fndcnt=0
x=0 /* initialize x */
do count=1 by 1 while jclline.count¬=""
x=pos("XXXXXXXX",jclline.count,1) /* find the string for member */
if x>0 then
do
fndline=count /* save line number with XXXXXXXX */
linepart1=substr(jclline.count,1,x-1)
linerest=substr(jclline.count,x+8,80-(x+8))
fndcnt=fndcnt+1
end
if count>100 then /* JCL line limit - precaution - infinite loop */
do
say "Over 100 JCL lines - if valid, increase REXX limit"
exit
end
end /* end search for XXXXXXXX loop */
lastline=count-1
if fndcnt<2 then
do
say "Unable to locate XXXXXXXX for two dsns "
exit
end
/* end-if */

/*====================================================================*/
/* PART 2 */
/*====================================================================*/
say "Enter dsn and member containing the member list"
/* e.g. TEST.GSPJMB.MEMBERS */
pull dsn2 /* retrieve users response */
dsn2=apst||dsn2||apst
/* "TS" */ /* uncomment to trace */
"free ddname(dd2)"
"allocate dsname("dsn2") ddname(dd2) shr"
if rc = 0 then
nop
else
do
say "Unable to open file - " dsn2
say "Return Code = " rc
exit
end
/* read the member names into a NEWSTACK */
"free ddname(zsubfile)"
"allocate ddname(zsubfile) dsname('test.gspjmb.source(zsubfile)') shr"
"NEWSTACK" /* CREATE A NEW DATA STACK FOR member list */
"EXECIO * DISKR dd2 (FINIS" /* read member list into stack */
totalmembers = Queued() /* save record count */
do mbrcnt=1 by 1 while mbrcnt<=totalmembers /* process each member */
parse upper pull member rest /* member and rest of line */
savejcl.=jclline. /* copy original jcl */
do cnt2=1 by 1 while cnt2<=lastline /* create jcl for member*/
savejcl.cnt2=jclline.cnt2 /* copy original jcl line*/
x=pos("XXXXXXXX",savejcl.cnt2,1) /* ? - contain XXXXXXXX */
if x>0 then
do
part1=substr(savejcl.cnt2,1,(x-1)) /* line up to member*/
part2=substr(savejcl.cnt2,(x+8)) /* line after member */
newline=part1||member||part2 /*restructure member line*/
savejcl.cnt2=newline /* replace the line with XXXXXXXX */
end
/* end-if */
end
"EXECIO * DISKW zsubfile (stem savejcl. finis"
"submit 'test.gspjmb.source(zsubfile)'"
say "Job for " member " has been submitted"
end /* end of loop to process members */
"DELSTACK" /* DELETE THE NEW DATA STACK */


 
Welcome to the forums<g>

(Sorry this didn't paste better.)
To preserve alignment, use the Code tags. Also, use the Preview Post so you can see your post as it will appear to the forum. Change as needed then Submit Post.

Code:
/* REXX */
/* This proc reads a PDS member containing compile/assembler JCL,  */
/* and a PDS member that contains a list of module names left      */
/* justified.  The proc wraps the JCL from PDS1 around each member */
/* in PDS2 and submits the JCL.                                    */
/* ALLOC DDNAME(SYSEXEC) DSNAME('GSPJMB.EXEC') SHR REUSE           */
/* AWB  - 05/10/01                                                 */
/* "TS"  */                         /* uncomment to trace   */
 
Thanks for the tip, papadba! Here it is, formatted. I really hope that somebody can tweak this for two parsed fields.

Code:
/* REXX */                                                              
/* This proc reads a PDS member containing compile/assembler JCL,  */   
/* and a PDS member that contains a list of module names left      */   
/* justified.  The proc wraps the JCL from PDS1 around each member */   
/* in PDS2 and submits the JCL.                                    */   
/* ALLOC DDNAME(SYSEXEC) DSNAME('GSPJMB.EXEC') SHR REUSE           */   
/* AWB  - 05/10/01                                                 */   
/* "TS"  */                         /* uncomment to trace   */          
/*====================================================================*/
/*                   PART 1                                           */
/*  Put JCL in a compound variable                                    */
/*====================================================================*/
apst="'"                                                                
say "Enter dsn and member of compare JCL"                               
/* e.g. TEST.GSPjmb.JCL(jclpdscp)                                     */
/* inproc = parse upper pull  */                                        
/*   pull dsn1  */                                                      
pull dsn1                                                               
dsn1=apst||dsn1||apst                                                
"free ddname(dd1)"                                                   
"allocate dsname("dsn1") ddname(dd1) shr"                            
if rc = 0 then                                                       
    nop                                                              
else                                                                 
    do                                                               
        say "Unable to open file - " dsn1                            
        say "Return Code = " rc                                      
        exit                                                         
    end                                                              
/* end-if */                                                         
                                                                     
/*  read the jcl into a compound variable - jclline */               
jclline.=""               /* initialize compound variable to null */ 
"EXECIO * DISKR dd1    (stem jclline."/* read the jcl into jclline */
"free ddname(dd1)"                                                   
fndline=0               /* line number containing XXXXXXXX */        
lastline=0              /* number of JCL lines */                    
fndcnt=0                                                                
x=0                     /* initialize x */                              
do count=1 by 1 while jclline.count¬=""                                 
    x=pos("XXXXXXXX",jclline.count,1) /* find the string for member */  
    if x>0 then                                                         
        do                                                              
           fndline=count          /* save line number with XXXXXXXX */  
           linepart1=substr(jclline.count,1,x-1)                        
           linerest=substr(jclline.count,x+8,80-(x+8))                  
           fndcnt=fndcnt+1                                              
        end                                                             
    if count>100 then /* JCL line limit - precaution - infinite loop  */
      do                                                                
        say "Over 100 JCL lines - if valid, increase REXX limit"        
        exit                                                            
      end                                                               
end            /* end search for XXXXXXXX loop  */                      
lastline=count-1                                                        
if fndcnt<2  then                                                       
    do                                                                  
      say "Unable to locate XXXXXXXX for two dsns    "                  
      exit                                                              
    end                                                                 
/* end-if */                                                            
                                                                        
/*====================================================================*/
/*                   PART 2                                           */
/*====================================================================*/
say "Enter dsn and member  containing the member list"                  
/*   e.g. TEST.GSPJMB.MEMBERS */                                        
pull dsn2                /* retrieve users response */                  
dsn2=apst||dsn2||apst                                                   
/* "TS"        */                   /* uncomment to trace   */          
   "free ddname(dd2)"                                                   
"allocate dsname("dsn2") ddname(dd2) shr"                               
if rc = 0 then                                                          
    nop                                                                 
else                                                                    
    do                                                                 
        say "Unable to open file - " dsn2                              
        say "Return Code = " rc                                        
        exit                                                           
    end                                                                
/*  read the member names into a NEWSTACK                   */         
   "free ddname(zsubfile)"                                             
"allocate  ddname(zsubfile) dsname('test.gspjmb.source(zsubfile)') shr"
"NEWSTACK"               /* CREATE A NEW DATA STACK FOR member list */ 
"EXECIO * DISKR dd2    (FINIS"  /* read member list into stack */      
totalmembers = Queued()              /* save record count */           
do mbrcnt=1 by 1 while mbrcnt<=totalmembers  /* process each member */ 
    parse upper pull member rest  /* member and rest of line */        
    savejcl.=jclline.      /* copy original jcl */                     
    do cnt2=1 by 1 while cnt2<=lastline   /* create jcl for member*/   
        savejcl.cnt2=jclline.cnt2     /* copy original jcl line*/      
        x=pos("XXXXXXXX",savejcl.cnt2,1) /* ? - contain XXXXXXXX */    
        if x>0 then                                                    
            do                                                         
              part1=substr(savejcl.cnt2,1,(x-1)) /* line up to member*/ 
              part2=substr(savejcl.cnt2,(x+8))   /* line after member */
              newline=part1||member||part2   /*restructure member line*/
              savejcl.cnt2=newline  /* replace the line with XXXXXXXX */
            end                                                         
         /* end-if */                                                   
     end                                                                
    "EXECIO * DISKW zsubfile (stem savejcl. finis"                      
    "submit 'test.gspjmb.source(zsubfile)'"                             
     say "Job for " member " has been submitted"                        
end     /* end of loop to process members */                            
"DELSTACK"                            /* DELETE THE NEW DATA STACK */
 
If positions 1-8 contain your program name and the next 8 bytes are the new ones that you want to extract...

Code:
second_bit_of_data = Substr(member,9,8)


Nic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top