1

I have the following abap program that looks as following:

TABLES lfa1.

DATA gt_lfa1 TYPE SORTED TABLE OF lfa1 WITH UNIQUE DEFAULT KEY.

SELECT-OPTIONS sl_lifnr FOR lfa1-lifnr.
SELECT-OPTIONS sl_name  FOR lfa1-name1.


START-OF-SELECTION.

  SELECT * FROM lfa1
   INTO CORRESPONDING FIELDS OF TABLE gt_lfa1
   WHERE lifnr IN sl_lifnr
   AND   name1 LIKE sl_name.

Searching for vendors that name starts with:

enter image description here

I've got no results, but it exists vendors with this pattern.

3
  • 3
    Why you dont use IN? Commented May 23, 2018 at 11:30
  • Yeah it works. Thanks a lot Commented May 23, 2018 at 12:05
  • 1
    Just put the asterisks into seltab and use IN. That's it. Commented May 23, 2018 at 12:13

3 Answers 3

3

It's not necessary to use LIKE. You can use IN instead.

I ran your code with IN in the SQL and I have results in the table.

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

if you use a select option you have to use the statement IN not like:

s_matnr = *3578 *

select options s_matnr type mara-matnr.

select bismt

from mara 

into lv_bismt

where matnr in s_matnr

If you use s/4hana you can use even fuzzy

Comments

-2

You need to replace * with %, if you are using LIKE operand. https://help.sap.com/doc/abapdocu_750_index_htm/7.50/de-DE/abenwhere_logexp_like.htm

REPLACE ALL OCCURENCES OF '*' in sl_lifnr WITH '%'
REPLACE ALL OCCURENCES OF '*' in sl_name WITH '%'

SELECT * FROM lfa1
   INTO CORRESPONDING FIELDS OF TABLE gt_lfa1
   WHERE lifnr LIKE sl_lifnr
   AND   name1 LIKE sl_name.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.