Display Variants in ALV

Hi,
I copied an existing Z report program to a new program to conform to the naming standards and deleted the old program. (I could do renaming as well but did it this way)
When copying the program, all object including the selection variants were copied but the ALV display variants were not copied to the target program.  Any thoughts on this please?
I tried using a simple program to copy the LTDX (Generic storage of display variants) and LTDXT (Display Variant Texts) entries of the old program to the new program. I checked that all entries in LTDX of the old program now exist for the new program too. When I execute the program, only the global ALV display variants are available for selection i.e all display variants that start with u2018/u2019. The user specific variants are not available although all entries in LTDX and LTDXT for the user display are in the respective tables
Thanks for respondinding.

Thanks Satyasuresh. I used a similar program that copies variant entries from tables ltdx and ltdxt for a source program to new entries in the same table for the target program.
parameters report like ltdx-report obligatory.
parameters report2 like ltdx-report obligatory.
select * into table lt_ltdx from ltdx
                where report = report.
  select * into table lt_ltdxt from ltdxt
                where report = report.
  loop at lt_ltdx.
    lt_ltdx-report = report2.
    modify ltdx from lt_ltdx..
  endloop.
  loop at lt_ltdxt.
    lt_ltdxt-report = report2.
    modify ltdxt from lt_ltdxt..
  endloop.

Similar Messages

  • How to transport display variants in alv

    Hi,
    Can any one please help me in transporting alv display variants?Actually I have transported the variants ,but only selection variants are getting transported.I want to transport ALV display variants accross the clients.
    Please reply soon.It is very urgent.

    Hi,
    Please use the following :
    First execute the report .
    Then Menubar Settings> Layout> layout management>select your variant> menubar layout--> transport
    This will work only when your variant management is activve in your ALV report.

  • Display variant in  ALV grid

    Hi ,
    i have developed an interactive report in which form the first grid display i will move to the second grid display.
    Problem:
                 For the first list there is an display variant. when i navigate to the second list it is using the same display variant form the first list ( this should not hapen ). so many of the fields are not be displayed in the second list.
                Is there any way to differentiate the display variant from first and second list.
    Please help me. sample code will be more helpful.
    Patil

    hi santhosh
        You can very well create 2 variants in your report for grid display...just restrict some fields n create 2 variants and while executing jus choose which variant you need to run..
    REWARD IT IF USEFUl...!!!!

  • OOPs :  SAVE and ALV Display Variant

    Can you please send me the code for 'Save and Display Variant' in ALV OOPs.

    DATA :  l_layout TYPE disvariant.
      l_layout-report = sy-repid.
    l_layouth-zebra = 'X'.   
    CALL METHOD gr_alvgrid->set_table_for_first_display
           EXPORTING
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
         i_structure_name              =  'ZQM01'    
    <b>     is_variant                    =  l_layout
         i_save                        = 'A'</b>
       I_DEFAULT                     = 'X'
        is_layout                     =  gs_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
          CHANGING
             it_outtab                     = gt_list[]
             it_fieldcatalog               = gt_fieldcat
       IT_SORT                       =
       IT_FILTER                     =
           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.

  • Problem in saving ALV display variant with filter

    Hello,
    I'm displaying an ALV grid with function 'REUSE_ALV_GRID_DISPLAY'. When I load a diplay variant and apply a filter, I could save new layout. But when I run the report without a display variant, then apply a filter to the result, I couldn't save filter option when saving display variant. In the "save" tab of save layout dialog, filter checkbox is not displayed. This happens in 4.6C version. Is it a bug or am i missing a point.
    Thanks,
    Mustafa.

    Slm Burak,
    'IT_FILTER' parameter is empty. Users apply a filter but couldn't save filtered list variant. When they run the report with saved display variant, list is displayed without filters.

  • ALV Display Variant copying between programs

    There is a report program say PROGRAM1 whose ALV display variants we want to copy to the ALV display variants of another program say PROGRAM2.
    Both these program share the same ALV output structure design. My questions are
    1) Can the display variants of an ALV be copied into another program.?
    2) Can this be managed programatically?

    Hi,
      Try using LVC_VARIANT_SELECT and LVC_VARIANT_SAVE fms.
      First call LVC_VARIANT_SELECT to read variant from the first program and then call LVC_VARIANT_SAVE to save it for the second program.
      Take a look at report BCALV_GRID_11 for reference
    Sri
    Message was edited by: Srikanth Pinnamaneni

  • Copying ALV Display Variants between different programs

    Is there a way to copy the ALV Display Variants from one program to another?  I am NOT referring to selection screen variants.
    An SAP standard program was copied to a Z program.  Some changes were made to the logic.  The original SAP program has many (100+) ALV Display Variants.  I do not want to manually re-create them.  Is there a way to copy these from one program to another (without using a custom program to manipulate the tables)?
    Thanks.
    Norm

    Hi norman,
    even i was thinking the same while you passing the alv parameter is_variant, give the the program which is having 100 variants.
    is_variant-REPORT = 'STANDARDPRG'.
    this will import all varaints from it, but when you save any new one it will  save in the same standard program.
    regards
    vijay

  • Select OO ALV Display Variants in a Sel Screen.

    Hi, Abapers.
    I'm wondering whether is possible to make a selection (in a sel-screen) over a field of the display variants which are further managed in an OO ALV.
    If it's possible, from where shoud I read them?
    Best regards.

    what do you means with "managed"?
    what do you think to do with the selected field?

  • ALV display Variant

    hi,
    I wrote a code for allowing the user to choose a display variant in the selection screen. The user chooses the required variant in the selection screen and views the ALV grid accordingly. This code is working fine in the development server but as it was transported to the quality server, somehow it has stopped working.
    Any new variants that are created are displayed in the selection screeN F4 help, but somehow the variants are not working.
    Could anyone suggest where i am going wrong?
    Thanks,
    Aviroop

    try to comment it and see./
    it will work..
    you are telling that alv Fm set the default variant.
    if you don't want then comment it, then what ever you choose in selection screen will come in the output otherwise defaut variant overrides the selected one.
    Regards
    vijay

  • Copy User Specific ALV Display Variants

    Does anyone know if it is possible to copy one user's ALV display variant (that has been saved as a user-specific variant) for a particular program (in this case VA05) to another user?

    Hi Eric,
    I'm a bit busy now and I cannot give you a complete solution, but sure can give you some c(l)ue. Just see if you have some success. If you do not, then i wuill get back to you later.
    Refer to the follwoing SAP Tables and see if you have some luck.
    ==========================================================
    LTDX  --> Generic storage of display variants
    LTDXD --> Default display variants
    LTDXS --> SAP Default Display Variants
    LTDXT --> Display variant texts
    ==========================================================
    The idea is to try and manipulate the table entries for various users.
    Regards,
    Anand Mandalika.

  • How to get the fields in a display variant

    Hello gurus,
    I have created variants for an ALV display that I can select on my selection. This works fine.
    Now I need to know during the execution of the program what are the fields that have been selected in the display variant so that I can export the selected fields in an excel sheet that I send by mail. The file is currently being sent with all the possible fields .
    Is there a module function that allows the program to know which field is present in the display variant?
    Thanks,
    Parvez

    Hi,
    Try these:     REUSE_ALV_VARIANT_DEFAULT_GET.
         REUSE_ALV_VARIANT_F4.
    .also see the link for more Details:
    http://www.abapcode.info/2008/09/selecting-variants-for-initial-alv-list.html.
    Hope it helps.
    Regards,
    Rahul

  • Function Module that will retrieve the Field Catalogs of a Display Variant

    Hello Experts,
    Are there any function modules that I can use to retrieve the field catalogs (fields to be displayed in ALV report) by passing the display variant name?
    An RFC needs to apply this to determine which field(data) to be passed to XI (calling system) depending on user login.
    Thanks in advance!

    These are the various FM available for Variants (field Layout)
    REUSE_ALV_VARIANT_ALL_MAINTAIN Maintain all display variants for one object
    REUSE_ALV_VARIANT_DEFAULT_GET  Read default display variant (description only, w/o field catalog)
    REUSE_ALV_VARIANT_EXISTENCE    Checks whether a display variant exists
    REUSE_ALV_VARIANT_F4           Display variant selection dialog box
    REUSE_ALV_VARIANT_MAINTAIN     Definition of a display variant outside the list context
    REUSE_ALV_VARIANT_SAVE         Save a display variant
    REUSE_ALV_VARIANT_SELECT       Read a display variant
    Regards,
    Amit

  • Variant in ALV Reports

    hello all
    can anybody tell how to use variant in ALV Reports

    Look at the following example.
    report z_rock_ALV_example.
        * D-A-T-A D-E-C-L-A-R-A-T-I-O-N-S *
    tables: sflight.
              o
                    +
                          # TYPE-POOLS Definition
    **Includes the types and constants of a type group. Since the types and
    *constants specified in a type group have global validity, you cannot
    *use the statement within a FORM or FUNCTION.
    type-pools: slis.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT.
              o
                    +
                          # ALV variables
                    +
                                      o Field Catalog structure
    data: ls_fieldcat type slis_fieldcat_alv, "Field Catalog list
              o
                    +
                                * Field Catalog table
    gt_fieldcat type slis_t_fieldcat_alv, "Field Catalog
              o
                    +
                                * Layout ( How you would like to see the output )
    gs_layout type slis_layout_alv, "List Layout
              o
                    +
                          # Report name
    g_repid like sy-repid,
    g_save(1) type c,
    g_exit(1) type c,
    g_variant like disvariant,
    gx_variant like disvariant.
              o
                    +
                          # Flight Info Internal table
    data: lt_sflight like sflight occurs 0 with header line.
        * C-O-N-S-T-A-N-T-S *
        * S-E-L-E-C-T-I-O-N S-C-R-E-E-N *
    selection-screen begin of block a with frame title text-100.
    select-options: s_carrid for sflight-carrid,
    s_connid for sflight-connid,
    s_fldate for sflight-fldate default sy-datum.
    selection-screen end of block a .
        * I-N-I-T-I-A-L-I-Z-A-T-I-O-N *
    initialization.
    g_repid = sy-repid.
              o
                    +
                          # Fill ALV field catalog
    perform initialize_fieldcat using gt_fieldcat[].
              o
                    +
                                * Build Events
        * perform build_eventtab using gt_events[].
              o
                    +
                          # Read the default variant
    perform initialize_variant.
        * A-T S-E-L-E-C-T-I-O-N S-C-R-E-E-N *
    at selection-screen on value-request for p_vari.
              o
                    +
                          # Display all existing variants
    call function 'REUSE_ALV_VARIANT_F4'
    exporting
    is_variant = g_variant
    i_save = g_save
    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.
        * S-T-A-R-T O-F S-E-L-E-C-T-I-O-N *
    start-of-selection.
              o
                    +
                          # Read Flight information.
    perform read_flight_info.
              o
                    +
                          # Fill ALV field catalog and display report.
    if not lt_sflight[] is initial.
    perform dislay_alv_report.
    endif.
    ======================================================================
        * FORMS / SUB ROUTINES *
    *======================================================================
    *& Form initialize_fieldcat
        * text
        * -->P_GT_FIELDCAT[] text
    form initialize_fieldcat using l_fieldcat type slis_t_fieldcat_alv.
    clear ls_fieldcat.
        * Air line
    ls_fieldcat-fieldname = 'CARRID'.
    ls_fieldcat-key = 'X'.
    ls_fieldcat-col_pos = 1.
    ls_fieldcat-seltext_s = 'Airline'.
    ls_fieldcat-seltext_l = 'Airline'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Flight Number
    ls_fieldcat-fieldname = 'CONNID'.
    ls_fieldcat-key = 'X'.
    ls_fieldcat-col_pos = 2.
    ls_fieldcat-seltext_s = 'Flight Number'.
    ls_fieldcat-seltext_l = 'Flight Number'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Flight date
    ls_fieldcat-fieldname = 'FLDATE'.
    ls_fieldcat-key = 'X'.
    ls_fieldcat-col_pos = 3.
    ls_fieldcat-seltext_s = 'Flight date'.
    ls_fieldcat-seltext_l = 'Flight date'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Airfare
    ls_fieldcat-fieldname = 'PRICE'.
    ls_fieldcat-col_pos = 4.
    ls_fieldcat-do_sum = 'X'.
    ls_fieldcat-seltext_s = 'Airfare'.
    ls_fieldcat-seltext_l = 'Airfare'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Local Currency
    ls_fieldcat-fieldname = 'CURRENCY'.
    ls_fieldcat-col_pos = 5.
    ls_fieldcat-seltext_s = 'Local Currency'.
    ls_fieldcat-seltext_l = 'Local Currency'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Plane Type
    ls_fieldcat-fieldname = 'PLANETYPE'.
    ls_fieldcat-col_pos = 6.
    ls_fieldcat-seltext_s = 'Plane type'.
    ls_fieldcat-seltext_l = 'Plane type'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Maximum capacity
    ls_fieldcat-fieldname = 'SEATSMAX'.
    ls_fieldcat-col_pos = 7.
    ls_fieldcat-seltext_s = 'Max. seats'.
    ls_fieldcat-seltext_l = 'Max. seats'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Occupied seats
    ls_fieldcat-fieldname = 'SEATSOCC'.
    ls_fieldcat-col_pos = 8.
    ls_fieldcat-seltext_s = 'Seats occupied'.
    ls_fieldcat-seltext_l = 'Seats occupied'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Total
    ls_fieldcat-fieldname = 'PAYMENTSUM'.
    ls_fieldcat-col_pos = 9.
    ls_fieldcat-do_sum = 'X'.
    ls_fieldcat-seltext_s = 'Total amount'.
    ls_fieldcat-seltext_l = 'Total amount'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Total
    ls_fieldcat-fieldname = 'PAYMENTSUM'.
    ls_fieldcat-col_pos = 9.
    ls_fieldcat-do_sum = 'X'.
    ls_fieldcat-seltext_s = 'Total amount'.
    ls_fieldcat-seltext_l = 'Total amount'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Max. Capacity, Buss. Class
    ls_fieldcat-fieldname = 'SEATSMAX_B'.
    ls_fieldcat-col_pos = 10.
    ls_fieldcat-seltext_s = 'Max.Buss.class cap.'.
    ls_fieldcat-seltext_l = 'Max.Buss.class cap.'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Max. occupancy, Buss. Class
    ls_fieldcat-fieldname = 'SEATSOCC_B'.
    ls_fieldcat-col_pos = 11.
    ls_fieldcat-seltext_s = 'Max.Bus.CL.occupied'.
    ls_fieldcat-seltext_l = 'Max.Bus.CL.occupied'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Max. Capacity, First. Class
    ls_fieldcat-fieldname = 'SEATSMAX_F'.
    ls_fieldcat-col_pos = 12.
    ls_fieldcat-seltext_s = 'Max.Buss.class cap.'.
    ls_fieldcat-seltext_l = 'Max.Buss.class cap.'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
        * Max. occupancy, First. Class
    ls_fieldcat-fieldname = 'SEATSOCC_F'.
    ls_fieldcat-col_pos = 13.
    ls_fieldcat-seltext_s = 'Max.Bus.CL.occupied'.
    ls_fieldcat-seltext_l = 'Max.Bus.CL.occupied'.
    append ls_fieldcat to l_fieldcat.
    clear ls_fieldcat.
    ENDFORM. " initialize_fieldcat
    *& Form read_flight_info
        * text
        * --> p1 text
        * <-- p2 text
    FORM read_flight_info .
    refresh lt_sflight.
    clear lt_sflight.
              o
                    +
                          # Read data from SFLIGHT table
    select *
    from SFLIGHT
    into table lt_sflight
    where carrid in s_carrid
    and connid in s_connid
    and fldate in s_fldate.
    if sy-subrc <> 0.
    message e208(00) with text-101.
    endif.
    ENDFORM. " read_flight_info
    *& Form dislay_alv_report
        * text
        * --> p1 text
        * <-- p2 text
    FORM dislay_alv_report .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
        * I_INTERFACE_CHECK = ' '
        * I_BYPASSING_BUFFER =
        * I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = g_repid
        * I_CALLBACK_PF_STATUS_SET = ' '
        * I_CALLBACK_USER_COMMAND = ' '
    I_STRUCTURE_NAME = 'sflight'
        * IS_LAYOUT =
    IT_FIELDCAT = gt_fieldcat
        * IT_EXCLUDING =
        * IT_SPECIAL_GROUPS =
        * IT_SORT =
        * IT_FILTER =
        * IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = 'A'
    IS_VARIANT = GX_VARIANT
        * IT_EVENTS =
        * IT_EVENT_EXIT =
        * IS_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 = lt_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.
    ENDFORM. " dislay_alv_report
    *& Form initialize_variant
        * text
        * --> p1 text
        * <-- p2 text
    FORM initialize_variant .
    g_save = 'A'.
    clear g_variant.
    g_variant-report = g_repid.
    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.
    ENDFORM. " initialize_variant
    Regards,
    Rock.

  • What is the button to change the variant in alv?

    Hi guys,
              can u tell me  is there any button to change the variant in alv?. what is tanscation varient in report , hw it will used.

    Hi
    The ALV Grid Control is a tool with which you can output non-hierarchical lists in a
    standardized format. The list data is displayed as a table on the screen.
    The ALV Grid Control offers a range of interactive standard list functions that users need
    frequently (find, sort, filter, calculate totals and subtotals, print, print preview, send list,
    export list (in different formats), and so on. These functions are implemented in the
    proxy object class. You as the programmer have the possibility to turn off functions not
    needed. In most cases the implementations of the standard functions provided by the
    control are sufficient. However, if required, you can adjust these implementations to
    meet application-specific needs.
    You can add self-defined functions to the toolbar, if necessary.
    The ALV Grid Control allows users to adjust the layout of lists to meet their individual
    requirements (for example, they can swap columns, hide columns, set filters for the
    data to be displayed, calculate totals, and so on). The settings (list customizing) made
    by a specific user are called a display variant. Display variants can be saved on a userspecific
    or on a global basis. If such display variants exist for a list, they can be offered
    to the user for selection. If a display variant is set as the default variant, the associated
    list is always displayed based on the settings of this variant.
    <b>2. REUSE_ALV_LIST_DISPLAY
    REUSE_ALV_GRID_DISPLAY
    REUSE_ALV_FIELDCATALOG_MERGE
    REUSE_ALV_COMMENTARY_WRITE</b>
    3. Use of Field Catalog is to determines the technical properties & add formating information of the column.
    6. all the definition of internal table, structure, constants are declared in a type-pool called SLIS.
    7.fieldcat-fieldname
    fieldcat-ref_fieldname
    fieldcat-tabname
    fieldcat-seltext_m
    5. Form user_command using r_ucomm like sy-ucomm rs_selfield type slis_selfield.
    Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length.
    In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output.
    The report output can contain up to 90 columns in the display with the wide array of display options.
    The commonly used ALV functions used for this purpose are;
    <b>1. REUSE_ALV_VARIANT_DEFAULT_GET
    2. REUSE_ALV_VARIANT_F4
    3. REUSE_ALV_VARIANT_EXISTENCE
    4. REUSE_ALV_EVENTS_GET
    5. REUSE_ALV_COMMENTARY_WRITE
    6. REUSE_ALV_FIELDCATALOG_MERGE
    7. REUSE_ALV_LIST_DISPLAY
    8. REUSE_ALV_GRID_DISPLAY
    9. REUSE_ALV_POPUP_TO_SELECT</b>
    Purpose of the above Functions are differ not all the functions are required in all the ALV Report.
    But either no.7 or No.8 is there in the Program.
    How you call this function in your report?
    After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB.
    Then use follwing function module.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = 'Prog.name'
    I_STRUCTURE_NAME = 'I_ITAB'
    I_DEFAULT = 'X'
    I_SAVE = 'A'
    TABLES
    T_OUTTAB = I_ITAB.
    IF SY-SUBRC <> 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC .
    ENDIF.
    ENDFORM. " GET_FINAL_DATA
    The object F_IT_ALV has a field, the activity ACTVT, which can
    contain four permitted values: 01, 02, 03 and 70. Each of the
    activities 01, 02 and 70 controls the availability of particular
    functions (in the menu and the toolbar) of the ALV line item list:
    a) 01: "Settings -> Display variant -> Save..."
    b) 02: "Settings -> Display variant -> Current..." and
    "Settings -> Display variant -> Current header rows "
    c) 70: "Settings -> Display variant -> Administration..."
    Activity 03 corresponds to the minimum authorization, which is the
    most restricted one: The user can only select layouts which have
    been configured already. In particular, all of the other functions
    named above are inactive with activity 03.
    Now if you want to permit a user to change the column selection and
    the headers as well as to save the layout thus created, for example,
    but if you do not want to permit the user to administrate the
    layouts, you grant him or her the authorization for activities 01
    and 02.
    Check this link it will be mosty usefull for u
    http://www.sap-img.com/fu017.htm
    Reward all helpfull answers
    Regards
    Pavan

  • Hw to use a variant in alv report

    Hi,
    How to create, use and give f4 functionality to a variant in alv report.
    Give an example.
    Regards,
    Madhu

    <b>In this  report  i had used the  FM ->  REUSE_ALV_VARIANT_F4  for F4 help and the Varient on it  .</b>
    REPORT Z_INVENTORY.
    * List of the materials inventory.                                    *
    TYPE-POOLS: SLIS.
    TABLES:MARC, MARD, VBAP, LIPS, EKPO, VBFA, EKBE, MARM, VBBE, MARA, MBEW.
    SELECTION-SCREEN BEGIN OF BLOCK SEL WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_WERKS FOR MARC-WERKS, " Plant
                    S_MATNR FOR MARC-MATNR, " Material
                    S_MTART FOR MARA-MTART. " Material Type
    SELECTION-SCREEN END OF BLOCK SEL.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT. " ALV Variant
    CONSTANTS: FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    DATA: BEGIN OF INV OCCURS 100,
            WERKS LIKE MARD-WERKS, " Plant
            MATNR LIKE MARD-MATNR, " Material
            MTART LIKE MARA-MTART, " Material Type
            STPRS LIKE MBEW-STPRS, " Standard Price
            AVAIL LIKE MARD-LABST, " Available
            LABST LIKE MARD-LABST, " Unrestricted use
            INSME LIKE MARD-INSME, " Quality Inspection
            RETME LIKE MARD-RETME, " Returns
            TRANS LIKE MARC-UMLMC, " Stock in transit (calculated)
            UMLMC LIKE MARC-UMLMC, " Stock Transfer (plant)
            UMLME LIKE MARD-UMLME, " Transfer (SLoc)
            WESBS LIKE EKBE-WESBS, " GR Blocked Stock
            TRAME LIKE MARC-TRAME, " Stock in transit
            SPEME LIKE MARD-SPEME, " Blocked
            KWMENG LIKE VBAP-KWMENG, " Sales orders
            LFIMG LIKE LIPS-LFIMG, " Scheduled for Delivery
            MENGE LIKE EKPO-MENGE, " Open Purch. Orders
            VALUE LIKE MBEW-SALK3, " Stock Value (Calculated)
            MEINS LIKE MARA-MEINS, " Unit of measure
          END OF INV.
    DATA: FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
          HEADING  TYPE SLIS_T_LISTHEADER,
          LAYOUT   TYPE SLIS_LAYOUT_ALV,
          EVENTS   TYPE SLIS_T_EVENT,
          REPNAME  LIKE SY-REPID,
          F2CODE   LIKE SY-UCOMM VALUE  '&ETA',
          G_SAVE(1) TYPE C,
          G_EXIT(1) TYPE C,
          G_VARIANT LIKE DISVARIANT,
          GX_VARIANT LIKE DISVARIANT.
    INITIALIZATION.
      REPNAME = SY-REPID.
      PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].
      PERFORM BUILD_EVENTTAB USING EVENTS[].
      PERFORM BUILD_COMMENT USING HEADING[].
      PERFORM INITIALIZE_VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
      PERFORM F4_FOR_VARIANT.
    AT SELECTION-SCREEN.
      PERFORM PAI_OF_SELECTION_SCREEN.
    START-OF-SELECTION.
      PERFORM GET_MARD.
      PERFORM GET_UNIT_OF_MEASURE.
      PERFORM GET_MARC.
      PERFORM GET_EKPO.
      PERFORM GET_LIPS.
      PERFORM GET_VBAP.
      PERFORM GET_OPEN.
      PERFORM GET_PRICE.
    END-OF-SELECTION.
      PERFORM BUILD_LAYOUT USING LAYOUT.
      PERFORM WRITE_OUTPUT.
    *&      Form  INITIALIZE_FIELDCAT
    *       text
    *      -->P_FIELDTAB[]  text                                           *
    FORM INITIALIZE_FIELDCAT USING P_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV.
      DATA: L_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    * fixed columns (obligatory)
      CLEAR L_FIELDCAT.
      L_FIELDCAT-TABNAME    = 'INV'.
      L_FIELDCAT-FIX_COLUMN = 'X'.
      L_FIELDCAT-NO_OUT     = 'O'.
      L_FIELDCAT-FIELDNAME  = 'WERKS'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME  = 'MATNR'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
    * totalized columns
      CLEAR L_FIELDCAT.
      L_FIELDCAT-TABNAME   = 'INV'.
      L_FIELDCAT-SP_GROUP  = 'A'.
      L_FIELDCAT-DO_SUM    = 'X'.
      L_FIELDCAT-FIELDNAME = 'LABST'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'INSME'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'RETME'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'UMLME'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'WESBS'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'SPEME'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
    * columns with different description
      L_FIELDCAT-FIELDNAME = 'KWMENG'.
      L_FIELDCAT-SELTEXT_M = 'Sales Orders'.
      L_FIELDCAT-SELTEXT_S = 'Sales Or'.
      L_FIELDCAT-SELTEXT_L = 'Sales Orders Qty'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'LFIMG'.
      L_FIELDCAT-SELTEXT_M = 'Sched. Delivery'.
      L_FIELDCAT-SELTEXT_S = 'Schd. Del'.
      L_FIELDCAT-SELTEXT_L = 'Scheduled for Delivery'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'TRANS'.
      L_FIELDCAT-SELTEXT_M = 'Stk. in transit'.
      L_FIELDCAT-SELTEXT_S = 'Stk. trns'.
      L_FIELDCAT-SELTEXT_L = 'Stock in transit (sum)'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'AVAIL'.
      L_FIELDCAT-SELTEXT_M = 'Available'.
      L_FIELDCAT-SELTEXT_S = 'Avail.'.
      L_FIELDCAT-SELTEXT_L = 'Stock Available'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'MENGE'.
      L_FIELDCAT-SELTEXT_M = 'Open Orders'.
      L_FIELDCAT-SELTEXT_S = 'Open Ord'.
      L_FIELDCAT-SELTEXT_L = 'Open Purchase Orders'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
    * columns not displayed
      CLEAR L_FIELDCAT.
      L_FIELDCAT-TABNAME   = 'INV'.
      L_FIELDCAT-SP_GROUP  = 'A'.
      L_FIELDCAT-NO_OUT    = 'X'.
      L_FIELDCAT-FIELDNAME = 'MEINS'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'UMLMC'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'TRAME'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'STPRS'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
      L_FIELDCAT-FIELDNAME = 'VALUE'.
      APPEND L_FIELDCAT TO P_FIELDTAB.
    ENDFORM.                               " INITIALIZE_FIELDCAT
    *&      Form  BUILD_EVENTTAB
    *       text
    *      -->P_EVENTS[]  text                                             *
    FORM BUILD_EVENTTAB USING P_EVENTS TYPE SLIS_T_EVENT.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = P_EVENTS.
      READ TABLE P_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO P_EVENTS.
      ENDIF.
    ENDFORM.                               " BUILD_EVENTTAB
    *&      Form  BUILD_COMMENT
    *       text
    *      -->P_HEADING[]  text                                            *
    FORM BUILD_COMMENT USING P_HEADING TYPE SLIS_T_LISTHEADER.
      DATA: HLINE TYPE SLIS_LISTHEADER,
            TEXT(60) TYPE C,
            SEP(20) TYPE C.
      CLEAR: HLINE, TEXT.
      HLINE-TYP  = 'H'.
      WRITE: TEXT-101 TO TEXT+23.
      HLINE-INFO = TEXT.
      APPEND HLINE TO P_HEADING.
      CLEAR TEXT.
      WRITE: 'User: ' TO TEXT,
             SY-UNAME TO TEXT+6,
             'Date: ' TO TEXT+25,
             SY-DATUM TO TEXT+31,
             'Page: ' TO TEXT+50,
             SY-PAGNO TO TEXT+56.
      HLINE-INFO = TEXT.
      APPEND HLINE TO P_HEADING.
    ENDFORM.                    " BUILD_COMMENT
    *       FORM TOP_OF_PAGE                                              *
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = HEADING.
    ENDFORM.
    *&      Form  INITIALIZE_VARIANT
    *       text
    FORM INITIALIZE_VARIANT.
      G_SAVE = 'A'.
      CLEAR G_VARIANT.
      G_VARIANT-REPORT = REPNAME.
      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.
    ENDFORM.                               " INITIALIZE_VARIANT
    *&      Form  F4_FOR_VARIANT
    *       text
    FORM F4_FOR_VARIANT.
    <b>  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                IS_VARIANT = G_VARIANT
                I_SAVE     = G_SAVE
           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.</b>
    ENDFORM.                               " F4_FOR_VARIANT
    *&      Form  PAI_OF_SELECTION_SCREEN
    *       text
    FORM PAI_OF_SELECTION_SCREEN.
      IF NOT P_VARI IS INITIAL.
        MOVE G_VARIANT TO GX_VARIANT.
        MOVE P_VARI TO GX_VARIANT-VARIANT.
        CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  I_SAVE     = G_SAVE
             CHANGING
                  CS_VARIANT = GX_VARIANT.
        G_VARIANT = GX_VARIANT.
      ELSE.
        PERFORM INITIALIZE_VARIANT.
      ENDIF.
    ENDFORM.                               " PAI_OF_SELECTION_SCREEN
    *&      Form  GET_MARD
    *       text
    FORM GET_MARD.
      SELECT MATNR WERKS LABST INSME RETME UMLME SPEME
             FROM MARD
             INTO CORRESPONDING FIELDS OF INV
             WHERE MATNR IN S_MATNR
             AND   WERKS IN S_WERKS.
        COLLECT INV.
      ENDSELECT.
      PERFORM FILTER_BY_MATERIAL_TYPE.
    ENDFORM.                               " GET_MARD
    *&      Form  FILTER_BY_MATERIAL_TYPE
    *       text
    FORM FILTER_BY_MATERIAL_TYPE.
      LOOP AT INV.
        CLEAR INV-MTART.
        SELECT SINGLE MTART
               INTO INV-MTART
               FROM MARA
               WHERE MATNR EQ INV-MATNR
               AND   MTART IN S_MTART.
        IF SY-SUBRC EQ 0.
          MODIFY INV.
        ELSE.
          DELETE INV.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " FILTER_BY_MATERIAL_TYPE
    *&      Form  GET_MARC
    *       text
    FORM GET_MARC.
      LOOP AT INV.
        SELECT SINGLE UMLMC TRAME
               FROM MARC
               INTO CORRESPONDING FIELDS OF INV
               WHERE MATNR EQ INV-MATNR
               AND   WERKS EQ INV-WERKS.
        IF SY-SUBRC EQ 0.
          INV-TRANS = INV-UMLMC + INV-TRAME.
          MODIFY INV.
        ENDIF.
      ENDLOOP.
    ENDFORM.                               " GET_MARC
    *&      Form  GET_EKPO
    *       text
    FORM GET_EKPO.
      DATA: WESBS LIKE INV-WESBS,
            SHKZG LIKE EKBE-SHKZG,
            MEINS LIKE EKPO-MEINS,
            LMEIN LIKE EKPO-LMEIN.
      LOOP AT INV.
        CLEAR: WESBS, SHKZG, MEINS, LMEIN.
        SELECT Y~WESBS Y~SHKZG X~MEINS X~LMEIN
               INTO (WESBS, SHKZG, MEINS, LMEIN)
               FROM EKPO AS X JOIN EKBE AS Y
               ON   X~EBELN = Y~EBELN
               AND  X~EBELP = Y~EBELP
               WHERE X~MATNR EQ INV-MATNR
               AND   X~WERKS EQ INV-WERKS
               AND   X~LOEKZ NE 'L'.
          IF SHKZG EQ 'H'.
            MULTIPLY WESBS BY -1.
          ENDIF.
          IF MEINS NE LMEIN.
            PERFORM CONVERT_UNIT_OF_MEASURE CHANGING INV-MATNR MEINS WESBS.
          ENDIF.
          ADD WESBS TO INV-WESBS.
        ENDSELECT.
        MODIFY INV.
      ENDLOOP.
    ENDFORM.                               " GET_EKPO
    *&      Form  GET_LIPS
    *       text
    FORM GET_LIPS.
      DATA: LFIMG LIKE INV-LFIMG.
      LOOP AT INV.
        CLEAR: LFIMG, INV-LFIMG.
        SELECT OMENG
               INTO LFIMG
               FROM VBBE
               WHERE MATNR EQ INV-MATNR
               AND   WERKS EQ INV-WERKS
               AND   VBTYP EQ 'J'.
          ADD LFIMG TO INV-LFIMG.
        ENDSELECT.
        MODIFY INV.
      ENDLOOP.
    ENDFORM.                               " GET_LIPS
    *&      Form  GET_VBAP
    *       text
    FORM GET_VBAP.
      DATA: KWMENG LIKE INV-KWMENG.
      LOOP AT INV.
        CLEAR: KWMENG, INV-KWMENG.
        SELECT OMENG
               INTO KWMENG
               FROM VBBE
               WHERE MATNR EQ INV-MATNR
               AND   WERKS EQ INV-WERKS
               AND   VBTYP EQ 'C'.
          ADD KWMENG TO INV-KWMENG.
        ENDSELECT.
        INV-AVAIL = INV-LABST - INV-INSME - INV-KWMENG - INV-LFIMG.
        MODIFY INV.
      ENDLOOP.
    ENDFORM.                               " GET_VBAP
    *&      Form  GET_UNIT_OF_MEASURE
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM GET_UNIT_OF_MEASURE.
      LOOP AT INV.
        SELECT SINGLE MEINS
               FROM MARA
               INTO INV-MEINS
               WHERE MATNR EQ INV-MATNR.
        MODIFY INV.
      ENDLOOP.
    ENDFORM.                               " GET_UNIT_OF_MEASURE
    *&      Form  GET_OPEN
    *       text
    FORM GET_OPEN.
      DATA: BEGIN OF XTAB OCCURS 10,       " Open orders table
               WERKS LIKE EKPO-WERKS,
               LGORT LIKE EKPO-LGORT,
               MATNR LIKE EKPO-MATNR,
               MENGE LIKE EKPO-MENGE,
               MENGK LIKE EKPO-MENGE,
             END OF XTAB.
      RANGES: L_WERKS FOR MARD-WERKS.
      LOOP AT INV.
        REFRESH XTAB.
        CLEAR: XTAB, L_WERKS.
        MOVE INV-WERKS TO L_WERKS-LOW.
        CALL FUNCTION 'MB_ADD_PURCHASE_ORDER_QUANTITY'
             EXPORTING
                  X_MATNR = INV-MATNR
                  X_MEINS = INV-MEINS
                  X_ELIKZ = SPACE
                  X_LOEKZ = SPACE
             TABLES
                  XTAB    = XTAB
                  XWERKS  = L_WERKS.
        MOVE XTAB-MENGE TO INV-MENGE.
        MODIFY INV.
      ENDLOOP.
    ENDFORM.                               " GET_OPEN
    *&      Form  GET_PRICE
    *       text
    FORM GET_PRICE.
      LOOP AT INV.
        SELECT SINGLE STPRS
               FROM MBEW
               INTO INV-STPRS
               WHERE MATNR EQ INV-MATNR
               AND   BWKEY EQ INV-WERKS
               AND   BWTAR EQ SPACE.
          IF SY-SUBRC EQ 0.
            INV-VALUE = INV-STPRS *
                      ( INV-LABST + INV-INSME + INV-TRANS + INV-SPEME ).
            MODIFY INV.
          ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_PRICE
    *       FORM CONVERT_UNIT_OF_MEASURE                                  *
    *       text                                                          *
    *  -->  P_MATNR                                                       *
    *  -->  P_VRKME                                                       *
    *  -->  P_QUANT                                                       *
    FORM CONVERT_UNIT_OF_MEASURE USING P_MATNR P_VRKME P_QUANT.
      DATA: UMREZ LIKE MARM-UMREZ,
            UMREN LIKE MARM-UMREN.
      SELECT SINGLE UMREZ UMREN
             INTO (UMREZ, UMREN)
             FROM MARM
             WHERE MATNR EQ P_MATNR
             AND   MEINH EQ P_VRKME.
      IF SY-SUBRC EQ 0.
        COMPUTE P_QUANT = ( P_QUANT * UMREZ ) / UMREN.
      ENDIF.
    ENDFORM.
    *&      Form  BUILD_LAYOUT
    *       text
    *      -->P_LAYOUT  text                                               *
    FORM BUILD_LAYOUT USING P_LAYOUT TYPE SLIS_LAYOUT_ALV.
      P_LAYOUT-F2CODE       = F2CODE.
      P_LAYOUT-ZEBRA        = 'X'.
      P_LAYOUT-DETAIL_POPUP = 'X'.
    ENDFORM.                               " BUILD_LAYOUT
    *&      Form  WRITE_OUTPUT
    *       text
    FORM WRITE_OUTPUT.
      SORT INV BY WERKS MATNR.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME     = REPNAME
                I_INTERNAL_TABNAME = 'INV'
                I_INCLNAME         = REPNAME
           CHANGING
                CT_FIELDCAT        = FIELDTAB.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_FIELDCATALOG_MERGE'.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM = REPNAME
                I_STRUCTURE_NAME   = 'INV'
                IS_LAYOUT          = LAYOUT
                IT_FIELDCAT        = FIELDTAB
                I_DEFAULT          = 'A'
                I_SAVE             = G_SAVE
                IS_VARIANT         = G_VARIANT
                IT_EVENTS          = EVENTS[]
           TABLES
                T_OUTTAB           = INV.
      IF SY-SUBRC <> 0.
        WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
      ENDIF.
    ENDFORM.                               " WRITE_OUTPUT
    reward  points if it is usefull.....
    Girish

Maybe you are looking for

  • Strange system log error

    Hi everyone. I'm having some trouble. Today i saw my system log file have an error going. its a iMac AOSNotification[165]: [AOSNotification] XMPP session not connected - no ping sent and it is coming all day long. i'm sure it have something to do wit

  • Ocs mail server not forwading email

    Hi all, I have OCS email server with a mail domain. OID has em forwarding set for users to forward em to external mail domain. The OCS web email client works, sending em to local domain i.e. [email protected] forwards to [email protected] Problem is

  • NTSC playback better than PAL?

    Hi, this is a question about DVD Player (4.6.5) rather than iDVD but I hope you can help. I've got a 20" Intel iMac and I often use it to watch commercial DVDs as I don't currently have a TV (poor me) it seems that if I watch an NTSC DVD the picture

  • Detect clicked cluster in mouse down event for clusters within multiple stacked clusters

    With the help of Ben (see http://forums.ni.com/t5/LabVIEW/Determine-cluster-element-clicked-in-mouse-down-event/td-p/1245770) I could easily find out what sub-cluster had been clicked on (mouse down event) within the main cluster, by using the Label.

  • Get specific eventId from sensor using browser

    Is there a way I can use just a browser (no java) to request only a specific eventId (alarm) from a sensor? XML results are fine. Thanks, Matt