Create SAP Goods Movements with BAPI Function
Details
- Details
- Category: ABAP
- Created on Tuesday, 06 November 2012 13:18
- Last Updated on Monday, 12 November 2012 09:08
- Published on Tuesday, 06 November 2012 13:18
- Written by Administrator
- Hits: 14440
Simple program for SAP Goods Movements with BAPI Functions:
program ZGOODS_MV.
*&---------------------------------------------------------------------*
*& www.developerpages.gr
*& Create Goods Movements
*&---------------------------------------------------------------------*
data: begin of l_goodsmvt_item occurs 100.
include structure bapi2017_gm_item_create.
data: end of l_goodsmvt_item.
data : begin of l_goodsmvt_header occurs 100.
include structure bapi2017_gm_head_01.
data : end of l_goodsmvt_header.
data : begin of l_goodsmvt_code occurs 100.
include structure bapi2017_gm_code.
data : end of l_goodsmvt_code.
data : begin of l_goodsmvt_headret occurs 100.
include structure bapi2017_gm_head_ret.
data : end of l_goodsmvt_headret.
data: begin of l_return occurs 10.
include structure bapiret2.
data: end of l_return.
l_goodsmvt_header-pstng_date = sy-datum.
l_goodsmvt_header-doc_date = sy-datum.
l_goodsmvt_header-pr_uname = sy-uname.
l_goodsmvt_code-gm_code = '04'. "04 - MB1B - Enter Transfer Posting
l_goodsmvt_item-move_type = 'AA5'.
l_goodsmvt_item-plant = '1010'.
l_goodsmvt_item-material = '000000000000000010'.
l_goodsmvt_item-entry_qnt = 5.
l_goodsmvt_item-move_stloc = '10'.
l_goodsmvt_item-stge_loc = '11'.
l_goodsmvt_item-ITEM_TEXT = 'Item Text'.
append l_goodsmvt_item.
call function 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = l_goodsmvt_header
goodsmvt_code = l_goodsmvt_code
IMPORTING
goodsmvt_headret = l_goodsmvt_headret
TABLES
goodsmvt_item = l_goodsmvt_item
return = l_return.
if l_goodsmvt_headret-MAT_DOC <> '' and l_goodsmvt_headret-DOC_YEAR <> ''.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
write :/ 'Goods movement created with number : ', l_goodsmvt_headret-MAT_DOC, ' Year : ',l_goodsmvt_headret-DOC_YEAR.
else.
loop at l_return.
write:/ l_return-type, l_return-message(100).
endloop.
endif.