Application Development and Automation 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: 
Read only

Select criteria without using SELECTION SCREENs

0 Likes
1,168

Hi everybody,

I have a report with a single screen, 4 fields for search criteria and 2 alv grids for the output.

I search db tables with a select statement.

Is it possible to define a select statement that searches for 3 out of 4 criteria, if the fourth input field isn't filled it?

Because right now the select statement doesn't return any data if I leave one parameter blank.

And how can I provide the possibility to define more than one search criteria of one kind withour adding several input fields on the screen?

For example: Data created on 20070101 and 20070105.

I know that most of this can be done with selection screens, but is there a possibility to do this without a selection screen?

Best regards

Tobias

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
965

You should use SELECT-OPTIONS on your selection screen. This allows the user to enter all kinds of possiblities, including leaving something blank. Then in your SELECT statement, you use the IN operator.

select-options: s_datum for sy-datum.

select * into table itab
           from ztable
                  where datum IN s_datum.

If you truly do not want to use a Selection-screen, you could hard code values in the SELECT statement or create a range using the RANGE statement. The RANGE statement works exactly like SELECT-OPTION statement but without the selection-screen.

Regards,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
966

You should use SELECT-OPTIONS on your selection screen. This allows the user to enter all kinds of possiblities, including leaving something blank. Then in your SELECT statement, you use the IN operator.

select-options: s_datum for sy-datum.

select * into table itab
           from ztable
                  where datum IN s_datum.

If you truly do not want to use a Selection-screen, you could hard code values in the SELECT statement or create a range using the RANGE statement. The RANGE statement works exactly like SELECT-OPTION statement but without the selection-screen.

Regards,

Rich Heilman

Read only

abdul_hakim
Active Contributor
0 Likes
965

Hi,

You need to use SELECT-OPTIONS for doing the same.

Please Follow the sample code given by Rich.

Regards,

Hakim

Read only

Former Member
0 Likes
965

if you have defined parameter then you should fill the value ...

if you dont want to fill it make it select-option and if you restrict user to give only one value then use

tables : mara.

select-options : s_matnr for mara-matnr no-extension no intervals.

it will show only one input field now write your code

select single * form mara where matnr in s_matnr.

regards

shiba dutta

Message was edited by:

SHIBA DUTTA

Read only

0 Likes
965

Thanks everybody!

I used the select-options/selction screen to do it.

Thanks again!

Best regards

Tobias