View previous topic :: View next topic
Author
Message
wiprov New User Joined: 13 Feb 2008Posts: 15 Location: Chennai
Hi,
My i/p file has header and detail records as below:
Input File:
Four set of records and first byte - '1' indicates header.
First byte - '5' or '6' indicates detail records.
1HDR1
5detail1
6detail1
1HDR3
5detail3
6detail3
1HDR2
5detail2
6detail2
1HDR3
5detail3
6detail3
Requirement:
If you could notice, 1HDR3 set of records is getting repeated and the duplicate occurrence of that, needs to be removed.
Expected o/p File:
1HDR1
5detail1
6detail1
1HDR3
5detail3
6detail3
1HDR2
5detail2
6detail2
Could you please let me know, is this viable to crack through DFSORT.
Kindly let me know, if you need any other details from my end. Thanks
Back to top
Rohit Umarjikar Global Moderator Joined: 21 Sep 2010Posts: 3053 Location: NYC,USA
Add a SEQNUM at the end of each record, remove duplicates and the sort it back using the SEQNUM.
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
What is the RECFM and LRECL?
Do you consider it duplicate if the header is duplicate, or need the data be duplicate as well?
Back to top
wiprov New User Joined: 13 Feb 2008Posts: 15 Location: Chennai
RECFM=FB and LRECL=10.
if the header is duplicate, then we can drop the entire set of records.
In our example, second set of 1HDR3 can contain different set of records.
Back to top
Rohit Umarjikar Global Moderator Joined: 21 Sep 2010Posts: 3053 Location: NYC,USA
While Bill takes a look on this further, Did you give a try on what I have suggested earlier and if you need a sample how to do it then it is verymuch available on Google or on this forum?
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Well, wiprov took it off to another site. Turns out he has SyncSORT as well.
Back to top
wiprov New User Joined: 13 Feb 2008Posts: 15 Location: Chennai
Hi Rohit,
Sorry for the late response. Adding a sequence number could be a problem, if the same detail records exists in another header (which is not duplicate). We might miss those records in that case......
Back to top
Rohit Umarjikar Global Moderator Joined: 21 Sep 2010Posts: 3053 Location: NYC,USA
I might be missing something,but can you please explain with an example for this statement?
Quote:
if the same detail records exists in another header (which is not duplicate). We might miss those records in that case......
As I guess same set of detail records and header would retain from one of the duplicate that found, like in your example still below sets of records would come.
Code:
HDR3
5detail3
6detail3
Back to top
Bill Woodger Moderator Emeritus Joined: 09 Mar 2011Posts: 7309 Location: Inside the Matrix
Quote:
if the header is duplicate, then we can drop the entire set of records.
In our example, second set of 1HDR3 can contain different set of records.
Back to top
Rohit Umarjikar Global Moderator Joined: 21 Sep 2010Posts: 3053 Location: NYC,USA
Right, I looked today closey and yes the sequence number option wouldn't fit here..
wiprov, have you got any solution or you still open to the options?
Back to top
saiprasadh Active User Joined: 20 Sep 2006Posts: 154 Location: US
Wiprov,
I used below mentioned sort card to obtain the result.
Code:
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,
BUILD=(1:1,10,81:20C'0')),
IFTHEN=(WHEN=GROUP,BEGIN=(1,4,CH,EQ,C'1HDR'),
PUSH=(81:ID=10)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,5,CH,EQ,C'1HDR3'),
END=(1,4,CH,EQ,C'1HDR',AND,1,5,CH,NE,C'1HDR3'),
PUSH=(91:ID=10))
OUTFIL FNAMES=SORTOUT,
INCLUDE=((2,3,CH,EQ,C'DET',AND,91,10,ZD,EQ,0),OR,
(1,4,CH,EQ,C'1HDR',AND,1,5,CH,NE,C'1HDR3'),OR,
(1,5,CH,EQ,C'1HDR3',AND,91,10,ZD,EQ,1),OR,
(2,3,CH,EQ,C'DET',AND,91,10,ZD,EQ,1)),
OUTREC=(1:1,10)
Input:
Code:
1HDR1
5DETAIL1
6DETAIL1
1HDR3
5DETAIL3
6DETAIL3
5DETAIL3
6DETAIL3
1HDR3
5DETAIL3
6DETAIL3
1HDR2
5DETAIL2
6DETAIL2
1HDR3
5DETAIL3
6DETAIL3
Output:
Code:
1HDR1
5DETAIL1
6DETAIL1
1HDR3
5DETAIL3
6DETAIL3
5DETAIL3
6DETAIL3
1HDR2
5DETAIL2
6DETAIL2
Back to top
Please enable JavaScript!