‎2007 Jun 26 12:20 PM
Hey,
I have 3 PARAMETERS that I use for a SELECT-Statement:
SELECT * FROM sflights2.
IF sflights2-connid = connid AND
sflights2-carrid = airline AND
sflights2-fldate = fldate.
WRITE / sflights2-seatsmax.
WRITE sflights2-seatsocc under text-003.
ENDIF.
ENDSELECT.
But all three fields are not obligatory and if some of these fields
are empty I would like to ignore them or place wildcards.
I tried it like this:
IF connid IS INITIAL. connid = ''. endif.Doesn't work. What is the wildcard?
thanks
chris
‎2007 Jun 26 12:25 PM
A quick solution is to Replace the Parameter declaration with Select-options.
And in the select query use 'IN' operation instead of '='.
Regards,
Anish Thomas
Please Mark useful answers
‎2007 Jun 26 12:25 PM
A quick solution is to Replace the Parameter declaration with Select-options.
And in the select query use 'IN' operation instead of '='.
Regards,
Anish Thomas
Please Mark useful answers
‎2007 Jun 26 12:27 PM
‎2007 Jun 26 12:27 PM
Hi,
If u r using parameters then u need to pass values means that should be obligatory other wise it won't pick data.Use select-options instead of parameters.
Regards,
nagaraj
‎2007 Jun 26 12:28 PM
HI,
do like this.
tables:sflights2.
if connid is not initial and airline is not initial and fldate is not initial.
SELECT * FROM sflights2 where connid = connid AND carrid = airline and fldate = fldate.
WRITE / sflights2-seatsmax.
WRITE sflights2-seatsocc under text-003.
ENDSELECT.
endif.
rgds,
bharat.
‎2007 Jun 26 12:42 PM
Thanks @all.
@Anish Thomas
Your first solution seems to work:
SELECT-OPTIONS airline FOR sflights2-carrid DEFAULT 'AZ' NO-EXTENSION.
SELECT-OPTIONS connid FOR sflights2-connid NO-EXTENSION.
SELECT-OPTIONS fldate FOR sflights2-fldate DEFAULT '20071017' NO-EXTENSION.
...
SELECT * FROM sflights2.
IF sflights2-connid IN connid AND
sflights2-carrid IN airline AND
sflights2-fldate IN fldate.
WRITE / sflights2-seatsmax.
WRITE sflights2-seatsocc UNDER text-003.
ENDIF.
ENDSELECT.
@bharat
I tried something like your soloution, but then ALL fields are obligatory. But
what happend if connid OR fldate is empty?
@Chandrasekhar
Here would also an error been thrown if one field is empty. But to work with itab
is a nice idea. thx
thank you all
‎2007 Jun 26 12:35 PM
try this.
data : begin of itab occurs 0,
seatsmax like sflights2-seatsmax,
seatsocc like sflights-seatsocc,
end of itab.
SELECT seatsmax seatsocc
FROM sflights2 into table itab
where connid = connid AND
carrid = airline AND
fldate = fldate.
loop at itab.
WRITE / itab-seatsmax.
WRITE itab-seatsocc.
ENdloop.
‎2007 Jun 26 12:44 PM
Hi Chris,
Use a SELECT-OPTION with "no-extension" and "no intervals" additions to make the control look like parameter. And use the IN operator in the SELECT/WHERE statement.
With parameter control in WHERE clause you have to use LIKE operator which can be used only in c type of variables or in IF clause a CP operator, but both are expensive and not useful always. Hope this helps.
Regards,
Prabhu