‎2008 Mar 07 3:37 AM
I hav a Ztable & need to fetch data from thr.
User will enter the year & BSTAT is blank & all other if he wish he'll enter.
I have used this logic:
refresh itab.
select * into table itab
from ztable
where bstat = ''
and djahr = djahr1
or belnr in belnr1
or werks in werks1
or KOSTL in kostl1
or ANLN1 in anln11
or AUFNR in aufnr1.
Is it correct plz guide
‎2008 Mar 07 4:00 AM
Hi Abhut,
If you the variable you want to use in select query and if you want that the value of those variables to be empty,but your select query should work then declare those variables as select-options with no interval and no extension .
if there is a range then no need to add no extension and no inerval.
SELECT * INTO TABLE itab
FROM ztable
WHERE bstat is initial
AND djahr IN djahr1
AND belnr IN belnr1
AND werks IN werks1
AND kostl IN kostl1
AND anln1 IN anln11
AND aufnr IN aufnr1
‎2008 Mar 07 3:47 AM
Hi,
Declare all the input fields as SELECT-OPTIONS with no intervals no-extensions so dey ll appear like parameters but behave as sel-options(if left empty all records ll be selected)
SELECT * INTO TABLE itab
FROM ztable
WHERE bstat EQ ' '
AND djahr IN djahr1
AND belnr IN belnr1
AND werks IN werks1
AND kostl IN kostl1
AND anln1 IN anln11
AND aufnr IN aufnr1.Cheers,
jose.
‎2008 Mar 07 3:52 AM
hi,
u r query is correct.... but if u want to select particular fields frm the table don't use select *. bcoz it 'll create a performance issuse instead of that use select (particular fields) from table.
Thanks.
Arunprasad.P
‎2008 Mar 07 3:53 AM
Does the 'ZTABLE' have data when .... 'BSTAT' is empty....
if yes ... then the query is ok ..... and i think u should use 'AND' instead of 'OR'.
but i thing i would suggest .... that don't use * rather mention the fields that u want ....even if u want all the fields try to mention them .... depending on the no. of fields in the table .... because it is performance wise better ..
Edited by: Anjali on Mar 7, 2008 4:55 AM
‎2008 Mar 07 3:54 AM
Hi,
It seems to be fine, but according to standards.
But make eure if you are using IN fir fetching data then you this field should be a select-option on the selection screen.
refresh itab.
select * into table itab
from ztable
where bstat = space and
djahr EQ djahr1 or
belnr in s_belnr1 or
werks in s_werks1 or
KOSTL in s_kostl1 or
ANLN1 in s_anln11 or
AUFNR in s_aufnr1.
Please reward if its helpful.
Regards,
Abhishek
‎2008 Mar 07 4:00 AM
Hi Abhut,
If you the variable you want to use in select query and if you want that the value of those variables to be empty,but your select query should work then declare those variables as select-options with no interval and no extension .
if there is a range then no need to add no extension and no inerval.
SELECT * INTO TABLE itab
FROM ztable
WHERE bstat is initial
AND djahr IN djahr1
AND belnr IN belnr1
AND werks IN werks1
AND kostl IN kostl1
AND anln1 IN anln11
AND aufnr IN aufnr1
‎2008 Mar 07 4:24 AM
Hi da,
Try this...
You no need to worry about other fields ...
refresh itab.
select * into table itab
from ztable
where bstat = ''
and djahr = djahr1.
Regards.
Balakumar.G.