ALV - How to default variant change.

I have coded one report with ALV output.
I have /DEFAULT variant in my ALV output  and the output contains 12 fields.
When I execute the this report
problem 1). How can i shift the 7th field to 12 th field and save as a new variant.
Problem 2).If I rerun this new variant, how can I keep new set of arranged fields of new variant in the new order( means 7th field in 12 th position ).
I mean in while re-running the program the fields are arranged in old manner (  7 th field in 7th position only - my functional consultant told me ) .
Could you please help me ?

are you sure that g_variant has got the correct value in it? Here's the components I use for programs that need the variant logic:
PARAMETERS: p_varint LIKE disvariant-variant.
initialization.
perform alv_setup_layout_variant.
AT SELECTION-SCREEN.
  PERFORM alv_validate_layout_variant.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varint.
  PERFORM alv_f4_for_layout_variant.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
...............etc
      i_save             = 'A'
      is_variant         = w_variant
............................etc
    EXCEPTIONS
      OTHERS             = 0.
FORM alv_setup_layout_variant .
  DATA: lw_variant LIKE disvariant. " Layout structure
  CLEAR w_variant.
  w_variant-report = sy-repid.
  w_save = 'A'.
Get default variant
  lw_variant = w_variant.
  CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
    EXPORTING
      i_save     = w_save
    CHANGING
      cs_variant = lw_variant
    EXCEPTIONS
      not_found  = 2.
  IF sy-subrc = 0.
    p_varint = lw_variant-variant.
  ENDIF.
ENDFORM.                    " alv_setup_layout_variant
FORM alv_validate_layout_variant.
  DATA: lw_variant LIKE disvariant. " Layout structure
  IF NOT p_varint IS INITIAL.
    lw_variant = w_variant.
    lw_variant-variant = p_varint.
    CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
      EXPORTING
        i_save     = w_save
      CHANGING
        cs_variant = lw_variant.
    w_variant = lw_variant.
  ENDIF.
ENDFORM.                    " alv_validate_layout_variant
FORM alv_f4_for_layout_variant.
  DATA: lw_variant LIKE disvariant.
  CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
       EXPORTING
            is_variant          = w_variant
            i_save              = w_save
          it_default_fieldcat =
       IMPORTING
            e_exit              = w_exit
            es_variant          = lw_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.
Store returned variant
    IF w_exit = space.
      p_varint = lw_variant-variant.
    ENDIF.
  ENDIF.
ENDFORM.                    " alv_f4_for_layout_variant

Similar Messages

  • How to track Variant Changes

    Hi,
    As part of SOX we have a requirement in which we want to track who changed the program variant and what changes he did. Is there is anyway we can get this info?
    If not is there any exit or BADI that we can use to create change documents for this scenario?
    Thanks
    Giridhar

    You can find who made the most recent change and when in table VARID, but I haven't been able to find any way to determine what was changed.  Likewise, I didn't see any place to customize the update to capture changes.  You might need to create a custom application for this which would be a bit tricky, but could be done.

  • Change default variant in ALV grid on runtime

    Hello colleagues,
    where is the place in a code (CL_ALV_VARIANT, CL_GUI_ALV_GRID, ...) where I can change the deault layout. Customer require a modification which change default layout in ALV under specific circumstances.
    Kind regards
    Radim Benek

    It depend when these "specific circumstances" are occurring?
    Before displaying the ALV, then force the value of the variant used in set_table_for_first_display,
    CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        I_STRUCTURE_NAME = 'SFLIGHT'
        IS_VARIANT = GS_variant
        I_SAVE = X_SAVE
      CHANGING
        IT_OUTTAB = GT_SFLIGHT.
    If you want to simulate multiple "default variant" you should "mislead" the ALV by changing the report name used for storing variant (IS_VARIANT-REPORT) But in this case you will no longuer see every variant  when in the ALV, only those of the "report name" passed when setting for first display.
    Regards

  • ALV How to save a variant?

    Hi experts, how can I save a layout variant?
    So I declared a variant, and put into reuse_alv_grid_display, but doesn't work instead of this. What could be the problem with it?
    DATA: g_variant like disvariant.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
      I_CALLBACK_PROGRAM                = ' '
      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                  = ' '
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
        IS_LAYOUT                         = gs_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                        = g_variant
      IT_EVENTS                         =
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = gt_list
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2

    Hi White,
    <b>Just try this code below it will certainly work out.</b>
    Create a field on the selecion screen for the variant selection.
    As : PARAMETERS : P_VAR LIKE DISVARIANT-VARIANT.
    *Then Form for all perform is coded below
    initialization.
    v_repid = sy-repid.
    Display default variant
    PERFORM SUB_VARIANT_INIT.
    AT SELECTION-SCREEN ON P_VAR.
    Once the user has entered variant, check about its existence
    PERFORM SUB_CHECK_PVAR.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VAR.
    Display a list of various variants of the report when the
    user presses F4 key in the variant field
    PERFORM SUB_VARIANT_F4.
    FORM SUB_CHECK_PVAR.
    If the name of the variable is not blank, check about its existence
    if not p_var is initial.
      clear i_variant.
      i_variant-report = sy-repid.
      i_variant-variant = p_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  I_SAVE     = 'A'
             CHANGING
                  CS_VARIANT = I_VARIANT.
    If no such variant found , flash error message
         if sy-subrc ne 0 .
          message e398(00) with 'No such variant exists'.
         else.
    If variant exists , use the variant name to populate structure
    I_VARIANT1 which will be used for export parameter : IS_VARIANT
    in the function module : REUSE_ALV_GRID_DISPLAY
           clear i_variant1.
           move p_var to i_variant1-variant.
           move sy-repid to i_variant1-report.
         endif.
    else.
       clear i_variant.
    endif.
    ENDFORM.                    " SUB_CHECK_PVAR
    FORM SUB_CHECK_PVAR.
    If the name of the variable is not blank, check about its existence
    if not p_var is initial.
      clear i_variant.
      i_variant-report = sy-repid.
      i_variant-variant = p_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
             EXPORTING
                  I_SAVE     = 'A'
             CHANGING
                  CS_VARIANT = I_VARIANT.
    If no such variant found , flash error message
         if sy-subrc ne 0 .
          message e398(00) with 'No such variant exists'.
         else.
    If variant exists , use the variant name to populate structure
    I_VARIANT1 which will be used for export parameter : IS_VARIANT
    in the function module : REUSE_ALV_GRID_DISPLAY
           clear i_variant1.
           move p_var to i_variant1-variant.
           move sy-repid to i_variant1-report.
         endif.
    else.
       clear i_variant.
    endif.
    ENDFORM.                    " SUB_CHECK_PVAR
    form SUB_VARIANT_F4.
    i_variant-report = sy-repid.
    Utilising the name of the report , this function module will
    search for a list of variants and will fetch the selected one into
    the parameter field for variants
    CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                IS_VARIANT         = I_VARIANT
                I_SAVE             = 'A'
                I_DISPLAY_VIA_GRID = 'X'
           IMPORTING
                ES_VARIANT         = I_VARIANT1
           EXCEPTIONS
                NOT_FOUND          = 1
                PROGRAM_ERROR      = 2
                OTHERS             = 3.
      IF SY-SUBRC = 0.
        P_VAR = I_VARIANT1-VARIANT.
    ENDIF.
    endform.                    " SUB_VARIANT_F4
    then in CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    pass the name of variant field
    <b></b>

  • How to Make Variant as a default?

    Hi,
          How  to  make  Variants as a  default variant  for  reports  like  Layouts?     
      and   how to make  Scope  of list   :     ALV -> grid control  as  default  in ME55 ( Collective release of Purchase requisitions )
    like ME28 ( Release Purchase Documents ) .   We have   scope of  list  is ALV  as  default  in ME28.
      Thanks  in  Advance.
    Regards,
    Aruna.

    Check
    Variant as default

  • How enhance the default variant in standard transaction COOIS (SAP&COOIS) as per the user requirement

    Hi,
    I have one query that how to enhance the standard default variant (SAP&COOIS) for standard transaction COOIS.
    If any one know solution pls share.
    Thanks & Regards,
    J.Goud

    Hi Maine,
    Thanks for your reply.
    As you mentioned for your own program, you can control the parameter "I_SAVE", when calling "REUSE_ALV_GRID_DISPLAY".
    so already i have use the same logic and control the parameter through I_SAVE and here i am calling method ALV_GRID->SET_TABLE_FOR_FIRST_DISPLAY instead of "REUSE_ALV_GRID_DISPLAY".
    and it works fine when we execute the report but the logic doesnt work when the user tries to change and save the layout variant on the output screen of the report.
    Regards,
    Satish

  • Default variants in ALV

    hello all,
    can someone kindly tell me how to use the FM
    "REUSE_ALV_VARIANT_DEFAULT_GET " in ALV for getting the default variant on the selection screen. what are the paameters to be specified????
    thanks in adance,
    seenu

    Hello,
    Check this code:
    DATA : g_r_disp_variant TYPE disvariant.
    SELECTION-SCREEN BEGIN OF BLOCK variant WITH FRAME TITLE text-003.
    PARAMETERS:  p_varian LIKE disvariant-variant DEFAULT '/STANDARD'.
    SELECTION-SCREEN END OF BLOCK variant.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varian.
      PERFORM show_existing_display_variants.
    *&      Form  SHOW_EXISTING_DISPLAY_VARIANTS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM show_existing_display_variants.
      g_r_disp_variant-report = sy-repid.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
           EXPORTING
                is_variant    = g_r_disp_variant
                i_save        = 'A'
           IMPORTING
                es_variant    = g_r_disp_variant
           EXCEPTIONS
                not_found     = 1
                program_error = 2
                OTHERS        = 3.
      IF sy-subrc = 0.
        p_varian = g_r_disp_variant-variant.
      ENDIF.
    ENDFORM.                               " SHOW_EXISTING_DISPLAY_VARIANTS
    *form get_output
      g_repid = sy-repid.
    *  display variant
      g_r_disp_variant-report = sy-repid.
      IF NOT p_varian IS INITIAL.
        g_r_disp_variant-variant = p_varian.
      ENDIF.
    *get_output
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program = g_repid
                i_grid_title       = 'PRICE COMPARISON REPORT:'
                is_layout          = it_layout
                it_fieldcat        = it_fldcat
                is_variant         = g_r_disp_variant
                i_default          = 'X'
                i_save             = 'A'
           TABLES
                t_outtab           = g_t_itab_alv
           EXCEPTIONS
                program_error      = 1
                OTHERS             = 2.
    REgards,
    Vasanth

  • I have s mac book pro--I would like very much to have the output to the DVI cable --my audio(sound) wilkl nit default to DVI output  --How can this be changed

    I have a mac book pro--I would like very much to have the output to the DVI cable --my audio(sound) wilkl nit default to DVI output  --How can this be changed, so it does not default to interabnl speaker
    Is there a way to force the system to change to DVI output?????
    thanks a lot

    Hi there,
    You may find the troubleshooting steps in the article below helpful.
    Troubleshooting issues with no audio from built-in speakers on Macs
    http://support.apple.com/kb/ts1574
    -Griff W.

  • Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Simple/silly question: how do I set/change default font/color for outgoing mail messages?

    Just a suggestion..........
    Download Thunderbird.  Easier to use when it comes to what you want to do w/your emails. 

  • SCI Change global default variant

    Hi,
    For a group of programmer I like to create a particular Default variant common for all. But I think I can Change the Global Variant...?
    Thanks
    Martin

    Martín Piattini,
    answering to your question I´ll give you this steps:
    1. Go to transaction 'SCI', make a copy of global DEFAULT variant and give other name, like DEFAULT_AISHI;
    2. Make your changes, setting all the flags your need at the categories;
    3. Go to transaction 'SE16', at the table 'SCICHKV_ALTER', set the item DEFAULT flag and click on EDIT BUTTON.
    4. Change the field 'CHECKVNAME_NEW', 'RESPONSIBL', 'CREADATE' and clik on SAVE BUTTON.
    Ready!
    Enjoy your new GLOBAL DEFAULT VARIANT.

  • How do I reset to default or change static IP address on HP Officejet Pro 8600 Premium printer?

    How do I reset setting to default or change static IP address on HP Officejet Pro 8600 Premium printer?

    Hi,Tap the right arrow and then tap the Setup icon.Tap the Network option and select Restore Network Defaults.Confirm any prompt to restore the default network settings, it will remove any manual IP configuration. If you are wirelessly connected to the network, select Wireless Setup Wizard and select your network to reconnect the printer wirelessly. Regards,Shlomi

  • How to save only changed data of ALV in a local table ?

    Hi everyone,
    I created and alv with cl_gui_alv_grid, and I made it editable
    Now I need that when I click on a button only the changed data to be saved on a local (internal) table
    Is there a way I can do that ?
    I tried with methods like check_changed_data() but they don't return a table like that
    Regards,
    Dren Selimi

    ok than
    class lcl_event_receiver definition.
         methods:
    * Handle Data Changed
         handle_data_changed
         for event data_changed of cl_gui_alv_grid
         importing er_data_changed,
    endclass.                    "lcl_event DEFINITION
    class lcl_event_receiver implementation.
         method handle_data_changed.
              data: ls_good type lvc_s_modi.
              loop at er_data_changed->mt_good_cells into ls_good.
                   read table gt_table into gs_table index ls_good-index. "is your changed row in ALV
                    ls_good-fieldname "is your changed field
                   if ls_good-fieldname eq 'MATNR'.
                        gs_table-matnr " is your changed field old value.
                   endif. "i couldn't find a dynamic solution for old value
                   "if you do not have so many columns in alv you can use this solution
                    ls_good-value "is your changed field new value
                   append these values to your changed field table.
                   modify gt_table from gs_table index ls_good-index.           
              endloop.
              call method g_alvgrid->refresh_table_display.
         endmethod.
    endclass.

  • How to set a Default variant for VL06O (Outbound Delivery Monitor)?

    Hi All,
    I want to set a DEFAULT VARIANT for  VL06O (Outbound Delivery Monitor) selection screen with "For Picking", "For Confirmation", "For Goods Issue" and "List of Outbound Deliveries" button option.
    I have already created a variant with those 4 buttons. But I cant find a way to set it as DEFAULT.
    Appreciate your help on this.
    Please note I'm using SAP ERP 6.0 Ehp 4.
    Thanks & best regards,
    Anupa

    Hi Indranil,
    Superb !
    This is what I was searching for.
    That works really fine. Thanks a lot!
    Best regards,
    Anupa

  • Report always shows default variant

    Hello,
    I've got a report where we can choose a variant in the selection screen.
    SELECTION-SCREEN BEGIN OF BLOCK SEL2 WITH FRAME TITLE TEXT-002.
    PARAMETERS p_layout TYPE slis_vari.
    SELECTION-SCREEN END OF BLOCK SEL2.
    I've got it setup so that when the user runs the report, the field p_layout is filled with his default variant or if he has none it's empty.
    My problem is when the field is empty the result ALV is always shown with the default variant.
    For example:
    User has 2 variants - SAV1 and SAV2 (default).
    User enters selection screen and p_layout is filled with SAV2.
    Scenario 1:
    User presses F8 and the ALV is shown with the variant SAV2
    Scenario 2:
    User changes p_layout to SAV1 and presses F8. ALV is shown with SAV1 variant
    Scenario 3:
    User emptys p_layout (p_layout IS INITIAL), presses F8 and ALV is shown with SAV2 variant - the default one
    What can I do so that when p_layout IS INITIAL the ALV shows all the columns?
    This is how I define the layout:
           gr_layout = gr_alv->get_layout( ).
           MOVE sy-repid TO gs_layout_key-report.
           gr_layout->set_key( gs_layout_key ).
           gr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
           gr_layout->set_default( 'X' ).
           gr_layout->set_initial_layout( p_layout ).
    F4 help for p_layout:
       ls_layout_key-report = sy-repid.
       ls_layout_info = cl_salv_layout_service=>f4_layouts( ls_layout_key ).
       p_layout = ls_layout_info-layout.
    Initialization of p_layout:
       gs_variant-report = sy-repid.
       CALL FUNCTION 'REUSE_ALV_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 = 2 OR sy-subrc = 0.
         p_layout = gs_variant-variant.
       ELSE.
         MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
    the sy-subrc = 2 is there to prevent error if user has no layouts => p_layout stays empty
    Thank you in advance!

    Thank you Thanga Prakash for your help, it lead me to the an awnser.
    Even after I cleared the p_layout I still had the same issue but after reviewing the code once more I deleted the following line
    gr_layout->set_default( 'X' ).
    With this, if no layout was specified (p_layout IS INITIAL) the default variant was always called.

  • How to use variants and/ or adding packages in Ulticap?

    Hi,
    Can anyone please explain me a bit what "Variants" are for in Ultiboard 2001's Ulticap?
    Recently I was rearranging my personal libraries in Ulticap and started to experiment with adding packages to symbols. (in order to reduce the number of seperate shapes).
    In a symbol properties tab you can add Ultiboard packages and set one of those as the default one. Expecting when in Ulticap placing the symbol that I would get a list of the "available packages" with the default one on top. But unfortunately still a one-line dialog stil is shown with the a question mark or the default package already filled in (and ready to be ok-d or re-entered).
    Exporting a schematic from Ulticap to Ultiboard and open the properties dialog of a component that I gave multiple packages in Ulticap still doesn't show the additional packages (to choose from).
    So I started to wonder why we can add packages to shapes in Ulticap. I can't find any useful explanation about it in the binder that came with ultiboard 2001, nor I can find anything useful in docs that came with previous versions.
    Anyway, I also ran into the "Variants" tab when opening the properties dialog of a shape in Ulticap. It might be something useful for my current issue but unfortunately again there's no reasonable explanation to find in the docs about what they are and what they are used for; just "how to add or change" is explained but not the slightest bit of a brief introduction.
    The main goal for me is e.g. having a shape "_ELCO" and on the run select the right package since elco's have a diversity of sizes and I find it unpractical to fill up the library with seperate shapes for elco's of different sizes. Otherwise the lists in the library get too long for browsing through them when placing an other component.
    So a brief explanation of the use of adding packages and what variants are for would be very helpful to me.
    Cheers,
    Roberto

    hi,
      You cannot use the logical and  or condition together at the same time in SQL statement. Sachin is correct while using the and and or in the same condition. You can get the data using or condition in SQL statement, and then use the delete statement of internal table using the end condition. please find the following code for the same.
    select *
      from dtab
    where cond1 eq 'A1'
         or cond2 eq 'A2'.
    if sy-subrc eq 0.
      delete itab where cond1 eq 'A1' and 'A2'.
    endif.
    regards,
    Veeresh

Maybe you are looking for