2023 Apr 19 10:29 AM
what is the purpose of this variable -> dbcursor ? because sometimes it becomes 1 or 2
open cursor with hold @data(dbcursor) for
select * from scarr.
2023 Apr 19 12:18 PM
You can have more than one cursor at a time - up to 17. You have a different dbcursor for each cursor open, allowing you to specify which cursor you're fetching from or closing.
The help for the FETCH statement has a nice example https://help.sap.com/doc/abapdocu_753_index_htm/7.53/en-US/abapfetch.htm
OPEN CURSOR @DATA(dbcur1) FOR
SELECT carrid, COUNT(*) AS count
FROM spfli
GROUP BY carrid
ORDER BY carrid.
OPEN CURSOR @DATA(dbcur2) FOR
SELECT *
FROM spfli
ORDER BY carrid.
DATA: BEGIN OF counter,
carrid TYPE spfli-carrid,
count TYPE i,
END OF counter,
spfli_tab TYPE TABLE OF spfli.
DO.
FETCH NEXT CURSOR @dbcur1 INTO @counter.
IF sy-subrc <> 0.
EXIT.
ENDIF.
cl_demo_output=>next_section( |{ counter-carrid
}, { counter-count }| ).
FETCH NEXT CURSOR @dbcur2
INTO TABLE @spfli_tab PACKAGE SIZE @counter-count.
cl_demo_output=>write( spfli_tab ).
ENDDO.
CLOSE CURSOR: @dbcur1,
@dbcur2.
cl_demo_output=>display( ).
2023 Apr 19 2:10 PM