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

decimal conversion in abap

Former Member
0 Kudos
9,320

hi,

i have been trying to do this.

'Let the user populate field with a value with 2 decimals but make always the conversion for the record

If a currency is managed with 3 decimals, apply rule of around with the top or with the lower. For example, 11.555 become 11.56 and 11.554 become 11.55.

If a currency is managed without decimal, apply the same rule. For example 11.49 become 11 and 11.50 become 12.

This conversion rules are use for the display and the record function of ZVA02N and ZVA02

Other currencies must work as today. For user, the modification have to be invisible when he use standard currencies with 2 decimals.

the problem is i am unable to do so.

can someone help me on this.

5 REPLIES 5
Read only

andreas_mann3
Active Contributor
0 Kudos
3,342

hi,

i don't get it. But please consider table <b>tcurx</b> - maybe that helps

A.

Read only

Former Member
0 Kudos
3,342

Hi,

Here u have specify screen field with 2 decimal places

then auto check will happen

Read only

0 Kudos
3,342

Using FLOOR will round down, CEIL will round up.

eg :

  • value_in is '25'.

25 / 10 = 2.5

w_next_integer = CEIL( 2.5 )

  • w_next_integer take the value '3'.

DATA: I TYPE I,

P TYPE P DECIMALS 2,

M TYPE F VALUE '-3.5',

D TYPE P DECIMALS 1.

P = ABS( M ). " 3,5

I = P. " 4 - business rounding

I = M. " -4

I = CEIL( P ). " 4 - next largest whole number

I = CEIL( M ). " -3

I = FLOOR( P ). " 3 - next smallest whole number

I = FLOOR( M ). " -4

I = TRUNC( P ). " 3 - integer part

I = TRUNC( M ). " -3

D = FRAC( P ). " 0.5 - decimal part

D = FRAC( M ). " -0.5

kishan negi

Read only

Former Member
0 Kudos
3,342

<b>case 1.</b>

DATA: FLD(8) TYPE P DECIMALS 3 value '11.555',
      final(8) type c,
      DEC    TYPE I.
DESCRIBE FIELD FLD DECIMALS DEC.

write:/ dec.


if dec = 3.
write fld decimals 2 to final.  "check here 
endif.

write:/ final.

<b>case2.</b>

DATA: FLD1(8) TYPE P DECIMALS 2 value '11.50',
      final1(8) type c,
      DEC1    TYPE I.
DESCRIBE FIELD FLD1 DECIMALS DEC1.

if dec1 = 2.
write fld1 decimals 0 to final1.  "check here 
endif.
write:/ final1.

regards,

vijay

Read only

Former Member
0 Kudos
3,342

Please try the below solution.

ltn = 2.

select single currdec into ltn

from tcurx where currkey = pcurr.

write lp2 to lchr decimals ltn.