2011 Jan 31 3:02 PM
Hi all,
I am displaying an classic (not OOP) ALV grid, but I have one small cosmetic irritation in it.
The grid has columns width optimisation on ( w_layout-colwidth_optimize = 'X'.).
At the first showing there is no problem. All column sizes are correct.
The column sizes doesn't change after a refresh, despite the fact that the values of the columns become wider then before.
Could someone tell me please, how can I force the ALV to make an "automatic" column optimization after refresh?
KR.
anac
2011 Jan 31 8:02 PM
Hi anacanac,
look what I found at [Auto Refresh ALV List|http://www.sap-basis-abap.com/abap/auto-refresh-alv-list.htm]
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm TYPE syucomm
is_selfield TYPE slis_selfield. "#EC CALLED
CASE i_ucomm.
WHEN '&NTE'.
PERFORM f_read_data.
is_selfield-refresh = 'X'.
SET USER-COMMAND '&OPT'. " Optimize columns width
ENDCASE.
ENDFORM. " USER_COMMAND
Looks as it could solve the issue.
Regards,
Clemens
2011 Jan 31 8:02 PM
Hi anacanac,
look what I found at [Auto Refresh ALV List|http://www.sap-basis-abap.com/abap/auto-refresh-alv-list.htm]
*---------------------------------------------------------------------*
* FORM USER_COMMAND *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm TYPE syucomm
is_selfield TYPE slis_selfield. "#EC CALLED
CASE i_ucomm.
WHEN '&NTE'.
PERFORM f_read_data.
is_selfield-refresh = 'X'.
SET USER-COMMAND '&OPT'. " Optimize columns width
ENDCASE.
ENDFORM. " USER_COMMAND
Looks as it could solve the issue.
Regards,
Clemens
2011 Jan 31 8:28 PM
Hi Clemens,
Thank you for your quick answer.
I've already tried this. The refreshing works, perfectly, but unfortunately the column optimizing dosen't work.
Should I make some special setup in GUI?
,
2011 Feb 02 7:35 AM
Hi try to insert this
is_selfield-intlen = <width_value>.
try to debug and study the is_selfield catalog so that you can see what are the possible fields for column adjustment. thanks
2011 Feb 02 6:11 PM
Hi Clemens,
I tried what you suggested:
when I call REUSE_ALV_GRID_DISPLAY, it doesn't work, but in case of REUSE_ALV_LIST_DISPLAY it works perfectly.
Regards
anacanac
2011 Feb 02 6:26 PM
Hi Johnny,
unfortunately is_selfield hasn't got intlen field, but the field catalog has.
Seting fieldcat-intlen in user-command form is not effective. as I see....
KR
anacanac
2013 Aug 30 2:18 PM
Hi Laszlo,
try this in the end of form USER_COMMAND, works with ALV_GRID perfectly
DATA: l_grid(33),
ls_layout TYPE lvc_s_layo.
FIELD-SYMBOLS <fs_grid> TYPE REF TO cl_gui_alv_grid.
UNASSIGN <fs_grid>.
l_grid = '(SAPLSLVC_FULLSCREEN)GT_GRID-GRID'.
ASSIGN (l_grid) TO <fs_grid>.
IF <fs_grid> IS ASSIGNED.
CLEAR ls_layout.
CALL METHOD <fs_grid>->get_frontend_layout
IMPORTING
es_layout = ls_layout.
IF sy-subrc EQ 0.
ls_layout-cwidth_opt = 'X'.
CALL METHOD <fs_grid>->set_frontend_layout
EXPORTING
is_layout = ls_layout.
ENDIF.
2014 Nov 26 10:02 AM
It works - I would like to add one important information ... After reset frontend layout You need to call a method <fs_grid>->refresh_table_display.
2015 Oct 01 2:38 PM