Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

CL_SALV_HIERSEQ_TABLE and CL_GUI_TIMER --> no reuse of ALV possible

Former Member
0 Kudos
186

Hello.

I use the CL_SALV_HIERSEQ_TABLE displaying my data. I refresh my data in the FINISHED Event of the CL_GUI_TIMER. I know that the coding isn't so good, but the refreshing takes place:

      ref_hierseq->close_screen().
      
      clear ref_hierseq.
      
      ls_binding-master = 'MANDT'.
      ls_binding-slave  = 'MANDT'.
      APPEND ls_binding TO lt_binding.

      ls_binding-master = 'EXIDV'.
      ls_binding-slave  = 'EXIDV'.
      APPEND ls_binding TO lt_binding.

      TRY.
          cl_salv_hierseq_table=>factory(
            EXPORTING
              t_binding_level1_level2  = lt_binding
            IMPORTING
              r_hierseq                = ref_hierseq
            CHANGING
              t_table_level1           = lt_master
              t_table_level2           = lt_slave ).
        CATCH cx_salv_data_error cx_salv_not_found.
      ENDTRY.

This coding takes place in the event handling methode.

I tried the SET_DATA Methode and so on, but nothing solves the problem: When I want to go BACK with F3 or Clicking, ich have to close alle ALVs, i.e. if my timer interval is 10 seconds and i watch the monitor for 1 Minute i have to go 6 times back

Some advice or help would be nice.

1 REPLY 1

Former Member
0 Kudos
45

I cant find any solution.

Now i posted the hole coding. The problem is the refreshing (handling the CL_GUI_TIMER event). I tried a lot, but nothing solved the problem.


REPORT  zle_jitm.

* INCLUDES
INCLUDE <icon>.
INCLUDE <symbol>.

TABLES: zle_jisk, zle_jisp.

TYPES:
  BEGIN OF t_rtab_exidv,
    sign(1)   TYPE c,
    option(2) TYPE c,
    low       TYPE exidv,
    high      TYPE exidv,
  END OF t_rtab_exidv,

  tt_rtab_exidv TYPE TABLE OF t_rtab_exidv,

  BEGIN OF t_rtab_typ,
    sign(1)   TYPE c,
    option(2) TYPE c,
    low       TYPE zle_etyp_jis,
    high      TYPE zle_etyp_jis,
  END OF t_rtab_typ,

  tt_rtab_typ TYPE TABLE OF t_rtab_typ,

  BEGIN OF t_master_alv.
    INCLUDE TYPE zle_jisk.
    TYPES:  expand TYPE char1,
  END OF t_master_alv,

  BEGIN OF t_slave_alv.
    INCLUDE TYPE zle_jisp.
    TYPES:
  END OF t_slave_alv
  .
* > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
*---------------------------------------------------------------------*
*       CLASS lcl_zjitm IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_zjitm DEFINITION.

  PUBLIC SECTION.

    CLASS-METHODS main
                    IMPORTING so_jisnr TYPE tt_rtab_exidv
                              so_typ   TYPE tt_rtab_typ.
  PRIVATE SECTION.
    CLASS-DATA:     lt_master     TYPE STANDARD TABLE OF t_master_alv,
                    lt_slave      TYPE STANDARD TABLE OF t_slave_alv,

                    ref_hierseq TYPE REF TO cl_salv_hierseq_table,
                    ref_timer   TYPE REF TO cl_gui_timer,

                    l_so_jisnr  TYPE tt_rtab_exidv,
                    l_so_typ    TYPE tt_rtab_typ
                    .

    CLASS-METHODS:  on_finished
                      FOR EVENT finished
                      OF cl_gui_timer,
                    get_data,
                    show_data
                      IMPORTING x_first TYPE char1 OPTIONAL
                    .

ENDCLASS.
*---------------------------------------------------------------------*
*       CLASS lcl_zjitm IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_zjitm IMPLEMENTATION.

*---------------------------------------------------------------------*
* PUBLIC MAIN()
*---------------------------------------------------------------------*
  METHOD main.

    l_so_jisnr[] = so_jisnr.
    l_so_typ[]   = so_typ.

    CREATE OBJECT ref_timer.

    ref_timer->interval = '10'.

    SET HANDLER lcl_zjitm=>on_finished FOR ref_timer.

    lcl_zjitm=>get_data( ).

    ref_timer->run( ).

    lcl_zjitm=>show_data( 'X' ).

  ENDMETHOD.

*---------------------------------------------------------------------*
* PRIVATE ON_FINISHED()
*---------------------------------------------------------------------*
  METHOD on_finished.

    lcl_zjitm=>get_data( ).

    ref_timer->run( ).

    lcl_zjitm=>show_data( ).

  ENDMETHOD.

*---------------------------------------------------------------------*
* PRIVATE GET_DATA()
*---------------------------------------------------------------------*
  METHOD get_data.

    FIELD-SYMBOLS:
      <fs_master> TYPE t_master_alv.

    DATA:
      t_slave TYPE STANDARD TABLE OF t_slave_alv.

* > Selektion der Kopfdaten (Masterdata selection)
    CLEAR lt_master.
    REFRESH lt_master.

    SELECT *
      FROM zle_jisk
      INTO CORRESPONDING FIELDS OF TABLE lt_master
      WHERE exidv IN l_so_jisnr
        AND typ   IN l_so_typ.

* > Selektion der Positionsdaten (Slavedata selection)
    CLEAR lt_slave.
    REFRESH lt_slave.

    LOOP AT lt_master ASSIGNING <fs_master>.

      SELECT *
        FROM zle_jisp
        INTO CORRESPONDING FIELDS OF TABLE t_slave
        WHERE exidv = <fs_master>-exidv.

      APPEND LINES OF t_slave TO lt_slave.

    ENDLOOP.

  ENDMETHOD.

*---------------------------------------------------------------------*
* PRIVATE SHOW_DATA( optional X_FIRST )
*---------------------------------------------------------------------*
* - Zeigt das ALV an.
* - wird X_FIRST = 'X' übergeben, wird kein neues ALV erzeugt sondern
*   nur die Datentabellen neu übergeben.
* - Shows the ALV.
* - No X_FIRST, no new instance of ref_hierseq
*---------------------------------------------------------------------*
  METHOD show_data.

    DATA:
      lt_binding TYPE salv_t_hierseq_binding,
      ls_binding TYPE salv_s_hierseq_binding.

    DATA:
      lr_functions TYPE REF TO cl_salv_functions_list.

    DATA:
      lr_columns TYPE REF TO cl_salv_columns_hierseq,
      lr_column  TYPE REF TO cl_salv_column.

    DATA:
      lr_level TYPE REF TO cl_salv_hierseq_level.

* > Erster Aufruf? (first call?)
    IF x_first = 'X'.
* > Festlegen der Fremschlüsselbeziehungen zwischen Kopf- und Posi-
* > tionsdaten (Master / Slave)
* > Relation between Master and Slave
      ls_binding-master = 'MANDT'.
      ls_binding-slave  = 'MANDT'.
      APPEND ls_binding TO lt_binding.

      ls_binding-master = 'EXIDV'.
      ls_binding-slave  = 'EXIDV'.
      APPEND ls_binding TO lt_binding.

* > Erzeugen eines NEUEN ALVs.
* > Creating new ALV
      TRY.
          cl_salv_hierseq_table=>factory(
            EXPORTING
              t_binding_level1_level2  = lt_binding
            IMPORTING
              r_hierseq                = ref_hierseq
            CHANGING
              t_table_level1           = lt_master
              t_table_level2           = lt_slave ).
        CATCH cx_salv_data_error cx_salv_not_found.
      ENDTRY.
     ELSE.
* > Aufruf zum mindestens zweiten Mal.
* > At least the second call

"* * * * WHAT SHOULD I DO HERE? * * * *    

     ENDIF.

* > Es werden alle Funktionen des ALV als aktiv gesetzt
* > Set all functions of the alv as activ
    lr_functions = ref_hierseq->get_functions( ).
    lr_functions->set_all( if_salv_c_bool_sap=>true ).

* > Einstellungen für die Kopfdaten (Master)
* > Options for the masterdata
    TRY.
        lr_columns = ref_hierseq->get_columns( 1 ).
      CATCH cx_salv_not_found.
    ENDTRY.

    TRY.
        lr_column = lr_columns->get_column( 'MANDT' ).
        lr_column->set_technical( if_salv_c_bool_sap=>true ).
      CATCH cx_salv_not_found.                          
    ENDTRY.

* > Spalte für das Expandieren festlegen
* > set expandcolumn
    TRY.
        lr_columns->set_expand_column( 'EXPAND' ).
      CATCH cx_salv_data_error.                         
    ENDTRY.

* > Festlegen das alle Kopfdaten expandiert sind.
* > All masterdata are expanded
    TRY.
        lr_level = ref_hierseq->get_level( 1 ).
        lr_level->set_items_expanded( ).
      CATCH cx_salv_not_found.
    ENDTRY.

* > Einstellungen für die Positionsdaten (Slave)
* > options for the slavedata
* > Holen aller Spalten.
* > fetching of all columns
    TRY.
        lr_columns = ref_hierseq->get_columns( 2 ).
      CATCH cx_salv_not_found.
    ENDTRY.

    TRY.
        lr_column = lr_columns->get_column( 'MANDT' ).
        lr_column->set_technical( if_salv_c_bool_sap=>true ).
      CATCH cx_salv_not_found.
    ENDTRY.

* > Anzeigen des ALVs
* > show the alv.
    ref_hierseq->display( ).

  ENDMETHOD.

ENDCLASS.
* < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < <


* > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
*---------------------------------------------------------------------*
* SELECT-OPTIONS / SELECTION-SCREEN
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK b1.
  SELECT-OPTIONS so_jisnr FOR zle_jisk-exidv.
  SELECT-OPTIONS so_typ   FOR zle_jisk-typ.
SELECTION-SCREEN END OF BLOCK b1.


* > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >
*---------------------------------------------------------------------*
* START OF SELECTION
*---------------------------------------------------------------------*
START-OF-SELECTION.
DATA:
  so_conv_jisnr TYPE tt_rtab_exidv,
  so_conv_typ   TYPE tt_rtab_typ
  .

  so_conv_jisnr[] = so_jisnr[].
  so_conv_typ[]   = so_typ[].

  lcl_zjitm=>main( so_jisnr = so_conv_jisnr
                   so_typ   = so_conv_typ   ).

* < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < <

Message was edited by:

Mathias Rieger