2017 Sep 01 2:30 PM
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.
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.
2017 Sep 01 4: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.
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.
2017 Sep 01 10: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.
CLASS - LOCAL FRIENDS
Syntax
CLASS class DEFINITION
LOCAL FRIENDS class1 class2 ...
intf1 intf2 ...
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |