2020 Jul 20 1:21 PM
Hi All,
If I have a variable of CURR(10,2) what is the correct values that can go into this variable?
A.) 12 characters in total. 10 whole numbers with 2 decimal places.
B.) 10 characters in total. 8 whole numbers with 2 decimal places.
I have encountered this dump in our system:
Short Text
SQL error "SQL code: 1438" occurred while accessing table "/ACNLQD/NUMRANGE".
What happened?
Database error text: "SQL message: ORA-01438: value larger than specified
precision allowed for this column"
Per checking for values that didn't dump, there was a field in the table that had a value 8 whole numbers and 2 decimal places. But for the dump encountered, the variable/field had 9 whole numbers and 2 decimal places(a total of 11). Is this what's causing the dump in our system? Thank you.
2020 Jul 20 1:59 PM
The correct is 10 characters, 8 whole numbers with 2 decimal places.
Take a look in the help: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenddic_currency_field.htm
The CURR type is stored like DEC type. The DEC type is stored as a packed number.
Numeric data type for saving fixed point numbers with a fixed number of decimal places or a number saved in a similar way. The associated predefined ABAP type is p. The number of decimal places is a property of the data type and not (as withfloating point numbers) a property of the data itself. Calculations with packed numbers are made using fixed point arithmetic. The internal representation uses the BCD format.
2020 Jul 20 1:56 PM
CURR(10,2) corresponds to a total number of 10 digits including the 2 decimals.
But the ABAP variable occupies 6 bytes (10 half bytes + 1 half byte for sign = 11 half bytes = 6 bytes), so it may occupy up to 11 digits (including the decimals), the short dump happens when the 11th leftmost digit is not zero.
SAP recommends (below SAP notes for instance) to never define packed fields with an even number of digits because of that (prefer CURR(11,2) or CURR(13,2), etc.)
2020 Jul 20 1:59 PM
The correct is 10 characters, 8 whole numbers with 2 decimal places.
Take a look in the help: https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abenddic_currency_field.htm
The CURR type is stored like DEC type. The DEC type is stored as a packed number.
Numeric data type for saving fixed point numbers with a fixed number of decimal places or a number saved in a similar way. The associated predefined ABAP type is p. The number of decimal places is a property of the data type and not (as withfloating point numbers) a property of the data itself. Calculations with packed numbers are made using fixed point arithmetic. The internal representation uses the BCD format.
2020 Jul 20 2:07 PM
kdarunday,
The correct answer is option B.
B.) 10 characters in total. 8 whole numbers with 2 decimal places.
One simple way to check is create a test program with parameter and assign the necessary datatype (CURR 10,2). Now try entering the digits, when you enter 8 digits system does not throw any error and allot the remaining two places (.00) for decimal. Once you enter the 9th digit system will err.
And yes your assumption on the dump is right, it is due to the value with 9 digits and 2 decimal places.
Regards!
2020 Jul 20 2:53 PM