‎2017 Aug 29 12:57 PM
Hello All,
I have an optimized ALV output where I can see all the columns are optimized. So far it is fine, but I would like to have fixed length output for a particular column(No optimization required). Can you please help me in providing how can we exclude optimization for a particular column in ALV output.
Thanks,
‎2017 Aug 29 1:59 PM
Hello,
With SALV You shoud try something like :
DATA: my_alv TYPE REF TO cl_salv_table,
lo_cols_tab TYPE REF TO cl_salv_columns_table,
lo_col_tab TYPE REF TO cl_salv_column_table.
lo_cols_tab = my_salv->get_columns( ).
lo_col_tab ?= lo_cols_tab->get_column( 'COLNAME' ).
lo_col_tab->SET_OPTIMIZED( abap_false ).
lo_col_tab->SET_OUTPUT_LENGTH( 20 ).
With ALV :
DATA t_fieldcatalog TYPE lvc_t_fcat.
DATA grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS <fieldcatalog> TYPE LINE OF lvc_t_fcat.
grid->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = t_fieldcatalog ).
LOOP AT t_fieldcatalog ASSIGNING <fieldcatalog>.
CASE <fieldcatalog>-fieldname.
WHEN 'COLNAME'.
<fieldcatalog>-COL_OPT = abap_false.
<fieldcatalog>-OUTPUTLEN = 20.
ENDCASE.
ENDLOOP.
grid->set_frontend_fieldcatalog( t_fieldcatalog ).
Best regards
Bertrand
‎2017 Aug 29 4:19 PM
Hi Bertrand,
Thanks for your reply. I know that we can do using SALV Model, but in my report(Old existing report with modifications) we are using REUSE_ALV_GRID_DISPLAY, so for this minor change, I can't switch from REUSE_ALV_GRID_DISPLAY to SALV Model. Can you please help me how to do using this FM?
Best Regards,
Saleem.
‎2017 Aug 29 4:43 PM
Oh I'm sorry but, as far as I know, it will be more complicated.
With FM REUSE, optimization is from layout; not from fieldcat. So I'm afraid you have to do this in several steps :
- display ALV optimized,
- unactivate optimization, change column length
- actualize display.
I'm sorry I don't know much about REUSE FM since cl_salv_table is far more versatile.
Best regards
Bertrand
‎2017 Aug 29 9:17 PM
Or maybe you can map the SLIS-type parameters you are currently using to LVC-type parameters, using the function module LVC_TRANSFER_FROM_SLIS, adjust COL_OPT in the field catalog (of type LVC_S_FCAT), and call the function module REUSE_ALV_GRID_DISPLAY_LVC instead of REUSE_ALV_GRID_DISPLAY. The refactoring would be quick, but you'll have to test everything.
‎2017 Aug 29 10:24 PM
What better excuse do you need to rewrite it into SALV?
That's not meant as sarcasm; unless you have a lot of custom ALV UI features (not talking about business logic), an SALV rewrite should be a piece of cake and greatly simplify it. A basic layout should not take more than half a day, a day or two if you have some fancy buttons that do stuff.
‎2017 Sep 07 12:44 PM
Thank you So much Sandra. I followed as suggested and I'm able to achieve now. Thanks again.
‎2017 Aug 29 4:20 PM
Can you please share a sample code for this. I'm using REUSE_ALV_GRID_DISPLAY for ALV Output.