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 with 3 PARAMETERS

Former Member
0 Likes
901

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

1 ACCEPTED SOLUTION
Read only

former_member150733
Contributor
0 Likes
877

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

7 REPLIES 7
Read only

former_member150733
Contributor
0 Likes
878

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

Read only

0 Likes
877

Ok, I will check this. Thanks.

Read only

former_member404244
Active Contributor
0 Likes
877

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

Read only

Former Member
0 Likes
877

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.

Read only

0 Likes
877

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

Read only

Former Member
0 Likes
877

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.

Read only

Former Member
0 Likes
877

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