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: 

select query

Former Member
0 Kudos

Hi all,

Plz tell me how to write select query .

I have 5 inputs in selection screen, 2 are obligatory , 3aro not.

In my first select qyery of my report how how can i write the conditions in where clause for this.

select ekgrp matnr werks lgort r menge meins badat

frgdt ebeln ebelp

into table itab_eban from eban

where ( ekgrp eq p_ekgrp ) and

( matnr in s_matnr ) and

werks eq p_werks and

( lgort eq p_lgort ) and

badat in s_badat.

endif.

I knew that if the input field is not obligatory, then we write the condition in brackets.

Plz tell me.

Savita

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Savita,

You can make all selection screen parameters as select-options, as select-options work fine even we donot give any value.

That is all the obligatory and optional fields you need to make them as select-options without intervals and extensions.

SELECT-OPTIONS: p_date FOR SY-DATUM NO-EXTENSION NO INTERVALS.

Plz reward if useful.

Thanks,

Dhanashri.

10 REPLIES 10

Former Member
0 Kudos

hi savita,

ur select stmt should be like this.

SELECT FIELD1 FIELD2.... FROM <TABLE> INTO TABLE <INTERNAL TABLE> WHERE COND1 AND

COND2 AND

COND3.

DO NOT BOTHER ABOUT OBLIGATORY.

Rgds.,

subash

0 Kudos

Hi Gaddameedi,

No data is populating in my internal table by the way u said & the way I wrote. but when i wrote only obligatory fields then the data is coming in internal table.

Savita

0 Kudos

Hi Savitha,

This is only based on the data entered in the Selection Screen. Can you share your code over here.

Regards,

Viji.

Former Member
0 Kudos

Hi Savitha,

If the Selection Screen Filed is mandatory or not, No need to write in BRACKETS. Remove the brackets in your code and check it.

Reward if it Helps.

Regards,

Viji.

Former Member
0 Kudos

Hi,

There is no need to give in brackets. There is nothing like that if the input field is not obligatory, then we write the condition in brackets.

Regards

Susheel

Former Member
0 Kudos

HI,

Obligatory fields are the mandatory fields on the selection screen, These fields will not make difference in fetching the data. Write the select according to your requirement, don't bother about the mandatory fields on the selection screen.

Functionality: Obligatory fields will not allow to leave the selection screen until these fields are filled properly.

Reward points if it is helpful.

0 Kudos

Hello Ravi,

I m getting a problem in fetching data when i m not giving any input in non-obligatory fields,

the it is taking as those fields value as null value(i feel)

.

Savita

0 Kudos

Dear,

Try like this,

if p_ekgrp is initial and

p_werks is intial and

s_badat is initial.

select ekgrp matnr werks lgort r menge meins badat

frgdt ebeln ebelp

into table itab_eban from eban

matnr in s_matnr and

lgort eq p_lgort .

elseif p_ekgrp is not initial and

p_werks is intial and

s_badat is initial.

select ekgrp matnr werks lgort r menge meins badat

frgdt ebeln ebelp

into table itab_eban from eban

matnr in s_matnr and

ekgrp eq p_ekgrp and

lgort eq p_lgort .

elseif

......................

......................

elseif

......................

else.

select ekgrp matnr werks lgort r menge meins badat

frgdt ebeln ebelp

into table itab_eban from eban

where ekgrp eq p_ekgrp and

matnr in s_matnr and

werks eq p_werks and

lgort eq p_lgort and

badat in s_badat.

endif.

Regards,

sachin_mathapati
Contributor
0 Kudos

Hi Savita,

No need to bother about weather input field is obligatory or not, if the input field is blank the select query does not consider that input field.

select ekgrp matnr werks lgort r menge meins badat

frgdt ebeln ebelp

into table itab_eban from eban

where ekgrp eq p_ekgrp and

matnr in s_matnr and

werks eq p_werks and

lgort eq p_lgort and

badat in s_badat.

Regards,

Sachin M M

Former Member
0 Kudos

Hi Savita,

You can make all selection screen parameters as select-options, as select-options work fine even we donot give any value.

That is all the obligatory and optional fields you need to make them as select-options without intervals and extensions.

SELECT-OPTIONS: p_date FOR SY-DATUM NO-EXTENSION NO INTERVALS.

Plz reward if useful.

Thanks,

Dhanashri.