cancel
Showing results for 
Search instead for 
Did you mean: 

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

0 Kudos

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.

lenastodal
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since this is your first question, I recommend that you familiarize yourself with our Q&A Tutorial: https://developers.sap.com/tutorials/community-qa.html, as it provides tips for preparing questions that draw responses from our members.

Should you wish, you can revise your question by selecting Actions, then Edit.

By adding a picture to your profile you encourage readers to respond: https://www.youtube.com/watch?v=46bt1juWUUM
Many thanks!

Keep in mind, when you receive an answer that was helpful to you, accept it as best answer.

Accepted Solutions (0)

Answers (0)