Skip to Content
author's profile photo Former Member
Former Member

selection criteria

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 29, 2008 at 12:25 PM

    Hi,

    Declare p_ernam is also as Select-options.

    like this

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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 29, 2008 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 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!

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 29, 2008 at 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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.