Skip to Content
Former Member
Aug 23, 2012 at 05:26 AM



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.




Vendor Error.JPG (44.4 kB)