BAPI para realizar movimientos de materiales:
Espero que les sirva este ejemplo.
Espero que les sirva este ejemplo.
Código:
FUNCION BAPI_GOODSMVT_CREATE REPORT Z_BAPI DATA: l_goodsmvt_header LIKE bapi2017_gm_head_01, l_goodsmvt_code LIKE bapi2017_gm_code, l_testrun LIKE bapi2017_gm_gen-testrun, l_goodsmvt_headret LIKE bapi2017_gm_head_ret, l_materialdocument LIKE bapi2017_gm_head_ret-mat_doc, l_matdocumentyear LIKE bapi2017_gm_head_ret-doc_year. DATA: i_goodsmvt_item LIKE bapi2017_gm_item_create OCCURS 10 WITH HEADER LINE, i_return LIKE bapiret2 OCCURS 10 WITH HEADER LINE. START-OF-SELECTION. * DATOS CABECERA CLEAR l_goodsmvt_header. l_goodsmvt_header-pstng_date = sy-datum. l_goodsmvt_header-doc_date = '20010122'. l_goodsmvt_header-pr_uname = sy-uname. l_goodsmvt_header-header_txt = 'Ent. desde fábrica'. L_GOODSMVT_HEADER-REF_DOC_NO = '00/00'. * Tipo de movimiento l_goodsmvt_code = '01'. "Goods receipt for purchase order * Posiciones CLEAR i_goodsmvt_item. i_goodsmvt_item-material = '01018950'. i_goodsmvt_item-plant = '0310'. i_goodsmvt_item-stge_loc = '0100'. i_goodsmvt_item-VENDOR = '0000000017'. i_goodsmvt_item-move_type = '101'. i_goodsmvt_item-MVT_IND = 'B'. "Indicador de movimiento i_goodsmvt_item-PO_NUMBER = '5500000001'. i_goodsmvt_item-po_item = '00020'. i_goodsmvt_item-ENTRY_QNT = '15.200'. I_GOODSMVT_ITEM-ENTRY_UOM = 'ST'. append i_goodsmvt_item. CALL FUNCTION 'BAPI_GOODSMVT_CREATE' EXPORTING goodsmvt_header = l_goodsmvt_header goodsmvt_code = l_goodsmvt_code testrun = ' ' IMPORTING goodsmvt_headret = l_goodsmvt_headret materialdocument = l_materialdocument matdocumentyear = l_matdocumentyear TABLES goodsmvt_item = i_goodsmvt_item * GOODSMVT_SERIALNUMBER = return = i_return . IF SY-SUBRC = 0. describe table i_return lines sy-tfill. if sy-tfill = 0. COMMIT WORK. endif. ENDIF.
Comentario