New REDUCE operator can be used in many ways.
Normally we use loop with increment count to get to know the specific matching record in an internal table.
OUTPUT
New REDUCE operator can be used to do the same in an improved way .
CODE
DATA: ls_spfli TYPE spfli,
lt_spfli TYPE TABLE OF spfli,
count1 TYPE i,
count2 TYPE i.
START-OF-SELECTION.
SELECT * FROM spfli INTO TABLE lt_spfli.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_structure_name = 'SPFLI'
TABLES
t_outtab = lt_spfli.
LOOP AT lt_spfli INTO ls_spfli WHERE carrid = 'LH'.
count1 = count1 + 1.
ENDLOOP.
WRITE:/ 'Occourence of carrid- LH' COLOR 3, count1 COLOR 3.
” COUNT operator use
count2 = REDUCE i( INIT x = 0 FOR ls IN lt_spfli
WHERE ( carrid = 'LH' )
NEXT x = x + 1 ).
WRITE:/ 'Occourence of carrid- LH', count2.
OUTPUT