This website is not affiliated with, sponsored by, or approved by SAP AG.

ALV Grid: Optimize column width

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

ALV Grid: Optimize column width

Postby Frank183 » Tue Apr 12, 2011 8:09 am

Hi gang,

I'm experiencing a weird effect:

I have 2 ALV grids in a splitter container, the top grid displays order heads the bottom grid displays the order positions of the selected order head.
Fine, for both grids I set in the layout the zebra look and opt. col. width (LVC_S_LAYO-CWIDTH_OPT) to 'X'.

Now, for the top grid that works fine, but for the bottom grid only the zebra look works, the width of the columns are *not* optimized. If I look at the variant display the box *is* checked. But only when I change *anything* in the variant, all of a sudden it works.

Can anybody explain this ... ?

Thanks
Frank
Frank183
 
Posts: 30
Joined: Mon Nov 16, 2009 10:45 am
Location: Germany

Re: ALV Grid: Optimize column width

Postby Sharpshooter » Tue Apr 12, 2011 9:00 am

From OSS note 1009650:
Code: Select all
[12] Within the ALV Grid, the system calculates the optimal column width only during the first call due to performance reasons.
If the method CL_GUI_ALV_GRID->REFRESH_TABLE_DISPLAY is called for the grind instance, the system does not optimize the grid again.
To force the grid to be optimized again, the methods CL_GUI_ALV_GRID->GET_FRONTEND_LAYOUT and CL_GUI_ALV_GRID->SET_FRONTEND_LAYOUT must be called before the method CL_GUI_ALV_GRID->REFRESH_TABLE_DISPLAY is called. The transfer of the parameter CWIDTH_OPT = 'X' ensures that the column widths are calculated again.
In the object model of the ALV (package SALV_OM), you must reset the column optimization by calling the method cl_salv_columns->set_optimize before you call the method cl_salv_table->refresh.


While this is not exactly your case, maybe it helps with a solution?
Good luck!
Sharpshooter
 
Posts: 1171
Joined: Wed Mar 17, 2010 12:01 pm
Location: In the dark

Re: ALV Grid: Optimize column width

Postby Frank183 » Wed Apr 13, 2011 7:16 am

Hey !!!!!!!

That was spot on !

When I call set_table_for_first_display the itab with it is still empty. Only when an order head is selected the itab becomes filled with data, but then I call only a refresh_table_display.

I found out that before the refresh only a set_frontend_layout is needed.

Thanks a lot, man !!!
Frank
Frank183
 
Posts: 30
Joined: Mon Nov 16, 2009 10:45 am
Location: Germany

Re: ALV Grid: Optimize column width

Postby danilosaciloto » Mon Nov 07, 2016 1:50 pm

An easy way is to do as follows (after refresh_table_display)

DATA lv_alv_col_opt TYPE sy-ucomm.
lv_alv_col_opt = '&OPT'.
call method screen9001-alv-control->set_function_code
changing
c_ucomm = lv_alv_col_opt.

This always works doesn't matter if in PBO or PAI
danilosaciloto
 
Posts: 1
Joined: Mon Nov 07, 2016 1:27 pm


Return to ABAP

Who is online

Users browsing this forum: No registered users and 5 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.