Application Development 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: 

Decimals Confusion ?

Former Member
0 Kudos

Hi,

I declared a variable in this manner

<b>data : w_zkprs(15) type p decimals 4.</b>

My guess is the total length is 15 of which 4 are for decimals and 1 for dot and rest for the number . Is that right ?

Regards,

Ben.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I think that the (15) is to include the decimal positions and the ".". In the case of type P, the output length is 31.

Regards,

RIch Heilman

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I think that the (15) is to include the decimal positions and the ".". In the case of type P, the output length is 31.

Regards,

RIch Heilman

0 Kudos

Hi Rich,

The 15 include decimal position and dot ? AM I right ?

Regards,

Ben.

0 Kudos

Hi Rich,

IN the case of P if the output length is 31 then what is the need to specify the number 15 ? It should give an error, right ?

Regards,

Ben.

0 Kudos

In the case of TYPE P, your output length will always be double of your definition plus 1. This is the way packed fields work, you get 2 for 1.

Regards,

Rich Heilman

0 Kudos

Hi,

THe following si from SAP Help on PAcked numbers.. hope this will clarify your cinfucion..

"Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers."

Regards,

Suresh Datti

govind_seenivasan
Participant
0 Kudos

Yes you are right.

Former Member
0 Kudos

hi daniel,

15 is for the whole number including the '.' and decimals 4 is 4 digits after the decimal point.

hope this helps,

priya.

Former Member
0 Kudos

Hi Daniel,

Nope, its 4 for decimals and the rest 11 for the non-decimal part of the number. Look at the output length for clues on how the entire number will look after formatting.

Regards,

Anand.

0 Kudos

Yes, the 15 includes the decimal positions, I'm really not sure about the '.'.

For example, say we are talking about a TYPE P(15) decimals 4, the output length is actually 31. So knowing that a TYPE P field will give us 2 for 1, then gives us 30, which is one less than 31, which leads me to believe that the extra character is for the ".".

So, I think the correct assumption is that the 15 includes the decimals places, not the ".".

Regards,

Rich Heilman