The end user can move columns around, hide them or show columns that are not visible by default. These are changes to the layout of the ALV report and these changes can be stored in a "layout". Users can even set one of these layouts as his/her personal favorite, which means the report will start with the default the next time it started. For the user. Can layouts be made available to everyone ? Yes they can.
Layout settings that are personal and layout settings that are global can be recognized by the / in the name. To allow users to create/change/delete global settings, simply follow the example coding below. Of course if it is only some users that are allowed to do this, the user check (authorization check) should be done before implementing this.
REPORT ZDEMO_ALV_9_PERSONAL_LAYOUTS. include ZABAPCADABRA_EASY_ALV. data: gt_data type table of t100, go_alv type ref to lcl_easy_alv, "Define go_salv type ref to cl_salv_table, * To allow access to layout subclass lo_layout type ref to cl_salv_layout, lw_layout_key type salv_s_layout_key. start-of-selection. select * from t100 up to 20 rows into table gt_data. create object go_alv. go_alv->set_alv_from_template( changing content = gt_data salv_table = go_salv ). * Note that the system already recognizes this field as key field go_alv->set_field( fieldname = 'SPRSL' description_overall = 'Language code' ). go_alv->set_field( fieldname = 'ARBGB' description_overall = 'Work area' ). go_alv->set_field( fieldname = 'MSGNR' description_overall = 'Message number' ). * Allow the end user to change (and save) the layout: lo_layout = go_salv->get_layout( ). lw_layout_key-report = sy-cprog. lw_layout_key-logical_group = 'ZXYZ'. "< A code unifier, declares storage area * The key for layouts needs to be set to enable it's functionality. lo_layout->set_key( lw_layout_key ). lo_layout->set_default( abap_true ). lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ). go_alv->display( ). "Report
So effectively this will make some more options available here:
And after: