Last active
December 22, 2015 23:38
-
-
Save js1972/6547810 to your computer and use it in GitHub Desktop.
#ABAP code to calculate the #tax from a gross amount. The example here calculates any non-deductible tax from a gross amount. Its used by the ZCL_PURCHASE_ORDER_STATUS class. Interestingly non-deductible tax is added to the amount shown as DELIVERED in the PO status screen (ME23N) which is confusing as the other amount such as PO ordered amount …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
method get_non_ded_tax_po_item. | |
data: tax_code type mwskz, | |
company_code type bukrs, | |
currency type waers, | |
tax_jurisdiction type txjcd, | |
gross_amount type wrbtr. | |
select single bukrs waers into (company_code, currency) | |
from ekko | |
where ebeln = po. | |
check sy-subrc = 0. | |
select single mwskz txjcd into (tax_code, tax_jurisdiction) | |
from ekpo | |
where ebeln = po | |
and ebelp = item. | |
check sy-subrc = 0. | |
gross_amount = value. "type conversion | |
call function 'CALCULATE_TAX_FROM_GROSSAMOUNT' | |
exporting | |
i_bukrs = company_code | |
i_mwskz = tax_code | |
i_txjcd = tax_jurisdiction | |
i_waers = currency | |
i_wrbtr = gross_amount | |
importing | |
e_fwnav = non_deductible_tax " Non-deductible tax calculated (total) | |
exceptions | |
bukrs_not_found = 1 | |
country_not_found = 2 | |
mwskz_not_defined = 3 | |
mwskz_not_valid = 4 | |
account_not_found = 5 | |
different_discount_base = 6 | |
different_tax_base = 7 | |
txjcd_not_valid = 8 | |
not_found = 9 | |
ktosl_not_found = 10 | |
kalsm_not_found = 11 | |
parameter_error = 12 | |
knumh_not_found = 13 | |
kschl_not_found = 14 | |
unknown_error = 15 | |
others = 16. | |
if sy-subrc <> 0. | |
non_deductible_tax = 0. | |
endif. | |
endmethod. "get_non_ded_tax_po_item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment