05-25-2017 5:47 PM
I know many questions have been asked about this BAPI, I've done countless searches but all the questions are advanced compared to where I am at, so here it goes..
These are the errors I am getting in BAPI return tables generated by the code below.
NOTE: when I entered these exact same parameters in the "BAPI" transaction test run, posting was actually successful.
report zpost
TYPE-POOLS truxs.
"declaring tables to be passed to BAPI
data:
DOCUMENTHEADER LIKE BAPIACHE09 occurs 0 WITH HEADER LINE,
ACCOUNTGL LIKE BAPIACGL09 occurs 0 with HEADER LINE,
CURRENCYAMOUNT LIKE BAPIACCR09 occurs 0 with HEADER LINE,
"declare working areas for each of the above tables.
wa_DOCUMENTHEADER type BAPIACHE09,
wa_ACCOUNTGL type BAPIACGL09,
wa_CURRENCYAMOUNT type BAPIACCR09,
"BAPI return table
return type table of bapiret2 WITH HEADER LINE.
"populate BAPI manually
wa_DOCUMENTHEADER-username = 'ADEL'.
wa_DOCUMENTHEADER-header_txt = 'header1'.
wa_DOCUMENTHEADER-comp_code = 'amle'.
wa_DOCUMENTHEADER-DOC_DATE = '250517'.
wa_DOCUMENTHEADER-PSTNG_DATE = '250517'.
wa_DOCUMENTHEADER-DOC_TYPE = 'SA'.
append wa_DOCUMENTHEADER to DOCUMENTHEADER.
wa_ACCOUNTGL-ITEMNO_ACC = 1.
wa_ACCOUNTGL-GL_ACCOUNT = '410010000'.
wa_ACCOUNTGL-ITEM_TEXT = 'item test'.
wa_ACCOUNTGL-PROFIT_CTR = 'Z010101040'.
append wa_accountgl to accountgl.
wa_ACCOUNTGL-ITEMNO_ACC = 2 .
wa_ACCOUNTGL-GL_ACCOUNT = '121201300'.
wa_ACCOUNTGL-ITEM_TEXT = 'item test'.
append wa_accountgl to accountgl.
wa_CURRENCYAMOUNT-ITEMNO_ACC = 1.
wa_currencyamount-CURRENCY = 'EGP'.
wa_currencyamount-AMT_DOCCUR = '-1000.0'.
wa_currencyamount-AMT_BASE = '-1000.0'.
append wa_CURRENCYAMOUNT to currencyamount.
wa_CURRENCYAMOUNT-ITEMNO_ACC = 2.
wa_currencyamount-CURRENCY = 'EGP'.
wa_currencyamount-AMT_DOCCUR = '1000.0'.
wa_currencyamount-AMT_BASE = '1000.0'.
append wa_CURRENCYAMOUNT to currencyamount.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
* CUSTOMERCPD =
* CONTRACTHEADER =
* IMPORTING
* OBJ_TYPE =
* OBJ_KEY =
* OBJ_SYS =
tables
* ACCOUNTGL =
* ACCOUNTRECEIVABLE =
* ACCOUNTPAYABLE =
* ACCOUNTTAX =
currencyamount = currencyamount
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
return = return
* PAYMENTCARD =
* CONTRACTITEM =
* EXTENSION2 =
* REALESTATE =
* ACCOUNTWT =
.<<<<breakpoint-here for debugging
05-25-2017 7:41 PM
Why are you doing APPEND? DOCUMENTHEADER is a structure, not a table. You don't need the WA_... part at all there.
05-29-2017 7:57 AM
Reread your code more carefully.
05-26-2017 4:09 PM
Hi Karim,
Please review your code and below link give you some idea.
https://blogs.sap.com/2013/07/23/accounttax-in-bapiaccdocumentpost/
05-26-2017 5:45 PM
05-26-2017 6:40 PM
05-27-2017 2:03 AM
wa_DOCUMENTHEADER-PSTNG_DATE ='250517'.
Maybe this is the issue place because of the wrong key in.