Calculate taxes using FM CALCULATE_TAX_ITEM with country specifics
If you need to output taxes from Purchase Order you should use FM CALCULATE_TAX_ITEM to achieve this. It works fine and provides necessary infos, but has 1 feature: you should firstly open tax screen by clicking on the button and then run FM. Looks like some global variables should be prefilled before tax calculation.
I faced this problem while working on PO print form for India. After some googling I found out, that Brazil also suffers from this problem. I have no information whether this is relevant for other countries.
For Brazil the solution is suggested in this thread.
Bur for India I haven’t found anything definitely working.
So I started searching and found my solution in subroutine KOND_TAXES of program SAPLMEPO.
I copied and adapted lines 219-297, after that FM bring correct results.
If you do that while printing PO you have to use local structures of EKKO/EKPO types, as printing structures are of MMPUR_PRINT_EKKO/MMPUR_PRINT_EKPO types.
data: lv_gst_rele type char1, lo_gst_service_purchasing type ref to j_1icl_gst_service_purchasing, lo_copypo type ref to if_ex_me_cin_mm06efko, ls_ekpo type ekpo, ls_ekko type ekko. call function 'J_1BSA_COMPONENT_ACTIVE' exporting bukrs = IS_EKKO-bukrs component = 'IN' exceptions component_not_active = 1 others = 2. if sy-subrc = 0. call method cl_exithandler=>get_instance exporting exit_name = 'ME_CIN_MM06EFKO' null_instance_accepted = 'X' changing instance = lo_copypo. if not lo_copypo is initial. move-corresponding: is_ekpo to ls_ekpo, is_ekpo to ls_ekpo. call method lo_copypo->me_cin_copy_po_data exporting flt_val = conv #( iv_ctry ) y_ekpo = ls_ekpo. endif. * GST India ---------------------------------------------------------------* call function 'J_1IG_DATE_CHECK' importing ex_gst_rele = lv_gst_rele. if lv_gst_rele eq abap_true. call function 'J_1IG_PASS_EKKO_EKPO' exporting im_ekko = ls_ekko im_ekpo = ls_ekpo. lo_gst_service_purchasing = j_1icl_gst_service_purchasing=>get_instance( ). lo_gst_service_purchasing->extend_mm06efko_kond_taxes( ls_ekpo ). endif. endif.