|
View previous topic :: View next topic
|
| Author |
Message |
andy12
New User
.jpg)
Joined: 30 Apr 2020 Posts: 18 Location: United States
|
|
|
|
I have a requirement, where i need to check and replacement few conditions in each single record.
Here is my input
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
AB...*01241940155514..¬1213 123*3456789 99US7ABCD 1220124356778 01......
AB...*01YYDDD0HHMMSS..¬ECSS éââ* ABCD 220
|
| Code: |
----+----1----+----2----+----3----+----4----+----5----+
SYSTEM INPUT 07/12/2024-21.14.00.000000
|
here is my SYSIN code
//SYSIN DD *
INREC IFTHEN=(WHEN=(52,3,CH,EQ,C'220'),
OVERLAY=(1,25,C'SYSTEM INPUT')),
IFTHEN=(WHEN=INIT,
BUILD=(26:9,5,Y2T,DT=(MD4/),
C'-',37:15,2,C'.',40:17,2,C'.',43:19,2,C'.',C'000000'))
OPTION COPY
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 |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
If you use the right sequence of statements, it's easier to read. Check the manual
Also you write DD/MM/YYYY but have coded MD4/ plus a different time format  |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
Don't forget to use the Code button:
| andy12 wrote: |
here is my SYSIN code
| Code: |
//SYSIN DD *
INREC IFTHEN=(WHEN=(52,3,CH,EQ,C'220'),
OVERLAY=(1,25,C'SYSTEM INPUT')),
IFTHEN=(WHEN=INIT,
BUILD=(26:9,5,Y2T,DT=(MD4/),
C'-',37:15,2,C'.',40:17,2,C'.',43:19,2,C'.',C'000000'))
OPTION COPY |
please advise |
|
|
| Back to top |
|
 |
andy12
New User
.jpg)
Joined: 30 Apr 2020 Posts: 18 Location: United States
|
|
|
|
| Joerg.Findeisen wrote: |
If you use the right sequence of statements, it's easier to read. Check the manual
Also you write DD/MM/YYYY but have coded MD4/ plus a different time format  |
Sorry for the typo.. i was expecting MM/DD/YYYY format..
| 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)),
IFTHEN=(WHEN=(52,3,CH,EQ,C'220'),
OVERLAY=(1:1,25,C'SYSTEM INPUT'))
|
Input
| Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
//SORTIN DD *
AB...*01241940155514..¬1213 123*3456789 99US7ABCD 1220124356778 01......
|
output
| Code: |
----+----1----+----2----+----3----+----4----+----5----+
SYSTEM INPUT 07/12/2024-21.14.00.000000 124356778
|
I'm getting the output but position 1:25 is not overlaid with 'SYSTEM INPUT' |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
It might be easier to understand, even for yourself!
| 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)),
IFTHEN=(WHEN=(52,3,CH,EQ,C'220'),
OVERLAY=(1:1,25,
C'SYSTEM INPUT'))
END |
After this line your input record has changed:
| Code: |
. . . . . . . . . . . . .
52:55,10,
. . . . . . . . . . . |
So, what do you expect to check by this???
| Code: |
. . . . . . . . . . . .
IFTHEN=(WHEN=(52,3,CH,EQ,C'220'),
. . . . . . . . . . . |
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= |
|
| Back to top |
|
 |
andy12
New User
.jpg)
Joined: 30 Apr 2020 Posts: 18 Location: United States
|
|
|
|
| sergeyken wrote: |
It might be easier to understand, even for yourself!
| 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)),
IFTHEN=(WHEN=(52,3,CH,EQ,C'220'),
OVERLAY=(1:1,25,
C'SYSTEM INPUT'))
END |
After this line:
| Code: |
. . . . . . . . . . . . .
52:55,10,
. . . . . . . . . . . |
| Quote: |
What do you expect to check by this???
| Code: |
. . . . . . . . . . . .
IFTHEN=(WHEN=(52,3,CH,EQ,C'220'),
. . . . . . . . . . . |
|
|
I wanted to replace position 1 to 25 as SYSTEM INPUT. if position 52,3 = ('220' or '100' or '001')
Thanks @sergeyken. Appreciate your help. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| 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... |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
That should be enough hints to get over the hump
I would have used IFTHEN <cond> BUILD and another IFTHEN NONE afterwards. |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| Joerg.Findeisen wrote: |
That should be enough hints to get over the hump
I would have used IFTHEN <cond> BUILD and another IFTHEN NONE afterwards. |
... and do it STEP-BY-STEP, please! |
|
| Back to top |
|
 |
andy12
New User
.jpg)
Joined: 30 Apr 2020 Posts: 18 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
|
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
| Code: |
OPTION COPY
INREC OVERLAY=(26:9,5,Y2T,DT=(MD4/),C'-',
15,2,C'.',
17,2,C'.',
19,2,C'.000000')
OUTREC IFTHEN=(WHEN=(52,3,CH,EQ,L(C'220',C'100',C'001')),
OVERLAY=(1:C'SYSTEM INPUT '))
OUTFIL BUILD=(1,51,
55,10,
46,5)
END |
|
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
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 |
|
|
| Back to top |
|
 |
andy12
New User
.jpg)
Joined: 30 Apr 2020 Posts: 18 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 |
|
Thanks for redoing it again. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|