View previous topic :: View next topic
|
Author |
Message |
ruchir pandey
New User
Joined: 02 May 2008 Posts: 3 Location: India
|
|
|
|
Hello Frank
This problem might sound weird but I have been asked this my my team Mate.
we are trying to sort a file on first 4 bytes which contains valid packed decimals except for the header records.
Our sort statement are :- sort fields=(1,4,pd,a)
and file looks something like this:-
MS67
DEFF
4267
----
MA82
DCFF
4182
----
...ð
0018
074C
----
...@
0017
074C
As you might notice that first 2 records which are headers, are not a valid packed decimal. DFSORT do not complain about it and sorts all valid packed decimals in correct order. But among Header records 'MS67' comes before 'MA82', the sort order is unexplained it always puts them in same order even if they appear in reverse order in sortin.
It means to me that dfsort in not ignoring these invalid packed decimals and always puts them in same order(MS67 THEN MA82).
Now I am not able to explain why sort puts them in this order?.
Can you please have a look at it.
Thanks
Ruchir Pandey |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Reasonable problem, if there is a way to identify the headers versus the actual data.....So far the only difference between the headers and data is that field in the header would fail a COBOL 'IF NUMERIC' test.......
Do you want the data between the headers sorted but the headers left in their original order? An example of what you want your output (based upon the input you provided) would be helpful. |
|
Back to top |
|
|
ruchir pandey
New User
Joined: 02 May 2008 Posts: 3 Location: India
|
|
|
|
Thanks for taking time to look into it.
Yes I have means to identify the header versus detail record but I am not looking for putting them in particular order.
when I sort them using above sort statement:- they look like
MS67
DEFF
4267
----
...ð
0018
074C
----
...@
0017
074C
MA82
DCFF
4182
i.e MS67 stays at TOP but MA82 Goes in Bottom.
I have ways to handle it to make sure headers come together.
But the question here is How can we explain why MS67 comes at TOP and MA82 goes in bottom.
How sort fields=(1,4,pd,a) responds when it finds a non numeric fields to be sorted and in what order they(non numeric fields) are sent in sortout. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
First, please create an example of exactly you want the output to look like (if you could get your job to run the way you want).
Second, post your JCL, CNTLs and the associated sysouts.
Then answers to your question(s) should be forth coming........ |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
DFSORT do not complain about it and sorts all valid packed decimals in correct order. But among Header records 'MS67' comes before 'MA82', the sort order is unexplained it always puts them in same order even if they appear in reverse order in sortin. |
DFSORT does not flag invalid PD sort values - it just interprets them as PD values and sorts them. It treats the last nibble as the sign as follows:
Positive signs: F, E, C, A, 8, 6, 4, 2, 0
Negative signs: D, B, 9, 7, 5, 3, 1
So MS67 is treated as negative (last nibble is 7 = negative) and MA82 is treated as positive (last nibble is 2 = positive).
The actual sorted records you would get for your example are:
X'D4E2F6F7'
X'0007147C'
X'0007148C'
X'D4C1F6F2'
The first header is treated as negative (7 for sign) so it's first. The other values are treated as positive (C and 2 for sign). Since D is greater than 0, the second header is last.
You should take steps to keep the headers in place. You can use the header part of the technique discussed in the "Sort records between a header and trailer" Smart DFSORT Trick at:
www.ibm.com/servers/storage/support/software/sort/mvs/tricks/ |
|
Back to top |
|
|
ruchir pandey
New User
Joined: 02 May 2008 Posts: 3 Location: India
|
|
|
|
Frank
That was exactly I was looking for. Thanks a Ton for the help.
I was challenged by one of the reviewer to prove that MS67 would always come first. All our team is delighted by your perfect explanation.
Thanks
Ruchir |
|
Back to top |
|
|
|