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: 

Post Goods Receipt for Inbound Delivery with BAPI_GOODSMVT_CREATE

0 Kudos
2,974

Hello,

I try to post GR for an Inbound Delivey with BAPI_GOODSMVT_CREATE and it is not working.

I know delivery number and PO number and give both to the bapi.

I am not sure how to set the movement indicator in the item.

When I set it to B.

I do get a shortdump from MB_POST_GOODS_MOVEMENT numer 143, stating that this type of movement is not allowed with this transaction

when setting to L I do get an error stating

"Update control of movement type is incorrect (entry 101 X X _ L)" from message class M7.

Below is the coding for it.

Thank you very much for your help

Michael

* Füllen der Kopfdaten
  ls_gm_header-pstng_date = sy-datum.
  ls_gm_header-doc_date = sy-datum.
  ls_gm_header-ref_doc_no = delivery_header-lifex.
  ls_gm_header-bill_of_lading = delivery_header-bolnr.
  ls_gm_header-gr_gi_slip_no = delivery_header-xabln.
  ls_gm_header-pr_uname = sy-uname.
  ls_gm_header-ref_doc_no_long = delivery_header-lifex.
  ls_gm_header-bill_of_lading_long = delivery_header-bolnr.
  lv_gm_code = '01'.

* Füllen der Positionsdaten
  LOOP AT selected_delivery_items INTO ls_delivery_item.
    ls_gm_items-material          =  ls_delivery_item-matnr.
    ls_gm_items-plant             = ls_delivery_item-werks. "             0001
    ls_gm_items-stge_loc = ls_delivery_item-lgort.

    ls_gm_items-move_type ='101'. "101
    ls_gm_items-entry_qnt                      = ls_delivery_item-lfimg. "          10,000
    ls_gm_items-entry_uom                      = ls_delivery_item-vrkme.
    ls_gm_items-po_number                      = ls_delivery_item-vgbel. "55001582
    ls_gm_items-po_item                        = ls_delivery_item-vgpos. "00010
    ls_gm_items-mvt_ind = 'B'.
    ls_gm_items-expirydate = sy-datum + 30 .
    ls_gm_items-deliv_numb = ls_delivery_item-vbeln.
    ls_gm_items-deliv_item = ls_delivery_item-posnr.

    APPEND ls_gm_items TO lt_gm_items.
  ENDLOOP.

  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
      goodsmvt_header               = ls_gm_header
      goodsmvt_code                 =  lv_gm_code
*     testrun                       = 'X'
*   GOODSMVT_REF_EWM              =
   IMPORTING
     goodsmvt_headret              =  ls_gm_header_ret
     materialdocument              = lv_mat_docno
     matdocumentyear               = lv_mat_year
    TABLES
      goodsmvt_item                 = lt_gm_items
     goodsmvt_serialnumber         = lt_gm_serial_numbers
      return                        = lt_return
            .

  if lt_return is INITIAL.
  endif.

1 ACCEPTED SOLUTION

former_member222709
Contributor
0 Kudos
677

Hi Micheal,

I would recommend you to discuss this with your Functional Consultant. Create a Delivery manually and then replicate the data for the BAPI. You can then compare the manual data entered and map it to the BAPI fields.

Regards,

Pranav.

7 REPLIES 7

former_member222709
Contributor
0 Kudos
678

Hi Micheal,

I would recommend you to discuss this with your Functional Consultant. Create a Delivery manually and then replicate the data for the BAPI. You can then compare the manual data entered and map it to the BAPI fields.

Regards,

Pranav.

0 Kudos
677

Hello Pranav,

the input for the business data is correct.

When performing the goods receipt with Migo it works.

I think the B in the movement indicator is correct, but there might be something wrong with the other data.

Best regards

Michael

0 Kudos
677

Try not to pass the delivery information ....

0 Kudos
677

Hi,

I am a bit confused.

I want to post goods receipt for that delivery. Therefore I think I should pass the delivery information.

Best regards

Michael

0 Kudos
677

Hi

Try to post a document online by MIGO and then check wihch fields have been filled in MKPF and MSEG by SE11 iin order to see if some data is missing

Max

0 Kudos
677

Well , Since delivery is against the PO , passing just only PO number will be sufficient . Delivery will automatically be determied .

In MIGO , if you do GR either using delivery or PO it works ...

kesavadas_thekkillath
Active Contributor
0 Kudos
677

It might be possible with MIGO. Check with other transaction like MB01 etc

Check in table T158G.