Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_ACC_DOCUMENT_POST with tax posting

Former Member
0 Likes
1,384

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
950

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^

4 REPLIES 4
Read only

Former Member
0 Likes
950

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

Read only

Former Member
0 Likes
950

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

Read only

0 Likes
950

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.

Read only

Former Member
0 Likes
951

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^