Dynamic sort ascending / descending

Hi all,
I am trying to sort an internal table dynamically.
In this table I have a number of field to use for an ascending sort and other used to sort descending.
I have writen the code to create two fields (character field) in which I concatenate the sort field names.
The result is :
sort_field_up = ' field1 field2 field 3'
sort_field_dn = ' field4 field5 field 6'
and then i coded :
sort itab by (sort_field_up) ascending (sort_field_dn) descending.
But I get a dump ...
has anyone ever done this ?
regards,
Nicolas

Hi,
only single fields can be mentioned in dynamic sort.
REPORT  Z_DYNAMIC_SORT                          .
data: sort1 type string,
      sort2 type string.
data: begin of itab occurs 0,
       vbeln like vbak-vbeln,
       posnr like vbap-posnr,
      end of itab.
"not possible to group the fileds.
"sort_field_up = ' field1 field2 field 3'
sort1 = 'VBELN'.
sort2 = 'POSNR'.
sort itab by (sort1) ascending (SORT2) descending.
"or
sort itab by (sort1) (SORT2) ascending .
write sy-subrc.
regards
vijay

Similar Messages

  • Listview sorting in ascending / descending order

    Hello
    I am new to winforms
    What I want to do is when the user clicks on a listview control column the listview data should get sorted by that column in ascending / descending order
    Please help me 
    Thanks
    regds
    Manoj Gokhale

    There's an example at the following link.
    https://msdn.microsoft.com/en-us/library/system.windows.forms.listview.listviewitemsorter%28v=vs.110%29.aspx

  • Change the sort order (ascending/descending) based on parameter field

    I have created a formula on a subreport to change sorting based on variables.
    select {?Pm-@Sorting}
    case "property_type_desc ASC" :
    {owned_property.property_type_desc}
    case "property_type_desc DESC" :
    {owned_property.property_type_desc}
    default:
    ({owned_property.property_type_cd}; )
    how can I change the sort order ascending and descending using the formula??
    Thanks, Jessica

    Try this
    1. Create a parameter with 2 default values in the picklist: Descending and Ascending.
    NOTE:
    In Crystal Reports version 5 or 6, it is not possible to have a pick a parameter value from a list. The user must enter a specific value, guided by the prompting text. For example : To Sort in Ascending order type A, to sort in Descending order type D.
    u2022 On the 'Insert' menu, click 'Parameter', then click 'New'.
    u2022 Type the name and prompting text for the parameter in the corresponding boxes.
    u2022 In the 'Type' box, click 'String'.
    u2022 Click 'Set Default'.
    u2022 In the 'Value to add' box, type 'Descending' then click '>' to move it to the 'Default Values' list.
    u2022 Repeat the above step for 'Ascending'.
    u2022 Click 'OK', then click 'OK' again to return to the report.
    2. Create 2 formulas based on the field you want to change the sort direction on:
    u2022 On the 'Insert' menu, click 'Formula', then click 'New'.
    u2022 Create this formula:
    @Asc
    If {?Parameter} = "Ascending" then
    u2022 Save this formula and close the Formula Editor. This brings you back to the Formula tab of the Insert Fields dialog box.
    u2022 Click 'New' and create this formula:
    @Des
    If {?Parameter} = "Descending" then
    u2022 Save this formula and close the Formula Editor.
    u2022 Click 'Close' to return to the report.
    4. Sort the report based on these two formulas.
    u2022 On the 'Report' menu, click 'Sort Records'.
    u2022 In the 'Report Fields' list, click {@Asc} and move it to the 'Sort Fields' list.
    u2022 Under 'Sort Direction', click 'Ascending'.
    u2022 In the 'Report Fields' list, click {@Des} and move it to the 'Sort Fields' list.
    u2022 Under 'Sort Direction', click 'Descending'.
    u2022 Click 'OK' to return to the report.
    Once you preview the report you will be prompted to select a parameter value, which will determine how the report is sorted.
    Regards,
    Raghavendra

  • Hide sort(ascending and descending) buttons in an alv report.

    Hi,
    I want to hide the  sort(ascending and descending) buttons in an alv report.
    can any one help me with the code?
    I am not able to use the parameter IT_TOOLBAR_EXCLUDING
    of SET_TABLE_FOR_FIRST_DISPLAY of class  CL_GUI_ALV_GRID.
    Regards,
    Himanshu.

    Hi,
    data it_exclude type ui_functions.
    Exclude Standard Functions
        PERFORM f_excludetoolbar USING obj_cust_grid
                              CHANGING it_exclude.
    FORM f_excludetoolbar  USING  u_obj_cust_grid  TYPE REF TO cl_gui_alv_grid
                        CHANGING  c_it_exclude     TYPE ui_functions.
    Exclude Standard Functions
      CLEAR: c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_check              TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_refresh            TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_loc_copy           TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_loc_copy_row       TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_loc_cut            TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_loc_delete_row     TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_loc_append_row     TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_loc_insert_row     TO  c_it_exclude.
      APPEND u_obj_cust_grid->mc_fc_loc_move_row       TO  c_it_exclude.
    APPEND u_obj_cust_grid->MC_FC_SORT_DSC          TO  c_it_exclude.
      APPEND u_obj_cust_grid->MC_FC_SORT_ASC  TO  c_it_exclude.
      APPEND u_obj_cust_grid->MC_FC_SORT           TO  c_it_exclude.*
    ENDFORM.                    " f_excludetoolbar
    Hope it will helpful for you.
    Reward if found helpful.
    Regards,
    SB

  • Dynamic sorting in pivot view

    Hello
    Can someone please point me to the OBIEE Oracle documentation where I can find "How to make dynamic sorting work in a pivot table view".
    I have many pivot views on a dashboard. Clicking on the measure columns "Sort Ascending" and "Sort Descending" did not use to sort the columns in 10g. But I have found on this link
    https://forums.oracle.com/message/9321054#9321054
    that dynamic sorting can be now done in pivot views. But I am unable to find Oracle documentation on it that tells me how.
    We have upgraded to 11.1.1.7 but still I am unable to do sorting in pivot views on dashboards
    Thanks

    Devendra,
    you cannot have both status and status icon in the same column. so create a new column and then populate it according to the status.
    here is the sample code from the layout section of document_todo.htm
    <!--      Column: Appraisal Name                   -->
              <htmlb:tableViewColumn columnName = "AP_STATUS_NAME"
                                     width      = "150"
                                     type       = "IMAGE" >
              </htmlb:tableViewColumn>
              <%
                  data: status_icon type string.
                  if APPLICATION->T_DOCUMENTS_TODO-AP_STATUS = '2'.
                  status_icon = cl_bsp_mimes=>sap_icon( id = 'ICON_WS_PLANE' ).
                  else.
                  endif.
              %>
              <htmlb:tableViewColumn columnName          = "STATUS SIGN"
                                     type                = "user"
                                     title               = "STATUS ICON"
                                     horizontalAlignment = "center" >
    regards,
    manasa

  • Dynamic SORT with multiple components

    Hi all,
    I want to sort an internal table in this way:
    SORT itab BY (component).
    This is not difficult if "component" contains the name of ONE column of itab. But - and here is my problem - how can I sort with multiple components?
    Like this:
    SORT itab BY (comp_1) (comp_2) ... (comp_N).
    The number of components (N) shall be flexible. It is not possible to concatenate the components into one string-variable. This causes an error ITAB_ILLEGAL_COMPONENT.
    Brillant would be a solution which also contains the sort-direction (ASCENDING or DESCENDING for each component like this:
    SORT itab BY (comp_1) (dir_1)
                 (comp_2) (dir_2)
                 (comp_N) (dir_N).
    Is there a way to do so?
    Thanks for all hints!
    Mathias

    Hi Matahias ...
    From ABAP help...
    SORT itab.
    Extras:
    1. ... BY f1 f2 ... fn
    2. ... ASCENDING
    3. ... DESCENDING
    4. ... AS TEXT
    5. ... STABLE
    The syntax check performed in an ABAP Objects context is stricter than in other ABAP areas. See Field symbols not allowed as sort criterion.
    Effect
    The entries in the internal table are sorted in ascending order using the key from the table definition (DATA, TYPES).
    Addition 1
    ... BY f1 f2 ... fn
    Effect
    Uses the sort key defined by the sub-fields f1, f2, ..., fn of the table itab instead of the table key. The fields can be of any type; even number fields and tables are allowed.
    You can also specify the sort fields dynamically in the form (name). If name is blank at run time, the sort field is ignored. If itab is a table with a header line, you can also use a field symbol pointing to the header line of itab as a dynamic sort criterion. A field symbol that is not assigned is ignored. If a field symbol is assigned, but does not point to the header line of the internal table, a runtime error occurs.
    If the line type of the internal table contains object reference variables as components, or the entire line type is a reference variable, you can use the attributes of the object to which a reference is pointing in a line as sort criteria (see Attributes of Objects as the Key of an Internal Table
    You can address the entire line of an internal table as the key using the pseudocomponent TABLE_LINE. This is particularly relevant for tables with a non-structured line type when you want to address the whole line as the key of the table (see also Pseudocomponent TABLE_LINE With Internal Tables).
    If you use one of the additions 2 to 5 before BY, it applies to all fields of the sort key by default. You can also specify these additions after each individual sort field f1, f2, ..., fn. For each key field, this defines an individual sort rule which overrides the default.
    Cheers
    Preetham

  • How to sort in numbers 3.0 sort ascending is grayed out

    I tried to follow "how to sort" in numbers, but I am doing something wrong. My "sort ascending" and "sort descending" are grayed out.

    Hi Jerry,
    I suspect you have merged some cells in the table somewhere. This confuses it, as it has no way of keeping the rows containing the merge together while sorting.
    Unmerging solved it when I had the same problem.
    Best wishes.

  • Html code visible when sorting ascending

    hello,
    I have a report where one column is sortable, but when i click the column header to sort descending, some text is visible over the column headers.
    this is the text that is visible, it is not visible when it sorted ascending.
    td headers="DOA" class="t9data">0
    Anyone know why this is happends?
    Anders
    Message was edited by:
    emband

    Peter,
    FYI - for HTML DB 2.0, the entry:
    PlsqlNLSLanguage DANISH_DENMARK.WE8MSWIN1252
    is incorrect. It should be:
    PlsqlNLSLanguage DANISH_DENMARK.AL32UTF8
    regardless of database character set. Note that on some instances, the PL/SQL Web Toolkit patch will need to be applied to accommodate this.
    http://download-west.oracle.com/docs/cd/B19306_01/relnotes.102/b16374/toc.htm#BGBCJIEA
    Joel

  • How do you sort vector descendingly?

    Lets say if have a vector which contains values in double data type.
    Vector vNum = ne wVector();
    vNum.addElement(new Double("50.5"));
    vNum.addElement(new Double("40.5"));
    vNum.addElement(new Double("60.5"));_______________________________________
    If you sort it ascendingly by entering the code:
    Collections.sort(vNum);The result would be
    40.5
    50.5
    60.5
    and it is correct. But i tried to sort it descendingly by entering the code:
    Collections.reverse(vNum);The result was:
    60.5
    40.5
    50.5
    Someone told me before that the code for sorting descendingly was Collections.reverse(vectorName); but it didnot work.
    Does anyone know what's the code for sorting the Vector descendingly?
    thanks!

    Collections.reverse(list) just reverses the order of the elements in the specified list.
    You can either call sort() and then reverse(), or you can specify your own Comparator for sorting in reverse order. (I prefer the second solution)
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#sort(java.util.List,%20java.util.Comparator)

  • Ascending descending table column in swt

    Hello,
    I am create eclipse RCP application and use SWT table and i am trying to ascending descending column value but not working in column shell value is not change so please help me ...

    Hi Brian de Alwis sir Thank you ,
    But sir my column value (cell value) is combobox , how to sort column combo value in my table ....
    please sir help me

  • Ascending/Descending Email Order Problem...

    Exasperating... I have set all my inboxes to show incoming mails in descending order. However, my main Inbox has to be re-set to descending every time I click on it... my other laptop running Lion doesn't exhibit this problem. Any ideas? (I've repaired permissions)... I don't want to have to trash my Mail prefs and start again...
    TIA,

    I tried this on a simple DataGrid and it worked most of the
    time (sorted ascending on the first click, descending on the second
    click), but once in a while it seemed to miss a button click, and
    then the sort did not work. When I do event.trace(target) in the
    click handler, the trace does not fire when the click event is
    missed, so I don't know how to get around this.

  • Sort Dimension descending using developer tool

    Hi,
    i have a alpha-numeric property in endeca, we need to sort it descending, can we achieve this using developer studio.
    i was able to sort it ascending order, not seeing any field in developer studio to sort descending order
    Thanks,
    Tijo

    Hi Mathew,
    If you want to sort dimension in descending order one way to do this is add following in "appname.refinement_config.xml"
    <REFINEMENTS NAME="price" SORT_TYPE="NUMERIC" SORT_ORDER="DESC">
    <STATS NUM_RECORDS="FALSE"/>
    </REFINEMENTS>
    This way we get dimension values in descending order.
    Please Note Whenever you have the pipeline in the developer studio this mapping gets removed, so you need to add it again before you run the baseline.
    HTH
    MS

  • Sort ascending problem?

    (Numbers '09, 2.1 (436))
    I have an 8000+ row table of names and addresses that I tried sorting by street address.  When I did an ascending sort on that column, the rows with blank street addresses were split between the top and bottom of the sort.  This was not the case for a descending sort on the same column, where all of the blanks appear at the bottom of the list.  Is this a know bug?
    The data in the table is quite varied, but I grabbed some of the odder stuff for the images below.
    Ascending sort:
    Decending sort:

    The images did not make it into my previous post.
    Here is the ascending sort result:
    descending sort:

  • Dynamic Sorting on Multiple filed in Crystal report 2008

    Hi
      I am using Crystal report 2008 sp3 full build with hotfix 3.3 along with ASP.NET 2.0
      I have implimented the multi filed sorting using the record sort export and setting the sort order in the report designer.
    Now my requirement is such that i would like to have dynamic sorting on multiple fileds while report is displayed in the UI.
    Means suppose i have a report with Customer region,name,city,rating,status etc.
    Now by using the sort control  i would like to have the functionality in such a way that if user
    a)  first sorts on the region then the records should be first sorted by region
    b)  then sorts on the city then the records should be sorted first by region then by city
    c) now sorts on the  rating then the records should be sorted first by region ,second by city and then by rating
    Now other user may do
    a) first sorts on the rating then the records should be first sorted by rating
    b)  then sorts on the status then the records should be sorted first by rating then by status
    c) now user sorts on the  region then the records should be sorted first by rating,second by status and then by region
    and so on the sorting criteria changes from user to user through the UI.
    Is there any way to achieve the dynamic kind of sorting with Crytsal report 2008 where we can set the order of the fileds at sorting in UI dynamically .The sorting order of the fields are not known at the time of design of the report and its completely depends on the user's need.
    Please let me know if you require any information on the same.
    Regards,
    smitha

    Hello,
       Good Day!
       Thanks for your answer.
       Could you please explain me in detail how to achieve this functionality?
       Do i need to create a static parameter?
       I  get my data set through the command option in crystal report.So i think i need to go by formula in the report.
       i am just putting down the steps to follow.Please correct me if i am wrong.
      step1 :Create s static parameter with the name SORT.
    step2: create the formula as you have mentioned like     
        (IF {?Sort}='Vendor Number' THEN {Pr_Voucher_Status;1.Vendor_Key}& " "& {Pr_Voucher_Status;1.ap_remt_key}
        & " " & {@date}
       else
        IF {?Sort}='Invoice Number' THEN {Pr_Voucher_Status;1.ap_vchr_invno}& " " & {Pr_Voucher_Status;1.Vendor_Key}&
        " " &{@date}
       else
       IF {?Sort}='Invoice Amount' THEN {Pr_Voucher_Status;1.ap_vchr_amtc}& " " & {Pr_Voucher_Status;1.Vendor_Key}&
         " " &{@date})
        I could not  understand what this formula is really doing .
        Could you please tell me what the following names indicates? :
                  Pr_Voucher_Status :- Table/Command name ??
                  Vendor Number,Invoice Number etc.. :-  ??
                 Vendor_Key,ap_vchr_invno,ap_vchr_amtc .. :-  Filed names ??
                 use of 1.{} :- ??                              
    step3: place the below formula in the page header  to display the sort order
        (if {?SORT}='Vendor Number' then "Vendor Number, Remit To, Invoice Date"
              else if {?SORT}='Invoice Number' then "Invoice Number, Vendor Number, Invoice Date"
              else if {?SORT}='Invoice Amount' then "Invoice Amount, Vendor Number, Invoice Date") .
    Note:-My report does not have grouping.Do i need to have grouping?
    in this case how the sort control will work  ?
    As i have mentioned in the first post the order of sorting is completely depends on the user's perspective .
    The report is used by the whole organization ..
    i mean the people with different roles like Manger,Team leads,modul leads,developers ,testers etc..
    the usage of report varies according to the roles so the sort order also.
    Regards,
    smitha.
    Edited by: smitha thomas on Mar 16, 2011 5:01 AM

  • How to acheive Pagination and Dynamic sorting in Web layout.

    Hi All,
    I'm new to Oracle Reports. I use Report Builder 10.1.2.0.2.
    I tried creating a template for simple tabular report. I modified the tempalte for Paper layout, Web layout ie modified .tdf, html, css files.
    When the data is dispalyed in the web browser, i need to do Pagination and dynamic sorting (ie when the column heading is clicked, it needs to do sorting by that column).
    In the jsp page of the report, it is possible but i want to incorporate this functionality in the Template. So that a single template can be used across multiple reprots with out any modification.
    Can any one please tell me how to do this.
    Please reply me at the earliest. Its very urgent.
    Thanks & Regards,
    P. Gayathri Devi

    Igor,
    You'll need to switch from using Partial Page Rendering to full page submits on that report. In version 4.0 we should be getting more control over event handling in PPRs but to what extent is still unknown.
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen
    http://sourceforge.net/projects/plrecur

Maybe you are looking for

  • Question regarding the date in MARC for a daily movement report

    Hi, I have a requirement, where i need to create a report, based on the selection screen parameters for <u>purchasing group</u> and <u>date</u> (the default is 1 minus the current date.) The report is used to view the daily movement, relating to the

  • Material is there in the BOM still no reservation.

    Hi , I have created planned order. According to planned order material is there in the BOM. Still no reservation happened. Can you please tell me what all the possible reasons for this? Regards, Amit

  • Issue while synchronizing company address in SCUG

    Hello All, I wish everyone is fine. Before starting the thread i already did a search on my issue however i was not successful. I am in the process of configuring CUA within a SAP instance with two different clients ( central and child). Logical syst

  • Message attachment - place in target directory

    Hi, The message comes to XI as an attachment. This message has to be placed in target directory by configuring Receiver File adapter using FTP protocol. How to configure the adapter to place an attachment file in target directory. Regards, Anil.

  • A strange bug in 10Gr2.How to handle??

    Hi friends, In Oracle 9i releases It works fine... SQL> set serveroutput on SQL> exec dbms_output.put_line(10*99990000*12); 11998800000 PL/SQL procedure successfully completed. but in any 10g releases the same code gives.. SQL> set serveroutput on SQ