Code: Alles auswählen.
REPORT demo_simple_alv_with_interaction.
CLASS lcl_application DEFINITION FINAL.
PUBLIC SECTION.
TYPES: BEGIN OF mts_selections,
t_r_dummy TYPE RANGE OF sy-subrc,
END OF mts_selections.
TYPES: BEGIN OF mts_data.
* include type ...
TYPES:
land1 TYPE land1,
END OF mts_data,
mtt_data TYPE STANDARD TABLE OF mts_data WITH NON-UNIQUE DEFAULT KEY.
METHODS:
main IMPORTING is_selections TYPE mts_selections,
at_user_command IMPORTING iv_ucomm TYPE syucomm.
CLASS-DATA:
mo_instance TYPE REF TO lcl_application.
DATA:
mt_data TYPE mtt_data,
mo_salv TYPE REF TO cl_salv_table.
ENDCLASS.
END-OF-SELECTION.
NEW lcl_application( )->main( is_selections = VALUE #( t_r_dummy = VALUE #( sign = 'I' option = 'EQ' ( low = '123')
)
)
).
AT USER-COMMAND.
lcl_application=>mo_instance->at_user_command( sy-ucomm ).
CLASS lcl_application IMPLEMENTATION.
METHOD main.
mo_instance = me.
SELECT land1 FROM t005 INTO TABLE @me->mt_data.
TRY.
cl_salv_table=>factory( EXPORTING r_container = cl_gui_container=>screen0 " Abstract Container for GUI Controls
IMPORTING r_salv_table = me->mo_salv " Basis Class Simple ALV Tables
CHANGING t_table = me->mt_data
).
me->mo_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).
me->mo_salv->display( ).
WRITE '.'.
SET PF-STATUS 'BOOK'.
CATCH cx_root INTO DATA(lo_cx).
MESSAGE lo_cx TYPE 'I' DISPLAY LIKE 'E'.
ENDTRY.
ENDMETHOD.
METHOD at_user_command.
me->mo_salv->get_metadata( ). "Necessary since Usercommand does not trigger ALV-Backend transport
CASE iv_ucomm.
WHEN 'ACTION1'.
LOOP AT me->mo_salv->get_selections( )->get_selected_rows( ) ASSIGNING FIELD-SYMBOL(<lv_row>).
READ TABLE me->mt_data INDEX <lv_row> ASSIGNING FIELD-SYMBOL(<ls_data>).
<ls_data>-land1 = '???'.
ENDLOOP.
me->mo_salv->refresh( VALUE #( row = 'X' col = 'X' ) ).
ENDCASE.
ENDMETHOD.
ENDCLASS.