View previous topic :: View next topic
|
Author |
Message |
ritnihi
New User
Joined: 30 Jul 2010 Posts: 7 Location: Bangalore
|
|
|
|
Hi,
I am having 2 files (File-1 and File-2). File-2 is having header part on the top (system date and other info). I have to extract the header part and match both the files on customer-id. The File-1 and File-2 is coming in sorted order.
I have tried 1 logic before procedure division:
SORT FILE-2 to S-FILE-2 +
USING (FILE-2 key) +
BEFORE HDR-EXTRACT para
But as my File-2 is coming in sorted order I can't use this logic.
Please help me if you have any solution for this. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
And since how long has Easytrieve been Mainframe COBOL.
Topic moved to correct forum. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
The header will not match, so what is the problem? |
|
Back to top |
|
|
ritnihi
New User
Joined: 30 Jul 2010 Posts: 7 Location: Bangalore
|
|
|
|
Hi,
I have to extract the header (1st record in file-2) and match other records in both the files......but the logic i m not getting how to do this??
If u have plz share it |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
Suggest you show the code you are using to compare the 2 files. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Try this :
Code: |
JOB INPUT(FILE-1 KEY(F1KEY) FILE-2 KEY(F2KEY))
IF MATCHED
* your matched processing goes here
END-IF
IF NOT MATCHED
IF FILE-2 AND FILE-2:RECORD-COUNT = 1
* your header record processing goes here
END-IF
END-IF
|
|
|
Back to top |
|
|
ritnihi
New User
Joined: 30 Jul 2010 Posts: 7 Location: Bangalore
|
|
|
|
I have got the solution. I kept 2 JOB INPUT syntax inside the Procedure division.
1) First JOB INPUT will read the FILE-2 and extract the header
2) Second JOB syntax will match FILE-1 and FILE-2 on base of key. Now file-2 is having only detail records without header.
Hi Peter,
Thank you for ur solution. But i was late to read your reply. Sorry i have already done my coding and testing. Ya but I will try ur solution once. |
|
Back to top |
|
|
|