‎2011 Nov 29 7:55 AM
Hi ,
I need to update a seris of tables and they must be transactional, i.e. all the data must be updated or not.
I have the following code.
*Fetch and Update Reference Profile Data
me->process_rp_data( ).
*Fetch and Update Request Data
me->process_req_data( ).
*Fetch and Update Collateral Data
me->process_coll_data( ).
*Fetch and Update Project Data
me->process_project_data( ).
IF i_update_flag IS INITIAL.
ROLLBACK WORK.
ELSE.
COMMIT WORK.
ENDIF.
in all the above four methods there are update statements like below
TRY .
UPDATE (i_table_name) SET bp_number = sur_bp WHERE (lt_dyn_cond).
IF sy-subrc NE 0.
me->raise_exception( EXPORTING i_text_id = zcx_rms_dedupe_process_excptns=>error_in_update
i_bp_num = vic_bp
i_guid = i_guid
i_table_name = i_table_name
i_process = i_process ).
ENDIF.
CATCH cx_sy_dynamic_osql_error.
me->raise_exception( EXPORTING i_text_id = zcx_rms_dedupe_process_excptns=>error_in_update
i_bp_num = vic_bp
i_guid = i_guid
i_table_name = i_table_name
i_process = i_process ).
ENDTRY.
If in the third method, if the exception cx_sy_dynamic_osql_error is raised all the data that is updated in the first two methods are commited. Can any one help how to overcome this situtation. I do not want the data to be committed
Regards
‎2011 Nov 29 9:54 AM
My guess is that the code in your RAISE_EXCEPTION method contains a statement that is leading to an implicit database commit. Are you showing an information message? That would be the source of your problem.
In this page you will find all the possible causes of an implicit commit.
http://help.sap.com/saphelp_nw73ehp1/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/frameset.htm
‎2011 Nov 29 10:14 AM
Hello,
I need to update a seris of tables and they must be transactional, i.e. all the data must be updated or not.
This is the perfect use case of "Update task". Why are you not using it?
You can call the Update FMs inside the methods. In the update FM you can put your code to update the DB tables.
BR,
Suhas
‎2011 Nov 29 12:18 PM
Hi,
My main question is that the why Exception I am raising is triggering a database commit. I am not even displaing an information message. I am simply outputing a write statement
[DataBase Commit|http://help.sap.com/saphelp_nw70/helpdata/en/41/7af4bca79e11d1950f0000e82de14a/content.htm]
Gives more information on Database commit but it does not mention this case. So wanted to know my mistake.
‎2011 Nov 29 1:05 PM
Hi,
If system is committing update while raising exception then roll back your work before exception.
Regards,
Prabhat