View previous topic :: View next topic
|
Author |
Message |
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi All,
I am currently working on a task, task is to compare two sorted files on key field and report report as below. If keys are matched then I need to compare FLD2, FLD4, FLD5 from both the files
Here is the sample input
Code: |
[b]File 1 Data:
[/b]
KEY1 FLD1 FLD2 FLD3 FLD4 FLD6
---- ---- ---- ---- ---- ----
K001 F101 F201 F301 F402 F501
K002 F102 F202 F30X F40A F50X
K004 F10A F20X F304 F403 F505
K006 F10A F20X F304 F403 F505
K008 F10A F20X F304 F403 F505
[b]File 2 Data:[/b]
KEY1 FLD1 FLD2 FLD3 FLD4 FLD6
---- ---- ---- ---- ---- ----
K002 F101 F20A F301 F401 F501
K003 F102 F202 F30X F402 F50X
K004 F10A F20X F304 F403 F505
K005 F10A F20X F304 F403 F505
K008 F10A F20X F304 F403 F505
|
Expected output is:
Code: |
K001 NOT FOUND IN FILE2
K002 FLD2 NOT MATCHED
F202 F20A
K002 FLD4 NOT MATCHED
F40A F402
K003 NOT FOUND IN FILE1 |
Can we achieve this using ICETOOL/DFSORT? If yes, kindly guide me.
PS: Both the files are fixed length. |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2146 Location: USA
|
|
|
|
Please, take one of THOUSANDS of existing examples, and TRY TO DO SOMETHING by yourself. Only in that case it can be discussed at this forum.
Your sample of input is not related in ANY MANNER to your sample of output data. At least it is not obvious.
Hints:
1) read about the statements JOINKEYS, JOIN, and REFORMAT
2) read about the parameters IFTHEN=, and WHEN= |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1338 Location: Bamberg, Germany
|
|
|
|
Basically it's possible to do it using SORT. I am able to get the following results:
Code: |
****** ***************************
000001 K001 Not found in F2
000002 K002 FLD1 Not matched
000003 F102 F101
000004 K002 FLD2 Not matched
000005 F202 F20A
000006 K002 FLD3 Not matched
000007 F30X F301
000008 K002 FLD4 Not matched
000009 F40A F401
000010 K002 FLD5 Not matched
000011 F50X F501
000012 K003 Not found in F1
000013 K005 Not found in F1
000014 K006 Not found in F2
****** *************************** |
Let us know if you need further help on this topic. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
Hi All,
Apologies for the late reply.
I have started exploring JOINKEYS and REFORMAT in DFSORT to implement solution for my request, however, customer confirmed to write the code in COBOL so I am writing code in COBOL.
Thank you so much for your guidance.
Thanks,
Satish |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Okay thanks if you ever wonder how to do it using DFSORT then give it a try .. it’s better than cobol program and customer may like it too . |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1338 Location: Bamberg, Germany
|
|
|
|
Also to mention, for the given sample, it's just a little more than 50 lines of SORT statements. The challenge is not the join operation itself, but the floating field comparison afterwards. |
|
Back to top |
|
|
|