11-13-2007 2:12 PM
HI,
i have a program that do search for string in some table in text field ,and the program is running OK when the user do search for one word in string.
the problem is when i do search for <b>2 or more</b> word despite that i have them in table the search is not successful. (nothing found).
e.g.
if i search word <u>Public</u> i get in ser_tab :
Public
Public Health
Public Accountants
...
but if id the search for :Public Health
i dont get anything
how i can solve this problem?
this is the code
"ql_text is the input field for the user
CONCATENATE '%' ql_text '%' INTO v_pattern.
SELECT qualifictn txtmd
FROM /bi0/tqualifictn
INTO TABLE ser_tab
WHERE langu = sy-langu
AND txtmd LIKE v_pattern
AND datefrom LE sy-datum
AND dateto GE sy-datum.
Regards
11-13-2007 4:14 PM
Hi,
Interesting question ... please try this.
DATA: INPUT(25) VALUE 'Our Team Management'.
DATA: CURRENT_CHAR(1) TYPE C,
TOTAL_LEN TYPE I,
CURRENT_POSITION TYPE I.
DATA: FLAG(1).
WRITE: / INPUT(1).
TRANSLATE INPUT TO LOWER CASE.
TOTAL_LEN = STRLEN( INPUT ).
CURRENT_POSITION = 1.
WHILE CURRENT_POSITION < TOTAL_LEN.
CURRENT_CHAR = INPUT+CURRENT_POSITION(1).
IF FLAG = 'X'.
CLEAR FLAG.
TRANSLATE CURRENT_CHAR TO UPPER CASE.
WRITE: / CURRENT_CHAR.
ENDIF.
IF CURRENT_CHAR EQ SPACE.
FLAG = 'X'.
ENDIF.
ADD 1 TO CURRENT_POSITION.
ENDWHILE.
Regards,
Ferry Lianto
11-13-2007 2:38 PM
Hi,
Please try this.
CONCATENATE '%' ql_text '%' INTO v_pattern.
CONDENSE V_PATTERN NO-GAPS. "Add here
SELECT qualifictn txtmd
FROM /bi0/tqualifictn
INTO TABLE ser_tab
WHERE langu = sy-langu
AND txtmd LIKE v_pattern
AND datefrom LE sy-datum
AND dateto GE sy-datum.
Regards,
Ferry Lianto
11-13-2007 2:50 PM
hi ferry
thanks for your Replay!
i try exactly like u tell and i get the 2 words without space but it still dont find the
words in the table
i have in table text like <u>Health System</u> and after i try with not gaps i get
<u>HealthSystem</u> but the subrc after the select is 0.
how i solve it?
Regards
11-13-2007 2:45 PM
Hi,
Also try to use ranges.
RANGES: r_pattern FOR apqi-groupid.
CONCATENATE '*' ql_text '*' INTO r_pattern-low.
r_pattern-sign = 'I'.
r_pattern-option = 'CP'.
append r_pattern.
SELECT qualifictn txtmd
FROM /bi0/tqualifictn
INTO TABLE ser_tab
WHERE langu = sy-langu
AND txtmd IN r_pattern
AND datefrom LE sy-datum
AND dateto GE sy-datum.
Regards,
Ferry Lianto
11-13-2007 2:52 PM
11-13-2007 2:58 PM
hi Ferry
i try it exactly and i get in table r_pattern-low "ICPalthsystem"
when i search for health Health system
what i do wrong?
Best Regards
11-13-2007 2:53 PM
Hi,
You can use ranges to extract data. Define range and use the same in select.
ranges : r_txtmd for /bi0/tqualifictn-txtmd.
CONCATENATE '' ql_text '' INTO v_pattern.
r_txtmd-sign = 'I'.
r_txtmd-option = 'EQ'.
r_txtmd-low = v_pattern.
append r_txtmd.
SELECT qualifictn txtmd
FROM /bi0/tqualifictn
INTO TABLE ser_tab
WHERE langu = sy-langu
AND txtmd in r_txtmd
AND datefrom LE sy-datum
AND dateto GE sy-datum.
Please note that the above method is case sensitive search. Even a single space in supplied value may create problem.
Regards,
Naren
11-13-2007 2:55 PM
Hi,
Sorry ... please try to remove CONDENSE statement.
*CONDENSE V_PATTERN NO-GAPS.
OR
*CONDENSE R_PATTERN-LOW NO-GAPS.
Also you may want to tranlate QL_TEXT to an upper and lower case using FM STRING_UPPER_LOWER_CASE.
Regards,
Ferry Lianto
11-13-2007 3:00 PM
Hi,
Please try this again.
RANGES: r_pattern FOR apqi-groupid.
CONCATENATE '*' ql_text '*' INTO r_pattern-low.
r_pattern-sign = 'I'.
r_pattern-option = 'CP'.
append r_pattern.
SELECT qualifictn txtmd
FROM /bi0/tqualifictn
INTO TABLE ser_tab
WHERE langu = sy-langu
AND txtmd IN r_pattern
AND datefrom LE sy-datum
AND dateto GE sy-datum.
Regards,
Ferry Lianto
11-13-2007 3:12 PM
hi Ferry
i try like that but its not working.
take a look maybe u can help.
MOVE ql_text TO v_pattern2. "Upper case
TRANSLATE ql_text TO UPPER CASE.
TRANSLATE ql_text TO LOWER CASE.
MOVE ql_text TO v_pattern3. "Lower case
MOVE ql_text(1) TO f_letter.
TRANSLATE f_letter TO UPPER CASE.
MOVE f_letter TO ql_text(1). "for capital lattrs
CALL FUNCTION 'SWA_STRING_TO_UPPERCASE'
EXPORTING
input_expression = ql_text
preserve_existing_capitals = ' '
IMPORTING
output_expression = ql_text
EXCEPTIONS
expression_truncated = 1
OTHERS = 2.
* CONCATENATE '%' ql_text '%' INTO v_pattern . "Capital latters
** CONDENSE v_pattern NO-GAPS.
* CONCATENATE '%' v_pattern2 '%' INTO v_pattern2. "Upper case
** CONDENSE v_pattern2 NO-GAPS.
* CONCATENATE '%' v_pattern3 '%' INTO v_pattern3. "Lower case
** CONDENSE v_pattern3 NO-GAPS.
CONCATENATE '*' ql_text '*' INTO r_pattern-low. "Capital latters
r_pattern-sign = 'I'.
r_pattern-option = 'CP'.
APPEND r_pattern.
CONCATENATE '*' v_pattern2 '*' INTO r_pattern-low. "Upper case
r_pattern-sign = 'I'.
r_pattern-option = 'CP'.
APPEND r_pattern.
CONCATENATE '*' v_pattern3 '*' INTO r_pattern-low. "Lower case
r_pattern-sign = 'I'.
r_pattern-option = 'CP'.
APPEND r_pattern.
SELECT qualifictn txtmd
FROM /bi0/tqualifictn
INTO TABLE ser_tab
WHERE langu = sy-langu
AND txtmd IN r_pattern
AND datefrom LE sy-datum
AND dateto GE sy-datum.
Best Regards
11-13-2007 3:24 PM
hi Ferry
this is what i have in table r_pattern and still the subrc = 4.
1 I CP *Public health*
2 I CP *PUBLIC HEALTH*
3 I CP *public health*
Best regards
11-13-2007 3:26 PM
Hi,
Please try this .. it works fine for me.
RANGES: R_PATTERN FOR /BI0/TQUALIFICTN-TXTMD.
DATA: EXPRESSION LIKE SWAEXPDEF-EXPR.
MOVE QL_TEXT TO EXPRESSION.
CALL FUNCTION 'SWA_STRING_TO_UPPERCASE'
EXPORTING
INPUT_EXPRESSION = EXPRESSION
PRESERVE_EXISTING_CAPITALS = ' '
CAPITALIZE_AFTER_SPACE = 'X'
LANGUAGE = SY-LANGU
IMPORTING
OUTPUT_EXPRESSION = EXPRESSION
EXCEPTIONS
EXPRESSION_TRUNCATED = 1
OTHERS = 2.
CONCATENATE '*' EXPRESSION '*' INTO R_PATTERN-LOW.
R_PATTERN-SIGN = 'I'.
R_PATTERN-OPTION = 'CP'.
APPEND R_PATTERN.
SELECT QUALIFICTN TXTMD
FROM /BI0/TQUALIFICTN
INTO TABLE SER_TAB
WHERE LANGU = SY-LANGU
AND TXTMD IN R_PATTERN
AND DATEFROM LE SY-DATUM
AND DATETO GE SY-DATUM.
Regards,
Ferry Lianto
11-13-2007 3:33 PM
hi Ferry
i think i now what is the problem
in the text i have the 2 words in capital latter's
like
<b>Team Management
Health System</b>
and when i do a search for words in table that in upper case like
<b>JAVA SCRIPT</b>
<i><b>i find it</b></i>
my question how i do search for two words that both are in capital letters?
Best Regards
11-13-2007 3:46 PM
hi Ferry
i think that the best way to solve it is to take the string and divide it for to words and get all the possibility (capital ,upper...) and then concatenate them to one string'
but how i can separate the string for two words after the space?
Best Regards
11-13-2007 4:14 PM
Hi,
Interesting question ... please try this.
DATA: INPUT(25) VALUE 'Our Team Management'.
DATA: CURRENT_CHAR(1) TYPE C,
TOTAL_LEN TYPE I,
CURRENT_POSITION TYPE I.
DATA: FLAG(1).
WRITE: / INPUT(1).
TRANSLATE INPUT TO LOWER CASE.
TOTAL_LEN = STRLEN( INPUT ).
CURRENT_POSITION = 1.
WHILE CURRENT_POSITION < TOTAL_LEN.
CURRENT_CHAR = INPUT+CURRENT_POSITION(1).
IF FLAG = 'X'.
CLEAR FLAG.
TRANSLATE CURRENT_CHAR TO UPPER CASE.
WRITE: / CURRENT_CHAR.
ENDIF.
IF CURRENT_CHAR EQ SPACE.
FLAG = 'X'.
ENDIF.
ADD 1 TO CURRENT_POSITION.
ENDWHILE.
Regards,
Ferry Lianto
11-13-2007 4:27 PM
hi Ferry
Thanks u are Great!!! i understand your logic and solved the problem .
Thanks!!!
Best Regards