Application Development and Automation 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: 
Read only

SALV doesn't work

Former Member
0 Likes
3,472

Hi,

i have a problem with my salv report.

after selecting data it does not show the grid. it's working, but the grid is not visible, i don't know why. could someone phelp me please?

thank you.

bye adalbert

START-OF-SELECTION.

...

PERFORM alv_anzeigen.
END-OF-SELECTION.

CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: on_user_command FOR EVENT added_function OF cl_salv_events IMPORTING e_salv_function.
    CLASS-METHODS: on_double_click FOR EVENT double_click OF cl_salv_events_table IMPORTING row column.
    CLASS-METHODS: handle_user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING e_ucomm  .
    CLASS-METHODS: handle_toolbar  FOR EVENT toolbar OF cl_gui_alv_grid  IMPORTING e_object.
  PRIVATE SECTION.
ENDCLASS.

CLASS lcl_eventhandler IMPLEMENTATION.
  METHOD handle_toolbar.
    DATA: ls_toolbar  TYPE stb_button.
* append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
* append an icon to show booking table
    CLEAR ls_toolbar.
    MOVE 'BOOKINGS' TO ls_toolbar-function.
    MOVE icon_employee TO ls_toolbar-icon.
    MOVE 'Show Bookings'(111) TO ls_toolbar-quickinfo.
    MOVE 'Detail'(112) TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.                    "handle_toolbar

  METHOD on_double_click. break pr900011. ENDMETHOD.
  METHOD on_user_command.break pr900011. ENDMETHOD.
  METHOD handle_user_command.
    CASE e_ucomm.
      WHEN 'BOOKINGS'.
        break-point.
    ENDCASE.
  ENDMETHOD.                    "on_user_command
ENDCLASS.

FORM alv_anzeigen.
  IF custom_container1 IS INITIAL.
* create a custom container control for our ALV Control
    CREATE OBJECT custom_container1
      EXPORTING
        container_name              = 'C1'
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5.
    IF sy-subrc NE 0.
* add your handling, for example
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = g_repid
          txt2  = sy-subrc
          txt1  = 'The control could not be created'(510).
    ENDIF.
  ENDIF.

  TRY.
*   Aufbau SALV-Struktur je nachdem was in SelScreen gewählt
      cl_salv_table=>factory( EXPORTING r_container    = custom_container1
                              IMPORTING r_salv_table = gr_table
                              CHANGING t_table = gt_process ).

      go_table_functions_list = gr_table->get_functions( ).
      go_table_functions_list->set_all( abap_true ).

* SALV-Struktur konfigurieren
      gr_display = gr_table->get_display_settings( ).
      gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
      gr_display->set_fit_column_to_table_size( 'X' ).
      gr_display->set_list_header_size( EXPORTING value = '0' ).
      gr_display->set_list_header( 'Übersicht CL-Prozesse' ).
      gr_display->set_horizontal_lines( 'X' ).
*      gr_display->set_min_linesize( value = '1280' ).
      gr_display->set_vertical_lines( 'X' ).

* Seitliche Selektionsleiste aktivieren
      gr_selections = gr_table->get_selections( ).
      gr_selections->set_selection_mode(
      if_salv_c_selection_mode=>row_column ).

* Events abgreifen
      gr_events = gr_table->get_event( ).

* Events behandeln
      CREATE OBJECT event_handler.
      SET HANDLER event_handler->on_user_command FOR gr_events.
      SET HANDLER event_handler->on_double_click FOR gr_events.

      gr_table->set_screen_status(
        EXPORTING
          report        =   sy-repid  " ABAP-Programm, aktuelles Rahmenprogramm
          pfstatus      sy-pfkey   " Bildschirmbilder, aktueller GUI-Status
*          set_functions = C_FUNCTIONS_NONE    " ALV: Datenelement für Konstanten      ).
      gr_table->display( ).
      PERFORM grab_toolbar" Muss nach dem Display aufgerufen werden
            gr_table->refresh(
*        EXPORTING
*          s_stable     =     " ALV-Control: Refresh-Stabilität
*          refresh_mode = IF_SALV_C_REFRESH=>SOFT    " ALV: Datenelement für Konstanten      ).
            custom_container1->finalize( ).
    CATCH cx_salv_msg .
  ENDTRY.
ENDFORM.

FORM grab_toolbar .
  FIELD-SYMBOLS: <child> LIKE LINE OF custom_container1->children.
  DATA: lo_grid TYPE REF TO cl_gui_alv_grid.
  READ TABLE custom_container1->children INDEX 1 ASSIGNING <child>.

  lo_grid ?= <child>.
  SET HANDLER lcl_eventhandler=>handle_toolbar FOR lo_grid.
  SET HANDLER lcl_eventhandler=>handle_user_command FOR lo_grid.

  lo_grid->refresh_table_display( ).
ENDFORM.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,043

Hi,

replace

cl_salv_table=>factory( EXPORTING r_container    = custom_container1
                              IMPORTING r_salv_table = gr_table
                              CHANGING t_table = gt_process ).


with

CALL METHOD cl_salv_table=>factory
                 IMPORTING r_salv_table = gr_table
                               CHANGING t_table = gt_process.



and try please

Hi,

i have a problem with my salv report.

after selecting data it does not show the grid. it's working, but the grid is not visible, i don't know why. could someone phelp me please?

thank you.

bye adalbert

START-OF-SELECTION.

...

PERFORM alv_anzeigen.
END-OF-SELECTION.

CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS: on_user_command FOR EVENT added_function OF cl_salv_events IMPORTING e_salv_function.
    CLASS-METHODS: on_double_click FOR EVENT double_click OF cl_salv_events_table IMPORTING row column.
    CLASS-METHODS: handle_user_command FOR EVENT user_command OF cl_gui_alv_grid IMPORTING e_ucomm  .
    CLASS-METHODS: handle_toolbar  FOR EVENT toolbar OF cl_gui_alv_grid  IMPORTING e_object.
  PRIVATE SECTION.
ENDCLASS.

CLASS lcl_eventhandler IMPLEMENTATION.
  METHOD handle_toolbar.
    DATA: ls_toolbar  TYPE stb_button.
* append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.
    APPEND ls_toolbar TO e_object->mt_toolbar.
* append an icon to show booking table
    CLEAR ls_toolbar.
    MOVE 'BOOKINGS' TO ls_toolbar-function.
    MOVE icon_employee TO ls_toolbar-icon.
    MOVE 'Show Bookings'(111) TO ls_toolbar-quickinfo.
    MOVE 'Detail'(112) TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.                    "handle_toolbar

  METHOD on_double_click. break pr900011. ENDMETHOD.
  METHOD on_user_command.break pr900011. ENDMETHOD.
  METHOD handle_user_command.
    CASE e_ucomm.
      WHEN 'BOOKINGS'.
        break-point.
    ENDCASE.
  ENDMETHOD.                    "on_user_command
ENDCLASS.

FORM alv_anzeigen.
  IF custom_container1 IS INITIAL.
* create a custom container control for our ALV Control
    CREATE OBJECT custom_container1
      EXPORTING
        container_name              = 'C1'
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5.
    IF sy-subrc NE 0.
* add your handling, for example
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel = g_repid
          txt2  = sy-subrc
          txt1  = 'The control could not be created'(510).
    ENDIF.
  ENDIF.

  TRY.
*   Aufbau SALV-Struktur je nachdem was in SelScreen gewählt
      cl_salv_table=>factory( EXPORTING r_container    = custom_container1
                              IMPORTING r_salv_table = gr_table
                              CHANGING t_table = gt_process ).

      go_table_functions_list = gr_table->get_functions( ).
      go_table_functions_list->set_all( abap_true ).

* SALV-Struktur konfigurieren
      gr_display = gr_table->get_display_settings( ).
      gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
      gr_display->set_fit_column_to_table_size( 'X' ).
      gr_display->set_list_header_size( EXPORTING value = '0' ).
      gr_display->set_list_header( 'Übersicht CL-Prozesse' ).
      gr_display->set_horizontal_lines( 'X' ).
*      gr_display->set_min_linesize( value = '1280' ).
      gr_display->set_vertical_lines( 'X' ).

* Seitliche Selektionsleiste aktivieren
      gr_selections = gr_table->get_selections( ).
      gr_selections->set_selection_mode(
      if_salv_c_selection_mode=>row_column ).

* Events abgreifen
      gr_events = gr_table->get_event( ).

* Events behandeln
      CREATE OBJECT event_handler.
      SET HANDLER event_handler->on_user_command FOR gr_events.
      SET HANDLER event_handler->on_double_click FOR gr_events.

      gr_table->set_screen_status(
        EXPORTING
          report        =   sy-repid  " ABAP-Programm, aktuelles Rahmenprogramm
          pfstatus      sy-pfkey   " Bildschirmbilder, aktueller GUI-Status
*          set_functions = C_FUNCTIONS_NONE    " ALV: Datenelement für Konstanten      ).
      gr_table->display( ).
      PERFORM grab_toolbar" Muss nach dem Display aufgerufen werden
            gr_table->refresh(
*        EXPORTING
*          s_stable     =     " ALV-Control: Refresh-Stabilität
*          refresh_mode = IF_SALV_C_REFRESH=>SOFT    " ALV: Datenelement für Konstanten      ).
            custom_container1->finalize( ).
    CATCH cx_salv_msg .
  ENDTRY.
ENDFORM.

FORM grab_toolbar .
  FIELD-SYMBOLS: <child> LIKE LINE OF custom_container1->children.
  DATA: lo_grid TYPE REF TO cl_gui_alv_grid.
  READ TABLE custom_container1->children INDEX 1 ASSIGNING <child>.

  lo_grid ?= <child>.
  SET HANDLER lcl_eventhandler=>handle_toolbar FOR lo_grid.
  SET HANDLER lcl_eventhandler=>handle_user_command FOR lo_grid.

  lo_grid->refresh_table_display( ).
ENDFORM.

4 REPLIES 4
Read only

Former Member
0 Likes
2,044

Hi,

replace

cl_salv_table=>factory( EXPORTING r_container    = custom_container1
                              IMPORTING r_salv_table = gr_table
                              CHANGING t_table = gt_process ).


with

CALL METHOD cl_salv_table=>factory
                 IMPORTING r_salv_table = gr_table
                               CHANGING t_table = gt_process.



and try please

Read only

0 Likes
2,043

Hi,

thank you for your Answer. its work now . But the Problem is, that i need a button.

So my idea was to create a container-Object and add a eventhandler with a toolbar to this.

its not possible to add a button to alv_table. Do you have a idea? is that possible?

regards

adalbert

Read only

Former Member
0 Likes
2,043

Go back to program SALV_DEMO_TABLE_REAL_SIMPLE.  You need the display method.

Read only

0 Likes
2,043

hi,

thank you for you post. i use the display method, but there is an another problem. adbul wrote a correct note, but my target to have a button in the grid is not reached.

thank you and bye

adalbert