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 BAPI_ACC_DOCUMENT_POST is not posting

Former Member
0 Likes
1,586

Hello,

I have a problem with the BAPI_ACC_DOCUMENT_POST BAPI, when i call it from my code I get a SUCCESSFUL message and the document number created by the BAPI. But when I look in the system for this document, it does not exist.

I am ussing the BAPI_TRANSACTION_COMMIT after BAPI_ACC_DOCUMENT_POST, in fact I tried to code a COMMIT WORK but none of those solutions works.

Please, if you have any idea or solution share it with me.

Best regards.

8 REPLIES 8
Read only

Former Member
0 Likes
1,306

Please make sure you are checking the RETURN table.

Post your code and let us see what you are doing.

Also, is this in your DEV environment?

if so, make sure the company you are posting for is setup correctly for GL entries

Read only

0 Likes
1,306

Hi Keith,

My code is:

sg_doc_header-username   = sy-uname.
  sg_doc_header-header_txt = p_i_index_header-import_text.
  sg_doc_header-comp_code  = p_i_index_header-bukrs.
  sg_doc_header-doc_date   = p_i_index_header-bldat.
  sg_doc_header-pstng_date = p_i_index_header-budat.
  sg_doc_header-doc_type   = c_ka.
  sg_doc_header-ref_doc_no = p_i_index_header-xblnr.

LOOP AT p_t_index_item ASSIGNING <sl_items>.

    sg_accountpay-itemno_acc = c_0010.
    sg_accountpay-vendor_no  = p_i_index_header-lifnr.
    sg_accountpay-comp_code  = <sl_items>-bukrs.
    sg_accountpay-pymt_meth  = c_t.
    sg_accountpay-pmnt_block = c_a.
    sg_accountpay-item_text  = <sl_items>-sgtxt.
    sg_accountpay-po_sub_no  = <sl_items>-ebeln.
    sg_accountpay-po_checkdg = <sl_items>-ebelp.
    sg_accountpay-tax_code   = <sl_items>-tax_code1.
    sg_accountpay-alloc_nmbr = <sl_items>-zuonr.
sg_accountpay-bline_date =  vl_fdtag.

    READ TABLE tl_ekpo WITH KEY ebeln = <sl_items>-ebeln
                                ebelp = <sl_items>-ebelp
     ASSIGNING <sl_ekpo> BINARY SEARCH.
 IF sy-subrc = 0.
      CASE <sl_ekpo>-knttp.
        WHEN c_p.
          sg_accountpay-sp_gl_ind = c_b.
        WHEN OTHERS.
          sg_accountpay-sp_gl_ind = c_a.
      ENDCASE.
    ENDIF.

    APPEND sg_accountpay TO tg_accountpay.
    CLEAR sg_accountpay.

    sg_currency-itemno_acc = c_0010.
    sg_currency-currency = p_i_index_header-waers.
    sg_currency-amt_base = <sl_items>-wrbtr.

    APPEND sg_currency TO tg_currency.
    CLEAR sg_currency.

endloop.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
    EXPORTING
      documentheader = sg_doc_header
    IMPORTING
      obj_type       = vg_obj_type
      obj_key        = vg_obj_key
      obj_sys        = vg_obj_sys
    TABLES
      accountpayable = tg_accountpay
      currencyamount = tg_currency
      return         = tl_return.

READ TABLE tl_return WITH KEY type = c_e TRANSPORTING NO FIELDS.
    IF sy-subrc >< 0.
      IF vg_obj_key IS NOT INITIAL.
        p_successful = c_x.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = c_x
          IMPORTING
            return = sl_return.
      ENDIF.
    ENDIF.

Edited by: Thomas Zloch on Mar 31, 2011 9:30 AM - code tags added, "sy-subrc >< 0" changed

Read only

0 Likes
1,306

Hello,

READ TABLE tl_return WITH KEY type = c_e TRANSPORTING NO FIELDS.

IF sy-subrc 0.

IF vg_obj_key IS NOT INITIAL.

There are a few problems here:

- errors returned in the RETURN table can have type E, A, or X (not just E). You should check for all of these

- the line "IF sy-subrc 0' is not syntactically correct! Was there a problem in pasting the code?

regards

Paul Bakker

Read only

0 Likes
1,306

the line "IF sy-subrc 0' is not syntactically correct! Was there a problem in pasting the code?

&lt;&gt; is being automatically removed from posts because it is interpreted as an HTML tag, I have changed it to >< now.

Thomas

Read only

0 Likes
1,306

Hello,

There is not any problem with the messages validation, the system makes the commit. But when I'm looking for the document I can not find it.

My example is for posting a FB65 document.

Best regards

Read only

0 Likes
1,306

Can you see if there were any documents posted on the day in question? Just look at the date of entry only.

Rob

Read only

0 Likes
1,306

CORRECTION: I have to post a F-47 document using the BAPI, i just have ONE position.

Read only

Former Member
0 Likes
1,306

Hi Daniel,

Have you tried with commit work and wait?

Regards,

Ernesto.