Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sorting a Non Numeric field as PD

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
ruchir pandey

New User


Joined: 02 May 2008
Posts: 3
Location: India

PostPosted: Fri May 02, 2008 8:56 pm    Post subject: Sorting a Non Numeric field as PD
Reply with quote



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
View user's profile Send private message

CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri May 02, 2008 9:15 pm    Post subject:
Reply with quote

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
View user's profile Send private message
ruchir pandey

New User


Joined: 02 May 2008
Posts: 3
Location: India

PostPosted: Fri May 02, 2008 9:42 pm    Post subject:
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri May 02, 2008 9:49 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Fri May 02, 2008 9:57 pm    Post subject:
Reply with quote

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:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/
Back to top
View user's profile Send private message
ruchir pandey

New User


Joined: 02 May 2008
Posts: 3
Location: India

PostPosted: Mon May 05, 2008 12:38 pm    Post subject: Reply to: Sorting a Non Numeric field as PD
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Partial color change of a field in CI... waseem0424 CICS 5 Fri Sep 29, 2017 7:56 pm
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us