‎2011 Jan 07 9:51 AM
Hi Experts,
I am new to interfaces like bapi, I tried a program for BAPI_ACC_DOCUMENT_POST to update AR, when i trying to execute it is displayng as "PROBLEM OCCURED".
Here i am giving program code, so please see the program and reslove my eror.
<removed by moderator>
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 bapiacar09 OCCURS 0 WITH HEADER LINE,
accountreceivable LIKE bapiacar09 OCCURS 0 WITH HEADER LINE,
currencyamount LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,
return LIKE bapiret2 OCCURS 0 WITH HEADER LINE,
extension1 LIKE bapiextc OCCURS 0 WITH HEADER LINE,
t_edidd LIKE edidd OCCURS 0 WITH HEADER LINE,
bapi_retn_info LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: error_flag.
documentheader-username = sy-uname.
documentheader-header_txt = 'Test BAPI'.
documentheader-comp_code = 'SERC'.
documentheader-doc_date = sy-datum.
documentheader-pstng_date = '10.09.2010'.
documentheader-doc_type = 'DR'.
CLEAR accountgl.
accountgl-itemno_acc = '1'.
accountgl-gl_account = '100100'.
accountgl-ref_key_1 = 'TEST'.
accountgl-comp_code = 'S150'.
accountgl-pstng_date = sy-datum.
accountgl-doc_type = 'DR'.
accountgl-customer = '2001'.
APPEND accountgl.
CLEAR accountgl.
CLEAR accountreceivable.
accountreceivable-itemno_acc = '1'.
accountreceivable-customer = '2001'.
accountreceivable-gl_account = '100100'.
accountreceivable-comp_code = 'S150'.
APPEND accountreceivable.
CLEAR accountreceivable.
APPEND currencyamount.
currencyamount-itemno_acc = '1'.
currencyamount-currency = 'INR'.
currencyamount-amt_doccur = '1000'.
APPEND currencyamount.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
* CUSTOMERCPD =
* CONTRACTHEADER =
IMPORTING
OBJ_TYPE = obj_type
OBJ_KEY = obj_key
OBJ_SYS = obj_sys
TABLES
accountgl = accountgl
accountreceivable = accountreceivable
* ACCOUNTPAYABLE =
* ACCOUNTTAX =
currencyamount = currencyamount
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
return = return
* PAYMENTCARD =
* CONTRACTITEM =
* EXTENSION2 =
* REALESTATE =
* ACCOUNTWT =
.
IF sy-subrc <> 0.
WRITE 'Problem occured'.
ELSE.
*LOOP AT return.*
*IF NOT return IS INITIAL.*
*CLEAR bapi_retn_info.*
*MOVE-CORRESPONDING return TO bapi_retn_info.*
*IF return-type = 'A' OR return-type = 'E'.*
*error_flag = 'X'.*
*ENDIF.*
*APPEND bapi_retn_info.*
*ENDIF.*
*ENDLOOP.* (in this block i find error)
IF error_flag = 'X'.
WRITE 'Problem occured'.
ROLLBACK WORK.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
ENDIF.
ENDIF.Thanks in Advance,
gsreddy.
Edited by: Thomas Zloch on Jan 7, 2011 11:01 AM - please use code tags
‎2011 Jan 07 11:48 AM
*LOOP AT return.*
*IF NOT return IS INITIAL.*
*CLEAR bapi_retn_info.*
*MOVE-CORRESPONDING return TO bapi_retn_info.*
*IF return-type = 'A' OR return-type = 'E'.*
*error_flag = 'X'.*
*ENDIF.*
*APPEND bapi_retn_info.*
*ENDIF.*
*ENDLOOP.* (in this block i find error)
Uncomment the above code and check the errors in itab 'return' in debugging mode.
If are not able to resolve the error let us know what errors you are getting
Regards
Praveen
‎2011 Jan 07 12:35 PM
Hi Praveen,
Thanks for you reply, in the thread by mistake it was commented,
and i run the program in uncomment mode only, and error is displaying like "error occured"
(it displaying the write statement in 'IF 'block).
i did debug also, but i am not able to reslove the error.
<removed by moderator>
regards,
gsreddy.
Edited by: Thomas Zloch on Jan 7, 2011 1:52 PM - please no "needful" in these forums
‎2011 Jan 07 1:50 PM
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = documentheader
* CUSTOMERCPD =
* CONTRACTHEADER =
IMPORTING
OBJ_TYPE = obj_type
OBJ_KEY = obj_key
OBJ_SYS = obj_sys
TABLES
accountgl = accountgl
accountreceivable = accountreceivable
* ACCOUNTPAYABLE =
* ACCOUNTTAX =
currencyamount = currencyamount
* CRITERIA =
* VALUEFIELD =
* EXTENSION1 =
return = return
* PAYMENTCARD =
* CONTRACTITEM =
* EXTENSION2 =
* REALESTATE =
* ACCOUNTWT =
.
In the BAPI tables parameter "return" what are the messages you are seeing in debugging mode???
‎2011 Jan 07 3:52 PM
SY-SUBRC is not relevant. Why do you check that and what is the condition? The 'NE' or 'EQ' is missing in your post. You've also hard-coded a customer account w/o leading zeros and hardcoded a date in the incorrect format - that's not correct. Otherwise, review some of that many examples in the forum or check the error messages as has already been suggested twice.