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: 

Automatic column size opt. after refresh in ALV

Former Member
0 Kudos
8,071

Hi all,

I am displaying an classic (not OOP) ALV grid, but I have one small cosmetic irritation in it.

The grid has columns width optimisation on ( w_layout-colwidth_optimize = 'X'.).

At the first showing there is no problem. All column sizes are correct.

The column sizes doesn't change after a refresh, despite the fact that the values of the columns become wider then before.

Could someone tell me please, how can I force the ALV to make an "automatic" column optimization after refresh?

KR.

anac

1 ACCEPTED SOLUTION

Clemenss
Active Contributor
0 Kudos
2,300

Hi anacanac,

look what I found at [Auto Refresh ALV List|http://www.sap-basis-abap.com/abap/auto-refresh-alv-list.htm]

*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm     TYPE syucomm
                        is_selfield TYPE slis_selfield.     "#EC CALLED

  CASE i_ucomm.
    WHEN '&NTE'.
      PERFORM f_read_data.
      is_selfield-refresh = 'X'.
      SET USER-COMMAND '&OPT'.         " Optimize columns width
  ENDCASE.

ENDFORM.                               " USER_COMMAND

Looks as it could solve the issue.

Regards,

Clemens

8 REPLIES 8

Clemenss
Active Contributor
0 Kudos
2,301

Hi anacanac,

look what I found at [Auto Refresh ALV List|http://www.sap-basis-abap.com/abap/auto-refresh-alv-list.htm]

*---------------------------------------------------------------------*
*       FORM USER_COMMAND                                             *
*---------------------------------------------------------------------*
FORM user_command USING i_ucomm     TYPE syucomm
                        is_selfield TYPE slis_selfield.     "#EC CALLED

  CASE i_ucomm.
    WHEN '&NTE'.
      PERFORM f_read_data.
      is_selfield-refresh = 'X'.
      SET USER-COMMAND '&OPT'.         " Optimize columns width
  ENDCASE.

ENDFORM.                               " USER_COMMAND

Looks as it could solve the issue.

Regards,

Clemens

Former Member
0 Kudos
2,300

Hi Clemens,

Thank you for your quick answer.

I've already tried this. The refreshing works, perfectly, but unfortunately the column optimizing dosen't work.

Should I make some special setup in GUI?

,

Former Member
0 Kudos
2,300

Hi try to insert this

is_selfield-intlen = <width_value>.

try to debug and study the is_selfield catalog so that you can see what are the possible fields for column adjustment. thanks

Former Member
0 Kudos
2,300

Hi Clemens,

I tried what you suggested:

when I call REUSE_ALV_GRID_DISPLAY, it doesn't work, but in case of REUSE_ALV_LIST_DISPLAY it works perfectly.

Regards

anacanac

Former Member
0 Kudos
2,300

Hi Johnny,

unfortunately is_selfield hasn't got intlen field, but the field catalog has.

Seting fieldcat-intlen in user-command form is not effective. as I see....

KR

anacanac

bruno_moreira
Explorer
2,300

Hi Laszlo,

try this in the end of form USER_COMMAND, works with ALV_GRID perfectly

  DATA: l_grid(33),

        ls_layout TYPE  lvc_s_layo.

  FIELD-SYMBOLS <fs_grid> TYPE REF TO cl_gui_alv_grid.

  UNASSIGN <fs_grid>.

  l_grid = '(SAPLSLVC_FULLSCREEN)GT_GRID-GRID'.

  ASSIGN (l_grid) TO <fs_grid>.

  IF <fs_grid> IS ASSIGNED.

    CLEAR ls_layout.

    CALL METHOD <fs_grid>->get_frontend_layout

      IMPORTING

        es_layout = ls_layout.

    IF sy-subrc EQ 0.

    ls_layout-cwidth_opt = 'X'.

    CALL METHOD <fs_grid>->set_frontend_layout

      EXPORTING

        is_layout = ls_layout.

    ENDIF.

0 Kudos
2,300

It works - I would like to add one important information ... After reset frontend layout You need to call a method  <fs_grid>->refresh_table_display.

0 Kudos
2,300

yes it works. thank you...