Skip to Content
-4

issue with Select query

Dec 23, 2017 at 07:34 PM

230

avatar image
Former Member

Hi in the below query i need the match 'ableinh ' with one select option parameter..

in select option field iam passing '01' or '02' or '03' or etc..

the value of 'ableinh' is '0112' or '01345' or '0287' or '03455' or etc.

i know LIKE work for single value , here i need to fetch multiple records..

SELECT anlage bis tariftyp ableinh FROM eanlh
INTO TABLE lt_eanlh WHERE anlage IN s_instl
AND bis = '99991231'
AND tariftyp IN s_ortyp
AND ableinh = .

please help me.

Thanks

NK

10 |10000 characters needed characters left characters exceeded
Former Member

I coded as below ,i but see different issue , on selection field iam passing range '01' to '03' , but it always fetching the records start with 01 , its considering the range ..even tried on on table SE11/SE16 , if you give range 01* to 03* , it only get the records start with '01'.

any idea.. cant really get range of values using pattern?

ls_data-option = 'BT'.
ls_data-sign = 'I'.
if not s_portn-low IS INITIAL.
CONCATENATE s_portn-low '%' INTO ls_data-low .
endif.
if not s_portn-high IS INITIAL.
CONCATENATE s_portn-high '%' INTO ls_data-high .
endif.
APPEND ls_data TO lt_data.

SELECT anlage bis tariftyp ableinh FROM eanlh
INTO TABLE lt_eanlh WHERE anlage IN s_instl
AND bis = '99991231'
AND tariftyp IN s_ortyp
AND ableinh IN lt_data .

0

Please don't use Answers to post additional information, use Comments instead.

Regarding the question - post the screenshots of the actual values you see in SE16. I don't see any conversion exits in this field in our system so I'm not sure what could be the problem. But with numeric values in CHAR 8 field it is most likely "owls are not what they seem".

P.S. Not sure why you're adding "%" in this code. Use selection variable as is, from the selection screen. No need to make it more complicated.

P.P.S. Just for the giggles why not try *03* pattern and see what happens.

1

Converted to comment

1
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
avatar image
Former Member Jan 08 at 06:13 PM
0

The above issue resolved with different approach . I find the field

ableinh in another table te422 , so now I used inner join on tables

eanlh and te422 .

Thanks all for your inputs.

Share
10 |10000 characters needed characters left characters exceeded
Sandra Rossi Dec 30, 2017 at 12:09 AM
2

If you want any value which starts with 01 or any value which starts with 02 or any value which starts with 03, then initialize your range table with those 3 entries:

SIGN  OPTION  LOW
I     CP      01*
I     CP      02*
I     CP      03*

EDIT: solution corrected as per Horst remark (thanks!)

Show 8 Share
10 |10000 characters needed characters left characters exceeded

I'd say the OPTION must be CP instead of EQ and LOW must be '01*', ...

2

Thanks Horst :)

1

Hm, this seems to be very peculiar. I don't have the same exact data as OP but tested with T001 table. It looks like if the range is entered using from/to select options (which translates into BT option with LOW/HIGH) then the "to" part is not included in the result.

If I enter 002*, 003*, and 004* as 3 separate items then it correctly finds all items that start with those numbers. But if I enter selection criteria from 002* to 004* then it only includes 002* and 003*. If I change it as up to 005* then 004* shows up.

This is very odd because if I just specify the exact values, e.g. 0020 to 0049 then 0049 is included in the result set. What the deuce? Is there any reasonable explanation? No wonder OP got confused...

0

When using BT the LOW and HIGH are not seen as patterns but just single entries. Since '*' comes before '0' in the ASCII table it will not select any 004 entries when you use HIGH as 004*.

2

Thanks for a reply! So essentially there is no "BP" option, like BT one but for the pattern. Weird...

0
Jelena Perfiljeva
1
"The relational operator matches the content of the column seltab-option
and the content of the columns seltab-low and seltab-high is concatenated as the right operand."

I might be slow today but I'm honestly having trouble translating this into "CP with 001*-004* will not find 004* pattern". :) Specific examples could be helpful.

Thank you!

0
Jelena Perfiljeva

+1 to Gerrit

0
avatar image
Former Member Dec 30, 2017 at 11:08 PM
-1

solved my self.

thank you

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi NK,

A lot of people took time and effort in order to help you reach the solution.

I would like to refer you to the rules of engagement section 5:

"5. Share expertise transparently. We are a community based site that encourages public knowledge sharing. Be open about your knowledge and how you obtained it."

Taking that into account, please share your solution and mark helpful/correct answers.

Iftah

SAP Community Moderator

6
avatar image
Former Member Dec 23, 2017 at 11:25 PM
-3

Hi NK Reddy, Are you not getting the output if you write the query like below...?

SELECT anlage bis tariftyp ableinh FROM eanlh
INTO TABLE lt_eanlh WHERE anlage IN s_instl
AND bis = '99991231'
AND tariftyp IN s_ortyp
AND ( ableinh = c_0112 OR ableinh = c_01345 OR ableinh = c_0287 OR ableinh = c_03455 ).

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

the field values are dynamically populated on selection screen , they are not fixed, so in runtime my query should compare first 2 characters of ableinh with SELECT-OPTION field value.

Thanks

NK

0
Former Member

Hi NK Reddy,

Please write the select query as below and enter the select option field value on selection screen as 01* , 02*, 03*

(for the field 's_able'). It should work.

SELECT anlage bis tariftyp ableinh FROM eanlh
INTO TABLE lt_eanlh WHERE anlage IN s_instl
AND bis = '99991231'
AND tariftyp IN s_ortyp
AND ableinh IN s_able.

0