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

Data element decimals points query

0 Likes
6,647

KONP-KBETR is type KBETR_KOND. This is a currency field of length 11 and 2 decimal points.

In this piece of code then, how is it L_KBETR can hold 3 decimals points?

  CONSTANTS: c_decimals_3(5) VALUE '3    '.
DATA: out_value(15) TYPE c,
l_kbetr TYPE konp-kbetr.

l_kbetr = '1.234'. "<-- should only be able to hold 1.23?

WRITE l_kbetr TO out_value CURRENCY c_decimals_3.

WRITE:/ out_value. "--> 1.234
1 ACCEPTED SOLUTION
Read only

5,651

omg I'm a moron! lol

That was it, the flag was off.

Thank-you Sandra!

7 REPLIES 7
Read only

former_member598787
Participant
0 Likes
5,651

Hello,

I am assuming your question is how to round off, as it is not clear what is it exactly that you need help with.

Have you tried using ROUND function module .

Read only

FredericGirod
Active Contributor
5,651

why didn't you put a real currency after CURRENCY keyword ? EUR --> 1.23 JPY --> 123

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
0 Likes
5,651

First of all, I cannot reproduce the behavior.

Check in the debugger the ABAP type of l_kbetr. It must be P(6) DECIMALS 2.

Then, after assigning '1.234', it contains 1.23.

Then, your are applying the character 3 to CURRENCY of WRITE TO.

Look into tables TCURC/TCURX which number of decimal places is assigned to currency '3'.

See WRITE, format_options, Addition 6 on how the CURRENCY addition works.

"For data objects of type p, the decimal places specified by the definition of the data type are ignored completely. Independently of the actual value and without rounding, decimal separators and thousands separators are inserted between the digits in the places determined by cur. "

If there are three decimal places behind the currency specified, it produces 0.123 from 1.23.

See also DDIC - Currency Fields

Read only

0 Likes
5,651

Hi Horst,
Not sure if system version affects why you cannot reproduce the behaviour. The code is as pasted above. I confirmed KONP-KBETR is a currency field, length 11 decimals 2.

Kernel 777 SP 429
SAP_BASIS 754 SP 3

Attached is a screenshot of debug. But what you wrote about type P certainly would suggest why the P variable can 'hold' 3 decimals places even though is defined with only 2.

Frederic,
To rule out any currency-related configuration issues in this test. Defining the explicit number of 'currency' decimals points eliminates this extra factor.

Read only

Sandra_Rossi
Active Contributor
5,651

it looks like this old good "floating decimal point" flag in program attributes...

Read only

5,652

omg I'm a moron! lol

That was it, the flag was off.

Thank-you Sandra!

Read only

0 Likes
5,651

+1 not for first sentence, but for switching on the "floating decimal point" program attribute!