Open cursor program in abap
* It is used to reduce the load balance.
Code
REPORT ZAJAY_CURSOR_PROG.
TABLES:mara.
types : begin of ty_mara,
matnr type mara-matnr,
matkl type mara-matkl,
mtart type mara-mtart,
END OF ty_mara.
data: it_mara type table of ty_mara,
wa_mara type ty_mara,
a type i,
it_final type table of ty_mara.
select-OPTIONS : s_matnr for mara-matnr.
START-OF-SELECTION.
open CURSOR a for select matnr matkl mtart FROM mara WHERE matnr in s_matnr.
DO.
FETCH NEXT CURSOR a into it_mara PACKAGE SIZE 10.
IF sy-subrc = 0.
APPEND LINES OF it_mara to it_final.
REFRESH it_mara.
else.
exit.
ENDIF.
ENDDO.
close CURSOR a.
cl_demo_output=>display( it_final ).
* Check in debugging first 10 records stored in it_mara and assigned to it_final. Clear it_mara,Because next 10 records stored.
* it_mara is dummy internal table because just fetch data and store it and assigned to it_final.
* Fetch data based on package size.
Input:
Output
Comments
Post a Comment