2008 Jul 21 5:58 AM
Hi experts,
I should do the error handling for commit work.
These are the statements used in my program.
Could you please suggest how to handle this for commit work
error handling or exeception. Put your valuable suggestions.
LOOP AT it_header INTO wa_header WHERE va_load EQ space.
MOVE-CORRESPONDING wa_header TO wa_header1.
wa_header1-va_load = co_on.
READ TABLE it_purord INTO wa_purord
WITH KEY object_id = wa_header-object_id.
CALL FUNCTION 'BBP_PD_PO_UPDATE'
EXPORTING
i_header = wa_header1
i_save = co_on
IMPORTING
es_header = wa_header.
*
Save the download status in the header
*
CALL FUNCTION 'BBP_PD_PO_SAVE'
EXPORTING
iv_header_guid = wa_purord-guid.
COMMIT WORK.
ENDLOOP.
2008 Jul 21 6:03 AM
before writing commit work..check if sy-subrc eq 0. then write commit work.
2008 Jul 21 6:03 AM
before writing commit work..check if sy-subrc eq 0. then write commit work.
2008 Jul 21 6:09 AM
hi
good
commit work is used mainly in case of database changes...
if in the report at certain point you want to make chages to databasethen you can use commit work....to update changes to your database.....
The Commit work is a default process what would happen whenever you try to update the database.
I would suggest you to use the sy-subrc before the function module to check the status of the commit work.
Thanks
mrutyun^
2008 Jul 21 6:28 AM
What happens if the commit work fails . how to handle that exeception. or in other words.
If i use commit work or any other related commit work statments in my program , i have to handle that exception if its failed to commit
See also the following code which uses commit work . i want to handle exclusively for the commit work statment alone....
CREATE OBJECT prxy.
TRY.
do asynchronous client proxy call
CALL METHOD prxy->execute_asynchronous
EXPORTING
output = it_grinfo.
COMMIT WORK.
MESSAGE i015(zebp).
Error handling
CATCH cx_ai_system_fault INTO fault.
CREATE OBJECT fault.
lv_msg_text = fault->get_text( ).
MESSAGE i012(zebp) WITH lv_msg_text.
RETURN.
WRITE:/ fault->errortext.
ENDTRY.
ENDIF.
ENDFORM. "USER_COMMAND
2008 Jul 21 7:46 AM
Also let me know how to use commit work and wait
and the corresponding exception / error handling for this statmement
2008 Jul 21 8:04 AM
Can we use commit work inside a try catch statment.
If so how do use that inside a try catch . Please give an example
Useful answers will sure be rewarded
2008 Jul 21 6:14 AM
Hi,
Check the link
http://help.sap.com/saphelp_nw2004s/helpdata/en/d2/7849b8bec911d4b2e80050dadfb92b/content.htm
regards,
Anirban
2008 Jul 21 7:54 AM
Hi,
You can take the help of below code.
UPDATE zo9_user_status
SET sub_date = sy-datum
sub_time = sy-uzeit
status = g_wa_outtab-status
WHERE representative = g_wa_outtab-representative AND
selection_id = g_wa_outtab-selection_id AND
sub_date = g_wa_outtab-sub_date AND
sub_time = g_wa_outtab-sub_time AND
superior = g_wa_outtab-superior.
IF sy-subrc EQ 0.
COMMIT WORK.
l_error = 'X1'.
ELSE.
l_error = 'X2'.
CLEAR l_error.
ROLLBACK WORK.
ENDIF.
IF l_error = 'X2'.
MESSAGE e031.
CLEAR l_error.
ELSEIF l_error = 'X1'.
MESSAGE s022.
CLEAR l_error.
ENDIF.
hope this helps out.
plz reward if useful.
thanks,
dhanashri