Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

packed decimal allocated length

Former Member
4,633

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

8 REPLIES 8
Read only

Former Member
0 Likes
2,073

Hi Hema,

Maximum suppoted length 31

Data : my_data type p type length 16 decimals 14.

it can hold '1234567890123456.12345678901234'.

Regards

Read only

0 Likes
2,073

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

Read only

0 Likes
2,073

use

DATA : gv_result TYPE p LENGTH 8 DECIMALS 4.

It will give you dump...

Beyond 8 it is 16

Regards

Read only

0 Likes
2,073

Thanks yakub .

can you tell me how much length is allocated to numeric data type

for interger it is 10 i suppose

Read only

0 Likes
2,073

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

Read only

rosenberg_eitan
Active Contributor
0 Likes
2,073

Hi ,

May I know the reason for this question ?

Are there specific customer requirement ?

regards.

Read only

anilkumar_kalkivai
Active Participant
0 Likes
2,073

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.

Read only

former_member209120
Active Contributor
0 Likes
2,073

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