Skip to Content
0
Feb 07, 2022 at 06:48 AM

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

719 Views Last edit Mar 07, 2022 at 02:57 PM 3 rev

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.

<content removed by SAP Community Moderator>

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.