Skip to Content
avatar image
Former Member

Help - BAPI_GOODSMVT_CREATE on an Inbound Delivery - R/3 4.7

Can anyone recommend how to get BAPI_GOODSMVT_CREATE working for an INBOUND delivery? I'm in R/3 4.7 and this BAPI does not update the delivery status or the delivery document flow for INBOUND deliveries. I have BAPI_GOODSMVT_CREATE working partially - it successfully creates the goods receipt and the P.O. doc flow is being updated.

Also, I am executing the COMMIT statement once directly after the FM call.

It seems the BAPI is not intended to do this functionality. How have you handled this scenario?

 

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Aug 31, 2005 at 09:42 AM

    Andrew,

    Have you had any luck with this. I have exactly the same problem and can't see any simple way to solve it. Did you find a standard solution for this, or have you managed to develop your own?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      I have solved at least part of the problem. I am using the message SHP_IBDLV_CONFIRM_DECENTRAL which allows me to post goods issue against the delivery and this in turn updates the Purchase order delivery history. The only drawback to this is that you need to have entered a put away quantity on the delivery before you pass the idoc.

      I have not worked this out yet, but am thinking that it should be possible using the inbound delivery creation methods. (Possible DESADV)

  • avatar image
    Former Member
    Oct 25, 2005 at 01:21 PM

    Hi,

    I just had the same problem. Wanted to post GR for inbound delivery with BAPI_GOODSMVT_CREATE, but only the PO history is updated, not the goods movement status / document flow in the inbound delivery. I debugged this for a while and came to the conclusion that this BAPI is not intended for this scenario.

    As an alternative I am using IDOC message type SHPCON / basic type DELVRY03 with process code DELV on the inbound side. This posts the GR to the inbound dlv., updates the GM status and document flow as well as the PO history. In the end it is function module IDOC_INPUT_DELVRY that is used. The only problem I am having is, that you cannot maintain the "delivery completed" flag (ELIKZ) in the PO with this IDoc.

    Well, if anyone finds a way to use BAPI_GOODSMVT_CREATE (which has the ELIKZ), please let me know.

    Claus

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 27, 2007 at 08:18 PM

    Dear all

    Bapi BAPI_GOODSMVT_CREATE could be used to post goods receipt against inbound delivery but in consequence no Delivery document flow is updated. This is official SAP explaination.

    But there is solution to accomplish it. After posting goods movements you should update Inbound Delivery using fm SD_DELIVERY_UPDATE.

    Check following coding:

    *&---------------------------------------------------------------------*
    form process_0112.
    
      clear post_status.
      post_status-delivery = wa_likp-vbeln.
    
    * posting
      perform post_goodsreceipt     changing post_status.
      perform post_delivery_hist    changing post_status.
      perform post_transferorder    changing post_status.
    
    * reversal posting if necessary
      perform reverse_goodsreceipt  changing post_status.
      perform reverse_delivery_hist changing post_status.
    
    * display message in case of error
      perform issue_message         changing post_status.
    
    * leave transaction
      leave to transaction sy-tcode.
    
    endform.                    " process_0112
    
    
    *&---------------------------------------------------------------------*
    form post_goodsreceipt changing post_status structure post_status.
    
    *-----------------------------------------
    * DATA DECLARATION
    *-----------------------------------------
    * material document header
      data: begin of it_head.
              include structure bapi2017_gm_head_01.
      data: end of it_head.
    * T158G special code
      data: begin of it_code.
              include structure bapi2017_gm_code.
      data: end of it_code.
    * material document returned data
      data: begin of it_rthead.
              include structure bapi2017_gm_head_ret.
      data: end of it_rthead.
    * material document items
      data: begin of it_pos occurs 100.
              include structure bapi2017_gm_item_create.
      data: end of it_pos.
    * error table
      data: begin of it_errmsg occurs 10.
              include structure bapiret2.
      data: end of it_errmsg.
    
    * return data
      data: post_mat_doc  type bapi2017_gm_head_ret-mat_doc,
            post_doc_year type bapi2017_gm_head_ret-doc_year.
    
    
    *-----------------------------------------
    * FILL DATA
    *-----------------------------------------
    * material document header
      it_head-pstng_date  = sy-datum.            
      it_head-doc_date    = sy-datum.            
      it_head-header_txt  = 'RF'.                
      it_head-pr_uname    = sy-uname.
    * T158G code
      it_code-gm_code     = '01'.
    * material document items
      loop at it_lips into wa_lips where posnr <> space.
        it_pos-mvt_ind              = 'B'.
        it_pos-deliv_numb_to_search = wa_lips-vbeln.
        it_pos-deliv_item_to_search = wa_lips-posnr.
        it_pos-po_number            = wa_lips-vgbel.
        it_pos-po_item              = wa_lips-vgpos.
        it_pos-move_type            = '985'.
        it_pos-entry_qnt            = wa_lips-rv_lfimg.
        append it_pos.
      endloop.
    
    
    *-----------------------------------------
    * CALL BAPI
    *-----------------------------------------
      refresh: it_errmsg.
      call function 'BAPI_GOODSMVT_CREATE'
        exporting
          goodsmvt_header             = it_head
          goodsmvt_code               = it_code
        importing
          materialdocument            = post_mat_doc
          matdocumentyear             = post_doc_year
        tables
          goodsmvt_item               = it_pos
          return                      = it_errmsg.
    * check result
      if post_mat_doc is initial.
        post_status-post_mat_doc  = space.
        post_status-post_doc_year = space.
        rollback work.
      else.
        post_status-post_mat_doc  = post_mat_doc.
        post_status-post_doc_year = post_doc_year.
        commit work and wait.
      endif.
    
    endform.                    " post_goodsreceipt
    
    
    *&---------------------------------------------------------------------*
    form post_delivery_hist changing post_status structure post_status.
    
    
    *-----------------------------------------
    * DATA DECLARATION
    *-----------------------------------------
      data: it_vbfa    like vbfa occurs 0,
            wa_vbfa    like vbfa.
    
    
    *-----------------------------------------
    * CHECK IF UPDATE DELIVERY IS ESSENTIAL
    *-----------------------------------------
      check not post_status-post_mat_doc  is initial
      and   not post_status-post_doc_year is initial.
    
    
    *-----------------------------------------
    * POPULATE TABLE
    *-----------------------------------------
      loop at it_lips into wa_lips where posnr <> space.
        clear wa_vbfa.
        wa_vbfa-vbelv = wa_lips-vbeln.
        wa_vbfa-posnv = wa_lips-posnr.
        wa_vbfa-vbeln = post_status-post_mat_doc.
        wa_vbfa-vbtyp_n = 'R'.
        wa_vbfa-vbtyp_v = '7'.
        wa_vbfa-plmin   = '+'.
        select single zeile waers menge dmbtr meins matnr bwart
          from mseg
            into (wa_vbfa-posnn, wa_vbfa-waers,
                  wa_vbfa-rfmng, wa_vbfa-rfwrt,
                  wa_vbfa-meins, wa_vbfa-matnr,
                  wa_vbfa-bwart)
              where mblnr = post_status-post_mat_doc
                and mjahr = post_status-post_doc_year
                and ebeln = wa_lips-vgbel
                and ebelp = wa_lips-vgpos.
        append wa_vbfa to it_vbfa.
      endloop.
    
    
    *-----------------------------------------
    * UPDATE DELIVERY
    *-----------------------------------------
      data:    begin of yvbfa occurs 0.
                 include structure vbfavb.
      data:    end of yvbfa.
      data:    begin of xvbfa occurs 0.
                 include structure vbfavb.
      data:    end of xvbfa.
      data:    begin of xvttk occurs 0.
                 include structure vttkvb.
      data:    end of xvttk.
    
      sort it_vbfa by mandt vbelv posnv vbeln posnn vbtyp_n.
    
      loop at it_vbfa into xvbfa.
        xvbfa-rfmng_flt = xvbfa-rfmng.
        xvbfa-updkz = 'I'.
        append xvbfa.
        at end of vbelv.
          call function 'SD_DELIVERY_UPDATE'
               exporting
                    i_vbtyp          = '7'
                    nicht_sperren    = 'Y'
                    no_imseg_refresh = 'X'
               tables
                    zxvbfa        = xvbfa
                    zyvbfa        = yvbfa
                    zxvttk        = xvttk
               exceptions
                    others        = 1.
          if sy-subrc <> 0.
            exit.
          endif.
          refresh xvbfa.
        endat.
      endloop.
    
    * check result
      if sy-subrc <> 0.
        post_status-post_deli_hist  = 'R'.
        rollback work.
      else.
        post_status-post_deli_hist  = 'C'.
        commit work and wait.
      endif.
    
    endform.                    " post_delivery_hist

    Add comment
    10|10000 characters needed characters exceeded