Overblog Folge diesem Blog
Edit post Administration Create my blog
SAPManDoo - SAP Resource

BAPI-Aufruf BAPI_GOODSMVT_CREATE

13. Dezember 2011 , Geschrieben von sapmandoo Veröffentlicht in #MM

Das nachfolgende Coding stellt einen Beispielaufruf für das o.g. BAPI dar: 

 

REPORT ytestbapi.
* test / sample report for BAPI_GOODSMVT_CREATE
* S.ROHDE WNRC 12/2011
 

PARAMETERS: pa_test AS CHECKBOX DEFAULT 'X'.

DATA: gs_goodsmvt_header TYPE bapi2017_gm_head_01.
DATA: git_return         TYPE TABLE OF bapiret2.
DATA: git_items          TYPE TABLE OF bapi2017_gm_item_create.
DATA: gs_item            LIKE LINE OF git_items.
DATA: g_materialdocument TYPE bapi2017_gm_head_ret-mat_doc.
DATA: g_matdocumentyear  TYPE bapi2017_gm_head_ret-doc_year.
DATA: g_goodsmvt_code    TYPE bapi2017_gm_code VALUE '06'.  "MB11

* All supported transactions can be found in table T158G


* header
CLEAR: gs_goodsmvt_header.

gs_goodsmvt_header-pstng_date  = sy-datum.    "Posting date
gs_goodsmvt_header-doc_date    = sy-datum.    "Document date
gs_goodsmvt_header-ref_doc_no  = '4711'.      "Reference No
gs_goodsmvt_header-pr_uname    = sy-uname.    "User name
gs_goodsmvt_header-header_txt  = 'Test BAPI'"Header text

* item(s)
CLEAR git_items[].
CLEAR gs_item.

* caution: give article/mat. no. with leading zeroes!!!
gs_item-material = '000000000000002002'.      "Art./Mat.No
gs_item-plant = 'C302'.                       "plant/site
gs_item-stge_loc = '0001'.                    "Storage loc.
gs_item-move_type = 'Z01'.                    "Movement type (BwA)
gs_item-entry_qnt = 5.                        "Quantity
gs_item-entry_uom = 'ST'.                     "Unit
APPEND gs_item TO git_items.

* call bapi
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
  EXPORTING
    goodsmvt_header  = gs_goodsmvt_header
    goodsmvt_code    = g_goodsmvt_code
    testrun          = pa_test
  IMPORTING
    materialdocument = g_materialdocument
    matdocumentyear  = g_matdocumentyear
  TABLES
    goodsmvt_item    = git_items
    return           = git_return.

* commit work.
IF pa_test IS INITIAL.
  COMMIT WORK.
  WRITE: / 'Document posted:',
           g_materialdocument,
           '/',
           g_matdocumentyear,
           '    Returncode:',
           sy-subrc.
ENDIF.

* display messages from bapi, if necessary
IF NOT git_return[] IS INITIAL.
  CALL FUNCTION 'C14ALD_BAPIRET2_SHOW'
    TABLES
      i_bapiret2_tab = git_return.
ELSE.
  MESSAGE s600(fr) WITH 'no messages occured'
                        'while BAPI processed'.
ENDIF.

Diesen Post teilen

Repost 0
Um über die neuesten Artikel informiert zu werden, abonnieren:

Kommentiere diesen Post