View previous topic :: View next topic
Author
Message
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi, I need help of you experts here.........
I have got an input file (LRECL=80, RECFM=FB) with sets of records as given below:
Code:
----+----1----+----2----+----3
01XX8 XXXXX8GIMS
02XX8 XXXXX813SALT
14XX8 XXXXX811022051
15XX8 XXXXX831001102
99XX8 XXXXX8
01X18 XXXX18GIMS
02X18 XXXX1823GILT
99X18 XXXX18
01118 XXX118GIMS
02118 XXX11813SALT
14118 XXX11811022051
15118 XXX11831001102
99118 XXX118
I would like to copy 02, 14 and 15 records whenever the 02 has '13SALT' at 16th column.
Expected Output:
Code:
----+----1----+----2----+----3
02XX8 XXXXX813SALT
14XX8 XXXXX811022051
15XX8 XXXXX831001102
02118 XXX11813SALT
14118 XXX11811022051
15118 XXX11831001102
Please help.
Thanks.
Back to top
Nic Clouston Global Moderator Joined: 10 May 2007Posts: 2455 Location: Hampshire, UK
What if there is no 14 or 15 record but the 02 matches the criteria?
Back to top
superk Global Moderator Joined: 26 Apr 2004Posts: 4652 Location: Raleigh, NC, USA
Off hand, I'd set up an IFTHEN= GROUP to group together all of the records that have '02' in the first two bytes, and PUSH the content of positions 16 through 21 to the end of the record.
Then, you can INCLUDE the records with '02', '14', or '15' in the first two bytes AND '13SALT' as the group.
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Hi,
Thanks for the suggestion.........got the expected results.
Back to top
dick scherrer Moderator Emeritus Joined: 23 Nov 2006Posts: 19244 Location: Inside the Matrix
Good to hear it is working - thank you for letting us know
If you post your solution, it will probably help someone else with a similar requirement one day.
d
Back to top
ramsri Active User Joined: 18 Oct 2008Posts: 380 Location: India
Yes Dick.........
Code:
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'02'),
PUSH=(50:16,6))
SORT FIELDS=COPY
OUTFIL INCLUDE=((1,2,CH,EQ,C'02',AND,50,6,CH,EQ,C'13SALT'),OR,
(1,2,CH,EQ,C'14',AND,50,6,CH,EQ,C'13SALT'),OR,
(1,2,CH,EQ,C'15',AND,50,6,CH,EQ,C'13SALT'))
Thanks.
Back to top
Please enable JavaScript!