Skip to Content
avatar image
Former Member

table control find button

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    Nov 11, 2010 at 11:46 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 22, 2010 at 06:35 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 11, 2010 at 10:11 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 22, 2011 at 02:25 PM

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

    Rob

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 28, 2011 at 10:59 AM

    Hi,

    Thanks for ur help my Problem Solved. . . .

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 28, 2011 at 11:15 AM

    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

    Add comment
    10|10000 characters needed characters exceeded