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_ACC_DOCUMENT_POST tax

Former Member
0 Kudos

Good day

I'm using BAPI_ACC_DOCUMENT_POST to create invoices from a vendor interface flat file (we do not want to use BDCs).

I'm not sure how to populate the tax codes? The total invoice tax is indicated on the invoice header level. Some line items are taxable and others not, but I don't know which line items have tax and which not. Besides DOCUMENTHEADER, I populate the first line with negative total amount in ACCOUNTPAYABLE table with ITEMNO_ACC of 10. All line items are then populated in ACCOUNTGL table. I then list the Tax/VAT as the last line item in ACCOUNTGL. But I never indicated the tax codes. Now that I attempt this, I'm running into all sorts of trouble. I think that ACCOUNTTAX table is only used if you actually want the tax to be listed separately per line item. In our case in transaction F-43 we don't set the checkbox to true for Calculate Tax. We just enter the tax code and capture the line items, the last being a separate line item for tax. So now I'd appreciate it if someone could tell me how to do this? If I only enter ACCOUNTGL entry and input the tax code, the RETURN table indicates that a corresponding tax entry is expected. If I enter a corresponding tax entry I get an error that the tax code I'm using is wrong for the GL Account. And it expects the tax entry to be a calculated amount per line item.

If this is too complicated to achieve with the BAPI, I'll revert to a BDC, but it would be great to get this working with the BAPI.

Best regards, Adrian

Edited by: Adrian Bruwer on Jul 26, 2011 11:56 AM

7 REPLIES 7

Former Member
0 Kudos

Hi

That BAPI doesn't calculate the tax line automatically, you need to do it by yourself, you can use fm like CALCULATE_TAX_FROM_NET_AMOUNT in order to get the tax data.

The tax line has to be transfer to ACCOUNTTAX only not in ACCOUNTGL

Max

0 Kudos

Thanks Max

The problem is that I only have the tax at header level, not line item level. So I cannot calculate the tax at the line item level as suggested.

Regards, Adrian

0 Kudos

Hi

You should know the base amount else how you can post the document?

Can you post the items (or header) of the document you need to post

Max

0 Kudos

This BAPI is a real PITA to get it to work,

It took me ages to finally find out how to get the tax in.

I used the Table: EXTENSION1

  • Call the POST-BAPI

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = cs_documentheader

TABLES

accountpayable = ct_accountpayable

currencyamount = ct_currencyamount

extension1 = ct_extension1

return = ct_bapiret2.

( ct_extension1 TYPE /sappce/tt_dpc_bapiacextc )

  • Don't ask me why, but it works.

  • For more info, put a breakpoint in FM: /SAPPCE/DPC_PROCESS_EXTENSION

This is how I filled the extension1 -table

DATA: ls_extension1 TYPE bapiacextc.

ls_extension1-field1 = '10'.

ls_extension1-field2 = 'ZUMSK'.

ls_extension1-field3 = 'L'.

APPEND ls_extension1 TO ct_extension1.

ls_extension1-field1 = '10'.

ls_extension1-field2 = 'BSTAT'.

ls_extension1-field3 = 'S'.

APPEND ls_extension1 TO ct_extension1.

ls_extension1-field1 = '10'.

ls_extension1-field2 = 'GLVOR'.

ls_extension1-field3 = 'RFST'.

APPEND ls_extension1 TO ct_extension1.

ls_extension1-field1 = '10'.

ls_extension1-field2 = 'BSCHL'.

ls_extension1-field3 = '39'.

APPEND ls_extension1 TO ct_extension1.

Above is how I did it for transaction F-47

I used the same bapi for tr: FB01, but used the accounttax-table:

==> For FB01

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = cs_documentheader

TABLES

accountgl = ct_accountgl

accountpayable = ct_accountpayable

currencyamount = ct_currencyamount

accounttax = ct_accounttax

return = ct_bapiret2.

0 Kudos

Thanks Max. The problem is that some line items might have tax, but others not. And I don't have such an indication at line item level, I only have the tax for the total invoice. And in transaction F-43 that is not a problem. The Functional requirement is that I flag all line items as taxable or non-taxable depending on if there is a total invoice tax amount or not - even if some of the line items might not be taxable. The total invoice tax is then captured as an additional line item posting to the tax GL Account. As mentioned, I can do this in transaction F-43, but not in the BAPI. I know this is an akward requirement, so if it is not possible, I'll do the BDC..

0 Kudos

Thank you very much for your reply Rob. I'll look into the extension and let you know if I get it working. The alternative is for me to generate an iDoc and send it to a different CLIENT and check if it populates fine from e.g. client 001 to client 002. Then I'll debug to see how SAP populates the ALE functions - and if these in turn call the BADI I'm using. I was able to do this in SD before.

0 Kudos

Hi

I still don't understand

F-43 is not magic, it can calculate the tax item from the G/L line where a certain tax code is indicate, else you need to do it manually like the BAPI.

If you have the amount to be posted, you need to do which are the taxable and untaxable part, that means you should know the vat code for both parts (taxable and untaxable).

For example:

It needs to post 1000 Euro, where only 900 are taxable (20%), so you should have:

Vendor 1 900 tax code 20 (20%)

Vendor 2 100 tax code 00 (0%)

Cost 3 - 900 tax code 20

Cost 4 - 100 tax code 00

So it needs to calculate the tax line manually and the posting to be transfer to the BAPI should be:

Vendor 1 1080 tax code 20 (20%)

Vendor 2 100 tax code 00 (0%)

Cost 3 - 900 tax code 20

Cost 4 - 100 tax code 00

tax 5 - 180 tax code 20

Max