ALV layout in selection criteria

Dear Friends,
I have created a webdynpro report with 2 views. 1st view contains all selction criteria and 2nd view contains ALV.
I have created couple of layouts for ALV using settings option. By default we will have [Standard View]. Every thing working fine.
Now my user is requesting layout also in the selection screen as dropdown and whatever layout is selected in selection criteria should apply to ALV in 2nd screen.
Please let me know how can we do this. Thank you.

Hi vijay,
Just do one thing create an attribute DES of NUMC2 in the COMPONENT CONTEXT node  and
drag that to local view.
Create dropdown box and fill with the four or five designs that are there
in the layout the values you can get from domain of WDUI_GROUP_DESIGN.
Now what you do is bind this attribute to the design property in the layout.
When user select say STANDARD, this particular string will be stored in the attribute DES.
Now in the view two drag that node which contains that attribute DES to local context
and bind that to DESIGN property of that table.
Now DES contains the one user selected int he initial screen and now set that to the view two,
I hope it gives you idea.
Regards and Best wishes.

Similar Messages

  • ALV Layout on selection screen?

    Is it possible to offer the ALV Layouts on the selection screen? And how can i pass such a variant to the reuse-FM?

    Hi,
    Yes u can do it.Check this sample code
    Variant for ALV display
    SELECTION-SCREEN BEGIN OF BLOCK 0 WITH FRAME TITLE text-000.
    <b>PARAMETERS: p_varnt LIKE disvariant-variant.</b>
    DATA:      w_save(1) TYPE c,
                w_default(1) TYPE c,
                i_variant LIKE disvariant,
                i_variant1 LIKE disvariant.
    INITIALIZATION.
      i_variant-report = w_repid.
      i_variant1 = i_variant.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save     = w_save
           CHANGING
                cs_variant = i_variant1
           EXCEPTIONS
                not_found  = 2.
      IF sy-subrc = 0.
        p_varnt = i_variant1-variant.
      ENDIF.
    Process on value request (list of possible variants)
    <b>AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varnt.</b>
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant          = i_variant
                i_save              = w_save
              it_default_fieldcat =
           IMPORTING
                e_exit              = w_exit
                es_variant          = i_variant1
           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.
        IF w_exit = space.
          p_varnt = i_variant1-variant.
        ENDIF.
      ENDIF.
    <b>AT SELECTION-SCREEN.</b>
       IF NOT p_varnt IS INITIAL.
        MOVE i_variant TO i_variant1.
        MOVE p_varnt TO i_variant1-variant.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  i_save     = w_save
             CHANGING
                  cs_variant = i_variant1.
        i_variant = i_variant1.
      ELSE.
        PERFORM variant_init.
      ENDIF.
    START_OF_SELECTION.
    Call ABAP/4 List Viewer
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_INTERFACE_CHECK           = ' '
               i_callback_program          =  w_repid
            I_CALLBACK_PF_STATUS_SET    = ' '
            I_CALLBACK_USER_COMMAND     = ' '
            I_CALLBACK_TOP_OF_PAGE      = ' '
            I_CALLBACK_HTML_TOP_OF_PAGE = ' '
            I_CALLBACK_HTML_END_OF_LIST = ' '
               i_structure_name            = 'SFLIGHT'
               i_background_id         = 'ALV_BACKGROUND'
            I_GRID_TITLE                =
            I_GRID_SETTINGS             =
               is_layout                   = i_layout
               it_fieldcat                 = i_fieldcat[]
            IT_EXCLUDING                =
               it_special_groups           = i_sp_group[]
               it_sort                     = i_sort[]
            IT_FILTER                   =
            IS_SEL_HIDE                 =
            I_DEFAULT                   = 'X'
               i_save                      = w_save
              <b> is_variant                  = i_variant</b>
               it_events                   = i_events[]
            IT_EVENT_EXIT               =
               is_print                    = i_print
            IS_REPREP_ID                =
            I_SCREEN_START_COLUMN       = 0
            I_SCREEN_START_LINE         = 0
            I_SCREEN_END_COLUMN         = 0
            I_SCREEN_END_LINE           = 0
       IMPORTING
            E_EXIT_CAUSED_BY_CALLER     =
            ES_EXIT_CAUSED_BY_USER      =
           TABLES
                t_outtab                    = i_sflight
          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.
    Hope u understood.
    Thanks&Regards,
    Ruthra.

  • How can i pull alv layouts for selection screen ?

    hello ,
    i search way to give the user option to choose his layout,
    i sow here examples that look good , but 
    all of tham talk about function :
    "REUSE_ALV_VARIANT_DEFAULT_GET"
    i run it in 'se37' and no data is pull ,
    i know that there is layouts for my alv report ,
    i use it like this in my report and in 'se37' :
    CLEAR ls_variant.
      ls_variant-report = sy-repid.
      ls_variant-handle = 'LIST'.
       MOVE ls_variant TO def_variante.
       MOVE vari TO def_variante-variant.
    CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = 'A'
        CHANGING
          cs_variant = def_variante
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        p_vari = def_variante-variant.
      ENDIF.
    thanks

    Hi,
    Try this.
    INITIALIZATION.
    Get Default display variant
      PERFORM f200_display_default_variants.
    Enable variant saving
    data   w_variant TYPE disvariant.
    FORM f200_display_default_variants.
    *initialize to default layout if one exist.
      w_variant-report   = sy-repid.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save        = 'A'
           CHANGING
                cs_variant    = w_variant
           EXCEPTIONS
                wrong_input   = 1
                not_found     = 2
                program_error = 3
                OTHERS        = 4.
      IF sy-subrc EQ 0.
        p_layout = w_variant-variant.
      ENDIF.
    ENDFORM.
    Try this and reward points by clicking the star on the left of reply,if it helps.

  • Displaying selection criteria in ALV report output

    Hello,
    I’ve been using REUSE_ALV_GRID_DISPLAY function module to display my report content in ALV.
    My report’s selection criteria has parameters, select options, checkboxes and radio buttons.  As part of the ALV output, I want to display the criteria that the user had selected in the selection screen.  I was hoping to do that via parameter "i_callback_top_of_page" and fill the selection criteria in the header area.  I'm using REUSE_ALV_COMMENTARY_WRITE to fill the header area. 
    However, the header area takes too much of view space in the output if I put all the selection screen information in it.
    Is there a way to make the header area scrollable?  What is a good way of displaying the selection criteria information as part of the report output?
    Appreciate your help.
    ss

    Hi SS,
    1. The purpose of displaying / writring
       selection information
       in alv is
       for identifying what the user has seleccted,
       directly from the report (when its printed)
    2. So, the option of priting/writing
       it on the TOP of alv, is ok.
    3. However, U can also choose to WRITE
      it at the BOTTOM (instead of top)
    4. Try to utilise maximum spacing (horizontally)
       field1 : abcd      fidl2 = xyz  field3 = ppp
       field4 : mnc       etc.         etc.
    regards,
    amit m.

  • Display/Print the Selection criteria entered by USER on the ALV Report o/p?

    Hi Experts,
    I hv a requirement of to print/display the Selection criteria entered by user in the selection screen.........on the top portion of the ALV report output lay out.
    There is a FM for this purpose, but, I forgot its name!!
    So, let me know the FM or FMs, so that, will choose, which is best one,
    or the piece of code, which covers all select-option entries..........appreciated.
    thanq
    Edited by: SAP ABAPer on Sep 3, 2008 6:35 PM

    Use the Function RS_REFRESH_FROM_SELECTOPTIONS get the selection details, now format the data accordingly in the TOP_OF_PAGE using the calss CL_DD_DOCUMENT.
    Check the below mention code.
    REPORT  ztest_page.
    TABLES: sflight.
    DATA : it_flight TYPE TABLE OF sflight WITH HEADER LINE.
    DATA BEGIN OF it_sel_opt OCCURS 0.
            INCLUDE STRUCTURE rsparams.
    DATA END   OF it_sel_opt.
    SELECT-OPTIONS: s_carrid FOR sflight-carrid.
    START-OF-SELECTION.
      SELECT * FROM sflight INTO TABLE it_flight
       WHERE carrid IN s_carrid.
    END-OF-SELECTION.
      CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
        EXPORTING
          curr_report     = sy-repid
        TABLES
          selection_table = it_sel_opt
        EXCEPTIONS
          not_found       = 01
          no_report       = 02.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = sy-repid
          i_callback_html_top_of_page = 'TOP_OF_PAGE'
          i_structure_name            = 'SFLIGHT'
        TABLES
          t_outtab                    = it_flight
        EXCEPTIONS
          program_error               = 1
          OTHERS                      = 2.
    *&      Form  top_of_page
    *       text
    *      -->DOCUMENT   text
    FORM top_of_page USING document TYPE REF TO cl_dd_document.
      DATA : dl_text(255) TYPE c.  "Text
    * Add new-line
      CALL METHOD document->new_line.
      CALL METHOD document->new_line.
      CLEAR : dl_text.
    * program ID
      dl_text = 'Program Name :'.
      CALL METHOD document->add_gap.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_heading_int.
      CLEAR dl_text.
      dl_text = sy-repid.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
      CALL METHOD document->new_line.
      CLEAR : dl_text.
      dl_text = 'Selection Criteria'.
      CALL METHOD document->add_gap
        EXPORTING
          width = 34.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
      CALL METHOD document->new_line.
      CLEAR : dl_text.
      CONCATENATE 'SELECT Option' 'SIGN' 'OPTION' 'LOW' 'HIGH'
      INTO dl_text SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
      CALL METHOD document->add_gap
        EXPORTING
          width = 34.
      CALL METHOD document->add_text
        EXPORTING
          text         = dl_text
          sap_emphasis = cl_dd_area=>heading
          sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
      CALL METHOD document->new_line.
      LOOP AT it_sel_opt.
        CLEAR : dl_text.
        CONCATENATE it_sel_opt-selname  it_sel_opt-sign
         it_sel_opt-option it_sel_opt-low it_sel_opt-high
        INTO dl_text SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
        CALL METHOD document->add_gap
          EXPORTING
            width = 34.
        CALL METHOD document->add_text
          EXPORTING
            text         = dl_text
            sap_emphasis = cl_dd_area=>heading
            sap_color    = cl_dd_area=>list_negative_inv.
    * Add new-line
        CALL METHOD document->new_line.
      ENDLOOP.
    ENDFORM.                    "top_of_page

  • How to add Change Layout, savelayout, select layout Button to ALV Toolba

    How to add Change Layout, savelayout, select layout Button to ALV Toolbar?
    Moderator message: please (re)search yourself before asking.
    [Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
    locked by: Thomas Zloch on Sep 10, 2010 10:57 AM

    Variant
    CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant          = gs_variant
                i_save              = c_save
              it_default_fieldcat =
           IMPORTING
                e_exit              = gf_exit
                es_variant          = gs_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.
        IF gf_exit = space.
          cf_varia = gs_variant-variant.
        ENDIF.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save        = c_save
        CHANGING
          cs_variant    = gs_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc NE 0.
        cf_subrc = sy-subrc.
      ENDIF.
    Change Layout, savelayout, select layout Button  pass the value which is in BOLD
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                =  gd_repid
         i_callback_user_command           =  'U_COMMAND'
         i_callback_top_of_page            = 'TOP-OF-PAGE'
                         is_layout                    =  fld_lay
           it_fieldcat                  =  fieldcatalog[]
                       IT_EXCLUDING                  =
                       IT_SPECIAL_GROUPS             =
                       IT_SORT                        =  it_sort[]
         i_default                      = 'X'
         i_save                         = 'A'
         is_variant                     = gs_variant
         it_events                      =  it_event[]
        TABLES
          t_outtab                      =    it_sales
                     EXCEPTIONS
                       PROGRAM_ERROR                     = 1
                       OTHERS                            = 2
    Annasaheb

  • Allowing a User to choose the ALV layout format on selection-screen

    Hi all,
    I would like to know how i can add a parameter to my selection-screen which would allow the User to choose a saved ALV layout format before pressing F8 rather than after. As used in CO15 or MB51.
    Thanks  femi.

    yes , You can check the program BCALV_TEST_FULLSCREEN_LAYOUT  to check how F4 help is to be used .
    to check existene of variant is pretty simple.
    Pass the variant name in the ALV display FM .

  • ALV + layout varient on selection screen

    hiii
    with ALV list i want to know with how to allow to put the layout on the selection screen and when user press F4 he will be able to use the list of layout he has save on the ALV output
    Note for the layout button to appear i had to activate shown below:
    i_save                   = c_x
    please give me sample code where user can choose layout on selection screen and this layout will be used to display on ALV

    Hi,
    Please refer the code below for layout variants :
    DATA:   gt_rsparams  TYPE TABLE OF rsparams.
    * Data for ALV variant
    DATA  gv_repname          LIKE sy-repid.
    DATA  gv_x_variant        LIKE disvariant.
    DATA  gv_exit(1)          TYPE c.
    DATA  gv_save(1)          TYPE c.
    DATA  gv_variant          LIKE disvariant.
    PARAMETERS: sp_vari LIKE disvariant-variant.        "Dispaly Variant
    INITIALIZATION.
      gv_repname = sy-repid.
      REFRESH : gt_glacct,
                gr_rcomp,
                gt_output,
                gt_fieldcat,
                gt_sort.
    * Initialize ALV Layout variant
      PERFORM f_initialize_variant.
    FORM f_initialize_variant .
      CLEAR gv_variant.
      gv_save           = 'X'.
      gv_variant-report = gv_repname.
      gv_x_variant      = gv_variant.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = gv_save
        CHANGING
          cs_variant = gv_x_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        sp_vari = gv_x_variant-variant.
      ENDIF.
    ENDFORM.                    " f_initialize_variant
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sp_vari.
      PERFORM f_f4_for_variant.
    FORM f_f4_for_variant .
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant = gv_variant
          i_save     = gv_save
        IMPORTING
          e_exit     = gv_exit
          es_variant = gv_x_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.
        IF gv_exit = space.
          sp_vari = gv_x_variant-variant.
        ENDIF.
      ENDIF.
    ENDFORM.                    " f_f4_for_variant
    AT SELECTION-SCREEN.
    *  Validating selection screen fields
      PERFORM f_at_selection_screen.
    FORM f_at_selection_screen .
    * ALV Layout variant
      IF NOT sp_vari IS INITIAL.
        MOVE gv_variant TO gv_x_variant.
        MOVE sp_vari    TO gv_x_variant-variant.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
          EXPORTING
            i_save     = gv_save
          CHANGING
            cs_variant = gv_x_variant.
        gv_variant = gv_x_variant.
      ELSE.
        PERFORM f_initialize_variant.
      ENDIF.
    FORM f_initialize_variant .
      CLEAR gv_variant.
      gv_save           = 'X'.
      gv_variant-report = gv_repname.
      gv_x_variant      = gv_variant.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save     = gv_save
        CHANGING
          cs_variant = gv_x_variant
        EXCEPTIONS
          not_found  = 2.
      IF sy-subrc = 0.
        sp_vari = gv_x_variant-variant.
      ENDIF.
    ENDFORM.                    " f_initialize_variant
    Thanks,
    Sriram POnna.

  • Change Layout in Selection Screen for OO ALV-Grid

    Hello everyone,
    I got a problem regarding layouts for objectoriented ALV Grid. I want to make it possible that user can take the layout for ALV he wants to on the selection screen. So far thats no problem and it works. But there are some little problems which I do not know how to fix them. But first the facts:
    (1) I got my parameter for layout
    PARAMETER: p_vari  TYPE disvariant-variant.
    (2) I fill my global layout structure in initialization
    INITIALIZATION.
    * Variante vorbelegen
       gs_variant-username = sy-uname.
       gs_variant-report   = sy-repid.
    * Layout holen
       CALL FUNCTION 'LVC_VARIANT_DEFAULT_GET'
         EXPORTING
           i_save        = 'A'
         CHANGING
           cs_variant    = gs_variant
         EXCEPTIONS
           wrong_input   = 1
           not_found     = 2
           program_error = 3
           OTHERS        = 4.
       IF sy-subrc = 0.
         p_vari = gs_variant-variant.
       ENDIF.
    (3) I got my handling for F4-value help on variant parameter
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
       CALL FUNCTION 'LVC_VARIANT_F4'
         EXPORTING
           is_variant    = gs_variant
           i_save        = 'A'
         IMPORTING
           es_variant    = gs_variant
         EXCEPTIONS
           not_found     = 1
           program_error = 2
           OTHERS        = 3.
       IF sy-subrc <> 0.
         MESSAGE text-m01 TYPE 'S'.
       ELSE.
         p_vari = gs_variant-variant.
       ENDIF.
    (4) I give back my parameters content into the variant structure at start of selection
    START-OF-SELECTION.
       gs_variant-username = sy-uname.
       gs_variant-report   = sy-repid.
       gs_variant-variant  = p_vari.
    This works all fine but I got some problems when using default variants/layouts. For example I got a default variant only for me. When starting the selection screen it works fine that the default layout was written. It is displayed automatically in the variant parameter. But I want that if i I empty the content (blank it out) from my variant parameter, that report should start with "normal" layout how it was written in the report and NOT with default layout.
    When I clear the gs_variant it works like I want it, but then the alv layout button looks like (without functions for layout), because I do not have the reference to my report.
    So what to do? :-)
    Regards
    Michael

    Wow that was fast, works great, thanks :-)
    I did not use this parameter in set table method but now I fill it dynamically.
    Ok next problem, one step harder ;-)
    Now I have one selection screen for one ALV-Grid, but four radio buttons which control with which data the ALV gets filled (four different fieldcats, data tables and so on). Each Grid got an own HANDLE so that the layouts can be separated in four categories.
    Now I want that by changing the radio button the individual standard layout for the chosen alv grid is getting filled.
    This works fine when using it in selection screen output.
    AT SELECTION-SCREEN OUTPUT.
       CLEAR gs_variant.
    * Layout-Handles individuell für Klausel-Radiobuttons setzen
       IF     p_py IS NOT INITIAL.
         gs_variant-username = sy-uname.
         gs_variant-report   = sy-repid.
         gs_variant-handle   = 'KLPY'.
       ELSEIF p_rh IS NOT INITIAL.
         gs_variant-username = sy-uname.
         gs_variant-report   = sy-repid.
         gs_variant-handle   = 'KLRH'.
       ELSEIF p_aj IS NOT INITIAL.
         gs_variant-username = sy-uname.
         gs_variant-report   = sy-repid.
         gs_variant-handle   = 'KLAJ'.
       ELSEIF p_sr IS NOT INITIAL.
         gs_variant-username = sy-uname.
         gs_variant-report   = sy-repid.
         gs_variant-handle   = 'KLSR'.
       ENDIF.
    * Layout holen
       CALL FUNCTION 'LVC_VARIANT_DEFAULT_GET'
         EXPORTING
           i_save        = 'A'
         CHANGING
           cs_variant    = gs_variant
         EXCEPTIONS
           wrong_input   = 1
           not_found     = 2
           program_error = 3
           OTHERS        = 4.
       IF sy-subrc = 0.
         p_vari = gs_variant-variant.
       ELSE.
         CLEAR p_vari.
       ENDIF.
    But unfortunately selection screen output is getting passed by EACH changing in the selection screen. This means when I try to clear the default layout in my parameter field, it gets refilled automatically with default layout. If I do a condition around the filling (only if not initial) the default value filling does not work fine in every case, e.g. when clearing the parameters field and then change the radiobutton -> then it does not get filled automatically.

  • How to put Layouts in selection screen for ALV

    Dear All,
    I have developed an ALV report . The users will create many layouts and save it. The requirement is that:
    In the selection screen , they need to get the list of saved layouts and select one from that so that they need not have to select layout after running the report.
    That means .. they want to select the layout before running the report.
    Hope that you understood my problem and will help me out...
    Thanking you,
    Shankar

    Hi,
    PARAMETERS P_LAYOUT LIKE DISVARIANT-VARIANT.
    INITIALIZATION.
    *Get Default display variant
    PERFORM F100_DISPLAY_DEFAULT_VARIANTS.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LAYOUT.
    *Value Help for Layouts
    PERFORM F1001_VALUE_REQUEST.
    *&      Form  F100_DISPLAY_DEFAULT_VARIANTS
         Initializing ALV Values                                        *
    FORM f100_display_default_variants.
      w_variant-report   = sy-repid.
      w_variant-handle   = c_handle.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                i_save        = c_a
           CHANGING
                cs_variant    = w_variant
           EXCEPTIONS
                wrong_input   = 1
                not_found     = 2
                program_error = 3
                OTHERS        = 4.
      IF sy-subrc EQ 0.
        p_layout = w_variant-variant.
      ENDIF.
    ENDFORM.
    *&      Form  F1001_VALUE_REQUEST
          Get the values for the layout.
    form F1001_VALUE_REQUEST.
      DATA:  lv_exit        TYPE c,
             lw_variant    LIKE w_variant.
      w_variant-report   = sy-repid.
      w_variant-username = sy-uname.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant    = w_variant
                i_save        = c_a
           IMPORTING
                e_exit        = lv_exit
                es_variant    = lw_variant
           EXCEPTIONS
                not_found     = 1
                program_error = 2
                OTHERS        = 3.
      IF sy-subrc IS INITIAL.
        IF lv_exit IS INITIAL.
          p_layout = lw_variant-variant.
        ENDIF.
      ELSE.
        MESSAGE i029."No layouts found
      ENDIF.
    endform.                    " F1001_VALUE_REQUEST
    Hope this helps.
    Regards,
    J.Jayanthi

  • How to get ALV Output with selected Layout

    I have a program which displays the output in ALV list format and i changed the layout and saved
    In the selection-screen i have a field to select the layout after selecting the layout it output is not coming with that layout
    can anyone tell me what is the problem
    or give me a sample code
    Thank you

    Hi,
    Check this code.
    Hope it helps.
    *& Report  zSALES_ORDER
    report  z_sales_order.
    type-pools: slis.
    *DATA DECLARATION.
    types: begin of i_vbak,
           vbeln type vbeln_va,
           augru type augru,
           erdat type erdat,
           end of i_vbak.
    types: begin of i_vbap,
           vbeln type vbeln_va,
           augru type augru,
           posnr type posnr_va,
           matnr type matnr,
           zmeng type dzmeng,
           end of i_vbap.
    types: begin of i_makt,
           matnr type matnr,
           maktx type maktx,
           end of i_makt.
    types: begin of i_lips,
           posnr type posnr_vl,
           matnr type matnr,
           lfimg type lfimg,
           end of i_lips.
    types: begin of i_reason,
           spras type spras,
           augru type augru,
           bezei type bezei40,
           end of i_reason.
    types: begin of i_vbpa,
           vbeln type vbeln,
           parvw type parvw,
           kunnr type kunnr,
           end of i_vbpa.
    types: begin of i_kna1,
           kunnr type kunnr,
           name1 type name1_gp,
           end of i_kna1.
    types: begin of i_final,
           vbeln type vbeln_va,
           posnr type posnr_va,
           matnr type matnr,
           zmeng type dzmeng,
           maktx type maktx,
           lfimg type lfimg,
           spras type spras,
           augru type augru,
           bezei type bezei40,
           parvw type parvw,
           kunnr type kunnr,
           name1 type name1_gp,
           end of i_final.
    *INTERNAL TABLES
    data: it_vbak type standard table of i_vbak.
    data: it_vbap type standard table of i_vbap.
    data: it_makt type standard table of i_makt.
    data: it_lips type standard table of i_lips.
    data: it_vbpa type standard table of i_vbpa.
    data: it_kna1 type standard table of i_kna1.
    data: it_final type standard table of i_final.
    data: it_reason type standard table of i_reason.
    data : v_flag.
    *WORK AREA
    data: wa_vbak type i_vbak.
    data: wa_vbap type i_vbap.
    data: wa_makt type i_makt.
    data: wa_lips type i_lips.
    data: wa_vbpa type i_vbpa.
    data: wa_kna1 type i_kna1.
    data: wa_final type i_final.
    data: wa_reason type i_reason.
    *DATA DECLARATION.
    data: v_progname type sy-repid.
    data: v_vbeln type vbak-vbeln.
    data: v_gridtitle type lvc_title.
    *PARAMETERS: D_VARI LIKE DISVARIANT-VARIANT.
    data: i_variant like disvariant.
    data: p_vari like disvariant-variant.
    *DATA DECLARATION FOR CATALOGS LAYOUT SORT EVENTCATALOG TOPOFPAGE.
    data: i_fieldcat type slis_t_fieldcat_alv.
    data: i_layout type slis_layout_alv.
    data: i_sortinfo type slis_t_sortinfo_alv.
    data: i_listheader type slis_t_listheader.
    data: i_eventcat type slis_t_event.
    *INITIALIZATION - First point of execution of program
                    To initialize Any variables that are to be
                    used in the program, even before selection screen
                    appears.
    initialization.
      v_progname = sy-repid.
      v_flag = space.
      perform z_default_variant.
    *SELECTION SCREEN
      selection-screen begin of block blk1 with frame title text-002.
      select-options: s_vbeln for v_vbeln.
      selection-screen end of block blk1.
    *Variable for ALV Variant
      selection-screen begin of block b_var with frame title text-020.
      parameters: d_vari like disvariant-variant.
      selection-screen end of block b_var.
    *AT SLECTION-SCREEN.
    at selection-screen.
      perform z_validations.
    *AT SELECTION SCREEN.
    at selection-screen on d_vari.
    CHECK FOR THE EXISTENCE OF THE VARIANT SELECTED
      perform zf_check_var_exist.
    at selection-screen on value-request for d_vari.
    PROVIDE THE F4-HELP.
      perform zf_variant_f4.
    *START OF SELECTION.
    start-of-selection.
      perform z_select.
      perform check_validation_flag.
      perform z_fieldcat using i_fieldcat.
      perform z_layout.
      perform z_sortinfo using i_sortinfo.
      perform z_eventcat using i_eventcat.
      perform z_gridtitle.
      perform z_listheader using i_listheader.
      perform z_display.
    *&      Form  Z_VALIDATIONS
          text
    -->  p1        text
    <--  p2        text
    form z_validations .
      select vbeln into v_vbeln
                   up to 1 rows
                   from vbak
                   where vbeln in s_vbeln.
      endselect.
      if sy-subrc <> 0.
        message i002(sy) with 'No Records'.
        v_flag = 'X'.
      endif.
    endform.                    " Z_VALIDATIONS
    *&      Form  Z_FIELDCAT
          text
         -->P_I_FIELDCAT  text
    form z_fieldcat  using  p_i_fieldcat type slis_t_fieldcat_alv.
      data: i_fieldcat type slis_fieldcat_alv.
    *VBAK-VELN
      i_fieldcat-col_pos     = '1'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'VBELN'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-key         = 'X'.                        " SO THAT THIS FIELD IS NOT SCROLLABLE AND HIDDABLE.
      i_fieldcat-just        = 'C'.                        " FOR JUSTIFICATION.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'SALES ORDER'.              " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   =  15.                         " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'VBAK'.                     " FOR F1 & F4 HELP AS REFERNCED TO THE DDIC TABLE.
      append i_fieldcat to p_i_fieldcat.
    *VBAP-SPRAS
      i_fieldcat-col_pos     = '2'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'SPRAS'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'LANGUAGE'.                     " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 5.                          " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'TVAUT'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *VBAP-AUGRU
      i_fieldcat-col_pos     = '3'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'AUGRU'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'REASON'.                     " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 5.                          " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'VBAK'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *VBAP-bezei
      i_fieldcat-col_pos     = '4'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'BEZEI'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'DESCRIPTION'.                     " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 20.                          " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'TVAUT'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *VBAP-POSNR
      i_fieldcat-col_pos     = '5'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'POSNR'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'ITEM'.                     " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 8.                          " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'VBAP'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *VBAP-MATNR.
      i_fieldcat-col_pos     = '6'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'MATNR'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'MATERIAL'.                 " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 10.                         " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'VBAP'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *VBAP-ZMENG
      i_fieldcat-col_pos     = '7'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'ZMENG'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'QUANT'.                     " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 10.                          " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'VBAP'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *MAKT-MAKTX
      i_fieldcat-col_pos     = '8'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'MAKTX'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'DESCRIPTION'.                     " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 20.                          " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'MAKT'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *LIPS-VBELN
      i_fieldcat-col_pos     = '9'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'VBELN'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'DELIVERY'.                 " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   = 15.                         " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'LIPS'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *LIPS-LFIMG
      i_fieldcat-col_pos     = '10'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'LFIMG'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-do_sum      = 'X'.
      i_fieldcat-seltext_l   = 'LFIMG'.                    " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   =  18.                        " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'LIPS'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *parvw
      i_fieldcat-col_pos     = '11'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'PARVW'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'PARTNER FUN'.                    " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   =  18.                        " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'VBPA'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *KUNNR
      i_fieldcat-col_pos     = '12'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'KUNNR'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'SHIP'.                    " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   =  18.                        " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'VBPA'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    *NAME1
      i_fieldcat-col_pos     = '13'.                        " POSITION OF THE COLUMN.
      i_fieldcat-fieldname   = 'NAME1'.                    " FIELD FOR WHICH CATALOG ID FILLED.
      i_fieldcat-tabname     = 'IT_FINAL'.                 " INTERNAL TABLE TO WHICH THE FIELD BELONGS TO.
      i_fieldcat-lzero       = 'X'.                        " OUTPUT WITH LEADING ZEROS.
      i_fieldcat-seltext_l   = 'NAME'.                    " LONG TEXT FOR HEADER.
      i_fieldcat-outputlen   =  18.                        " SET THE OUTPUT LENGTH.
      i_fieldcat-ref_tabname = 'KNA1'.                     " FOR F1 & F4 HELP AS REFERNCED TO TABLE.
      append i_fieldcat to p_i_fieldcat.
    endform.                    " Z_FIELDCAT
    *&      Form  Z_SELECT
          text
    -->  p1        text
    <--  p2        text
    form z_select .
      select vbeln
             augru erdat into corresponding fields of table it_vbak
                   from vbak
                   where vbeln in s_vbeln.
      loop at it_vbak into wa_vbak.
        wa_vbak-erdat = '99991231'.
        modify it_vbak from wa_vbak transporting erdat.
      endloop.
    select * from vbak into corresponding fields of table it_vbak
                   for all entries in it_vbak
                   where erdat = it_vbak-erdat.
      if sy-subrc = 0.
        select vbeln
               posnr
               matnr
               zmeng into corresponding fields of table it_vbap
                     from vbap
                     for all entries in it_vbak
                     where vbeln = it_vbak-vbeln.
        if sy-subrc = 0.
          select spras
                 augru
                 bezei into corresponding fields of table it_reason
                       from tvaut
                       for all entries in it_vbak
                       where augru = it_vbak-augru.
          if sy-subrc = 0.
            select vbeln
                   parvw
                   kunnr into corresponding fields of table it_vbpa
                         from vbpa
                         for all entries in it_vbak
                         where vbeln = it_vbak-vbeln.
            if sy-subrc = 0.
              select kunnr
                     name1 into corresponding fields of table it_kna1
                           from kna1
                           for all entries in it_vbpa
                           where kunnr = it_vbpa-kunnr.
              if sy-subrc = 0.
                select posnr
                       matnr
                       lfimg into corresponding fields of table it_lips
                             from lips
                             for all entries in it_vbap
                             where posnr = it_vbap-posnr.
                if sy-subrc = 0.
                  select matnr
                         maktx into corresponding fields of table it_makt
                               from makt
                               for all entries in it_vbap
                               where matnr = it_vbap-matnr.
                endif.
              endif.
            endif.
          endif.
        endif.
      else.
        message i002(sy) with 'No Data found'.
        leave list-processing.
      endif.
      if sy-subrc = 0.
        loop at it_vbap into wa_vbap.
          read table it_vbak into wa_vbak with key vbeln = wa_vbap-vbeln binary search.
          if sy-subrc = 0.
    *MOVE DATA INTO IT_FINAL.
            move: wa_vbak-vbeln to wa_final-vbeln,
                  wa_vbak-augru to wa_final-augru,
                  wa_vbap-posnr to wa_final-posnr,
                  wa_vbap-matnr to wa_final-matnr,
                  wa_vbap-zmeng to wa_final-zmeng.
          endif.
          read table it_lips into wa_lips with key posnr = wa_final-posnr binary search.
          if sy-subrc = 0.
            move: wa_lips-lfimg to wa_final-lfimg.
          endif.
          read table it_reason into wa_reason with key augru = wa_final-augru binary search.
          if sy-subrc = 0.
            move: wa_reason-spras to wa_final-spras,
                  wa_reason-bezei to wa_final-bezei.
          endif.
          read table it_makt into wa_makt with key matnr = wa_final-matnr binary search.
          if sy-subrc = 0.
            move: wa_makt-maktx to wa_final-maktx.
          endif.
         read table it_vbpa into wa_vbpa with key vbeln = wa_final-vbeln binary search.
          if sy-subrc = 0.
            move: wa_vbpa-parvw to wa_final-parvw,
                  wa_vbpa-kunnr to wa_final-kunnr.
          endif.
           read table it_kna1 into wa_kna1 with key kunnr = wa_final-kunnr binary search.
          if sy-subrc = 0.
            move: wa_kna1-name1 to wa_final-name1.
          endif.
          append wa_final to it_final.
          clear wa_final.
        endloop.
      endif.
    endform.                    " Z_SELECT
    *&      Form  Z_LAYOUT
          text
    -->  p1        text
    <--  p2        text
    form z_layout .
      i_layout-zebra = 'X'.
      i_layout-totals_text = 'Total'(a00).
      i_layout-subtotals_text = 'SubTotal'(a01).
      i_layout-box_tabname = 'IT_FINAL'.
    endform.                    " Z_LAYOUT
    *&      Form  Z_SORTINFO
          text
         -->P_I_SORTINFO  text
    form z_sortinfo  using    p_i_sortinfo type slis_t_sortinfo_alv.
      data: i_sortinfo type slis_sortinfo_alv.
      clear i_sortinfo.
      i_sortinfo-spos = '1'.
      i_sortinfo-fieldname = 'VBELN'.
      i_sortinfo-tabname = 'IT_FINAL'.
      i_sortinfo-up = 'X'.
      i_sortinfo-group = 'UL'.                     " I.E UNDERLINE AFTER EVERY GROUP
      i_sortinfo-subtot = 'X'.
      append i_sortinfo  to p_i_sortinfo.
    endform.                    " Z_SORTINFO
    *&      Form  Z_EVENTCAT
          text
         -->P_I_EVENTCAT  text
    form z_eventcat  using    p_i_eventcat type slis_t_event.
      data: i_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type     = 0
        importing
          et_events       = p_i_eventcat
        exceptions
          list_type_wrong = 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.
      clear i_event.
      read table p_i_eventcat with key name = slis_ev_top_of_page into
      i_event.
      if sy-subrc = 0.
        move 'TOP_OF_PAGE' to i_event-form.
        append i_event to p_i_eventcat.
      endif.
      read table p_i_eventcat with key name = slis_ev_pf_status_set into i_event.
      if sy-subrc = 0.
        move 'SET_PF_STATUS' to i_event-form.
        append i_event to p_i_eventcat.
      endif.
      clear i_event.
      read table p_i_eventcat into i_event with key name = slis_ev_user_command .
      if sy-subrc = 0.
        move 'USER_COMMAND' to i_event-form.
        append i_event to p_i_eventcat.
      endif.
    endform.                    " Z_EVENTCAT
    *&      Form  Z_DISPLAY
          text
    -->  p1        text
    <--  p2        text
    form z_display .
      call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
         i_callback_program                = v_progname
         i_callback_pf_status_set          = 'SET_PF_STATUS'
         i_callback_user_command           = 'USER_COMMAND'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         i_grid_title                      = v_gridtitle
         i_save                            = 'A'
         is_layout                         = i_layout
         it_fieldcat                       = i_fieldcat[]
         it_sort                           = i_sortinfo
         it_events                         = i_eventcat
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        tables
          t_outtab                          = it_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.
    endform.                    " Z_DISPLAY
    *&      Form  Z_GRIDTITLE
          text
    -->  p1        text
    <--  p2        text
    form z_gridtitle .
      v_gridtitle = 'ALV FOR SALES ORDER DISPLAY'.
    endform.                    " Z_GRIDTITLE
    *TOP OF PAGE.
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = i_listheader.
    endform.                    "TOP_OF_PAGE
    *MENU SETTINGS.
    form set_pf_status using rt_extab type slis_t_extab.
      set pf-status 'ALV_MENU'.
    endform.                    "SET_PF_STATUS
    *USER-COMMAND
    form user_command using p_ucomm type sy-ucomm
                            rs_selfield type slis_selfield.
      data : vbeln type vbeln_va.
      case p_ucomm.
        when 'BACK'.
          leave program.
        when '&IC1'.
          clear : vbeln.
          vbeln = rs_selfield-value.
          set parameter id: 'AUN' field vbeln.
          call transaction 'VA03' and skip first screen.
      endcase.
    endform.                    " USER_COMMAND
    *&      Form  Z_LISTHEADER
          text
         -->P_I_LISTHEADER  text
    form z_listheader using p_i_listheader type slis_t_listheader.
      data: l_listheader type slis_listheader.
      refresh p_i_listheader.
      clear l_listheader.
      l_listheader-typ = 'H'.
      l_listheader-info = text-001.
      append l_listheader to p_i_listheader.
      clear l_listheader.
      l_listheader-typ = 'H'.
      l_listheader-info = text-002.
      append l_listheader to p_i_listheader.
    endform.                    " Z_LISTHEADER
    *&      Form  check_validation_flag
          text
    -->  p1        text
    <--  p2        text
    form check_validation_flag .
      if not v_flag is initial.
        leave list-processing.
      endif.
    endform.                    " check_validation_flag
    *&      Form  Z_DEFAULT_VARIANT
          text
    -->  p1        text
    <--  p2        text
    form z_default_variant .
      i_variant-report = v_progname.
      call function 'REUSE_ALV_VARIANT_DEFAULT_GET'
        exporting
          i_save        = 'A'
        changing
          cs_variant    = i_variant
        exceptions
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          others        = 4.
      if sy-subrc = 0.
        p_vari = i_variant-variant.
       D_VARI = P_VARI.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " Z_DEFAULT_VARIANT
    *&      Form  ZF_CHECK_VAR_EXIST
          text
    -->  p1        text
    <--  p2        text
    form zf_check_var_exist .
      data: l_variant like disvariant.
      if not p_vari is initial.
        clear l_variant.
        l_variant-report = v_progname.
        l_variant-variant = p_vari.
        call function 'REUSE_ALV_VARIANT_EXISTENCE'
          exporting
            i_save        = 'U'
          changing
            cs_variant    = l_variant
          exceptions
            wrong_input   = 1
            not_found     = 2
            program_error = 3
            others        = 4.
        if sy-subrc = 0.
          clear i_variant.
          move: l_variant-variant to i_variant-variant,
                l_variant-report to i_variant-report.
        else.
          message id sy-msgid type sy-msgty number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        endif.
      endif.
    endform.                    " ZF_CHECK_VAR_EXIST
    *&      Form  ZF_VARIANT_F4
          text
    -->  p1        text
    <--  p2        text
    form zf_variant_f4 .
      data: x_variant like disvariant.
      call function 'REUSE_ALV_VARIANT_F4'
        exporting
          is_variant                = i_variant
      I_TABNAME_HEADER          =
      I_TABNAME_ITEM            =
      IT_DEFAULT_FIELDCAT       =
         i_save                    = 'U'
         i_display_via_grid        = 'X'
       importing
      E_EXIT                    =
         es_variant                = x_variant
       exceptions
         not_found                 = 1
         program_error             = 2
         others                    = 3
      if sy-subrc = 0.
        p_vari = x_variant-variant.
        d_vari = p_vari.
        clear i_variant.
        move: x_variant-variant to i_variant-variant,
              x_variant-report to i_variant-report.
      else.
        message id sy-msgid type sy-msgty number sy-msgno
                with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      endif.
    endform.                    " ZF_VARIANT_F4
    Regards,
    Pritha.

  • Print Layout Designer (PLD) - Displaying Selection Criteria

    Does anyone know how to display the selection criteria on a pld form.  Specifically, I would like to display the selected 'Item Property' on the Inventory > Inventory Reports > Items List report.
    I noticed on the Inventory > Inventory Reports > Inactive Items report that it displays the Date From selection criteria and the document types selected, but I can't figure out how it is doing this. They are Text fields and I don't see any dependencies.
    Thank You

    Vaughn,
    The selection criteria are pre-build to be included on some of the reports and are not on others.  If they are not available on the PLD template you could not add them.
    Suda

  • How to have a Layout as Selection in a Report?

    Hi All,
    I am using "REUSE_ALV_GRID_DISPLAY" to display a ALV Grid. I need to know how could I have Layout Selection Criteria where the user could select the desired Layout and then execute the program. The selected Layout could be stored in "g_layout" and assign to the "IS_LAYOUT" found in the import list of "REUSE_ALV_GRID_DISPLAY".
    Thanks,
    Kishan

    Hi,
    1. have a pramter in the selection screen for variant.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
    2.
      G_SAVE = 'A'.
        CLEAR G_VARIANT.
      G_VARIANT-REPORT = G_REPID.
    * Get default variant
      GX_VARIANT = G_VARIANT.
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
           EXPORTING
                I_SAVE     = G_SAVE
           CHANGING
                CS_VARIANT = GX_VARIANT
           EXCEPTIONS
                NOT_FOUND  = 2.
      IF SY-SUBRC = 0.
        P_VARI = GX_VARIANT-VARIANT.
      ENDIF.
    * Process on value request
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                IS_VARIANT          = G_VARIANT
                I_SAVE              = G_SAVE
    *           it_default_fieldcat =
           IMPORTING
                E_EXIT              = G_EXIT
                ES_VARIANT          = GX_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.
        IF G_EXIT = SPACE.
          P_VARI = GX_VARIANT-VARIANT.
        ENDIF.
      ENDIF.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_BACKGROUND_ID         = 'ALV_BACKGROUND'
                I_CALLBACK_PROGRAM      = G_REPID
                I_STRUCTURE_NAME        = 'SFLIGHT'
                IS_LAYOUT               = GS_LAYOUT
                IT_FIELDCAT             = GT_FIELDCAT[]
    *           IT_EXCLUDING            =
                IT_SPECIAL_GROUPS       = GT_SP_GROUP[]
                IT_SORT                 = GT_SORT[]
    *           IT_FILTER               =
    *           IS_SEL_HIDE             =
    *           i_default               = g_default
    <b>            I_SAVE                  = G_SAVE
                IS_VARIANT              = G_VARIANT</b>
    Regards
    vijay

  • ALV layout variant missing in background job.

    hi guys,
    Having problem on getting the default ALV layout variant when run the job in backgorund. Please advise any correction needed in the following code.
    Thanks.
    *&  Include           Z_MM_KBR_AGSUBCONINV_MOD2                        *
    MODULE status_0100 OUTPUT.
      SET PF-STATUS '100'.
      SET TITLEBAR '100'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  display_data  OUTPUT
          text
    MODULE display_data OUTPUT.
    IF sy-batch IS INITIAL. "Foreground
      IF w_container IS INITIAL.
        IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    *Creating the container
          CREATE OBJECT w_container
            EXPORTING
              container_name              = c_container
            EXCEPTIONS
              cntl_error                  = 1
              cntl_system_error           = 2
              create_error                = 3
              lifetime_error              = 4
              lifetime_dynpro_dynpro_link = 5
              OTHERS                      = 6.
          IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
        ENDIF.
    *Creating the ALV GRID
        CREATE OBJECT w_grid
          EXPORTING
            i_parent          = w_container
            i_appl_events     = c_check
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        else.
         exit.
        ENDIF.
      ELSE.
    *Creating the ALV GRID
        CREATE OBJECT w_grid
          EXPORTING
            i_parent          = go_dock_container
            i_appl_events     = c_check
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5.
        IF sy-subrc <> 0.
          WRITE:/ 'Error in grid'.
        ENDIF.
         CREATE OBJECT w_grid
          EXPORTING  i_parent = go_dock_container.
      ENDIF.
    *getting the variant option
        wa_variant-report     = sy-repid.
        wa_variant-username   = sy-uname.
        wa_layout-grid_title  = sy-title.
        wa_layout-cwidth_opt  = c_check.
        wa_layout-zebra       = c_check.
        wa_layout-no_f4       = c_check.
        wa_layout-sel_mode    = 'D'.
    *Excluding the unwanted buttons
         PERFORM exclude_toolbar_buttons.
    build field catalog.
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_buffer_active        = c_check
            i_structure_name       = c_fcat_str
            i_bypassing_buffer     = c_check
          CHANGING
            ct_fieldcat            = t_fieldcat
          EXCEPTIONS
            inconsistent_interface = 1
            program_error          = 2
            OTHERS                 = 3.
        IF sy-subrc <> 0.
         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                 WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        loop at t_fieldcat into w_fieldcat.
         if w_fieldcat-FIELDNAME = 'AGING1'.
          W_FIELDCAT-NO_ZERO = 'X'.
          MODIFY t_fieldcat FROM W_FIELDCAT INDEX SY-TABIX.
         ENDIF.
        endloop.
    Generate sort critria
        PERFORM generate_sort.
    Create object of class lcl_event_receiver.
        CREATE OBJECT w_event.
    Handler for events.
       SET HANDLER w_event->handle_top_of_page       FOR w_grid.
       SET HANDLER w_event->handle_print_top_of_page FOR w_grid.
       SET HANDLER w_event->handle_print_end_of_list FOR w_grid.
        SET HANDLER w_event->handle_hotspot_click     FOR w_grid.
    *Displaying the alv
       IF NOT sy-batch IS INITIAL.
         PERFORM create_snp.
       ENDIF.
    t_data = i_final.
        CALL METHOD w_grid->set_table_for_first_display
          EXPORTING
            i_save                        = 'A'
            is_layout                     = wa_layout
            is_variant                    = wa_variant
          CHANGING
            it_outtab                     = t_data
            it_fieldcatalog               = t_fieldcat
          EXCEPTIONS
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            OTHERS                        = 4.
        IF sy-subrc <> 0.
        ENDIF.
    ENDIF.
    ENDIF.
    ENDMODULE.                 " display_data  OUTPUT
    *&      Module  user_command_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      DATA: lt_rows TYPE lvc_t_row,
             w_rows TYPE lvc_s_row.
      CASE sy-ucomm.
        WHEN c_back.
          LEAVE TO SCREEN 0.
        WHEN c_exit.
          LEAVE TO SCREEN 0.
        WHEN c_cancel.
          LEAVE TO SCREEN 0.
       WHEN 'BILDET'.
         CALL METHOD w_grid->get_selected_rows
           IMPORTING
             et_index_rows = lt_rows.
         CALL METHOD cl_gui_cfw=>flush.
         IF sy-subrc EQ 0.
           READ TABLE lt_rows INTO w_rows INDEX 1.
           READ TABLE i_vbfa INTO w_vbfa INDEX w_rows-index.
           IF sy-subrc EQ 0.
             CLEAR i_zbw_br_nf4.
             LOOP AT i_zbw_br_nf3 INTO w_zbw_br_nf3 WHERE
                         refkey = w_vbfa-v_vbeln.
               APPEND w_zbw_br_nf3 TO i_zbw_br_nf4.
             ENDLOOP.
    call dialog screen and display new alv control
             CALL SCREEN 101 STARTING AT 10 5.
           ENDIF.
         ENDIF.
         WHEN 'NOTAF'.
         CALL METHOD w_grid->get_selected_rows
           IMPORTING
             et_index_rows = lt_rows.
         CALL METHOD cl_gui_cfw=>flush.
         IF sy-subrc EQ 0.
           READ TABLE lt_rows INTO w_rows INDEX 1.
           READ TABLE i_zbw_br_nf3 INTO w_zbw_br_nf3 INDEX w_rows-index.
           DATA docnum LIKE j_1bdydoc-docnum.
           docnum = w_zbw_br_nf3-docnum.
           SET PARAMETER ID 'JEF' FIELD docnum.
           CALL TRANSACTION 'J1B3N' AND SKIP FIRST SCREEN.
         ENDIF.
      ENDCASE.
      ENDMODULE.                 " user_command_0100  INPUT
    *&      Form  modify_col_name
          text
         -->P_<FCAT>  text
         -->P_TEXT_H01  text
    FORM modify_col_name  USING  pwa_fcat TYPE lvc_s_fcat
                                 value(pw_text) TYPE any.
      pwa_fcat-coltext   = pw_text.
      pwa_fcat-scrtext_l = pw_text.
      pwa_fcat-scrtext_m = pw_text.
      pwa_fcat-scrtext_s = pw_text.
    ENDFORM.                    " modify_col_name
          FORM display_hotspot                                          *
    FORM display_hotspot USING pw_row_id    TYPE lvc_s_row
                               pw_column_id TYPE lvc_s_col.
      FIELD-SYMBOLS <l_data> TYPE zbrforecast.
    READ TABLE t_br_nf_acum ASSIGNING <l_data> INDEX pw_row_id-index.
    CHECK sy-subrc = 0.
    IF pw_column_id = ' '.
    ENDIF.
    ENDFORM.                    "display_hotspot
    *&      Form  generate_sort
          Genereate Sort criteria
    FORM generate_sort.
    Local variables
    DATA: wal_sort TYPE lvc_s_sort,
           wl_pos   TYPE numc2.
    wl_pos = 01.
    sort ORDER
    wal_sort-spos      = wl_pos.
    wal_sort-fieldname = c_aufnr.
    wal_sort-up        = c_check.
    APPEND wal_sort TO t_sort.
    ENDFORM.                    "generate_sort
    *&      Form  f4_variant
          text
         <--PW_VARI  text
    FORM f4_variant CHANGING pw_vari TYPE disvariant-variant.
    wa_variant-report = sy-cprog.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant    = wa_variant
          i_save        = c_u
        IMPORTING
          es_variant    = wa_variant
        EXCEPTIONS
          not_found     = 1
          program_error = 2
          OTHERS        = 3.
      IF sy-subrc IS INITIAL.
        pw_vari = wa_variant-variant.
      ELSE.
        MESSAGE s208(00) WITH text-t04.
      ENDIF.
    ENDFORM.                    " f4_variant
    *&      Form  validate_layout
    *This subroutine is to validate the layout
    No parameters are passed to this subroutine
    FORM validate_layout.
    IF NOT p_layout IS INITIAL.
      Check Layout
       wa_variant-report   = sy-repid.
       wa_variant-username = sy-uname.
       wa_variant-variant  = p_layout.
       CALL FUNCTION 'LVC_VARIANT_EXISTENCE_CHECK'
         EXPORTING
           i_save     = c_u
         CHANGING
           cs_variant = wa_variant
         EXCEPTIONS
           OTHERS     = 01.
       IF NOT sy-subrc IS INITIAL.
         SET CURSOR FIELD 'P_LAYOUT'.
         MESSAGE s001(00) WITH text-t06 p_layout.
         STOP.
       ENDIF.
    ELSE.
      clear wa_variant.
    ENDIF.
    ENDFORM.                    " validate_layout
    *&      Form  validate_data
          text
    FORM validate_data .
    PERFORM validate_layout.
    ENDFORM.                    " validate_data

    Hi,
    Before the call to method set_table_for_first_display, populate
    wa_variant-report = sy-repid.
    Best regards,
    Prashant

  • How to suppress blank page and selection criteria in SPOOL ?

    My Z program submits two programs to spool and converts the ABAP List in the spool to PDF and emails.
    After upgrade to ECC6, the first (a report painter report) resulting PDF there was one blank page and the contents were displayed on second page. For the second report (RKPEP003 - CJI3)  the selection criteria that the report used was printed as the first page of output and the result on a subsequent page. The same thing happens when I individually execute these two reports directly in SE38 with the same selection criteria. I believe the blank page is there in the spool because when I view the spool as a RAW, there is a P in the first column, however the spool shows that there is only one page in the first and two in the second (this is true - one for selection criteria "which I don't want" and then the actual content). In 46C, when I look at the RAW view of the spool there is no additional P's in the first column.
    I do not want to have the blank page on the first report and the selection criteria listed on the output of the report. How can I do that ? I am thinking get_print_parameters can in someway get me there, but I am not sure.
    Thanks
    Hari
    Edited by: Hari Sudarsanan on Apr 8, 2009 7:28 PM
    Edited by: Hari Sudarsanan on Apr 8, 2009 8:05 PM

    The first report painter program writes a regular ABAP list.
    The second outputs an ALV.

Maybe you are looking for

  • Hyperion Planning Web URL is taking Too long time to respond

    Hi, When Users are accessing Hyperion Planning URL web link its taking too long time to respond.We restarted the services after these for 2 hours it works fine after that again same issue.Please advise.

  • FFmpeg crash when recording desktop

    I'm using x264-git and ffmpeg-svn from AUR.  I am attempting to record usage of xcalc as an example of using FFmpeg to capture a specific application on the desktop.   However, FFmpeg will always crash at certain resolutions, but it will encode if I

  • My dream- an iphone 3g car adapter and charger WHICH

    Lets me decide on whether or not to charge while playing music or not to charge... Why I want this? because if I charge my iphone for 30 min every day it wil kill the already weak battery. So I rather have a car adapter that could be used as a charge

  • Create folders for other users

    I have a process that automatically generates folders based on events in the database using Advanced Queues. This process will work if I am creating folders for the user I am currently connected as. What I can't seem to do is use the system admin acc

  • Subtotals text

    Hi gurus, I'm displaying a list using Hierarchial ALV's. I'm displaying subtotals for field AMOUNT. Now I have 2 issues. 1) while displaying subtotals exactly after the list, and exactly before the subtotal is displayed, one extra line is getting add