DEFINE _get_range_from_table.
LOOP AT &2 ASSIGNING <lfs_struct>.
ASSIGN COMPONENT &3 OF STRUCTURE <lfs_struct> TO <lfs_field>.
CHECK sy-subrc IS INITIAL.
APPEND VALUE #( sign = 'I' option = 'EQ' low = <lfs_field> ) TO &1.
ENDLOOP.
SORT &1 BY low.
DELETE ADJACENT DUPLICATES FROM &1 COMPARING low.
END-OF-DEFINITION.
ESEMPIO DI APPLICAZIONE
_get_range_from_table lr_belnr lt_data 'BELNR'.
_get_range_from_table lr_gjahr lt_data 'GJAHR'.
_get_range_from_table lr_bukrs lt_data 'BUKRS'.
_get_range_from_table lr_buzei lt_data 'BUZEI'.