Application Development 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: 

issue with Select query

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

19 REPLIES 19

Former Member
0 Kudos

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 ).

0 Kudos

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 Kudos

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.

Former Member
0 Kudos

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 .

former_member215439
Participant
0 Kudos

Hi,

Goodday!

Have you solved this concern?

As per checking my code above did not work but I suggest you to try this work around.

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

DELETE lt_eanlh WHERE ableinh(2) NOT IN s_ableinh.

If this concern already solved, please close this thread.

Jelena
Active Contributor

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.

Sandra_Rossi
Active Contributor

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!)

horst_keller
Product and Topic Expert
Product and Topic Expert

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

Thanks Horst 🙂

Jelena
Active Contributor
0 Kudos

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...

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*.

0 Kudos

+1 to Gerrit

Jelena
Active Contributor
0 Kudos

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

Jelena
Active Contributor
0 Kudos
"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!

matt
Active Contributor

Converted to comment

Former Member
0 Kudos

solved my self.

thank you

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

Former Member
0 Kudos

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.