View previous topic :: View next topic
|
Author |
Message |
harsh singh
New User
Joined: 11 Dec 2007 Posts: 26 Location: INDIA
|
|
|
|
Hi
i tried to dig out the portal for solving my confusion but my effort went in vain, please try to help me.
I have a account number field which is of numeric datatype in my master file , say
ACCT-NO PIC 9(16).
I tried to sort the file on this account no field
Sort card used by me is
SORT FIELDS=(736,16,ZD,A)
to my curiosity i tried sorting the file with below sort card too
SORT FIELDS=(736,16BI,A)
to my surprise the output(sort account no) using both card are same.
I tried to investigate why the output are same for both sort card but could not reach any solution.
I believe the storing technique in memory is different for BI datatype and ZD datatype so either of the one should give errors but this actually did not happened.
Please let me know the correct data type to be used in SORT for numeric data type and what is the possible reason of not encountering any error using above cards( i believe that either of the card suits the requirement). |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Maybe PIC 9(16) is not zoned decimal? |
|
Back to top |
|
|
harsh singh
New User
Joined: 11 Dec 2007 Posts: 26 Location: INDIA
|
|
|
|
pic 9(16) is PIC 9(n) DISPLAY and is of format ZD in DFSORT format
As far as the account no is concerned i believe that they are mapped in memory as type Zoned decimal not Binary.
What does you suggest sir ?
If my understanding is correct and it is of type ZD then Sort card with type as BI should gives error . Please advise. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
PIC 9(n) display is nothing but Character or x type, unsigned, which is why the BI works.
ZD is Zoned Decimal, signed
here is the link to the page in the reference manual.
I promised Frank and Kolusu to stay out of DFSORT questions,
but this is sooooooooooooooooooooooooooooooooo basic. |
|
Back to top |
|
|
harsh singh
New User
Joined: 11 Dec 2007 Posts: 26 Location: INDIA
|
|
|
|
thank you dick for coming up with a valid reason,unfortunanetly it did not clicked me. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
If my understanding is correct and it is of type ZD then Sort card with type as BI should gives error . Please advise. |
There is a flaw in the understanding. . .
Why would there be an error? Any field may be sorted with BI - what error did you expect?
If all of the values were positive, they would both sort in the same sequence. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
there is no signed field involved. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Dick,
Quote: |
there is no signed field involved. |
Good catch - my "processor" read it as s9(16) - d'oh
d |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
but what you said was true |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
ZD is the correct format to use for zoned decimal numeric values. ZD will handle signed and unsigned zoned decimal values correctly.
BI will give the correct results for zoned decimal values as long as they all have the same sign, but may or may not give the correct results if all of the values don't have the same sign.
For example, if we have 2-byte ZD values like this:
Code: |
X'F1F2' = +12
X'F1F4' = +14
|
both ZD and BI will give the correct results.
But if we have 2-byte ZD values like this:
Code: |
X'F1F2' = +12
X'F2C4' = +14
X'F1D4' = -14
|
ZD will give the correct results (because it interprets F and C as plus signs and D as a minus sign), whereas BI will not give the correct results (because it treats the values as unsigned binary). |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Frank,
then what you are saying is that DFSORT considers both:
PIC 9(n)
PIC S9(n)
as zoned decimal.
In that case, I was wrong and owe Harsh an apology.
Harsh,
the reason that both ZD and BI sorted the same in this case
is because the ZD treated the unsigned numeric as positive,
which gives the same output sequence as BI,
as Dick said. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
|