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: 

How to assign a value for Unit of measure (like PC, KG...) in ABAP program?

Former Member
0 Kudos

Hi,

How to assign a value for Unit of measure (like PC, KG...) in ABAP program?

I want to assign PC in a field to execute the program, like wa-ENTRY_UOM = 'pc'.

But the system returen a message that "Unit of measure is not convertible to stockkeeping unit PC"

Could anyone tell me how to assign the value??

Thanks!

4 REPLIES 4

Former Member
0 Kudos

Hi Nick,

There is a conversion routine ( Function Module) for UOM field, which is avaliable in the domain of the the field (Ex. MEINS), i.e PC is stored as ST in the database.

Use these conversion routine ( Function Module) before updating it or assinging it .

Regards,

Kumar M.

0 Kudos

Dear Kumar,

Thanks for your respond, But I still confuse about it. For example, if I want to create a new Sales order, I just need to type 'PC' in the unit field. But now I need to use the ABAP code to do something and I also need to assign a vlue of the unit field. I want to assign 'PC' in this field and I use the code

wa-ENTRY_UOM = 'pc'. If 'PC' is stored as 'ST' in DB, so I need to assign wa-ENTRY_UOM = 'ST' ?

or how could i assign the unit value? I really need to solve this problem. Hope can give me some respond. Thanks a lot!

Former Member
0 Kudos

hi,

first convert the quantity in the same unit ( like in you case ST to PC ) by using FM : MD_CONVERT_MATERIAL_UNIT

CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
    EXPORTING
      i_matnr                    = matnr
      i_in_me                    = entry_uom
      i_out_me                   = out_uom
      i_menge                    = quantity 
   IMPORTING
     E_MENGE                     = fp_l_v_quant
   EXCEPTIONS
     ERROR_IN_APPLICATION       = 1
     ERROR                      = 2
     OTHERS                     = 3.
  IF sy-subrc <> 0.
  
          give error message here

   ENDIF.

bcoz in ur program somewhere the quantities etc are compared and there units may be different... so that is why it is showing such error. so just convert convert the quantity in the same unit .

regards

rahul

Edited by: RAHUL SHARMA on Jun 17, 2009 9:31 AM

Former Member
0 Kudos

Hi NIck,

There are conversion routines avaliable to these transactions, so it will automatically change to the database value.

As a value table assigned these fields at domain level, error will alwalys pop up, so check whether a conversion exit is avaliable at domain level for UOM and currency fields and even check the value table by these you will a idea.

Regards,

Kumar M.