‎2008 Jul 16 12:47 PM
Hi experts,
I'm using reuse_alv_grid_display. I defined a layout and saved it. How can I manage if I want my alv to use this layout as a default and display the list with this layout?
‎2008 Jul 16 1:23 PM
Hi,
You can hide the particular fields that you do not want to show in your initial layout. You can use the property 'no_out' of the field catalog to achieve this. In program you can write two subroutines, one for creating the field catalog for visible fields and one for hidden fields as follows,
*---- Move hidden fields -
FORM move_field_h USING field text.
gs_slis_fcat-fieldname = field.
gs_slis_fcat-no_out = 'X'.
gs_slis_fcat-seltext_l = text.
APPEND gs_slis_fcat TO gt_slis_fcat.
CLEAR gs_slis_fcat.
ENDFORM.
*---- Move Visible Fields -
FORM move_field USING field text.
gs_slis_fcat-fieldname = field.
gs_slis_fcat-seltext_l = text.
APPEND gs_slis_fcat TO gt_slis_fcat.
CLEAR : gs_slis_fcat.
ENDFORM.
-
And also you can create variants for the ALV display and can provide it as an input parameter to the user.
ALV allows users to save the layout variants.
DATA : LS_VARIANT TYPE DISVARIANT.
PARAMETER : p_var1 TYPE disvariant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var1.
PERFORM get_f4variant.
FORM get_f4variant .
DATA: l_variant_help TYPE disvariant,
l_variant TYPE disvariant,
l_exit TYPE c. " User-Exit while F4-Help
l_variant-report = sy-repid.
clear ls_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = l_variant
i_save = 'A'
IMPORTING
e_exit = l_exit
es_variant = l_variant_help.
IF l_exit = space.
p_var1 = l_variant_help-variant.
ls_variant-report = sy-repid.
ls_variant-variant = l_variant_help-variant.
ENDIF.
ENDFORM.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_pf_status_set = 'PF-STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_slis_layo
i_default = ' '
i_save = 'X'
is_variant = ls_variant
it_fieldcat = gt_slis_fcat
it_sort = gt_sort
i_grid_title = text
it_events = gt_events
TABLES
t_outtab = p_it_tab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Hence, you can make a defualt layout by hiding the unnecessary fields.
The end user if they require they can make their own layout and save it.
This is available in the search help of the parameter.
Select it if required and the ALV will be shown as per the layout variant.
Hope this helps.
BR,
Sreejith
‎2008 Jul 16 12:51 PM
hi,
declare S_LAYOUT TYPE SLIS_LAYOUT_ALV .
now build layout in one of the perform statement as
FORM LAYOUT .
*&&..Set Variant
S_VARIANT-USERNAME = SY-UNAME.
S_VARIANT-REPORT = V_REPID .
V_SAVE = C_A .
*&&..Layout
S_LAYOUT-ZEBRA = C_X .
S_LAYOUT-NO_HLINE = C_X .
S_LAYOUT-COLWIDTH_OPTIMIZE = C_X .
ENDFORM.
and pass this s_layout to reuse_alv_grid_display fm
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_BACKGROUND_ID = 'SIWB_WALLPAPER'
I_CALLBACK_PROGRAM = SY-REPID
i_callback_user_command = 'USER_COMMAND'
IS_LAYOUT = S_LAYOUT
IT_FIELDCAT = T_FIELDCAT
IT_SORT = T_SORT[]
I_SAVE = V_SAVE
IS_VARIANT = S_VARIANT
IT_EVENTS = T_EVENTS
TABLES
T_OUTTAB = T_FINAL
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
‎2008 Jul 16 12:54 PM
Am I wrong? I'm using like this:
DATA: gs_layout TYPE slis_layout_alv.
...
gs_layout = 'TEST'.
...
Then I pass:
... is_layout = gs_layout in the function call
‎2008 Jul 16 12:58 PM
Hi,
Save ur layout as default layout (settings->layout->layout management). Then ALV automatically selects it as default layout to display if u have not mentioned any other layout name.
No extra coding is required for it.
Regards,
Joy.
‎2008 Jul 16 1:02 PM
Dear Joyit,
I want to make it in the program code, is it possible to set the default layout to use during the list display somehow in the program code?
‎2008 Jul 16 1:23 PM
Hi,
You can hide the particular fields that you do not want to show in your initial layout. You can use the property 'no_out' of the field catalog to achieve this. In program you can write two subroutines, one for creating the field catalog for visible fields and one for hidden fields as follows,
*---- Move hidden fields -
FORM move_field_h USING field text.
gs_slis_fcat-fieldname = field.
gs_slis_fcat-no_out = 'X'.
gs_slis_fcat-seltext_l = text.
APPEND gs_slis_fcat TO gt_slis_fcat.
CLEAR gs_slis_fcat.
ENDFORM.
*---- Move Visible Fields -
FORM move_field USING field text.
gs_slis_fcat-fieldname = field.
gs_slis_fcat-seltext_l = text.
APPEND gs_slis_fcat TO gt_slis_fcat.
CLEAR : gs_slis_fcat.
ENDFORM.
-
And also you can create variants for the ALV display and can provide it as an input parameter to the user.
ALV allows users to save the layout variants.
DATA : LS_VARIANT TYPE DISVARIANT.
PARAMETER : p_var1 TYPE disvariant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_var1.
PERFORM get_f4variant.
FORM get_f4variant .
DATA: l_variant_help TYPE disvariant,
l_variant TYPE disvariant,
l_exit TYPE c. " User-Exit while F4-Help
l_variant-report = sy-repid.
clear ls_variant.
CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = l_variant
i_save = 'A'
IMPORTING
e_exit = l_exit
es_variant = l_variant_help.
IF l_exit = space.
p_var1 = l_variant_help-variant.
ls_variant-report = sy-repid.
ls_variant-variant = l_variant_help-variant.
ENDIF.
ENDFORM.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = sy-cprog
i_callback_pf_status_set = 'PF-STATUS'
i_callback_user_command = 'USER_COMMAND'
is_layout = gs_slis_layo
i_default = ' '
i_save = 'X'
is_variant = ls_variant
it_fieldcat = gt_slis_fcat
it_sort = gt_sort
i_grid_title = text
it_events = gt_events
TABLES
t_outtab = p_it_tab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Hence, you can make a defualt layout by hiding the unnecessary fields.
The end user if they require they can make their own layout and save it.
This is available in the search help of the parameter.
Select it if required and the ALV will be shown as per the layout variant.
Hope this helps.
BR,
Sreejith