SAP ABAP 获取PO item 中invoice页签下的Tax Code后按钮TAXES里的金额
最近收到以下需求,将PO item Invoice 页签中 点击Taxes按钮后 会跳出一个界面,将CN TY 为 JI开头的对应的金额取出来。
当时以为很简单有konv表可以找出来,结果KONV表找出来的是和 condition 页签相关的,所以这个方法PASS。给大家避坑了!
最后选择使用 函数 这个方法好使!
代码如下:
DATA:ls_taxcom TYPE taxcom,
lt_xkomv TYPE STANDARD TABLE OF komv,
gt_komv TYPE TABLE OF komv.
ls_taxcom-bukrs = ekko-bukrs.
ls_taxcom-budat = ekko-bedat.
ls_taxcom-bldat = ekko-bedat.
ls_taxcom-kposn = ekpo-ebelp.
ls_taxcom-mwskz = ekpo-mwskz.
ls_taxcom-txjcd = ekpo-txjcd.
ls_taxcom-wrbtr = ekpo-netpr.
ls_taxcom-shkzg = 'H'.
ls_taxcom-xmwst = 'X'.
ls_taxcom-lifnr = ekko-lifnr.
ls_taxcom-land1 = ekko-lands.
ls_taxcom-ekorg = ekko-ekorg.
ls_taxcom-hwaer = ekko-waers.
ls_taxcom-llief = ekko-llief.
ls_taxcom-bldat = ekko-bedat.
ls_taxcom-matnr = ekpo-matnr.
ls_taxcom-werks = ekpo-werks.
ls_taxcom-bwtar = ekpo-bwtar.
ls_taxcom-matkl = ekpo-matkl.
ls_taxcom-meins = ekpo-meins.
ls_taxcom-mglme = ekpo-menge.
ls_taxcom-mtart = ekpo-mtart.
*注意以下三行十分重要,会导致之后function 能否将内容全部都抓到
DATA lo_gst_service_purchasing TYPE REF TO j_1icl_gst_service_purchasing.
lo_gst_service_purchasing = j_1icl_gst_service_purchasing=>get_instance( ).
lo_gst_service_purchasing->extend_mm06efko_kond_taxes( ekpo ).
************************************************************************
CALL FUNCTION 'CALCULATE_TAX_ITEM'
EXPORTING
i_taxcom = ls_taxcom
TABLES
t_xkomv = lt_xkomv
EXCEPTIONS
mwskz_not_defined = 1
mwskz_not_found = 2
mwskz_not_valid = 3
steuerbetrag_falsch = 4
country_not_found = 5
txjcd_not_valid = 6
OTHERS = 7.
IF sy-subrc = 0.
* Implement suitable error handling here
APPEND LINES OF lt_xkomv[] TO gt_komv[].
ENDIF.