Thursday, October 27, 2011
Goods Movement For Production Order
Sample Code to fulfill Goods Movement For Production Order.
*** PARAMETERS PASSED
i_aufnr , i_aufnr_itno , i_plant , i_lgort , i_quantity
*** PARAMETERS PASSED
*** DATA Decleration
DATA : gs_header TYPE bapi2017_gm_head_01 ,
gs_code TYPE bapi2017_gm_code ,
gt_headret TYPE TABLE OF bapi2017_gm_head_ret WITH HEADER LINE ,
gt_item TYPE TABLE OF bapi2017_gm_item_create WITH HEADER LINE,
gt_return TYPE TABLE OF bapiret2 WITH HEADER LINE.
*** Find Order's UNIT
SELECT SINGLE sbmeh FROM afko INTO lv_sbmeh
WHERE aufnr = i_aufnr.
*GM_CODE TCODE Description
*01 MB01 Goods receipt for purchase order
*02 MB31 Goods receipt for production order
*03 MB1A Goods issue
*04 MB1B Transfer posting
*05 MB1C Other goods receipt
*06 MB11 Reversal of goods movements
*07 MB04 Subsequent adjustment with regard to a subcontract order
*** Set Code
gs_code-gm_code = '02' .
*** Header
gs_header-pstng_date = sy-datum .
gs_header-doc_date = sy-datum .
gs_header-pr_uname = sy-uname .
gs_header-header_txt = 'Text 123'.
gs_header-ref_doc_no = i_aufnr.
*** Item
CLEAR gt_item .
gt_item-move_type = '101' .
gt_item-spec_stock = 'E'.
gt_item-mvt_ind = 'F'.
gt_item-stck_type = 'X'.
*** Order Id
gt_item-orderid = i_aufnr.
gt_item-order_itno = i_aufnr_itno.
gt_item-plant = i_plant .
gt_item-stge_loc = i_lgort.
gt_item-entry_qnt = i_quantity .
gt_item-entry_uom = lv_sbmeh.
gt_item-entry_uom_iso = lv_sbmeh.
gt_item-item_text = i_aufnr .
APPEND gt_item .
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = gs_header
goodsmvt_code = gs_code
IMPORTING
goodsmvt_headret = gt_headret
TABLES
goodsmvt_item = gt_item[]
return = gt_return[].
BREAK-POINT.
LOOP AT gt_return WHERE type = 'S'
AND id = 'L9'
AND number = '514'.
ENDLOOP.
IF sy-subrc EQ 0.
*** Delivery Created - OK
ELSE.
*** Problem Occured - Check gt_return[]
ENDIF.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment