‎2010 Feb 08 2:11 PM
HI All ,
i need to create program search from table (roles) that run exactly like the outlook
person search .
Letu2019s assume we have three roles in table Zrole_db_table : abc, acc, adc
If I type u2018abu2019 ïƒ the method should return abc since only one match exists
If I type u2018au2019 ïƒ the method should return all three roles but the
If I type u2018abcu2019 ïƒ the method should return abc due to the exact match
What is the best way to do it ,performance is very important ?
Regards
James
Edited by: James Herb on Feb 8, 2010 3:34 PM
‎2010 Feb 08 2:47 PM
Hi,
Simple select does this job.
DATA: l_role TYPE string.
l_role = 'ab*' or 'a*' or 'abc* (As per your input).
SELECT ...
INTO TABLE....
FROM Zrole_db_table
WHERE type LIKE l_role.
Performance completely depends on the number of entries in your table.
Thanks,
Vinod.
‎2010 Feb 08 2:47 PM
Hi,
Simple select does this job.
DATA: l_role TYPE string.
l_role = 'ab*' or 'a*' or 'abc* (As per your input).
SELECT ...
INTO TABLE....
FROM Zrole_db_table
WHERE type LIKE l_role.
Performance completely depends on the number of entries in your table.
Thanks,
Vinod.
‎2010 Feb 08 3:23 PM
HI Vinod ,
Thanks this is not exactly the issue .
assume that we have 4 roles like
A
ABC
ABD
ABCD
And user request ABC
he will get ABC and ABCD but he should get just ABC
How you suggest to handle it ?
Regards
James
Edited by: James Herb on Feb 8, 2010 4:56 PM
‎2010 Feb 08 4:20 PM
Hello James,
How about trying this way:
PARAMETERS: P_ROLE TYPE CHAR30. "Use the Data Element for role (i am not infront of an SAP system)
DATA:
R_RNG TYPE STANDARD TABLE OF SELOPT,
W_RNG TYPE SELOPT.
W_RNG-SIGN = 'I'.
W_RNG-OPTION = 'CP'.
CONCATENATE P_ROLE '*' INTO W_RNG-LOW.
APPEND W_RNG TO R_RNG.
SELECT * FROM <AGR* table> INTO TABLE ITAB WHERE ROLE IN R_RNG.
IF SY-SUBRC = 0.
SORT ITAB BY ROLE.
READ TABLE ITAB INTO WA WITH KEY ROLE = P_ROLE BINARY SEARCH.
IF SY-SUBRC = 0.
" You have the single Role you need. In this case you will get ABC :)
ENDIF.
ENDIF.Hope i am clear.
BR,
Suhas