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: 

table control find button

Former Member
0 Kudos

I had used find button in my screen painter. the below code is working fine when i give material number input.

my given material nuber matches with more number of records in my internal table but in my top of line of table control

its showing only one record. i want to display all records matches in order from top of line of table control

please provide me some solution.

code:

WHEN 'FIND'.

REFRESH tab.

clear ok_code.

TAB-TABNAME = 'MARA'.

TAB-FIELDNAME = 'MATNR'.

TAB-VALUE = ''.

APPEND TAB.

CALL FUNCTION 'POPUP_GET_VALUES'

EXPORTING

POPUP_TITLE = 'FIND'

START_COLUMN = '5'

START_ROW = '5'

TABLES

FIELDS = TAB.

LOOP AT TAB WHERE VALUE IS NOT INITIAL.

READ TABLE ITAB WITH KEY MATNR = TAB-VALUE.

IF SY-SUBRC = 0.

TBL_CTRL_0112-TOP_LINE = sy-tabix.

ENDIF.

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

i want to display all records matches in order from top of line of table control

If you are providing serach for some fixed fields then you can just do a sort on the internal table based on the searched field and use your existing logic. If the search fields are not fixed then you can use the logic below


DATA: itab    TYPE TABLE OF string,
      lf_string type string,
      lf_pattern type string,
      results TYPE match_result_tab.

lf_string = 'AA'.
append lf_string to itab.
lf_string = 'AC'.
append lf_string to itab.
lf_string = 'BB'.
append lf_string to itab.
lf_string = 'AC'.
append lf_string to itab.
lf_string = 'ABAC'.
append lf_string to itab.

lf_pattern = 'AC'.

FIND ALL OCCURRENCES OF lf_pattern
  IN TABLE itab
  RESULTS results.

The table results will hold all the indexes of the search pattern.

Now when the user clicks find next read the index from results and place it as the top_line of the table control.

6 REPLIES 6

Former Member
0 Kudos

Hi,

Why don't you have a separate button 'Find Next' which will take you to the next record that matches your find? Or code your FIND in such a way that it displays all the matched records in the beginning followed by the others.

kesavadas_thekkillath
Active Contributor
0 Kudos

i want to display all records matches in order from top of line of table control

If you are providing serach for some fixed fields then you can just do a sort on the internal table based on the searched field and use your existing logic. If the search fields are not fixed then you can use the logic below


DATA: itab    TYPE TABLE OF string,
      lf_string type string,
      lf_pattern type string,
      results TYPE match_result_tab.

lf_string = 'AA'.
append lf_string to itab.
lf_string = 'AC'.
append lf_string to itab.
lf_string = 'BB'.
append lf_string to itab.
lf_string = 'AC'.
append lf_string to itab.
lf_string = 'ABAC'.
append lf_string to itab.

lf_pattern = 'AC'.

FIND ALL OCCURRENCES OF lf_pattern
  IN TABLE itab
  RESULTS results.

The table results will hold all the indexes of the search pattern.

Now when the user clicks find next read the index from results and place it as the top_line of the table control.

faisal_altaf2
Active Contributor
0 Kudos

Hi, All

Its too late but i think it will help the people who will find for the similar option. Check out my Blog [Filter and Search in Table Control|http://sdnabaper.blogspot.com/2010/11/filter-and-search-in-table-control.html]

Thanks and Regards,

Faisal

Former Member
0 Kudos

If you want to search a particular column for a string, you will have to parse the column names. of the table control.

Rob

Former Member
0 Kudos

Hi,

Thanks for ur help my Problem Solved. . . .

Former Member
0 Kudos

Hi,

Can we Hi-Lite the Perticular Row what we Searched and also Can i have the code for Next button also

So that if the record exist with same Name So that i stops at Next row of same Name.

Thanks&Regards

Neetha