I want the ALV Grid to be displayed with a default layout. I am able to get the saved layout on the selection screen but when I select that layout still the output layout is not taking it.
Please refer the code which I have written.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
PERFORM variant_search CHANGING p_layout.
FORM variant_search CHANGING p_layout TYPE slis_vari.
DATA : lv_exit TYPE c,
ls_variant TYPE disvariant.
ls_variant-report = syst-repid.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
is_variant = ls_variant
i_save = 'A'
e_exit = lv_exit
es_variant = ls_variant
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc EQ 0 AND lv_exit IS INITIAL.
p_layout = ls_variant-variant.
ENDFORM. " variant_search
*-------The above piece of code helps me to save a layout.
Now when I enter the saved layout in my parameter, I want the output to take this layout and display the grid, but I dont know why it is not taking this layout. Please refer the code which I have written.
lr_layout = gr_alv->get_layout( ).
key-report = sy-repid.
lr_layout->set_key( key ).
lr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
Please let me know how can I achieve this.