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
 

 

Replace 'ab' 'cd' chars in the dataset using SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2284
Location: @my desk

PostPosted: Mon Oct 22, 2007 1:05 pm    Post subject: Replace 'ab' 'cd' chars in the dataset using SORT
Reply with quote

Hi ,

I want to replace 'ab' by 'cd' in a dataset.Moreover it can come at any position in the file.

Thanks in advance,
Arun


TITLE EDITED
Back to top
View user's profile Send private message

shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Oct 22, 2007 3:40 pm    Post subject:
Reply with quote

arcvns,

Please check with the following code for your requirement.
The below code will work fine for LRECL=80 and RECFM=F or RECFM=FB
Change the below code according to your LRECL and RECFM.

Code:
// EXEC PGM=ICETOOL                   
//TOOLMSG DD SYSOUT=*                 
//DFSMSG DD SYSOUT=*                   
//DUMMY DD *                           
DUMMY                                 
/*                                     
//INFILE DD *                         
ABAAAAAA                               
BBABBBBB                               
CCCCABCC                               
DDDDDDAB                               
ABEEEEEE                               
/*                                     
//T1 DD DSN=&&T1,DISP=(,PASS)         
//CTL3CNTL DD DSN=&&T2,DISP=(,PASS)   
//OUT DD SYSOUT=*                     
//TOOLIN DD *                         
 COPY FROM(DUMMY) TO(T1) USING(CTL1)                           
 COPY FROM(T1) TO(CTL3CNTL) USING(CTL2)                         
 COPY FROM(INFILE) TO(OUT) USING(CTL3)                         
/*                                                             
//CTL1CNTL DD *                                                 
 OUTFIL REPEAT=79                                               
/*                                                             
//CTL2CNTL DD *                                                 
 INREC FIELDS=(7X,C'IFTHEN=(WHEN=(',SEQNUM,5,ZD,               
 C',2,CH,EQ,C''AB''),OVERLAY=(',SEQNUM,5,ZD,C':C''CD'')),',80:X)
 OUTFIL IFTHEN=(WHEN=(22,05,ZD,EQ,01),OVERLAY=(2:C'INREC')),   
        IFTHEN=(WHEN=(52,05,ZD,EQ,79),OVERLAY=(65:X))           
/*                                                             
//                                                             

Output:
Code:
CDAAAAAA
BBCDBBBB
CCCCCDCC
DDDDDDCD
CDEEEEEE
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Oct 22, 2007 4:10 pm    Post subject:
Reply with quote

shankar.v

What if the i/p contains
Code:
ABAAAAAB

Don't you need
Code:
HIT=NEXT


I think, this task would be easier if we could use PARSE
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Oct 22, 2007 4:34 pm    Post subject:
Reply with quote

krisprems,

Quote:
shankar.v

What if the i/p contains Code:
ABAAAAAB


Don't you need Code:
HIT=NEXT

You are correct.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Mon Oct 22, 2007 5:32 pm    Post subject:
Reply with quote

arcvns,

Please check with the following code after fixing the problem which was identified by Krisperms.
Code:
// EXEC PGM=ICETOOL                   
//TOOLMSG DD SYSOUT=*                 
//DFSMSG DD SYSOUT=*                 
//DUMMY DD *                         
DUMMY                                 
/*                                   
//INFILE DD *                         
ABABABABAB                           
ABABABABAB                           
ABABABABAB                           
ABABABABAB                           
ABABABABAB                           
/*                                   
//T1 DD DSN=&&T1,DISP=(,PASS)         
//CTL3CNTL DD DSN=&&T2,DISP=(,PASS)   
//OUT DD SYSOUT=*                     
//TOOLIN DD * 
  COPY FROM(DUMMY) TO(T1) USING(CTL1)                                 
  COPY FROM(T1) TO(CTL3CNTL) USING(CTL2)                             
  COPY FROM(INFILE) TO(OUT) USING(CTL3)                               
 /*                                                                   
 //CTL1CNTL DD *                                                     
  OUTFIL REPEAT=79                                                   
 /*                                                                   
 //CTL2CNTL DD *                                                     
  INREC IFTHEN=(WHEN=INIT,BUILD=(7X,C'IFTHEN=(WHEN=(',SEQNUM,3,ZD,   
  C',2,CH,EQ,C''AB''),OVERLAY=(',SEQNUM,3,ZD,C':C''CD''),HIT=NEXT),',
  80:X))                                                             
  OUTFIL IFTHEN=(WHEN=(22,3,ZD,EQ,+1),OVERLAY=(2:C'INREC')),         
         IFTHEN=(WHEN=(22,3,ZD,EQ,+79),OVERLAY=(60:C')',10X))         
 /*                                                                   
 //                                                                   
                       
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Oct 25, 2007 6:12 am    Post subject: Reply to: Replace 'ab' 'cd' using sort
Reply with quote

If you have FILEAID then this should fulfil your requirement.
Code:
//*********************************************************************
//*                                                                     
//STEP0001 EXEC PGM=FILEAID                                             
//SYSPRINT DD SYSOUT=*                                                 
//DD01     DD DSN=I/P FILE                                             
//DD01O    DD DSN=O/P FILE                                             
//SYSIN    DD *                                                         
*                                                                       
$$DD01 COPY OUT=0,                                                     
              EDITALL=(1,0,C'AB',                                       
              C'CD')                                                   
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Oct 25, 2007 9:20 am    Post subject:
Reply with quote

gcicchet
What about just mentioning
Code:
$$DD01 COPY EDIT=(1,0,C'AB',C'CD')
in your SYSIN card
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1703
Location: Australia

PostPosted: Thu Oct 25, 2007 11:04 am    Post subject: Reply to: Replace 'ab' 'cd' using sort
Reply with quote

kRISPREMS,
why don't you explain why you would want to change my parameters as by changing them the results are not the same.

The OUT=0 parameter processes the entire file. no OUT parameter defaults to 999999999, which is a fairly high number but still not necessarily the entire file.

The EDIT parameter only changes the first occurrence of matched compare-data in a record.

To change all occurrences, use the EDITALL parameter.


cheers

Gerry
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Thu Oct 25, 2007 12:17 pm    Post subject:
Reply with quote

gcicchet
Quote:
why don't you explain why you would want to change my parameters as by changing them the results are not the same.
wanted to know the exact usage of the OUT=0 and EDITALL, the example i took was with only 3 records so i couldn't realize these things.
Anways thank you.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1439
Location: Bangalore,India

PostPosted: Fri Oct 26, 2007 9:02 am    Post subject:
Reply with quote

Frank,

Quote:
But the original request was to replace 'ab' with 'cd', not to replace 'a' with 'b' and 'c' with 'd'. ALTSEQ doesn't apply for the original request.


Quote:
For what, giving bad information?


I was not advising anyone to use ALTSEQ for the original requirement ('ab' to 'cd'). I know, altseq cannot be usde for replacing combination of characters.

Rather my intention was to correct Aaru as he provided the sort step using ALTSEQ for the orginial issue.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Fri Oct 26, 2007 10:47 pm    Post subject:
Reply with quote

I read back through all of the posts carefully - it was all quite confusing but I see now that you were trying to correct the error. There were so many off-topic posts that it was difficult to follow who was saying what to who. At any rate, I deleted all of the off-topic posts to avoid confusion. I seem to be doing that more and more lately - its tiresome and keeps me from working on more productive stuff and makes me cranky.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Aug 26, 2008 2:05 am    Post subject:
Reply with quote

You can now use DFSORT's new FINDREP function available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008) to do this kind of thing quite easily like this:

Code:

//S1   EXEC  PGM=ICEMAN                                         
//SYSOUT    DD  SYSOUT=*                                         
//SORTIN DD DSN=...  input file                                                   
//SORTOUT DD DSN=...  output file   
//SYSIN    DD    *                                               
  OPTION COPY                                                   
  INREC FINDREP=(IN=C'ab',OUT=C'cd')                               
/*


For complete details on the new FINDREP function and the other new functions available with PTF UK90013, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Browse dataset cvnlynn CLIST & REXX 4 Tue Jul 18, 2017 3:52 am
No new posts SORT to unpack a feild shr_amar DFSORT/ICETOOL 7 Fri Jul 07, 2017 4:32 am
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Optimize sort inrec parse vishwakotin DFSORT/ICETOOL 6 Mon Jun 26, 2017 11:15 pm
No new posts Reduce CPU Times for Join Sort santoshn SYNCSORT 12 Sat Jun 10, 2017 1:40 pm


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