04-08-2016 10:05 AM
Hi,
I have a requirement that I am working on and looking for some pointers for one of the issues that I am facing now.
Requirement :
To build a parent-child relationship between two sap gui screens.
The parent screen is displaying an ALV grid (using cl_gui_alv_grid class) .
On Double-clicking on a particular record in the ALV , the corresponding details are displayed in the child screen.
The double click is handled(method)by a non-local class.
This is modeled and is working well.
Issue :
When I double click on any specific ALV record, the details are displayed correctly(below) in the
child screen but the ALV record is not highligted/selected in the ALV grid (so this is confusing/no information for the user).
I tried the following :
get_selected_nodes and set_selected_nodes methods.
cl_gui_cfw=>flush
refresh_table_display .
The double-clicked record is not highlighted.
Is there anything missing ? I have gone through some of the other blogs as well , a double-click is what is required .
Regards,
Abhay
[Note : The screens are configured using BDT framework , but the that should not be a problem as the PBO is getting
called again ]
04-08-2016 10:20 AM
Use the SET_SELECTED_ROWS method to highlight the lines you require.
Also check the parameters of the REFRESH_TABLE_DISPLAY in case of scrolling problems.
04-08-2016 10:20 AM
Use the SET_SELECTED_ROWS method to highlight the lines you require.
Also check the parameters of the REFRESH_TABLE_DISPLAY in case of scrolling problems.
04-08-2016 10:24 AM
I have tried both get_selected_rows and set_selected_rows.
[Also, tried setting in the debugging. ]
04-08-2016 10:42 AM
I've done exactly the same in the past using the SET_SELECTED_ROWS method.
No offense intended, but are you only refreshing the alv in the PBO of the screen? Or are you instantiating the objects all over again?
04-08-2016 10:56 AM
Sure.
I am creating single instance of the container and the grid and made it global.
So it’s the same instance that I use.
I tried a few combinations of the below call sequence. Open for sugestions.:
CALL METHOD go_alv_meap->set_table_for_first_display
CALL METHOD go_alv_meap->get_selected_rows
IMPORTING
et_index_rows = lt_index_rows.
CALL METHOD go_alv_meap->set_selected_rows
EXPORTING
it_index_rows = lt_index_rows.
go_alv_meap->refresh_table_display( ).
CALL METHOD cl_gui_cfw=>flush.
(May be BDT has also a role to play)
04-08-2016 11:04 AM
Nope, I meant the process before output. Do you check if the GO_ALV_MEAP object exists (and only refresh it if it does)? Or are you re-instantiating it each round-trip?
04-08-2016 11:07 AM
Not sure if I get you . But if the go_alv_meap instance doesnt exist, then the method call will dump with null reference.
04-08-2016 11:15 AM
Is your PBO structured like this?
IF gr_alvgrid IS INITIAL .
CREATE OBJECT gr_ccontainer
CREATE OBJECT gr_alvgrid
PERFORM prepare_field_catalog CHANGING gt_fieldcat.
PERFORM prepare_layout CHANGING gs_layout .
CALL METHOD gr_alvgrid->set_table_for_first_display
ELSE .
CALL METHOD gr_alvgrid->refresh_table_display
ENDIF .
04-08-2016 11:27 AM
No , at the moment , the if contains only the object creation part (there is no else) .
Then its the below sequence :
CALL METHOD go_alv_meap->set_table_for_first_display
CALL METHOD go_alv_meap->get_selected_rows
IMPORTING
et_index_rows = lt_index_rows.
CALL METHOD go_alv_meap->set_selected_rows
EXPORTING
it_index_rows = lt_index_rows.
CALL METHOD go_alv_meap->check_changed_data
IMPORTING
e_valid = lv_valid
** CHANGING
** c_refresh = 'X'
* .
IF lv_valid = 'X'.
go_alv_meap->refresh_table_display( ).
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
I've tried always calling them , setting values in debugging as well . Also it seems cl_gui_alv_grid has a private attribute mt_selected_rows.
04-08-2016 11:35 AM
There are no selected rows if you recreate (or reinstantiate) the ALV object. That resets everything.
Try adding the if statement, and create the GO_ALV_MEAP only once. That will do the trick.
04-08-2016 12:00 PM
Thanks Patrick. As I mentioned, the go_alv_meap is created only once there is no other instance created.
04-08-2016 12:15 PM
Nope, if you don't include the IF statement, the GO_ALV_MEAP is created each time you have a round-trip (when the user presses a button, triggers an event, etc).
If you don't believe me, just put a break-points on the create object and the set_table_for_first_display method. If you stop there more then once -> troubles
04-08-2016 1:17 PM
I believe you .
No it doesnt get called multiple times am taking care of that. Though the framework does flip some global_guid value for the instance between the refresh calls , but that could be internally for the framework .
I have fixed the issue.
The problem was in the sequence of the get_selected_rows and set_selected_rows.
I was calling the get_selected_rows and set_selected_rows after calling set_table_for_first_display .
The selected rows value in m_selected_rows attribute of cl_gui_alv_grid was getting cleared.
I am now calling the get_selected_rows before calling set_table_for_first_display and then calling the set.
I should have observed this earlier.
Thanks for spending some time on this. Appreciate.
04-08-2016 2:04 PM
04-08-2016 11:49 AM
Hi,
to highlight the lines in grid alv
create an event handler method
ex: handle_del FOR EVENT delayed_changed_sel_callback OF cl_gui_alv_grid.
call method in the method handle_del
CALL METHOD grid1->get_selected_rows
IMPORTING
et_index_rows = isel
then after set table for first display call SET_SELECTED_ROWS method.
thanks!!
04-08-2016 12:02 PM
Thanks Chintu. Can this not be handled in the double-click event ? Do I have to handle the other event as well ?
04-08-2016 12:06 PM
04-08-2016 1:20 PM