SAP提供的创建会计凭证的bapi 是处理不了W\S类型的凭证。我们可以在函数FI_DOCUMENT_CHECK 这块,把他的校验去掉,跳过去
Char_w改为 U
CHAR_W值改回原值:
函数ZFI_ZUMSK_WS:
标准程序LFACIF5D增加增强点,对BSED表复制,并清除函数中的全局变量
程序:
LFACIF5D
截图:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
DATA:lt_bsed TYPE TABLE OF bsed, ls_bsed LIKE LINE OF lt_bsed, lv_subrc TYPE subrc. CALL FUNCTION 'ZFI_ZUMSK_WS' EXPORTING iv_step = '02' IMPORTING ex_subrc = lv_subrc TABLES t_bsed = lt_bsed. IF lv_subrc = 0. LOOP AT xbseg WHERE umsks = 'W' OR umsks = 'S'. READ TABLE lt_bsed INTO ls_bsed WITH KEY buzei = xbseg-buzei. IF sy-subrc = 0. MOVE-CORRESPONDING ls_bsed TO xbsed. MOVE-CORRESPONDING xbseg TO xbsed. APPEND xbsed. ENDIF. CLEAR:ls_bsed. ENDLOOP. CALL FUNCTION 'ZFI_ZUMSK_WS' EXPORTING iv_step = '03'. ENDIF. |
最后是在调用bapi:BAPI_ACC_DOCUMENT_CREATE 的时候
判断是否有特别总账W/S的数据,一定要给BSED数据,不然冲销的时候过不去
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
********************************************************************** *客户供商票据类增强处理 *FM :FI_DOCUMENT_CHECK *PROG: LFACIF5D IF ( ls_item-zumsk = 'W' OR ls_item-zumsk = 'S' ) AND ( ls_tbsl-koart = 'D' OR ls_tbsl-koart = 'K' ) . PERFORM frm_set_zumsk_ws USING ls_item lv_itemno ls_tbsl-koart ls_t001. ENDIF. ********************************************************************* *&---------------------------------------------------------------------* *& Form FRM_SET_ZUMSK_WS *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_LS_ITEM text * -->P_LV_ITEMNO text *----------------------------------------------------------------------* FORM frm_set_zumsk_ws USING ps_item TYPE zitfi_s_items pv_itemno TYPE posnr_acc pv_koart TYPE koart ps_t001 TYPE t001. DATA:lt_bsed TYPE TABLE OF bsed, ls_bsed LIKE LINE OF lt_bsed, ls_kna1 TYPE kna1, lv_kunnr TYPE kunnr, ls_lfa1 TYPE lfa1, lv_lifnr TYPE lifnr, ls_adrc TYPE adrc, lv_umskz TYPE umskz. ls_bsed-buzei = pv_itemno. * xsiwe "标记:即期汇票 * wstat "汇票状态 * wevwv "计划用途 * wdate "签发日期 * xaktz "标记:汇票已接收 * wgbkz "拒付汇票标志 IF pv_koart = 'D'. ls_bsed-wname = ps_t001-butxt. "汇票收款人 T001-BUTXT ls_bsed-wort1 = ps_t001-ort01. "汇票出票人的城市 T001-ORT01 SELECT SINGLE region INTO ls_bsed-regio "地区 adrc-region FROM adrc WHERE addrnumber = ps_t001-adrnr. lv_kunnr = ps_item-hkont. SELECT SINGLE * INTO ls_kna1 FROM kna1 WHERE kunnr = lv_kunnr. IF sy-subrc = 0. ls_bsed-wbzog = ls_kna1-name1. "汇票付款人 KNA1-NAME1 ls_bsed-wort2 = ls_kna1-ort01. "汇票受票人的城市 kna1-ort01 ENDIF. ENDIF. IF pv_koart = 'K'. lv_lifnr = ps_item-hkont. SELECT SINGLE * INTO ls_lfa1 FROM lfa1 WHERE lifnr = lv_lifnr. IF sy-subrc = 0. ls_bsed-wname = ls_lfa1-name1. "汇票收款人 lfa1-name1 ls_bsed-wort1 = ls_lfa1-ort01. "汇票出票人的城市 lfa1-ORT01 SELECT SINGLE region INTO ls_bsed-regio "地区 adrc-region FROM adrc WHERE addrnumber = ls_lfa1-adrnr. ENDIF. ls_bsed-wbzog = ps_t001-butxt. "汇票付款人 T001-BUTXT ls_bsed-wort2 = ps_t001-ort01. "汇票受票人的城市 T001-ORT01 ENDIF. * WBANK "可以支付汇票的银行地址(国内) * WLZBP "国家中央银行所在地 lv_umskz = ps_item-zumsk. *全局函数传内表 LFACIF5D CALL FUNCTION 'ZFI_ZUMSK_WS' EXPORTING is_bsed = ls_bsed iv_zumsk = lv_umskz iv_step = '01'. "写入 ENDFORM. |