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

Changing strings from unknown position


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Sat Sep 29, 2007 4:02 pm
Reply with quote

I want to replace a file name between () but the position of () may change
in input file

ex :
input file :
DELETE PDSE1.XXXXXX.DATA(TOTO)
DELETE PDS2.XXXXXX.DATA(TOTO2)
DELETE PDS2.XXXXXX.DATA(TOTOMORE)
......
output file :
DELETE PDSUNIQU.XXXXXX.DATA(TOTO)
DELETE PDSUNIQU.XXXXXX.DATA(TOTO2)
DELETE PDSUNIQU.XXXXXX.DATA(TOTOMORE)
......


I think It could be possible with "IFTHEN=(WHEN=..."
in ICETOOL (or other)

as
...
IFTHEN=(WHEN=(29,1,CH,EQ,C'(',and,34,1,CH,EQ,C')',
BUILD=(1,9:C'PDSUNIQU.XXXXXX.DAT(',30,4,c')')),
IFTHEN=(WHEN=(28,1,CH,EQ,C'(',and,34,1,CH,EQ,C')',
BUILD=(1,9:C'PDSUNIQU.XXXXXX.DAT(',29,5,c')'))
IFTHEN=(WHEN=(28,1,CH,EQ,C'(',and,37,1,CH,EQ,C')',
BUILD=(1,9:C'PDSUNIQU.XXXXXX.DAT(',29,8,c')'))
...

But, for all positions of "(" and positions of ")" in 70 columns the number of IFTHEN would be astronomic !

Is there a better solution to do that ?
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Sat Sep 29, 2007 4:20 pm
Reply with quote

Searchman
Look at the topic Find and extract values from different positions
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Sep 29, 2007 8:35 pm
Reply with quote

Quote:
Is there a better solution to do that ?


Yes, with DFSORT's PARSE function which has been available since April, 2006. Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/80)
//SORTOUT DD DSN=...  output file (FB/80)
//SYSIN    DD    *
  OPTION COPY
  INREC PARSE=(%01=(STARTAT=C'(',ENDAT=C')',FIXLEN=10)),
    BUILD=(C'  DELETE  PDSUNIQU.XXXXXX.DATA',
           %01,
           80:X)
/*


For complete details on DFSORT's PARSE function, see:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Mon Oct 01, 2007 10:56 pm
Reply with quote

Thank you for this idea ! I didn't know this option which is quite powerful
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Fri Oct 05, 2007 12:15 am
Reply with quote

Now, I've got a problem because of the FIXLEN (=8) that can't be truncated
in fact, the parenthesis are not in the file this time

ex :
input file (member to delete starts at pos. 2, X* starts at pos. 11) :

Code:

 TODELET1 XXXXX YYYYYYYY
 TODELE   XXXXX YYYYYYYY
 TOD      XXXXX YYYYYYYY
......


output file :

Code:

DELETE PDSUNIQU.XXXXXX.DATA(TODELET1)
DELETE PDSUNIQU.XXXXXX.DATA(TODELE   )
DELETE PDSUNIQU.XXXXXX.DATA(TOD        )
......


and I want :

Code:

DELETE PDSUNIQU.XXXXXX.DATA(TODELET1)
DELETE PDSUNIQU.XXXXXX.DATA(TODELE)
DELETE PDSUNIQU.XXXXXX.DATA(TOD)
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Oct 05, 2007 1:17 am
Reply with quote

It's not clear if XXXXX represents a fixed value in position 11-15 or a value that can be different lengths. I'll assume it's a fixed value until you tell me otherwise. Given that assumption, you don't even need DFSORT's PARSE function for this - you just need DFSORT's SQZ function. Here's the DFSORT job to do what I think you want:

Code:

//S1    EXEC  PGM=ICEMAN                             
//SYSOUT    DD  SYSOUT=*                             
//SORTIN DD *                                       
 TODELET1 XXXXX YYYYYYYY                             
 TODELE   XXXXX YYYYYYYY                             
 TOD      XXXXX YYYYYYYY                             
//SORTOUT DD SYSOUT=*                               
//SYSIN    DD    *                                   
  OPTION COPY                                       
  INREC BUILD=(C'DELETE PDSUNIQU.',11,5,C'.DATA(',   
    2,9,SQZ=(SHIFT=LEFT,TRAIL=C')'))                 


SORTOUT will have:

Code:

DELETE PDSUNIQU.XXXXX.DATA(TODELET1) 
DELETE PDSUNIQU.XXXXX.DATA(TODELE)   
DELETE PDSUNIQU.XXXXX.DATA(TOD)       


If that's not what you need, then please do a better job of explaining what you do need. And please use code tags in your posts where appropriate.
Back to top
View user's profile Send private message
Searchman

New User


Joined: 28 Dec 2006
Posts: 80
Location: France

PostPosted: Fri Oct 05, 2007 2:54 am
Reply with quote

Yes, I think it is exactly what I wanted. I'll run it tomorrow. I didn't know this SQZ option too.
Thank's again !

Sorry not to have use quotes...
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Oct 05, 2007 3:38 am
Reply with quote

Quote:
For complete details on DFSORT's PARSE function, see:

Use [URL] BBCode for External Links


That doc I pointed you to earlier also contains details of the SQZ and JFY functions.

Quote:
Sorry not to have use quotes...


It's better to use the code tags for code rather than the quote tags.

Code:

     spaces are preserved with code tags


Quote:

spaces are not preserved with quote tags
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts changing defaults in db2 admin - Unlo... DB2 0
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
No new posts Tilde Characters Changing to COLONs i... CLIST & REXX 22
This topic is locked: you cannot edit posts or make replies. How to search multiple strings in a PDS IBM Tools 3
Search our Forums:

Back to Top