|
View previous topic :: View next topic
|
| Author |
Message |
Raymond Sachs
New User
Joined: 13 Dec 2007 Posts: 45 Location: USA
|
|
|
|
Dear Listers,
I want to look for 'L' and replace it with a zero (0). The Character
'L' can occur only between 6 and 9 positions. We are a SYNCSORT shop.
Input file: FB
| Code: |
************************
ABCD LLLGHIJ 1990-12-31
ABCD FLLGHIJ 2010-12-31
ABCD LFGGHIJ 1993-12-31
ABCD UFFGHIJ 1999-12-31
ABCD LLLLHIJ 2009-12-31
************************
|
I tried to use the following cards
| Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(6,1,CH,EQ,C'L'),OVERLAY=(6:C'0')),
IFTHEN=(WHEN=(7,1,CH,EQ,C'L'),OVERLAY=(7:C'0')),
IFTHEN=(WHEN=(8,1,CH,EQ,C'L'),OVERLAY=(8:C'0')),
IFTHEN=(WHEN=(9,1,CH,EQ,C'L'),OVERLAY=(9:C'0'))
|
Output is not what I desired. It seems only the first occurrence of 'L'
is being replaced.
| Code: |
************************
ABCD 0LLGHIJ 1990-12-31
ABCD F0LGHIJ 2010-12-31
ABCD 0FGGHIJ 1993-12-31
ABCD UFFGHIJ 1999-12-31
ABCD 0LLLHIJ 2009-12-31
************************
|
What I require is
| Code: |
************************
ABCD 000GHIJ 1990-12-31
ABCD F00GHIJ 2010-12-31
ABCD 0FGGHIJ 1993-12-31
ABCD UFFGHIJ 1999-12-31
ABCD 0000HIJ 2009-12-31
************************
|
Any pointers or help will be greatly appreciated |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
To get multiple matches from IFTHEN with and expression, you need HIT=NEXT so that the next IFTHEN will be processed for that record. For your case, you'll need three of them.
You might check if your Syncsort has FINDREP (find and replace). |
|
| Back to top |
|
 |
bodatrinadh
Active User

Joined: 05 Jan 2007 Posts: 101 Location: chennai (India)
|
|
|
|
HI Raymond Sachs,
Try the below code. Added " HIT=NEXT " to your code.
| Code: |
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(6,1,CH,EQ,C'L'),OVERLAY=(6:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(7,1,CH,EQ,C'L'),OVERLAY=(7:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(8,1,CH,EQ,C'L'),OVERLAY=(8:C'0'),HIT=NEXT),
IFTHEN=(WHEN=(9,1,CH,EQ,C'L'),OVERLAY=(9:C'0'))
|
Your expected Output :-
| Code: |
ABCD 000GHIJ 1990-12-31
ABCD F00GHIJ 2010-12-31
ABCD 0FGGHIJ 1993-12-31
ABCD UFFGHIJ 1999-12-31
ABCD 0000HIJ 2009-12-31
|
Or you can use FINDREP.
| Code: |
SORT FIELDS=COPY
OUTREC FINDREP=(INOUT=(C'L',C'0'),STARTPOS=6,ENDPOS=9)
|
Thanks
-3nadh |
|
| Back to top |
|
 |
Raymond Sachs
New User
Joined: 13 Dec 2007 Posts: 45 Location: USA
|
|
|
|
Bill/Bodatrinadh,
The HIT=NEXT syntax worked. That is exactly what I wanted. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|