Saving Layouts 
The standard function Change Layout can be accessed by users by clicking an icon in the toolbar. This icon allows users to adjust the current layout to their requirements for the lifetime of the control instance.
The application developer determines if users are allowed to save layouts and defines the saving options available.
Note
See also report BCALV_GRID_09 in development class SLIS.
In the default setting, users can save a default layout. If such a default layout exists, it is loaded when method set_table_for_first_display is called. If you do not want to allow users to create default layouts, set parameter I_DEFAULT of this method to SPACE.
Declare a variable for determining the saving options available to the user, and a structure for identifying a layout:
Syntax
DATA: X_SAVE, "for Parameter I_SAVE GS_variant TYPE DISVARIANT. "for parameter IS_VARIANT
The structure of type DISVARIANT must contain the report ID as a minimum:
Syntax
G_REPID = SY-REPID. GS_variant-REPORT = G_REPID.
Determine the saving options available to the user:
Syntax
X_SAVE = 'U'. "layouts can only be saved as user specific ones
Pass both variables using call set_table_for_first_display:
Syntax
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY EXPORTING I_STRUCTURE_NAME = 'SFLIGHT' IS_VARIANT = GS_variant I_SAVE = X_SAVE CHANGING IT_OUTTAB = GT_SFLIGHT.
Caution
If you pass only the actual parameter for IS_VARIANT, users can only load layouts but not save new ones. If you use parameter I_SAVE, passing a layout structure with IS_VARIANT is a required step.
The toolbar now includes a pull-down menu next to the layout icon that allows users to save and load layouts. Depending on the value of parameter I_SAVE, the following options for saving layouts are available:
Saving Options for Layouts
I_SAVE = SPACE |
Layouts cannot be saved. |
I_SAVE = 'U' |
Only user-defined layouts can be saved. |
I_SAVE = 'X' |
Only global layouts can be saved. |
I_SAVE = 'A' |
Both user-defined and global layouts can be saved. |