清账相关事物代码: FB05
相关函数:POSTING_INTERFACE_START
POSTING_INTERFACE_CLEARING
DATA: LT_BLNTAB TYPE STANDARD TABLE OF BLNTAB.DATA: LS_BLNTAB TYPE BLNTAB.DATA: LT_FTCLEAR TYPE STANDARD TABLE OF FTCLEAR.DATA: LS_FTCLEAR TYPE FTCLEAR.DATA: LT_FTPOST TYPE STANDARD TABLE OF FTPOST.DATA: LS_FTPOST TYPE FTPOST.DATA: LT_FTTAX TYPE STANDARD TABLE OF FTTAX.DATA: LS_FTTAX TYPE FTTAX.DATA: LT_GROUP TYPE STANDARD TABLE OF TY_DATA.DATA: LS_GROUP TYPE TY_DATA.DATA: LV_MODE TYPE CHAR01.DATA: LV_BLART TYPE BLART.DATA: LV_SUBRC TYPE SY-SUBRC .DATA: LV_MESSAGE TYPE STRING.DEFINE POPULATE_FTPOST.CLEAR LS_FTPOST.LS_FTPOST-STYPE = &1.LS_FTPOST-COUNT = &2.LS_FTPOST-FNAM = &3.LS_FTPOST-FVAL = &4.APPEND LS_FTPOST TO LT_FTPOST.END-OF-DEFINITION.SORT LT_GROUP BY GROUP.DELETE ADJACENT DUPLICATES FROM LT_GROUP COMPARING GROUP.LOOP AT LT_GROUP INTO LS_GROUP.READ TABLE GT_DATA INTO GS_DATAWITH KEY GROUP = LS_GROUP-GROUPICON = ICON_RED_LIGHT.IF SY-SUBRC = 0.CONTINUE.ENDIF.CLEAR:LT_BLNTAB,LT_FTCLEAR,LT_FTPOST,LT_FTTAX,LV_MESSAGE.POPULATE_FTPOST: 'K' 1 'BKPF-BUKRS' LS_GROUP-BUKRS, "Company code'K' 1 'BKPF-BLART' 'DR', "凭证类型'K' 1 'BKPF-BLDAT' LS_GROUP-BUDAT, "凭证中的凭证日期'K' 1 'BKPF-BUDAT' LS_GROUP-BUDAT, "凭证中的过帐日期'K' 1 'BKPF-WAERS' LS_GROUP-WAERS. "货币码LOOP AT GT_DATA INTO GS_DATA WHERE BOX IS NOT INITIAL AND GROUP = LS_GROUP-GROUP.CLEAR LS_FTCLEAR.LS_FTCLEAR-AGKOA = 'D'.LS_FTCLEAR-AGUMS = 'D'.LS_FTCLEAR-AGKON = GS_DATA-KUNNR.LS_FTCLEAR-AGBUK = GS_DATA-BUKRS.LS_FTCLEAR-XNOPS = 'X'.LS_FTCLEAR-SELFD = 'SGTXT'.LS_FTCLEAR-SELVON = GS_DATA-SGTXT.APPEND LS_FTCLEAR TO LT_FTCLEAR.ENDLOOP.CALL FUNCTION 'POSTING_INTERFACE_START'EXPORTINGI_CLIENT = SY-MANDTI_FUNCTION = 'C'I_MODE = LV_MODEI_KEEP = 'X'I_UPDATE = 'S'I_USER = SY-UNAME."AUSGZAHL 付款
"EINGZAHL 收款
"GUTSCHRI 贷方凭证
"UMBUCHNG 转帐并清帐CALL FUNCTION 'POSTING_INTERFACE_CLEARING'EXPORTINGI_AUGLV = 'EINGZAHL' "具体选择参见上述参数说明I_TCODE = 'FB05'I_SGFUNCT = 'C'IMPORTINGE_MSGID = SY-MSGIDE_MSGNO = SY-MSGNOE_MSGTY = SY-MSGTYE_MSGV1 = SY-MSGV1E_MSGV2 = SY-MSGV2E_MSGV3 = SY-MSGV3E_MSGV4 = SY-MSGV4E_SUBRC = LV_SUBRCTABLEST_BLNTAB = LT_BLNTABT_FTCLEAR = LT_FTCLEART_FTPOST = LT_FTPOSTT_FTTAX = LT_FTTAXEXCEPTIONSCLEARING_PROCEDURE_INVALID = 1CLEARING_PROCEDURE_MISSING = 2TABLE_T041A_EMPTY = 3TRANSACTION_CODE_INVALID = 4AMOUNT_FORMAT_ERROR = 5TOO_MANY_LINE_ITEMS = 6COMPANY_CODE_INVALID = 7SCREEN_NOT_FOUND = 8NO_AUTHORIZATION = 9OTHERS = 10.IF SY-SUBRC <> 0 OR LT_BLNTAB IS INITIAL .
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.CALL FUNCTION 'MESSAGE_TEXT_BUILD'EXPORTINGMSGID = SY-MSGIDMSGNR = SY-MSGNOMSGV1 = SY-MSGV1MSGV2 = SY-MSGV2MSGV3 = SY-MSGV3MSGV4 = SY-MSGV4IMPORTINGMESSAGE_TEXT_OUTPUT = LV_MESSAGE.ENDIF.IF LT_BLNTAB IS NOT INITIAL AND LV_MESSAGE IS INITIAL .READ TABLE LT_BLNTAB INTO LS_BLNTAB INDEX 1.LOOP AT GT_DATA INTO GS_DATA WHERE BOX IS NOT INITIAL AND GROUP = LS_GROUP-GROUP..GS_DATA-BELNR1 = LS_BLNTAB-BELNR.GS_DATA-ICON = ICON_GREEN_LIGHT.MODIFY GT_DATA FROM GS_DATA.ENDLOOP.ELSE.LOOP AT GT_DATA INTO GS_DATA WHERE BOX IS NOT INITIAL AND GROUP = LS_GROUP-GROUP..GS_DATA-ICON = ICON_RED_LIGHT.GS_DATA-MSG = LV_MESSAGE.MODIFY GT_DATA FROM GS_DATA.ENDLOOP.ENDIF.CALL FUNCTION 'POSTING_INTERFACE_END'EXPORTINGI_BDCIMMED = 'X'EXCEPTIONSSESSION_NOT_PROCESSABLE = 1OTHERS = 2.ENDLOOP.