Application Development and Automation 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: 
Read only

Runtime Error DBSQL_INVALID_CURSOR (Cursor already closed or not open yet)

0 Likes
1,863

Hello Friends,

I am receiving runtime error as " Cursor already closed or not open yet." for the below piece of code.

So, can anyone please help me how to solve it?

I have tried DB_COMMIT FM for commit work and also without it, still the same dump occurs.

data: gv_cursor TYPE cursor.

OPEN CURSOR WITH HOLD gv_cursor

FOR SELECT
erdk~opbel
fkkvkp~ktokl
FROM erdk AS erdk
INNER JOIN fkkvkp AS fkkvkp
ON fkkvkp~vkont = erdk~vkont
WHERE erdk~opbel IN s_prtdoc.

DO.

FETCH NEXT CURSOR gv_cursor
INTO TABLE gt_input
PACKAGE SIZE 1000.
IF sy-subrc IS INITIAL.
SORT gt_input BY opbel.
ELSE.
CLOSE CURSOR gv_cursor.
EXIT.
ENDIF.

****Some other logics is implemented below.

ENDDO.

Hello Friends,

I am receiving runtime error as " Cursor already closed or not open yet." for the below piece of code.

So, can anyone please help me how to solve it?

I have tried DB_COMMIT FM for commit work and also without it, still the same dump occurs.

data: gv_cursor TYPE cursor.

OPEN CURSOR WITH HOLD gv_cursor

FOR SELECT
erdk~opbel
fkkvkp~ktokl
FROM erdk AS erdk
INNER JOIN fkkvkp AS fkkvkp
ON fkkvkp~vkont = erdk~vkont
WHERE erdk~opbel IN s_prtdoc.

DO.

FETCH NEXT CURSOR gv_cursor
INTO TABLE gt_input
PACKAGE SIZE 1000.
IF sy-subrc IS INITIAL.
SORT gt_input BY opbel.
ELSE.
CLOSE CURSOR gv_cursor.
EXIT.
ENDIF.

****Some other logics is implemented below.

ENDDO.

1 REPLY 1
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,694

Does it work without code from "other logics"?