首页 > 代码库 > 查询PO的预付款剩余金额
查询PO的预付款剩余金额
FUNCTION zrfc_mm016. *"---------------------------------------------------------------------- *"*"Local interface: *" IMPORTING *" VALUE(CALLNO) TYPE ZCALLNO *" VALUE(BUKRS) LIKE BSIK-BUKRS *" VALUE(GJAHR) LIKE BSIK-GJAHR *" EXPORTING *" VALUE(FLAG) LIKE BAPIRET2-TYPE *" VALUE(MESSAGE) LIKE BAPIRET2-MESSAGE *" TABLES *" ZRS_EBELN STRUCTURE ZRS_EBELN OPTIONAL *" ZRS_LIFNR STRUCTURE ZRS_LIFNR OPTIONAL *" ZYFYE STRUCTURE ZYFYE OPTIONAL *"---------------------------------------------------------------------- TYPES:BEGIN OF ty_regup, lifnr TYPE regup-lifnr, "供应商 bukrs TYPE regup-bukrs, "公司代码 gjahr TYPE regup-gjahr, "年度 blart TYPE regup-blart, "凭证类型 xref3 TYPE regup-xref3, "参考码3 dmbtr TYPE regup-dmbtr, "金额 wmwst TYPE regup-wmwst, "税额 zzbelnr TYPE regup-zzbelnr, "付款成功标识 END OF ty_regup. DATA:lt_regup TYPE TABLE OF ty_regup, lt_regup_y TYPE TABLE OF ty_regup, lt_regup1 TYPE TABLE OF ty_regup, lt_regup_y1 TYPE TABLE OF ty_regup, ls_regup TYPE ty_regup, ls_regup_y TYPE ty_regup, l_syed TYPE regup-dmbtr. "剩余额度 DATA:dmbtr(18), lv_datano TYPE i. SELECT lifnr bukrs gjahr blart xref3 dmbtr wmwst zzbelnr INTO TABLE lt_regup FROM regup WHERE xvorl = ‘X‘ AND zbukr = bukrs AND lifnr IN zrs_lifnr AND bukrs = bukrs AND gjahr = gjahr AND xref3 IN zrs_ebeln. DELETE lt_regup WHERE zzbelnr = ‘‘. "删除支付不成功的凭证 SORT lt_regup BY lifnr bukrs blart xref3. lt_regup_y = lt_regup. DELETE lt_regup WHERE blart = ‘KA‘. "应付款额度 DELETE lt_regup_y WHERE blart NE ‘KA‘. "预付款额度 *--汇总应付金额 LOOP AT lt_regup INTO ls_regup. CLEAR:ls_regup-blart,ls_regup-zzbelnr. COLLECT ls_regup INTO lt_regup1. ENDLOOP. *--汇总预付金额 LOOP AT lt_regup_y INTO ls_regup_y. CLEAR:ls_regup_y-blart,ls_regup_y-zzbelnr. COLLECT ls_regup_y INTO lt_regup_y1. ENDLOOP. LOOP AT lt_regup_y1 INTO ls_regup_y. zyfye-bukrs = ls_regup_y-bukrs. "公司 zyfye-gjahr = ls_regup_y-gjahr. "年度 zyfye-lifnr = ls_regup_y-lifnr. "供应商 zyfye-ebeln = ls_regup_y-xref3. "PO号(参考码3) *--预付额度 = 预付额度 + 预付税额 l_syed = ls_regup_y-dmbtr + ls_regup_y-wmwst. READ TABLE lt_regup1 INTO ls_regup WITH KEY xref3 = ls_regup_y-xref3. *--剩余额度 = 预付额度 - 应付额度 zyfye-dmbtr = l_syed - ls_regup-dmbtr. APPEND zyfye. CLEAR:l_syed,ls_regup,ls_regup_y,zyfye. ENDLOOP. IF zyfye[] IS NOT INITIAL. flag = ‘S‘. ELSE. flag = ‘E‘. message = ‘没有数据‘. ENDIF. *---记录日志 CLEAR:gt_log,gs_log. LOOP AT zyfye. dmbtr = zyfye-dmbtr. lv_datano = lv_datano + 1. gs_log-name = ‘ZRFC_MM016‘. gs_log-cdate = sy-datum. GET TIME. gs_log-ctime = sy-uzeit. gs_log-callno = callno. gs_log-datano = lv_datano. gs_log-flag = flag. gs_log-log = message. CONCATENATE zrs_ebeln-sign zrs_ebeln-option zrs_ebeln-low zrs_ebeln-high zrs_lifnr-sign zrs_lifnr-option zrs_lifnr-low zrs_lifnr-high zyfye-bukrs zyfye-gjahr zyfye-lifnr zyfye-ebeln dmbtr INTO gs_log-content SEPARATED BY ‘|‘. CONDENSE gs_log-content NO-GAPS. gs_log-length = STRLEN( gs_log-content ). APPEND gs_log TO gt_log. ENDLOOP. IF gt_log IS NOT INITIAL. INSERT zrfc_mm01out_log FROM TABLE gt_log. IF sy-subrc = 0. COMMIT WORK. ENDIF. ENDIF. ENDFUNCTION.
查询PO的预付款剩余金额
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。