2013 Aug 24 10:05 AM
hi
i saw multiple sap help docs but could not find out how the length of a packed decimal variable is allocated?
i mean if I declare
Data : abc type p length 16 decimals 2
will it allow 16 digits followed by a decimal ( dot ) followed by 2 chars
xyz type p length 3 decimals 2
will it allow total 3 digits including decimal(dot ) and 2 decimal digits
please give a specific answer and not links as I have even debugged and seen that different lengths are allocated at diff times
thanks
hi
i saw multiple sap help docs but could not find out how the length of a packed decimal variable is allocated?
i mean if I declare
Data : abc type p length 16 decimals 2
will it allow 16 digits followed by a decimal ( dot ) followed by 2 chars
xyz type p length 3 decimals 2
will it allow total 3 digits including decimal(dot ) and 2 decimal digits
please give a specific answer and not links as I have even debugged and seen that different lengths are allocated at diff times
thanks
2013 Aug 24 10:24 AM
Hi Hema,
Maximum suppoted length 31
Data : my_data type p type length 16 decimals 14.
it can hold '1234567890123456.12345678901234'.
Regards
2013 Aug 24 10:43 AM
Hi Yakub,
then why is this code working ?
DATA : gv_result TYPE p LENGTH 12 DECIMALS 4.
gv_result = '1234567890123456.4567'.
write: / gv_result.
Here even though i have specified 16 digits before the decimal instead of 12 it is working
2013 Aug 24 11:08 AM
use
DATA : gv_result TYPE p LENGTH 8 DECIMALS 4.
It will give you dump...
Beyond 8 it is 16
Regards
2013 Aug 24 11:42 AM
Thanks yakub .
can you tell me how much length is allocated to numeric data type
for interger it is 10 i suppose
2013 Aug 26 6:30 AM
Hi Hema,
Well for each specfic internal data type you can check SAP Online documentation
here is what you need.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/content.htm
Regards
2013 Aug 24 2:02 PM
Hi ,
May I know the reason for this question ?
Are there specific customer requirement ?
regards.
2013 Aug 24 5:57 PM
Hi,
Take an example decimal value 123456.123
Here total no. of digits= 9
Formula: 2N - 1 = 9.
N = 5.
Here Length = 5 and Decimals = 3.
IF we get N value as 5.5 , then we will take Length as 6.
Hope this will help you in packed decimal.
Regards,
Anil.
2013 Aug 26 6:42 AM
Hi Hema,
Data Type P :
The valid length for packed numbers is between 1 and 16 bytes; two decimal places are packed into one byte, whereby the last byte only contains one place and the plus/minus sign; after the decimal separator, up to 14 decimal places are permitted. Depending on the field length len and the number of decimal places dec, the following applies for the value area: (-10^(2len -1) +1) / (10^(+dec)) to (+10^(2len -1) -1) /(10^(+dec)) in steps of 10^(-dec). Values in between this range are rounded off.
https://help.sap.com/abapdocu_70/en/ABENBUILT_IN_TYPES_VALUES.htm
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |