09-28-2005 10:16 AM
Hi,
I want to be able to use the bapi with tax. I have the following code which gives me the result: E FF 747 Tax amount must not be greater than the tax base.
Its not clear to me what i do wrong when filling the tables for the bapi. Any help will be appreciated.
FORM FILL_INTERNAL_TABLES.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
OWN_LOGICAL_SYSTEM = GD_DOCUMENTHEADER-OBJ_SYS.
fill header
GD_DOCUMENTHEADER-OBJ_TYPE = 'BKPFF'.
GD_DOCUMENTHEADER-OBJ_KEY = REF_KEY.
GD_DOCUMENTHEADER-USERNAME = SY-UNAME.
GD_DOCUMENTHEADER-HEADER_TXT = 'AHJD BAPI Test'.
GD_DOCUMENTHEADER-COMP_CODE = 'A14'.
GD_DOCUMENTHEADER-DOC_DATE = '20050927'.
GD_DOCUMENTHEADER-PSTNG_DATE = '20050927'.
GD_DOCUMENTHEADER-DOC_TYPE = 'KR'.
fill AP (line 1)
IT_ACCOUNTPAYABLE-ITEMNO_ACC = 1.
IT_ACCOUNTPAYABLE-VENDOR_NO = '0000001001'.
IT_ACCOUNTPAYABLE-PMNTTRMS = '30'.
IT_ACCOUNTPAYABLE-ITEM_TEXT = 'AP BAPI Test'.
APPEND IT_ACCOUNTPAYABLE.
IT_CURRENCYAMOUNT-ITEMNO_ACC = 1.
IT_CURRENCYAMOUNT-CURR_TYPE = '00'.
IT_CURRENCYAMOUNT-CURRENCY = 'EUR'.
IT_CURRENCYAMOUNT-AMT_DOCCUR = -119.
APPEND IT_CURRENCYAMOUNT.
fill GL (line 2)
IT_ACCOUNTGL-ITEMNO_ACC = 2.
IT_ACCOUNTGL-GL_ACCOUNT = '0043419002'.
IT_ACCOUNTGL-ITEM_TEXT = 'GL BAPI Test'.
IT_ACCOUNTGL-COSTCENTER = '0000514200'.
APPEND IT_ACCOUNTGL.
IT_CURRENCYAMOUNT-ITEMNO_ACC = 2.
IT_CURRENCYAMOUNT-CURR_TYPE = '00'.
IT_CURRENCYAMOUNT-CURRENCY = 'EUR'.
IT_CURRENCYAMOUNT-AMT_DOCCUR = 100.
APPEND IT_CURRENCYAMOUNT.
fill tax
IT_ACCOUNTTAX-ITEMNO_ACC = 3.
IT_ACCOUNTTAX-TAX_CODE = 'BA'.
APPEND IT_ACCOUNTTAX.
IT_CURRENCYAMOUNT-ITEMNO_ACC = 3.
IT_CURRENCYAMOUNT-CURR_TYPE = '00'.
IT_CURRENCYAMOUNT-CURRENCY = 'EUR'.
IT_CURRENCYAMOUNT-AMT_DOCCUR = 19.
IT_CURRENCYAMOUNT-AMT_BASE = 100.
APPEND IT_CURRENCYAMOUNT.
09-28-2005 10:23 AM
Hi,
In SAP every GL account is associated with a certain tax.
When you try to upload new information via the BAPI you enter a taxamount manually. However this is checked against the rule on the GL-account associated tax-rate. If it differs too much this error can occur.
09-28-2005 10:26 AM
Hi Bert
Tax is a tricky part with this BAPI. The key is to append the tax as the last line item.
check out this link...
http://www.sapfans.com/sapfans/forum/intface/messages/4192.html
hope this helps
Abhishek
11-08-2005 5:12 PM
Hi all, And thanks in advance,
We have been reading about this bapi to make an INVOICE. We use it and the table "return" , returns OK, so we supposed the invoice was created with its own invoice number, that´s to say BELNR (this number is inside the range than we have defined for the doc. type ). After that, when we access the BKPF table, the invoice is not there, we can´t find it. Can anyone tell me what´s going wrong?.
REPORT ztestbapi01 .
TABLES bkpf.
PARAMETERS: bukrs LIKE lfb1-bukrs DEFAULT 'PS01' OBLIGATORY.
DATA: header LIKE bapiache03,
acc_pay LIKE bapiacap03 OCCURS 0 WITH HEADER LINE,
acc_tgl LIKE bapiacgl03 OCCURS 0 WITH HEADER LINE,
acc_tax LIKE bapiactx01 OCCURS 0 WITH HEADER LINE,
cur_amo LIKE bapiaccr01 OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
porder LIKE bapiacpo00 OCCURS 0 WITH HEADER LINE,
ext_doc LIKE bapiacdockey OCCURS 0 WITH HEADER LINE,
obj_type LIKE bapiache03-obj_type,
obj_key LIKE bapiache03-obj_key,
obj_sys LIKE bapiache03-obj_sys.
START-OF-SELECTION.
FORM fill_header USING head STRUCTURE bapiache03.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = head-obj_sys
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
head-username = sy-uname.
head-header_txt = 'Prueba de App Cont Bapi'.
head-comp_code = bukrs.
head-fisc_year = '2005'.
head-doc_date = sy-datum.
head-pstng_date = sy-datum.
head-fis_period = '11'.
head-doc_type = 'HM'.
head-obj_type = 'BKPFF '.
head-obj_key = '100000036PS012005'.
head-ac_doc_no = '1000000036'.
ENDFORM. " fill_header
FORM fill_acc_tgl.
acc_tgl-itemno_acc = '002'.
acc_tgl-gl_account = '0000606000'.
acc_tgl-comp_code = bukrs.
acc_tgl-tax_code = 'SC'.
APPEND acc_tgl.
ENDFORM. " fill_acc_tgl
FORM fill_cur_amo.
cur_amo-itemno_acc = '001'.
cur_amo-currency = cur_amo-currency_iso = 'EUR'.
cur_amo-curr_type = '00'.
cur_amo-amt_doccur = 69.
cur_amo-amt_base = 69.
APPEND cur_amo.
cur_amo-itemno_acc = '002'.
cur_amo-currency = cur_amo-currency_iso = 'EUR'.
cur_amo-curr_type = '00'.
cur_amo-amt_doccur = 69.
cur_amo-amt_base = 69.
APPEND cur_amo.
ENDFORM. " fill_cur_amo
FORM fill_acc_pay.
acc_pay-itemno_acc = '001'.
acc_pay-vendor_no = '0007759049'.
acc_pay-gl_account = '0000400004'.
acc_pay-pmnttrms = '0001'.
acc_pay-bline_date = sy-datum.
acc_pay-pymt_meth = 'W'.
acc_pay-pmnt_block = 'A'.
acc_pay-alloc_nmbr = '20051102'.
APPEND acc_pay.
ENDFORM. " fill_acc_pay
PERFORM fill_header USING header.
PERFORM fill_acc_pay.
PERFORM fill_acc_tgl.
PERFORM fill_cur_amo.
CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_CHECK'
EXPORTING
documentheader = header
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountpayable = acc_pay
accountgl = acc_tgl
accounttax = acc_tax
currencyamount = cur_amo
return = return.
LOOP AT return.
WRITE: / return-type, return-id, return-number, return-message.
ENDLOOP.
CALL FUNCTION 'BAPI_ACC_INVOICE_RECEIPT_POST'
EXPORTING
documentheader = header
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountpayable = acc_pay
accountgl = acc_tgl
accounttax = acc_tax
currencyamount = cur_amo
return = return.
LOOP AT return.
WRITE: / return-type, return-id, return-number, return-message.
ENDLOOP.
REFRESH return. CLEAR return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = return.
LOOP AT return.
WRITE: / return-type, return-id, return-number, return-message.
ENDLOOP.
11-08-2005 6:02 PM
Hi,
We have also tried to:
**************************
head-obj_type = ''.
head-obj_key = ''.
head-ac_doc_no = ''.
head-obj_sys = ''.
*******************************
and we obtained the same result as before.
11-09-2005 11:29 AM
We have find a note talking about this problem,
note 884246. We´ll try to probe it.
02-21-2006 4:03 PM