Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Grid optimization issue

Former Member
0 Likes
1,576

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,

7 REPLIES 7
Read only

bertrand_delvallee
Active Participant
0 Likes
1,404

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

Read only

0 Likes
1,404

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.

Read only

0 Likes
1,404

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

Read only

1,404

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.

Read only

0 Likes
1,404

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.

Read only

1,404

Thank you So much Sandra. I followed as suggested and I'm able to achieve now. Thanks again.

Read only

Former Member
0 Likes
1,404

Can you please share a sample code for this. I'm using REUSE_ALV_GRID_DISPLAY for ALV Output.