Enable SAP Users Create Own Layout Variants using set_table_for_first_display
SAP users want to configure ALV grid layout settings and change the standart ABAP report according to their requirements.
SAP users want to customize the ALV layout and create custom layouts for own use or for global use.
For an ABAP developer this means enabling SAP system users create User or Global layout variants for the ALV grid display.
If the ABAP programmer is using method set_table_for_first_display of cl_gui_alv_grid type ALV grid object, then it is very easy to let SAP users create own layout variants and manage layout variants.
To manage this task, ABAP developers can use is_variant and i_save export parameters of the set_table_for_first_display method call.
i_save parameter has 4 possible values.
U: An i_save parameter value "U" means that the user can only save user-specific layouts.
X: An i_save parameter value "X" means that the users are enabled to save only global layouts. So other users can also use these global layouts too.
A: An i_save parameter value "A" means that the SAP user can save both user specific and global layouts.
Space: An empty or space i_save parameter value which is default for i_save means users cannot save own layouts either global or user specific layout.
Below, ABAP developers can find example ABAP code which enables SAP users save own layout variants on ABAP ALV Grid screens.
Especially focus on the is_variant and i_save parameters, and gs_variant variable.
Note that I did not copy here all ABAP codes required for a real demo.
But the above ABAP codes are taken from a real working ABAP report.
ABAP developers should add their own codes for :
Populating gt_fieldcatalog variable for set_table_for_first_display method it_fieldcatalog parameter
Populating ALV Grid data, it_outtab parameter value which is gt_outtab variable here.