In most countries the calculation of tax base and tax amount cannot be achieved via standard configurations of the Withholding Tax Types and Withholding Tax Codes. In this blog I will try to explain how to use the Badi to calculate the Tax base via ABAP.
BADI Name: MRM_WT_SPLIT_UPDATE
The following are the transactions in which this BADI is called:
- Withholding Tax Types and Codes should be configured
- Withholding Tax Types and Codes should be assigned in the Business Partner
Limitation to Manual Tax Base and Tax Amount:
Activating this BADI means that you cannot manually enter the withholding tax base and amount.
Parameters which can be used:
- I_RBKPV – Invoice Document Header
- TI_DRSEG – Invoice Document Item
- TE_RBWS – Withholding Tax
- TE_RBVS – Supplier Split
- E_QSSKZ – Withholding tax code
As an example, I am providing a sample code for understanding purpose only where I have used the concept of Maximum Base Amount for a particular tax code in a specific company code. However this can be different based on the requirements in your country / company code:
DATA: ZBASE_AMOUNT_DC TYPE MRM_RBKPV-RMWWR. "Base Amount in Document Currency DATA: ZMAX_BASE_AMOUNT TYPE MRM_RBKPV-RMWWR. "Maximum Base Amount in Document Currency IF I_RBKPV-BUKRS = '3000'. LOOP AT TE_RBWS INTO DATA(LS_TE_RBWS) WHERE WITHT = 'Z1' AND WT_WITHCD = '01'. ZMAX_BASE_AMOUNT = '2125000'. ZBASE_AMOUNT_DC = I_RBKPV-RMWWR. IF ZBASE_AMOUNT_DC GE ZMAX_BASE_AMOUNT. LS_TE_RBWS_Z101-WT_QSSHB = ZMAX_BASE_AMOUNT. ELSE. LS_TE_RBWS_Z101-WT_QSSHB = ZBASE_AMOUNT_DC. ENDIF. MODIFY TE_RBWS FROM LS_TE_RBWS. CLEAR: LS_TE_RBWS. ENDLOOP. ENDIF.
Can we use this BADI to calculate the Base Amount for dependent Tax Codes?
Yes one of the core essence of this BADI is that we can use this to calculate Inter-Dependent Tax Bases. For E.g.
In the above example, the second and the third tax bases are dependent upon the balance after the deductions of the previous codes. For understanding purpose, I am sharing another draft sample code:
Although this BADI can be used for multiple other scenarios but I hope that in this blog I was able to explain on the subject matter. I used this BADI in one of my recent implementation and thought to share this with other colleagues and consultants.
If you find this useful, please do comment and hit likes.