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_INVOICE_RECEIPT_POST Error..!

Former Member
0 Likes
898

Hi Guys,

               I am trying post an Invoice for Employee Vendor in AP.

Here is my code.

FUNCTION ztm_post_ta.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(PERNR) TYPE  LFB1-PERNR
*"     REFERENCE(WAGE_TYPE) TYPE  WAGETYPE
*"     REFERENCE(DOC_DATE) TYPE  BLDAT
*"     REFERENCE(AMOUNT) TYPE  NETPR
*"----------------------------------------------------------------------
** Reference: have a look at standard report ACC_BAPI_TEST_INVOICE_RECEIPT.
  CONSTANTS: lc_bukrs TYPE bukrs VALUE 'CC01'.
  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_account_payable.
  DATA: wa_account_payable LIKE bapiacap03.
  DATA: wa_account_gl LIKE bapiacgl03.
  DATA: wa_currency_amount LIKE bapiaccr01.
  DATA: lv_fiscalyr TYPE gjahr,
        lv_period TYPE monat,
        lv_lifnr TYPE lifnr,
        lv_gl_acc TYPE saknr,
        lv_amount TYPE netpr.
* get fiscal year and period - (requires date and company code)
  CALL FUNCTION 'BAPI_COMPANYCODE_GET_PERIOD'
    EXPORTING
      companycodeid = lc_bukrs
      posting_date  = doc_date
    IMPORTING
      fiscal_year   = lv_fiscalyr
      fiscal_period = lv_period.
** fill document header.
  document_header-username = sy-uname."mandatory
  document_header-comp_code = lc_bukrs."mandatory
  document_header-fisc_year = lv_fiscalyr.
  document_header-doc_date = doc_date.
  document_header-pstng_date = doc_date. "mandatory
  document_header-fis_period = lv_period.
  document_header-doc_type = 'KR'.   "mandatory
  SELECT SINGLE lifnr FROM lfb1 INTO lv_lifnr
    WHERE pernr = pernr.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = lv_lifnr
    IMPORTING
      output = lv_lifnr.
** Fill Vendor details (Accounts Payable)
  wa_account_payable-itemno_acc = '0000000010'.
  wa_account_payable-vendor_no = lv_lifnr.      "mandatory
  APPEND wa_account_payable TO account_payable.
  SELECT SINGLE gl_account FROM ztm_wagetyp_gl INTO lv_gl_acc
    WHERE wage_type = wage_type.
  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
    EXPORTING
      input  = lv_gl_acc
    IMPORTING
      output = lv_gl_acc.
** fill GL account details
  wa_account_gl-itemno_acc = '0000000020'.
  wa_account_gl-gl_account = lv_gl_acc."mandatory
  wa_account_gl-pstng_date = doc_date."mandatory
  APPEND wa_account_gl TO account_gl.
** Fill currency details
  wa_currency_amount-itemno_acc = '0000000010'.
  wa_currency_amount-currency = 'AUD'.           "mandatory
  wa_currency_amount-amt_doccur = amount.
  APPEND wa_currency_amount TO currency_amount.
  lv_amount = amount * -1.
  wa_currency_amount-itemno_acc = '0000000020'.
  wa_currency_amount-currency = 'AUD'.            "mandatory
  wa_currency_amount-amt_doccur = lv_amount.
  APPEND wa_currency_amount TO currency_amount.
  CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_POST'
    EXPORTING
      documentheader = document_header
    TABLES
      accountpayable = account_payable
      accountgl      = account_gl
      accounttax     = account_tax "pode ir vazio
      currencyamount = currency_amount
      return         = t_return.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      wait = 'X'.
ENDFUNCTION.

Getting the following error

I checked that the vendor has been assigned to the company code CC01, but still throwing that error.

Thanks

Sam

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
772

Do the error messages not sound clear enough?

- The vendor does not exist in the company - check LFB1 just after selecting from LFA1. (*)

(Also remove the call to CONVERSION_EXIT_ALPHA_INPUT as you read data from database value is already in internal format.)

- Check the GL account, it is associated to a primary cost element in controlling, check field status group and ask functional to identify a correct assignment like cost center, order, wbs, etc.

(Check your ztm_wagetyp_gl table for a field like a cost-center in its definition.)

Regards,

Raymond

(*) I read again your post, so add BUKRS in your where clause.

3 REPLIES 3
Read only

RaymondGiuseppi
Active Contributor
0 Likes
773

Do the error messages not sound clear enough?

- The vendor does not exist in the company - check LFB1 just after selecting from LFA1. (*)

(Also remove the call to CONVERSION_EXIT_ALPHA_INPUT as you read data from database value is already in internal format.)

- Check the GL account, it is associated to a primary cost element in controlling, check field status group and ask functional to identify a correct assignment like cost center, order, wbs, etc.

(Check your ztm_wagetyp_gl table for a field like a cost-center in its definition.)

Regards,

Raymond

(*) I read again your post, so add BUKRS in your where clause.

Read only

0 Likes
772

I missed few things like Dynamic Cost center assignment to the GL Account and Reference Document No.

Now its posting successfully.

Thanks

Sam

Read only

bharat_rathod2
Active Participant
0 Likes
772

Dear,

You have to assign Account asignment 50103 to CO object through oby* tcode.