SAP Bilgi Merkezi
Ana Sayfa  ABAP   FI   CO   MM   SD   PP   QM   HR   BW 
ABAP Destek
Malzeme Belgesi At

SAP de mal hareketi yapabilmek için BAPI_ACC_GOODS_MOVEMENT_POST fonksiyonunu aşağıdaki gibi doldurup çalıştırabilirsiniz.

Örnek Program:

*&---------------------------------------------------------------------
*& Created Date : 12.09.2006                                           *
*& Created By   : Yavuz KOMUT                                          *
*&---------------------------------------------------------------------*
REPORT acc_bapi_test_goods_movement LINE-SIZE 250. SELECTION-SCREEN BEGIN OF BLOCK bl01 WITH FRAME TITLE text-002. PARAMETER: check_l DEFAULT 'X' AS CHECKBOX, check_a DEFAULT 'X' AS CHECKBOX, post DEFAULT ' ' AS CHECKBOX, ref_key LIKE bapiache01-obj_key DEFAULT '0000000000TEST', dest LIKE bdi_logsys-logsys DEFAULT ' '. SELECTION-SCREEN END OF BLOCK bl01. DATA: gd_documentheader LIKE bapiache02, it_accountgl LIKE bapiacgl02 OCCURS 0 WITH HEADER LINE, it_criteria LIKE bapiackecr OCCURS 0 WITH HEADER LINE, it_valuefield LIKE bapiackeva OCCURS 0 WITH HEADER LINE, it_currencyamount LIKE bapiaccr01 OCCURS 0 WITH HEADER LINE, it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE, it_purchaseorder LIKE bapiacpo00 OCCURS 0 WITH HEADER LINE, it_purchaseamount LIKE bapiaccrpo OCCURS 0 WITH HEADER LINE, it_receivers LIKE bdi_logsys OCCURS 0 WITH HEADER LINE. PERFORM fill_internal_tables. IF check_l = 'X'. CALL FUNCTION 'BAPI_ACC_GOODS_MOVEMENT_CHECK' DESTINATION dest EXPORTING documentheader = gd_documentheader TABLES accountgl = it_accountgl * CURRENCYAMOUNT = it_CURRENCYAMOUNT purchaseorder = it_purchaseorder purchaseamount = it_purchaseamount return = it_return criteria = it_criteria valuefield = it_valuefield * EXTENSION1 = it_EXTENSION1 . WRITE: / 'Result of check lines:'. PERFORM show_messages. ENDIF. IF check_a = 'X'. CALL FUNCTION 'BAPI_ACC_GOODS_MOVEMENT_CHECK' DESTINATION dest EXPORTING documentheader = gd_documentheader TABLES accountgl = it_accountgl currencyamount = it_currencyamount purchaseorder = it_purchaseorder purchaseamount = it_purchaseamount return = it_return criteria = it_criteria valuefield = it_valuefield * EXTENSION1 = it_EXTENSION1 . WRITE: / 'Result of check all:'. PERFORM show_messages. ENDIF. IF post = 'X'. IF dest = space OR dest = gd_documentheader-obj_sys. * post synchron CALL FUNCTION 'BAPI_ACC_GOODS_MOVEMENT_POST' EXPORTING documentheader = gd_documentheader * IMPORTING * OBJ_TYPE = * OBJ_KEY = * OBJ_SYS = TABLES accountgl = it_accountgl currencyamount = it_currencyamount purchaseorder = it_purchaseorder purchaseamount = it_purchaseamount return = it_return criteria = it_criteria valuefield = it_valuefield * EXTENSION1 = it_EXTENSION1 . WRITE: / 'Result of post:'. PERFORM show_messages. ELSE. * post Idoc it_receivers-logsys = dest. APPEND it_receivers. CALL FUNCTION 'ALE_ACC_GOODS_MOVEMENT_POST' EXPORTING documentheader = gd_documentheader * SERIAL_ID = '0' TABLES accountgl = it_accountgl currencyamount = it_currencyamount purchaseorder = it_purchaseorder purchaseamount = it_purchaseamount criteria = it_criteria valuefield = it_valuefield * EXTENSION1 = receivers = it_receivers * COMMUNICATION_DOCUMENTS = * APPLICATION_OBJECTS = * EXCEPTIONS * ERROR_CREATING_IDOCS = 1 * OTHERS = 2 . WRITE: / 'IDoc created'. ENDIF. ENDIF. COMMIT WORK. *---------------------------------------------------------------------* * Form fill_internal_tables *---------------------------------------------------------------------* FORM fill_internal_tables. CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET' IMPORTING own_logical_system = gd_documentheader-obj_sys. * fill header gd_documentheader-obj_type = ' '. gd_documentheader-obj_key = ref_key. * GD_DOCUMENTHEADER-OBJ_SYS = FUNKTION OWN_LOGICAL_SYSTEM_GET gd_documentheader-username = sy-uname. gd_documentheader-header_txt = 'HD BAPI Test'. * GD_DOCUMENTHEADER-OBJ_KEY_R = gd_documentheader-comp_code = '0001'. * GD_DOCUMENTHEADER-AC_DOC_NO = * GD_DOCUMENTHEADER-FISC_YEAR = gd_documentheader-doc_date = '19990303'. gd_documentheader-pstng_date = '19990303'. * GD_DOCUMENTHEADER-FIS_PERIOD = * GD_DOCUMENTHEADER-DOC_TYPE = * GD_DOCUMENTHEADER-REF_DOC_NO = * GD_DOCUMENTHEADER-COMPO_ACC = . * fill GL (line 1) it_accountgl-itemno_acc = 1. it_accountgl-gl_account = '0000300000'. * IT_ACCOUNTGL-COMP_CODE = * IT_ACCOUNTGL-PSTNG_DATE = * IT_ACCOUNTGL-DOC_TYPE = * IT_ACCOUNTGL-AC_DOC_NO = * IT_ACCOUNTGL-FISC_YEAR = * IT_ACCOUNTGL-FIS_PERIOD = * IT_ACCOUNTGL-LOG_PROC = * IT_ACCOUNTGL-STAT_CON = * IT_ACCOUNTGL-REF_KEY_1 = * IT_ACCOUNTGL-REF_KEY_2 = * IT_ACCOUNTGL-REF_KEY_3 = * IT_ACCOUNTGL-ACCT_KEY = * IT_ACCOUNTGL-ACCT_TYPE = * IT_ACCOUNTGL-CUSTOMER = * IT_ACCOUNTGL-VENDOR_NO = it_accountgl-item_text = 'GL BAPI Test'. * IT_ACCOUNTGL-BUS_AREA = * IT_ACCOUNTGL-COSTCENTER = * IT_ACCOUNTGL-PO_PR_QNT = * IT_ACCOUNTGL-PO_PR_UOM = * IT_ACCOUNTGL-PO_PR_UOM_ISO = * IT_ACCOUNTGL-ORDERID = * IT_ACCOUNTGL-ASSET_NO = * IT_ACCOUNTGL-SUB_NUMBER = * IT_ACCOUNTGL-ASVAL_DATE = it_accountgl-material = 'Mat1'. it_accountgl-quantity = 10. it_accountgl-base_uom = 'kg '. * IT_ACCOUNTGL-BASE_UOM_ISO = * IT_ACCOUNTGL-PLANT = * IT_ACCOUNTGL-TR_PART_BA = * IT_ACCOUNTGL-ORIG_GROUP = * IT_ACCOUNTGL-ORIG_MAT = * IT_ACCOUNTGL-COST_OBJ = * IT_ACCOUNTGL-PROFIT_CTR = * IT_ACCOUNTGL-PART_PRCTR = * IT_ACCOUNTGL-WBS_ELEMENT = * IT_ACCOUNTGL-NETWORK = * IT_ACCOUNTGL-ROUTING_NO = * IT_ACCOUNTGL-ORDER_ITNO = * IT_ACCOUNTGL-CMMT_ITEM = * IT_ACCOUNTGL-FUNDS_CTR = * IT_ACCOUNTGL-FUND = * IT_ACCOUNTGL-SALES_ORD = * IT_ACCOUNTGL-S_ORD_ITEM = * IT_ACCOUNTGL-TRADE_ID = * IT_ACCOUNTGL-VAL_AREA = * IT_ACCOUNTGL-VAL_TYPE = * IT_ACCOUNTGL-OBJ_TYP_P = * IT_ACCOUNTGL-OBJ_KEY_P = * IT_ACCOUNTGL-OBJ_POS_P = * IT_ACCOUNTGL-SERIAL_NO = * IT_ACCOUNTGL-PART_ACCT = * IT_ACCOUNTGL-MVT_IND = * IT_ACCOUNTGL-ITEM_CAT = * IT_ACCOUNTGL-REVAL_IND = * IT_ACCOUNTGL-MATL_TYPE = * IT_ACCOUNTGL-DIVISION = * IT_ACCOUNTGL-GROSS_WT = * IT_ACCOUNTGL-UNIT_OF_WT = * IT_ACCOUNTGL-UNIT_OF_WT_ISO = * IT_ACCOUNTGL-VOLUME = * IT_ACCOUNTGL-VOLUMEUNIT = * IT_ACCOUNTGL-VOLUMEUNIT_ISO = * IT_ACCOUNTGL-ENTRY_QNT = * IT_ACCOUNTGL-ENTRY_UOM = * IT_ACCOUNTGL-ENTRY_UOM_ISO = * IT_ACCOUNTGL-ACTTYPE = * IT_ACCOUNTGL-CO_BUSPROC = APPEND it_accountgl. it_currencyamount-itemno_acc = 1. it_currencyamount-curr_type = '00'. it_currencyamount-currency = 'USD'. * IT_CURRENCYAMOUNT-CURRENCY_ISO = it_currencyamount-amt_doccur = 100. * IT_CURRENCYAMOUNT-EXCH_RATE = 2. * IT_CURRENCYAMOUNT-AMT_BASE = * IT_CURRENCYAMOUNT-DISC_BASE = it_currencyamount-exch_rate_v = '0.5'. APPEND it_currencyamount. * fill GL (line 2) it_accountgl-itemno_acc = 2. it_accountgl-gl_account = '0000400000'. * IT_ACCOUNTGL-COMP_CODE = * IT_ACCOUNTGL-PSTNG_DATE = * IT_ACCOUNTGL-DOC_TYPE = * IT_ACCOUNTGL-AC_DOC_NO = * IT_ACCOUNTGL-FISC_YEAR = * IT_ACCOUNTGL-FIS_PERIOD = * IT_ACCOUNTGL-LOG_PROC = * IT_ACCOUNTGL-STAT_CON = * IT_ACCOUNTGL-REF_KEY_1 = * IT_ACCOUNTGL-REF_KEY_2 = * IT_ACCOUNTGL-REF_KEY_3 = * IT_ACCOUNTGL-ACCT_KEY = * IT_ACCOUNTGL-ACCT_TYPE = * IT_ACCOUNTGL-CUSTOMER = * IT_ACCOUNTGL-VENDOR_NO = it_accountgl-item_text = 'GL BAPI Test'. * IT_ACCOUNTGL-BUS_AREA = it_accountgl-costcenter = 'KOSTL 1'. * IT_ACCOUNTGL-PO_PR_QNT = * IT_ACCOUNTGL-PO_PR_UOM = * IT_ACCOUNTGL-PO_PR_UOM_ISO = * IT_ACCOUNTGL-ORDERID = * IT_ACCOUNTGL-ASSET_NO = * IT_ACCOUNTGL-SUB_NUMBER = * IT_ACCOUNTGL-ASVAL_DATE = * IT_ACCOUNTGL-MATERIAL = * IT_ACCOUNTGL-QUANTITY = * IT_ACCOUNTGL-BASE_UOM = * IT_ACCOUNTGL-BASE_UOM_ISO = * IT_ACCOUNTGL-PLANT = * IT_ACCOUNTGL-TR_PART_BA = * IT_ACCOUNTGL-ORIG_GROUP = * IT_ACCOUNTGL-ORIG_MAT = * IT_ACCOUNTGL-COST_OBJ = * IT_ACCOUNTGL-PROFIT_CTR = * IT_ACCOUNTGL-PART_PRCTR = * IT_ACCOUNTGL-WBS_ELEMENT = * IT_ACCOUNTGL-NETWORK = * IT_ACCOUNTGL-ROUTING_NO = * IT_ACCOUNTGL-ORDER_ITNO = * IT_ACCOUNTGL-CMMT_ITEM = * IT_ACCOUNTGL-FUNDS_CTR = * IT_ACCOUNTGL-FUND = * IT_ACCOUNTGL-SALES_ORD = * IT_ACCOUNTGL-S_ORD_ITEM = * IT_ACCOUNTGL-TRADE_ID = * IT_ACCOUNTGL-VAL_AREA = * IT_ACCOUNTGL-VAL_TYPE = * IT_ACCOUNTGL-OBJ_TYP_P = * IT_ACCOUNTGL-OBJ_KEY_P = * IT_ACCOUNTGL-OBJ_POS_P = * IT_ACCOUNTGL-SERIAL_NO = * IT_ACCOUNTGL-PART_ACCT = * IT_ACCOUNTGL-MVT_IND = * IT_ACCOUNTGL-ITEM_CAT = * IT_ACCOUNTGL-REVAL_IND = * IT_ACCOUNTGL-MATL_TYPE = * IT_ACCOUNTGL-DIVISION = * IT_ACCOUNTGL-GROSS_WT = * IT_ACCOUNTGL-UNIT_OF_WT = * IT_ACCOUNTGL-UNIT_OF_WT_ISO = * IT_ACCOUNTGL-VOLUME = * IT_ACCOUNTGL-VOLUMEUNIT = * IT_ACCOUNTGL-VOLUMEUNIT_ISO = * IT_ACCOUNTGL-ENTRY_QNT = * IT_ACCOUNTGL-ENTRY_UOM = * IT_ACCOUNTGL-ENTRY_UOM_ISO = * IT_ACCOUNTGL-ACTTYPE = * IT_ACCOUNTGL-CO_BUSPROC = APPEND it_accountgl. it_currencyamount-itemno_acc = 2. it_currencyamount-curr_type = '00'. it_currencyamount-currency = 'USD'. * IT_CURRENCYAMOUNT-CURRENCY_ISO = it_currencyamount-amt_doccur = -100. * IT_CURRENCYAMOUNT-EXCH_RATE = 2. * IT_CURRENCYAMOUNT-AMT_BASE = * IT_CURRENCYAMOUNT-DISC_BASE = it_currencyamount-exch_rate_v = '0.5'. APPEND it_currencyamount. ENDFORM. " fill_internal_tables *---------------------------------------------------------------------* * Form Show_messages *---------------------------------------------------------------------* FORM show_messages. IF it_return[] IS INITIAL. WRITE: / 'no messages'. ELSE. SKIP 1. LOOP AT it_return. WRITE: / it_return-type, (2) it_return-id, it_return-number, (80) it_return-message, * IT_RETURN-LOG_NO * IT_RETURN-LOG_MSG_NO * IT_RETURN-MESSAGE_V1 * IT_RETURN-MESSAGE_V2 * IT_RETURN-MESSAGE_V3 * IT_RETURN-MESSAGE_V4 (20) it_return-parameter, (3) it_return-row, it_return-field. * IT_RETURN-SYSTEM ENDLOOP. ENDIF. ULINE. ENDFORM. " Show_messages
ABAP Programlar
SAP Chain
SAP NetWeaver
ticket sistemimize katılın ve ücretsiz
10 adam gün kazanın >>
 Ana Sayfa  |  ABAP  |  FI  |  CO  |  MM  |  SD  |  PP  |  QM  |  HR  |  BW 
ykomut@gmail.com