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

decimals in quantity

Madjid_Khanevadegi
Participant
0 Likes
1,285

hello

how to show 2 decimals of quantity value without rounding

data C_CARGO type char15.
data CARGO   type VOLUM.

CARGO = '43.077' .

write  CARGO to C_CARGO LEFT-JUSTIFIED DECIMALS 2 .

write C_CARGO .  "--show  43.08

1 ACCEPTED SOLUTION
Read only

former_member246634
Active Participant
1,169

Or:

DATA c_cargo TYPE char15.
DATA cargo   TYPE volum.

cargo = '43.077' .

cargo = round( val = cargo dec = 2 mode = cl_abap_math=>round_down ).

WRITE  cargo TO c_cargo LEFT-JUSTIFIED DECIMALS 2.

WRITE: / c_cargo .
3 REPLIES 3
Read only

former_member246634
Active Participant
0 Likes
1,169
DATA c_cargo TYPE char15.
DATA cargo   TYPE volum.
DATA lv_len TYPE i.

cargo = '43.077' .

WRITE  cargo TO c_cargo LEFT-JUSTIFIED.
lv_len = strlen( c_cargo ) - 1.
c_cargo = substring( val = c_cargo len = lv_len ).

WRITE: / c_cargo 
Read only

former_member246634
Active Participant
1,170

Or:

DATA c_cargo TYPE char15.
DATA cargo   TYPE volum.

cargo = '43.077' .

cargo = round( val = cargo dec = 2 mode = cl_abap_math=>round_down ).

WRITE  cargo TO c_cargo LEFT-JUSTIFIED DECIMALS 2.

WRITE: / c_cargo .
Read only

1,169

Well done!

Innovative method

thank you so much Bartlomiej Borucki