‎2006 Dec 01 3:30 PM
Hi;
I have implemented BAPI_ACC_DOCUMENT_POST to post some items and a related vendor document. The program runs fine and creates documents for all lines and an additional line for vendor. But when i want to add a tax line nothing happens. The code for adding tax line data is as follows:
CALL FUNCTION 'CALCULATE_TAX_FROM_GROSSAMOUNT'
EXPORTING
I_BUKRS = '1100'
I_MWSKZ = mwskz
I_TXJCD = ' '
I_WAERS = waers
I_WRBTR = toplam
I_ZBD1P = 0
I_PRSDT =
I_PROTOKOLL =
I_TAXPS =
I_ACCNT_EXT =
IS_ENHANCEMENT =
IMPORTING
E_FWNAV = vergi
E_FWNVV =
E_FWSTE = vergi
E_FWAST =
TABLES
T_MWDAT = vergi
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
tax-itemno_acc = line + 2. "accounttax
tax-gl_account = vergi-hkont.
tax-tax_code = mwskz.
tax-acct_key = vergi-ktosl.
tax-cond_key = vergi-kschl.
append tax.
it_accounttax-acct_key = 'VST'.
clear amount. "currency amount
amount-itemno_acc = line + 2.
amount-currency = waers. "'TRY'.
amount-currency_iso = waers.
amount-curr_type = '00'.
amount-amt_doccur = toplam." - vergi-wmwst.
amount-amt_base = vergi-wmwst.
amount-tax_amt = vergi-wmwst.
append amount.
the tax function calculates the tax amount correctly (eg. for an amount of 600 gross and tax rate 1% the tax is 5,94) but BAI does not create the relevant tax line.
Can someone help?
Thx
Ali
‎2006 Dec 01 3:40 PM
hi
good
go through this link which ll give you detail idea about the BAPI_ACC_DOCUMENT_POST .
http://sap4.com/wiki/index.php?title=BAPI_ACC_DOCUMENT_POST
thanks
mrutyun^
‎2006 Dec 01 3:38 PM
I'm not sure why you are using this FM to add tax. Why not transfer it in BAPI_ACC_DOCUMENT_POST using the ACCOUNTTAX table?
Rob
‎2006 Dec 01 3:39 PM
Ali,
In my program, I fill the following field of the TAX Structure :
Take a look, it should help :
* ACCOUNTTAX
PERFORM calculate_vat_amount USING t_notilus-comp_code
t_notilus-vat_cod
t_notilus-amt_doccur
CHANGING p_tax_amount
accounttax-tax_code
accounttax-tax_rate
accounttax-acct_key
accounttax-gl_account
accounttax-cond_key.
accounttax-tax_date = sy-datum.
accounttax-itemno_acc = p_compt.
accounttax-itemno_tax = p_compt - 1.
APPEND accounttax.
*&---------------------------------------------------------------------*
*& Form calculate_vat_amount
*&---------------------------------------------------------------------*
FORM calculate_vat_amount USING p_comp_code
p_vat_cod
p_amount
CHANGING tax_amount
w_vat_cod
w_msatz
w_ktosl
w_hkont
w_kschl.
DATA : BEGIN OF t_mwdat OCCURS 0.
INCLUDE STRUCTURE rtax1u15.
DATA : END OF t_mwdat.
DATA : w_ttc LIKE bseg-wrbtr.
w_ttc = p_amount.
CALL FUNCTION 'CALCULATE_TAX_FROM_NET_AMOUNT'
EXPORTING
i_bukrs = p_comp_code
i_mwskz = p_vat_cod
i_waers = 'EUR'
i_wrbtr = w_ttc
TABLES
t_mwdat = t_mwdat
EXCEPTIONS
bukrs_not_found = 1
country_not_found = 2
mwskz_not_defined = 3
mwskz_not_valid = 4
ktosl_not_found = 5
kalsm_not_found = 6
parameter_error = 7
knumh_not_found = 8
kschl_not_found = 9
unknown_error = 10
account_not_found = 11
txjcd_not_valid = 12
OTHERS = 13.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR t_mwdat.
READ TABLE t_mwdat INDEX 1. "INTO s_mwdat
* w_tax_amount = t_mwdat-WMWST.
w_tax_amount = t_notilus-vat_amount.
w_ktosl = t_mwdat-ktosl.
w_hkont = t_mwdat-hkont.
w_kschl = t_mwdat-kschl.
w_msatz = t_mwdat-msatz.
w_vat_cod = p_vat_cod.
ENDFORM. " calculate_vat_amount
Erwan
‎2006 Dec 01 4:53 PM
Hi;
Thx for the answer. Unfortunately it does not work. Still i can't create the item for tax in the document although the tax amounts for lines are correctly calculated.
Regards
Ali.
‎2006 Dec 01 3:40 PM
hi
good
go through this link which ll give you detail idea about the BAPI_ACC_DOCUMENT_POST .
http://sap4.com/wiki/index.php?title=BAPI_ACC_DOCUMENT_POST
thanks
mrutyun^