This replaces the need for LOOP AT, IF, and APPEND all in one line—powerful and readable.
*&---------------------------------------------------------------------*
*& Report ZREP_LCLCLASS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zrep_lclclass.
TYPES: BEGIN OF ty_user,
name TYPE string,
status TYPE string,
END OF ty_user.
DATA: lt_users TYPE STANDARD TABLE OF ty_user WITH EMPTY KEY,
lt_names TYPE STANDARD TABLE OF string WITH EMPTY KEY.
lt_users = VALUE #(
( name = 'Alice' status = 'ACTIVE' )
( name = 'Bob' status = 'INACTIVE' )
( name = 'Charlie' status = 'ACTIVE' )
).
lt_names = VALUE string_table(
FOR user IN lt_users
WHERE ( status = 'ACTIVE' )
( user-name )
).
LOOP AT lt_names INTO DATA(name).
WRITE: / name.
ENDLOOP.
Output:
Alice
Charlie