Skip to Content
author's profile photo Former Member
Former Member

ALV Choose Layout on selection screen

Hi,

I have a requirement to have a parameter in the selection screen of the report where the users can choose the saved alv layouts. I require the list of layouts to be displayed when the f4 help is clicked or the choose layout popup to get displayed.

Please let me know what function module to use.

Thanks,

Harini

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Dec 14, 2009 at 09:20 AM

    FM: REUSE_ALV_VARIANT_F4 & how to implement check BCALV_TEST_GRID.

    Further details on SDN.

    BR,

    Suhas

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2009 at 09:23 AM
    PARAMETERS: p_layout TYPE slis_vari.
    
    DATA: g_alv_table TYPE REF TO cl_salv_table.
    
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_layout.
      PERFORM select_layout.
    
    FORM select_layout.
      DATA: ls_layout_key  TYPE salv_s_layout_key,
            ls_layout_info TYPE salv_s_layout_info.
      ls_layout_key-report = sy-repid.
      ls_layout_info = cl_salv_layout_service=>f4_layouts( ls_layout_key ).
      p_layout = ls_layout_info-layout.
    ENDFORM.                    "select_layout
    
    FORM display_data.
    ...
      DATA: l_layout      TYPE REF TO cl_salv_layout,
            ls_layout_key TYPE salv_s_layout_key.
      l_layout = g_alv_table->get_layout( ).
      ls_layout_key-report = sy-repid.
      l_layout->set_key( ls_layout_key ).
      l_layout->set_save_restriction( ).
      l_layout->set_initial_layout( p_layout ).
    ...
    ENDFORM.                    "display_data
    

    /Christoffer

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2009 at 09:23 AM

    To show default layouse set in the selection scree put the below code in the INITIALIZATION event.

    PARAMETERS p_vari LIKE disvariant-variant.

    ----


    INITIALIZATION.

    */Get the default variant

    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'

    EXPORTING

    i_save = 'A'

    CHANGING

    cs_variant = gs_alv_variant

    EXCEPTIONS

    not_found = 2.

    IF sy-subrc = 0.

    p_vari = gs_alv_variant-variant.

    ENDIF.

    ----


    AT SLECTION-SCREEN ON <your selection screen field name> VALUE REQUEST.

    gs_alv_variant-report = gf_alv_repid.

    CALL FUNCTION 'REUSE_ALV_VARIANT_F4'

    EXPORTING

    is_variant = gs_alv_variant

    i_save = 'A'

    IMPORTING

    es_variant = gs_alv_variant

    EXCEPTIONS

    not_found = 2.

    IF sy-subrc = 2.

    MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ELSE.

    p_vari = gs_alv_variant-variant.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      What is the use of showing the default layout in the selection screen? The default layout will be used if you don't specify a layout in the selection screen. No need to write code to get it.

      /Christoffer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2009 at 09:25 AM
    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 14, 2009 at 09:18 AM

    Hi Harini!

    Please use

    call function 'HR_F4_FOR_ALV_VARIANT'

    exporting

    current_report = o_repid

    importing

    variant = variant.

    Kind regards

    Peter

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.