Application Development 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: 

ALV grid display column length optimize

0 Kudos

Hi All,

i need to display the report in ALV grid display.i have a question and will explain with example.

i have a field material description to display,but when i display i need column to be compressed or widen based on field value.for ex.description legth is 40 character but data we see in table is at max 30 characters.so grid display shouldn't display 40 character length instead should display 30.but at runn time i dunno what is the field value so how to achieve this requirement ..thanks in advance

7 REPLIES 7

Ashg1402
Contributor
0 Kudos

Hi,

There is a field called outputlen in fieldcatalogs.  Adjust the value according to your need.

  But when there will be multiple rows of records having that material description value, the width of column will depend on the maximum length of the value . Don't pass anything and it will automatically adjust it.

Give it a try.

Regards

Ashish

0 Kudos

yes my requirement was this and it worked ..sorry for not keeping my question in correct way...its working .

0 Kudos

Oh , cool..

Sandra_Rossi
Active Contributor

Users may adjust automatically the widths of all columns, there's a checkbox in the options.

Programmatically, for cl_gui_alv_grid, there's the field CWIDTH_OPT to be set to A or X, in the layout parameter. There's also the option for only specified columns using the field catalog, parameter COL_OPT (same values). There's more info in the documentation.

If you use SALV, then it's method SET_OPTIMIZED of classes CL_SALV_COLUMNS or CL_SALV_COLUMN.

former_member196331
Active Contributor
0 Kudos

I hope in Field catalog you mention like below.

  fcat-fieldname = 'BALQTY'.

   fcat-tabname = 'IT_FINAL1'.

   fcat-seltext_l = 'Balance Qty'.

           the below are the properties.

          seltext_l      like dd03p-scrtext_l, " long key word

          seltext_m      like dd03p-scrtext_m, " middle key word

          seltext_s      like dd03p-scrtext_s, " short key word

manivel
Participant
0 Kudos

Hi Jai kumar,

You can achieve this using SLIS_LAYOUT_ALV.


Data : wk_layout type SLIS_LAYOUT_ALV.

Set wk_layout-colwidth_optimize  = 'X'


Pass the wk_layout in ALV Function module in exporting layout IS_LAYOUT.


It will work. Try this.



Regards,

Manivel S

0 Kudos

("It will work" if the op uses REUSE_ALV_GRID_DISPLAY function module)