08-09-2005 2:42 PM
Hi Gurus,
I am having error message in saving the document using 'BAPI_ACC_DOCUMENT_POST'. The error message coming as :
BAPI call failed - debug and fix!
E 609
Error in document: BKPFF $ S47CLNT800
E 628
Incorrect entry in field OBJ_TYPE: BKPFF
Below is the code i am using for the bapi. Please let me know where i m missing.
Thanks in advance.
Ajay
-
REPORT ZAJ_BAPI_POSTACCDOC.
DATA: doc_header LIKE bapiache09,
doc_item LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,
doc_values LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
extension1 like BAPIEXTC occurs 0 with header line,
obj_type LIKE bapiache09-obj_type,
obj_key LIKE bapiache09-obj_key,
obj_sys LIKE bapiache09-obj_sys,
docnum LIKE bkpf-belnr.
Fill Document Header
doc_header-username = sy-uname.
doc_header-header_txt = 'TEST BAPI POSTING'.
doc_header-comp_code = '1000'.
doc_header-doc_date = '20040920'.
doc_header-pstng_date = sy-datlo.
doc_header-doc_type = 'SA'.
doc_header-bus_act = 'RFBU'.
doc_header-obj_type = 'BKPFF'.
doc_header-obj_key = '$'.
*
concatenate sy-sysid 'CLNT' sy-mandt into doc_header-obj_sys.
Fill Line 1 of Document Item
doc_item-itemno_acc = '1'.
doc_item-gl_account = '0000476000'.
doc_item-pstng_date = sy-datlo.
doc_item-item_text = 'TEST POSTING DEBIT ITEM'.
doc_item-costcenter = '00000010000'.
*doc_item-orderid = 'M5253'.
APPEND doc_item.
CLEAR doc_item.
Fill Line 2 of Document Item
doc_item-itemno_acc = '2'.
doc_item-gl_account = '0000113100'.
doc_item-pstng_date = sy-datlo.
doc_item-item_text = 'TEST POSTING CREDIT ITEM'.
APPEND doc_item.
CLEAR doc_item.
Fill Line 1 of Document Value.
doc_values-itemno_acc = '1'.
doc_values-currency_iso = 'EUR'.
doc_values-amt_doccur = '5.0'.
APPEND doc_values.
CLEAR doc_values.
Fill Line 2 of Document Value
doc_values-itemno_acc = '2'.
doc_values-currency_iso = 'EUR'.
doc_values-amt_doccur = '5.0-'.
APPEND doc_values.
CLEAR doc_values.
Add tax code in extension1 table.
extension1-field1 = 'BAPI CALL'.
APPEND EXTENSION1.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
DOCUMENTHEADER = doc_header
IMPORTING
OBJ_TYPE = doc_header-obj_type
OBJ_KEY = doc_header-obj_key
OBJ_SYS = doc_header-obj_sys
TABLES
ACCOUNTGL = doc_item
CURRENCYAMOUNT = doc_values
EXTENSION1 = extension1
RETURN = return.
LOOP AT return WHERE type = 'E'.
EXIT.
ENDLOOP.
IF sy-subrc EQ 0.
WRITE: / 'BAPI call failed - debug and fix!'.
loop at return.
write : / return-TYPE, return-number,
return-message.
endloop.
ELSE.
CLEAR return.
REFRESH return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT =
IMPORTING
return = return.
WRITE: / 'BAPI call worked!!'.
WRITE: / doc_header-obj_key, ' posted'.
ENDIF.
08-09-2005 2:59 PM
08-09-2005 3:00 PM
Why do you put something in the 'extension1' segment ?
What sort of doc do u post ?
Message was edited by: Erwan LE BRUN