04-23-2009 8:31 AM
Hi,
I have a requirement to dynamically alter the Column width of the ALV grid.
For eg, if I have 3 records in a single column ALV grid then the Columns width should be the maximum of the 3 records.
If the first record is of length 5, 2nd record of length 10 and 3rd record of length 8,
then the column width should dynamically take 10 (maximum length of all the records).
Please let me know if it is possible.
Thanks,
Harini
04-23-2009 8:34 AM
Hello,
Its possible. You have to pass the "column width optimizer" flag in the layout structure of the ALV.
DATA: ST_LAYOUT TYPE SLIS_LAYOUT_ALV.
ST_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = FP_ST_LAYOUT "Pass the layout struc. here
IT_FIELDCAT = FP_IT_FIELDCAT
IT_SORT = FP_IT_SORT
I_SAVE = 'A'
TABLES
T_OUTTAB = FP_IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Error in calling Standard ALV Functional Module
ENDIF.
BR,
Suhas
04-23-2009 8:34 AM
Hello,
Its possible. You have to pass the "column width optimizer" flag in the layout structure of the ALV.
DATA: ST_LAYOUT TYPE SLIS_LAYOUT_ALV.
ST_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
IS_LAYOUT = FP_ST_LAYOUT "Pass the layout struc. here
IT_FIELDCAT = FP_IT_FIELDCAT
IT_SORT = FP_IT_SORT
I_SAVE = 'A'
TABLES
T_OUTTAB = FP_IT_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Error in calling Standard ALV Functional Module
ENDIF.
BR,
Suhas
04-23-2009 8:34 AM
Hi,
One suggestion is, first get the maximum length from all the entries into one variable..say v_max_length. Now while filling the fieldcat, give ddic_outputlen = v_max_length for all the entries...
Try this...
Hope this helps you...
04-23-2009 8:45 AM