# CALCULATE_TAX_FROM_GROSSAMOUNT — Calculate Tax from Gross Amount

> Calculates the tax amount from a tax-inclusive (gross) amount based on company code, tax code and currency; details per tax condition are returned in the T_MWDAT table. It is used in invoice upload programs to split a gross amount into net and VAT, or to fill tax lines before posting. Make sure the amount is in document currency and handle the tax code exceptions (MWSKZ_NOT_DEFINED, MWSKZ_NOT_VALID); to calculate from a net amount use CALCULATE_TAX_FROM_NET_AMOUNT.

- Modules: FI
- Type: Function module
- Function group: TAX1
- Remote-enabled (RFC): No
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/calculate-tax-from-grossamount/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| I_BUKRS | BKPF-BUKRS | Company code | Yes |
| I_MWSKZ | BSEG-MWSKZ | Tax code | Yes |
| I_WAERS | BKPF-WAERS | Currency | Yes |
| I_WRBTR | BSEG-WRBTR | Gross amount | Yes |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| E_FWNAV | BSET-FWSTE | Non-deductible tax amount |
| E_FWNVV | BSET-FWSTE | Non-deductible tax not distributed |
| E_FWSTE | BSET-FWSTE | Tax amount |
| E_FWAST | BSET-FWSTE | Other tax amount (FWAST) |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| T_MWDAT | RTAX1U15 | Tax condition details | - |

## Exceptions

- BUKRS_NOT_FOUND: Company code not found
- COUNTRY_NOT_FOUND: Country not found
- MWSKZ_NOT_DEFINED: Tax code not defined
- MWSKZ_NOT_VALID: Tax code not valid
- ACCOUNT_NOT_FOUND: Account not found
- DIFFERENT_DISCOUNT_BASE: Different discount base
- DIFFERENT_TAX_BASE: Different tax base
- TXJCD_NOT_VALID: Tax jurisdiction not valid
- NOT_FOUND: Record not found
- KTOSL_NOT_FOUND: Transaction key not found
- KALSM_NOT_FOUND: Calculation procedure not found
- PARAMETER_ERROR: Parameter error
- KNUMH_NOT_FOUND: Condition record not found
- KSCHL_NOT_FOUND: Condition type not found
- UNKNOWN_ERROR: Unknown error

## Call template (ABAP)

```abap
CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
  EXPORTING
    i_bukrs = lv_i_bukrs
    i_mwskz = lv_i_mwskz
    i_waers = lv_i_waers
    i_wrbtr = lv_i_wrbtr
  IMPORTING
    e_fwnav = lv_e_fwnav
    e_fwnvv = lv_e_fwnvv
    e_fwste = lv_e_fwste
    e_fwast = lv_e_fwast
  TABLES
    t_mwdat = lt_t_mwdat
  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
    OTHERS = 9.
```

## Related tables

T001, T007A

