Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to display records accordingly while using asterisk in input

Former Member
0 Kudos

Say,

In a database table I have a field named "site" which contains the following records.

972

345

240

950


so there are four entries.

Now my parameter is

SELECT-OPTIONS: s_site FOR string NO INTERVALS.


If I give the input as only asterisk


i.e. s_site = *


then all the records must display.


on the other hand if I give the input like this,


i.e. s_site = 9*


then it must display all the records starting with 9


In this case the answer must be: 972 and 950.

Can someone help me with the logic or syntax please.



1 ACCEPTED SOLUTION

michael_kozlowski
Active Contributor
0 Kudos

Hi, will be handled automatically by the WHERE condition of the SELECT statement.

Try this: SELECT * FROM dbtable WHERE site IN s_site.

5 REPLIES 5

michael_kozlowski
Active Contributor
0 Kudos

Hi, will be handled automatically by the WHERE condition of the SELECT statement.

Try this: SELECT * FROM dbtable WHERE site IN s_site.

0 Kudos

This message was moderated.

0 Kudos

Exactly,

the way Michael says is perfect, SAP handles it on its own.

you can actually check the same in debug by looking at the table s_site and the value in field OPTIONS

Former Member
0 Kudos

Thank you so much guys. I'll try it and revert back

0 Kudos

Hi,

run the following code..

both the logics mentioned above are working fine,.

select-option internal table OPTION field will have value 'CP' i.e contain pattern

REPORT ZTEST.

TABLES:MARA.




DATA: IT_FLIGHT TYPE TABLE OF MARA.

DATA: IT_FLIGHT1 TYPE TABLE OF MARA.

SELECT-OPTIONS: S_MTART FOR MARA-MTART NO INTERVALS NO-EXTENSION.

PARAMETERS: P_MTART TYPE MARA-MTART.



TRANSLATE P_MTART TO UPPER CASE.



REPLACE ALL OCCURRENCES OF '*' IN P_MTART WITH '%'.


case 1:  for select options
SELECT * FROM MARA

INTO TABLE IT_FLIGHT UP TO 10 ROWS

*WHERE MTART LIKE SVAR.

WHERE MTART IN S_MTART.

case 2 for parameters

SELECT * FROM MARA

INTO TABLE IT_FLIGHT1 UP TO 10 ROWS

WHERE MTART LIKE P_MTART.


BREAK-POINT.

thanks!!