Hallo nochmal!
Der Aufruf über die SE37 hat jetzt funktioniert (ole!), ABER: Wenn ich das ganze in einen Report packe, erhalte ich folgende Meldung "Sachkonto 405201 ist im Kontenplan INT nicht vorgesehen" (ein Test in VBA gibt den gleichen Fehler...). Das Konto finde ich aber sehr wohl im Kontenplan INT, wenn ich z.B. über die FB01 gehe.
Verstehe nicht, dass es in der SE37 geht und sonst nicht
Hab meinen Testreport anbei gepackt
Frank
------------------------------------------
REPORT z_fuba_tmp.
DATA:
obj_type LIKE BAPIACHE09-obj_type,
obj_key LIKE BAPIACHE09-obj_key,
obj_sys LIKE BAPIACHE09-obj_sys,
documentheader LIKE BAPIACHE09,
accountgl LIKE BAPIACGL09 OCCURS 0 WITH HEADER LINE,
accountpayable LIKE bapiacap09 OCCURS 0 WITH HEADER LINE,
currencyamount LIKE BAPIACCR09 OCCURS 0 WITH HEADER LINE,
return LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.
DATA: error_flag.
" ********* documentheader *********
documentheader-bus_act = 'RMRP'.
documentheader-username = sy-uname.
documentheader-header_txt = 'Test using BAPI 2'.
documentheader-comp_code = '0001'.
documentheader-doc_date = sy-datum.
documentheader-pstng_date = sy-datum.
documentheader-doc_type = 'KR'.
" ********* ACCOUNTPAYABLE *********
accountpayable-ITEMNO_ACC = '0000000001'.
accountpayable-VENDOR_NO = 'ABVEND00'.
APPEND accountpayable.
" ********* accountgl *********
accountgl-itemno_acc = '0000000002'.
accountgl-gl_account = '405201'.
accountgl-doc_type = 'KR'.
accountgl-comp_code = '0001'.
accountgl-pstng_date = sy-datum.
accountgl-tax_code = 'V0'.
accountgl-costcenter = 'SAP-DUMMY'.
APPEND accountgl.
" ********* currencyamount *********
currencyamount-itemno_acc = '0000000001'.
currencyamount-currency = 'EUR'.
currencyamount-amt_doccur = '100.00'.
APPEND currencyamount.
currencyamount-itemno_acc = '0000000002'.
currencyamount-currency = 'EUR'.
currencyamount-amt_doccur = '-100.00'.
APPEND currencyamount.
* call BAPI-function in this system *
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
IMPORTING
obj_type = obj_type
obj_key = obj_key
obj_sys = obj_sys
TABLES
accountpayable = accountpayable
accountgl = accountgl
currencyamount = currencyamount
return = return
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE e999(re) WITH 'Problem occured'.
ELSE.
LOOP AT return.
IF NOT return IS INITIAL.
IF return-type = 'A' OR return-type = 'E'.
write: return-MESSAGE.
error_flag = 'X'.
ENDIF.
ENDIF.
ENDLOOP.
IF error_flag = 'X'.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
ENDIF.