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

rounding the amount

Former Member
0 Likes
1,052

Hi,

I want to round decimal palces to normal value.

Ex: bsis-wrbtr ( 12.45) - i want to convert to 1245

133.00) - 13300.

Pls any one help.

Thanks,

Veeru

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,014
data : p_amt type p decimals 2,
         v_amt(15)

p_amt = '133.00'.
v_amt = p_amt.

replace '.' with space in v_amt.
condense v_amt.

write : v_amt.

Hi,

I want to round decimal palces to normal value.

Ex: bsis-wrbtr ( 12.45) - i want to convert to 1245

133.00) - 13300.

Pls any one help.

Thanks,

Veeru

7 REPLIES 7
Read only

Former Member
0 Likes
1,014

data:var type p.
var1 = var *100
Read only

Former Member
0 Likes
1,015
data : p_amt type p decimals 2,
         v_amt(15)

p_amt = '133.00'.
v_amt = p_amt.

replace '.' with space in v_amt.
condense v_amt.

write : v_amt.
Read only

0 Likes
1,014

Hi Chandra,

i have tried this , iam not getting.

data : p_amt type p decimals 2,

v_amt(15).

p_amt = it_bsis-wrbtr.

v_amt = p_amt.

replace '.' with space in v_amt.

condense v_amt.

write : v_amt.

Thanks,

Veeru

Read only

0 Likes
1,014
data : p_amt type p decimals 2,
v_amt(15).

p_amt = it_bsis-wrbtr.
v_amt = p_amt.

search v_amt for '.'.
if sy-sbrc eq 0.
clear  v_amt+sy-fdpos(1).
endif.
condense v_amt.

write : v_amt.
Read only

0 Likes
1,014

bsis-wrbtr ( 12.45) - i want to convert to 1245

133.00) - 13300

See the below modifications in ur code

This works fine.

DATA : p_amt TYPE p DECIMALS 2,
v_amt(15).

p_amt = '133.00'.
v_amt = p_amt.

REPLACE '.' WITH space

<b>INTO</b> v_amt.

CONDENSE v_amt <b>NO-GAPS</b>.

WRITE : v_amt.

Output is 13300.

If u want the output like

<b>13,300.00</b>

DATA : p_amt TYPE p DECIMALS 2,
v_amt(15).

p_amt = '133.00'.
v_amt = p_amt.

REPLACE '.' WITH space INTO v_amt.
CONDENSE v_amt NO-GAPS.

<b>p_amt = v_amt.</b>

WRITE : p_amt.

reward points and close the thread if ur problem got solved.

Reward pointsfor those who helped to solve this.

Message was edited by:

Judith Jessie Selvi

Read only

0 Likes
1,014

Hi Chandra,

Solved. Assigned full points.

Thanks,

Veeru.

Read only

Former Member
0 Likes
1,014

Hi,

USe keyword ... ROUND r with write statement as shown in following example:

Scaled output of a field of type P.

The decimal point is first moved r places to the left (r > 0)

or to the right (r < 0); this is the same as dividing with the

appropriate exponent 10**r. The value determined in this way is

output with the valid number of digits before and after the

decimal point. If the decimal point is moved to the left, the

number is rounded.

For further information about the interaction between the

formatting options CURRENCY and DECIMALS, see the notes below.

Effect of different ROUND specifications:

DATA: X TYPE P DECIMALS 2 VALUE '12493.97'.

WRITE: /X ROUND -2, "output: 1,249,397.00

/X ROUND 0, "output: 12,493.97

/X ROUND 2, "output: 124.94

/X ROUND 5, "output: 0.12

Hope this helps.

Reward if helpful.

Regards,

Sipra