View previous topic :: :: View next topic

Author 
Message 
sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1013 Location: India




HI,
I have SQLCODE FFFFFC66. How to convert it to readable SQLCODE. This error occurred when executing a cobol program which uses CICS.
Thank You In Advance,
Sushanth Bobby 

Back to top 




Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8280 Location: Dubuque, Iowa, USA




Windows has a calculator function that converts hex to decimal. There are also other ways to convert the value both on the web and on mainframes. FC66 is 922 decimal. 

Back to top 


sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1013 Location: India




Robert,
In windows i have tried the CALCULATOR application for FC66, its giving 64614. I also tried in the EXCEL using =HEX2DEC("FC66"). Same result 64614.
Can you give me tip to how to convert in any one of the applications in windows or mainframe.
Sushanth Bobby 

Back to top 


enricosorichetti
Global Moderator
Joined: 14 Mar 2007 Posts: 10457 Location: italy




negative numbers in binary are in two complement notation
FFFFFC66 ==> 39A ==> 922 

Back to top 


Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8280 Location: Dubuque, Iowa, USA




Windows calculator, scientific mode, hex, key or click in FC66. Hit the +/ key to negate the value and note the 039A. Clear, enter 39A and hit the decimal key. See the value 922 on the display. Hit the +/ key again to reverse the sign to its original value. 

Back to top 


sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1013 Location: India




Thank You Enrico,
Thank You Robert,
Sushanth Bobby 

Back to top 


Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA




or subtract 64K (65536) from 64614 to get 922. 

Back to top 


Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA




or have DB2 translate the error for you by calling DSNTIAC (DSNTIAR for batch) for a formatted version of the SQLCODE. 

Back to top 


sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1013 Location: India




Thank You Terry,
Quote: 
subtract 64K (65536) from 64614 to get 922. 
I have one doubt, for any type of SQLCODE error will it be 64K only. What is the reason behind 64K, that is WHY 64K ?
Sushanth 

Back to top 


dick scherrer
Site Director
Joined: 23 Nov 2006 Posts: 19270 Location: Inside the Matrix




Hello,
The decimal value of x'FFFF' is 65535. When 1 is added, it gives 65536  which is 64k. This is the largest number that will fit in 2 bytes. 

Back to top 


Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA




Someone with a math background can probably explain it better than me, but I once noticed that if you increment 32,767 (the largest positive number that fits in a 2byte binary field) by one you get X'8000' which is 0. Increment by one again and you get 1. Again, you get 2. In other words every increment by a +1 results in a successively smaller number. The same thing happens with 64K. Once you reach the maximum positive number, adding +1 to it results in successively smaller numbers. I guess this is because the sign of a binary number is stored in the leftmost bit. As I said, someone with a math background could I'm sure explain it better. 

Back to top 


sushanth bobby
Senior Member
Joined: 29 Jul 2008 Posts: 1013 Location: India




D.sh & Terry,
I just want to check is my calculation correct.
SQLCODE : FFFFFC66
splitting the SQLCODE in 2 parts,
first part : FFFF
FFFF+1 = 65536
second part : FC66
FC66 = 64614
Subracting the decimals of Part2 from Part 1,
922
And the ve sign is got by,
Quote: 
Once you reach the maximum positive number, adding +1 to it results in successively smaller numbers 
Final Result Code = 922
Sushanth 

Back to top 


Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA




I don't fully understand 2s compliment but if you flip all the bits of X'FC66' which is 1111 1100 0110 0110 you get 0000 0011 1001 1001 which is X'0399'. Adding 1 you get X'039A' which is decimal 922. Reversing the sign, it becomes 922. A quicker way to get to the final result is to simply subtract 64K from the SQLCODE as shown by SQLCA. I don't know if that's more confusing or not. 

Back to top 


Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1275 Location: Israel




sushanth bobby wrote: 
I just want to check is my calculation correct.
SQLCODE : FFFFFC66
splitting the SQLCODE in 2 parts,
first part : FFFF
FFFF+1 = 65536
second part : FC66
FC66 = 64614
Subracting the decimals of Part2 from Part 1,
922
Sushanth 
No splitting of SQLCODE!!!
If you really want, you can do the full calculation (all numbers in hexa): 100000000  FFFFFC66 = 39A
But it's easier to use smaller numbers, they give the same result:
(100000000  FFFFFC66) = (1000000  FFFC66) = (10000  FC66)
Isn't that magic ??? 

Back to top 


surya.kalyan
New User
Joined: 09 Jan 2007 Posts: 20 Location: Mumbai




A simple way:
1) Use the windows scientific calculator...
2) select hex in the radio button....
3) select Dword radio button (4 bytes)...
4) paste your number FFFFFC66...
5) press the button +/....
6) press =....
7) I got 39A...
8) select the dec radio button now...
9) the decimal number 922...
One more way using the calculator is:
Repeat the procedure till 4 in the steps above...
after pasting FFFFFC66
5) press NOT button...
6) add 1....
7) I got 39A...
8) select the dec radio button now...
9) the decimal number 922...
So, the number was 922
In short: The negative of a number is stored as Two's complement which is inverting the bits from zero to 1 (1's complement and then adding 1). 

Back to top 


