02-15-2021 4:16 PM
I have been given excel sheet data with 1st line item with gl_account field & tax_code field filled and passing that entry into GLACCOUNT table and 2nd line item contains Vendor data filled and passing this entry into ACCOUNTPAYABLE table. The 1st line item derives multiple line items and passed them into ACCOUNTTAX table.
Now,
glaccount table has --->1 entry
accountpayable--->1 entry
taxaccount table --->2 entries
currencyamount table --> 4 entries( all the entries clubbed together) and passed them to BAPI_ACC_DOCUMENT_POST. along with document header and customercpd structures. But unable to find the derived line entries in BSEG table after committing the BAPI.
02-15-2021 4:29 PM
There is a good example for the BAPI call under this URL,
https://answers.sap.com/questions/3117081/sample-code-for-bapiaccdocumentpost.html
just check the return parameter after the call to see what is wrong.
02-15-2021 5:15 PM
Hello vamshisaichand23
The note 626235 - Tax postings with accounting BAPIs provides nice examples of how to fill the BAPI_ACC_DOCUMENT_POST. It also contains to sample reports.
Have a look.
Best regards
Dominik Tylczynski
02-24-2021 11:45 AM
Nowadays SAP provided a method (fi_tax_services=>calculate, this method is also wrapped in FM FI_TAX_SERVICES_CALCULATE) that provides the required TAX records.
" Prepare parameters
" ...
" Evaluate Taxes
CALL METHOD fi_tax_services=>calculate
EXPORTING
documentheader = documentheader
taxamount = l_amount
accountpayable = accountpayable
IMPORTING
return_code = l_return_code
CHANGING
accountgl = accountgl
accounttax = accounttax
currencyamount = currencyamount
return = return.
" Call BAPI
IF l_return_code = 0.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
Ref: Check OSS notes 1873588 'Filling tax information for BAPIs' and 2070697 'Filling tax information for BAPIs'