I'm getting INIT syntax error.
check for position 52 (3) in i/p = 220 or 230 then change the output position 1-25 as SYSTEM INPUT,
then change the Julian date in Position (9 - YYDDD, pos 37 - hhmmss) to DD/MM/YYYY-hh:mm:ss:000000
Cant we check multiple condition in each record? if so, please advise
P.S.
A very ancient hint:
Debug your code step-by-step, not all-in-one.
E.g., try your first IFTHEN=clause only, verify its result, and ONLY AFTER VERIFICATION start adding extra IFTHEN=
Joined: 30 Apr 2020 Posts: 10 Location: United States
sergeyken wrote:
andy12 wrote:
I wanted to replace position 1 to 25 as SYSTEM INPUT. if position 52,3 = ('220' or '100' or '001')
Please, re-read my reply more carefully. I tried to add more clarification...
Yes. i understand now.. with INIT and BUILD my layout was changed.. Let me add condition to move my check condition from 52,3 = ('220' or '100' or '001') to new position in the output file.
Code:
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:1,25,
26:9,5,Y2T,DT=(MD4/),C'-',
37:15,2,C'.',
40:17,2,C'.',
43:19,2,C'.',C'000000',
52:55,10,
62:46,5,
78:52,3)), --> moving it to new location
IFTHEN=(WHEN=(78,3,CH,EQ,C'230'),
OVERLAY=(1:SYSTEM INPUT ')) --> goes till position 25
In the last sample there is a bug: the original field (46,5) has been overridden by the time it is used at the end.
For more clarity I would suggest to perform date/time conversion in separate fields, and rebuild the output record in full at the very end.
Code:
* format date/time as separate fields
INREC OVERLAY=(81:9,5,Y2T,DT=(MD4/), 'MM/DD/YYYY'
91:15,2,C'.', 'HH.MM.SS'
17,2,C'.',
19,2)
SORT FIELDS=COPY
* make conditional replacement of selected records
OUTREC IFTHEN=(WHEN=(52,3,CH,EQ,L(C'220',C'100',C'001')),
OVERLAY=(1:C'SYSTEM INPUT '))
* combine final record from parts of original one, field after field
OUTFIL BUILD=(1,25, old/replaced part
81,10,C'-', formatted date
91,8,C'.000000', formatted time
55,10, moved old part
46,5) moved old part
*----+----1----+----2----+----3----+----4----+----5----+----6----+----7
*AB...*01241940155514..¬1207/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 07/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 07/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 07/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 99/99/9999-HH.MM.SS.000000 ABCD
*----+----1----+----2----+----3----+----4----+----5----+----6----+----7
END
Joined: 30 Apr 2020 Posts: 10 Location: United States
sergeyken wrote:
In the last sample there is a bug: the original field (46,5) has been overridden by the time it is used at the end.
For more clarity I would suggest to perform date/time conversion in separate fields, and rebuild the output record in full at the very end.
Code:
* format date/time as separate fields
INREC OVERLAY=(81:9,5,Y2T,DT=(MD4/), 'MM/DD/YYYY'
91:15,2,C'.', 'HH.MM.SS'
17,2,C'.',
19,2)
SORT FIELDS=COPY
* make conditional replacement of selected records
OUTREC IFTHEN=(WHEN=(52,3,CH,EQ,L(C'220',C'100',C'001')),
OVERLAY=(1:C'SYSTEM INPUT '))
* combine final record from parts of original one, field after field
OUTFIL BUILD=(1,25, old/replaced part
81,10,C'-', formatted date
91,8,C'.000000', formatted time
55,10, moved old part
46,5) moved old part
*----+----1----+----2----+----3----+----4----+----5----+----6----+----7
*AB...*01241940155514..¬1207/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 07/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 07/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 07/12/2024-15.55.14.000000124356778 ABCD
*SYSTEM INPUT 99/99/9999-HH.MM.SS.000000 ABCD
*----+----1----+----2----+----3----+----4----+----5----+----6----+----7
END