The following example shows how to enhance SELECT statements with the use of Wildcard characters.
Wildcard characters used:
- "%" represents any character string, even an empty one.
- "_" represents any character
* Structure & Data of MINE_TABLE:
-------------------------
| ID | TEXT |
-------------------------
| 1AB001 | line #1AB |
-------------------------
| 1AB002 | line #2AB |
-------------------------
| 1AC001 | line #1AC |
-------------------------
| 1AD001 | line #1AD |
-------------------------
* Local variables
DATA:
lt_table TYPE STANDARD TABLE OF mine_table,
ls_table LIKE LINE OF lt_table.
DATA:
lv_id TYPE string.
* Define the use of wildcard characters
CLEAR: lv_id.CONCATENATE '_' 'AB' '%' INTO lv_id.
* Select data from dB MINE_TABLE with a Wild-Card
REFRESH: lt_table.
SELECT *
INTO CORRESPONDING FIELDS OF lt_table
FROM mine_table
WHERE id LIKE lv_id.
* Write the content of internal table LT_TABLE
CLEAR: ls_table.LOOP AT lt_table IN ls_table.
WRITE:/ ls_table-id, ' - ', ls_table-text.
ENDLOOP.
This is the output on the screen:
1AB001 - line #1AB
1AB002 - line #2AB