F-02 创建财务凭证BAPI

Posted Rainystuday

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了F-02 创建财务凭证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



5001-5004
yj50
lcv5000000

yj51
5101
5102
lcv5100000

 

以上是关于F-02 创建财务凭证BAPI的主要内容,如果未能解决你的问题,请参考以下文章

会计凭证原因代码增强

201704 创建财务凭证函数

试着利用BAPI 寻找F-59创建凭证的函数

[问题解决]创建预制发票(BAPI_INCOMINGINVOICE_PARK)时报错”采购凭证的帐户设置00不存在”

疑问SD更新凭证流

SAP 系统财务问题,财务账和成本账不平,如何处理?