• 通用清账程序


    REPORT ZFI0999_TEST.

    *-----------------------------------------------------------------------------
    * BAPI_ACC_DOCUMENT_POST? 部分清账使用凭证接口,行项目的填上
    * REBZG 发票参考号
    * REBZJ 年度
    * REBZZ 行项目
    * 把这三个字段放到 extension2 内
    *-----------------------------------------------------------------------------
    * 清账数据 变量申明
    *-----------------------------------------------------------------------------
    DATA: LS_BSEG TYPE BSEG.

    DATA: LT_BLNTAB TYPE STANDARD TABLE OF BLNTAB WITH HEADER LINE,
    LT_FTCLEAR TYPE STANDARD TABLE OF FTCLEAR WITH HEADER LINE,
    LT_FTPOST TYPE STANDARD TABLE OF FTPOST WITH HEADER LINE,
    LT_FTTAX TYPE STANDARD TABLE OF FTTAX WITH HEADER LINE.

    DATA: E_MSGID LIKE SY-MSGID,
    E_MSGNO LIKE SY-MSGNO,
    E_MSGTY LIKE SY-MSGTY,
    E_MSGV1 LIKE SY-MSGV1,
    E_MSGV2 LIKE SY-MSGV2,
    E_MSGV3 LIKE SY-MSGV3,
    E_MSGV4 LIKE SY-MSGV4,
    E_SUBRC LIKE SY-SUBRC.

    *--------------------------------
    * 清账参数整理
    *--------------------------------

    * 抬头信息
    PERFORM FULL_FTPOST USING 'K' '1' 'BKPF-BLDAT' '20170609'. "凭证日期
    PERFORM FULL_FTPOST USING 'K' '1' 'BKPF-BLART' 'DZ'. "凭证类型
    PERFORM FULL_FTPOST USING 'K' '1' 'BKPF-BUKRS' '1000'. "公司代码
    PERFORM FULL_FTPOST USING 'K' '1' 'BKPF-BUDAT' '20170609'. "过账日期
    PERFORM FULL_FTPOST USING 'K' '1' 'BKPF-WAERS' 'CNY'. "货币/汇率
    PERFORM FULL_FTPOST USING 'K' '1' 'BKPF-BKTXT' '测试清账'. "凭证抬头文本

    * 行项目信息 第一个行项目 银行信息
    PERFORM FULL_FTPOST USING 'P' '1' 'BSEG-BSCHL' '40'. "记账码
    PERFORM FULL_FTPOST USING 'P' '1' 'BSEG-HKONT' '0010020107'. "科目
    PERFORM FULL_FTPOST USING 'P' '1' 'BSEG-WRBTR' '12000'. "清账金额
    PERFORM FULL_FTPOST USING 'P' '1' 'BSEG-RSTGR' '101'. "原因代码
    PERFORM FULL_FTPOST USING 'P' '1' 'COBL-PRCTR' '0000001000'. "利润中心


    * 行项目信息 第2 ~ N 个行项目 清账信息

    * 行项目2
    PERFORM FULL_FTPOST USING 'P' '2' 'BSEG-BSCHL' '01'. "记账码
    PERFORM FULL_FTPOST USING 'P' '2' 'BSEG-HKONT' '0001000006'. "客户编码
    PERFORM FULL_FTPOST USING 'P' '2' 'BSEG-WRBTR' '6547.01'. "剩余金额

    * 被清账参数整理
    * 客户编码 / 凭证号 / 公司代码 / 会计年度 / 行项目号
    PERFORM FULL_FTCLEAR USING '0001000006' '0100000222' '1000' '2016' '001'.

    * 行项目3
    PERFORM FULL_FTPOST USING 'P' '3' 'BSEG-BSCHL' '01'. "记账码
    PERFORM FULL_FTPOST USING 'P' '3' 'BSEG-HKONT' '0001000006'. "客户编码
    PERFORM FULL_FTPOST USING 'P' '3' 'BSEG-WRBTR' '10000'. "剩余金额

    * 被清账参数整理
    * 客户编码 / 凭证号 / 公司代码 / 会计年度 / 行项目号
    PERFORM FULL_FTCLEAR USING '0001000006' '0100000545' '1000' '2016' '001'.


    *------------------------------------------------------
    * 开始清账
    *------------------------------------------------------
    CALL FUNCTION 'POSTING_INTERFACE_START'
    EXPORTING
    I_FUNCTION = 'C'
    I_MODE = 'A' "N后台不可见,A前台可见
    I_UPDATE = 'S'
    I_USER = SY-UNAME
    EXCEPTIONS
    CLIENT_INCORRECT = 1
    FUNCTION_INVALID = 2
    GROUP_NAME_MISSING = 3
    MODE_INVALID = 4
    UPDATE_INVALID = 5
    OTHERS = 6.

    IF SY-SUBRC <> 0.
    * Implement suitable error handling here
    ENDIF.

    *----清账类型--------------------------------
    * AUSGZAHL 付款 - 对供应商清账
    * EINGZAHL 收款 - 对客户清账
    * GUTSCHRI 贷方凭证 - 对贷项凭证清账
    * UMBUCHNG 转帐并清帐 -
    *-------------------------------------------

    CALL FUNCTION 'POSTING_INTERFACE_CLEARING'
    EXPORTING
    I_AUGLV = 'EINGZAHL' " 清账类型
    I_TCODE = 'FB05' " 清账事物
    I_SGFUNCT = 'C' " C 表示:直接过账
    IMPORTING
    E_MSGID = E_MSGID
    E_MSGNO = E_MSGNO
    E_MSGTY = E_MSGTY
    E_MSGV1 = E_MSGV1
    E_MSGV2 = E_MSGV2
    E_MSGV3 = E_MSGV3
    E_MSGV4 = E_MSGV4
    E_SUBRC = E_SUBRC
    TABLES
    T_BLNTAB = LT_BLNTAB
    T_FTCLEAR = LT_FTCLEAR
    T_FTPOST = LT_FTPOST
    T_FTTAX = LT_FTTAX
    EXCEPTIONS
    CLEARING_PROCEDURE_INVALID = 1
    CLEARING_PROCEDURE_MISSING = 2
    TABLE_T041A_EMPTY = 3
    TRANSACTION_CODE_INVALID = 4
    AMOUNT_FORMAT_ERROR = 5
    TOO_MANY_LINE_ITEMS = 6
    COMPANY_CODE_INVALID = 7
    SCREEN_NOT_FOUND = 8
    NO_AUTHORIZATION = 9
    OTHERS = 10.

    IF SY-SUBRC <> 0.
    RETURN.
    ENDIF.

    *------------------------------------------------------
    * 结束清账
    *------------------------------------------------------
    CALL FUNCTION 'POSTING_INTERFACE_END'
    EXPORTING
    I_BDCIMMED = 'X'
    EXCEPTIONS
    SESSION_NOT_PROCESSABLE = 1
    OTHERS = 2.

    IF SY-SUBRC <> 0.
    RETURN.
    ENDIF.


    *------------------------------------------------------
    * 填充清账参数
    *------------------------------------------------------
    FORM FULL_FTPOST USING P_STYPE TYPE STYPE_PI
    P_COUNT TYPE COUNT_PI
    P_FNAM TYPE BDC_FNAM
    P_FVAL TYPE BDC_FVAL.

    LT_FTPOST-STYPE = P_STYPE.
    LT_FTPOST-COUNT = P_COUNT.
    LT_FTPOST-FNAM = P_FNAM .
    LT_FTPOST-FVAL = P_FVAL .

    APPEND LT_FTPOST.
    CLEAR: LT_FTPOST.

    ENDFORM.

    *------------------------------------------------------
    * 填充被清账参数
    *------------------------------------------------------
    FORM FULL_FTCLEAR USING P_AGKON TYPE FTCLEAR-AGKON
    P_BELNR TYPE BSEG-BELNR
    P_BUKRS TYPE BSEG-BUKRS
    P_GJAHR TYPE BSEG-GJAHR
    P_BUZEI TYPE BSEG-BUZEI.

    SELECT SINGLE * INTO LS_BSEG FROM BSEG WHERE BELNR = P_BELNR
    AND BUKRS = P_BUKRS
    AND GJAHR = P_GJAHR
    AND BUZEI = P_BUZEI.

    LT_FTCLEAR-AGKOA = LS_BSEG-KOART. "科目类型
    LT_FTCLEAR-AGBUK = LS_BSEG-BUKRS. "公司编码
    LT_FTCLEAR-SELFD = 'BELNR'. "会计凭证编号
    LT_FTCLEAR-AGKON = P_AGKON. "客户编码

    IF LS_BSEG-UMSKZ IS INITIAL. "特殊总帐标识
    LT_FTCLEAR-XNOPS = 'X'.
    ELSE.
    LT_FTCLEAR-AGUMS = LS_BSEG-UMSKZ.
    ENDIF.

    CONCATENATE LS_BSEG-BELNR LS_BSEG-GJAHR LS_BSEG-BUZEI INTO LT_FTCLEAR-SELVON.

    APPEND LT_FTCLEAR.
    CLEAR: LT_FTCLEAR.

    ENDFORM.

  • 相关阅读:
    #动态规划 0-1背包问题空间复杂度优化
    #动态规划 0-1背包问题思路概述
    #动态规划 LeetCode 337 打家劫舍 III
    #动态规划 LeetCode 213 打家劫舍 II
    #动态规划 LeetCode 198 打家劫舍
    #动态规划 LeetCode 63 不同路径 II
    #动态规划 LeetCode 62 不同路径
    #动态规划 LeetCode 279 完全平方数
    #动态规划 LeetCode 343 整数拆分
    #动态规划 LeetCode 64 最小路径和
  • 原文地址:https://www.cnblogs.com/liu1838998131/p/15429196.html
Copyright © 2020-2023  润新知