on 02-20-2014 6:32 AM
Hi Experts,
I'm using an OVS search help for my custom field in ztable. Almost every thing is fine expect searching with '*'. I have implemented the below logic, but it is not working in search help.
REPLACE ALL OCCURRENCES OF '*' IN <ls_query_params>-UNIQUENO WITH '%'.
SELECT UNIQUENO
INTO TABLE lt_select_list
FROM ZWORKFL0W_TB_RK.
Have searched a lot and all followed the same logic, but it's not working for me:(
Please let me know, am I missing anything.
With Regards,
RAM.
Hi,
You might be getting all records from table beacuse you have not set where condition
Please modify the select query as below
SELECT UNIQUENO
INTO TABLE lt_select_list
FROM ZWORKFL0W_TB_RK
Hope this helps you.
Regards,
Rama
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rama,
I was waiting for your reply:)
Already I had used the same statement in my select query, but it throws an error during code check. So I just left it. See the below error.
" The pattern used with a LIKE condition can only be specified in a type
C field. not in a field of type "%_#D4407". of type "%_#D4407". "
Please let me know, how can I proceed further.
With Regards,
Ram.
Hi RK,
The field UNIQUENO should be of type C.
I would suggest you other option.
- Select all records from your table into an internal table
SELECT UNIQUENO
INTO TABLE lt_select_list
FROM ZWORKFL0W_TB_RK.
- Do not replace the * with '%', keep as it is
- Delete the records from internal table lt_select_list as below
data lv_pattern type string.
lv_pattern = <ls_selection>-uniqueno.
DELETE lt_select_list WHERE uniqueno NP lv_pattern.
Now, the internal table contains only records which mataches with <ls_selection>-uniqueno.
Hope this helps you.
Regards,
Rama
Rama,
Sorry, but my requirement is, I need to display all the records of UNIQUENO(TYPE NUM) from Ztable and ofcourse all the values are coming in F4 help.
And additionally I prefers to search the records with '*', as in future the number of records would be in lakhs.
But to your code, I'll get only one record with the searched UNIQUENO which will not be good for me.
So, I need to display all those records from ztable as well as I want to search the UNIQUENO with '*' in search option.
Please correct me, if I were wrong.
BR,
RAM.
Hi RK,
If UNIQUENO is of type numeric and need wild cards search, then there is a problem
Let me explain the problem as below
- now let us say we have UNIQUENO of type NUMC5
- When we save data to table unique no.s are stored like below
00001
00011
00002
00221
00222
- if we want to search a record with 1*, we never get a record from table because, we need to tell the system how many zero we need to put in before the number i.e. 000001* or 0001* ?
- So, we need to take care of preceeding zeros to get search result
Okay, let us look the steps involved to get wild card search done for your requirement
- Create structure field <ls_selection>-uniqueno is of type STRING in ovs
- Collect the uniqueno into a local variable as below
data lv_pattern type string.
lv_pattern = <ls_selection>-uniqueno.
- Replace all occurance of '*' with '%'
REPLACE ALL OCCURRENCES OF '*' IN lv_pattern WITH '%'.
if lv_pattern is initial. " nothing is given, need to get all records
lv_pattern = '%'.
endif.
- Select data from table as below
SELECT UNIQUENO
INTO TABLE lt_select_list
FROM ZWORKFL0W_TB_RK
WHERE uniqueno LIKE lv_pattern.
Now, lt_select_list should contains the filterd data
Hope this helps you.
Regards,
Rama
Hi Rama,
Thanks a lot. It's done. The think id did the mistake is, directly I assigened the value from field.
But now I passed it to a variable of CHAR10 type. See the below code FYR.
DATA lv_pattern TYPE char10.
lv_pattern = <ls_query_params>-uniqueno.
IF lv_pattern CA '*'.
REPLACE ALL OCCURRENCES OF '*' IN lv_pattern WITH '%'.
SELECT uniqueno
INTO TABLE lt_select_list
FROM zworkfl0w_tb_rk WHERE uniqueno LIKE lv_pattern.
* ORDER BY uniqueno ASCENDING.
ELSEIF lv_pattern IS NOT INITIAL.
SELECT uniqueno
INTO TABLE lt_select_list
FROM zworkfl0w_tb_rk WHERE uniqueno = lv_pattern.
ELSE.
SELECT uniqueno
INTO TABLE lt_select_list
FROM zworkfl0w_tb_rk.
ENDIF.
Thats good to hear
Your code looks fine but I hope, you can still optimize your code to one single select query statement.
if lv_pattern ca '*'.
REPLACE ALL OCCURRENCES OF '*' IN lv_pattern WITH '%'.
endif.
if lv_pattern is initial.
lv_pattern = '%'.
endif.
"now it should work for all scenarios is n't it?
SELECT UNIQUENO
INTO TABLE lt_select_list
FROM ZWORKFL0W_TB_RK
WHERE uniqueno LIKE lv_pattern.
Regards,
Rama
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.