2013 Jan 18 3:12 PM
Hello everyone,
I have created a report which calls 2 ALV Grids. Therefore I used ABAP OO.
I got a selection screen which calls the first ALV Grid with dynpro number 0100. It gives a list of data. If I click on one of the data rows, it calls the second ALV Grid with dynpro number 0110 and gives me a detailed overview of the line items of the clicked row of the first grid. Therefore I use event double_click. When I display the second grid and click on back (F3), i get back to the first grid. There I can for example double click on some other row and will get the line items of the new selected row, etc. etc.
In the second dynpro 0110 (for detailed line items) I separate between first call (creating ALV container) and further calls (refreshing ALV container). The display of the selected line items works fine. But I got some problems with the layout, because I canot change anything of the layout. When I e.g. try to mark a column for fading it out, after marking the column it gets immedialy unmarked, so that I canot fade it out. I think this happens because of the refresh_table_display. But when I do not use the refresh_table_display and always free and create the container, it works with the layout but my selected data in second grid is always the same like I have chosen when clicking on any of the rows for the first time. It does not get updated after clicking on another row.
Does anyone have an idea?
FORM alv_create_epo USING us_variant.
DATA: l_batch TYPE i,
ls_stable TYPE lvc_s_stbl.
* ---------------------------------------------------------------------*
* Für ersten Aufruf des ALV-Containers
* ---------------------------------------------------------------------*
IF gr_alv_epo IS NOT BOUND.
* Handelt es sich um eine Hintergrundverarbeitung?
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING
e_offline = l_batch.
* Container darf nicht erstellt werden bei Batch-Verarbeitung, sonst Dump!
IF l_batch IS INITIAL.
* CustomContainer für ALV instanziieren
CREATE OBJECT gr_container_epo
EXPORTING
container_name = 'CONTAINER_EPO'.
ENDIF.
* ALV-Instanz generieren
CREATE OBJECT gr_alv_epo
EXPORTING
i_parent = gr_container_epo
i_appl_events = 'X'.
* Ereignisbehandler
CREATE OBJECT evt_handler.
SET HANDLER evt_handler->handle_toolbar FOR gr_alv_epo.
SET HANDLER evt_handler->handle_user_command FOR gr_alv_epo.
SET HANDLER evt_handler->handle_double_click FOR gr_alv_epo.
SET HANDLER evt_handler->set_subtotal_text FOR gr_alv_epo.
* Zusätzliche Events für in KST-Bericht manipulierte Summen
IF p_kst IS NOT INITIAL.
SET HANDLER evt_handler->handle_after_refresh FOR gr_alv_epo.
SET HANDLER evt_handler->print_top_of_list FOR gr_alv_epo.
ENDIF.
* ALV-Grid ausgeben
CALL METHOD gr_alv_epo->set_table_for_first_display
EXPORTING
is_variant = us_variant
is_layout = gs_layout
i_save = 'A'
it_toolbar_excluding = gt_toolbar_excluding
CHANGING
it_outtab = <ft_data_epo>
it_fieldcatalog = gt_fieldcat_epo
it_sort = gt_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
* ---------------------------------------------------------------------*
* Für Folgeaufrufe des ALV-Containers
* ---------------------------------------------------------------------*
ELSE.
* Cursor bleibt nach Refresh bei ausgewählter Zeile und Spalte
ls_stable-row = 'X'.
ls_stable-col = 'X'.
CALL METHOD gr_alv_epo->refresh_table_display
EXPORTING
is_stable = ls_stable
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDIF.
ENDFORM. "alv_create_epo
Regards
Michael Boguth
2013 Jan 21 9:05 AM
"Try to mark a column for fading it out, after marking the column it gets immedialy unmarked"
Are you trying to do this manually with the ALV column after the list is displayed in the screen ?
Hello everyone,
I have created a report which calls 2 ALV Grids. Therefore I used ABAP OO.
I got a selection screen which calls the first ALV Grid with dynpro number 0100. It gives a list of data. If I click on one of the data rows, it calls the second ALV Grid with dynpro number 0110 and gives me a detailed overview of the line items of the clicked row of the first grid. Therefore I use event double_click. When I display the second grid and click on back (F3), i get back to the first grid. There I can for example double click on some other row and will get the line items of the new selected row, etc. etc.
In the second dynpro 0110 (for detailed line items) I separate between first call (creating ALV container) and further calls (refreshing ALV container). The display of the selected line items works fine. But I got some problems with the layout, because I canot change anything of the layout. When I e.g. try to mark a column for fading it out, after marking the column it gets immedialy unmarked, so that I canot fade it out. I think this happens because of the refresh_table_display. But when I do not use the refresh_table_display and always free and create the container, it works with the layout but my selected data in second grid is always the same like I have chosen when clicking on any of the rows for the first time. It does not get updated after clicking on another row.
Does anyone have an idea?
FORM alv_create_epo USING us_variant.
DATA: l_batch TYPE i,
ls_stable TYPE lvc_s_stbl.
* ---------------------------------------------------------------------*
* Für ersten Aufruf des ALV-Containers
* ---------------------------------------------------------------------*
IF gr_alv_epo IS NOT BOUND.
* Handelt es sich um eine Hintergrundverarbeitung?
CALL METHOD cl_gui_alv_grid=>offline
RECEIVING
e_offline = l_batch.
* Container darf nicht erstellt werden bei Batch-Verarbeitung, sonst Dump!
IF l_batch IS INITIAL.
* CustomContainer für ALV instanziieren
CREATE OBJECT gr_container_epo
EXPORTING
container_name = 'CONTAINER_EPO'.
ENDIF.
* ALV-Instanz generieren
CREATE OBJECT gr_alv_epo
EXPORTING
i_parent = gr_container_epo
i_appl_events = 'X'.
* Ereignisbehandler
CREATE OBJECT evt_handler.
SET HANDLER evt_handler->handle_toolbar FOR gr_alv_epo.
SET HANDLER evt_handler->handle_user_command FOR gr_alv_epo.
SET HANDLER evt_handler->handle_double_click FOR gr_alv_epo.
SET HANDLER evt_handler->set_subtotal_text FOR gr_alv_epo.
* Zusätzliche Events für in KST-Bericht manipulierte Summen
IF p_kst IS NOT INITIAL.
SET HANDLER evt_handler->handle_after_refresh FOR gr_alv_epo.
SET HANDLER evt_handler->print_top_of_list FOR gr_alv_epo.
ENDIF.
* ALV-Grid ausgeben
CALL METHOD gr_alv_epo->set_table_for_first_display
EXPORTING
is_variant = us_variant
is_layout = gs_layout
i_save = 'A'
it_toolbar_excluding = gt_toolbar_excluding
CHANGING
it_outtab = <ft_data_epo>
it_fieldcatalog = gt_fieldcat_epo
it_sort = gt_sort
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
* ---------------------------------------------------------------------*
* Für Folgeaufrufe des ALV-Containers
* ---------------------------------------------------------------------*
ELSE.
* Cursor bleibt nach Refresh bei ausgewählter Zeile und Spalte
ls_stable-row = 'X'.
ls_stable-col = 'X'.
CALL METHOD gr_alv_epo->refresh_table_display
EXPORTING
is_stable = ls_stable
EXCEPTIONS
finished = 1
OTHERS = 2.
ENDIF.
ENDFORM. "alv_create_epo
Regards
Michael Boguth
2013 Jan 18 6:06 PM
2013 Jan 21 8:07 AM
Hello Raymond,
thanks for your answer but I don't think that this is the problem. I already tried with is_variant and already got there to the differing handles.
is_variant is filled for Grid 1 at the start of the programm
************************************************************************
INITIALIZATION.
************************************************************************
* Variante vorbelegen
gs_variant-username = sy-uname.
gs_variant-report = sy-repid.
gs_variant-handle = 'SUM'.
for Grid 2 at the PBO of second dynpro...
MODULE status_0110 OUTPUT.
SET PF-STATUS 'Z_STATUS_ALV'.
SET TITLEBAR 'TITLE_ALV'.
* Variante vorbelegen
gs_variant-username = sy-uname.
gs_variant-report = sy-repid.
gs_variant-handle = 'EPO'.
PERFORM alv_fieldcat_epo CHANGING gt_fieldcat_epo.
PERFORM alv_layout_epo CHANGING gs_layout.
PERFORM alv_sort_epo CHANGING gt_sort.
PERFORM alv_toolbar CHANGING gt_toolbar_excluding.
PERFORM alv_create_epo USING gs_variant.
ENDMODULE. "status_0110 OUTPUT
Unfortunately it does not help.
I think it happens because of the refresh because when I try to rightclick one column for fading it out, I can see that the alv gets refreshed and because of the refresh the column gets immediately unmarked so that I canot fade it out.
Regards
Michael
2013 Jan 21 9:13 AM
Hi Michael,
For marking a field in the Layout. Use the below mentioned code.
GS_LAYOUT should be of type LVC_S_LAYO.
GS_LAYOUT-SEL_MODE = 'D'.
Hope this helps.
2013 Jan 21 8:46 AM
2013 Jan 21 8:51 AM
**For first Alv output
W_VARIANT-REPORT = SY-REPID.
w_variant-handle = 'ALV1'.
**For second alv Output
W_VARIANT1-REPORT = SY-REPID.
w_variant1-handle = 'ALV2'.
2013 Jan 21 9:21 AM
Hello friends,
I think that problem is when you selected a secondary list,
The seelcted row is fading,for that use the below stmt.
for getting the row color gs_filnal-light = '3'.
2013 Jan 21 9:01 AM
Hi Michael,
Please check with the Field Catlog you are filling seperately and correctly for both the ALVs.
Also for Freeing the display check the below method.
* Free the Container After Data is Displayed
CALL METHOD G_CONT->FREE( ). "Instance of CL_GUI_ALV_GRID
If you are still having problem with Layout
Pass the parameter 'X' to the Field I_CONSISTENCY_CHECK in SET_TABLE_FOR_FIRST_DISPLAY
Hope this helps
2013 Jan 21 9:05 AM
"Try to mark a column for fading it out, after marking the column it gets immedialy unmarked"
Are you trying to do this manually with the ALV column after the list is displayed in the screen ?
2013 Jan 21 9:12 AM
Yes. I got the problem only in the second (detailed) ALV screen. I got my list of columns and mark it by rightclicking.
Here is a screnshot of first ALV screen where it works.
2013 Jan 21 9:40 AM
Hi,
The problem is your PBO get's tirggered again in the second screen when the option is chosen from drop down, here the alv is refreshed again so that it retains the old vales passed to the ALV. In your case, the refresh need not be triggered in this case. Could you please check this by debugging.
2013 Jan 21 9:49 AM
Hm I was differing between set_table_for_first_display and refresh_table_display because without differenciation the data was not shown correctly.
I got my first alv grid and when i doubleclick on one value i get to the second detailed alv grid. So this is the set_table_for_first_display where the data is shown correctly.
But then - when i go back to first grid - and try to double-click on a differing value than at the first time, the data does not get refreshed and I see the detail value of the first click again. This is why I use the ELSE with the refresh.
2013 Jan 21 10:07 AM
Yes that is correct, I feel that the refresh is again triggered in the second screen after you right click on the column and set some thing.
2013 Jan 21 10:14 AM
Yes it is like this and this is the problem 🙂
After marking a column by rightclicking, I always get into PAI of second alv grid, and then into PBO of second alv grid and there I always get to the ELSE with my refresh because the grid instance already exists.
But I thought that it is normal that PAI/PBO gets triggered after marking a column?
2013 Jan 21 10:20 AM
No, it does not happen if you choose an option from right click menu unless due to some events ,
Could you please check the events registered from your side. 🙂 I am glad that atleast you got a hint to trouble shoot it.
2013 Jan 21 10:31 AM
You can check the demo program BCALV_TEST_GRID_EVENTS for more details.
2013 Jan 21 10:32 AM
Hm no it does not look like that one of the events is the reason. When I cut them out so that no event is raised I get to PAI as well.
But it is not like when choosing an option of the right click menu. It's before that! I don't get there because the refresh of the list is faster than the right click menu. I only sew for a second the right click context menu but I am not able to click on any line like 'Hide' for example.
When I try to debug with /h, I get immediately into PAI module of alv grid2 after rightclicking on the column.
2013 Jan 21 2:25 PM
After hours of searching I finally found it, thanks a lot Kesavadas!!!
You were right it was because of events, but not because of mine 🙂
In every SAP ALV Grid list I created in the last years I used the following source code for creating Grid instance, because I found it somewhere when I started progamming ALV Grids.
It is the parameter i_appl_events which looks like that it activates several additional events like reacting when marking a column and so getting me to PAI.
* ALV-Instanz generieren
CREATE OBJECT gr_alv_epo
EXPORTING
i_parent = gr_container_epo.
i_appl_events = 'X'.
I greyed it out now and it works fine. Thanks a lot for getting me into the right direction
Can anyone please tell me for what I need the application events?