01-29-2008 12:19 PM
HI friends
i am using below select statement
select vbeln erdat ernam
from vbrk
where
vbeln in s_vbeln and
erdat in s_erdat and
ernam eq p_ernam .
My problem is s_vbeln and s_erdat is select option and
p_ernam is parameter.
while running this program with all 3 blank selection screen select statement not fetching any data. If I exclude the statement p_ernam, I am getting the data.
how to place parameter p_ernam to this select query to get data
thanks in advance
01-29-2008 12:24 PM
Hi Karthik-
I think the select stmt is taking ernam value as SPACE and hence u r not getting any recorsd when u put p_ernam in the WHERE clause of select stmt..
put a condition:
IF not p_ernam is initial.
select..where <> and ernam eq p_ernam.
ELSE.
select ...where <> .
ENDIF.
Hope this helps,
Shakir
01-29-2008 12:24 PM
Hi Karthik-
I think the select stmt is taking ernam value as SPACE and hence u r not getting any recorsd when u put p_ernam in the WHERE clause of select stmt..
put a condition:
IF not p_ernam is initial.
select..where <> and ernam eq p_ernam.
ELSE.
select ...where <> .
ENDIF.
Hope this helps,
Shakir
01-29-2008 12:25 PM
Hi,
Declare p_ernam is also as Select-options.
like this
select-options:p_ernam for table-field no intervals.
01-29-2008 12:25 PM
Hi,
for parameters we have to specify the value..other wise it won't give the output.
Try like this
if not p_ernam is initial.
select vbeln erdat ernam
from vbrk
where
vbeln in s_vbeln and
erdat in s_erdat and
ernam eq p_ernam .
else.
select vbeln erdat ernam
from vbrk
where
vbeln in s_vbeln
erdat in s_erdat.
endif.
Regards,
nagaraj
01-29-2008 12:26 PM
The problem is that you are looking for an invoice with user SPACE and no user had that user name.
Then the parameter USER NAME should be obligatory. One more thing you can do is declare a range and put the selected value in that range:
ranges r_ernam for vbrk-ernam.
clear: r_ernam .
r_ernam-low = p_ernam.
r_ernam-sign = 'I'.
r_ernam-option = 'EQ'.
append r_ernam.
select vbeln erdat ernam
from vbrk
where
vbeln in s_vbeln and
erdat in s_erdat and
ernam IN R_ERNAM .
Now if the user doesn't specifies a user name, all user names are looked for in database. I hope that helps!
01-29-2008 12:26 PM
Hi,
For Select-Options without giving any values in the selection screen, you can get data.
Where as for Parameters, whatever you give values that should be matched the value in the table field.
Currently you are not giving any value for parameter means the table should contain a record without any creating date. This is not possible, hence you are not getting any records.
Regards,
Ashok
01-29-2008 12:27 PM
hi
Create a range for p_ernam and fill the value from p_ernam to the -low field of the range. When using ranges you will be able to find data, when p_ernam is blank (or initial)
Rgds
Flemming
01-29-2008 12:40 PM
try:
select-options:
p_eranme for <fiedname> NO-EXTENSION NO INTERVALS.
select vbeln erdat ernam
from vbrk
where
vbeln in s_vbeln and
erdat in s_erdat and
ernam in p_ernam .
01-29-2008 12:49 PM
IN your code check the value of P_ernam if it is blank then query should not shoot.
use code like this.
if not p_ernam is initial.
select vbeln erdat ernam
from vbrk
where
vbeln in s_vbeln and
erdat in s_erdat and
ernam eq p_ernam .
else.
select vbeln erdat ernam
from vbrk
where
vbeln in s_vbeln
erdat in s_erdat.
endif.
reward points if helpful,
kushagra
01-29-2008 12:56 PM
1. u can declare the parameter as select option without extension and intervals
or
2. u can use the a default value in parameter
or.
u can write the SELECT ina IF block like
IF parameter is initial
do this
else
do this
endif.
Narendra