0

I need to modify an old report using REUSE_ALV_GRID_DISPLAY. The requirement is that all columns are optimized except for one. As far as I can tell, i can only set optimization for all with layout-colwidth_optimize.

Is there a way to deactivate optimization for a single column?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
Kevin Holtkamp
  • 479
  • 4
  • 17

1 Answers1

1

You could just loop over your field catalog and do something like this:

LOOP AT lt_fcat INTO DATA(ls_fcat).
  CASE ls_fcat-fieldname.
    WHEN 'YOUR_COL'.
      ls_fcat-outputlen = 10.

    WHEN OTHERS.
      ls_fcat-col_opt = 'X'.
  
  ENDCASE.
  MODIFY lt_fcat FROM ls_fcat.
ENDLOOP.

Then remove the colwidth_optimize from your layout. I can't test right now but it should work.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Leo
  • 61
  • 5
  • We are using `REUSE_ALV_FIELDCATALOG_MERGE` to generate the field catalog, which returns `slis_t_fieldcat_alv`, which does not have a field called col_opt – Kevin Holtkamp Jul 20 '22 at 12:18
  • Have you solved the problem? I'd just edit the default layout to fit the desired column width. If you really want to have the width automatically adjust, you could try building your field catalog as `lvc_t_fieldcat` (probably have to include the layout as well) and passing everything through FM `LVC_TRANSFER_TO_SLIS`. Alternatively you could find the longest string in the column by looping over the output table and use that to set the column width. Probably not best practice though. – Leo Jul 21 '22 at 13:20