Page 1 of 1

File SORT For Record key

PostPosted: Tue Sep 18, 2012 7:30 pm
by Vineet
Hi All,

I am having a Sequential file having LRECL = 1199 & RECFM = FB. File is Sorted on First 16 Bytes i.e. (1,16,CH,A). My Requirement is, For all the Records where First 15 Bytes are same & there is a Difference in the Remaning Field then I need to write the Record to the Output File. O/P File having same Attribute as Input File. Below is Example.


Input File

1234|ABCDE|XYZ98|HELLO|MAINFRAME|XYZ12345|..... ---> To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98
1234|ABCDE|XYZ98|HELLO|MAINFRAME|ABC12345|.....---> To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98
1234|HIJKL|XYZ98|HELLO|MAINFRAME|XYZ12345|..... ---> Not To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98

5678|IJKLM|99999|HELLO|MAINFRAME|XYZ12345|.....----> Not to be written to O/P file. First 16 Bytes = 5678|IJKLM|99999
5678|IJKLM|99999|HELLO|MAINFRAME|XYZ12345|.....----> Not to be written to O/P file. First 16 Bytes = 5678|IJKLM|99999

7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... Not to be written to O/P file. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ99999|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ88888|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888

Can this be achieved using SORT.

Thanks
Kind Rgd's

Vineet Anand

Re: File SORT For Record key

PostPosted: Tue Sep 18, 2012 9:29 pm
by skolusu
Vineet,

It is not clear as to what you are trying to do.

Why did you want to write this record when it is exactly the same
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... Not to be written to O/P file. First 16 Bytes = 7899|ABCDE|88888


what do you do with orphan records like this ?
1234|HIJKL|XYZ98|HELLO|MAINFRAME|XYZ12345|..... ---> Not To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98


It has got nothing to compare against. Why aren't you writing this record?

Re: File SORT For Record key

PostPosted: Tue Sep 18, 2012 10:02 pm
by Vineet
Hi KOLUSU,

I am sorry for the Incorrect Information. below is the Correct One.

Input File

1234|ABCDE|XYZ98|HELLO|MAINFRAME|XYZ12345|..... ---> To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98
1234|ABCDE|XYZ98|HELLO|MAINFRAME|ABC12345|.....---> To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98
1234|ABCDE|XYZ98|HELLO|MAINFRAME|XYZ12345|..... ---> Not To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98

If U Notice 1st 16 Bytes in all 3 Records are same.Record 1 & 3 is Same & Record 2 Differs (ABCD12345). So in the O/P File Record 1 & 2 to be Written.

5678|IJKLM|99999|HELLO|MAINFRAME|XYZ12345|.....----> Not to be written to O/P file. First 16 Bytes = 5678|IJKLM|99999
5678|IJKLM|99999|HELLO|MAINFRAME|XYZ12345|.....----> Not to be written to O/P file. First 16 Bytes = 5678|IJKLM|99999

If U Notice 1st 16 Bytes in 2 Records are same.Also the Remaning Fileds are Same. So Both Of the Records Not to be Written to the O/P File.

7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... Not to be written to O/P file. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ99999|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ88888|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888

If U Notice 1st 16 Bytes in all 4 Records are same.Record 1 & 2 is Same, Record 3 & 4 Differs (XYZ99999 / XYZ88888). So in the O/P File Record 1,3 & 4 to be Written.

If U need Further Clarification Please do let eme know. In Nut Shell I can say, There should be One Instance of Common Records i.e. First 16 Bytes + Remaning Fields. If any Other Field Differs apart From the 16 Bytes that Should be Written to O/P File.

Rgd's

Re: File SORT For Record key

PostPosted: Tue Sep 18, 2012 10:10 pm
by skolusu
Vineet wrote:Hi KOLUSU,

I am sorry for the Incorrect Information. below is the Correct One.

If U need Further Clarification Please do let eme know. In Nut Shell I can say, There should be One Instance of Common Records i.e. First 16 Bytes + Remaning Fields. If any Other Field Differs apart From the 16 Bytes that Should be Written to O/P File.

Rgd's


Vineet,

It is still confusing. If you need 1 instance of common records why aren't you writing this record?

5678|IJKLM|99999|HELLO|MAINFRAME|XYZ12345|

On the other hand you write the first record from this group when both of them are exactly the same.

7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... Not to be written to O/P file. First 16 Bytes = 7899|ABCDE|88888

So be clear on what you are trying to do and show us better examples.

Re: File SORT For Record key

PostPosted: Tue Sep 18, 2012 10:15 pm
by enrico-sorichetti
wouldn' t have been simpler to say...
eliminate all <full record> duplicates keeping just one ???

Re: File SORT For Record key

PostPosted: Tue Sep 18, 2012 10:38 pm
by skolusu
enrico-sorichetti wrote:wouldn' t have been simpler to say...
eliminate all <full record> duplicates keeping just one ???


I believe that is indeed the final requirement, however he seems to skip a few records. SELECT on the full record with FIRST would get him the results he want.

Re: File SORT For Record key

PostPosted: Wed Sep 19, 2012 12:22 am
by Vineet
I am sorry for the Incorrect Information. below is the Correct One.

Input File

1234|ABCDE|XYZ98|HELLO|MAINFRAME|XYZ12345|..... ---> To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98
1234|ABCDE|XYZ98|HELLO|MAINFRAME|ABC12345|.....---> To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98
1234|ABCDE|XYZ98|HELLO|MAINFRAME|XYZ12345|..... ---> Not To be written to O/P File. First 16 Bytes = 1234|ABCDE|XYZ98

If U Notice 1st 16 Bytes in all 3 Records are same.Record 1 & 3 is Same & Record 2 Differs (ABCD12345). So in the O/P File Record 1 & 2 to be Written.
Here We Need to Write Only Those Records where First 16 Bytes are same & any One of the Remaning field(s) is Different. In the above stated example XYZ12345 & ABCD12345 Differs where as First
16 Bytes are same.

5678|IJKLM|99999|HELLO|MAINFRAME|XYZ12345|.....----> Not to be written to O/P file. First 16 Bytes = 5678|IJKLM|99999
5678|IJKLM|99999|HELLO|MAINFRAME|XYZ12345|.....----> Not to be written to O/P file. First 16 Bytes = 5678|IJKLM|99999

If U Notice 1st 16 Bytes in 2 Records are same.Also the Remaning Fileds are Same. So Both Of the Records Not to be Written to the O/P File.
Here First 16 Bytes & All Remaning Fields are same. So None of Record to be Written to the File.

7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ12345|.... Not to be written to O/P file. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ99999|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888
7899|ABCDE|88888|WORLD|MAINFRAME|XYZ88888|.... To be written to O/P File. First 16 Bytes = 7899|ABCDE|88888

If U Notice 1st 16 Bytes in all 4 Records are same.Record 1 & 2 is Same (16 Bytes + Remaning Fields), Record 3 & 4 Differs (16 Bytes are same where as Field XYZ99999 / XYZ88888 differs). So in the O/P File Record 1,3 & 4 to be Written.

If U need Further Clarification Please do let eme know. In Nut Shell I can say, There should be One Instance of Common Records i.e. First 16 Bytes + Remaning Fields. If any Other Field Differs apart From the 16 Bytes that Should be Written to O/P File.

Rgd'sVineet

Posts: 51
Joined: 19 Jun 2007, 11:38
Private message

Re: File SORT For Record key

PostPosted: Wed Sep 19, 2012 12:40 am
by enrico-sorichetti
Your description is still clear as mud :evil:

but rereading it 10 times ...

why did You not simply write ....

if a group of records ( with the same 16 byte key ) consists only of <full> equal records eliminate the whole group

otherwise eliminate the <full> duplicates keeping one of each

Re: File SORT For Record key

PostPosted: Wed Sep 19, 2012 10:24 pm
by skolusu
vineet,

Stop posting the same thing over and over. Please answer my questions.

Re: File SORT For Record key

PostPosted: Fri Sep 21, 2012 8:05 pm
by dick scherrer
Hello,

To help someone help you, you need to post a few a few sample input records and the exact output you want when your process is run. You need to post enough info so that the rules are understood.

Use the "code" tags to preserve alignment sand improve readabaility,