IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

TSO change colume command needed


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kokwind

New User


Joined: 22 May 2008
Posts: 15
Location: Singapore

PostPosted: Tue Dec 24, 2013 1:26 pm
Reply with quote

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
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Tue Dec 24, 2013 1:31 pm
Reply with quote

What did you try? Which manuals couldn't you find?
Back to top
View user's profile Send private message
kokwind

New User


Joined: 22 May 2008
Posts: 15
Location: Singapore

PostPosted: Tue Dec 24, 2013 1:57 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Dec 24, 2013 2:07 pm
Reply with quote

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
View user's profile Send private message
kokwind

New User


Joined: 22 May 2008
Posts: 15
Location: Singapore

PostPosted: Tue Dec 24, 2013 3:01 pm
Reply with quote

i have 4000 members in a pds D/S
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Dec 24, 2013 3:21 pm
Reply with quote

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
View user's profile Send private message
sureshpathi10

Active User


Joined: 03 May 2010
Posts: 154
Location: Kuala Lumpur

PostPosted: Tue Dec 24, 2013 7:18 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Dec 24, 2013 7:28 pm
Reply with quote

when You modify somebody else code the objective is to make it better, not worse icon_evil.gif

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
View user's profile Send private message
kokwind

New User


Joined: 22 May 2008
Posts: 15
Location: Singapore

PostPosted: Fri Dec 27, 2013 9:06 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Routing command Address SDSF to other... TSO/ISPF 2
No new posts DTL - how to define key with stacked ... TSO/ISPF 3
No new posts LTJ command CA Products 4
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top