2011 Dec 20 4:30 PM
Hi all,
I am developing a search utility to arrange a internal table based on ranking ie the internal table should be arranged
based on my search term.
I will have 2 input parameters
1st Input parameter (structure) will have 2 fields "FIELDNAME" "SEARCH STRING" (ITAB1)
2nd Input parameter will be internal table which needs to be searched on.(ITAB2)
Since this search function will be used in many programs i c'nt have defined structure of my internal table
Something like this:
loop at ITAB2.
FIND ALL OCCURRENCES OF ITAB1-SEARCH STRING
IN ITAB2-FIELDNAME (Field name should be the one which is in ITAB1)
How can i get the fieldname which is given as input in my find all occurrence statement??
What kind of structure should be my internal table more of generic form ??
Any pointers will be helpful
Thanks
Bhanu
2011 Dec 20 6:47 PM
If you wanted to find the value in a specific field of the table (and the calling program knows the field it's looking in) you could do the following:
FUNCTION y_test_function.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(INPUT_TAB) TYPE ANY TABLE
*" REFERENCE(FIELDNAME) TYPE STRING
*" REFERENCE(SEARCH_VALUE) TYPE STRING
*"----------------------------------------------------------------------
FIELD-SYMBOLS: <line> TYPE ANY,
<field> TYPE ANY.
DATA: results TYPE match_result_tab.
LOOP AT input_tab ASSIGNING <line>.
ASSIGN COMPONENT fieldname OF STRUCTURE <line> TO <field>.
FIND ALL OCCURRENCES OF search_value IN <field> IGNORING CASE RESULTS results.
ENDLOOP.
ENDFUNCTION.
Hi all,
I am developing a search utility to arrange a internal table based on ranking ie the internal table should be arranged
based on my search term.
I will have 2 input parameters
1st Input parameter (structure) will have 2 fields "FIELDNAME" "SEARCH STRING" (ITAB1)
2nd Input parameter will be internal table which needs to be searched on.(ITAB2)
Since this search function will be used in many programs i c'nt have defined structure of my internal table
Something like this:
loop at ITAB2.
FIND ALL OCCURRENCES OF ITAB1-SEARCH STRING
IN ITAB2-FIELDNAME (Field name should be the one which is in ITAB1)
How can i get the fieldname which is given as input in my find all occurrence statement??
What kind of structure should be my internal table more of generic form ??
Any pointers will be helpful
Thanks
Bhanu
2011 Dec 20 6:34 PM
FIND ALL OCCURRENCES OF pattern
IN TABLE itab table_range
The statement FIND doesn't find the string in any particular column, rather it find the text in entire row.
In your case, you can create a temp table with only a column. Populate that with the data from ITAB2 and use above statement to find the text.
Regards,
Naimesh Patel
2011 Dec 20 6:45 PM
Hi Bhanu ,
I understood like this , we don't know the structure of itab2 , so how can we check with respect to ITab2,
for this so like this
create data element with type any then assign itab2-field to that type any data element.
data : l_var type any.
loop at itab2.
assign itab2-field to <l_val>
chceck with that <lavl>
Regards
Siva
2011 Dec 20 6:47 PM
If you wanted to find the value in a specific field of the table (and the calling program knows the field it's looking in) you could do the following:
FUNCTION y_test_function.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(INPUT_TAB) TYPE ANY TABLE
*" REFERENCE(FIELDNAME) TYPE STRING
*" REFERENCE(SEARCH_VALUE) TYPE STRING
*"----------------------------------------------------------------------
FIELD-SYMBOLS: <line> TYPE ANY,
<field> TYPE ANY.
DATA: results TYPE match_result_tab.
LOOP AT input_tab ASSIGNING <line>.
ASSIGN COMPONENT fieldname OF STRUCTURE <line> TO <field>.
FIND ALL OCCURRENCES OF search_value IN <field> IGNORING CASE RESULTS results.
ENDLOOP.
ENDFUNCTION.
2011 Dec 20 8:12 PM
Hi Bryan,
Thanks for your reply i think your solution is close to what i am looking for:
My only concern is FIELDNAME will be a internal table which will have entries with table field names.
How will i use the below logic there?
2011 Dec 20 8:18 PM
Same idea I would think - just put the "assign component" line inside a loop on your field name parameter.
2011 Dec 20 8:28 PM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |