1. 程式人生 > >關於憑證過賬及沖銷BAPI

關於憑證過賬及沖銷BAPI

**1.獲取擡頭引數,
documentheader

**2.專案引數
accountgl = lt_acgl"G/L account item
accountreceivable = lt_acar"Customer Item
accountpayable = lt_acap"Vendor Item
currencyamount = lt_aamt"貨幣金額

*返回引數
return = lt_retn.

**3.BAPI 憑證過賬,

**憑證資料檢查-防止跳號
CLEAR: ls_retn,lt_retn[].
CALL FUNCTION ‘BAPI_ACC_DOCUMENT_CHECK’
EXPORTING
documentheader = ls_ache
TABLES
accountgl = lt_acgl
accountreceivable = lt_acar
accountpayable = lt_acap
return = lt_retn.
READ TABLE lt_retn INTO ls_retn WITH KEY type = ‘E’.
IF SY-SUBRC = 0.
LOOP AT lt_retn INTO ls_retn WHERE type = gc_e OR type = gc_a.
CHECK ls_retn-id <> ‘RW’.
MESSAGE ID ls_retn-id
TYPE ls_retn-type
NUMBER ls_retn-number
WITH ls_retn-message_v1
ls_retn-message_v2
ls_retn-message_v3
ls_retn-message_v4
INTO gs_out-message.
EXIT.
ENDLOOP.

ELSE.
CLEAR: ls_retn,lt_retn[].
CALL FUNCTION ‘BAPI_ACC_DOCUMENT_POST’
EXPORTING
documentheader = ls_ache
IMPORTING
obj_key = lv_key
TABLES
accountgl = lt_acgl"G/L account item
accountreceivable = lt_acar"Customer Item
accountpayable = lt_acap"Vendor Item
currencyamount = lt_aamt"貨幣金額
return = lt_retn.
READ TABLE lt_retn INTO ls_retn WITH KEY type = E.
IF SY-SUBRC EQ 0.
CALL FUNCTION ‘BAPI_TRANSACTION_COMMIT’.
MESSAGE = 處理成功
BELNR = lv_key+0(10).
抓取返回欄位.

ELSE.
CALL FUNCTION ‘BAPI_TRANSACTION_ROLLBACK’.
MESSAGE = 處理出錯
BELNR =
抓取錯誤訊息.

ENDIF.

ENDIF.

BAPI_ACC_DOCUMENT_POST

FG:ACC9 Accounting:bapis
short text Accounting posting

import- 輸入引數 短文字

DOCUMENTHEADER LIKE BAPIACHE09 Header
CUSTOMERCPD LIKE BAPIACPA09 One-time customer
CONTRACTHEADER LIKE BAPIACCAHD 、、、

TABLES:
ACCOUNTGL LIKE BAPIACGL09 G/L account item
ACCOUNTRECEIVABLE LIKE BAPIACAR09 Customer Item
ACCOUNTPAYABLE LIKE BAPIACAP09 Vendor Item
ACCOUNTTAX LIKE BAPIACTX09 Tax item
CURRENCYAMOUNT LIKE BAPIACCR09 Currency Items
CRITERIA LIKE BAPIACKEC9 CO-PA Account Assignment Characteristics
VALUEFIELD LIKE BAPIACKEV9 CO-PA Account Assignment Value Fields
EXTENSION1 LIKE BAPIACEXTC Container for ‘Customer Exit’ Parameter
RETURN LIKE BAPIRET2 Return parameter
PAYMENTCARD LIKE BAPIACPC09 Payment Card Information
CONTRACTITEM LIKE BAPIACCAIT Additional Contract Accounts Recieviable and Payable Document Line Item
EXTENSION2 LIKE BAPIPAREX Reference Structure for BAPI Parameters EXTENSIONIN/EXTENSIONOUT
REALESTATE LIKE BAPIACRE09 Real Estate Account Assignment Data
ACCOUNTWT LIKE BAPIACWT09 Withholding tax information for FI Interface

gs_out-sqdno

e_awtyp = ‘BKPFF’.
e_awkey = ‘$’.
CALL FUNCTION ‘OWN_LOGICAL_SYSTEM_GET’
IMPORTING
own_logical_system = log_sys
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc IS INITIAL.
e_awsys = log_sys.
ENDIF.

LOGICAL_SYSTEM_GET.

LOG_SYS CDRCLNT710
DOCUMENT_HEADER-BUS_ACT RFBU

  • OBJ_TYPE, OBJ_KEY und USERNAME

GS_AW-AWTYP BKPFF
GS_AW-AWREF $
GS_BAPI_ACCHD-USERNAME C_XIANGC

BAPI_ACC_DOCUMENT_REV_CHECK

Function module BAPI_ACC_DOCUMENT_REV_POST

FG:ACC9 Accounting: BAPIs
Short text Accounting: Post Reversal