Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

REXX :Issue with replacing string in PDS memebers

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
chanchalS

New User


Joined: 30 Nov 2010
Posts: 5
Location: Pune, India

PostPosted: Fri Dec 10, 2010 2:54 pm    Post subject: REXX :Issue with replacing string in PDS memebers
Reply with quote

Hello Everyone!!
I have written REXX code to replace particular string from all members of a PDS.However while retrieving contents of PDS member, REXX is concatenating lines in 72 chars instead of reading line by line which is causing string break for instance, I want to replace $CYC by '5072' however in some places '$CYC' is read as '$C' in one line and 'YC' in another line due to which '$CYC" couldn't be replaced. Here's my REXX
Code:
DSN= 'USERID.PDS'
SRCSTR = SPACE('$CYC')     
TRGSTR = SPACE('5072')     
DUMMY = OUTTRAP("MEMB.","*")                     
ADDRESS TSO                                       
"LISTDS '"DSN"' MEMBERS"                         
DUMMY = OUTTRAP("OFF")                           
DO I = 7 TO MEMB.0                               
     DSN1 = "'"||DSN||"("||SPACE(MEMB.I,0)||")'" 
     DROP OUT.                                   
     ADDRESS TSO                                 
     "ALLOC F(IN) DS("DSN1") SHR"                 
     "EXECIO * DISKR IN (FINIS STEM IN."         
     "FREE F(IN)"                                 
      T = 0                                       
      DO S = 1 TO IN.0                           
        STRING = IN.S                             
        DO FOREVER                                     
   POSN = POS(SRCSTR,STRING)                     
    IF POSN > 0                                   
    THEN DO
   SUBLEN= LENGTH(SRCSTR)                       
     STRLEN= LENGTH(STRING)                       
    FPART = SUBSTR(STRING,1,POSN-1)             
     SPART = SUBSTR(STRING,POSN+SUBLEN)           
       STRING= FPART||TRGSTR||SPART ;END         
        ELSE DO                                       
     LEAVE ;END                                   
      END
   T = T + 1                           
         OUT.T = STRING                       
       END                                   
       OUT.0 = IN.0                           
       ADDRESS TSO                           
       "ALLOC F(OUT) DS("DSN1") SHR"         
       "EXECIO * DISKW OUT (FINIS STEM OUT." 
       "FREE F(OUT)"                         
 END     

Could you please let me know how to make REXX read 1 line at time without concatenating it.

Kind Regards,
CS
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Dec 10, 2010 3:02 pm    Post subject:
Reply with quote

A simple ISPF edit macro will suffice.
Why read every line and parse it for something and then split lines and try to rejoin them
Code:
"ISREDIT MACRO"
"ISREDIT C '"source"' '"target"' ALL"
"ISREDIT END"
Have a read of the ISPF edit macro manual found by using the "IBM Manuals" link at the top of every page.

If you need to do something, at least choose the easier option to get it done.

In fact, the forum is full of good examples on how to do this, on how to get the complete member list of a PDS and how to process each member.
Back to top
View user's profile Send private message
John L. McConnell

New User


Joined: 10 Dec 2010
Posts: 11
Location: Orlando, FL

PostPosted: Fri Dec 10, 2010 7:53 pm    Post subject: More information, please.
Reply with quote

I think I unerstand the issue, and if so, the edit macro will not solve it. what I am hearing from you is that the character string for which you are searching can break across a line boundary and is, therefore not discoverable by a simple POS, nor by an ISREDIT FIND. In order to understand the issue better, I would like to see the DCB attributes of the PDS and an example of a few lines of a member as it appears in EDIT.
As a work-around, assuming that the records are of equal length, you could try S1 = S+1; STRING = IN.S||IN.S1. Then POSN will find an occurrence which is broken across the record boundary. Then you will follow your replacement logic. But it's not clear how you would then split the STRING back into IN.S and IN.S1 unless the total length of the two concatenated records remains constant after the substitution.
Back to top
View user's profile Send private message
chanchalS

New User


Joined: 30 Nov 2010
Posts: 5
Location: Pune, India

PostPosted: Fri Dec 10, 2010 8:51 pm    Post subject:
Reply with quote

Hi John,
Thanks for the response..The string to be replaced is in different places within the PDS member so I don't have a specific position.Here's DCB attributes of my PDS:
RECFM=FB,LRECL=80,BLKSIZE=27920

And few lines from PDS member:

Code:
//FILEIN1  DD DSN=RC30?.BU1.PFB10.SOCSOUT.C$CYCV00,DISP=SHR           
//FILEIN2  DD DSN=RC30?.BU1.PFB10.OUTSORCD.C$CYCV00,DISP=SHR           
//FILEIN3  DD DSN=RC10?.BU1.PFB10.CRISCYCL.C$CYCV00,DISP=SHR           
//FILEIN4  DD DSN=RG60?.BU2.PFB25.COEDIT.C$CYCV00,DISP=SHR             
//FILEIN5  DD DSN=RG60?.BU2.PFB42D.COEDITBS.C$CYCV00,DISP=SHR
Here, all the $CYC should be replaced with '5072'. I have captured input string in my REXX program before replacement..It looks like this:

i/p string:
Code:
CSOUT.C$CYCV00,DISP=SHR:h//FILEIN2::DD DSN=RC30?.BU1.PFB10.OUTSORCD.C$
CYCV00,DIS                                                                 
i/p string: P=SHR:h//FILEIN3::DD DSN=RC10?.BU1.PFB10.CRISCYCL.C$CYCV00,DISP=SHR
:h//FILEIN4::                                                                 
i/p string: DD DSN=RG60?.BU2.PFB25.COEDIT.C$CYCV00,DISP=SHR:h//FILEIN5::DD DSN=
RG60?.BU2.PFB                                                                 
i/p string: 42D.COEDITBS.C$CYCV00,DISP=SHR:://DSNICNTL DD * :1 DESPOOL RDSN=RC3
In first line $CYC is splitted as '$' and 'CYC' due to which it's not replaced.

Kind Regards,
Chanchal
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Dec 10, 2010 8:58 pm    Post subject: Reply to: REXX :Issue with replacing string in PDS memebers
Reply with quote

given the sample You posted...
again what would be wrong in using expat' s suggestion (EDIT macro) ?
Back to top
View user's profile Send private message
John L. McConnell

New User


Joined: 10 Dec 2010
Posts: 11
Location: Orlando, FL

PostPosted: Fri Dec 10, 2010 9:04 pm    Post subject: Stumped
Reply with quote

What you are doing in your program looks perfectly reasonable, but the behavior we are both observing in your program is bizarre! I've never seen EXECIO fail to honor record boundaries the way it appears to be happening in this program. Try a minimal program on one member of the PDS. Allocate it, EXECIO * DISKR, the DO S = 1 to IN.0; SAY IN.S; END. Do you still see this concatenation of records?
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Fri Dec 10, 2010 10:00 pm    Post subject:
Reply with quote

Chancal, is your PDS member the result of FTPing a data set to the mainframe?
Back to top
View user's profile Send private message
chanchalS

New User


Joined: 30 Nov 2010
Posts: 5
Location: Pune, India

PostPosted: Mon Dec 13, 2010 1:16 pm    Post subject:
Reply with quote

Hi John,
Thanks for the response..The string to be replaced is in different places within the PDS member so I don't have a specific position.Here's DCB attributes of my PDS:
RECFM=FB,LRECL=80,BLKSIZE=27920

And few lines from PDS member:

//FILEIN1 DD DSN=RC30?.BU1.PFB10.SOCSOUT.C$CYCV00,DISP=SHR
//FILEIN2 DD DSN=RC30?.BU1.PFB10.OUTSORCD.C$CYCV00,DISP=SHR
//FILEIN3 DD DSN=RC10?.BU1.PFB10.CRISCYCL.C$CYCV00,DISP=SHR
//FILEIN4 DD DSN=RG60?.BU2.PFB25.COEDIT.C$CYCV00,DISP=SHR
//FILEIN5 DD DSN=RG60?.BU2.PFB42D.COEDITBS.C$CYCV00,DISP=SHR

Here, all the $CYC should be replaced with '5072'. I have captured input string in my REXX program before replacement..It looks like this:

i/p string: CSOUT.C$CYCV00,DISP=SHR:h//FILEIN2:icon_biggrin.gifD DSN=RC30?.BU1.PFB10.OUTSORCD.C$
CYCV00,DIS
i/p string: P=SHR:h//FILEIN3:icon_biggrin.gifD DSN=RC10?.BU1.PFB10.CRISCYCL.C$CYCV00,DISP=SHR
:h//FILEIN4::
i/p string: DD DSN=RG60?.BU2.PFB25.COEDIT.C$CYCV00,DISP=SHR:h//FILEIN5:icon_biggrin.gifD DSN=
RG60?.BU2.PFB
i/p string: 42D.COEDITBS.C$CYCV00,DISP=SHR:://DSNICNTL DD * :1 DESPOOL RDSN=RC3

In first line $CYC is splitted as '$' and 'CYC' due to which it's not replaced.

Kind Regards,
Chanchal
Back to top
View user's profile Send private message
chanchalS

New User


Joined: 30 Nov 2010
Posts: 5
Location: Pune, India

PostPosted: Mon Dec 13, 2010 1:45 pm    Post subject:
Reply with quote

Hi John/Akatsukami,

Here's the sequence of steps that I'm doing:

1) I'm taking input from users via PANEL.
2) Based on input provided, I'm creating a PDS with following attributes:

ADDRESS "TSO" "ALLOC DD(DD) DS('"DSNAME"') NEW",
"DSORG(PO) RECFM(F M) LRECL(80) SPACE(50, 50) DIR(10) TRACKS"

3) Once PDS is created, I'm copying members from a MASTER PDS. Also renaming members as per the input provided in step 1 using following command:
Copying:
"LMCOPY FROMID("INDD1") TODATAID("OUTDD1") FROMMEM(*)
REPLACE PACK"

Renaming:Do Forever
"ISPEXEC LMMLIST DATAID("dataid") OPTION(LIST) MEMBER(oldmem)"
If rc <> 0 Then Leave
oldmem1 = DELSTR(oldmem,8)
newmem = oldmem1||site
"ISPEXEC LMMREN DATAID("dataid") MEMBER("oldmem")",
"NEWNAME("newmem") NOENQ"

4) After all the members are copied and renamed, I'm replacing certain 'control' string like 'test node', 'cycle' etc with the values/input provided in step 1.
Back to top
View user's profile Send private message
John L. McConnell

New User


Joined: 10 Dec 2010
Posts: 11
Location: Orlando, FL

PostPosted: Mon Dec 13, 2010 8:22 pm    Post subject:
Reply with quote

Well, it's obvious what to do. It looks as if the record boundaries are delimited by the "://h" string. So before fou can discover the strings you want to replica, you have to reconstruct the file format to the original records. Your REXX programming skills appear to be solid, as is your strategy. So you can use the approach of building a temp = IN.S||IN.S1, as I suggested before. Then you will scan temp for the delimiter string and build a new array (NEW.?) with the logical records as you see them when you view the original PDS member. Then your scan and replace logic will work as you loop through the NEW. array. The stumper is still the question of how the records of the original PDS member became reformatted in this very normal, very reasonable procedure. Is there any chance that the input PDS is RECFM=VB? Even so, I don't think REXX EXECIO gives you the RDW, does it? I'm just musing out loud to try to account for the "://h" string...
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Mon Dec 13, 2010 8:38 pm    Post subject: Reply to: REXX :Issue with replacing string in PDS memebers
Reply with quote

CS, just don't forget that if you PACK the dataset contents, then you can only access those contents via ISPF services.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Mon Dec 13, 2010 9:38 pm    Post subject:
Reply with quote

Right after I reached Akatsukami message, I thought: the input is packed.

Best solution: follow expat advice and use a macro.
Back to top
View user's profile Send private message
John L. McConnell

New User


Joined: 10 Dec 2010
Posts: 11
Location: Orlando, FL

PostPosted: Tue Dec 14, 2010 12:58 am    Post subject:
Reply with quote

Thanks for reporting that result. This was driving me nuts! Best of luck. icon_smile.gif
Back to top
View user's profile Send private message
chanchalS

New User


Joined: 30 Nov 2010
Posts: 5
Location: Pune, India

PostPosted: Tue Dec 14, 2010 5:10 pm    Post subject:
Reply with quote

Dear All,
Thanks for all your responses!!

I'm able to fix it..as stated above, the datasets were packed.I removed 'REPLACE PACK' from copying command:

"LMCOPY FROMID("INDD1") TODATAID("OUTDD1") FROMMEM(*) "

Warm Regards,
Chanchal
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts DFHRESPONSE returns issue divated CICS 3 Wed Nov 02, 2016 6:32 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts Replace repeated JCL with looping REXX prino CLIST & REXX 3 Thu Oct 13, 2016 5:30 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us