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: Retaining the default layout when refreshing the display

Former Member
0 Likes
2,383

Afternoon,

I have created a ALV grid. When the ALV grid is displayed for the first time using the method SET_TABLE_FOR_FIRST_DISPLAY the default layout is used. However when the grid is refreshed the default layout is lost. How can I ensure that the default layout is always displayed until the user selects a different one. If the user does select a different layout how can I ensure that this layout is always displayed until the users chooses a different one or the user exits the program.

Thanks and regards

John.

1 ACCEPTED SOLUTION
Read only

amit_khare
Active Contributor
0 Likes
1,241

Hi,

You have to save layout as variant.

Check this code for reference -

data: variant type disvariant.

variant-report = sy-repid.

variant-username = sy-uname.

CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IT_TOOLBAR_EXCLUDING = GT_EXCLUDE

IS_LAYOUT = GS_LAYOUT

<b>IS_VARIANT = VARIANT</b>

I_SAVE = 'A'

CHANGING

IT_FIELDCATALOG = GT_FIELDCAT

IT_OUTTAB = ITAB.

Regards,

Amit

Reward all helpful replies.

3 REPLIES 3
Read only

amit_khare
Active Contributor
0 Likes
1,242

Hi,

You have to save layout as variant.

Check this code for reference -

data: variant type disvariant.

variant-report = sy-repid.

variant-username = sy-uname.

CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING

IT_TOOLBAR_EXCLUDING = GT_EXCLUDE

IS_LAYOUT = GS_LAYOUT

<b>IS_VARIANT = VARIANT</b>

I_SAVE = 'A'

CHANGING

IT_FIELDCATALOG = GT_FIELDCAT

IT_OUTTAB = ITAB.

Regards,

Amit

Reward all helpful replies.

Read only

0 Likes
1,241

Amit,

Thanks for your comments. I have found that if you change the layout of an ALV grid (e.g. by making some fields editable) you cannot use Refresh Display to update the grid with the revised layout. However, you can use set_table_for_first_display.

Thanks

John.

Read only

Former Member
0 Likes
1,241

If the layout of a grid is changed you must use set_table_for_first_display to reflect that change.