You are on page 1of 4

Getting Started Store

Community WIKI SAP Community Welcome, Guest Login Register Search the Community

Code Gallery

Function Module to Calculate Tax in Purchase order based on condition type


Created by Jyothi Swaroop Kaza, last modified by niran orkkatteri kariyadan on Apr 22, 2014

---> 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

1
2 *Local Data declaration
3 DATA: my_taxcom TYPE j_1b_taxcom ,
4 l_taxcom TYPE taxcom ,
5 l_wa_t001 TYPE t001,
6 e_taxcom TYPE taxcom ,
7 l_wa_komv TYPE komv ,
8 l_gv_amount TYPE netwr ,
9 l_unitprice TYPE netwr,
10 l_ipiamount TYPE netwr,
11 l_total_ipi TYPE netwr,
12 l_total TYPE netwr ,
13 l_taxamount TYPE netwr.
14
15 SELECT SINGLE * FROM t001
16 INTO l_wa_t001
17 WHERE bukrs EQ i_ekko-bukrs.
18
19 * Fill tax fields relevant for PO
20 my_taxcom-txreg_sf = i_lfa1-txjcd.
21 my_taxcom-txreg_st = i_ekpo-txjcd.
22 my_taxcom-taxbs = i_lfa1-taxbs.
23 my_taxcom-ipisp = i_lfa1-ipisp.
24 my_taxcom-brsch = i_lfa1-brsch.
25 my_taxcom-mtuse = i_ekpo-j_1bmatuse.
26 my_taxcom-mtorg = i_ekpo-j_1bmatorg.
27 my_taxcom-ownpr = i_ekpo-j_1bownpro.
28 my_taxcom-steuc = i_ekpo-j_1bnbm.
29 my_taxcom-matkl = i_ekpo-matkl.
30 my_taxcom-vrkme = i_ekpo-meins.
31 my_taxcom-mgame = i_ekpo-menge.
32
33 * ISS Calculation with 2-level tax jurisdiction code
34 * To get the ISS Tax Condtions, need to pass the Following Parameters
35 my_taxcom-loc_se = i_lfa1-txjcd.
36 my_taxcom-loc_sr = i_lfa1-txjcd.
37 * if you don't pass the above parameters and if your PO has ISS Tax conditions,
38 * you don't see them in the Result
39
40
41 * Location of service provider = Tax Jur. Code of
42 * vendor:
43 my_taxcom-loc_pr = i_lfa1-txjcd.
44 * Location of service = Tax Jur. Code of delivery address
45
46 *Populate fields based on country
47 CALL FUNCTION 'J_1B_SAVE_TAX_FIELDS'
48 EXPORTING
49 i_taxcom = my_taxcom.
50
51 CLEAR l_taxcom.
52 l_taxcom-bukrs = i_ekpo-bukrs.
53 l_taxcom-budat = i_ekko-bedat.
54 l_taxcom-waers = i_ekko-waers.
55 l_taxcom-kposn = i_ekpo-ebelp.
56 l_taxcom-mwskz = i_ekpo-mwskz.
57 l_taxcom-txjcd = i_ekpo-txjcd.
58 l_taxcom-shkzg = 'H'.
59 l_taxcom-xmwst = 'X'.
60 IF i_ekko-bstyp EQ 'F'.
61 l_taxcom-wrbtr = i_ekpo-netwr.
62 ELSE.
63 l_taxcom-wrbtr = i_ekpo-zwert.
64 ENDIF.
65 l_taxcom-lifnr = i_ekko-lifnr.
66 l_taxcom-land1 = i_ekko-lands. "WIA
67 l_taxcom-ekorg = i_ekko-ekorg.
68 l_taxcom-hwaer = l_wa_t001-waers.
69 l_taxcom-llief = i_ekko-llief.
70 l_taxcom-bldat = i_ekko-bedat.
71 l_taxcom-matnr = i_ekpo-matnr. "HTN-Abwicklung
72 l_taxcom-werks = i_ekpo-werks.
73 l_taxcom-bwtar = i_ekpo-bwtar.
74 l_taxcom-matkl = i_ekpo-matkl.
75 l_taxcom-meins = i_ekpo-meins.
76 IF i_ekko-bstyp EQ 'F'.
77 l_taxcom-mglme = i_ekpo-menge.
78 ELSE.
79 IF i_ekko-bstyp EQ 'K' AND i_ekpo-abmng GT 0.
80 l_taxcom-mglme = i_ekpo-abmng.
81 ELSE.
82 l_taxcom-mglme = i_ekpo-ktmng.
83 ENDIF.
84 ENDIF.
85 IF l_taxcom-mglme EQ 0.
86 l_taxcom-mglme = 1000.
87 ENDIF.
88 l_taxcom-mtart = i_ekpo-mtart.
89
90 *Calculation of TAX
91
92 CALL FUNCTION 'CALCULATE_TAX_ITEM'
93 EXPORTING
94 dialog = ' '
95 display_only = ' '
96 i_taxcom = l_taxcom
97 IMPORTING
98 e_taxcom = e_taxcom
99 TABLES
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.


snippet abap
7 Comments
Guest
Great Job.

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....

Regard,

Tarun Bahal

Guest
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

Guest
This saved me a lot of time!

Thanks for sharing this..

Regards,

Rozie

Guest
This saved me a lot of time!

Thanks for sharing this..

Regards,

Rozie

Guest
This saved me a lot of time!

Thanks for sharing this..

Regards,

Rozie

Guest
Thanks for sharing this code.

its a very help ful and undersanding.

Regards

Vinod k Dwivedi

Marcio Ozorio de Jesus


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:


http://scn.sap.com/thread/3150483

Regards,

Márcio

Contact Us SAP Help Portal


Privacy Terms of Use Legal Disclosure Copyright Follow SCN

You might also like