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

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


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

Moderator


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

PostPosted: Mon Oct 22, 2007 1:05 pm
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
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
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
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
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: 1702
Location: Australia

PostPosted: Thu Oct 25, 2007 6:12 am
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
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: 1702
Location: Australia

PostPosted: Thu Oct 25, 2007 11:04 am
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
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: 1436
Location: Bangalore,India

PostPosted: Fri Oct 26, 2007 9:02 am
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 Developer


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

PostPosted: Fri Oct 26, 2007 10:47 pm
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 Developer


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

PostPosted: Tue Aug 26, 2008 2:05 am
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:

Use [URL] BBCode for External Links
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top