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

Format a quantity according to a unit

0 Likes
9,766

Hi experts,

I want to format a quantity according to a unit.

1,00 Unit ST --> 1.

Can you help me??

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,490

Hi,

If you display in output, do like this


write <quantity_field> unit <unit_field>.

It will display acording to the number of decimal places fixed table T006 for <unit_field>..

Regards

Dillip

Hi experts,

I want to format a quantity according to a unit.

1,00 Unit ST --> 1.

Can you help me??

Thanks

5 REPLIES 5
Read only

Former Member
0 Likes
4,491

Hi,

If you display in output, do like this


write <quantity_field> unit <unit_field>.

It will display acording to the number of decimal places fixed table T006 for <unit_field>..

Regards

Dillip

Read only

Former Member
0 Likes
4,490

Hi,

You can use FM UNIT_CONVERSION_SIMPLE.

This FM is used for conversion of one Unit to another, with rounding.

CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
     EXPORTING
          INPUT                = VALUE_IN    ---->Actual UOM
          ROUND_SIGN           = 'X'      ------->Rounding
          UNIT_IN              = UNIT_IN     ------->UOM you want to convert.
          UNIT_OUT             = UNIT_OUT
     IMPORTING
          OUTPUT               = VALUE_OUT
     EXCEPTIONS
          CONVERSION_NOT_FOUND = 01
          DIVISION_BY_ZERO     = 02
          INPUT_INVALID        = 03
          OVERFLOW             = 04
          OUTPUT_INVALID       = 05
          UNITS_MISSING        = 06
          UNIT_IN_NOT_FOUND    = 07
          UNIT_OUT_NOT_FOUND   = 08.

Just check it.

May it helps you.

Regards.

Deepak Sharma.

Read only

0 Likes
4,490

Hi Deepak Sharma,

It doesn't work correctly, It always returns the excepction 'conversion_not_found'.

Thanks anyway.

Read only

4,490

Hi,

Check the below code


DATA: WA_QTY TYPE KTMNG.
WA_QTY = 100.000.
WRTIE WA_QTY UNIT 'ST'.
" Will display 100
WRTIE WA_QTY UNIT 'KG.
" Will display 100.000

Regards

Dillip

Read only

Former Member
0 Likes
4,490

Hi,

You can try below syntax :

WRITE <f> UNIT <u>.

Where as this statement sets the number of decimal places according to the unit <u>. The contents of <u> must be an entry in database table T006 in column MSEHI. The entry in column DECAN then determines the number of decimal places of the field <f> to be displayed. If the system does not find the entry <u> in table T006, it ignores the option.

Thanks and Regards,

P.Bharadwaj