David Shary
New User
Joined: 01 Jul 2012 Posts: 1 Location: USA
|
|
|
|
There is a file where (see attachment) a field in all records needs to have leading zeros suppressed, for example:
004102109 needs to be 4102109. I am able to make this work as long as the fields are located in the same position. Unfortunately in my file the data is delimited and not always in the same location, although it is always right after the 6th delimiter (|~|). Do you know how to position the sort to the location based on the number of delimiters and then do the suppression?
Code below will work if the exact position is known for a particular record (see attachment for record details):
Code: |
SORT FIELDS=COPY
SUM FIELDS=(64,09,ZD)
OUTFIL IFTHEN=(WHEN=(53,5,CH,EQ,C'CHBRX'),
OVERLAY=(64:64,9,ZD,M10,LENGTH=9,64:64,9,
SQZ=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"')),HIT=NEXT),
IFTHEN=(WHEN=(53,5,CH,EQ,C'CHBRX'),
OVERLAY=(64:64,9,
SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),
IFTHEN=(WHEN=(53,5,CH,EQ,C'CHBRX'),
FINDREP=(IN=C'"',OUT=C'')) |
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8 1 2 3
2930078510~00001|~|R|~|00001|~|20111127010101|~|CHBRX|~||~|3192431|~|CHBRX~02220 <<<<<<< I was able to suppress the zeros because I new the exact column for this record
2930078510~00001|~|R|~|00002|~|20111127010101|~|CHBRX|~||~|3192431|~|CHBRX~02220
2844321610~00001|~|P|~|00001|~|20111127010101|~|HANRX|~|66638|~|004158481|~|HANR <<<<<< this needs to be suppressed as well but it begins in another column
2844321610~00001|~|P|~|00002|~|20111127010101|~|HANRX|~|66638|~|004158481|~|HANR
2157690610~00001|~|R|~|00001|~|20111127010101|~|NALC|~|GROUP|~|000294922|~|NALC~
2157690610~00001|~|R|~|00002|~|20111127010101|~|NALC|~|GROUP|~|000294922|~|NALC~
2324411610~00001|~|R|~|00001|~|20111127010101|~|NALC|~|GROUP|~|000294922|~|NALC~
|
Code that works based on looking at a fixed column is below. Note that the variable length of the record was taken into account by adding 4 bytes to the position. 'CHBRX' starts in column 49 on the layout but 4 was addded to make the location 53 as used in the code:
Your post has been Code'd and the attachment inlined.
Please use the Code tags to preserve spacing where necessary and post file examples in the Code tags, not as attachments. |
|