Reading and updating the member of a pds using rexx



IBM's Command List programming language & Restructured Extended Executor

Reading and updating the member of a pds using rexx

Postby arya_starc » Tue Jan 24, 2017 7:23 pm

Hi All,

I need to write rexx code for updating the member content (changing some string).
Below is the rexx code which i get from one of the post in this forum


PARSE ARG LIB MACRO
LIB = STRIP(LIB,B,"'")
ADDRESS ISPEXEC
"LMINIT DATAID(LIBDID) DATASET("LIB") ENQ(SHR)"
"LMOPEN DATAID("LIBDID") OPTION(INPUT)"
MEMBER = ''
"LMMLIST DATAID("LIBDID") OPTION(LIST) STATS(YES) MEMBER(MEMBER)"
/*------------------------------------------------------------------*/
/* */
/*------------------------------------------------------------------*/
DO WHILE ( RC = 0 )
 MEMBER = STRIP(MEMBER)
 "EDIT DATASET('"LIB"("MEMBER")') MACRO("MACRO")"
 "LMMLIST DATAID("LIBDID") OPTION(LIST) STATS(YES) MEMBER(MEMBER)"
END
/*------------------------------------------------------------------*/
/* FREE AND CLOSE LIB LIBRARY DIRECTORY */
/*------------------------------------------------------------------*/
"LMMLIST DATAID("LIBDID") OPTION(FREE)"
"LMCLOSE DATAID("LIBDID")"
"LMFREE DATAID("LIBDID")"
EXIT


Where MACRO contains:

/*REXX*/
ADDRESS ISREDIT
"MACRO PROCESS"
"CHANGE 'ABC' 'EFG' ALL"
"SAVE"
"END"
"MEND"
EXIT

 


How can i call the respective pds to this rexx ??
halp please...
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

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

Postby enrico-sorichetti » Tue Jan 24, 2017 8:55 pm

see here for a full working application ( TESTED )
http://ibmmainframes.com/viewtopic.php? ... ht=masschg
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: 3003
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

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

Postby willy jensen » Tue Jan 24, 2017 9:12 pm

I think that you need to be more specific about what you want to do and what kind of scenario you have in mind. The sample you posted will run the edit macro against all the members of a pds.
willy jensen
 
Posts: 465
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 70 times

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

Postby enrico-sorichetti » Tue Jan 24, 2017 9:56 pm

The sample you posted will run the edit macro against all the members of a pds.


that' s what emerges from the question and the code snippet posted
( too bad that no error handling was implemented )
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: 3003
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

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

Postby willy jensen » Tue Jan 24, 2017 10:28 pm

The sample, yes, but the subject says 'updating the member of a pds' which to me means a single named member, hence my request for clarification. Let's see what the OP comes back with.
willy jensen
 
Posts: 465
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 70 times

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

Postby arya_starc » Wed Jan 25, 2017 3:02 pm

I need to read the members of as pds then inside that member i need to change the string
I am tried with below code but it is not working:


/*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)"                                                
"LISTDS'"LIBI"'MEMBER"                                          
/* PARSE ARG LIB MACRO  */                                      
IF SYSDSN("'"LIBI"'") = 'OK' THEN                              
   SAY YES                                                        
I = 1                                                          
DO WHILE I <= MYFILE.0                                        
   SAY I                                                        

   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)"                                  
   DO J = 1 TO TAB.0                            
      DISPLAY TAB.J                                
      IF LENGTH(TAB.J) > 0 THEN
          CHANGESTR('SSIDCAMS','TAB.J','VIDCAMS')    
   END                                                  
END                                                  
EXIT                                                
 


On tracing it giving error: ROUTINE NOT FOUND

Edited by moderator to remove unnecessary DO/ENDs and to align code properly.
Note to OP:if that was how your code really looked then learn to code with proper indentation and unnecessary code blocks.
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

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

Postby NicC » Wed Jan 25, 2017 4:06 pm

Where does it say that - which line?
What is in routine DISPLAY?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

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

Postby enrico-sorichetti » Wed Jan 25, 2017 4:22 pm

I do not see the I incremented

substitute
I = 1                                                          
DO WHILE I <= MYFILE.0        


with
do i = 1 to myfile.0
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: 3003
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

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

Postby arya_starc » Wed Jan 25, 2017 4:25 pm

NicC wrote:Where does it say that - which line?
What is in routine DISPLAY?



On tracing this...... it is saying routine not found.
I think refering to CHANGESTR

CHANGESTR('SSIDCAMS','TAB.J','VIDCAMS')
 


The error written in screen as ERROR RUNNING REIDCAMS; LINE 29:ROUTINE NOT FOUND
Last edited by arya_starc on Wed Jan 25, 2017 4:34 pm, edited 1 time in total.
arya_starc
 
Posts: 136
Joined: Mon Sep 21, 2015 1:39 pm
Has thanked: 5 times
Been thanked: 0 time

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

Postby willy jensen » Wed Jan 25, 2017 4:33 pm

The following sample will change a number of strings in all members of a pds using pure REXX. It will also set the ISPF statistics for changed members - note that values are reset as EXECIO willl destroy old info. But I will still very strongly advise using a proper utility, my personal favorite is PD86 from CBTTAPE.ORG, or it's commercial sibling STARTOOL from SERENA.

 ds='TEST.CF.PDS'  /* pds to update */                  
 xdd=''                                                            
 cf.1='TIME=1440'        /* change from */                          
 cf.2='SYS1.@'                                                      
 cf.0=2                                                            
 ct.1='TIME=NOLIMIT'     /* change to   */                          
 ct.2='SYSX'                                                        
 if sysdsn("'"ds"'")<>'OK' then call xit ds sysdsn("'"dsq"'")      
 zz=outtrap('mls.')                                                
 "listds '"ds"' members"                                            
 zz=outtrap('off')                                                  
 alp='rtddn(xdd)'                                                  
 do mln=7 to mls.0                                                  
   cn=0                                                            
   mbr=strip(mls.mln)                                              
   /* change data in member begin */                                
   cc=Bpxwdyn('alloc da('ds'('mbr')) shr' alp)                      
   if cc<>0 then call xit 'alloc' ds 'rc' cc                        
   alp='dd('xdd') reuse'                                            
   "execio * diskr" xdd "(stem data. finis)"                        
   if rc<>0 then call xit 'read' ds'('mbr')' 'rc' rc                
   do di=1 to data.0                                                
     do cfn=1 to cf.0                                              
       cf=cf.cfn                                                    
       ct=ct.cfn                                                    
       parse value ' 'strip(data.di,'t')' ' with front (cf) back    
       if length(back)=0 then iterate                              
       say mbr 'before:' data.di                                    
       data.di=substr(front''ct''back,2)                            
       say mbr 'after: ' data.di                                    
       cn=cn+1                                                      
     end                                                            
   end                                                              
   if cn=0 then iterate                                            
   "execio * diskw" xdd "(stem data. finis)"                        
   if rc<>0 then call xit 'write' ds'('mbr')' 'rc' rc              
   say 'Changes done in' mbr                                        
   /* ISPS stats */                                                
   address ispexec "lminit dataid(did) dataset('"ds"') enq(shr)"    
   if rc<>0 then call xit 'lminit rc' rc                            
   address ispexec "lmmstats dataid("did") member("mbr")"          
   if rc<>0 then call xit 'LMMStats rc' rc zerrlm                  
   address ispexec "lmfree dataid("did")"                          
   /* change data in member end   */                                
 end                                                                
 Call xit 'All done'                                                
XIT:                                                                
 if arg(1)<>'' then say arg(1)                                      
 if xdd<>'' then zz=Bpxwdyn('free dd('xdd')')                      
 exit word(arg(2) 0,1)                                              
 
willy jensen
 
Posts: 465
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 70 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post