View previous topic :: View next topic
|
Author |
Message |
morpheus007
New User
Joined: 27 Dec 2005 Posts: 58
|
|
|
|
We have a requirement to generate a report that is sorted on a particular field FIELD1.
Following is the dummy format for data in the input file:
FIELD1 FIELD2---->OTHER FIELDS
aaaaa 12300
aaaaa 12301
aaaaa 12200
Suppose all 3 records are selected as per selection criteria.
What we would expect on the report is:
FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
---------------------------------------------------
aaaaa 12300
aaaaa 12301
aaaaa 12200
What we are ending up getting for some sequences is:
FIELD1 FIELD2 FIELD3 FIELD4 FIELD5
---------------------------------------------------
aaaaa 12300
aaaaa 12200
aaaaa 12301
For other cases it does work as well.So its sort of random.
12300 and 12301 are in sequence in the file and also have aaaaa for FIELD1 and would be expected to be together yet on sorting another record with aaaaa for the sort field comes in between in some cases.This seems to differ from the order in which data was in the input file and was released to the SORT area.
I have used cobol sort and JCL SORT(for unsorted detail records without the report headers)+Program to write headers with SORTED data techniques and still find that the final SORT sequence does not necessarily seem to match with the sequence in which the Records get selected frmo the File.
Q>Please let me know if its normal to have SORT pick up at random ie if SORT has 3 records which have same values for the SORT field is it necessary or not that it writes them out in the same order as the came in or is there something wrong with the way I am coding.
This looks something like if SORT was to eliminate duplicates how does it decide which one to pick and which one to eliminate. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Either your sort key is not defined properly or the that data is not as it is shown. Look at the data in hex and see if it is really what you think it is. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
The EQUALS or NOEQUALS option in effect determines the order of duplicate input records.
With EQUALS, the original order of duplicate records must be maintained.
With NOEQUALS, the order of duplicate records does not have to be maintained.
If you want the duplicate records in their original order, ensure that EQUALS is in effect, e.g.
Code: |
//DFSPARM DD *
OPTION EQUALS
/*
|
Quote: |
if SORT was to eliminate duplicates how does it decide which one to pick and which one to eliminate |
The first record of the duplicates is kept if EQUALS is in effect. Any one of the duplicate records can be kept if NOEQUALS is in effect. |
|
Back to top |
|
|
|