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: 

Problem with PARAMETERS and SELECT

Former Member
0 Kudos

Hi,

Pls have a look at the code below.

**********

tables: spfli.

parameters: p_carrid type spfli-carrid,

p_connid type spfli-connid.

data: ispfli type table of spfli with header line.

select * into table ispfli from spfli

where carrid eq p_carrid and

connid eq p_connid.

****************

If in the parameters on the selection screen, we didnt give any values Iam not getting any data into internal table ISPFLI.

Even, if I give 'AA' for p_carrid in selection screen iam not getting any values into internal table ISPFLI.

If we use parameters, in the selection screen is it compulsory to give fill all the values into parameters to get values into internal table???

Thanks,

Shivaa......

11 REPLIES 11

Former Member
0 Kudos

Hi,

Parameters are used to fetched exact data from table.

If you provide no input in the parameter field while using

where clause it searches for a blank entry in Database table.

In you codes:

If carrid = AA and Connid = No input.

There is no specific record in database table.

here comes difference between Select-options and parameters:

If no input is provided on selection screen select-options will give you all recodrs of table

whereas paraameters will give no records.

You can use Select-options as parameters:

select-options:s_carrid for spfli-carrid no-interval.(Hides upper limit)

SELECT * from spfli where carrid in p_carrid.

regards,

Gurpreet

Former Member
0 Kudos

Hi Shiva,


parameters: p_carrid type spfli-carrid,
p_connid type spfli-connid.


data: ispfli type table of spfli with header line.

select * into table ispfli from spfli
where carrid eq p_carrid and
connid eq p_connid.

here it retrieves the values mentioned of p_carrid and p_connid , once check in spfli table whether there are any entries for condition carrid = AA .

In other case like give select-options


select-options : s_carrid type spfli-carrid,
s_connid type spfli-connid.


data: ispfli type table of spfli with header line.

select * into table ispfli from spfli
where carrid in s_carrid and
connid in s_connid.

here if s_connid is space then it retrieves all the records .

if we give parameters we shud give the values . where as if we dont give ny values in select-options it retrieves all values .

PS : check in debugging mode , you will get clear idea .

Regards ,

Aby

Former Member
0 Kudos

Hi,

If u r using parameters and if u dont mention any values it is consider as BLANK..So it wont fetch any data from spfli...

And for the second condition,u mentioned the first field with AA and second field u left with blank...

select * into table ispfli from spfli

where carrid eq p_carrid and

connid eq p_connid.

In above select query u mentioned carrid eq p_carrid and connid eq p_connid

...u mentioned AND condition...if bothe statements true then it fetches the values into internal table and also there is no record like BLANK inthe SPFLI table...

Thats y it isu r not getting any records

Regards

Kiran

former_member224008
Active Participant
0 Kudos

Hi,

tables: spfli.

parameters: p_carrid type spfli-carrid,

p_connid type spfli-connid.

data: ispfli type table of spfli with header line.

select * into table ispfli from spfli

where carrid eq p_carrid and

connid eq p_connid.

In this case u canu2019t use u2018ANDu2019 . because u2018ANDu2019 means to satisfy both the condition.

U give carrid u2018AAu2019.so the second condition was false. So u r internal table have none of the record.

Regards,

ARUN.

dev_parbutteea
Active Contributor
0 Kudos

Hi,

select-options:s_carrid for spfli-carrid no-interval no-extension. " display just like a parameter

SELECT * from spfli where carrid in p_carrid.

Regards.

Former Member
0 Kudos

Hi,

You didnot get any output because u have used 'AND' condition.

If you want ur condition to be checked against all those u gave in query,then use 'AND' else use 'OR'.

Bcoz, 'AND' checks for all conditions,only if all are true ,will it gives the corresponding record.

With select-options ,if u dont give any input,it fetches all records.

Former Member
0 Kudos

Hi

To get the data from database table for both carrid and connid. You can use select-options.

Check with this code.

tables:

spfli.

select-options:

s_carrid for spfli-carrid,

s_connid for spfli-connid.

DATA: ispfli TYPE TABLE OF spfli WITH HEADER LINE.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE ispfli

WHERE carrid in s_carrid AND

connid in s_connid.

Regards,

Rajani

Former Member
0 Kudos

hii...

ITS A WORKING CODE......

**************************************************

tables: spfli.

parameters: p_carrid type spfli-carrid,

p_connid type spfli-connid.

data: ispfli type table of spfli with header line.

select * from spfli into table ispfli

where carrid eq p_carrid and

connid eq p_connid.

***************************************************

if you dont give both the parameter filled with value ...you will not get any value as result of the selection.

**************************************but if you go like this......

tables: spfli.

select-options: p_carrid type spfli-carrid,

p_connid type spfli-connid.

data: ispfli type table of spfli with header line.

select * from spfli into table ispfli

where carrid in p_carrid and

connid in p_connid.

but if you go like thiis even if you dont give any value for select option it will return you all records....

so you can go like this

tables: spfli.

parameters: p_carrid type spfli-carrid obligatory,

p_connid type spfli-connid obligatory.

data: ispfli type table of spfli with header line.

select * from spfli into table ispfli

where carrid eq p_carrid and

connid eq p_connid.

Former Member
0 Kudos

hi,

Parameters you can not keep blank,

And as far as AA is concerned, there may not be any data with AA as Carrid.

If you will remove the other Parameter i.e. p_connid you will definately get some data in the Internal table .

And use "Select * from table into i_table

where carrid = p_carrid and

connid = p_connid ". and give inputs on the Selection Screen to both the parameters.

I hope this will help u,

If I am wrong please let me know.

Thanks and Regards

Suraj

former_member217544
Active Contributor
0 Kudos

Hi,

I would suggest you one more option:

Follow the same code you are using, but try including two more statements above the select query and use like in the select query.


tables: spfli.
parameters: p_carrid type spfli-carrid,
p_connid type spfli-connid.

data: ispfli type table of spfli with header line.

if p_carrid is initial.
p_carrid = '%'.
endif.

if p_connid is initial.
p_connid = '%'.
endif.

select * into table ispfli from spfli
where carrid like p_carrid and
connid like p_connid.

Hope this will work.

Regards,

Swarna Munukoti.

Edited by: Swarna Munukoti on Feb 16, 2009 5:54 AM

Former Member
0 Kudos

Hello Shiva,

When p_carrid AND p_connid contain value, then the records are retrieved, or else it is not fetched.

Anyways, that can be very well handled by SELECT-OPTIONS.

Just try it,

[Select-Options and Parameters|;

SELECT-OPTIONS and PARAMETERS look similar, but behave differently.

For example,

PARAMETERS:
  p_field1 TYPE vbap-vbeln,
  p_filed2 TYPE vbap-vbeln.

now , we'll a select query,

SELECT vbeln
             matnr
             posnr
             matkl
FROM  vbap
INTO TABLE I_TAB
WHERE vbeln IS BETWEEN p_field1 AND p_field2.

If p_field1 and p_field2 contain no value, then no records are fetched.

Whereas

DATA:
  w_vbeln TYPE vbap-vbeln.
 
SELECT-OPTIONS:
  s_vbeln FOR w_vbeln NO-EXTENSION NO INTERVALS.

now, we'll run a select query using select-options,

SELECT vbeln
             matnr
             posnr
             matkl
FROM  vbap
INTO TABLE I_TAB
WHERE vbeln IN s_vbeln.

If s_vbeln is NULL, I_TAB contains * all records of VBAP*.

Just, try it out, you'll experience the same.

Thanks: Zahack