Enable Adding Layout toolbar buttons

Up to this point, the output of the ALV does not allow the user to save changes made to layout. In this recipe, we will add coding that will allow saving user-specific layouts, load layouts, as well as specify a default layout.

How to do it...

For enabling layout saving, follow these steps:

  1. We declare two variables and also, an object reference to the class cl_salv_layout. In addition, a key is defined based on the type salv_s_layout_key.
  2. The get_layout method is then used to get the layout object for the ALV.
  3. The set_key method is called for the layout object mylayout. The mykey structure having the report name sy-repid is passed to this method.
  4. Next, the set_save_restriction method is called. It is passed the static ...

Get SAP ABAP Advanced Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.