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 column width optimising

Former Member
0 Likes
22,181

hello,

I am facing a problem in optimising the width of a column while displaying an alv grid. the column i am displaying contains id's taken from table ADR6 and field name is SMTP_ADDR. I have tried giving the option CWIDTH_OPT as 'X' in layout structure LVC_S_LAYO , for getting the optimised column width.. i didnot get it and also i have tried changing in the filed caltalogue( of structure LVC_S_FCAT ) by setting the property of the column OUTPUTLEN to some value. But the column width it is showing in the grid display is of 241 characters..but my id's are too short to show such a big column width( roughly around 40 char)..kindly help me in solving this problem.

with regards,

sandeep akella.

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
8,926

I have tried with setting up the Column width in the field catalog and it is working fine for me.

Like:


  clear ls_fcat.
  ls_fcat-fieldname = 'EMAIL'.
  ls_fcat-coltext = 'Email'.
  ls_fcat-outputlen = 40.
  append ls_fcat to t_fieldcat.

Regards,

Naimesh Patel

10 REPLIES 10
Read only

Former Member
0 Likes
8,926

Try using this:

DATA: t_slis_layout_alv TYPE slis_layout_alv.

t_slis_layout_alv-colwidth_optimize = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

is_layout = t_slis_layout_alv

and so on and so forth..

This should give you optimum column.

Let me know if you need further help.

Thanks-

Read only

0 Likes
8,926

hello,

I am using object orientd fo r displayin the alv grid and to be more specfic the change is being made in standard report purchase requsetion-ME2N transaction. In thiis i have added 2 fields one is email id( field above mentioned ) and other one is gross price.

Read only

8,926

Thanks Guest. it's works fine.

Read only

0 Likes
8,926

yes working fine

Read only

naimesh_patel
Active Contributor
8,927

I have tried with setting up the Column width in the field catalog and it is working fine for me.

Like:


  clear ls_fcat.
  ls_fcat-fieldname = 'EMAIL'.
  ls_fcat-coltext = 'Email'.
  ls_fcat-outputlen = 40.
  append ls_fcat to t_fieldcat.

Regards,

Naimesh Patel

Read only

0 Likes
8,926

hello,

I have tried the same code ..but i am not gettin it.

with regards,

sandeep akella.

Read only

0 Likes
8,926

use these options.

LVC_S_FCAT-COL_OPT = 'X'.
LVC_S_FCAT-COLTEXT = 'Email'.

Read only

Former Member
0 Likes
8,926

Try COL_OPT field in Layout.

Read only

guillaume-hrc
Active Contributor
0 Likes
8,926

Hi,

An approach I just discovered (I use FM in this case altough I'm not very fond of them....) is the following.

I also used a (nasty) trick to get access to the underlying CL_ALV_GUI_GRID object.

In the ALV_USER_COMMAND routine:


ASSIGN ('(SAPLSLVC_FULLSCREEN)GT_GRID-GRID') TO <lo_grid>.

CHECK <lo_grid> IS ASSIGNED.

lv_ucomm =  '&OPT'.

<lo_grid>->refresh_table_display( EXPORTING i_soft_refresh = space ).  " necessary before optimizing columns

<lo_grid>->set_function_code( CHANGING c_ucomm = lv_ucomm ).


Best regards,

Guillaume

Read only

0 Likes
8,926

You can use FM 'GET_GLOBALS_FROM_SLVC_FULLSCR' to get reference of the ALV Grid instead of using field symbols.