Skip to Content
avatar image
-4
Former Member

issue with Select query

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

Add comment
10|10000 characters needed 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 .

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

  • Converted to comment

  • Get RSS Feed

4 Answers

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

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 30, 2017 at 12:09 AM

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

    Add comment
    10|10000 characters needed characters exceeded

    • "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!

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

    solved my self.

    thank you

    Add comment
    10|10000 characters needed 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

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

    Add comment
    10|10000 characters needed characters exceeded

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