cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI_ACC_DOCUMENT_POST

Former Member
0 Likes
3,307

Hi Friends,

Thanks in Advance.

I am using the BAPI 'BAPI_ACC_DOCUMENT_POST' for the FB70 T.Code.

Please check the Below Code...

Moderator message - Please see below

The above code is Executing Perfectly...and generating the Accounting Documnet Number.

But the Problem is i cant able to see the Generated Accounting Document Number in FB03.

I had crossed Checked with the G/L Account in FBL3N T.Code and with Customer Number in FBL5N T.Code

Finally i checked the Data Base Table BKPF & BSEG.

But no use.

i can't understand where the problem is...

Whether in Customizing or in Table Inconsistency or i have to Send any other parameter.

If we try to post using Standard Transaction FB70 / FB60 it is Posting Successfully.

i mean we can see this A/C Number in FB03, FBl3N, FBl5N and in BKPF & BSEG Tables.

Regards:

Sridhar.J

Edited by: Rob Burbank on Sep 22, 2009 2:10 PM

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Likes

Hi Friends,

I think you all were cant able to read the code..

Now please check the below code..


DATA gd_documentheader LIKE bapiache09.
DATA l_type            LIKE gd_documentheader-obj_type.
DATA l_key             LIKE gd_documentheader-obj_key.
DATA l_sys             LIKE gd_documentheader-obj_sys.
DATA it_accountgl      LIKE TABLE OF bapiacgl09 WITH HEADER LINE.
DATA it_currencyamount LIKE TABLE OF bapiaccr09 WITH HEADER LINE.
DATA it_return         LIKE TABLE OF bapiret2   WITH HEADER LINE.
DATA it_return1        LIKE TABLE OF bapiret2   WITH HEADER LINE.

gd_documentheader-username   = sy-uname.
gd_documentheader-header_txt = 'BAPI Test'.
gd_documentheader-comp_code  = '2000'.
gd_documentheader-fisc_year  = '2009'.
gd_documentheader-doc_date   = sy-datum.
gd_documentheader-pstng_date = sy-datum.
gd_documentheader-bus_act    = 'RMRP'.
gd_documentheader-fis_period = '06'.
gd_documentheader-doc_type = 'DR'.

CLEAR it_accountgl.
it_accountgl-itemno_acc     = 1.
it_accountgl-gl_account     = '0003101110'.
it_accountgl-tax_code       = 'V0'.
it_accountgl-item_text      = 'BAPI Test G/L line item'.
it_accountgl-customer       = '0000000092'.
it_accountgl-profit_ctr     = '0000002002'.
it_accountgl-de_cre_ind     = 'H'.
it_accountgl-comp_code      = '2000'.
it_accountgl-doc_type       = 'DR'.
it_accountgl-fis_period     = '06'.
it_accountgl-fisc_year      = '2009'.
it_accountgl-pstng_date     = sy-datum.
APPEND it_accountgl.

CLEAR it_currencyamount.
it_currencyamount-itemno_acc   = 1.
it_currencyamount-curr_type    = '00'.
it_currencyamount-currency     = 'INR'.
it_currencyamount-amt_base     = '100'.
APPEND it_currencyamount.

CLEAR it_currencyamount.
it_currencyamount-itemno_acc   = 2.
it_currencyamount-curr_type    = '00'.
it_currencyamount-currency     = 'INR'.
it_currencyamount-amt_base     = '100'.
APPEND it_currencyamount.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
  EXPORTING
    documentheader = gd_documentheader
  IMPORTING
    obj_type       = l_type
    obj_key        = l_key
    obj_sys        = l_sys
  TABLES
    accountgl      = it_accountgl
    currencyamount = it_currencyamount
    return         = it_return.

WAIT UP TO 10 SECONDS.

IF sy-subrc IS INITIAL.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
ENDIF.

Former Member
0 Likes

Thanks for adding the code tags

I've seen this problem before in the forum. If you search, you may be able to find if it was ever solved.

Rob

Former Member
0 Likes

>

>


> IF sy-subrc IS INITIAL.
>   CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
>     EXPORTING
>       wait = 'X'.
> 

On the other hand, the problem may be right here. You should check the contents of the return table rather than sy-subrc before doing the COMMIT. SY-SUBRC will have the last value from the BAPI but does not mean it worked or did not.

Rob

Former Member
0 Likes

yes true you need to check with return table of bapi instead of sy-subrc and I believe no need of any wait statement.One thing to update you is the document you are trying to post is not a balanced entry so this will not post the document until you make the currency structure[line item 2 with negative sign].

Thanks and Regards

Sudharshan

Former Member
0 Likes

Hi Rob Burbank

Thanks for ur answer.

After execution of the BAPI 'BAPI_ACC_DOCUMENT_POST', the return table is filling with one entry.

That is Successful Message with 'Document Posted Succesfully 010664021820002009'.

Here first 10 Characters is Accounting Document Number

Then four Characters is Company Code

Then Last Four Characters is Fiscal Year.

After this BAPI i wrote 'WAIT UPTO 10 SEC'.

then i called BAPI_TRANSACTION_COMMIT.

I checked with the return tale aslo..like what u said.

If the BAPI is not executed properly it may throw errors in RETURN Tables...right?

But it generating Accounting Document Successfully..

Regards:

Sridhar.J

Former Member
0 Likes

Hi Sudharshan

I had check with the Negative Sign also...

If balances is not taly..it willl throw an error stating that 'Error is Balance Amounts'.

but i not getting that one..

it is posting Accounting Document Successfully.

Regards:

Sridhar

ThomasZloch
Active Contributor
0 Likes

Try getting rid of the "WAIT UP TO" statement, it is probably not needed and it sets sy-subrc to 0 and also issues a DB commit (see ABAP help for WAIT). Evaluate the return table, if you find the success message, do the commit, otherwise don't.

Thomas

ThomasZloch
Active Contributor
0 Likes

From what I can decipher, you should always call the commit function except when there is errors in the return table.

Checking for the empty table is wrong, as the successful posting will also result in an entry there.

Thomas

Former Member
0 Likes

Hi Friends,

I think you all were cant able to read the code..

Now please check the below code..

Moderator message - keep going

Edited by: Rob Burbank on Sep 22, 2009 2:30 PM

Former Member
0 Likes

The above code is Executing Perfectly...and generating the Accounting Documnet Number.

But the Problem is i cant able to see the Generated Accounting Document Number in FB03.

I had crossed Checked with the G/L Account in FBL3N T.Code and with Customer Number in FBL5N

T.Code. Finally i checked the Data Base Table BKPF & BSEG. But no use. I can't understand where

the problem is...Whether in Customizing or in Table Inconsistency or i have to Send any other

parameter. If we try to post using Standard Transaction FB70 / FB60 it is Posting Successfully.

i mean we can see this A/C Number in FB03, FBl3N, FBl5N and in BKPF & BSEG Tables.

Regards:

Sridhar.J

Former Member
0 Likes

Hi,

I couldn't read your code well because of improper indentation but from what i could read try leaving the following fields blank and post...

*--Reference Transaction

wa_documentheader-obj_type = ''.

*--Reference Key

wa_documentheader-obj_key = ''.

*--Logical system of source document

wa_documentheader-obj_sys = ''.

Hope this helps..

Thanks,

Former Member
0 Likes

Hi Take a look at the and check the parameter

bapiache09-username       = sy-uname.
  bapiache09-bus_act        = 'RMRP'.
  bapiache09-comp_code      = bkpf-bukrs.
  bapiache09-pstng_date     = bkpf-budat.
  bapiache09-doc_date       = bkpf-budat.

***************************************************************************************
* POPULATE THE GL ITEM.

  it_bapiacgl09-itemno_acc = '0000000001'.
  it_bapiacgl09-gl_account = rf05a-konto+6(10).
  it_bapiacgl09-comp_code  = 'RS01'.
  it_bapiacgl09-bus_area   = busa.
  append it_bapiacgl09.
  clear it_bapiacgl09.
  amtp =  -1 * amtp .
  it_bapiaccr09-itemno_acc   = '0000000001'.
  it_bapiaccr09-currency_iso = 'INR'.
  it_bapiaccr09-amt_doccur   = amtp.
  it_bapiaccr09-amt_base     = amtp.
  append it_bapiaccr09.

*************************************************************************************

  it_bapiacap09-itemno_acc   = '0000000002'.
  it_bapiacap09-vendor_no    = rf05a-agkon.
*  it_bapiacap09-PMNTTRMS     = '0001'.
  append it_bapiacap09.
  clear it_bapiacap09.
*lf_inv = -1 * lf_inv.
  it_bapiaccr09-itemno_acc   = '0000000002'.
  it_bapiaccr09-currency_iso = 'INR'.
  it_bapiaccr09-amt_doccur   = lf_inv.
  it_bapiaccr09-amt_base     = lf_inv.
  append it_bapiaccr09.
  clear :it_bapiaccr09.
*****************************************************************************************
  it_bapiacgl09-itemno_acc = '0000000003'.
  it_bapiacgl09-gl_account = '0056000002'.
  it_bapiacgl09-comp_code  = 'RS01'.
  it_bapiacgl09-bus_area   = busa.
  it_bapiacgl09-costcenter = 'D1102'.
  append it_bapiacgl09.
  clear it_bapiacgl09.

  bank_c = -1 * bank_c.
  it_bapiaccr09-itemno_acc   = '0000000003'.
  it_bapiaccr09-currency_iso = 'INR'.
  it_bapiaccr09-amt_doccur   = bank_c.
  it_bapiaccr09-amt_base     = bank_c.
  append it_bapiaccr09.
  clear it_bapiaccr09.
   
 call function 'BAPI_ACC_DOCUMENT_POST'
       exporting
         documentheader          =  bapiache09

       tables
      accountgl              =  it_bapiacgl09[]
      accountpayable         =  it_bapiacap09[]
**   ACCOUNTTAX              =
         currencyamount      =  it_bapiaccr09[]
         return              =  it_return[]  
  endif.
  if sy-subrc = 0 .
    call function 'BAPI_TRANSACTION_COMMIT'.

    leave to list-processing.
    perform refresh.
    loop at it_return .
      write: / it_return-message.
    endloop.
  else.
    leave to list-processing.
    perform refresh.
    loop at it_return .

write: / it_return-message.

endloop.

endif.

with regards

Nilesh

former_member404244
Active Contributor
0 Likes

Hi ,

Are you checking in the same client ..... i don't see any problem with ur code.....

Regards,

Nagaraj

Former Member
0 Likes

Hi Nagraj,

Have u check correctly...

For me also it is Posting Correctly... but after posting i cant able to see the Documnet Number in BKPF or in BSEG Tables.

Regards:

Sridhar.J