Functionality to dynamically sort tableview columns

Has anybody successfully tried sorting columns of a tableview component by clicking on its header? I need to sort a column containing dates in mm/dd/yyyy format. Please share your hints or code. BR, Maulin

Hi,
Here is the code, no support included :-):
import java.util.Collections;
import java.util.Comparator;
import java.util.Vector;
import com.sapportals.htmlb.table.DefaultTableViewModel;
public class SortTableModel extends DefaultTableViewModel implements Comparator {
     protected int currCol;
     protected Vector ascendCol; // this vector stores the state (ascending or descending) of each column
     protected Integer one = new Integer(1);
     protected Integer minusOne = new Integer(-1);
     public SortTableModel() {
          super();
          ascendCol = new Vector();
     public SortTableModel(Vector vec) {
          super(vec);
          ascendCol = new Vector();
     public SortTableModel(Vector vec, Vector vec2, int numberOfColumns) {
          super(vec, vec2);
          ascendCol = new Vector();
          setSortOrder(numberOfColumns);
This method is the implementation of the Comparator interface.
It is used for sorting the rows
     public int compare(Object v1, Object v2) {
          // the comparison is between 2 vectors, each representing a row
          // the comparison is done between 2 objects from the different rows that are in the column that is being sorted
          int ascending = ((Integer)ascendCol.get(currCol)).intValue();
          if (v1 == null && v2 == null) {
               return 0;
          } else if (v2 == null) { // Define null less than everything.
               return 1 * ascending;
          } else if (v1 == null) {
               return -1 * ascending;
          Object o1 = ((Vector)v1).get(currCol);
          Object o2 = ((Vector)v2).get(currCol);
          // If both values are null, return 0.
          if (o1 == null && o2 == null) {
               return 0;
          } else if (o2 == null) { // Define null less than everything.
               return 1 * ascending;
          } else if (o1 == null) {
               return -1 * ascending;
          if (o1 instanceof Number && o2 instanceof Number) {
               Number n1 = (Number)o1;
               double d1 = n1.doubleValue();
               Number n2 = (Number)o2;
               double d2 = n2.doubleValue();
               if (d1 == d2) {
                    return 0;
               } else if (d1 > d2) {
                    return 1 * ascending;
               } else {
                    return -1 * ascending;
          } else if (o1 instanceof Boolean && o2 instanceof Boolean) {
               Boolean bool1 = (Boolean)o1;
               boolean b1 = bool1.booleanValue();
               Boolean bool2 = (Boolean)o2;
               boolean b2 = bool2.booleanValue();
               if (b1 == b2) {
                    return 0;
               } else if (b1) {
                    return 1 * ascending;
               } else {
                    return -1 * ascending;
          } else {
               // default case
               if (o1 instanceof Comparable && o2 instanceof Comparable) {
                    Comparable c1 = (Comparable)o1;
                    Comparable c2 = (Comparable)o2; // superflous cast, no need for it!
                    try {
                         return c1.compareTo(c2) * ascending;
                    } catch (ClassCastException cce) {
                         // forget it... we'll deal with them like 2 normal objects below.
               String s1 = o1.toString();
               String s2 = o2.toString();
               return s1.compareTo(s2) * ascending;
This method sorts the rows using Java's Collections class.
After sorting, it changes the state of the column -
if the column was ascending, its new state is descending, and vice versa.
     public void sort() {
          Collections.sort(dataVector, this);
          Integer val = (Integer)ascendCol.get(currCol);
          ascendCol.remove(currCol);
          if (val.equals(one)) // change the state of the column
               ascendCol.add(currCol, minusOne);
          else
               ascendCol.add(currCol, one);
     public void sortByColumn(int column) {
          this.currCol = column;
          sort();
     public void setSortOrder(int numberOfColumns) {
          for (int i = 0; i < numberOfColumns; i++) {
               ascendCol.add(one);

Similar Messages

  • Sorting character column ( used in order by clause dynamically)

    Hi,
    I need help on sorting character-based numbers. Like say, I want to sort customers based on street numbers(which is a character string being used in the
    order by clause) they live in.
    The criteria are :
    i. Numbers must take precedence.
    This being a character string, 1000001 comes before 2. This shouldn't happen. And you cannot use to_number
    since using it with a string having characters in it would raise an error.
    ii. If only a single alphabet occurs as the last character, then treat the whole string as a number except the last character and then sort it
    as if sorting a number. Something like : if you have 1000A, 200D, 200B, 1000X, the result would be 200B,200D,1000A,1000X.
    iii. if a character occurs elsewhere in the string, then perform the search normally as if performing a character search.
    The output of the following data :
    100
    A101
    B100A
    110C
    C120B
    120
    100020
    120C
    C1100
    100D
    would be like :
    100
    100D
    110C
    120
    120C
    100020
    A101
    B100A
    C120B
    C1100
    Please note that the sort is being done dynamically, so I could have access to the values of the street numbers only during run time.
    Any help is really appreciated.
    Thanks in advance.
    Regards,
    Anil.

    Create a function to test whether the column is numeric :
    create FUNCTION is_numeric(v_number VARCHAR2)
    RETURN INTEGER
    IS
    l_number NUMBER;
    BEGIN
    IF INSTR(UPPER(v_number),'E') > 0 THEN
    RETURN 0;
    END IF;
    l_number := TO_NUMBER(v_number);
    RETURN 1;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN 0;
    END;
    And try this query
    Assume the table name is TEST with column STREET
    select * from TEST
    order by case is_numeric(STREET) when 1 then LPAD(STREET,20, ' ') else STREET end
    Please make sure that 20 mentioned above is the column size for STREET.
    Hope this helps.
    -Nags

  • 'Sort order column' doesn't work for prompt with function

    I turned on the 'sort order column property' in repository for a logic column 'school year', so when I get school year from prompt, it shows desc order. It works fine if th colume in prompt is a simple prompt. But when I add function in the column in prompt (means edit Fx with a case statement), when school year prompt shows in dashboard, it is not sorted in desc order any more, it went back to acs.
    Am I missing something, or this is a bug?
    Another question, when I turn on 'sort order column property' in repository for a logic column, can I choose to desc on another column? I couldn't do it, and had to create another sorting column.
    Thanks,
    Amy

    Cant you create this logic in the rpd and then apply order there and use the newly created column in your prompt..

  • Function returning SQL - dynamically select the column

    Hi there,
    [Oracle 11g],
    Hi there,
    I want to dynamically select the column to be displayed.
    Or lets say it in an easier way regarding the EMP Table:
    I got a table called teststable with value1 and value2 in it.
    Value1 is EMPNO
    Value 2 is DEPTNO
    Now I like to have something like this:
    Select (Select Value1 from testtable),(Select Value2 from testtable) from EMP This will not work. So I need a function for this. Does someone now how to get this to work? Thx in advance. Thorsten

    + 1 to the above replies.
    An example to pick the column name dynamically from a table and rendering the output of EMP table as a XMLTYPE is here.Pushing it a little bit further, you can project back XML as relational rows and columns :
    SQL> with testtable (value1, value2) as (
      2    select 'EMPNO', 'DEPTNO' from dual
      3  )
      4  select x.*
      5  from testtable t
      6     , xmltable(
      7         'for $r in fn:collection("oradb:/SCOTT/EMP")/ROW
      8          return element r {
      9            $r/*[local-name()=$v1]
    10          , $r/*[local-name()=$v2]
    11          }'
    12         passing t.value1 as "v1"
    13               , t.value2 as "v2"
    14         columns value1 varchar2(30) path '*[1]'
    15               , value2 varchar2(30) path '*[2]'
    16       ) x
    17  ;
    VALUE1                         VALUE2
    7369                           20
    7499                           30
    7521                           30
    7566                           20
    7654                           30
    7698                           30
    7782                           10
    7839                           10
    7844                           30
    7900                           30
    7902                           20
    7934                           10
    12 rows selected

  • Numbers Sort function. In Numbers 09 there was 'rearrange' which worked perfectly. New Numbers 13 has Sort by column but I can't get it to work. is there a bug?

    In Numbers 09 there was 'rearrange' which worked perfectly. New Numbers 13 has Sort by column but I can't get it to work. is there a bug?

    Numbers '09 has a Reorganize panel and the top section of that panel is for sorting. Numbers 3 also has the ability to sort and it works.  However, Numbers '09 and Numbers 3 sort differently.
    In Numbers '09, if you had a formula such as =Table 1::A1 and if a sort of Table 1 moved cell A1 to A20, the formula would change to =Table 1::A20. In Numbers 3, the formula would stay =Table1::A1.

  • 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

  • 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

  • I am unable to sort multiple columns in a table created in Pages.

    I had been using Appleworks up until I installed Lion and have now switched to iWork. I created a table within a Pages document and am able to sort a single column (using the Table Inspector and choosing Sort from  Edit Rows and Columns) but the Sort option is grayed out when I attempt to sort multiple columns.
    In another post, someone talked about this being a problem if you have merged fields. I do not believe I have done this (to be honest I don't know the function of merging fields).
    This is very frustrating as I was easily able to sort these tables in Appleworks.

    Sharon Anderson wrote:
    Thanks for your quick response! I have been trying that but then found that Numbers would only let me print in landscape view so I had to paste the table back into Pages. Is there a way to print in portrat view (from Numbers?)
    Not so. In the lower left corner of the window, there's an icon that looks like a piece of paper. If you see this:
    you are in Sheet View, or normal, mode. If you see this:
    You are in Print View mode. Now you see the icons for portrait and landscape modes. Click your choice. Then arrange your content to fit the pages as you wish.
    Jerry

  • Dynamic sort help needed

    I am trying to implement a dynamic sort using pl/sql procedure
    with two IN params, which tell what column to sort by
    and wich direction. smth. like this
    procedure getEmployees (p_dept_no in employee.dept_no%type,
    p_sortBy in varchar2,
    p_sortDir in varchar2
    p_empl_cur in out emplCur
    ) is
    begin
    OPEN p_empl_cur
    FOR
    SELECT EMP_ID, F_NAME, L_NAME
    FROM EMPLOYEE
    WHERE DEPT_NO=p_dept_no
    ORDER BY p_sortBy p_sortDir ; --> this is the part that does not work
    -- I make sure that the params values are correct
    -- possible p_sortBy values: EMP_ID, F_NAME, L_NAME
    -- and p_sortDir: 'ASC' or 'DESC'
    end getEmployees;
    Thank you in advance.

    Try execute immediate.
    Some thing like this:
    PROCEDURE GETEMPLOYEES (P_DEPT_NO IN EMPLOYEE.DEPT_NO%TYPE,
    P_SORTBY IN VARCHAR2,
    P_SORTDIR IN VARCHAR2
    P_EMPL_CUR IN OUT EMPLCUR
    ) IS
    BEGIN
    OPEN P_EMPL_CUR
    FOR
    SORT_SQL := NULL;
    SORT_SQL := 'SELECT EMP_ID, F_NAME, L_NAME FROM EMPLOYEE'||
    ' WHERE DEPT_NO=P_DEPT_NO '||
    ' ORDER BY '||P_SORTBY||' '||P_SORTDIR||';'
    EXECUTE IMMEDIATE SORT_SQL INTO P_EMPL_CUR;
    Thanks
    Vasu
    I am trying to implement a dynamic sort using pl/sql procedure
    with two IN params, which tell what column to sort by
    and wich direction. smth. like this
    procedure getEmployees (p_dept_no in employee.dept_no%type,
    p_sortBy in varchar2,
    p_sortDir in varchar2
    p_empl_cur in out emplCur
    ) is
    begin
    OPEN p_empl_cur
    FOR
    SELECT EMP_ID, F_NAME, L_NAME
    FROM EMPLOYEE
    WHERE DEPT_NO=p_dept_no
    ORDER BY p_sortBy p_sortDir ; --> this is the part that does not work
    -- I make sure that the params values are correct
    -- possible p_sortBy values: EMP_ID, F_NAME, L_NAME
    -- and p_sortDir: 'ASC' or 'DESC'
    end getEmployees;
    Thank you in advance.

  • How not to sort datagrid column on double click

    Hello,
    I am currently building an application containing a datagrid for data representation. I've created a custom datagridheader in order to add a input text for filtering the columns (see code below).
    My goal is to hide the textinput, and then show it on a double click on the header. So i would like to know how to avoid the sort of this column each time i double click.?
    <?xml version="1.0" encoding="utf-8"?>
    <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx" resize="onColumnResize(event)" clipAndEnableScrolling="true" doubleClick="managefilterField(event)">
        <fx:Declarations>
            <!--- The default value of the <code>sortIndicator</code> property.
            It must be an IFactory for an IVisualElement.       
            <p>This value is specified in a <code>fx:Declaration</code> block and can be overridden
            by a declaration with <code>id="defaultSortIndicator"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <fx:Component id="defaultSortIndicator">
                <s:Path data="M 3.5 7.0 L 0.0 0.0 L 7.0 0.0 L 3.5 7.0" implements="spark.components.gridClasses.IGridVisualElement">
                    <fx:Script>
                        <![CDATA[
                            import spark.components.DataGrid;
                            import spark.components.Grid;
                             *  @private
                            public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void
                                const dataGrid:DataGrid = grid.dataGrid;
                                if (!dataGrid)
                                    return;
                                const color:uint = dataGrid.getStyle("symbolColor");
                                arrowFill1.color = color;
                                arrowFill2.color = color;
                        ]]>
                    </fx:Script>
                    <s:fill>
                        <s:RadialGradient rotation="90" focalPointRatio="1">   
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill1" color="0" alpha="0.6" />
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill2" color="0" alpha="0.8" />
                        </s:RadialGradient>
                    </s:fill>
                </s:Path>
            </fx:Component>
            <!--- Displays the renderer's label property, which is set to the column's <code>headerText</code>.
            It must be an instance of a <code>TextBase</code>, like <code>s:Label</code>.
            <p>This visual element is added to the <code>labelDisplayGroup</code> by the renderer's
            <code>prepare()</code> method.   Any size/location constraints specified by the labelDisplay
            define its location relative to the labelDisplayGroup.</p>
            <p>This value is specified with a <code>fx:Declaration</code> and can be overridden
            by a declaration with <code>id="labelDisplay"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <s:Label id="labelDisplay"
                     verticalCenter="1" left="0" right="0" top="0" bottom="0"
                     textAlign="start"
                     fontWeight="bold"
                     verticalAlign="middle"
                     maxDisplayedLines="1"
                     showTruncationTip="true" />
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import net.awl.ismp.console.components.misc.FilterCriteria;
                import net.awl.ismp.console.events.ColumnFilteredEvent;
                import net.awl.ismp.console.events.ColumnResizedEvent;
                import mx.events.ResizeEvent;
                import spark.components.gridClasses.IGridVisualElement;
                import mx.core.IVisualElement;
                import spark.components.DataGrid;
                import spark.components.GridColumnHeaderGroup;
                import spark.components.gridClasses.GridColumn;
                import spark.primitives.supportClasses.GraphicElement;
                // chrome color constants and variables
                private static const DEFAULT_COLOR_VALUE:uint = 0xCC;
                private static const DEFAULT_COLOR:uint = 0xCCCCCC;
                private static const DEFAULT_SYMBOL_COLOR:uint = 0x000000;
                private static var colorTransform:ColorTransform = new ColorTransform();
                 *  @private
                private function dispatchChangeEvent(type:String):void
                    if (hasEventListener(type))
                        dispatchEvent(new Event(type));                   
                protected function onColumnResize(event:ResizeEvent):void
                    dispatchEvent(new ColumnResizedEvent(ColumnResizedEvent.COLUMNRESIZED_EVT,this.width,this.column.columnInde x));
                //  maxDisplayedLines
                private var _maxDisplayedLines:int = 1;
                [Bindable("maxDisplayedLinesChanged")]
                [Inspectable(minValue="-1")]
                 *  The value of this property is used to initialize the
                 *  <code>maxDisplayedLines</code> property of this renderer's
                 *  <code>labelDisplay</code> element.
                 *  @copy spark.components.supportClasses.TextBase#maxDisplayedLines
                 *  @default 1
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get maxDisplayedLines():int
                    return _maxDisplayedLines;
                override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void
                    trace("state changed from : "+oldState+" to "+newState);
                    super.stateChanged(oldState, newState, recursive);
                 *  @private
                public function set maxDisplayedLines(value:int):void
                    if (value == _maxDisplayedLines)
                        return;
                    _maxDisplayedLines = value;
                    if (labelDisplay)
                        labelDisplay.maxDisplayedLines = value;
                    invalidateSize();
                    invalidateDisplayList();
                    dispatchChangeEvent("maxDisplayedLinesChanged");
                //  sortIndicator
                private var _sortIndicator:IFactory;
                private var sortIndicatorInstance:IVisualElement;
                [Bindable("sortIndicatorChanged")]
                 *  A visual element that's displayed when the column is sorted.
                 *  <p>The sortIndicator visual element is added to the <code>sortIndicatorGroup</code>
                 *  by this renderer's <code>prepare()</code> method.  Any size/location constraints
                 *  specified by the sortIndicator define its location relative to the sortIndicatorGroup.</p>
                 *  @default null
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get sortIndicator():IFactory
                    return (_sortIndicator) ? _sortIndicator : defaultSortIndicator;
                 *  @private
                public function set sortIndicator(value:IFactory):void
                    trace("setSortIndicator");
                    if (_sortIndicator == value)
                        return;
                    _sortIndicator = value;
                    if (sortIndicatorInstance)
                        sortIndicatorGroup.includeInLayout = false;
                        sortIndicatorGroup.removeElement(sortIndicatorInstance);
                        sortIndicatorInstance = null;
                    invalidateDisplayList();
                    dispatchChangeEvent("sortIndicatorChanged");
                 *  @private
                 *  Create and add the sortIndicator to the sortIndicatorGroup and the
                 *  labelDisplay into the labelDisplayGroup.
                override public function prepare(hasBeenRecycled:Boolean):void
                    trace("prepare !!");
                    super.prepare(hasBeenRecycled);
                    if (labelDisplay && labelDisplayGroup && (labelDisplay.parent != labelDisplayGroup))
                        labelDisplayGroup.removeAllElements();
                        labelDisplayGroup.addElement(labelDisplay);
                    trace(sortIndicator);
                    trace("sortIndicatorInstance : "+sortIndicatorInstance);
                    const column:GridColumn = this.column;
                    if (sortIndicator && column && column.grid && column.grid.dataGrid && column.grid.dataGrid.columnHeaderGroup)
                        const dataGrid:DataGrid = column.grid.dataGrid;
                        const columnHeaderGroup:GridColumnHeaderGroup = dataGrid.columnHeaderGroup;
                        if (columnHeaderGroup.isSortIndicatorVisible(column.columnIndex))
                            if (!sortIndicatorInstance)
                                sortIndicatorInstance = sortIndicator.newInstance();
                                sortIndicatorGroup.addElement(sortIndicatorInstance);
                                chromeColorChanged = true;
                                invalidateDisplayList();
                            // Initialize sortIndicator
                            sortIndicatorInstance.visible = true;
                            const gridVisualElement:IGridVisualElement = sortIndicatorInstance as IGridVisualElement;
                            if (gridVisualElement)
                                gridVisualElement.prepareGridVisualElement(column.grid, -1, column.columnIndex);
                            sortIndicatorGroup.includeInLayout = true;
                            sortIndicatorGroup.scaleY = (column.sortDescending) ? 1 : -1;
                        else
                            if (sortIndicatorInstance)
                                sortIndicatorGroup.removeElement(sortIndicatorInstance);
                                sortIndicatorGroup.includeInLayout = false;
                                sortIndicatorInstance = null;
                private var chromeColorChanged:Boolean = false;
                private var colorized:Boolean = false;
                 *  @private
                 *  Apply chromeColor style.
                override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                    //trace("update display list");
                    // Apply chrome color
                    if (chromeColorChanged)
                        var chromeColor:uint = getStyle("chromeColor");
                        if (chromeColor != DEFAULT_COLOR || colorized)
                            colorTransform.redOffset = ((chromeColor & (0xFF << 16)) >> 16) - DEFAULT_COLOR_VALUE;
                            colorTransform.greenOffset = ((chromeColor & (0xFF << 8)) >> 8) - DEFAULT_COLOR_VALUE;
                            colorTransform.blueOffset = (chromeColor & 0xFF) - DEFAULT_COLOR_VALUE;
                            colorTransform.alphaMultiplier = alpha;
                            transform.colorTransform = colorTransform;
                            var exclusions:Array = [labelDisplay, sortIndicatorInstance];
                            // Apply inverse colorizing to exclusions
                            if (exclusions && exclusions.length > 0)
                                colorTransform.redOffset = -colorTransform.redOffset;
                                colorTransform.greenOffset = -colorTransform.greenOffset;
                                colorTransform.blueOffset = -colorTransform.blueOffset;
                                for (var i:int = 0; i < exclusions.length; i++)
                                    var exclusionObject:Object = exclusions[i];
                                    if (exclusionObject &&
                                        (exclusionObject is DisplayObject ||
                                            exclusionObject is GraphicElement))
                                        colorTransform.alphaMultiplier = exclusionObject.alpha;
                                        exclusionObject.transform.colorTransform = colorTransform;
                            colorized = true;
                        chromeColorChanged = false;
                    super.updateDisplayList(unscaledWidth, unscaledHeight);
                 *  @private
                override public function styleChanged(styleProp:String):void
                    var allStyles:Boolean = !styleProp || styleProp == "styleName";
                    super.styleChanged(styleProp);
                    if (allStyles || styleProp == "chromeColor")
                        chromeColorChanged = true;
                        invalidateDisplayList();
                protected function managefilterField(event:MouseEvent):void
                    trace("double click sortIndicator : "+this.sortIndicatorInstance);
                    this.filterInput.visible=!this.filterInput.visible;
                    this.filterInput.includeInLayout=this.filterInput.visible;
                    this.filterSpacer.visible=this.filterInput.visible;
                    this.filterSpacer.includeInLayout=this.filterInput.visible;
                    if(!this.filterInput.visible)
                        this.filterInput.text="";
                        dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                    //this.filterInput.setStyle(
                protected function onTextInputSelection(event:MouseEvent):void
                    event.stopImmediatePropagation();
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                protected function onKeyUp(event:KeyboardEvent):void
                    if(event.charCode==Keyboard.ENTER)
                        stage.focus=null;
                protected function onFocusOut(event:FocusEvent):void
                    this.filterInput.setStyle("borderColor",0x00ff00);
                    this.filterInput.setStyle("focusColor",0x70B2EE);
                    dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
            ]]>
        </fx:Script>
        <s:states>
            <s:State name="normal" />
            <s:State name="hovered" />
            <s:State name="down" />
        </s:states>     
        <!-- layer 1: shadow -->
        <!--- @private -->
        <s:Rect id="shadow" left="-1" right="-1" top="-1" bottom="-1" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.01"
                                     alpha.down="0" />
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.07"
                                     alpha.down="0.5" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 2: fill -->
        <!--- @private -->
        <s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     color.hovered="0xBBBDBD"
                                     color.down="0xAAAAAA"
                                     alpha="0.85" />
                    <s:GradientEntry color="0xD8D8D8"
                                     color.hovered="0x9FA0A1"
                                     color.down="0x929496"
                                     alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 3: fill lowlight -->
        <!--- @private -->
        <s:Rect id="lowlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="270">
                    <s:GradientEntry color="0x000000" ratio="0.0" alpha="0.0627" />
                    <s:GradientEntry color="0x000000" ratio="0.48" alpha="0.0099" />
                    <s:GradientEntry color="0x000000" ratio="0.48001" alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 4: fill highlight -->
        <!--- @private -->
        <s:Rect id="highlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.0"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12"/>
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12" />
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48001"
                                     alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect> 
        <!-- layer 5: highlight stroke (all states except down) -->
        <!--- @private -->
        <s:Rect id="highlightStroke" left="0" right="0" top="0" bottom="0" excludeFrom="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0xFFFFFF" alpha.hovered="0.22" />
                    <s:GradientEntry color="0xD8D8D8" alpha.hovered="0.22" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!-- layer 6: highlight stroke (down state only) -->
        <!--- @private -->
        <s:Rect id="hldownstroke1" left="0" right="0" top="0" bottom="0" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.001" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.0011" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.965" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.9651" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--- @private -->
        <s:Rect id="hldownstroke2" left="1" right="1" top="1" bottom="1" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.09" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.0001" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--<s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color.normal="0xf9f9f9" color.hovered="0xfcfdfa"
                                     color.down="0xdceac2" alpha="0.85" />
                    <s:GradientEntry color.normal="0xeaeaea" color.hovered="0xdceac2"
                                     color.down="0xd2e1b5" alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>-->
        <!--<s:VGroup left="7" right="7" top="5" bottom="5" gap="6" verticalAlign="middle">
            <s:TextInput width="100%" />
            <s:HGroup width="100%">
                <s:Group id="labelDisplayGroup" width="100%" />
                <s:Group id="sortIndicatorGroup" includeInLayout="false" />
            </s:HGroup>
        </s:VGroup>-->
        <s:VGroup verticalAlign="middle" left="7" top="5" right="7" bottom="5" gap="2" >
            <s:TextInput id="filterInput" width="100%" visible="false" includeInLayout="false" keyUp="onKeyUp(event)" focusOut="onFocusOut(event)" click="onTextInputSelection(event)"/>
            <s:Spacer id="filterSpacer" visible="false" includeInLayout="false" height="5" />
        <s:HGroup width="100%" height="100%" verticalAlign="middle">
            <s:Group id="labelDisplayGroup" width="100%" />
            <s:Group id="sortIndicatorGroup" includeInLayout="false" />
        </s:HGroup>
        </s:VGroup>
    </s:GridItemRenderer>

    Based on your idea, i've intercepted the click event and I use stopImmediatePropagation.
    THen i added an image to sort the column. So if the image is clicked the sort is ok.

  • Sort Order Column not Working

    I have set a sort order column on one of A VARCHAR field, but the functionality is not working. The sorting is enabled in the table view and when I sort by the said column it still sorts based on the VARCHAR values of the column instead of the other INT column I want to sort by. The logical SQL and physical query never even includes the column to sort. Are there any exceptions for the 'Sort Order Column' setting? Is there a config setting or data connections setting that I need to check to make this work?
    Thank You!
    Edited by: VNC on Oct 3, 2011 9:08 AM

    hi,
    can you give me more detailes like some sample column data like below kind
    Like Ex: varchar month column it sould display based on month id
    month : Fev-2011,Dec-2011,jan-2011 and month id 1 to 12
    set your month id as sort order column of month name.
    double click month name ->In general tab set the sort order column as month id
    FYI...see the sample link
    http://www.biconsultinggroup.com/obiee-tips-and-tricks/setting-a-sort-order-column.html
    i hope helped you
    THanks
    Deva
    Edited by: Devarasu on Oct 4, 2011 12:39 AM

  • 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

  • Hotspot-clicking (Insert function) plus ALV Sorting

    Hi,
    I have a requirement where the ALV display has to be SORTED based on values entered/changed on a certain column. The sort works ok when used with a custom APPEND button for new records (always inserted at the bottom of the list).
    However, it does not work correctly when used with the Hotspot-click (INSERT functionality). It looks like if you CLICK on a particular record onscreen, you are actually addressing the original record in that position before the SORT was effected. 
    Is the Hotspot-clicking (Insert functionality) possible with ALV sorting? The ideal solution would be to have the ALV sorted at PBO and also at PAI so that the user can change existing records and add new ones with the sorting being updated everytime ON_DATA_CHANGED is triggered.
    Will appreciate any help on this.
    Thanks!
    Michael

    Hello Michael
    Thanks for further specifying your requirements. I have created the sample variant ZUS_SDN_ALVGRID_HOTSPOT_SORT_1 which contains two differences as compared to its template:
    Replace table VBAK with VBAP (so we have two levels of sorting: VBELN, POSNR)
    Move SET_TABLE_FOR_FIRST_DISPLAY method call into PBO
    When I click on the hotspot (VBELN) a new row entry for the order number is created. The sorting (VBELN, POSNR) is kept even though the new row has been appended to the itab.
    *& Report  ZUS_SDN_ALVGRID_HOTSPOT_SORT
    *& Thread: Hotspot-clicking (Insert function) plus ALV Sorting
    *& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1159431"></a>
    REPORT  zus_sdn_alvgrid_hotspot_sort.
    TYPES: BEGIN OF ty_s_outtab.
    INCLUDE TYPE vbap.
    TYPES: END OF ty_s_outtab.
    TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                          WITH DEFAULT KEY.
    DATA: gt_outtab    TYPE ty_t_outtab.
    DATA:
      gd_okcode        TYPE ui_func,
      gd_repid         TYPE syrepid,
      gt_sort          TYPE lvc_t_sort,
      gt_fcat          TYPE lvc_t_fcat,
      gs_layout        TYPE lvc_s_layo,
      gs_variant       TYPE disvariant,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid          TYPE REF TO cl_gui_alv_grid.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-DATA:
          ms_sel_row    TYPE lvc_s_row. " selected row
        CLASS-METHODS:
          handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
            IMPORTING
              er_data_changed
              e_onf4
              e_onf4_before
              e_onf4_after
              sender,
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_data_changed.
        FIELD-SYMBOLS: <lt_outtab>  TYPE ty_t_outtab.
        BREAK-POINT.
      ENDMETHOD.                    "handle_data_changed
      METHOD handle_hotspot_click.
        " define local data
        DATA: ls_outtab    TYPE ty_s_outtab,
              ld_msg        TYPE bapi_msg.
        BREAK-POINT.
        CLEAR: lcl_eventhandler=>ms_sel_row.
        ms_sel_row = e_row_id.
        READ TABLE gt_outtab INTO ls_outtab INDEX e_row_id-index.
        CONCATENATE 'Selected Sales Order = ' ls_outtab-vbeln ' / '
                                              ls_outtab-posnr
          INTO ld_msg.
          message i398(00) with ld_msg.
        " Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'INSERT'
    *      IMPORTING
    *        rc       =
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    PARAMETERS:
      p_vkorg      TYPE vkorg  DEFAULT '0001'  OBLIGATORY.
    START-OF-SELECTION.
    **  SELECT  * FROM  vbak INTO CORRESPONDING FIELDS OF TABLE gt_outtab
    **    UP TO 200 ROWS
    **         WHERE  vkorg = p_vkorg.
      SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE gt_outtab
        UP TO 100 ROWS.
      PERFORM init_controls.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog.
      PERFORM set_layout_and_variant.
      PERFORM set_sorting.
      " Register EDIT event
      CALL METHOD go_grid->register_edit_event
        EXPORTING
          i_event_id = cl_gui_alv_grid=>mc_evt_enter
        EXCEPTIONS
          error      = 1
          OTHERS     = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      SET HANDLER:
        lcl_eventhandler=>handle_data_changed  FOR go_grid,
        lcl_eventhandler=>handle_hotspot_click FOR go_grid.
    * Link the docking container to the target dynpro
      gd_repid = syst-repid.
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = gd_repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    * Display data
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          i_bypassing_buffer            = abap_true
          is_variant                    = gs_variant
          i_save                        = 'A'
    *      i_default                     = 'X'
          is_layout                     = gs_layout
    *      is_print                      =
    *      it_special_groups             =
    *      it_toolbar_excluding          =
    *      it_hyperlink                  =
    *      it_alv_graphics               =
    *      it_except_qinfo               =
    *      ir_salv_adapter               =
        CHANGING
          it_outtab                     = gt_outtab
          it_fieldcatalog               = gt_fcat
          it_sort                       = gt_sort
    *      it_filter                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  CALL METHOD go_grid->refresh_table_display
    ***        EXPORTING
    ***          IS_STABLE      =
    ***          I_SOFT_REFRESH =
    **    EXCEPTIONS
    **      finished       = 1
    **      OTHERS         = 2.
    **  IF sy-subrc ne 0.
    ***       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    ***                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    **  ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN 'INSERT'.
          PERFORM insert_row.
        WHEN OTHERS.
          " Check for changed data at the frontend (= grid control)
          CALL METHOD go_grid->check_changed_data( ).
      ENDCASE.
      CALL METHOD go_grid->refresh_table_display
    *    EXPORTING
    *      IS_STABLE      =
    *      I_SOFT_REFRESH =
        EXCEPTIONS
          finished       = 1
          OTHERS         = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  INIT_CONTROLS
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM init_controls .
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent = cl_gui_container=>screen0
          ratio  = 90
        EXCEPTIONS
          others = 6.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking->set_extension
        EXPORTING
          extension  = 99999
        EXCEPTIONS
          cntl_error = 1
          OTHERS     = 2.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid
        EXPORTING
          i_parent = go_docking
        EXCEPTIONS
          others   = 5.
      IF sy-subrc NE 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " INIT_CONTROLS
    *&      Form  BUILD_FIELDCATALOG
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog.
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'VBAP'  " 'VBAK'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        EXCEPTIONS
          inconsistent_interface       = 1
          program_error                = 2
          OTHERS                       = 3.
      IF sy-subrc NE 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    **  LOOP AT gt_fcat INTO ls_fcat.
    **    CASE ls_fcat-fieldname.
    **      WHEN 'VBELN'  OR
    **           'ERDAT'  OR
    **           'ERZET'  OR
    **           'ERNAM'  OR
    **           'AUART'  OR
    **           'NETWR'  OR
    **           'WAERK'.
    **        CONTINUE.
    **      WHEN OTHERS.
    **        ls_fcat-no_out = abap_true.
    **    ENDCASE.
    **    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
    **  ENDLOOP.
    * Only non-key fields are editable
    **  ls_fcat-edit = 'X'.
    **  MODIFY gt_fcat FROM ls_fcat
    **    TRANSPORTING edit
    **    WHERE ( fieldname NE space ).
      ls_fcat-hotspot = abap_true.
      MODIFY gt_fcat FROM ls_fcat
        TRANSPORTING hotspot
        WHERE ( fieldname = 'AUART'   OR
                fieldname = 'VBELN' ).
    **  DELETE gt_fcat FROM 15 TO 99.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    *&      Form  SET_LAYOUT_AND_VARIANT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_layout_and_variant .
      CLEAR: gs_layout,
             gs_variant.
      gs_layout-cwidth_opt = abap_true.
      gs_variant-report = syst-repid.
      gs_variant-handle = 'GRID'.
    ENDFORM.                    " SET_LAYOUT_AND_VARIANT
    *&      Form  SET_SORTING
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM set_sorting .
    * define local data
      DATA: ls_sort   TYPE lvc_s_sort.
      REFRESH: gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'VBELN'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
      CLEAR: ls_sort.
      ls_sort-spos = 1.
      ls_sort-fieldname = 'POSNR'.
      ls_sort-up = abap_true.
      APPEND ls_sort TO gt_sort.
    ENDFORM.                    " SET_SORTING
    *&      Form  INSERT_ROW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM insert_row .
    * define local data
      DATA: ls_outtab   TYPE ty_s_outtab,
            ld_order    TYPE vbeln.
      READ TABLE gt_outtab INTO ls_outtab
                           INDEX lcl_eventhandler=>ms_sel_row-index.
      ld_order = ls_outtab-vbeln.
      " Find last item of sales order
      LOOP AT gt_outtab INTO ls_outtab
                        WHERE ( vbeln = ld_order ).
      ENDLOOP.
      " Create next item:
      add 10 to ls_outtab-posnr.
      " NOTE: added at the end of the list
      APPEND ls_outtab TO gt_outtab.
      " NOTE: insert new row AFTER selected row => works, too
    **  INSERT ls_outtab INTO gt_outtab
    **                   INDEX lcl_eventhandler=>ms_sel_row-index.
    ENDFORM.                    " INSERT_ROW

  • Enable Dynamic Sorting in Tabular Report

    Hi All,
    I have 100's of reports and i need to enable dynamic sorting for the columns in tabular report.
    Just wanted to know which tag i need to put in advanced tab of the report where i can set the XML.
    Please guide

    Thanks Krishna..
    I have done that for one report and i want to do it for the remaining 99 reports.As i have to run each and every report and then enable dyamic sorting which is pain...so i was just thinking if there is any property in advanced tab of the tabular report where i can do it and then set the XML for the reports

  • ALV sort any column in fieldcatalog by default

    hi all
    i have developed report in ALV format. i have total 8 columns
    normally we sort any column in the output only.
    i have requirement that instead of sorting manually any column say Material no
    it should be sorted by default when user execute the report. he should not do manually by pressing Sort button in
    alv list
    give code for refrence

    hi u can use the IT_SORT parameter of the FM REUSE_ALV_GRID_DISPLAY for this purpose.
    specify the fields for which u need to sort ur table and the sorting order
    ( I have jst given da example for one field but this it_sort table can hav more than one fields.)
      gs_alv_sort-spos = 1.
      gs_alv_sort-fieldname = 'VKORG'.            " Sales Org
      gs_alv_sort-up = 'X'.                       " Ascending
      APPEND gs_alv_sort TO gt_alv_sort.
    then pass this internal table to teh alv fm
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         I_CALLBACK_PROGRAM                = wf_repid
       I_CALLBACK_HTML_TOP_OF_PAGE       = 'HTML_TOP_OF_PAGE'
       I_BACKGROUND_ID                   = 'WEAVE_BACKGROUND'
       IS_LAYOUT                         = gs_alv_layout
       IT_FIELDCAT                       =  gt_alv_fieldcat
       IT_SORT                           =  gt_alv_sort
        TABLES
          T_OUTTAB                          = it_output
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2

Maybe you are looking for