Page 2 of 3

Re: Reading and updating the member of a pds using rexx

PostPosted: Wed Jan 25, 2017 4:42 pm
by prino
PDS86 or IPOUPDTE are the ways to go!

Re: Reading and updating the member of a pds using rexx

PostPosted: Wed Jan 25, 2017 4:55 pm
by willy jensen
For this kind of change I fully agree, but as an exercise it might be useful.

Re: Reading and updating the member of a pds using rexx

PostPosted: Wed Jan 25, 2017 5:09 pm
by NicC
You realise that the CHANGESTR statement is trying to find the string "SSIDCAMS" within the string "TAB.J" - not within the string contained in the variable TAB.J?

You still have not explained what DISPLAY is - it is not a Rexx keyword or function so this is probably the cause of thr "ROUTINE NOT FOUND" message. Do not post your interpretation of the trace but post the actual trace - the error messages and a few lines before the point of failure.

Re: Reading and updating the member of a pds using rexx

PostPosted: Wed Jan 25, 2017 5:59 pm
by prino
CHANGESTR is not a REXX function on z/OS!

Re: Reading and updating the member of a pds using rexx

PostPosted: Wed Jan 25, 2017 6:10 pm
by NicC
Thanks, Prino. I was using my OS/2 Rexx information as my external hard drive with all my work related stuff is "offline" at the moment (and I was too lazy to Google for the z/OS version - which is now book-marked!).

Re: Reading and updating the member of a pds using rexx

PostPosted: Wed Jan 25, 2017 6:46 pm
by arya_starc
Hi
Now i am doing different approach for updating the pds member.
As I would like to remove a specific line from a file and each string is different in a member.So i am using the array approach to verify which line has a specific string.
So I would like replaced the particular line string( that had this specific string) .

I tried to code that rexx but it I am not getting how to copy line by line to the output pds member.
As some lines have that specific string and some lines has not.

Below is the rexx code that I write

/*REXX*/                                                                
 TRACE I                                                                
 SAY HI                                                                  
 ADDRESS TSO                                                            
 LIBI = 'VM.LAT.D10A010.PF.JCLLIB.FB.SASH1'                              
 LIBO = 'VM.LAT.D10A010.PF.JCLLIB.FB.SASH2'                              
 "ALLOC F(INFILE) DSN('VM.LAT.D10A010.PF.SCHED3') SHR REU"              
 "EXECIO * DISKR INFILE( FINIS STEM MYFILE."                            
 "FREE F(INFILE)"                                                        
 "ALLOC F(INFILE1) DSN('VM.LAT.D10A010.PF.JCLLIB.FB.SASH1') SHR REU"    
 "EXECIO * DISKW INFILE1( FINIS STEM MYFILE1."                          
 "FREE F(INFILE1)"                                                      
 "ALLOC F(OUTFILE) DSN('VM.LAT.D10A010.PF.JCLLIB.FB.SASH2') SHR REU"    
 "EXECIO * DISKW INFILE( FINIS STEM MYFILE2."                            
 "FREE F(OUTFILE)"                                                      
 "LISTDS'"LIBI"'MEMBER"                                                  
  DO I=1 TO  MYFILE.0                                                    
   SAY ' LINE ' I ':' MYFILE.I                                          

   MEMBER = STRIP(MYFILE.I)                                              
    MEM = LIBI || "(" || MEMBER || ")"                                    
    SAY 'JOBNAME :' MEMBER                                                
    "ALLOC FI(IN) DA('"MEM"') SHR REUSE"                                  
    "EXECIO * DISKR IN (STEM TAB. FINIS"                                  
    "FREE F(IN)"                                                          
    Address 'ISPEXEC'                                                    
    "LMINIT DATAID("DATA1")DATASET("LIBI")ENQ(SHR)"                      
    "LMINIT DATAID("DATA2")DATASET("LIBO")ENQ(SHR)"                      
    "LMCOPY FROMID("DATA1")FROMMEM("MEMBER")TODATAID("DATA2")"            
          DO J = 1 TO TAB.0                                              
             SAY TAB.J                                                    
             IF LENGTH(TAB.J) > 0 THEN DO                                
                TAB.I = OVERLAY('SSIDCAMS','VDIDCAMS',14)                
                SAY 'HERE1' MEMBER                                        
                MEM1 = LIBO || "(" || MEMBER || ")"                      
                DO K =  TAB1.0 TO 1                                      
                ADDRESS TSO "ALLOC FI(IN) DA('"MEM1"') SHR REUSE"        
                ADDRESS TSO "EXECIO "TAB1.0" DISKW IN (STEM TAB1. FINIS"  

              ADDRESS  TSO "FREE F(IN)"                                
               END                                                      
         END                                                            
 END                                                                    
 EXIT                        

 

Re: Reading and updating the member of a pds using rexx

PostPosted: Wed Jan 25, 2017 8:12 pm
by NicC
There are no arrays in z/OS rexx - you are using stems.

You can use EXECIO to read 1 or many or all lines at a time. The same with writing.

There are several approaches to doing what you want. For example:
. read/write line by line
.read into a stem and copy the lines that you want to another stem and write that.
.have a mixture of the first two e.g. bulk read/write by line

This makes no sense:
DO K =  TAB1.0 TO 1                                      
ADDRESS TSO "ALLOC FI(IN) DA('"MEM1"') SHR REUSE"        
ADDRESS TSO "EXECIO "TAB1.0" DISKW IN (STEM TAB1. FINIS"  

 ADDRESS  TSO "FREE F(IN)"                                
 END  

I do not know what you are intending to do here but it is probably not doing what you want.

Your process should be:
.get a list of members and store in stem - let's call it members.
.loop through each member
.allocate the member
.read it into a stem - let's call it memb_lines.
.loop through each line
.if the line is required:
.change line if a change is required
.write line to output stem - lt us call it lines_out.
.end loop through memb_lines
.write the output stem - lines_out.
.free the member
.end loop through member. stem
.end program

Re: Reading and updating the member of a pds using rexx

PostPosted: Thu Jan 26, 2017 3:55 pm
by arya_starc
NicC wrote:There are no arrays in z/OS rexx - you are using stems.

You can use EXECIO to read 1 or many or all lines at a time. The same with writing.

There are several approaches to doing what you want. For example:
. read/write line by line
.read into a stem and copy the lines that you want to another stem and write that.
.have a mixture of the first two e.g. bulk read/write by line

This makes no sense:
DO K =  TAB1.0 TO 1                                      
ADDRESS TSO "ALLOC FI(IN) DA('"MEM1"') SHR REUSE"        
ADDRESS TSO "EXECIO "TAB1.0" DISKW IN (STEM TAB1. FINIS"  

 ADDRESS  TSO "FREE F(IN)"                                
 END  

I do not know what you are intending to do here but it is probably not doing what you want.

Your process should be:
.get a list of members and store in stem - let's call it members.
.loop through each member
.allocate the member
.read it into a stem - let's call it memb_lines.
.loop through each line
.if the line is required:
.change line if a change is required
.write line to output stem - lt us call it lines_out.
.end loop through memb_lines
.write the output stem - lines_out.
.free the member
.end loop through member. stem
.end program


Thanks a lot NicC. yes this is my requirement.
I am writing code as per your pseudo code.

Re: Reading and updating the member of a pds using rexx

PostPosted: Thu Jan 26, 2017 4:25 pm
by enrico-sorichetti
see here for a TESTED snippet
( how to apply a macro to all the members of a pds )

http://ibmmainframes.com/viewtopic.php? ... ight=apply

Re: Reading and updating the member of a pds using rexx

PostPosted: Thu Jan 26, 2017 5:02 pm
by arya_starc
prino wrote:CHANGESTR is not a REXX function on z/OS!

As here I see the function
http://www.rexxinfo.org/html/functions.html#changestr

then which function can we use for changing the string.
Any alternative for changestr?