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

MD_CONVERT_MATERIAL_UNIT ISSUE

Former Member
0 Likes
5,897

Hi friends

These my requirement :

Use Function Module MD_CONVERT_MATERIAL_UNIT.  Pass the following data:

I_MATNR = VBAP-MATNR

I_IN_ME= VBAP-VRKME

I_OUT_ME = “MSF”

I_MENGE =  VBAP-KWMENG & Execute

Use E_MENGE

T006A-MSEHT

Pass “MSF” (UOM as described above) to T006A-MSEHI.

when i am writing the  below code instead of getting conversion result iam getting kwmeng values in the output.....help me

if sy-subrc eq 0.


DATA: lv_msf LIKE mara-meins,
      lv_menge
TYPE ekpo-menge.

LOOP AT git_output INTO gwa_output.

SELECT msehi
        mseht
FROM t006a
INTO TABLE git_t006a
WHERE msehi = 'MSF'.


lv_menge
= gwa_output-kwmeng.

CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr             
= gwa_output-matnr
i_in_me             
= gwa_output-vrkme
i_out_me            
= 'MSF'
i_menge             
lv_menge
IMPORTING
e_menge             
= lv_lfimg "lv_menge
EXCEPTIONS
error_in_application
= 1
error               
= 2
OTHERS               = 3.

IF sy-subrc = 0.
** Implement suitable error handling here
gwa_output
-kwmeng = lv_menge.
ELSE.
lv_menge
= gwa_output-kwmeng.
ENDIF.
MODIFY git_output from gwa_output TRANSPORTING kwmeng.

ENDLOOP.
ENDIF.

4 REPLIES 4
Read only

Former Member
0 Likes
3,153

Hi Naveen,

Create a variable as meshi

and call FM CONVERSION_EXIT_CUNIT_INPUT and pass MSF to it and use the variable as output parameter.

let me know if not resolved.

Regards,

Read only

Former Member
0 Likes
3,153

Hi,

From your code,

lv_menge = gwa_output-kwmeng.

CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
EXPORTING
i_matnr             
= gwa_output-matnr
i_in_me             
= gwa_output-vrkme
i_out_me            
= 'MSF'
i_menge             
lv_menge
IMPORTING
e_menge             
= lv_lfimg "lv_menge
EXCEPTIONS
error_in_application
= 1
error               
= 2
OTHERS               = 3.

IF sy-subrc = 0.
** Implement suitable error handling here
gwa_output
-kwmeng = lv_menge.
ELSE.
lv_menge
= gwa_output-kwmeng.
ENDIF.

according to your code after calling FM, whether the sy-subrc = 0 or <> 0,the lv_menge and gwa_output-kwmeng will contain same value.

check it once .

Regards,

shamili.


Read only

venkateswaran_k
Active Contributor
0 Likes
3,153

Try in SE37 first - MD_CONVERT_MATERIAL_UNIT

By passing the value as example and verify the output value

Then debug at the place sy-subrc and see...

Probably as Shamili says, coding issue

Regards,

Venkat


Read only

Former Member
0 Likes
3,153

Hi Naveen,

If you want to convert a material quantity from base to alternate or alternate to base then use FM,

'MATERIAL_UNIT_CONVERSION'.

1 thing about this FM,

*) If you want to convert an alternate unit to another alternate unit, you need to call this FM two times in sequence.

Sample Code -

*-- Set Indicator KZMEINH to indicate conversion of Alternate to Base UoM

data : lv_lfimg type lips-lfimg,

              lv_meins              TYPE meins,                                 

              lv_vrkme              TYPE vrkme,                                      

              lv_input_qty          TYPE f,     

              lv_output_qty          TYPE f,     

    

          lv_input_qty = lv_lfimg.

          lv_kzmeinh = 'X'.

          CALL FUNCTION 'MATERIAL_UNIT_CONVERSION'

            EXPORTING

              input                = lv_input_qty

              kzmeinh              = lv_kzmeinh

              matnr                = lv_matnr

              meinh                = lv_vrkme

              meins                = lv_meins

            IMPORTING

              output               = lv_output_qty

            EXCEPTIONS

              conversion_not_found = 01

              input_invalid        = 02

              material_not_found   = 03

              meinh_not_found      = 04

              meins_missing        = 05

              output_invalid       = 06

              overflow             = 07.

BR.