Skip to Content

*&———————————————————————*

*& Report  ZP_RBA

*  Demonstrate using alv in modal dialog

*  as dynamic popup with radio buttons.

*&———————————————————————*

REPORT  ZP_RBA.

TYPE-POOLS: slis.

INCLUDE <icons>.

types: BEGIN OF itype_alv_flight,

         radio1(4),                            “Radio button

         carrid TYPE sflight-carrid,

         connid TYPE sflight-connid,

       END OF itype_alv_flight.

class lcl_handle_events definition deferred.

data: gr_table   type ref to cl_salv_table.

data: gr_container type ref to cl_gui_custom_container.

data: gr_events type ref to lcl_handle_events.

DATA: it_alv_flight type standard table of itype_alv_flight.

*———————————————————————*

*       CLASS lcl_handle_events DEFINITION

*———————————————————————*

class lcl_handle_events definition.

  public section.

    methods:

      on_link_click for event link_click of cl_salv_events_table

        importing row column.

endclass.         “lcl_handle_events DEFINITION

*———————————————————————*

*       CLASS lcl_handle_events IMPLEMENTATION

*———————————————————————*

class lcl_handle_events implementation.

  method on_link_click.

    perform user_command using row column.

  endmethod.                    “on_single_click

endclass.

selection-screen begin of block dsp with frame.

selection-screen end of block dsp.

*———————————————————————-*

* START-OF-SELECTION                                                   *

*———————————————————————-*

start-of-selection.

  field-symbols: <fs_grid> type itype_alv_flight.

  SELECT carrid connid FROM sflight

  INTO corresponding fields of table it_alv_flight

  UP TO 20 ROWS.

  LOOP AT it_alv_flight assigning <fs_grid>.

    <fs_grid>-radio1 = icon_wd_radio_button_empty.  “Empty Radio Buttons

  ENDLOOP.

  try.

      cl_salv_table=>factory(

        exporting

          list_display   = ‘X’

        importing

          r_salv_table   = gr_table

        changing

          t_table        = it_alv_flight ).

    catch cx_salv_msg.                                “#EC NO_HANDLER

  endtry.

  try.

    gr_table->set_screen_popup(

      start_column = 10

      end_column = 60

      start_line = 4

      end_line = 15 ).

    catch cx_salv_msg.

  endtry.

*   set icon column and make it a hotspot

  data: lr_columns type ref to cl_salv_columns,

        lr_column  type ref to cl_salv_column_table.

  lr_columns = gr_table->get_columns( ).

  try.

      lr_column ?= lr_columns->get_column( ‘RADIO1’ ).

      lr_column->set_icon( if_salv_c_bool_sap=>true ).

      lr_column->set_cell_type( if_salv_c_cell_type=>hotspot ).

      lr_column->set_long_text( text-001 ).

    catch cx_salv_not_found.                          “#EC NO_HANDLER

  endtry.

*  turn off front-end handler

  data: lr_selections type ref to cl_salv_selections.

  lr_selections = gr_table->get_selections( ).

  lr_selections->set_selection_mode( if_salv_c_selection_mode=>none ).

*  capture events

  data: lr_events type ref to cl_salv_events_table.

  lr_events = gr_table->get_event( ).

  create object gr_events.

  set handler gr_events->on_link_click for lr_events.

*   display the table

  gr_table->display( ).

FORM user_command USING row type i

                        column type lvc_fname.

  data: refr_stable type lvc_s_stbl.

  field-symbols: <fs_itab> like line of it_alv_flight.

  if column = ‘RADIO1’.

    loop at it_alv_flight assigning <fs_itab>.

      if sy-tabix <> row.

        <fs_itab>-radio1 = icon_wd_radio_button_empty.

      endif.

    endloop.

    READ TABLE it_alv_flight INDEX row assigning <fs_itab>.

    IF <fs_itab>-radio1 = icon_radiobutton.

    ELSE.

      <fs_itab>-radio1 = icon_radiobutton.

    ENDIF.

  endif.

  refr_stable-row = abap_true.

  gr_table->refresh( s_stable = refr_stable refresh_mode = if_salv_c_refresh=>full ).

ENDFORM.                    “USER_COMMAND

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply