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

BAPI_GOODSMVT_CREATE for GRN posting

Former Member
0 Likes
3,804

Hi Experts,

I am using BAPI_GOODSMVT_CREATE for posting GRN against Purchase Order.

I want to post Quantity in Delivery note(LSMNG) and Unit of Measure From Delivery Note(LSMEH) also.

I used itab-QUANTITY = '1'.

itab-BASE_UOM = 'L'.

but it is not getting updated properly.

I am getting document number and GRN has been done against Purchase Order using this BAPI.All other fields are properly getting updated except these 2 fields Qty in delivery note and unit of delivery note. Can i pass these 2 field values using this BAPI or do I need to use any other BAPI. Is there any BAPI for MIGO instead of MB01?

Can any one help me to pass these values through BAPI

Regards,

Sam

11 REPLIES 11
Read only

venkateswaran_k
Active Contributor
0 Likes
2,290

Hi

Please pass the value as follows:

gt_goodsmvt_item-move_type = gv_upload-movetype. "'101'. <-- decide based on your transaction

gt_goodsmvt_item-entry_qnt = gv_upload-quantity. "'50'. <- for quantity

gt_goodsmvt_item-entry_uom = lips-vrkme.

Please let me know if it works..

Use same BAPI_GOODSMVT_CREATE - and change the movement type for MIGO, MB1C, etc...

Regards,

Venkat

Read only

0 Likes
2,290

Hi iyeve01,

I tried these values.But these fields are for Qty in Unit of Entry and Qty in SKU.These values are properly getting updated in data base.I also want to update Qty in Delivery Note and UOM.

If we didn't maintain these values in GRN, is there any effect?

Regards,

Sam

Read only

0 Likes
2,290

Hi Venkat,

Still quantity in delivery note and unit of delivery note fields not getting updated.

Under doc.info tab, I can view MB01 as transaction code instead of MIGO_GR. Will it be the reason?

Stock is properly updated but in GRN screen these 2 field entries are blank. How to rectify this problem?

Regards,

Sam

Read only

0 Likes
2,290

Use same BAPI 'BAPI_GOODSMVT_CREATE' and send the following fields to item data.

t_bapiitem-move_type = '101'. "Movement type

t_bapiitem-plant = '0002'. "Plant

t_bapiitem-stge_loc = '0100'. "Storage Location

t_bapiitem-material = '102342'. "Material

t_bapiitem-entry_qnt = '10'. "Quantity

t_bapiitem-entry_uom = 'EA' . "UOM

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = bapiheader " Header Data

goodsmvt_code = '5' " Goods movement Code

IMPORTING

materialdocument = matdoc " Material Document

TABLES

goodsmvt_item = t_bapiitem " BAPI item data

return = t_bapiret2. " Return

Read only

0 Likes
2,290

Hi Ravi,

The fields which u have mentioned is for Qty in unit of entry and its UOM. I want Qty in delivery note(LSMNG) to be updated.

Also when I put mvmt type as 5 I am getting the following error:

Goods movement not possible with mvmt type 101

If LSMNG field is left blank in MIGO, will it affect any other tables? This field is not a mandatory field.

Pls help me to reslove this issue.

Regards,

Sam

Read only

Former Member
2,290

Hi,

you can update LSMNG quantity using EXTENSIONIN structures of BAPI_GOODSMVT_CREATE.

The steps are the following:

Add LSMNG field in BAPI_TE_XMSEG structure create an appending structure (char field)

By SE19 transaction create the Enhancement Spot starting from MB_GOODSMOVEMENT

Define the Badi Implementation choosing MB_BAPI_GOODSMVT_CREATE Badi Definition implementing a new customer class.

Remember to choose to copy the class with the source code of methods.

In The method IF_EX_MB_Hi, you can update LSMNG quantity using EXTENSIONIN structures of BAPI_GOODSMVT_CREATE. The steps are the following: Add LSMNG field in BAPI_TE_XMSEG structure create an appending structure (char field) By SE19 transaction create the Enhancement Spot starting from MB_GOODSMOVEMENT Define the Badi Implementation choosing MB_BAPI_GOODSMVT_CREATE Badi Definition implementing a new customer class.

Remember to choose to copy the class with the source code of methods.

In the method IF_EX_MB_BAPI_GOODSMVT_CREATE~EXTENSIONIN_TO_MATDOC you will find the following source code:

  DATA:     c_lenstruc          TYPE i VALUE 30,    

   wa_bapi_mb_header   TYPE bapi_te_xmkpf,    

   wa_bapi_mb_item     TYPE bapi_te_xmseg,    

   wa_extension_in     TYPE bapiparex.  

   FIELD-SYMBOLS:               TYPE imseg.  

   CHECK NOT extension_in[] IS INITIAL.

  * Analyze IMSEG for document structure and assign LINE_IDs if necessary  

   CALL METHOD cl_mmim_line_id_manager=>analyze_mb_create    

          CHANGING       ct_imseg          = ct_imseg[]    

             EXCEPTIONS       duplicate_line_id = 1      

             OTHERS            = 2.  

  LOOP AT extension_in INTO wa_extension_in.    

     CASE wa_extension_in-structure.

* extension of MKPF      

     WHEN 'BAPI_TE_XMKPF'.        

     MOVE wa_extension_in+c_lenstruc TO wa_bapi_mb_header.        

     MOVE-CORRESPONDING wa_bapi_mb_header TO cs_imkpf.

* extension of MSEG      

    WHEN 'BAPI_TE_XMSEG'.        

    MOVE wa_extension_in+c_lenstruc TO wa_bapi_mb_item.        

    READ TABLE ct_imseg           WITH KEY line_id = wa_bapi_mb_item-matdoc_itm           ASSIGNING   <fs_imseg>.        

      IF sy-subrc EQ 0.          

         MOVE-CORRESPONDING wa_bapi_mb_item TO   <fs_imseg>.       

       ENDIF.   

     ENDCASE.  

    ENDLOOP.

Then you have to call BAPI_GOODSMVT_CREATE using extensionin in the following way:

* Fill   goodsmvt_header structures

  goodsmvt_header-........

* Fill    goodsmvt_item-position

  Loop at it_position.

         goodsmvt_item-..........

          wf_line_id = wf_line_id + 1.

          goodsmvt_item-line_id = wf_line_id.

          APPEND goodsmvt_item.

        CLEAR extensionin.
        MOVE 'BAPI_TE_XMSEG'    TO extensionin-structure.
        MOVE wf_line_id+2(4)    TO extensionin-valuepart1+14(4).
        MOVE LSMNG              TO extensionin-valuepart1+18(16).
        APPEND extensionin.

endloop.

        CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header               = goodsmvt_header
          goodsmvt_code                 = goodsmvt_code
*         TESTRUN                       = ' '
          goodsmvt_ref_ewm              = goodsmvt_ref_ewm
        IMPORTING
*         GOODSMVT_HEADRET              =
          materialdocument              = materialdocument
          matdocumentyear               = matdocumentyear
        TABLES
          goodsmvt_item                 = goodsmvt_item
*         GOODSMVT_SERIALNUMBER         =
          return                        = return
          extensionin                   = extensionin.

Hope it helps

Lorenzo

Read only

0 Likes
2,290

Hi  lorenzo,

Thank you for your suggestion ...it's very useful to me.

Regards,

Subba.R

Read only

0 Likes
2,290

Thanks Lorenzo, it worked very well to me..

Regards!

Read only

former_member184737
Active Contributor
0 Likes
2,290

Hi

     My query is also very specific and exactly the same to this post. So that, i have raised my query here. Is this possible to copy the values of " Qty in Unit of Entry" and its "Unit" fields into "Qty into delivery Note" and its "Unit" fields automatically? Is there any settings? we wants to copy the same  values should be copied into "Qty into delivery Note" and its "Unit" fields automatically. Any suggestion please.

Thanks

Read only

0 Likes
2,290

Hi,

i solved this issue by customizing the FM    MAP2I_B2017_GM_ITEM_TO_IMSEG......

Regards,

Suba.

Read only

0 Likes
2,290

Hi,

The 'BAPI_GOODSMVT_CREATE' internally calls the FM 'MAP2I_B2017_GM_ITEM_TO_IMSEG'.

adding the code in this FM by enhancement you can surely change the 'Quantity in delivery' Note along with the 'unit', provided if and only if the quantity to be posted in GRN (i.e. GRN Quantity) should be the same as Quantity in delivery note and its unit.

Just go to the FM 'MAP2I_B2017_GM_ITEM_TO_IMSEG' in subroutine ' map2i_b2017_gm_item_to_imseg'

create an enhancement and move the values of imseg- erfmg to  imseg-lsmng and  imseg-erfme to  imseg-lsmeh.

Code for the same is as follow:

IF imseg-erfmg IS NOT INITIAL.

     MOVE imseg-erfmg

     TO imseg-lsmng.

ENDIF.

IF imseg-erfme IS NOT INITIAL.

     MOVE imseg-erfme

     TO imseg-lsmeh.

ENDIF.


Regards,

Abhijeet U