View previous topic :: View next topic
|
Author |
Message |
kokwind
New User
Joined: 22 May 2008 Posts: 15 Location: Singapore
|
|
|
|
Hi all
I have a file as below
Code: |
----+----1----+----2----+----3----+----4
DB-NAME TS-NAME DD NNNN
GCD FNGCD GC 0001
GCD FNGCDRAD GC 0002
GCD FNGCDRCE GC 0003
GCD FNGCDROS GC 0004
|
I have to change all the dataset of the file as below
is there any tso command or any other way to do it?
Code: |
----+----1----+----2----+----3----+----4-
DB-NAME TS-NAME DD NNNN
GCD FNGCD GC 0001
GCD FNGCDRAD GC 0002
GCD FNGCDRCE GC 0003
GCD FNGCDROS GC 0004
|
Thanks n Regards |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
What did you try? Which manuals couldn't you find? |
|
Back to top |
|
|
kokwind
New User
Joined: 22 May 2008 Posts: 15 Location: Singapore
|
|
|
|
I try to use change command,but it can not do it.
Code: |
C 'text1' 'text2' Changes next occurrence of text string
C 'text1' 'text2' all Changes all occurrences of text string
C 'text1' 'text2' all nn Changes all occurrences of text string in column nn
C 'text1' 'text2' all X Changes all occurrences of text string in excluded lines
C 'text1' 'text2' all NX Changes all occurrences of text string in Non excluded lines
C 'text1' 'text2' first Changes first occurrences of text string
C 'text1' 'text2' prev Changes previous occurrences of text string
C 'text1' 'text2' last Changes last occurrences of text string
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
You might try with a combination of the
BOUNDS command to isolate the columns to process
and the shift >/>> line command to do it |
|
Back to top |
|
|
kokwind
New User
Joined: 22 May 2008 Posts: 15 Location: Singapore
|
|
|
|
i have 4000 members in a pds D/S |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
here is a snippet to parse and realign
Code: |
#!/usr/bin/rexx
line.1 = "DB-NAME TS-NAME DD NNNN"
line.2 = "GCD FNGCD GC 0001"
line.3 = "GCD FNGCDRAD GC 0002"
line.0 = 3
size = 8
do l = 1 to line.0
newl.l = ""
tail = line.l
do while ( tail \= "" )
parse var tail tokn tail
newl.l = newl.l || left(tokn, size)
end
end
do l = 1 to line.0
say l line.l
say l newl.l
end
|
and here is a snippet to apply an edit macro to all the member of a pds
www.ibmmainframes.com/viewtopic.php?t=25947&highlight= |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
I assumed the length of the columns like these
1st - 9
2nd - 10
3rd - 10
4th - 4
So, here is the enrico's modified code.
Code: |
/*rexx*/
line.1 = "DB-NAME TS-NAME DD NNNN"
line.2 = "GCD FNGCD GC 0001"
line.3 = "GCD FNGCDRAD GC 0002"
line.0 = 3
size = 8
do l = 1 to line.0
newl.l = ""
word1 = subword(line.l,1,1)
newl.l = strip(word1) || copies(' ',9-length(strip(word1)))
word1 = subword(line.l,2,1)
newl.l = newl.l || strip(word1) || copies(' ',10-length(strip(word1)))
word1 = subword(line.l,3,1)
newl.l = newl.l || strip(word1) || copies(' ',10-length(strip(word1)))
word1 = subword(line.l,4,1)
newl.l = newl.l || strip(word1) || copies(' ',4-length(strip(word1)))
end
do l = 1 to line.0
say l newl.l
end
exit
|
Output:
Code: |
1 DB-NAME TS-NAME DD NNNN
2 GCD FNGCD GC 0001
3 GCD FNGCDRAD GC 0002
|
|
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
when You modify somebody else code the objective is to make it better, not worse
what is wrong with my code ? it is open and does not depend on the number of fields/words
and ... why write Your own version of the left builtin function ???
if You want to stick to a FIXED and IMMUTABLE number of words You can simply use
Code: |
parse var line.l word1 word2 word3 word4 . |
do not forget the final dot ( read the PARSE documentation to understand why ) |
|
Back to top |
|
|
kokwind
New User
Joined: 22 May 2008 Posts: 15 Location: Singapore
|
|
|
|
Enrico and sureshpathi10
Thanks a lot for your valuabe inputs.
Your script gave me a better insight of how things work.
Code: |
/*REXX*/
PDS_NAME = 'MY PDS LIB'
SIZE = 8
CALL OUTTRAP "TRAP."
"LISTDS '"||PDS_NAME||"' MEMBERS"
IF RC <> 0 THEN DO
SAY "ERROR: DATA SET DOES NOT EXIST"
EXIT 12
END
CALL OUTTRAP "OFF"
DO I = 1 TO TRAP.0
IF TRAP.I = "--MEMBERS--" THEN LEAVE
END
I = I + 1
DO J = I TO TRAP.0
PARSE VALUE TRAP.J WITH MEM
MEM = STRIP(MEM)
"ALLOC F(XXIN) DS('"PDS_NAME"("MEM")') SHR REUSE"
"EXECIO * DISKR XXIN (FINIS STEM LINE."
"FREE F(XXIN)"
HIT = 0
DO L = 1 TO LINE.0
NEWL.L = ""
WORD1 = SUBWORD(LINE.L,1,1)
NEWL.L = STRIP(WORD1) || COPIES(' ',9-LENGTH(STRIP(WORD1)))
WORD1 = SUBWORD(LINE.L,2,1)
NEWL.L = NEWL.L || STRIP(WORD1) || COPIES(' ',10-LENGTH(STRIP(WORD1)))
WORD1 = SUBWORD(LINE.L,3,1)
NEWL.L = NEWL.L || STRIP(WORD1) || COPIES(' ',10-LENGTH(STRIP(WORD1)))
WORD1 = SUBWORD(LINE.L,4,1)
NEWL.L = NEWL.L || STRIP(WORD1) || COPIES(' ',4-LENGTH(STRIP(WORD1)))
END
"ALLOC F(XXIN) DS('"PDS_NAME"("MEM")') SHR REUSE"
"EXECIO * DISKW XXIN (FINIS STEM NEWL."
"FREE F(XXIN)"
END
EXIT
|
|
|
Back to top |
|
|
|