2006 Dec 08 5:03 PM
Hello All,
My program has insert and update to database tables. What happends if my program crashes in the middle? How to COMMIT this transactions to DB table, only after executing whole program?
example:
....
....
LOOP AT itab.
IF x = 100.
UPDATE zdbtable
SET date = sy-datum
userid = ''
WHERE sno = '100'.
ELSEIFx = 200.
UPDATE zdbtable
SET date = sy-datum
userid = ''
WHERE sno = '200'.
ELSEIF lv_days_pending = 300.
int_dbtable-sno = '300'.
int_dbtable-userid = ''.
INSERT into zdbtable values int_dbtable.
DELETE
FROM zdbtable
WHERE sno = '100'
ENDIF.
ENDLOOP.
I would like all this data base transactions to be executed or else if there is any crash in the middle no chages has to be made to the database tables.
Thanks,
Hello All,
My program has insert and update to database tables. What happends if my program crashes in the middle? How to COMMIT this transactions to DB table, only after executing whole program?
example:
....
....
LOOP AT itab.
IF x = 100.
UPDATE zdbtable
SET date = sy-datum
userid = ''
WHERE sno = '100'.
ELSEIFx = 200.
UPDATE zdbtable
SET date = sy-datum
userid = ''
WHERE sno = '200'.
ELSEIF lv_days_pending = 300.
int_dbtable-sno = '300'.
int_dbtable-userid = ''.
INSERT into zdbtable values int_dbtable.
DELETE
FROM zdbtable
WHERE sno = '100'
ENDIF.
ENDLOOP.
I would like all this data base transactions to be executed or else if there is any crash in the middle no chages has to be made to the database tables.
Thanks,
2006 Dec 08 5:11 PM
Hi,
Use the ROLLBACK WORK if the SQL fails...
UPDATE zdbtable
SET date = sy-datum
userid = ''
WHERE sno = '100'.
ELSEIFx = 200.
UPDATE zdbtable
SET date = sy-datum
userid = ''
WHERE sno = '200'.
<b>IF SY-SUBRC <> 0.
ROLLBACK WORK.
MESSAGE E208(00) WITH 'UPDATE FAILED'.
ENDIF.</b>
ELSEIF lv_days_pending = 300.
int_dbtable-sno = '300'.
int_dbtable-userid = ''.
INSERT into zdbtable values int_dbtable.
<b>IF SY-SUBRC <> 0.
ROLLBACK WORK.
MESSAGE E208(00) WITH 'INSERT FAILED'.
ENDIF.</b>
DELETE
FROM zdbtable
WHERE sno = '100'
ENDIF.
<b>IF SY-SUBRC <> 0.
ROLLBACK WORK.
MESSAGE E208(00) WITH 'DELETE FAILED'.
ENDIF.</b>
If everything is successful then commit.
<b>COMMIT WORK.</b>
Thanks,
Naren
2006 Dec 08 5:13 PM
Hi
You can use PERFORM ON COMMIT or Update Function modules for this .
For creating Update Function modules you have to select the attribute Processing type as 'Update' . And you have to call the function in update task
Ex : Call ' FM ' in update task.
Cheers
Anand
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |