|
|
| Author |
Message |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 710 Location: Chennai, India
|
|
|
|
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 |
|
 |
References
|
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 182 Location: Bangalore
|
|
|
|
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 |
|
 |
krisprems
Senior Member
Joined: 27 Nov 2006 Posts: 624 Location: India
|
|
|
|
shankar.v
What if the i/p contains
Don't you need
I think, this task would be easier if we could use PARSE |
|
| Back to top |
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 182 Location: Bangalore
|
|
|
|
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 |
|
 |
shankar.v
Active User
Joined: 25 Jun 2007 Posts: 182 Location: Bangalore
|
|
|
|
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 |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 654
|
|
|
|
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 |
|
 |
krisprems
Senior Member
Joined: 27 Nov 2006 Posts: 624 Location: India
|
|
|
|
gcicchet
What about just mentioning
| Code: |
$$DD01 COPY EDIT=(1,0,C'AB',C'CD')
|
in your SYSIN card |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 654
|
|
|
|
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 |
|
 |
krisprems
Senior Member
Joined: 27 Nov 2006 Posts: 624 Location: India
|
|
|
|
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 |
|
 |
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1478 Location: Bangalore,India
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4579 Location: San Jose, CA
|
|
|
|
| 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 |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4579 Location: San Jose, CA
|
|
|
|
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 |
|
 |
|
|
|