View previous topic :: View next topic |
Author |
Message |
chuck Beginner
Joined: 30 Nov 2007 Posts: 29 Topics: 13
|
Posted: Fri May 12, 2023 2:47 pm Post subject: Sorting CH v PD |
|
|
Hi,
Posting on behalf of someone who is not very comfortable in forums and so on
Is there any real impact if you use PD or CH to sort signed packed decimal numbers? I just ran a test and both sorted to the same ascending sequence. Just wonder if that would ever bite us?
Thanks |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Sun May 14, 2023 7:42 am Post subject: |
|
|
chuck wrote: | Is there any real impact if you use PD or CH to sort signed packed decimal numbers? I just ran a test and both sorted to the same ascending sequence. Just wonder if that would ever bite us? |
chuck,
You caNNOT sort packed decimal fields as character data as the sign(positive or negative) is in the lower nibble of the data.
For example , here is a sample data.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
-40000
-60040
+55000
-20000
+20000
+30000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(20:1,6,SFF,PD,LENGTH=6)
SORT FIELDS=(20,6,PD,A)
/* |
Now change the sort fields to
Code: |
SORT FIELDS=(20,6,CH,A) | and see the order of the data.
The question is why do you want to sort the packed decimal data as character? _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
chuck Beginner
Joined: 30 Nov 2007 Posts: 29 Topics: 13
|
Posted: Mon May 15, 2023 4:26 pm Post subject: |
|
|
I have conveyed your response to my coworker. Thank you very much. He gave me some complicated reasoning for wanting to do this, but with your example I was able to dissuade him! |
|
Back to top |
|
|
|
|