Skip to Content
Author's profile photo Denis Skuridin

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'
        bukrs                = IS_EKKO-bukrs
        component            = 'IN'
        component_not_active = 1
        others               = 2.
    if sy-subrc = 0.
      call method cl_exithandler=>get_instance
          exit_name              = 'ME_CIN_MM06EFKO'
          null_instance_accepted = 'X'
          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
            flt_val = conv #( iv_ctry )
            y_ekpo  = ls_ekpo.
* GST India ---------------------------------------------------------------*
      call function 'J_1IG_DATE_CHECK'
          ex_gst_rele = lv_gst_rele.
      if lv_gst_rele eq abap_true.
        call function 'J_1IG_PASS_EKKO_EKPO'
            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 ).

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo VN Gadgil
      VN Gadgil

      Dear Mr. Denis,

      Thanks for the post. We are also facing the same issue in Po printing program. The FM is not showing the result but when we click on po tax button then in our driver program the FM calculate_tax_item gives the correct result. As you have said do we have to mention the said lines before we call the FM. Please give us more details about the solution. Your research has given us very valuable info.

      Author's profile photo Denis Skuridin
      Denis Skuridin
      Blog Post Author


      yes, these lines should be placed before FM call.

      Author's profile photo Thomas Blasche
      Thomas Blasche

      Thanks a lot for this.

      Two remarks to your coding:

      DATA:       iv_ctry  TYPE intca. " it is just t005-intca
          MOVE-CORRESPONDING<fs>    TO ls_ekpo, " or just what you have for ekpo
                              is_ekko TO ls_ekko. " you have twice ls_ekpo
      SELECT SINGLE intca FROM t005 INTO iv_ctry WHERE land1 = 'IN'.
      Author's profile photo Denis Skuridin
      Denis Skuridin
      Blog Post Author

      Glad someone found this helpful after 5 years. 🙂