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 doesn't commit

Former Member
0 Likes
3,213

I have found thread

it is marked as answered but still it contains no answer

and I have the similiar problem that BAPI_TRANSACTION_COMMIT doesn't work

I get a key from BAPI_ACC_DOCUMENT_POST

I don't get any errors in the commit

but I can't find the records back in the SAP system in the bkpf tables

Is there any sollution why the commit doesn't work ?

I also checked the notes but couldn't find anything related to the non working commit



      CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
        EXPORTING
          documentheader    = doc_header
        IMPORTING
          obj_type          = h_objtype
          obj_key           = h_objkey
        TABLES
          accountgl         = acc_gl
*      ACCOUNTRECEIVABLE =
*      ACCOUNTPAYABLE    = vervaldat
*      ACCOUNTTAX        = tax
          currencyamount    = curr_amount
          return            = tret.

      IF h_objkey NE '$' .
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = 'X'
          IMPORTING
            return = h_commit_return.
        ASSIGN COMPONENT 'BOEKSTATUS' OF STRUCTURE <l_line> TO <l_field>.
        <l_field> = c_green.
      ELSE.
        ASSIGN COMPONENT 'BOEKSTATUS' OF STRUCTURE <l_line> TO <l_field>.
        <l_field> = c_red.
      ENDIF.

kind regards

arthur de smidt

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,814

Hi,

I also faced the same problem in one of my program. I find one wiered solution to this problem.

you can use WAIT UP TO 4 SECONDS. and then do the commit.

It worked for me, i hope it will work for you too.

Please reward if you find the answer useful.

Thanks,

Kamesh Bathla

9 REPLIES 9
Read only

naimesh_patel
Active Contributor
0 Likes
1,814

Instead of checking OBJKEY with '$', please try to read the return table with the specific status message, which says "Accounting Document ... posted". And if you find that message, than call the 'BAPI_TRANSACTION_COMMIT'.

I don't know the exact message number and class, otherwise I could have provided it to you.

Regards,

Naimesh Patel

Read only

Former Member
0 Likes
1,814

Is this posting related to cross company code ?

I have seen this case where actually the document is posted for the other company code so whenever you are displaying the document display using correct company code.

Thanks

Sudharshan

Read only

0 Likes
1,814

yep it's cross company, and perhaps I can refine the checking but stil the bapi returns with the message that everything was succesfull and has a key which consist of the company code. after that it passes the $ condition and does the commit and the commit also has no errors returned

but in development it is simple I check the BKPF table only with the current year and I get 20 records back. and my record is not 1 of them

kind regards

arthur

Read only

0 Likes
1,814

What I am trying to tell is check the document with both the company code and you will find the document which is at line item level.

Thanks

Sudharshan

Read only

0 Likes
1,814

here an example with the key returned from the bapi

1 S RW 605 Document correct geboekt: BKPFF 990000025758802008 BASTET030

______________________________

key 9900000257

company code 5880

year 2008

I can't find this record back in bkpf even when I leave the company code blank and even when I just enter the year (as told there are not many records in development this year)

kind regards

arthur de smidt

Read only

0 Likes
1,814

Hi

Have u checked the message tables returned by the BAPI before doing the commit?

Anyway u can try to debug the BAPI while fm FI_DOCUMENT_POST is calling: here the fm POST_DOCUMENT should be called in UPDATE TASK.

If you need u can debug fm POST_DOCUMENT setting UPDATE DEBUGGING while you're debugging the BAPI.

Max

Read only

Former Member
0 Likes
1,816

Hi,

I also faced the same problem in one of my program. I find one wiered solution to this problem.

you can use WAIT UP TO 4 SECONDS. and then do the commit.

It worked for me, i hope it will work for you too.

Please reward if you find the answer useful.

Thanks,

Kamesh Bathla

Read only

0 Likes
1,814

we actually found the answer in the fact that not all gl accounts were set to accept taxes in FS00.

as soon as we set the indicator to acceptance the bapi commit worked.

now we have to figure out the automatic postings done in the background since they happen with no taxcode the bapi wants to fill it in with a tax code used for the normal gl account.

further on we had to change the path also instead from company A to company B we had to make the booking from company B to A

kind regards

arthur de smidt

Read only

0 Likes
1,814

here is an example of how it looks like if we do the booking by hand

http://www.thehospages.com/sap/crosscompany.jpg

on the gl account 15000 the taxcode is always empty

on 44208 at the top item the taxcode is V3 (high tax)

on 44208 at the bottom item the taxcode is V9 (no taxes)

on 14015 the taxcode is V3

in fs00 the 15000 is also set that it doesn't allow taxes

the 15000 and 14015 bookings are made automaticaly when the 44208 postings are made in fb50

in the bapi I have added the 14015 line at the taxes

If I try to run the bapi with 15000 set to allow taxes everything works well. but then the taxcode in the 15000 lines are set to V9

now I try to turn it off again and add the 15000 lines in the bapi with the taxcode empty but still I get the error

FS 217 No taxes on sales/purch.are allowed for account 15000 2900, V9 is not allowed

F5 562 Account 15000 can only be posted to internally in company code 2900

F5 562 Account 15000 can only be posted to internally in company code 5880

anybody got a clue how to implement these bookings ?

kind regards

arthur de smidt