‎2009 Nov 27 10:12 PM
Hi
How can I do to select data using string with range:
srch_strA = notcr-low.
srch_strb = notcr-high.
* Building selection
IF srch_strA IS NOT INITIAL AND srch_strB IS INITIAL.
CONCATENATE '%' srch_strA '%' INTO srch_strA.
*document header
SELECT bukrs belnr gjahr bktxt bldat xblnr
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE bukrs EQ p_bukrs AND
belnr IN belnr AND
gjahr EQ p_gjahr
AND xblnr IN xblnr
AND BKTXT LIKE srch_strA.
ENDIF.
IF srch_strA NE '' AND srch_strB NE ''.
CONCATENATE '*' srch_strA '*' INTO srch_strA.
CONCATENATE '*' srch_strB '*' INTO srch_strB.
ti_nc-sign = 'I'.
ti_nc-option = 'BT'.
ti_nc-low = srch_strA.
ti_nc-high = srch_strB.
append ti_nc. clear ti_nc.
*document header
SELECT bukrs belnr gjahr bktxt bldat xblnr
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE bukrs EQ p_bukrs AND
belnr IN belnr AND
gjahr EQ p_gjahr
AND xblnr IN xblnr
AND BKTXT IN ti_nc.
ENDIF.Thanks in advance.
Moderator message - Please use code tags around your code
Edited by: Rob Burbank on Nov 27, 2009 5:26 PM
‎2009 Nov 27 10:26 PM
‎2009 Nov 27 10:26 PM
‎2009 Nov 30 1:04 PM
I need to make a data selection but field is an string, if user put just one parameter is OK, but I need to let open range parameter selection (string) , charaters searched are in first 9 position of the string.
‎2009 Nov 30 1:56 PM
I meant - what is it about the code that you have written that doesn't work?
Rob
‎2009 Nov 30 2:03 PM
this line in Select Command
AND BKTXT IN ti_ncThanks for answering
‎2009 Nov 30 2:06 PM
Hello Rob,
I think he is trying to make a range of pattern & the SELECT does not seem to return the correct values
I was trying to replicate the same & gives wierd results.
In T001, i have 10 comp codes starting with 12. In SE16 if i give the input BUKRS = 12 to 12, it tells no values available. But if i give the input as 12 to 13* i get all the 10 values.
Can you explain this?
BR,
Suhas
‎2009 Nov 30 2:07 PM
Hello,
While building the range internal table, change the option for BT to CP
ti_nc-sign = 'I'.
ti_nc-option = 'CP'. " This is what you have to use for the functionality you expect
ti_nc-low = srch_strA.
ti_nc-high = srch_strB.
append ti_nc. clear ti_nc.
Vikranth
‎2009 Nov 30 2:07 PM
And what is the problem with that line - a syntax error, a dump, incorrect output something else?
What is the content of ti_nc at execution?
Rob
‎2009 Nov 30 2:10 PM
Hello Vik,
I read through SAP documentation for the OPTION of a SELECT-OPTION & it says:
Analyzable operators are "EQ", "NE", "GE", "GT", "LE", "LT", "CP" and "NP" if column high is initial, and "BT", "NB" if column high is not initial.
So my understanding is you cannot use CP with low & high values. May be i am wrong
BR,
Suhas
‎2009 Nov 30 2:17 PM
Hello Suhas,
I wasn't aware of that. If the documentation tells that then it must be true:) It also really doesn't make sense to use a high option when searching for patterns. If the OP is looking to search for patterns, he shouldn't fill the high value as pointed by you.
Vikranth
‎2009 Nov 30 2:19 PM
Ok Vikranth
I'll change it and let you know.
Thanks to all for answering.
‎2009 Nov 30 2:22 PM
Hello Tokio,
Please note that the high option should be initial when searching for patterns using CP option.
Vikranth
‎2009 Nov 30 2:22 PM
Hi Suhas,
On a research with this issue I found that the concatenate statements you are using is giving problems...
CONCATENATE '' srch_strA '' INTO srch_strA.
CONCATENATE '' srch_strB '' INTO srch_strB.
if you replace them with the below, i hope you get some output from them,
CONCATENATE srch_strA '*' INTO srch_strA.
CONCATENATE srch_strB '*' INTO srch_strB.
This is what I could find because in select query the first character * is not accepted, I dont know the reason...
Thanks,
Sid
‎2009 Nov 30 2:29 PM
‎2009 Nov 30 3:03 PM
Guys
I've made these changes:
1.- Please note that the high option should be initial when searching for patterns using CP option. I did it
2.-
CONCATENATE '' srch_strA '' INTO srch_strA.
CONCATENATE '' srch_strB '' INTO srch_strB.
CONCATENATE srch_strA '*' INTO srch_strA.
CONCATENATE srch_strB '*' INTO srch_strB.
Still getting all records... is there something I miss?
Thanks to all for helping
‎2009 Nov 30 3:20 PM
Hi,
Pls. use this code and check if its working...
srch_strA = notcr-low.
srch_strb = notcr-high.
* Building selection
IF srch_strA IS NOT INITIAL AND srch_strB IS INITIAL.
CONCATENATE '%' srch_strA '%' INTO srch_strA.
*document header
SELECT bukrs belnr gjahr bktxt bldat xblnr
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE bukrs EQ p_bukrs AND
belnr IN belnr AND
gjahr EQ p_gjahr
AND xblnr IN xblnr
AND BKTXT LIKE srch_strA.
ENDIF.
IF srch_strA NE '' AND srch_strB NE ''.
CONCATENATE srch_strA '*' INTO srch_strA.
CONCATENATE srch_strB '*' INTO srch_strB.
ti_nc-sign = 'I'.
ti_nc-option = 'BT'.
ti_nc-low = srch_strA.
ti_nc-high = srch_strB.
append ti_nc. clear ti_nc.
*document header
SELECT bukrs belnr gjahr bktxt bldat xblnr
FROM bkpf INTO CORRESPONDING FIELDS OF TABLE it_bkpf
WHERE bukrs EQ p_bukrs AND
belnr IN belnr AND
gjahr EQ p_gjahr
AND xblnr IN xblnr
AND BKTXT IN ti_nc.
ENDIF.Thanks,
Sid
‎2009 Nov 30 5:49 PM
Thanks to all for your very helpfull answers!!!
Siddharth your help solve it!!!
‎2009 Nov 30 2:20 PM
Check the WHERE clause help. You can use something like:
DATA: mywhere TYPE string.
RANGES: r_range FOR table-field2.
* define your range
...
* continue
mywhere = 'field = condition AND field2 IN r_range'.
SELECT field_list
INTO destination
FROM table
WHERE (mywhere).