Saving Layouts
Purpose
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.
Prerequisites
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.
Process Flow
-
Declare a variable for determining the saving options available to the user, and a structure for identifying a layout:
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:
G_REPID = SY-REPID. GS_variant-REPORT = G_REPID.
-
Determine the saving options available to the user:
X_SAVE = 'U'. "layouts can only be saved as user specific ones
-
Pass both variables using call set_table_for_first_display :
set_table_for_first_display : 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.
Result
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. |