Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
29,850

By Gejo john, Lnt Infotech.

At times it is required that the user wants the option
of changing the layout of the ALV format and then Can Save it.
It can be also required that after some time they can delete it also , so a manage layout option sholud also be there.

This kind of requirement will mainly comes when there are lots of columns are there in ALV .


All you have to do to achive this is to pass IS_VARIANT  and I_SAVE as the export parameters in method
SET_TABLE_FOR_FIRST_DISPLAY.

Pass the program name to IS_VARIANT.
I_SAVE can have below values .

I_SAVE = blank " sAVE layout option will not be there .
I_SAVE = 'X'  " Global layout only
I_SAVE = 'A'  " BOTH User specific and global
I_SAVE = 'U'  " only user specific only


E.g :

  GV_VARIANT  TYPE DISVARIANT    VALUE SY-REPID,
  CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        IS_VARIANT                    = GV_VARIANT
        I_SAVE                        = 'A'
      CHANGING
        IT_OUTTAB                     = <FS_OUTTAB>
        IT_FIELDCATALOG               = <FS_FIELDCATALOG>
        IT_SORT                       = GT_SORT
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        OTHERS                        = 4.
    IF SY-SUBRC <> 0.
      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.


this will give u 4 options in the ALV tool bar
• Save layout: User can Save the layout
• Manage Layout : User can delete the saved layout 
• Choose Layout : User can select among the saved layouts
• Change Layout : User can change the layout and can save if required

Let me know if you have any doubts in this .

Thanks,

Gejo john