‎2011 Mar 30 7:31 PM
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.
‎2011 Mar 30 7:54 PM
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
‎2011 Mar 30 8:06 PM
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
‎2011 Mar 31 7:19 AM
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
‎2011 Mar 31 8:32 AM
the line "IF sy-subrc 0' is not syntactically correct! Was there a problem in pasting the code?
<> is being automatically removed from posts because it is interpreted as an HTML tag, I have changed it to >< now.
Thomas
‎2011 Mar 31 5:58 PM
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
‎2011 Mar 31 6:37 PM
Can you see if there were any documents posted on the day in question? Just look at the date of entry only.
Rob
‎2011 Mar 31 9:10 PM
CORRECTION: I have to post a F-47 document using the BAPI, i just have ONE position.
‎2011 Mar 30 7:54 PM
Hi Daniel,
Have you tried with commit work and wait?
Regards,
Ernesto.