Skip to Content
avatar image
Former Member

Sorting Option in Table Control

Hi Guru's,

ย  I have a requirement that to add Sorting option in my Table Control Wizard .I added code but in my table control I am unable to select any column .This is in editable mode also.I am facing this problem and i go through the websites .I didn't get solution.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Jun 27, 2012 at 07:11 AM

    There is no built-in sort option in table control, you have to code the SORT yourself by reacting to selectio of column headers and your own defined function code (eg. adding two icons on the dynpro for sort ascending/descending).

    PBO :

    In the defined Table control (CONTROLS, structure CXTAB_CONTROL) there is a subfield COL_SEL_MODE to enable column selection (0-no selection (default) 1-one column 2-any number ofย  columns)

    PAI :

    Loop at columns (subfield COLS internal table, records structure CXTAB_COLUMN subfield SELECTED) to find which columns where selected and execute a dynamic SORT



    Add comment
    10|10000 characters needed characters exceeded

    • (You could consider using ALV grid, where those functions are built-in)

      The filtering is a little harder.๐Ÿ˜ญ

      Layout :

      For filter input, add a new icon with function code (e.g.ICON_FILTER)

      PAI :

      You could use a FM like FREE_SELECTIONS_DIALOG to generate a "selection-screen" dialog, then FREE_SELECTIONS_RANGE_2_WHERE to convert into ranges

      PBO :

      You should consider filtering record between two internal tables - the total one and the filtered one using the generated ranges. (and in PAI you will have to map the update from the filtered/displayed itab  to the full itab)

      The search tool is comparatively easy, try to solve it yourself ๐Ÿ˜‰



  • Jun 27, 2012 at 06:43 AM


    In the table control properties there are checkboxes about column and line select-ability. Please check that the correct checkboxes are selected and reply.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 27, 2012 at 07:19 AM


    For selecting column :

    you have to set this column property and for your sorting give 2 sort up and sort down button and write logic for function code in PAI -

    READ TABLE I<table_contol_name>-cols INTO cols WITH KEY selected = 'X'.
         IF sy-subrc = 0.
           SORT <Internal_table>_name STABLE BY (cols-SCREEN-name+17) ASCENDING. " OR DESCENDING
           cols-selected = ' '.
           MODIFY <table_contol_name>-cols FROM cols INDEX sy-tabix.

    Here i've used 17 for offset because my internal table name is 16character long + one character for '-'.

    Add comment
    10|10000 characters needed characters exceeded

    • Hiii shek ,

                         I have one new idea just try it ...... all the fields which you have in your internal table same field put on your one new modal dialog screen ok and same as search button give two more button filter and delete filter - put both buttons on main screen (but delete filter button should not be activate until filter is set ) on click event of filter button check whether the column is selected or not if yes - than get column name as i mentioned above by offset than in PBO do loop on screen and rest of all screen field make hide and show only selected field than on POV use F4IF_INT_TABLE_VALUE_REQUEST FM for getting F4 help by internal table values , once you select value from F4 List and press ok button delete all  record  from internal table which not come into filter criteria and show results on screen . before deleting make sure your original internal table should be copied into same new internal table because when you press delete filter button than on than buttons click event you can get the original records back ๐Ÿ˜Š

      my solution was different ....Try this  one .... and let me know if you found any problem ,

      Regards ,