Вы находитесь на странице: 1из 5

SAP Community Network Wiki - Code Gallery - Function Module to Calculate Tax in Purchase order based on condition type

Log In Register About Us How to Contribute Store

Welcome Guest

SDN Community BPX Community Business Analytics University Alliances SAP EcoHub
Home Forums Wiki Blogs Articles eLearning Downloads Code Exchange Career Center Events InnoCentive Idea Place SAP Help Portal

My Home > Code Gallery > Function Module to Calculate Tax in Purchase order based on condition type Browse Search

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

4 Added by Jyothi Swaroop Kaza, last edited by Florian Teepen on Jul 21, 2010 (view change)

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

http://wiki.sdn.sap.com/wiki/display/Snippets/Function+Module+to+Calculate+Tax+in+Purchase+order+based+on+condition+type[1/13/2012 6:15:36 PM]


SAP Community Network Wiki - Code Gallery - Function Module to Calculate Tax in Purchase order based on condition type

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

http://wiki.sdn.sap.com/wiki/display/Snippets/Function+Module+to+Calculate+Tax+in+Purchase+order+based+on+condition+type[1/13/2012 6:15:36 PM]


SAP Community Network Wiki - Code Gallery - Function Module to Calculate Tax in Purchase order based on condition type

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.

SELECT SINGLE * FROM t001


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


* 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


CALL FUNCTION 'J_1B_SAVE_TAX_FIELDS'
EXPORTING
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.
ELSE.
l_taxcom-wrbtr = i_ekpo-zwert.
ENDIF.

http://wiki.sdn.sap.com/wiki/display/Snippets/Function+Module+to+Calculate+Tax+in+Purchase+order+based+on+condition+type[1/13/2012 6:15:36 PM]


SAP Community Network Wiki - Code Gallery - Function Module to Calculate Tax in Purchase order based on condition type

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.
ELSE.
IF i_ekko-bstyp EQ 'K' AND i_ekpo-abmng GT 0.
l_taxcom-mglme = i_ekpo-abmng.
ELSE.
l_taxcom-mglme = i_ekpo-ktmng.
ENDIF.
ENDIF.
IF l_taxcom-mglme EQ 0.
l_taxcom-mglme = 1000.
ENDIF.
l_taxcom-mtart = i_ekpo-mtart.

*Calculation of TAX

CALL FUNCTION 'CALCULATE_TAX_ITEM'


EXPORTING
* ANZAHLUNG =''
dialog =''
display_only =''
* INKLUSIVE =''
* I_ANWTYP =''
* I_DMBTR = '0'
* I_MWSTS = '0'
i_taxcom = l_taxcom
* PRUEFEN =''
* RESET =''
IMPORTING
* E_NAVFW =
e_taxcom = e_taxcom
* E_XSTVR =
* NAV_ANTEIL =
TABLES
t_xkomv = t_komv
* EXCEPTIONS
* MWSKZ_NOT_DEFINED =1
* MWSKZ_NOT_FOUND =2
* MWSKZ_NOT_VALID =3
* STEUERBETRAG_FALSCH =4
* COUNTRY_NOT_FOUND =5
* OTHERS =6
.

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.

Labels
snippet abap

Comments (5) Show Comments

Contact Us Site Index Marketing Opportunities Legal Terms Privacy Impressum

http://wiki.sdn.sap.com/wiki/display/Snippets/Function+Module+to+Calculate+Tax+in+Purchase+order+based+on+condition+type[1/13/2012 6:15:36 PM]


SAP Community Network Wiki - Code Gallery - Function Module to Calculate Tax in Purchase order based on condition type

Powered by SAP NetWeaver

http://wiki.sdn.sap.com/wiki/display/Snippets/Function+Module+to+Calculate+Tax+in+Purchase+order+based+on+condition+type[1/13/2012 6:15:36 PM]

Вам также может понравиться