TYPES: BEGIN OF ty_alv,
        lights_1 TYPE icon_d, “Exception, Holding the value of the lights
        lights_2 TYPE icon_d,  “some text
        lights_3 TYPE icon_d,  “some text
*        lights_4 TYPE icon_d,  “some text
       END OF ty_alv.

DATA: gs_alv TYPE ty_alv,
      gt_alv TYPE TABLE OF ty_alv,
      gr_alv TYPE REF TO cl_salv_table,
      gr_columns TYPE REF TO cl_salv_columns_table.

*———————————————–*
* CLASS lcl_receiver DEFINITION
*———————————————–*
*
*———————————————–*
CLASS lcl_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
    handle_finished FOR EVENT finished OF cl_gui_timer.
ENDCLASS.                    “

DATA:
i_data TYPE TABLE OF spfli,
o_grid TYPE REF TO cl_gui_alv_grid,
receiver TYPE REF TO lcl_receiver,
timer TYPE REF TO cl_gui_timer.

DATA : lv_temp TYPE i.

CONSTANTS:
c_interval TYPE i VALUE 1.

CREATE OBJECT timer.
CREATE OBJECT receiver.
SET HANDLER receiver->handle_finished FOR timer.
timer->interval = c_interval.
CALL METHOD timer->run.

START-OF-SELECTION.

  DATA : v_index TYPE index.

  DO 33 TIMES.

    v_index = sy-index.

    IF v_index LE 11.
      MOVE : ‘@5B@’ TO gs_alv-lights_1,
       ‘@5B@’ TO gs_alv-lights_2,
       ‘@5B@’ TO gs_alv-lights_3.
*       ‘@BZ@’  TO gs_alv-lights_4.
      APPEND gs_alv TO gt_alv.

    ELSEIF v_index GT 11 AND v_index LE 22.
      MOVE : ‘@5D@’ TO gs_alv-lights_2,
       ‘@5D@’ TO gs_alv-lights_3,
       ‘@5D@’ TO gs_alv-lights_1.
*       ‘@BZ@’  TO gs_alv-lights_3.
      APPEND gs_alv TO gt_alv.

    ELSEIF v_index GT 22 AND v_index LE 33.
      MOVE : ‘@5C@’ TO gs_alv-lights_3,
       ‘@5C@’ TO gs_alv-lights_1,
       ‘@5C@’ TO gs_alv-lights_2.
*       ‘@BZ@’  TO gs_alv-lights_2.
      APPEND gs_alv TO gt_alv.
    ENDIF.
  ENDDO.

  CALL METHOD cl_salv_table=>factory
*    EXPORTING
*      list_display = ‘X’
    IMPORTING
      r_salv_table = gr_alv
    CHANGING
      t_table      = gt_alv.

  CALL METHOD gr_alv->refresh.

  gr_columns = gr_alv->get_columns( ).

*  gr_columns->set_exception_column( value = ‘ICON’ ).

  CALL METHOD gr_alv->display.

*————————————————*
* CLASS lcl_receiver IMPLEMENTATION
*————————————————*
*
*————————————————*
CLASS lcl_receiver IMPLEMENTATION.
  METHOD handle_finished.
    PERFORM refresh_view.
    CALL METHOD timer->run.
  ENDMETHOD.                    “handle_finished
ENDCLASS.                    “lcl_receiver IMPLEMENTATION

*&———————————————–*
*& Form refresh_view
*&———————————————–*
* Refresh logic
*————————————————*
FORM refresh_view.

  FIELD-SYMBOLS : <lfs_alv> TYPE ty_alv.

  DATA : lv_index TYPE sytabix.
  UNASSIGN <lfs_alv>.

  DO 11 TIMES.
*    CLEAR lv_index.
*    lv_index = sy-index.
    UNASSIGN <lfs_alv>.
    READ TABLE gt_alv ASSIGNING <lfs_alv> INDEX 1.
    CHECK <lfs_alv> IS ASSIGNED.
    APPEND <lfs_alv> TO gt_alv.
    DELETE gt_alv INDEX 1.
  ENDDO.

  CALL FUNCTION ‘GET_GLOBALS_FROM_SLVC_FULLSCR’
    IMPORTING
      e_grid = o_grid.

  IF o_grid IS NOT INITIAL.
    CALL METHOD o_grid->refresh_table_display.
  ENDIF.
ENDFORM.                    “refresh_view

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