Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting Option in Table Control

Former Member
0 Kudos

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.

Regards

Shek

18 REPLIES 18

laurent_fournier2
Contributor
0 Kudos

Hi,

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

0 Kudos

Are you referring to below settings? I can see the options to hide (mark invisible) fields. But there is no option to sort them.

I doubt it can be done in table control.

0 Kudos

Hi,

I didn't get you.Will you plz explain me in detail

Regards

Shek

0 Kudos

Hi ,

I got it .Can you plz tell me filter option ,search option also.

Regards

Shek

0 Kudos

Hi Laurent,

I was working now.Can you plz tell me filter and search option also.

Regards

Shek

0 Kudos

As with sorting functionality, filtering and search requires you to program the functions manually.

Add the pushbuttons and create coding for eash function depending what you want to do.

But, since you want all this functionality, why you are not using alv instead of table control ?

0 Kudos

Hi ,

I suggested my user for ALV but they don't want to use it .That is the problem

Regards

Shek

0 Kudos

OK, so in this case , you must code all the appropriate functions.

Regards.

raymond_giuseppi
Active Contributor

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

Regards,

Raymond

0 Kudos

Hi Raymond ,

  I added code for sorting .It is working .Now I need filtering and search option.

Regards

Shek

0 Kudos

(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

Regards,

Raymond

Aashish28
Contributor
0 Kudos

Hiiii,

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.
     ENDIF.

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

Former Member
0 Kudos

Hi ,

I is working fine . Now I want searchng & filtering option

Regards

Shek

0 Kudos

Hiiii ,

            For Search option on your main screen give a search button ... on click event call modal dialog box screen - and you can make a modal dialog box screen give suitable field which you want to use as a search option  and on modal dialog box screen made 2 buttons ok and cancel

on ok button write logic ,

READ TABLE <internal table> INTO <workarea> WITH KEY <as you given in modal screen>.
    
     IF sy-subrc = 0 .


       SET SCREEN 0.


       <table control name>-current_line = " Write
your own logic
      <table control name>-top_line =. "Write your own logic


     ELSE.

       MESSAGE 'No record found ' TYPE 'S'.

     ENDIF.

Same as for filer also use delete on internal table as per your filter criteria and  show it on <table_control> . " For filter you have to use some screen concept also

Try to apply your own logic also .............i have given hints .....


Former Member
0 Kudos

Hi Ashish,

Here what logic I have to write

    <table control name>-current_line = " Write your own logic

      <table control name>-top_line =. "Write your own logic

Regards

Shek

0 Kudos

Hiiii ,

         In my Case for putting my search result on top I had used serial no. in my internal table so when my read table performs and if i got successful search result than i also got one serial number which i had used for putting result to top of row in table control.

      <table control name>-current_line = wa-srno . " Write your own logic

      <table control name>-top_line =. wa-srno . "Write your own logic

As per you requirement you can use your one   and filtering is tricky and little harder so just apply screen logic for that read my previous comments .

Former Member
0 Kudos

Hi Ashish,

Searching option was solved . Only filter option is remaining.If you have any logic plz provide.

Regards

Shek

0 Kudos

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 ,

Ashish