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_INVOICE_RECEIPT_POST creates document but doesnt apear in fb60

Former Member
0 Kudos
731

I am working on putting together a program that will allow users to upload invoices from a spreadsheet into SAP.

accordingly to this thread I should use BAPI_ACC_INVOICE_RECEIPT_POST. (and so I did)

The program seems to be working fine, the return table sends a message telling me the document XXXX has been created, however when I go check it in fb60 it tells me that the document does not exist...

Here he's my "playground" program to test this BAPI

REPORT  zsl_teste.
 
DATA: document_header LIKE bapiache03,
      account_payable LIKE bapiacap03 OCCURS 0,
      account_gl      LIKE bapiacgl03 OCCURS 0,
      account_tax     LIKE bapiactx01 OCCURS 0,
      currency_amount LIKE bapiaccr01 OCCURS 0,
      t_return        LIKE bapiret2 OCCURS 0.
 
PERFORM fill_document_header.
PERFORM fill_account_payable.
PERFORM fill_account_gl.
 
PERFORM fill_currency_amount.
 
CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_POST'
  EXPORTING
    documentheader       = document_header
*   CUSTOMERCPD          = "optional
* IMPORTING
*   OBJ_TYPE             = "optional
*   OBJ_KEY              = "optional
*   OBJ_SYS              = "optional
  TABLES
    accountpayable       = account_payable
    accountgl            = account_gl
    accounttax           = account_tax"pode ir vazio
    currencyamount       = currency_amount
*   PURCHASEORDER        = "optional
*   PURCHASEAMOUNT       = "optional
    return               = t_return
*   CRITERIA             = "optional
*   VALUEFIELD           = "optional
*   EXTENSION1           = "optional
.
 
BREAK-POINT.
 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.
 
*&---------------------------------------------------------------------*
*&      Form  fill_document_header
*&---------------------------------------------------------------------*
FORM fill_document_header .
 
*  document_header-obj_type.
*  document_header-obj_key.
*  document_header-obj_sys.
  document_header-username = sy-uname."mandatory
  document_header-comp_code = 'Z001'."mandatory
  document_header-pstng_date = '20100611'."mandatory
  document_header-doc_type = 'WA'."mandatory
 
ENDFORM.                    " fill_document_header
*&---------------------------------------------------------------------*
*&      Form  fill_account_payable
*&---------------------------------------------------------------------*
FORM fill_account_payable .
 
  DATA: wa_account_payable LIKE bapiacap03.
 
  wa_account_payable-itemno_acc = ''.
  wa_account_payable-vendor_no = '100010'."mandatory
 
  APPEND wa_account_payable TO account_payable.
 
ENDFORM.                    " fill_account_payable
*&---------------------------------------------------------------------*
*&      Form  fill_account_gl
*&---------------------------------------------------------------------*
FORM fill_account_gl .
 
  DATA: wa_account_gl LIKE bapiacgl03.
 
  wa_account_gl-itemno_acc = ''.
  wa_account_gl-gl_account = '221000'."mandatory
  wa_account_gl-pstng_date = '20100612'."mandatory
 
  APPEND wa_account_gl TO account_gl.
 
ENDFORM.                    " fill_account_gl
*&---------------------------------------------------------------------*
*&      Form  fill_currency_amount
*&---------------------------------------------------------------------*
FORM fill_currency_amount .
 
  DATA: wa_currency_amount LIKE bapiaccr01.
 
  wa_currency_amount-currency = 'EUR'."mandatory
 
  APPEND wa_currency_amount TO currency_amount.
 
ENDFORM.                    " fill_currency_amount

I've put a break-point so that you can check t_return at that point and see the number of the document created.

But I can't find it neither on FB60 (where I think It should be) neither on mir4 like suggested before.

isn't this the appropriate BAPI to create vendor invoices in FB60?

8 REPLIES 8

Former Member
0 Kudos
118

As anyone done something similar? I dont know were else to look for an answer

0 Kudos
118

Is there a difference betwen Posting an invoice and creating an invoice??

0 Kudos
118

Hi RgnaRock,

Could you resolve this problem even iam facing similar kind of problem, BAPI is creating document number but it is not appearing in FB03/FB60 and not even in BKPF table also.

Could you help me if you resolve the issue pls.

0 Kudos
118

Hi,

have a look at standard report ACC_BAPI_TEST_INVOICE_RECEIPT.

Best regards.

0 Kudos
118

the problem is related with currency_amount-amt_doccur if its initial the document doesnt appear anywere

you can try this working code, as a test report:

REPORT  zsl_teste5.

DATA: document_header LIKE bapiache03,
      account_payable LIKE bapiacap03 OCCURS 0,
      account_gl      LIKE bapiacgl03 OCCURS 0,
      account_tax     LIKE bapiactx01 OCCURS 0,
      currency_amount LIKE bapiaccr01 OCCURS 0,
      t_return        LIKE bapiret2 OCCURS 0.

PERFORM fill_document_header.
PERFORM fill_account_payable.
PERFORM fill_account_gl.

PERFORM fill_currency_amount.

CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_POST'
  EXPORTING
    documentheader       = document_header
*   CUSTOMERCPD          = "optional
* IMPORTING
*   OBJ_TYPE             = "optional
*   OBJ_KEY              = "optional
*   OBJ_SYS              = "optional
  TABLES
    accountpayable       = account_payable
    accountgl            = account_gl
    accounttax           = account_tax"pode ir vazio
    currencyamount       = currency_amount
*   PURCHASEORDER        = "optional
*   PURCHASEAMOUNT       = "optional
    return               = t_return
*   CRITERIA             = "optional
*   VALUEFIELD           = "optional
*   EXTENSION1           = "optional
.

BREAK-POINT.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
  EXPORTING
    wait = 'X'.

*&---------------------------------------------------------------------*
*&      Form  fill_document_header
*&---------------------------------------------------------------------*
FORM fill_document_header .

  document_header-username = sy-uname."mandatory
  document_header-comp_code = 'Z001'."mandatory
  document_header-fisc_year = '2010'.
  document_header-doc_date = '20100610'.
  document_header-pstng_date = '20100610'."mandatory
  document_header-fis_period = '06'.
  document_header-doc_type = 'KR'."mandatory


ENDFORM.                    " fill_document_header
*&---------------------------------------------------------------------*
*&      Form  fill_account_payable
*&---------------------------------------------------------------------*
FORM fill_account_payable .

  DATA: wa_account_payable LIKE bapiacap03.

  wa_account_payable-itemno_acc = '0000000010'.
  wa_account_payable-vendor_no = '0000100014'."mandatory

  APPEND wa_account_payable TO account_payable.

ENDFORM.                    " fill_account_payable
*&---------------------------------------------------------------------*
*&      Form  fill_account_gl
*&---------------------------------------------------------------------*
FORM fill_account_gl .

  DATA: wa_account_gl LIKE bapiacgl03.

  wa_account_gl-itemno_acc = '0000000020'.
  wa_account_gl-gl_account = '0000712000'."mandatory
  wa_account_gl-pstng_date = '20100610'."mandatory

  APPEND wa_account_gl TO account_gl.

ENDFORM.                    " fill_account_gl
*&---------------------------------------------------------------------*
*&      Form  fill_currency_amount
*&---------------------------------------------------------------------*
FORM fill_currency_amount .

  DATA: wa_currency_amount LIKE bapiaccr01.

  wa_currency_amount-itemno_acc = '0000000010'.
  wa_currency_amount-currency = 'EUR'."mandatory
  wa_currency_amount-amt_doccur = '10'.

  APPEND wa_currency_amount TO currency_amount.

  wa_currency_amount-itemno_acc = '0000000020'.
  wa_currency_amount-currency = 'EUR'."mandatory
  wa_currency_amount-amt_doccur = '-10'.

  APPEND wa_currency_amount TO currency_amount.

ENDFORM.                    " fill_currency_amount

for me, it worked

0 Kudos
118

Hi RgnaRock,

Could you resolve this problem even iam facing similar kind of problem, BAPI is creating document number but it is not appearing in FB03/FB60 and not even in BKPF table also.

Could you help me if you resolve the issue pls.

0 Kudos
118

you can try to use the code above your post,

all you have to do is change some values to match your system (like the vendor number, etc)

that code worked for me

And like I said before, the problem was I was creating invoices without "amounts" so make sure you have some in the currency tables

0 Kudos
118

you can try to use the code above your post,

all you have to do is change some values to match your system (like the vendor number, etc)

that code worked for me

And like I said before, the problem was I was creating invoices without "amounts" so make sure you have some in the currency tables