06-18-2008 8:00 AM
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
06-18-2008 8:43 AM
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.
06-18-2008 8:04 AM
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
06-18-2008 8:16 AM
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
06-18-2008 8:21 AM
Hi Savitha,
This is only based on the data entered in the Selection Screen. Can you share your code over here.
Regards,
Viji.
06-18-2008 8:07 AM
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.
06-18-2008 8:08 AM
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
06-18-2008 8:08 AM
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.
06-18-2008 8:24 AM
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
06-18-2008 8:32 AM
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,
06-18-2008 8:10 AM
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
06-18-2008 8:43 AM
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.