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: 

cheking the material for base unit or convert it to base unit.

Former Member
0 Kudos

Hi friends,

I have a requirement asa follows.

I Have an internal table ITAB1 in that i have some 200 records. In that ITAB1 i have

MATNR and MEINS field and iam selecting those fields from MSEG table.

Now my requirment is i have to check for base unit of that particular.

example :

now let us say iam getting in my ITAB1.

MATNR MEINS

M-123 EA

now i have to check the base material for that material. if both the base unit and what i got i same then its ok. or if the both are not same then it should convert to the base unit.

how can i do that.

Regards,

Priyanka.

1 ACCEPTED SOLUTION

vinod_vemuru2
Active Contributor
0 Kudos

Hi,

First get the data from mara then compare and convert.

IF NOT itab1[] IS INITIAL.

SELECT matnr meins INTO table i_uoms FROM mara

FOR ALL ENTRIES IN itab1

WHERE matnr EQ itab1-matnr.

ENDIF.

LOOP AT itab1 INTO wa.

READ TABLE i_uoms INTO wa1 WITH KEY matnr = wa-matnr.

IF wa-uom NE wa1-uom.

CALL FM mentioned by AMIT to convert quantity to base unit.

ELSE.

Proceed.

ENDIF.

ENDLOOP.

Thanks,

Vinod.

7 REPLIES 7

former_member181995
Active Contributor
0 Kudos

MD_CONVERT_MATERIAL_UNIT

vinod_vemuru2
Active Contributor
0 Kudos

Hi,

First get the data from mara then compare and convert.

IF NOT itab1[] IS INITIAL.

SELECT matnr meins INTO table i_uoms FROM mara

FOR ALL ENTRIES IN itab1

WHERE matnr EQ itab1-matnr.

ENDIF.

LOOP AT itab1 INTO wa.

READ TABLE i_uoms INTO wa1 WITH KEY matnr = wa-matnr.

IF wa-uom NE wa1-uom.

CALL FM mentioned by AMIT to convert quantity to base unit.

ELSE.

Proceed.

ENDIF.

ENDLOOP.

Thanks,

Vinod.

0 Kudos

can u tell me what all the parameters we need to pass to the function module .

later after converting i should pass the ITAB1 after doing the check ie: converting to base unit to alv grid display. will it work.

Regards,

Priyanka.

0 Kudos

Hi Priyanka,

To this FM u have to pass the material number, Input unit(itab1-meins), Output unit(Base unit-mara-meins), Quantity. In Importing parameter E_MENGE pass one variable. After FM call u will receive the converted value in this variable.

Just check the where used list of the FM to see the sample code.


    CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
         EXPORTING
              I_MATNR              = P_MATNR
              I_IN_ME              = P_MEEHT "Input unit
              I_OUT_ME             = P_AUSME "Base unit
              I_MENGE              = P_MENGE "Input Quantity
         IMPORTING
              E_MENGE              = I_AUMENGE "Quantity in base unit.
         EXCEPTIONS
              ERROR_IN_APPLICATION = 1
              OTHERS               = 2.

Thanks,

Vinod.

0 Kudos

After converting the unit ie: after comparing i should modify my itab1 with the modified value.

ie: for every reocrd.

How can i do tht.

Regards,

Priyanka.

0 Kudos

Hi Priyanka,

For this question u could have pressed F1 key of ur key board:-). If u post this question here u get ans only for this question. But If u press F1 u come to many things about MODIFY statement.

Anyways ans for ur question is...

LOOP AT itab1 INTO wa.

l_tabix = sy-tabix.

the logic i told.

wa-quantity = FM output quantity(Converted value).

MODIFY itab1 FROM wa TRANSPORTING quantity INDEX l_tabix.

ENDLOOP.

Thanks,

Vinod.

Former Member
0 Kudos

Hello


select single * from MARM where matnr = ITAB1-matnr and meins = ITAB1-meins.
if sy-subrc = 0.
  call function 'MD_CONVERT_MATERIAL_UNIT' ......
endif.