SAP Function ‘BAPI_GOODSMVT_CREATE’ Source Code 공유
Stock Transfer시 이용하는 BAPI 함수 소스코드 입니다.
* BAPI
DATA: gt_item TYPE TABLE OF bapi2017_gm_item_create WITH HEADER LINE,
gv_materialdocument TYPE bapi2017_gm_head_ret-mat_doc,
gv_matdocumentyear TYPE bapi2017_gm_head_ret-doc_year,
gs_header TYPE bapi2017_gm_head_01.
DATA: lt_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
DATA: lv_tabix TYPE sy-tabix.
* Header
CLEAR: gs_header.
gs_header-pstng_date = p_bldat. “전기일(입고일)
gs_header-doc_date = p_budat. “전표증빙일
gs_header-header_txt = ‘Vendor Stock’. “Header Text
gs_header-ver_gr_gi_slip = ‘2’. “GR/GI Slip
gs_header-ver_gr_gi_slipx = ‘X’. “GR/GI Slip Update Flag
* Item
LOOP AT gt_upload.
lv_tabix = sy-tabix.
CLEAR: gt_item, gt_item[].
gt_item-plant = gt_upload-werks. “플랜트
gt_item-move_type = p_bwart. “이동유형
gt_item-entry_qnt = gt_upload-menge. “수량
gt_item-stge_loc = gt_upload-lgort.
CALL FUNCTION ‘CONVERSION_EXIT_CUNIT_INPUT’
EXPORTING
input = gt_upload-meins
language = sy-langu
IMPORTING
output = gt_item-entry_uom.
macro_conversion_alpha_output gt_upload-matnr gt_item-material.
macro_conversion_alpha_output gt_upload-lifnr gt_item-vendor.
APPEND gt_item. CLEAR gt_item.
CLEAR: gv_materialdocument, gv_matdocumentyear,
lt_return, lt_return[].
CALL FUNCTION ‘BAPI_GOODSMVT_CREATE’
EXPORTING
goodsmvt_header = gs_header
goodsmvt_code = ’04’ “Transfer Posting
IMPORTING
materialdocument = gv_materialdocument
matdocumentyear = gv_matdocumentyear
TABLES
goodsmvt_item = gt_item
return = lt_return.
IF gv_materialdocument IS INITIAL.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.
READ TABLE lt_return WITH KEY type = ‘E’.
gt_upload-icon = icon_red_light.
gt_upload-msg = lt_return-message.
MODIFY gt_upload INDEX lv_tabix TRANSPORTING icon msg.
ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’
EXPORTING
wait = ‘X’.
gt_upload-icon = icon_green_light.
gt_upload-mblnr = gv_materialdocument.
gt_upload-msg = ‘Success!’.
MODIFY gt_upload INDEX lv_tabix TRANSPORTING mblnr icon msg.
ENDIF. “IF gv_materialdocument IS INITIAL.
ENDLOOP
Subscribe
Login
0 Comments
Oldest