View previous topic :: View next topic
|
Author |
Message |
senthamizh
New User
Joined: 27 Apr 2009 Posts: 23 Location: mumbai
|
|
|
|
I have a requirement to compare 2 file and write the matched records into output file with condition.
File 1: RECLEN=350,FB
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
APPLE20182018-02-01?
APPLE20182018-02-02?
CHIKU20182018-02-03?
CHIKU20182018-02-04?
LEMON20182018-02-05?
LEMON20182018-02-06?
TANGO20182018-02-07?
TANGO20182018-02-08? |
File 2: RECLEN=86,FB
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
********************************* Top of Data **********************************
APPLEvW1XXXX ....STOCK 2016-02-04xx..Y..V..IND..IND..S..........C..N.........
CHIKUvW1XXXX ....STOCK 2016-02-04xx..Y..V..IND..IND..S..........O..N.. ......
LEMONvW1XXXX ....STOCK 2016-02-04xx..Y..V..IND..IND..S..........D..N.. ......
TANGOlW1XXXX ....STOCK 2016-02-04xx..Y..V..IND..IND..S..........C..N.. ......
MANGOgW2XXXX ....STOCK 2016-02-04xx..Y..V..IND..IND..S..........M..N.. ......
PINEAMW2XXXX ...STOCK 2016-02-04xx..Y..V..IND..IND..S..........E..N.. ...... |
key for both file is 1,5.The condion is for matched records if (68,1) is C or D or O(in file2) then 1001 is inserted in outputfile,if (68,1) is M(in file2) then 1002 is inserted in outputfile.for example Apple in file1 is matching with file 2 .for Apple in file 2 @ position 68 is set as C,so in the outputfile @ position 10 '1001' needs to be inserted. can some one help me.
The output records should be
-
Code: |
---+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
APPLE201810012018-02-01?
APPLE201810012018-02-02?
CHIKU201810012018-02-03?
CHIKU201810012018-02-04?
LEMON201810012018-02-05?
LEMON201810012018-02-06?
TANGO201810022018-02-07?
TANGO201810022018-02-08? |
|
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Sentamizh,
With all due respect what have you tried so far..
Please let us know where you find difficulty or post the errors you have got if any
someone will be able to assist |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
Use simple dfsort join keys and ifthen conditions on reformatted records. ( you could have searched here and found many examples). |
|
Back to top |
|
|
|