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?

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.