cancel
Showing results for 
Search instead for 
Did you mean: 

select query

Former Member
0 Kudos

Can we have something like this in a select query.. ( see the WHERE clause)

select vbeln vstel

route kunnr

lstel bolnr

traty traid

wadat_ist

from likp

into gt_likp

where kunnr in s_kunnr

and kunnr in r_kunnr.

regards

Nishant

Message was edited by: Nishant Gupta

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Sure, why not? I assume that R_KUNNR is a range.

Regards,

Rich Heilman

Former Member
0 Kudos

ya r_kunnr is a range

Former Member
0 Kudos

Hi Rich,

Will it give correct results?

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

It really depends on what logic you have built in the SELECT-OPTION and the RANGE. Logically, the only records that will be retrieved will be the ones that satisfy BOTH the SELECT-OPTION and the RANGE, hence the logic will need to be overlapping in some way. I don't know your purpose for doing it this way, but there must be a reason. If not, using one range would be better.


* Copy S_KUNNR to the R_KUNNR range
Loop at s_kunnr.
r_Kunnr = s_kunnr.
append r_kunnr.
endloop.

Regards,

Rich Heilman

Answers (3)

Answers (3)

Former Member
0 Kudos

lets take for example there are two customer numbers : 100 and 101. Assuming that both are populated in S_KUNNR and R_KUNNR.

your select statement will get converted to

select vbeln vstel

route kunnr

lstel bolnr

traty traid

wadat_ist

from likp

into gt_likp

where ( kunnr eq '100' or kunnr eq '101')

and ( kunnr eq '100' or kunnr eq '101').

i dont see a point in using R_KUNNR, even if you remove it the number of entries are not going to vary.

Former Member
0 Kudos

It might be more efficient to do something like this:


append lines of r_kunnr to s_kunnr.
select vbeln vstel
    route kunnr
    lstel bolnr
    traty traid
    wadat_ist 
  from likp
  into gt_likp
  where kunnr in s_kunnr.

Rob

Former Member
0 Kudos

Before doing the select, you could also:


SORT s_kunnr.
DELETE ADJACENT DUPLICATES FROM s_kunnr.

That might help a bit.

Rob

Former Member
0 Kudos

Nishant,

Syntactically we can do that, I am not sure if it gives the right results.

So, why can't append all the values from s_kunnr into r_kunnr and use just r_kunnr in the WHERE clause.

By the way what happened to your IDOC thing?

Regards,

Ravi

Former Member
0 Kudos

thanks Ravi.. The idoc thing also got solved