How can we sort records in alv, give example

how can we sort records in alv, give example

Hi
<b>Setting Sort Conditions</b>
It is possible to set sort conditions for the table data. This is achieved by filling an internal table of structure “LVC_T_SORT” which consists of the sort criteria. To have an initial sorting, pass it to the parameter “IT_SORT” of the method “set_table_for_first_display”.
FORM prepare_sort_table CHANGING pt_sort TYPE lvc_t_sort .
DATA ls_sort TYPE lvc_s_sort .
ls_sort-spos = '1' .
ls_sort-fieldname = 'CARRID' .
ls_sort-up = 'X' . "A to Z
ls_sort-down = space .
APPEND ls_sort TO pt_sort .
ls_sort-spos = '2' .
ls_sort-fieldname = 'SEATSOCC' .
ls_sort-up = space .
ls_sort-down = 'X' . "Z to A
APPEND ls_sort TO pt_sort .
ENDFORM. " prepare_sort_table
<b>Preparing the table for sorting settings</b>
We have two important points to tell about this topic. First one is that, be ready for a short dump if any one of the fields given to be sorted is not in the content of the field catalog. Secondly, when you make ALV Grid to sort data, by default it vertically merges fields having the same content. To avoid from this for all of the columns, you can set “no_merging” field of the layout structure to ‘X’. If you want to disable merging for just some columns, set “no_merging” field of the field catalog row corresponding to that column.
You can get and set sort criteria applied whenever you want by using methods “get_sort_criteria” and “set_sort_criteria”, respectively.
<b>
Sort Using FACTORY CLASSES</b>
<b>Sorts – CL_SALV_SORTS</b>
we can add some sorting to the ALV grid. Create the object reference variable and receive the object using the GET_SORTS method of the GR_TABLE object. Next, add the sort by calling the ADD_SORT method of the GR_SORTS object.
report zalvom_demo1.
data: ispfli type table of spfli.
data: gr_table type ref to cl_salv_table.
data: gr_functions type ref to cl_salv_functions.
data: gr_display type ref to cl_salv_display_settings. data: gr_columns type ref to cl_salv_columns_table.
data: gr_column type ref to cl_salv_column_table.
data: gr_sorts type ref to cl_salv_sorts.
data: color type lvc_s_colo.
start-of-selection.
select * into table ispfli from spfli. cl_salv_table=>factory( importing r_salv_table = gr_table   changing t_table = ispfli ).
gr_functions = gr_table->get_functions( ). gr_functions->set_all( abap_true ).
gr_display = gr_table->get_display_settings( ). gr_display->set_striped_pattern( cl_salv_display_settings=>true ). gr_display->set_list_header( 'This is the heading' ). gr_columns = gr_table->get_columns( ).
gr_column ?= gr_columns->get_column( 'CITYTO' ). gr_column->set_long_text( 'This is long text' ). gr_column->set_medium_text( 'This is med text' ). gr_column->set_short_text( 'This is sh' ).
gr_column ?= gr_columns->get_column( 'CITYFROM' ). color-col = '6'.
color-int = '1'.
color-inv = '0'.
gr_column->set_color( color ).
gr_sorts = gr_table->get_sorts( ).
gr_sorts->add_sort 'CITYTO' ).
gr_table->display( ).
Regards
Ravish
<b><i>
Reward if useful to you</i></b>
Message was edited by:
        Ravish Garg

Similar Messages

  • How we can select two records in alv report

    how we can select two records in alv report

    Hello,
    You can use the method <b>get_selected_rows</b>.
         CALL METHOD gv_alv->get_selected_rows
            IMPORTING
          ET_INDEX_ROWS =
            et_row_no     = lt_selected_rows.
    READ TABLE lt_selected_rows INTO ls_selected_row INDEX 1 .
    The table <b>lt_selected_rows</b> will contain all the selected rows.
    Regards,
    Beejal
    **reward if this helps

  • Pages:  How can I sort one column of words and not have it affect the other columns?

    How can I sort one column of words and not have it affect the other columns?  I have opened the inspector to the edit columns and rows under Table.  It will sort the column, but then it changes the other colums as well.  I know that if I use Numbers, it will work, but I want to know how to do the same thing in Pages.

    Hi Peter,
    Numbers sorts full rows on values in selected column(s). The technique for sorting a single column is essentially the same as Jerry is describing for Pages tables—separate the (data in the) column to be sorted, sort it, return it to the table.
    In Numbers the actual column may be separated from the original table, sorted, then returned. In Pages, the data must be extracted, sorted, then pasted back in, overwriting the unsorted data (if it was left in the original table).
    iWork tables follow a database model in which each row is a Record, and each column holds a Field within the records.
    As evidenced by the current question (and several similar questions arising in the Numbers community) that model doesn't apply to the way some users, especially some who come in from the MS Excel world, use tables.
    With Excels model—islands of data on a single large table, the ability to sort one or a selected few columns of data makes sense. One 'island' may comprise only cells AA21:AH50. Sorting that small 'table' should be possible without disturbing the rest of rows 21-30, which are probably part of one or more other 'data islands' in the sea that is a MS Excel spreadsheet.
    In Numbers, each of those 'islands' would be a separate Table, and that Table would be sortable without disturbing other Tables in the document.
    Regards,
    Barry

  • How can I sort photos within an event? When I follow the Help instructions, I can sort manually in Photo format, but when I return to Event format, the original order is restored.

    How can I sort photos within an event? When I follow the Help instructions, I can sort manually in Photo format, but when I return to Event format, the original order is restored.

    Events are organisation for those who can't really be bothered. They are automatic - based entirely on Date and Time the camera records the photos as taken.
    You can move photos between Events, you can Merge Events, you can Rename them and sort them in various ways except one: You cannot manually sort in an Event as Events are all automated.
    If you want to manually sort in an Event then you've outgrown Events as an organising tool. Now it's time to look at albums (Where you can manually sort) which are much more flexible than Events as an organising tool.

  • How can i sort the RowSet?

    I have the 2 (master and detail) entity objects, and corresponding 2 (master and detail) view objects.
    Then i've generated the entity object class for the master EO, this class has methods of getting/setting EO attributes, and method for getting a row iterator for the detail object:
    /**Gets the associated entity oracle.jbo.RowIterator */
    public RowIterator getDetailEO() {
    return (RowIterator)getAttributeInternal(DETAILEO);
    Also in that entity object class i've created a method which gets the rows of the detail table, that correspond to the master record, and perform different action on these detail rows:
    RowSet detailRowSet = (RowSet)getDetailEO();
    detailRowSet.executeQuery();
    The question is - How can i sort the rows in that detail RowSet, i.e. order them by their Id? I know that sort operations can be performed on the ViewObjects, but i can't get detail VO from this RowSet.
    Is there a method of sorting/ordering rows in the RowSet?

    You can actually have methods in the VO that access details from the master and vice versa - you define the generation of these methods in you ViewLink properties.
    http://download.oracle.com/docs/html/B25947_01/bcquerying010.htm#sthref327

  • How can i fetch records from 3 tables in a single query  without using join

    Hi.
    Can any body please tell me <b>How can i fetch records from 3 tables with a single query  without using joins</b>
    Thanx
    prabhudutta

    Hi Prabgudutta,
    We can fetch the data by using the views concept.
    Go throuth this info we can know the how to create view and same like database table only we can fetch the data.
    Views conatin the data at runtime only.
    Four different view types are supported. These differ in the
    way in which the view is implemented and in the methods
    permitted for accessing the view data.
    Database views are implemented with an equivalent view on
    the database.
    Projection views are used to hide fields of a table (only
    projection).
    Help views can be used as selection method in search helps.
    Maintenance views permit you to maintain the data
    distributed
    on several tables for one application object at one time.
    step by step creation of Maintenance view:
    With the help of the table maintenance generator, you are able to maintain the ENTRIES of the table in SM30 transaction.
    It can be set in transaction SE11 - Tools - Table maintenance generator.
    Table maintanance Generator is used to manually input values using transaction sm30
    follow below steps
    1) go to se11 check table maintanance check box under attributes tab
    2) utilities-table maintanance Generator-> create function group and assign it under
    function group input box. Also assign authorization group default &NC& .
    3) select standard recording routine radio in table table mainitainence generator to move table
    contents to quality and production by assigning it to request.
    4) select maintaience type as single step.
    5) maintainence screen as system generated numbers this dialog box appears when you click on create button
    6) save and activate table
    One step, two step in Table Maintenance Generator
    Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.
    Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.
    SM30 is used for table maintenance(addition or deletion of records),
    For all the tables in SE11 for which Table maintenance is selected , they can be maintained in SM30
    Sm30 is used to maintain the table ,i.e to delete ,insert or modify the field values and all..
    It creates the maintenance screen for u for the aprticular table as the maintenance is not allowed for the table..
    In the SE11 delivery and maintenance tab, keep the maintenance allowed..
    Then come to the SM30 and then enter the table name and press maintain..,
    Give the authorization group if necessary and give the function group and then select maintenance type as one step and give the screen numbers as system specified..
    Then create,,,
    Then u will able to see the maintenance view for the table in which u can able to insert and delete the table values...
    We use SM30 transaction for entering values into any DB table.
    First we create a table in SE11 and create the table maintenance generator for that Table using (utilities-> table maintenance generator) and create it.
    Then it will create a View.
    After that from SM30, enter the table name and Maintain, create new entries, change the existing entries for that table.
    Hope this resolves your query.
    Reward all the helpful answers.
    Rgds,
    P.Naganjana Reddy

  • My mac mini wont shut down when i try it does restard instead and said it has recovery from a problem. How can i sort this out?

    I've installed the new ios on my mac mini and ever since i can not shut down my computer, it does now restard itshelf and give me a messages saing that it has shut down because of a problem.
    Why is that?
    How can I sort this out?
    Thanks guys!

    Welcome to Apple Communities
    http://www.reedcorner.net/understanding-upgrade-nightmares/ Do a PRAM and SMC reset and see if it appears

  • How can i use "GT_SORT"  in alv  ?

    hello  ,
    i need to sort alv report by some fields  .
    i use   :
    GT_SORT-FIELDNAME = 'FRGGR'.
    GT_SORT-TABNAME = 'G_TABNAME_ITEM'.
    GT_SORT-SPOS = 1.
    GT_SORT-UP = 'X'.
    GT_SORT-SUBTOT = 'X'.
    GT_SORT-GROUP = '*'.
    APPEND GT_SORT.
    the alv is "REUSE_ALV_HIERSEQ_LIST_DISPLAY"
    but i don't see the change  , what i doing wronge ?

    Hi dakota,
    what are the results of the forum search you di before posting the question?
    Regards,
    Clemens
    Expert Forums
    Forum Search
    Use the form below to search the forum content. You can choose to search all content or restrict it to certain forums or dates. Also, you can filter the results by a username or user ID.
    Search Forum Content
    Search Terms:        Search Tips
    Category or Forum:      
    Date Range:      
    Results Per Page:      
    Welcome, Clemens Li      Help
    Your Control Panel      Your Control Panel
    Your Reward Points      Your Reward Points
    Your Questions      Your Questions
    Search Results » Messages: 339 - Search Terms: GT_SORT      Sort by:
    Pages: 23 1 2 3 4 5 6 7 8 9 10
       1. Re: how can i use "GT_SORT" in alv ?
          Posted on: Jul 15, 2007 3:50 PM, by user: Kiran Sure(skk) -- Relevance: 100% -- Show all results within this thread
          Hi, GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE, GT_SORT-FIELDNAME = 'UOM'. GT_SORT-TABNAME = '1'. GT_SORT-SPOS = 1. GT_SORT-UP = 'X'. GT_SORT-SUBTOT = 'X'.
    Reward points ...   2. Re: "Totals" option in Hierarchical List
          Posted on: Feb 7, 2006 8:40 PM, by user: John Jakabcsin -- Relevance: 17% -- Show all results within this thread
          Vicky, The SORT table is the device that allows the ALV tree to paint in it's hierarchial fashion. Your source might look like this: FORM set_sorting TABLES gt_sort STRUCTURE lvc_s_sort. g ...
       3. Re: Regarding ALV Report
          Posted on: Mar 14, 2007 7:36 AM, by user: Azeem Mohammed -- Relevance: 15% -- Show all results within this thread
          GT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE, GT_SORT-FIELDNAME = 'UOM'. GT_SORT-TABNAME = '1'. GT_SORT-SPOS = 1. GT_SORT-UP = 'X'. GT_SORT-SUBTOT = 'X'. Then in FCAT use parameter do ...
       4. Re: ALV display
          Posted on: Aug 31, 2006 1:33 AM, by user: Kishore Maddu -- Relevance: 10% -- Show all results within this thread
          in your example you can see passing sorting table GT_SORT to reuse_....grid function module... just copy that program to one z program and commet and gt_sort parameter and then check... please ...
       5. Re: How to remove horizontal lines in ALV_LIST
          Posted on: Feb 15, 2006 12:48 PM, by user: Hymavathi Oruganti -- Relevance: 10% -- Show all results within this thread
          just check whether in gt_sort if u have mentioned gs_sort-group = 'UL'
       6. Re: Problem Saving ALV Report
          Posted on: Feb 7, 2007 4:12 PM, by user: Clemens Li -- Relevance: 10% -- Show all results within this thread
          Hi Anwarul, parameter it_sort = gt_sort[] will overrirde the sort in the variant. Regards, Clemens ...
       7. Re: Subtotals in ALV
          Posted on: Dec 13, 2006 6:15 PM, by user: krk -- Relevance: 10% -- Show all results within this thread
          Hi You have gs-sort and gt_sort. Make sure which one you are passing and declare the type as for that FM LIST_Display. ...
       8. Re: ALG Grid Same values not grouped!
          Posted on: Mar 17, 2006 11:23 AM, by user: Kumar Prashanth -- Relevance: 9% -- Show all results within this thread
          set_table_for_first_display EXPORTING i_save = gv_save is_layout = gv_layout is_print = gv_print is_variant = gv_variant CH ...
       9. Re: Total amount in ALV report
          Posted on: Dec 12, 2005 9:41 PM, by user: Phani Kiran Nudurupati -- Relevance: 9% -- Show all results within this thread
          Hi Naren, Pass it this way in the structure. DATA: GT_SORT TYPE SLIS_T_SORTINFO_ALV, DATA: GS_SORT TYPE SLIS_SORTINFO_ALV. CLEAR GS_SORT. GS_SORT-FIELDNAME = 'EBELN'. "This should be the fie ...
      10. Re: ALV Subtotal
          Posted on: May 2, 2007 11:29 PM, by user: Alchemi -- Relevance: 8% -- Show all results within this thread
          I have this in one include program GT_SORT_OFFSET TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE, can i email u the code? ...
      11. Re: ALV Tree Problem
          Posted on: Mar 20, 2007 6:49 PM, by user: Christian CHOULET -- Relevance: 8% -- Show all results within this thread
          Hello aRs, Yes i'm sure KOSTL is available in WT_TEST. The problem is that when i another element in GT_SORT, this error appears... Thanks anyway ...
      12. Re: subtotal calculation in ALV
          Posted on: Nov 14, 2006 5:35 PM, by user: Narendran Muthukumaran -- Relevance: 8% -- Show all results within this thread
          Hi, 1) Create a sort internal table for you to do sub totaling based on the field change..In this example..I have created a sort internal table and it will sum for every change in the field VBELN. ...
      13. Re: ALV grid sort
          Posted on: Oct 4, 2006 1:22 PM, by user: sreejesh purapadiath -- Relevance: 7% -- Show all results within this thread
          set_table_for_first_display EXPORTING is_layout = gs_layout it_toolbar_excluding = gt_excl_func[] CHANGING it_outtab = i_final[] ...
      14. Re: ALV Print about subtotal
          Posted on: Dec 17, 2005 11:35 AM, by user: max bianchi -- Relevance: 7% -- Show all results within this thread
          Hi In the sort table you has to define the field for sorting and subtotal: DATA: LT_SORT TYPE LVC_S_SORT, GT_SORT TYPE LVC_T_SORT. LT_SORT-SPOS = 1. LT_SORT-FIELDNAME = . LT_SORT-UP ...
      15. Re: Subtotals text in ALV
          Posted on: Feb 14, 2006 11:53 AM, by user: Wenceslaus G -- Relevance: 7% -- Show all results within this thread
          To display subtotal text you have to create sort interface GT_SORT TYPE SLIS_T_SORTINFO_ALV, and GS_SORT-FIELDNAME = 'FIELD1'. GS_SORT-SPOS = 1. GS_SORT-UP = 'X'. GS_S ...
    Pages: 23 1 2 3 4 5 6 7 8 9 10

  • How can I sort lines of data (alphabetically) in the new pages 5.0?

    How can I sort lines of data (alphabetically) in the new pages 5.0?
    It was very simple to do in the previou version of pages.

    I'm not sure why people are torturing themselves with Pages 5 given the nearly universal outcry on this forum and the incredibly negative reviews elswhere, such as the App Store.
    Pages 4.3 should still be in an iWorks folder within your Applications folder.  Just use that.
    Please remember to tell Apple what we need from them at:
    http://www.apple.com/feedback/pages.html

  • How can i suppress columns in ALV ?? Will reward points.

    Hello Gurus, how can i suppress column in ALV when i`m using the transparent table:
    CALL METHOD grid->set_table_for_first_display
          EXPORTING
            i_structure_name = 'ZIANEXE'
            is_layout        = wa_layout
            is_variant       = wa_variant
            i_save           = 'U'
            IT_TOOLBAR_EXCLUDING = LT_EXCLUDE
          CHANGING
            it_outtab        = itab[]
            it_fieldcatalog  = fieldcat.
    Please help.

    in the fieldcatalog you are providing there is a field NO_OUT use this.
    Loop over internal table and check fieldname. If fieldname = column you want to hide, NO_OUT = 'X'.
    Edited by: Micky Oestreich on May 8, 2008 12:06 PM

  • How can I sort files in a folder by name?

    How can I sort files in a folder by name? iFS first sort files that starts with upper-case letter and then files with lower-case letter.
    Like:
    A_file
    B_file
    a_file
    b_file
    I want:
    A-file
    a_file
    B_file
    b_file
    This doesn't help:
    String[] sort_attributes = {"NAME"};
    boolean [] sort_orders = {true};
    SortSpecification sort = new SortSpecification(sort_attributes, sort_orders);
    currentFolder.setSortSpecification(sort);
    Do I have to get all items in a folder and then sort them?
    /Elin

    I do not think there is a way to do that without add-ons
    There are a couple of workarounds I am aware of
    * Add the bookmarks manually in the bookmarks library and choose the position. That is using Show all bookmarks -> open required folder -> select a position and right click -> add new bookmark <br />Rather a slow and clumsy process
    * Sort a folder and copy it. If you sort the folder contents then copy and paste them they remain in that order when pasted.
    There are add-ons but I have not tried them. For example
    * https://addons.mozilla.org/firefox/addon/simplesort-bookmarks/
    * https://addons.mozilla.org/firefox/addon/auto-sort-bookmarks/
    There will be others available and take note of the advice to backup bookmarks manaully.
    * [[Restore bookmarks from backup or move them to another computer#w_manual-backup]]_manual-backup

  • How can I sort albums in a genre by release date in the itunes store

    How can I sort albums in a genre by release date in the itunes store

    Did you figure this out? Am having the same problem.
    EDIT:
    Found the group in store (in this case Juana Molina) It said music -> alternative
    Changed to column view, and could not find the artist at all in any of the sub categories.
    iTunes is really the biggest pain in the .... and has gotten worse over the years.

  • HT1267 The Apple ID in my new IPhone is not the same as my ID . how can i sort this

    Hi, The Users ID on My New IPhone Is not the same as my apple ID
    How can I sort this ...

    Got it!!!!  A re-install is NOT the answer.  You need to turn on individual notifications under Settings > Facebook > Push Notifications, BUT (and this is a big and confusing BUT) you also need to turn on global push settings under Settings > Mail, Contacts, Calendards > Fetch New Data (and change the Push slider to 'on').  This doesn't sound like it makes sense, but I guess that the push slider under 'Mail, Contacts, Calendars' is actually for ALL push notifications on iPhone, and not just Mail, Contacts and Calendar apps!

  • Photos for iOS: How can i sort all of my albums automatically in alphabetical order

    Hey there,
    first off, why isn't there a a community for the new Photos app?
    Anyway, here is my problem:
    How can i sort my albums on the new Photos app on iOS?
    I think it's not possible at the moment.
    I am using the iCloud Photo library and uploadet all of my 15.000 photos from the last 15 years.
    And because of that, i now have many many albums on Photos now.
    Overall i love the new app and i love the iCloud Photo library, but i cannot sort my albums on the iOS app automatically in alphabetical order.
    I can sort albums manual, but who wants that, when you have so many of them???
    I have Photos on my Mac too and there i am able to do sort them in alphabetical order. But it is not adopted to iOS or the iCloud Web-App.
    Because of that, i have a complete picture chaos on my iPhone and when i am looking for this one pic in that one album it takes me forever to find it.
    So please Apple, fix this and we all can live happily ever after!
    Thank you!

    Moments in Photo are the new Events.  T
    here's a way to simulate events in Photos.
    When the library was first migrated there was a folder created titled iPhoto Events and all migrated iPhoto Events are represented by an album in the folder. To open the sidebar if it's not open use the Option+Command+S key combination.
    When new photos are imported into the Photos library go to the Last Import smart album, select all the photos and use the File ➙ New Album menu option or use the key combination Command+N.  Name it as desired.  It will appear just above the iPhoto Events folder where you can drag it into the iPhoto Events folder
    When you click on the iPhoto Events folder you'll get a simulated iPhoto Events window showing all of the albums.
    The downside to this simulation is that the Album/Events can only be sorted automatically by Title while viewed in the Folder in the main window or in the sidebar. But they can be sorted manually.
    Ask Apple for more sorting options in Photos via https://www.apple.com/feedback/photos.html.

  • How can I sort movies by genre on itunes  from ipad 2 ?

    If i find a movie for buy in itunes ( from pc ) i can select the genre (action , comedy ..) for optimize the search. In mi ipad 2 i cannot do this  , i can select genre for music , apps , etc but in movies i only see alphabetical order and older / news movies .
    How can I sort movies by genre on itunes  from ipad 2 ?¿
    Thans very much ¡

    I'm looking for an answer to this same question.  I can sort (group) by Genre on iTunes and Apple TV - but not by brand new iPad 2...? 

Maybe you are looking for