Sort in ALV like On Change Of

Hi All,
In ALV o/p that im getting........
    Doc. No.         Doc.Date.         Material
    ABC               10.3.07            xyz
    ABD               10.3.07            anh
    ABD               10.3.07            sdf
    ABD               10.3.07            lkd
    ABE               11.3.07            hkg
O/p Required
    Doc. No.         Doc.Date.         Material
    ABC               10.3.07            xyz
    ABD               10.3.07            anh
                                                 sdf
                                                 lkd
    ABE               11.3.07            hkg
Imp Date Should be sorted only on change of Doc. No.
How to do that?
Thanks in Advance
Aniket

Here is sample code....
TYPE-POOLS: slis.
DATA: BEGIN OF it_output OCCURS 0,
          var1(8) TYPE n,
          var2(10),
          var3 TYPE I,
      END OF it_output.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
       t_fieldcat TYPE slis_fieldcat_alv,
      it_sort TYPE slis_t_sortinfo_alv,
      t_sort TYPE slis_sortinfo_alv,
      v_repid LIKE sy-repid.
INITIALIZATION.
  v_repid = sy-repid.
START-OF-SELECTION.
  PERFORM get_data.
  PERFORM sort_fields.
  PERFORM fill_fieldcat.
  PERFORM list_display.
*&      Form  GET_DATA
      text
-->  p1        text
<--  p2        text
FORM get_data.
  it_output-var1 = 1000.
  it_output-var2 = 'anupama'.
  it_output-var3 = '10000'.
  APPEND it_output.
  CLEAR it_output.
  it_output-var1 = 1000.
  it_output-var2 = 'siddhu'.
  it_output-var3 = '20000'.
  APPEND it_output.
  CLEAR it_output.
  it_output-var1 = 1000.
  it_output-var2 = 'chinni'.
  it_output-var3 = '100000'.
  APPEND it_output.
  CLEAR it_output.
  it_output-var1 = 2000.
  it_output-var2 = 'chicchu'.
  it_output-var3 = '10000'.
  APPEND it_output.
  CLEAR it_output.
  it_output-var1 = 2000.
  it_output-var2 = 'candy'.
  it_output-var3 = '10000'.
  APPEND it_output.
  CLEAR it_output.
  it_output-var1 = 1000.
  it_output-var2 = 'anupama'.
  it_output-var3 = '10000'.
  APPEND it_output.
  CLEAR it_output.
  it_output-var1 = 4000.
  it_output-var2 = 'anupama'.
  it_output-var3 = '10000'.
  APPEND it_output.
  CLEAR it_output.
ENDFORM.                    " GET_DATA
*&      Form  fill_fieldcat
      text
-->  p1        text
<--  p2        text
FORM fill_fieldcat.
  PERFORM fill_fields USING: 'IT_OUTPUT' 'VAR1' 'Variable 1' ' ',
                             'IT_OUTPUT' 'VAR2' 'Variable 2' ' ',
                             'IT_OUTPUT' 'VAR3' 'Variable 3' 'X'.
ENDFORM.                    " fill_fieldcat
*&      Form  fill_fields
      text
     -->P_0146   text
     -->P_0147   text
     -->P_0148   text
     -->P_0149   text
FORM fill_fields USING    value(tabname) TYPE slis_tabname
                          value(fieldname) TYPE slis_fieldname
                          value(seltext_m) LIKE dd03p-scrtext_m
                          value(do_sum) TYPE c.
  t_fieldcat-tabname = tabname.
  t_fieldcat-fieldname = fieldname.
  t_fieldcat-seltext_m  = seltext_m.
  IF do_sum = 'X'.
    t_fieldcat-datatype = 'CURR'.
  ENDIF.
  t_fieldcat-do_sum = do_sum.
  APPEND t_fieldcat TO it_fieldcat.
  CLEAR t_fieldcat.
ENDFORM.                    " fill_fields
*&      Form  list_display
      text
-->  p1        text
<--  p2        text
FORM list_display.
  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
   EXPORTING
     i_callback_program             = v_repid
     it_fieldcat                    = it_fieldcat
     it_sort                        = it_sort[]
   TABLES
      t_outtab                       = it_output
   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.                    " list_display
*&      Form  sort_fields
      text
-->  p1        text
<--  p2        text
FORM sort_fields.
  t_sort-fieldname = 'VAR1'.
  t_sort-tabname = 'IT_OUTPUT'.
  t_sort-spos = 1.
  t_sort-up = 'X'.
  t_sort-subtot = 'X'.
  APPEND t_sort TO it_sort.
  CLEAR t_sort.
  t_sort-fieldname = 'VAR3'.
  t_sort-tabname = 'IT_OUTPUT'.
  t_sort-spos = 2.
  t_sort-up = 'X'.
  APPEND t_sort TO it_sort.
  CLEAR t_sort.

Similar Messages

  • Like ot change the View of F110 (Payment proposal)

    Hi
    The veiw of the payment proposal using Tcode F110 is stamdatd as attached. and i would like to change this like as  ALV Grid ..Please suggest how can i change the same.

    Hello,
    In O7FB you can define the fields that can be used to sort the payment proposal payment.
    You can define a default layout to be used in the Display/Edit Payment Proposal, and then in F110 specify the sort sequence once thelist is displayed.
    FAKP > Periodic Processing > Payment autom.pmnts > Line Layout
    FAKP > Periodic Processing > Payment autom.pmnts > Default values >
    and for transaction FBZ0 select the defined Layout
    From release 5.0 the payment proposal processing was changed to the ALV. With this tool the line structure is determined - as in all ALV lists -within the application. During the use of the ALV the "old" Customizing settings are obsolete. Hence in your case with ALV option, the Proposal -> edit -> Settings -> Line Layout is greyed out. The note number 617492 is useful to understand this new funcionality.
    As an alternative also I would suggest you to use proposal list , program RFZALI20.
    I hope this helps.
    Oscar

  • ALV: Issue with double  click event after sorting the ALV

    Hello Experts,
    I have an internal table that populates an ALV grid. When the user doubleclicks a row, my method HANDLE_DOUBLE_CLICK returns the e_row-index value from the ALV Grid. I use this index value to read the internal table, then retrieve additional data.
    My problem is the user may sort the ALV grid before double clicking on a line. If this happens my internal table is not sorted to match the ALV grid, so reading the internal table with the e_row-index value returns the wrong information.
    When the double click event occurs, is it possible to capture the value in column 1 instead of a value for e_row-index?
    There is one more paramter in HANDLE_DOUBLE_CLICK for row id.   It is coming blank in debugging .  what is the purpose of this parameter and how i can make use of it ?
    Regards
    Vivek

    Hi,
    I am Posting The Code Which Uses Double Click Event.
    And This Code will provide the total information to you.
    REPORT  ZALVGRID_PG.
    TABLES: SSCRFIELDS.
    DATA: V_BELNR TYPE RBKP-BELNR.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: IRNO FOR V_BELNR.
    PARAMETERS: P_GJAHR TYPE RBKP-GJAHR.
    SELECTION-SCREEN END OF BLOCK B1.
    DATA: WA TYPE ZALVGRID_DISPLAY,
          ITAB TYPE STANDARD TABLE OF ZALVGRID_DISPLAY.
    DATA: IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATA: GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: L_IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATA: L_TREE TYPE REF TO CL_GUI_ALV_TREE_SIMPLE.
    TYPE-POOLS: SLIS,SDYDO.
    DATA: L_LOGO TYPE SDYDO_VALUE,
          L_LIST TYPE SLIS_T_LISTHEADER.
    END-OF-SELECTION.
    CLASS CL_LC DEFINITION.
      PUBLIC SECTION.
        METHODS: DC FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN.
    ENDCLASS.
    CLASS CL_LC IMPLEMENTATION.
      METHOD DC.
        DATA: WA1 TYPE ZALVGRID_DISPLAY.
        READ TABLE ITAB INTO WA1 INDEX E_ROW-INDEX.
        BREAK-POINT.
        SET PARAMETER ID 'BLN' FIELD WA1-BELNR.
        CALL TRANSACTION 'FB02'.
      ENDMETHOD.                    "DC
    ENDCLASS.
    DATA: OBJ_CL TYPE REF TO CL_LC.
    START-OF-SELECTION.
      PERFORM SELECT_DATA.
      IF SY-SUBRC = 0.
        CALL SCREEN 100.
      ELSE.
        MESSAGE E000(0) WITH 'DATA NOT FOUND'.
      ENDIF.
      INCLUDE ZALVGRID_PG_STATUS_0100O01.
      INCLUDE ZALVGRID_PG_LOGOSUBF01.
      INCLUDE ZALVGRID_PG_SELECT_DATAF01.
    INCLUDE ZALVGRID_PG_USER_COMMAND_01I01.
    ***INCLUDE ZALVGRID_PG_STATUS_0100O01 .
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'AB'.
    *  SET TITLEBAR 'xxx'.
      IF IDENTITY IS INITIAL.
        CREATE OBJECT IDENTITY
        EXPORTING
          CONTAINER_NAME = 'ALVCONTROL'.
        CREATE OBJECT GRID
        EXPORTING
          I_PARENT = IDENTITY.
        CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
             I_STRUCTURE_NAME              = 'ZALVGRID_DISPLAY'
          CHANGING
            IT_OUTTAB                     = ITAB.
        CREATE OBJECT OBJ_CL.
        SET HANDLER OBJ_CL->DC FOR GRID.
        ENDIF.
        IF L_IDENTITY IS INITIAL.
          CREATE OBJECT L_IDENTITY
          EXPORTING
            CONTAINER_NAME = 'LOGO'.
          CREATE OBJECT L_TREE
          EXPORTING
            I_PARENT = L_IDENTITY.
          PERFORM LOGOSUB USING L_LOGO.
          CALL METHOD L_TREE->CREATE_REPORT_HEADER
            EXPORTING
              IT_LIST_COMMENTARY    = L_LIST
              I_LOGO                = L_LOGO.
          ENDIF    .
    ENDMODULE.                 " STATUS_0100  OUTPUT
    ***INCLUDE ZALVGRID_PG_LOGOSUBF01 .
    FORM LOGOSUB  USING    P_L_LOGO.
      P_L_LOGO = 'ERPLOGO'.
    ENDFORM.                    " LOGOSUB
    ***INCLUDE ZALVGRID_PG_SELECT_DATAF01 .
    FORM SELECT_DATA .
      SELECT RBKP~BELNR
             RBKP~BLDAT
             RSEG~BUZEI
             RSEG~MATNR
             INTO TABLE ITAB
             FROM RBKP INNER JOIN RSEG
        ON RBKP~BELNR = RSEG~BELNR
        WHERE RBKP~BELNR IN IRNO
        AND RBKP~GJAHR = P_GJAHR.
    ENDFORM.                    " SELECT_DATA
    ***INCLUDE ZALVGRID_PG_USER_COMMAND_01I01 .
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
           EXIT.
           ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    Warm Regards,
    PavanKumar.G
    Edited by: pavankumar.g on Jan 19, 2012 5:30 AM

  • How to sort the alv

    what is the process to sort in alvs report  the output is in  decending and accending order without using standard buttenens in the output list .
             i am asking how to sort bydefault when we are executing the report ,
             output list  will automatically in sort order.
    could u plz explalin clearly with comments
    and code

    Hi
    Add this to your alv reporting
    Add Default Sorting to ALVgrid report  
    In order to display an ALV report with specific columns already sorted by default you will need to build a
    sort catalogue. This is fairly straight forward and is done in the following way:
            Step 1. Add data declaration for sort catalogue
            Step 2. Add code to build sort catalogue table 
            Step 3. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include parameter 'it_sort'
    ALV data declarations
      data: it_sortcat   type slis_sortinfo_alv occurs 1,
            wa_sort like line of it_sortcat.
    perform build_sortcat.
    *&      Form  build_sortcat
          Build Sort catalog
    FORM build_sortcat .
      wa_sort-spos      = 1.
      wa_sort-fieldname = 'EBELN'.
    gd_sortcat-tabname
      APPEND wa_sort TO it_sortcat.
      wa_sort-spos      = 2.
      wa_sort-fieldname = 'EBELP'.
    gd_sortcat-tabname
      APPEND wa_sort TO it_sortcat.
    ENDFORM.                    " build_sortcat
    call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE' 
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
                it_sort                 = it_sortcat
                i_save                  = 'X'
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
    Thanks
    Shiva

  • Dynamic sort in ALV

    hi all,
    HOw can we write the dynamic sort in ALV.
    regards,
    AJ

    Hi,
    Please find the sample code for dynamic sort in OO ALV
      perform built_sort_table.
    form built_sort_table.
      data ls_sort_wa type lvc_s_sort.
      ls_sort_wa-spos = 1.
      ls_sort_wa-fieldname = 'MATNR'.    "<< here your pass fieldname to sort dynamically
      ls_sort_wa-up = selected.
      ls_sort_wa-subtot = ''.
      append ls_sort_wa to gt_sort.
      ls_sort_wa-spos = 2.
      ls_sort_wa-fieldname = 'STATUS'.  "<< here your pass fieldname to sort dynamically
      ls_sort_wa-up = selected.
      ls_sort_wa-subtot = ''.
      append ls_sort_wa to gt_sort.
    endform.                               " BUILT_SORT_TABLE
        call method grid1->set_table_for_first_display
          exporting
            is_layout                     = gs_layout
            is_variant                    = gs_variant
            i_save                        = 'A'
            it_toolbar_excluding          = i_exclude[]
          changing
            it_outtab                     = i_output[]
            it_fieldcatalog               = i_fieldcat[]
            it_sort                       = gt_sort[]
          exceptions
            invalid_parameter_combination = 1
            program_error                 = 2
            too_many_lines                = 3
            others                        = 4.
    aRs

  • I would like to change the display way of address book.

    Hello~
    I purchased Blackberry Q10 and have a question.
    I would like to change the display way of address book.
    Now BB Q10's address book show contact's name by "First Name -> Last Name" (Tarou<First Name> Yamada<Last Name>
    But I prefer "Last Name->First Name" ( Yamada Tarou)
    Because My native language is Japanese...
    When I using Black Berry Bold 9900, I could change this setting by below way...
    Options -> Typing and Language -> Language -> Global Name Display (Change to "Last,First")
    But I can't find this option in my Black Berry Q10.
    Could you let me know how to change this setting?

    Hello yshr_825 and welcome to the BlackBerry Support Community Forums.
    Thanks for your question on sorting contacts by name.
    Launch Contacts and swipe down from the top of the Bezel and select Settings. In the tab Sort Contacts By tap on it and select Last Name.
    This should now update your contact list to sort them by surname.
    Let us know if this helps.
    -HMthePirate
    Come follow your BlackBerry Technical Team on twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.Click Solution? for posts that have solved your issue(s)!

  • When I try to sync my photos on iphone using itunes, some events are incomplete on my iphone and they are all randomly placed instead of being sorted by date like on my iphoto. Help?

    Using the latest Iphoto and Iphone5 software. I try to sync all my photos on my iphone and for some reasons, when they appear on my iphone, some events (when i go to events from mac) are incomplete (photos missing in some events) and randomly presented as opposed to being sorted by date like they are on my iphoto on my mac. This also happens on trying to sync my ipad... Solution anyone?

    Hey there vtec99,
    It sounds like you are syncing photos from iPhoto on your computer but not all the photos you set to sync are actually coming over, and they are disorganized. Based on what you are describing, I would recommend deleting the iPod Photo cache which stores picture information that iTunes uses to sync photos from your iPhoto library. The following article will help you do that:
    iTunes: Understanding the iPod Photo Cache folder
    When you use iTunes to sync photos to your iPhone, iPad, or iPod, iTunes creates a folder called iPod Photo Cache. The iPod Photo Cache stores photos that are optimized for display on your device. The location of this folder depends on the syncing options you select. In iTunes, if you change the selection in the Sync Photos From menu, a new iPod Photo Cache folder will be created (and the previous folder will remain).
    Thank you for using Apple Support Communities.
    Take care,
    Sterling

  • Hi Apple Team, I would like to change the iCloud account on my iPhone, however it says I must 'delete the account' before doing so? Does this mean that I delete the entire existing account, or just delete it from my phone specifically?

    Hi Apple Team, I would like to change the iCloud account on my iPhone, however it says I must 'delete the account' before doing so? Does this mean that I delete the entire existing account, or just delete it from my phone specifically?

    From the iPhone only.

  • Is there any functionality for AVERAGE in ALV, like do_sum, subtot?

    Hi Experts,
    In my_alv report, am doing sub/totals for prices, by using do_sum, subtot functions.........fine. But, I need to do/display the AVERAGE value for Discount % column?
    Is there any functionality for AVERAGE in ALV, like do_sum, subtot?
    thanq

    hi
    check these links out
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    regards
    vijay
    reward points if helpful

  • I would like to change my apple id to one of my alternate email addresses so therefore i would have to delete the alternate email address as an alternate email address and it says that if i do that it will permanently be deleted from my account

    I would like to change my apple id to one of my alternate email addresses so therefore i would have to delete the alternate email address as an alternate email address and it says that if i do that it will permanently be deleted from my account so could i use that email address as my primary one?

    The following article may help you:
         http://www.ehow.com/how_8362857_rename-mailbox-apple-mail.html

  • Would Like to Change "appleuser" to my name but don't know how. Help?

    Hi,
    For starters, I have a late 2009 Macbook (white) and am running Mountain Lion (10.8.2). Anyway, I purchased this computer off of someone else and I would like to change what I assume is the home directory (little house logo) from "appleuser" to my name. Unfortunately, I can't seem to find anything online that is helpful to me. I saw one thing that talked about changing the root login or something like that, but I couldn't even find it when following the steps that were given.
    Anyway, like I said I bought the computer off of someone else and seeing the "appleuser" drives me insane so I'd like to change it. Anybody know how?

    Open the Users & Groups pane of System Preferences, create a new user account, and log in with it; alternatively, after unlocking the pane, control-click that account, choose Advanced Options, and change it there.
    (75190)

  • I would like to change my apple ID because i Dont use the email address that is currently attached to my Itunes How do i go about this

    I would like to change my apple id to a different email because the one i am currently using I dont use as my email address anymore but we I tried to change it in manage apple ID it said I already have that email address as one of my accounts but I never created and apple ID with that email address. how do I go about this

    The following article may help you:
         http://www.ehow.com/how_8362857_rename-mailbox-apple-mail.html

  • I would like to change the colour of bars in a chart without losing the underlying default texture associated with my chosen theme. None of the 3D textured fills offered in "Chart Colors" match the textured fill of the theme. Any suggestions?

    I would like to change the colour of bars in a chart without losing the underlying default texture associated with my chosen theme. None of the 3D textured fills offered in "Chart Colors" match the textured fill of the theme. Any suggestions?

    Thanks Gary, but no, that does not work. First of all, I can't select each bar individually. When I click on one bar, all three bars are selected.
    When I use "inspector > graphic" I have 5 fill options: none, color, gradient, image, tinted image. The default selection for the theme I'm using is image. What I would like to use for my charts is the same image that this theme uses for table headers. It has the same texture as the chart, but a different colour. Using anything but image or tinted image removes the texture from the fill.
    I have found I can do one of two things. I can select tinted image from the fill selections in "inspector > graphic" or I can select 2D Image Fills from "inspector > chart > chart colors". The first choice does not allow me to match the table header colour because it only allows me to apply a tint to the existing colour and adjust its opacity. The existing colour has too much influence on the fill, so I can't find an RGB adjustment that will match the table header colour. The image selections from "inspector > chart > chart colors" do not quite match the colour or the texture. Again, I can try to tint the image, but I still can't get it to match and the texture is not the same anyway.
    The image I want to use obviously exists in the software as it is an attribute of the theme, but for some reason is inaccessible. The other angle I have tried is to edit the theme, but I can't figure out how to do that either.

  • HT1918 I would like to change the data of my credit card. For the next year I live in Germany, I have a geman visa card, but I want the itunes and everything to be in english language. How can I do this?

    I would like to change the data of my credit card. For the next year I live in Germany, I have a german visa card, but I want the itunes and everything to be in english language. How can I do this?

    You cannot.

  • I currently have a DROID RAZR M and I'm 1 year into my 2 year contract.  Since the Kitkat update, the phone won't stay charged and it's very buggy.  I know this is not Verizons fault but it's also not mine. I would like to change my phone to an iPhone 5s

    I currently have a DROID RAZR M and I'm 1 year into my 2 year contract.  Since the Kitkat update, the phone won't stay charged and it's very buggy.  I know this is not Verizons fault but it's also not mine. I would like to change my phone to an iPhone 5s and keep my same plan but switch to the Edge program. Is this possible? I don't think I should have to pay an early termination fee or anything like that since my phone has become almost unusable. I know under normal circumstances you have to wait 2 yrs to upgrade but due to the update and the poor service I'm now getting I hope Verizon can make an exception. Thank you.

    How recently did you switch?  If it's less than 60 days, then Verizon simply reinstates your previous account.  The fact that you were on the EDGE plan and mailed the devices back, and they apparently are somewhere in the system, could cause complications, and it might just work out that you just go back on the same plan and they set you up with the same devices.  I'm not sure how it will go - but since you are still being billed for the devices... 

Maybe you are looking for