Skip to end of metadata
Go to start of metadata

--->  Introduction / Overview     Function Module to calculate TAX in Purchase Order- What is it?     

  This development is used for calculating tax amount based on Condition types. Generally when we create Purchase order, the tax amount is calculated based on tax code.

While creating Purchase order if we click on taxes, the tax detailed screen will appear (refer below screen shot), In which we can see Tax calculated based on condition type.  The tax field contains the sum of all the condition types .However in our development we need to calculate tax amount only for certain condition types which we could not find in any table, so for that we developed this Function module in which we would be getting all the condition types value separately.

--->  How this Function Module will work:

The Function Module requires Purchase order header details, item details and vendor details of Purchase Order .In purchase order, tax details are item specific. So if Purchase Order has multiple items, the function module should be in item loop.

The Table parameter has T_KONV parameter. These T_KONV parameters will populate with all condition type and amounts

The below screenshot is for TABLES parameters.

Write this code in source code

*Local Data declaration
DATA: my_taxcom TYPE j_1b_taxcom ,
      l_taxcom  TYPE taxcom ,
      l_wa_t001    TYPE t001,
      e_taxcom  TYPE taxcom ,
      l_wa_komv TYPE komv ,
      l_gv_amount TYPE netwr ,
      l_unitprice TYPE netwr,
      l_ipiamount TYPE netwr,
      l_total_ipi TYPE netwr,
      l_total  TYPE netwr  ,
      l_taxamount TYPE netwr.

                INTO l_wa_t001
                WHERE bukrs EQ i_ekko-bukrs.

* Fill tax fields relevant for PO
my_taxcom-txreg_sf = i_lfa1-txjcd.
my_taxcom-txreg_st = i_ekpo-txjcd.
my_taxcom-taxbs    = i_lfa1-taxbs.
my_taxcom-ipisp    = i_lfa1-ipisp.
my_taxcom-brsch    = i_lfa1-brsch.
my_taxcom-mtuse    = i_ekpo-j_1bmatuse.
my_taxcom-mtorg    = i_ekpo-j_1bmatorg.
my_taxcom-ownpr    = i_ekpo-j_1bownpro.
my_taxcom-steuc    = i_ekpo-j_1bnbm.
my_taxcom-matkl    = i_ekpo-matkl.
my_taxcom-vrkme    = i_ekpo-meins.
my_taxcom-mgame    = i_ekpo-menge.

* ISS Calculation with 2-level tax jurisdiction code
* To get the ISS Tax Condtions, need to pass the Following Parameters
 my_taxcom-loc_se = i_lfa1-txjcd.
 my_taxcom-loc_sr = i_lfa1-txjcd. 
* if you don't pass the above parameters and if your PO has ISS Tax conditions,
* you don't see them in the Result 
* Location of service provider = Tax Jur. Code of
* vendor:
my_taxcom-loc_pr   = i_lfa1-txjcd.
* Location of service = Tax Jur. Code of delivery address

*Populate fields based on country
    i_taxcom = my_taxcom.

CLEAR l_taxcom.
l_taxcom-bukrs = i_ekpo-bukrs.
l_taxcom-budat = i_ekko-bedat.
l_taxcom-waers = i_ekko-waers.
l_taxcom-kposn = i_ekpo-ebelp.
l_taxcom-mwskz = i_ekpo-mwskz.
l_taxcom-txjcd = i_ekpo-txjcd.
l_taxcom-shkzg = 'H'.
l_taxcom-xmwst = 'X'.
IF i_ekko-bstyp EQ 'F'.
  l_taxcom-wrbtr = i_ekpo-netwr.
  l_taxcom-wrbtr = i_ekpo-zwert.
l_taxcom-lifnr = i_ekko-lifnr.
l_taxcom-land1 = i_ekko-lands. "WIA
l_taxcom-ekorg = i_ekko-ekorg.
l_taxcom-hwaer = l_wa_t001-waers.
l_taxcom-llief = i_ekko-llief.
l_taxcom-bldat = i_ekko-bedat.
l_taxcom-matnr = i_ekpo-matnr. "HTN-Abwicklung
l_taxcom-werks = i_ekpo-werks.
l_taxcom-bwtar = i_ekpo-bwtar.
l_taxcom-matkl = i_ekpo-matkl.
l_taxcom-meins = i_ekpo-meins.
IF i_ekko-bstyp EQ 'F'.
  l_taxcom-mglme = i_ekpo-menge.
  IF i_ekko-bstyp EQ 'K' AND i_ekpo-abmng GT 0.
    l_taxcom-mglme = i_ekpo-abmng.
    l_taxcom-mglme = i_ekpo-ktmng.
IF l_taxcom-mglme EQ 0.
  l_taxcom-mglme = 1000.
l_taxcom-mtart = i_ekpo-mtart.

*Calculation of TAX

    dialog       = ' '
    display_only = ' '
    i_taxcom     = l_taxcom
    e_taxcom     = e_taxcom
    t_xkomv      = t_komv.

Now, we can Read form table T_KONV based on condition types.

--->  Scenario where the FM was used in the project 

1)      This Function  Module is used for printing partial tax amount in purchase order form .

2)      This Function module is used in SRM as well by remote call.


  1. Unknown User (w3j35wv)

    Great Job.(thumbs up)

    I had been trying to debug and create this scenario for long time now...

     just dint figure out that vendor detail;s need to be passed as well....


    Tarun Bahal

  2. Unknown User (xmglnct)

    This code is not working when i try to calculate taxes for service PO (Limits). it does not give BISE and BISA and corresponding conditions for value.

    has anyone been able to figure this out

  3. Unknown User (w46swjj)

    This saved me a lot of time!

    Thanks for sharing this..



  4. Unknown User (w46swjj)

    This saved me a lot of time!

    Thanks for sharing this..



  5. Unknown User (w46swjj)

    This saved me a lot of time!

    Thanks for sharing this..



  6. Unknown User (99om1o8s)

    Thanks for sharing this code.

    its a very help ful and undersanding.


    Vinod k Dwivedi

  7. I do not know if it is due to Brazil have specific tax rules, but for some cases this routine returns differences in some values.

    So I used the reviews described in the article below: