关于凭证过账及冲销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

你可能感兴趣的:(SAP)