cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How can I use the lifnr field in the select statement with both IN and LIKE?

gulbin01
Explorer
0 Likes
1,407

SELECT
bukrs
gjahr
budat
lifnr
waers
FROM vsak INTO TABLE lt_blg
WHERE bukrs IN s_bukrs
AND lifnr IN s_lifnr ( AND ) lifnr LIKE 'OOOO9%' *******************************
AND budat IN s_budat.

HI,

*************How can I use the lifnr field in the select statement with both IN and LIKE?
What is the correct combined code?

Many Thanks for any help..!!!!

Accepted Solutions (1)

Accepted Solutions (1)

RaymondGiuseppi
Active Contributor

Is the number range selection related to some vendor account group (e.g. non employee vendor) in this case consider a more dynamic code using a join with LFA1 to get the group and filter on its value.

Else just remove the parenthesis ( ) 

AND lifnr IN s_lifnr AND lifnr LIKE '00009%

 

Answers (1)

Answers (1)

PAmburi
Discoverer

Hi! 

I changed the code to fit my system data model, but the idea is the same, here is an example of the SQL Statement working:

TABLES: bsak, t001.

SELECT-OPTIONS: s_bukrs FOR t001-bukrs,
                s_lifnr FOR bsak-lifnr,
                s_budat FOR bsak-budat.

SELECT bukrs,
       gjahr,
       budat,
       lifnr,
       waers
  FROM bsak
  INTO TABLE @DATA(lt_data)
 WHERE bukrs IN @s_bukrs
   AND ( lifnr IN @s_lifnr AND  lifnr LIKE '%61%' )
   AND budat IN @s_budat.

LOOP AT lt_data INTO DATA(ls_data).
  WRITE: / ls_data.
ENDLOOP.

 I´ve changed the wildcard to %61% just to get some records in the result.

Hope that helps!