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 in quantity

Madjid
Participant
0 Kudos
324

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

former_member246634
Active Participant
208

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

former_member246634
Active Participant
0 Kudos
208
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 

former_member246634
Active Participant
209

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 .

208

Well done!

Innovative method

thank you so much Bartlomiej Borucki