How to get default lay out set in my ALV out put.

I need to have default layout in my ALV output.
My functional consultant idea was to make sure they have an ALV variant selected. 
When he first run the program, how will need to  get a "/DEFAULT" variant created.
How can I do that ?
Initialization - For ALV variant
INITIALIZATION.
  ws_repid = sy-repid.
  g_save  = 'A'.
  CLEAR g_variant.
  g_variant-report = ws_repid.
Get default variant.
  gx_variant  = g_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.
&--F4 HELP - FOR ALV VARIANT GET--
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_vari.
  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.
&--AT SELECTION-SCREEN.- For ALV Variant--
AT SELECTION-SCREEN.
*Getting variant Existence
  PERFORM get_exist_variant.
*&      Form  GET_EXIST_VARIANT                                        *
      text                                                           *
FORM get_exist_variant .
  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.
    CLEAR g_variant.
    g_variant-report = ws_repid.
  ENDIF.
ENDFORM.                    " GET_EXIST_VARIANT
*&      Form  alv_display                                              *
This subroutine is to display the out put in ALV.                    *
FORM alv_display .
Local data
  DATA: y_x          LIKE boole  VALUE 'X'.
  DATA: lh_index     LIKE lf_fieldcat-col_pos.
For variant
DATA: ws_repid LIKE sy-repid,
      g_save TYPE c VALUE 'A',
      g_exit TYPE c,
      g_variant LIKE disvariant,
      gx_variant LIKE disvariant.
  For 1st field.( RPT_LOC )
    CLEAR lf_fieldcat.
    lf_fieldcat-fieldname = 'RPT_LOC'.
    lf_fieldcat-tabname = 'GT_ZGXMIT_L'.
    lf_fieldcat-ref_tabname = 'ZGXMIT'.
    lf_fieldcat-ref_fieldname = 'RPT_LOC'.
    lh_index = lh_index + 1.
    lf_fieldcat-col_pos = lh_index.
    lf_fieldcat-key = y_x.
    lf_fieldcat-no_sum = y_x.
    APPEND lf_fieldcat TO lt_fieldcat.
For 2nd field.( BAL_XMIT )
    CLEAR lf_fieldcat.
    lf_fieldcat-fieldname = 'BAL_XMIT'.
    lf_fieldcat-tabname = 'GT_ZGXMIT_L'.
    lf_fieldcat-ref_tabname = 'ZGXMIT'.
    lf_fieldcat-ref_fieldname = 'BAL_XMIT'.
    lh_index = lh_index + 1.
    lf_fieldcat-col_pos = lh_index.
    lf_fieldcat-key = y_x.
    lf_fieldcat-no_sum = y_x.
    APPEND lf_fieldcat TO lt_fieldcat.
4,5,....fields appening
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
        i_callback_program                = ws_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
       i_callback_user_command           = 'USER_COMMAND'
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         = v_alv_layout
       it_fieldcat                       = lt_fieldcat
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
       i_save                            = 'A'
      IS_VARIANT                        =
       it_events                         = events[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
       TABLES
            t_outtab                 = gt_zgxmit_l
       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.                    " alv_display

Hello SAm,
U have to set like   DATA: IT_VARIANT LIKE DISVARIANT,
        G_S_SORT  LIKE LINE OF IT_SORT.
  DATA : G_R_DISP_VARIANT TYPE DISVARIANT.
  SORT G_T_OUTTAB BY PSPID POSID.
  CLEAR: G_R_DISP_VARIANT.
For storing the variant layout
  IT_VARIANT-REPORT  = SY-REPID.
  IF NOT P_VARIAN IS INITIAL.
    G_R_DISP_VARIANT-VARIANT = P_VARIAN.
  ELSE.
    IT_VARIANT-VARIANT = '/Z48M'.
  ENDIF.
  CLEAR G_T_OUTTAB.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            I_CALLBACK_PROGRAM = IT_VARIANT-REPORT
            I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
            IT_FIELDCAT        = IT_FIELDCAT
            I_SAVE             = 'A'
            IS_VARIANT         = IT_VARIANT
           IS_LAYOUT          = IT_LAYOUT
            IT_SORT            = IT_SORT[]
       TABLES
            T_OUTTAB           = G_T_OUTTAB
       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.
If u want F4 help in the selection screen then do like this.
SELECTION-SCREEN BEGIN OF BLOCK VARIANT WITH FRAME TITLE TEXT-013.
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.
  DATA: G_R_DISP_VARIANT TYPE DISVARIANT.
  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
If useful reward.
Vasanth

Similar Messages

  • My time machine backup external hard drive has failed.  I have a newer external drive already connected to my MAC but can't figure out how to get Time Machine to set up on it?

    My time machine backup external hard drive has failed.  I have a newer external drive already connected to my MAC but can't figure out how to get Time Machine to set up on it

    http://pondini.org/TM/21.html

  • How to get default values while using the transaction "BP"

    Hi Group,
    I have a query on how to get default values while using the transaction <b>BP</b>?
    The thing is:
    when I enter into the transaction "BP", I need to see some default values to some of the input fields in the screen.
    how can I achieve this?
    So please kindly let me know the procedure to achieve this.
    Thanks & Regards,
    Vishnu.

    Hi,
    The events of BDT can be used to default some fields on creating a partner.
    For this create a function module for ISDAT. attach that event in BUS7.
    In the ISDAT funtion modulethe following code should be used.
    For example to set the nationality:
    I_BUSDEFAULT-NATIO = 'DE.
    CALL FUNCTION 'BUP_BUPA_FIELDVALUES_SET'
    EXPORTING
    i_busdefault = I_BUSDEFAULT
    Regards, Smita.

  • How to get calendar travel time (set up in Mavericks) to show on iOS 7 calendar?

    I was wondering how to get calendar travel time (set up in Mavericks) to show on iOS 7 calendar? If I change a location in mavericaks it is updated in my iOS 7 calendar, but if I add travel time to an appointment, that does not show up on my iphone. This seems like a big miss for apple if this is the case. I could maybe understand not adding the ability to add travel time in iOS 7, but not being able to see the travel times you set up seems very incomplete. Any ideas or insight?

    Hello Cheer,
    I don't believe the table changed when migrating from Access.  I had two tables before the migration, one was for the SwitchBoard Manager and the other table was for the database table.  I used the Switchboard to navigate to different menus, such
    as the Main Form, Power Form, Server Form, etc.  Let me know if I can provide any other information to help you narrow this down for me.   
    Thank you for your assistance. 
    Thai

  • How to get the line in the template (smartform) with out using under score

    Hi,
         How to get the line in the template (smartform) with out using under score,
         and how to print the box (line the check box - small squre box (which is used ot mark the tick by the user in front of the item).
         Please provide the valueble answer as early as possible.
    Thanks,
    Ravi

    Hi Ravi,
    Line -
    Use a SMATSTYLE for this purpose.in the smartstyle create a paragraph or character with underline atribute.Then call the smartstyle in the text.
    Search SDN with Key <b>UNDERSCORE</b>.. will get few more posts on the same.
    For Checkbox - refer link
    Re: Quick Question on Smartforms
    Re: putting tick mark into check box in smartform
    Reward points if this Helps.
    Manish
    Message was edited by:
            Manish Kumar

  • How to get sum for each currency's in ALV Report

    Hi,
    A column has amounts with various currency's.
    May I know how to get sum quantity for each currency in ALV Report?
    Thanks in advance.

    Hi,
    Currency value column should have reference to currency code column.
    Regards,
    Wojciech

  • How to get the current logged in username from windows and put it into an AS var

    Hello,
    I was hopeing someone would know how to get the current logged in username from windows and put it into a var, so I can create a dynamic text box to display it.
    Thanks in advance
    Michael

    Just for everyone’s info, this is the script I have used to get the logged in windows username into flash ---- not and air app.
    In the html page that publishes with the .swf file under the <head> section:-
    <script language="JavaScript" type="text/javascript">
    function findUserName() {
         var wshell=new ActiveXObject ("wscript.shell");
         var username=wshell.ExpandEnvironmentStrings("%username%");
         return username;
    </script>
    The ActionScript:-
    import flash.external.ExternalInterface;
    var username:String = ExternalInterface.call ("findUserName");
    trace (username); // a quick test to see it in output

  • How to get transation(mm01 or va01 etc) in alv

    how to get transation(mm01 or va01 etc) in alv using hot spots

    hai,
    see in the function module, u will find something like
    CALLBACK_PROGRAM-USER-COMMNAD..
    USE THAT (UNCOMMENT) AND GIVE THAT VALUE AS
    'USER-COMMAND'(in upper case). AND AFTER THIS FUNCTION MODULE.. WRITE THE Sub routine as same name as above u have given..eg:
    Form USER-COMMAND.
    endform.
    in this form just write : call transaction 'VA01'.
    hope it will help for u
    Regards
    Ramakrishna S

  • How to change default media player setting in Mountain Lion

    I right click on the desired media player, then I click on "get info" and another pop up appears,
    but there is no "open with" selection!  See pic below:
    I open the application folder in the Finder window, I highlight the desired media player, I go to the top and
    click on File and in the drop down menu, the "open with" is grayed out.  Why?
    How do I change the default media player setting or better yet, where do I find what is the default player?  Help Please!

    CheeMiss8
    you need to find the file you are trying to have open with a specific application.
    for example, I'm going to use an MP4 file titled cat_adventure video.
    here it is in finder
    I right click (secondary click) it in finder, and then hold down the option key on my keyboard.
    the Open With dialogue should change to "Always Open With" and then you choose your application from the pull out menu when you hover that.
    You can make it so all MP4 or whichever file you are using (AVI, MKV, etc) to open with a specific app by right clicking the file choosing get info
    The difference here is I'm not selecting the application but a file with the extension of the video format I always want to be opened with a specific application
    once in the get info menu I can then select to have the video always open with a certain app.
    1.click the open with accordion menu arrow if it is pointing to the left. it should be pointing down.
    2.select the application you want to always be associated with that file format
    3.select Change All to have that file format always be opened with that Application.
    Where this isn't working for you is because you are doing this to the Application itself. you don't do it like that. You need to find the type of file you are trying to open with itunes and then go through these steps.
    selecting the application (itunes) instead of the file (mp4, avi, mkv, flv) will not allow you to set what the file format lets you use to play your video.
    having said that, itunes is very limited in what it can and can't play. Mainly .mov and mp4's (apples proprietary extensions)

  • How to get default color of a selected row in a JLIst

    I have a JList that I am changing the font color for based on a certian situation so I created my own MyCellRenderer to do this. However, when I select an item in the list the row is no longer highlighted. I used the isSelected method to determine if a row was selected and then change the background color of that row. However, I would like the color to be the default color that you get when you select a row in a default JList. I can't seem to figure out how to get that color. How do I obtain what that color is? I found an example where you can get the default color for the background of a button and use that color so I would guess it is something similar to that. My code is below so I hope someone can tell me how to get that color that I want.
    Thanks...Chris
    class MyCellRenderer extends JLabel implements ListCellRenderer {
         public MyCellRenderer() {
              setOpaque(true);
         public Component getListCellRendererComponent(
             JList list,
             Object value,
             int index,
             boolean isSelected,
             boolean cellHasFocus)
             int index1 = value.toString().indexOf("-");
               String errors = value.toString().substring(index1 + 1, index1 + 6).trim();
             int numErrors = Integer.parseInt(errors);
               if (numErrors > 0)
                      setForeground(Color.red);
                      setBackground(Color.white);          
             else
                  setBackground(Color.white);
                  setForeground(Color.black);
             if(isSelected)
                  //ColorUIResource col = (ColorUIResource)UIManager.getDefaults().get("JButton.background");
                  ColorUIResource col = (ColorUIResource)UIManager.getDefaults().get("Button.background");
                  setBackground(col);
             setText(value.toString());
             return this;
    }

    Swing related questions should be posted in the Swing forum.
    I would like the color to be the default color that you get when you select a row in a default JList. I can't seem to figure out how to get that colorlist.getSelectionBackground();

  • How to get default values on selection screen(multiple ranges)?

    i want to know how to maintain default ranges in selection screen...like 2000 to 3000 and 7000 to 8000 and 11000 to 15000
    all the above ranges must get by default how to provide those to selection screen by default...please give me idea...with example...

    Hi Suresh,
    You can either use select-options or Ranges. If you want the selection screen to be displayed with allwoing user to enter values apart for the default ones use select options else use ranges. With ranges what ever values use hard code would be set and the end user will not be able to add any more values (or range of values).
    Simply write the following code
    tables : <name of the table from which the field belongs>
    select-options <fieldname> for <tablename>-<fieldname>.
    <fieldname>-sign = 'I'.
    <fieldname>-option = 'BT'.
    <fieldname>-low = '7000'.
    <fieldname>-high = '8000'.
    append <fieldname>..
    similiarly add all the ranges that you need to include as default and in your select statement use the IN operator inthe where clause to include the range.
    If using range replacethe select-option with the range statement.
    Thanks.

  • How to get Default (System) Date Format Pattern?

    How to get system default date format which is defined in Regional Setting of Control Panel.
    We can get an instance of DateFromat using DateFormat.getDateInstance(DateFormat.SHORT) but problem is that there is no toPattern() exist in class DateFormat.
    However toPattern() exist in class SimpleDateFormat but there is no costructor like SimpleDateFormat(DateFormat)
    So please advise me, how can I get system short date format pattern?
    Thanks
    GAJESH TRIPATHI

    I reterieve the system date format but not which is currently defined in regional setting of control panel but it returns the format which is installed by default when windows(os) is installed.
    Edited by: gajesh on ? ????????, ???? ??:?? ?????????
    Thanks to provide me solution. My source code related problem is solved but still I am not getting format which is defined in control panel. but By Letting that it is not possible in Java,... I am doing my next work...so CLOSE THIS TOPIC Thanks'n Bye.

  • How to get only the record which is different by outer join

    Hi,
    how to get the values Existing in table A which are not existing in table B by using left outer join, In this example only the record '3' should display. thanks
    the requirementment is like
    Table A.Number Table B.Number
    1 1
    2 2
    3 4
    4 5
    output
    3

    SQL>  with a as (
    select 1 a from dual union all
    select 2 a from dual union all
    select 3 a from dual union all
    select 4 a from dual
    b as (
    select 1 a from dual union all
    select 2 a from dual union all
    select 4 a from dual union all
    select 5 a from dual
    select a.*
      from a left outer join b on (a.a = b.a)
    where b.a is null
             A
             3

  • How to get Default Activity(Infotype 0315) using BAPI

    Hi Everyone,
    I have a task to get Default Activity by Personal number for my third party application. Unfortunately function HR_READ_INFOTYPE is not allowed for Remote Call.
    Is there any simple way how to get this value from system using BAPI? E.e. using RFC_READ_TABLE function(but i don't know table name ).
    Thanks,
    Roman.

    Table -> PA0315        Field ->LSTAR (Activity Type)
    Class :CL_HRPT_INFOTYPE_0315
    You can also use FM "CATS_GET_INFOTYPE_0315" RFC Enable
    Good luck !
    ~Saquib

  • How to get the validity of the socket before writes out datas?

    I should keep the socket which created before and send/recieve datas several times,and the socket would be closed by other side after minites,
    the question is
    How can I get the validity of the socket before writes out datas?

    If I understand well yor concern...
    There is no way to know if a socket is still connected without using (i.e reading /writing on) it.
    That's the way it works on C API layer, so it should not be defferent in Java.
    For a good understanding of how TCP/IP works, if C code is OK for you, the best are Richard Stevens books.... (IMHO)

Maybe you are looking for

  • Problem with HR_MAINTAIN_MASTERDATA delimiting infotypes

    hi, I'm trying to delimit a register of the infotype 0017 using the FM HR_MAINTAIN_MASTERDATA because i had to execute a infogroup (like the PA40 transaction) this is the call:   CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'       EXPORTING         pernr   

  • Can't view PDF files in Mail

    After the 10.5 upgrade I can no longer view PDFs in Mail. Not sure if this is also due to the install of Adobe CS3, however now PDFs just show as a "mime-attachment" which do not display in any other app. Other 10.5.1 users can view these email attac

  • System preferences not saving

    Every time I log out, any system preferences I had set up are not saving. Such as what should boot up in the dock or what programs should be in the system bar or the settings for the keyboard and mouse. Thanks for any guidance on this issue.

  • Help Needed With A Java Installation

    Hello, I'm beyond being a novice with regards to Java. To be quite honest, I don't have the time right now to learn the language, nor do I have the need for anything other than what I am about to ask. I say this upfront to avoid unfriendly comments f

  • Trouble installing plugins for CS3 and CS4 onto a 32 bit/64 bit PC.

    I have two new PCs. They are supposed to run both 32 Bit and 64 Bit programs. I have CS3 and CS4 32 Bit programs installed on both. Many of my old faithful plugins have gone on strike or at least a work stoppage! I can get some of them to install cor