Skip to Content

How to access table in on_user_command


I've developed a program using cl_salv_table and are using the event at_user_command to update data based on selected lines.

I've built this on the MVC pattern, which means I have a report <rep> using class lcl_data, class lcl_salv and lcl_salv_events.

The data table itab are filled inside lcl_data and passed back to <rep>, then passed inn as a changing parameter to lcl_salv. The issue is; how do I access it inside the user_command method?

I could of course made it completely global, visible to all, but that would void the MVC principle.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 01, 2017 at 09:31 PM

    I am not sure if understand your question compeltely but if you want to use an Attribute in Class A which is a private Attribute of class B you have to make them friends.



    LOCAL FRIENDS class1 class2 ...
    intf1 intf2 ...

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 01, 2017 at 03:29 PM

    Nice question. My approach is that the controller handles the user response (IMHO this is the 'correct' MVC behaviour).

    From your description, it seems to me your report is the controller? Make it an own class.

    class lcl_controller definition.
      public section. 
        methods start. 
        methods on_double_click for event double_click of cl_salv_events_table. 
      private section. 
        data: model type ref to lcl_data, 
              view  type ref to lcl_salv.
    class lcl_controller implementation.
      method start. 
        model = lcl_model=>new( )->load_from_db( ). 
        view = lcl_view=>new( model->get_data_ref( ) ).
        view->display( ). 
      method on_double_click. 
        model->update_time( row = row time = sy-uzeit ). 
        view->refresh( ).

    Note for larger datasets it's a good idea to work with data references to avoid excessive copying of large tables.

    Add comment
    10|10000 characters needed characters exceeded