Search code examples
abapopensql

ABAP LIKE with select option


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.


Solution

  • 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