Application Development 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: 

BAPI to update Tax details in FB01 transaction

Former Member
0 Kudos
726

Hi,

I need to update Tax Codes(MWSKZ) and Tax Amounts(FWSTE) in FB01 transaction.

I tried with 'BAPI_ACC_DOCUMENT_POST', but it doesnot have Tax Amount(FWSTE) field.

Please let me know, if there is any other BAPI to achieve this?

Thanks & Regards,

Priyanka

6 REPLIES 6

Former Member
0 Kudos
216

Hi

Please try,

BAPI_ACC_GL_POSTING_POST

BAPI_ACC_BILLING_POST

BAPI_ACC_INVOICE_RECEIPT_POST

Regards

Abhii..

0 Kudos
216

Please try,

BAPI_ACC_GL_POSTING_POST

BAPI_ACC_BILLING_POST

BAPI_ACC_INVOICE_RECEIPT_POST

Don't blindly post info if you don't know the answer...

To the original poster, you might want to be a bit more specific, but you can post tax amounts, such as a direct posting to a tax accrual account, with BAPI_ACC_DOCUMENT_POST. You should use the ACCOUNTTAX and CURRENCYAMOUNT tables, plus the EXTENSION1 table for the posting key. Here is a snippet of an example that performs a write-off to a tax account:


...
*     Document Line item if tax not 0
      gs_curramt-itemno_acc = lv_item.
      gs_curramt-currency   = gs_stmnt-currency.
      gs_curramt-amt_doccur = ls_bset-fwste.
      gs_curramt-amt_base   = ls_bset-fwbas.
      gs_curramt-tax_amt    = ls_bset-fwste.

      APPEND gs_curramt TO gt_curramt.
      CLEAR  gs_curramt.

      IF ls_bset-fwste NE 0.

        gs_ext-field1 = lv_item.
        gs_ext-field2 = '40'.

        APPEND gs_ext TO gt_ext.
        CLEAR  gs_ext.

      ENDIF.

*     Tax line item for all BSET entries
      gs_tax-itemno_acc       = lv_item.
      gs_tax-gl_account       = ls_bset-hkont.
      gs_tax-acct_key         = ls_bset-ktosl.
      gs_tax-tax_code         = ls_bset-mwskz.
      gs_tax-cond_key         = ls_bset-kschl.
      gs_tax-tax_date         = sy-datum.
      gs_tax-taxjurcode       = ls_bset-txjcd.
      gs_tax-taxjurcode_deep  = ls_bset-txjdp.
      gs_tax-taxjurcode_level = ls_bset-txjlv.
      gs_tax-tax_rate         = ls_bset-kbetr.
      gs_tax-direct_tax       = 'X'.
*     gs_tax-ITEMNO_TAX

      APPEND gs_tax TO gt_tax.
      CLEAR  gs_tax.

...

* Call the BAPI
  CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
      documentheader    = gs_header
    IMPORTING
      obj_type          = gs_header-obj_type
      obj_key           = gs_header-obj_key
      obj_sys           = gs_header-obj_sys
    TABLES
      accountgl         = gt_gl
      accountreceivable = gt_ar
      accounttax        = gt_tax
      currencyamount    = gt_curramt
      extension1        = gt_ext
      return            = gt_return.

0 Kudos
216

Hello Brad,

AFAIK you cannot change the line item fields of an already posted a/c'ing document. You have to reverse the doc & try to re-post.

Correct me if i am wrong.

BR,

Suhas

PS: Almost a year i have done any FI developments, so i am a lil' bit rusty

0 Kudos
216

Hello Brad,

AFAIK you cannot change the line item fields of an already posted a/c'ing document. You have to reverse the doc & try to re-post.

Correct me if i am wrong.

Somewhat correct, but certainly true for amounts. You can configure which fields can be changed after posting. However, the poster said 'update' but also mentioned 'FB01' and that the create BAPI did not have the correct fields, so I assumed CREATE was the desired approach...

raymond_giuseppi
Active Contributor
0 Kudos
216

- If you want to post like FB01 with an accounting BAPI, read SAP documentation at OSS [Note 626235 - Tax postings with accounting BAPIs|https://service.sap.com/sap/support/notes/626235]

- If you want to change the value calculated during FB01, you don't need a BAPI, search for BADI (like BADI_ACC_DOCUMENT) or [substitution rules|http://help.sap.com/saphelp_ides/helpdata/en/6e/1229b99f0411d189b80000e829fbbd/frameset.htm]

- If you want to change values already posted, sorry, reverse the postings and post it again correctly (some fields may be changed but not many, check [Note 827413 - FI: Changeability of fields in FI documents|https://service.sap.com/sap/support/notes/827413])

Regards,

Raymond

kesavadas_thekkillath
Active Contributor
0 Kudos
216