Application Development and Automation 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: 
Read only

Need help in search program

Former Member
0 Likes
462

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

1 ACCEPTED SOLUTION
Read only

vinod_vemuru2
Active Contributor
0 Likes
437

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.

3 REPLIES 3
Read only

vinod_vemuru2
Active Contributor
0 Likes
438

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.

Read only

0 Likes
437

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

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
437

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