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: 

selection criteria

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

0 Kudos

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

9 REPLIES 9

0 Kudos

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

former_member188829
Active Contributor
0 Kudos

Hi,

Declare p_ernam is also as Select-options.

like this

select-options:p_ernam for table-field no intervals.

former_member404244
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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!

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

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 .

Former Member
0 Kudos

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

Former Member
0 Kudos

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