Skip to Content
avatar image
Former Member

Different behavior: SELECT where IN pattern / check it_tab-f IN pattern

scenario:

I use the pattern 'A++++' in the select-option so_akey.

Table ztab has 5 entries with the following key:

AAB4

AAC4

AAD4

AAE4

A5555

problem

I get different results by using

a) RESULT: 1 line (A5555)

select * from ztab where akey IN so_akey.

write ztab.

endselect.

and b) RESULT 5 lines (all entries)

select * from ztab into TABLE it_ztab.

loop at it_ztab.

check it_ztab-akey IN so_akey.

write ztab.

endloop.

Any ideas?

Actually I need both variants. How can I manipulate so_akey, just before excution comes to b), so b) shows the same results as a) ?

Regards

Norbert

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Apr 18, 2006 at 02:23 PM

    loop at it_ztab.

    <b>check it_ztab-akey IN so_akey.</b>

    write ztab.

    endloop.

    The high lighted code will be succesfull all the time(For all the five records and hence you are getting five records.

    Do this way

    select * from ztab into TABLE it_ztab.

    loop at it_ztab where akey IN so_akey.

    write: it_ztab.

    endloop.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      > OK - I see what you mean. Now I get different results

      > (but I really don't know why).

      >

      > You could get the second example to work like the

      > first one if you exclude entries that don't have the

      > same length as the range table LOW field (assuming

      > there's only one entry in it).

      >

      > Rob

      Hi Rob,

      Thank you for your help.

      Actually I hoped there is more general solution for this problem, because the user is free to fill the option parameter.

      I'll start a support case and will be back here when I got an answer.

      Best Regards

      Norbert Weber

  • avatar image
    Former Member
    Apr 18, 2006 at 02:45 PM

    Is the actual key length 4, 5 or longer?

    Rob

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 18, 2006 at 06:28 PM

    Try the follow:

    Instead of select-options for so_akey, use parameters with default value 'A++++'.

    select * from ztab where akey LIKE p_akey.

    write ztab.

    endselect.

    Hope this helps.

    thanks,

    vamshi tallada

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 19, 2006 at 01:11 PM

    Well, I did some research:

    In help 'CP' I found this statement:

    "... 'ABC' CP 'ABC+' is false, ..."

    That is exactly what I expected from:

    b) "check it_ztab-akey IN so_akey"

    but this checks 'AAB4' CP 'AAB4+' as TRUE!

    Why it's not working as described?

    BECAUSE: it_ztab-akey is type char(10)!!

    Using a STRING works as expected!

    Here in my test only the char10 variante says 'true'.

    Best Regards

    Norbert

    DATA: cc1(10), cc2(10).

    DATA: strc1 TYPE string, strc2 TYPE string .

    IF 'ABC' CP 'ABC+'.

    WRITE 'Konstante: ABC CP ABC+ = true'.

    ENDIF.

    cc1 = 'ABC'.

    cc2 = 'ABC+'.

    IF cc1 CP cc2.

    WRITE 'Variable cC1 char 10: ABC CP ABC+ = true'.

    ENDIF.

    strc1 = cc1.

    strc2 = cc2.

    IF strc1 CP strc2.

    WRITE 'Variable strC1 string: ABC CP ABC+ = true'.

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded