11-03-2015 4:37 PM
Hi all,
i use cl_gui_alv_grid to display an ALV in my dynpro and i need to set the width of columns ; i read that i had to use the field outputlen (structure LVC_S_FCAT) but it don't work.
Do you have a sample for me ?
Regards
Eric
11-03-2015 6:23 PM
I've used this sample code with some success. The outputlen is in the build_fcat.
ALV Report using class CL_GUI_ALV_GRID ~ Team ABAP
Jeremy
11-03-2015 7:59 PM
11-04-2015 4:10 AM
11-04-2015 6:50 AM
Hi Eric,
Create a reference object to the class cl_salv_columns_table and use this set of code to optimize the column length
obj_columns = obj_salv->get_columns( ).
obj_columns->set_key_fixation( 'X' ).
obj_columns->set_optimize('X').
Regards,
Thulja
11-04-2015 7:43 AM
Hi Erik,
Pls check
CLEAR ls_fieldcat.
ls_fieldcat-fieldname = 'MATNR'.
ls_fieldcat-ref_tabname = 'VBAP'.
ls_fieldcat-ref_fieldname = 'MATNR'.
ls_fieldcat-outputlen = 30.
ls_fieldcat-key = 'X'.
APPEND ls_fieldcat TO pt_fieldcat.
11-04-2015 8:00 AM
please check this link http://scn.sap.com/message/5521374#5521374
11-04-2015 8:46 AM
11-06-2015 7:37 PM
11-18-2015 12:19 PM
Hi Eric,
Set the field CWIDTH_OPT as 'X' in layout structure LVC_S_LAYO.
Regards.
11-18-2015 12:25 PM
This is for a variable optimized column width, not for a fixed column width.
11-18-2015 12:40 PM
Hi Eric,
Sorry to say for this problem we d'not have any solution .
on more scenario,
we working with interactive oalv. before interaction we have proper aliened alv but after interaction that column width automatically reset .this is the situation i face when i tried to fix the column width in O alv.
11-18-2015 12:51 PM
You can only set a default/desired length (field OUTPUTLEN of field catalog) but user shall be able to change it, and of course you must remove the optimize column (field CWIDTH_OPT of layout)
A solution "could" be coded, you have to handle the event AFTER_REFRESH to check field catalog, (GET_FRONTEND_FIELDCATALOG) and if required, update it (SET_FRONTEND_FIELDCATALOG) and display again the grid (REFRESH_TABLE_DISPLAY)
Hint: Try to prevent infinite loop of refresh event <-> refresh method...
Regards,
Raymond
02-18-2021 9:51 AM
The "outputlen" field is not giving expected column width when variant details "is_variant" are passed while displaying ALV.
In layout as well as in field catalogue no flag is set for column width optimization.
Note:
A default layout is set but in layout the flag for column width optimization is set to false.
But still the column width is getting set to optimized one.
Please let me know if you are ware about this issue.
Thanks.
02-18-2021 10:16 AM
As I wrote some year ago, the field catalog are 'default' values and can be ovveride by user/variant.
Did you try my suggested solution: handle the event after_refresh to force again and again (but prevent infinite loop) the width of some fields even if user load a variant or set the optimize flag himself or herself.
Use GET/SET_FRONTEND_LAYOUT to clear CWIDTH_OPT and GET/SET_FRONTEND_FIELDCATALOG to set OUTPUTLEN and COL_OPT
02-18-2021 11:03 AM
Thanks a lot for your quick response Raymond.
Yes I got your point and will implement the GET/SET method for field catalogue/ layout to preserve the column width even after user actions.
But in this case it was not even coming for the first time.
In old default layout even after changing the optimize column it was not reflecting in the output.
So I created a new layout at global level and set it as default one with Optimize column flag as false.
And it is working now for first time.
02-18-2021 1:28 PM
Do a test when you have implemented the event handler, I seem to remember that it is also triggered at the first display, so it would also have fixed an initial variant with column optimization.