Skip to Content
1

How to access table in on_user_command

Sep 01, 2017 at 01:30 PM

61

avatar image

Hi,

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.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Holger Homann Sep 01, 2017 at 09:31 PM
0

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.

CLASS - LOCAL FRIENDS

Syntax

CLASS class DEFINITION
LOCAL FRIENDS class1 class2 ...
intf1 intf2 ...

Share
10 |10000 characters needed characters left characters exceeded
Mike Pokraka Sep 01, 2017 at 03:29 PM
0

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.
endclass. 

class lcl_controller implementation.
  method start. 
    model = lcl_model=>new( )->load_from_db( ). 
    view = lcl_view=>new( model->get_data_ref( ) ).
    view->display( ). 
  endmethod.

  method on_double_click. 
    model->update_time( row = row time = sy-uzeit ). 
    view->refresh( ).
  endmethod.

endclass.

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

Share
10 |10000 characters needed characters left characters exceeded