Skip to Content
0
Nov 16, 2009 at 08:04 PM

Query regarding using cursor and arfc - performance

345 Views

I was trying to use a cursor in order to perform some parallel processing in order to improve performance of a database select.

I opened a cursor in the main program

OPEN CURSOR WITH HOLD c FOR SELECT *

FROM BSEG

WHERE BUKRS IN BUKRS

and BELNR IN BELNR

and GJAHR in GJAHR.

And called an ARFC function module that processes the cursor using the fetch statement(similar to the statement below)

. In order t ensure that the cursor is still available, I also sent the cursor as a parameter to the RFC.

fetch NEXT CURSOR c into table it_bseg PACKAGE SIZE 3000.

Upon testing this program, it seems that the cursor becomes invalid/closed after the RFC is executed one time. I think it is because the end of RFC LUW implicitly closed the database cursor once it finished execution. Hence the second and subsequent calls to the RFC fails with the error that cursor is invalid/not open.

Do you know if there is any way to keep the cursor valid till the end of the program, till an explicit close is issued?

Most SAP documentation seems to indicate that there is no way to influence this. However,as cursor is a pure db function, I find it difficult to believe that it is not possible to control the cursor's validity manually rather than letting SAP LUW handle it.

Thanks in advance.

Best Regards,

Shrikant