Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Runtime Error:Invalid interruption of a database selection

Former Member
0 Kudos
289

Hi,

I have the above mentioned runtime error (short text of runtime error) while executuing FM with the runtime error DBIF_RSQL_INVALID_CURSOR and exception CX_SY_OPEN_SQL_DB.

the source code for the cause of the error is as follows:

{ PERFORM fill_spras USING g_r_werks[]

CHANGING g_r_spras[].

IF g_r_spras[] IS INITIAL.

  • Please specify a value for Language.

MESSAGE e003(yy_master_data).

RAISE error_passed_to_mess_handler.

ENDIF.

  • Determine number of database records to be read per FETCH statement

  • from input parameter I_MAXSIZE. If there is a one to one relation

  • between DataSource table lines and database entries, this is trivial.

  • In other cases, it may be impossible and some estimated value has to

  • be determined.

OPEN CURSOR s_marc FOR SELECT *

FROM marc

WHERE werks IN g_r_werks AND

matnr IN g_r_matnr.

ENDIF. "First data package

  • Fetch records into interface table.

  • named E_T_'Name of extract structure'.

FETCH NEXT CURSOR s_marc INTO TABLE gt_marc PACKAGE SIZE s_s_if-maxsize.

IF sy-subrc = 0.

DELETE ADJACENT DUPLICATES FROM gt_marc COMPARING matnr}

the pointer shown in the runtime analysis is at if sy-subrc EQ 0.

while debugging also it gives run time error when curson reaches the statement FETCH Next Cursor.

Any ideas?

3 REPLIES 3

Former Member
0 Kudos
107

Did you run off end of table, or possibly, SAP doesn't know what the next row should be? Why extract data this way...and simple Open SQL Select would probably be as fast or faster, since you're using primary key for MARC, and you could utilize package size there to manage table size (and thus memory consumption). IMHO, there's rarely anything to be gained by this read method.

Clemenss
Active Contributor
0 Kudos
107

Hi Simran,

if for whatever reason the process is interrupted between SELECT and ENDSELECT (or, in other words, after OPEN CURSOR between subsequent FETCHes), you will get this error: The Database is exspected to run within one logical unit of work.

If any screen is displayed waiting for user input (this also applies for debug screen), an implicit commit is is done that finishes the current LUW. The database will not like it....

That's why you should do only minor things between SELECT and ENDSELECT (OPEN/CLOSE CURSOR).

The E Message will also cause the end of the LUW.

Regards,

Clemens

Former Member
0 Kudos
107

"Open cursor with hold" does the job as open cursor with hold will make the reference intact even after making commit in the following statements under open cursor.

with only Open cursor :

Commit work resets the database cursor, so the next fecth does not know anymore where the last one has left off.