View previous topic :: View next topic
|
Author |
Message |
chanchalS
New User
Joined: 30 Nov 2010 Posts: 5 Location: Pune, India
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
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 |
|
|
John L. McConnell
New User
Joined: 10 Dec 2010 Posts: 11 Location: Orlando, FL
|
|
|
|
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 |
|
|
chanchalS
New User
Joined: 30 Nov 2010 Posts: 5 Location: Pune, India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10886 Location: italy
|
|
|
|
given the sample You posted...
again what would be wrong in using expat' s suggestion (EDIT macro) ? |
|
Back to top |
|
|
John L. McConnell
New User
Joined: 10 Dec 2010 Posts: 11 Location: Orlando, FL
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
Chancal, is your PDS member the result of FTPing a data set to the mainframe? |
|
Back to top |
|
|
chanchalS
New User
Joined: 30 Nov 2010 Posts: 5 Location: Pune, India
|
|
|
|
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:D DSN=RC30?.BU1.PFB10.OUTSORCD.C$
CYCV00,DIS
i/p string: P=SHR:h//FILEIN3:D 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:D 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 |
|
|
chanchalS
New User
Joined: 30 Nov 2010 Posts: 5 Location: Pune, India
|
|
|
|
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 |
|
|
John L. McConnell
New User
Joined: 10 Dec 2010 Posts: 11 Location: Orlando, FL
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Right after I reached Akatsukami message, I thought: the input is packed.
Best solution: follow expat advice and use a macro. |
|
Back to top |
|
|
John L. McConnell
New User
Joined: 10 Dec 2010 Posts: 11 Location: Orlando, FL
|
|
|
|
Thanks for reporting that result. This was driving me nuts! Best of luck. |
|
Back to top |
|
|
chanchalS
New User
Joined: 30 Nov 2010 Posts: 5 Location: Pune, India
|
|
|
|
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 |
|
|
|