Commit Work in SELECT statement
Do not use explicit or implicit commit in the SELECT ... ENDSELECT
statement, the database cursor will be lost and the runtime error
DBIF_RSQL_INVALID_CURSOR with exception CX_SY_OPEN_SQL_DB will occur.
* Bad example
DATA:
ls_usr02 TYPE usr02.
SELECT *
INTO ls_usr02
FROM usr02.
* ...
COMMIT WORK.
ENDSELECT.
DATA:
ls_usr02 TYPE usr02.
SELECT *
INTO ls_usr02
FROM usr02.
* ...
COMMIT WORK.
ENDSELECT.
Store the data in internal table and process it with LOOP.
* Correct example
DATA:
lt_usr02 TYPE TABLE OF usr02,
ls_usr02 TYPE usr02.
SELECT *
INTO TABLE lt_usr02
FROM usr02.
LOOP AT lt_usr02 INTO ls_usr02.
* ...
COMMIT WORK.
ENDLOOP.
DATA:
lt_usr02 TYPE TABLE OF usr02,
ls_usr02 TYPE usr02.
SELECT *
INTO TABLE lt_usr02
FROM usr02.
LOOP AT lt_usr02 INTO ls_usr02.
* ...
COMMIT WORK.
ENDLOOP.
See other related notes in my infodepot:
Full list of examples in my infodepot
If you have a question, have found an error or just want to contact me, please use this form.
If you have a question, have found an error or just want to contact me, please use this form.
Copyright (C) 2010 http://www.kerum.pl/infodepot/
Disclaimer: I am not affiliated or related to any division or subsidiary of SAP AG.
Trademarks or registered trademarks of any products or companies referred to on this site belong to those companies.
Anyone using the given solutions, is doing it under his/her own responsibility and at own risk.