How to save Layout in ALV List.

The user can be able to change the layout such as hiding columns, sorting specific columns or adding a filter in ALV Table List. The user can also be able to save the layouts of ALV Report in the toolbar. In order to enable this feature, the user must activate this option programmatically.

              There are two key steps to activate the save layout option in ALV table list.

  1. Assign the fields report, username of the structure disvariant.
  2. Set the exporting parameters is_variant, i_save during the method call SET_TABLE_FOR_FIRST_DISPLAY of ALV object.
  • Assign fields of structure DISVARIANT

It contains the details of the report and username to which the layout can be saved.

              DATA ls_variant TYPE disvariant.

              ls_variant-report = sy-repid.

              ls_variant-username = sy-uname.

  • Setting the exporting parameters is_variant, i_save.

There are different saving options such as ‘U’, ‘X’, ‘A’ for the exporting parameter i_save.

              U: User defined layout can be saved in this option. The layout cannot be seen by other users.

X: It is the Global layout. Other users can also see this layout.

              A: The user can save both user defined layout and Global layout.

              Let us look at the following SET_TABLE_FOR_FIRST_DISPLAY Method.

              CALL METHOD lr_gui_alv_grid -> set_table_for_first_display

                            EXPORTING

                                          is_variant = ls_variant.

                                          is_save = ‘U’.

              If you are having more than one ALV in the same program, then each ALV must be uniquely differentiated through the field HANDLE. The field HANDLE hold a ID with four characters which is unique. Each ALV variant is differentiated through this unique ID.