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: 

how to use RANGES with SELECT

Former Member
0 Kudos

i am using ranges as follows, but it is not giving me desired result, pls correct me if i am doing something wrong.

values are changed, i want to know is this right way to use ranges with select.

IF var1 NE 'y'.

r_risklevel-low = abc.

r_risklevel-sign = 'I'.

r_risklevel-option = 'EQ'.

APPEND r_risklevel.

ENDIF.

IF var2 NE 'y'.

r_status-low = xyz.

r_status-sign = 'I'.

r_status-option = 'EQ'.

APPEND r_status.

ENDIF.

SELECT * FROM dbtable

INTO TABLE itab

WHERE priority IN r_risklevel AND

status IN r_status.

regards.

1 ACCEPTED SOLUTION

andreas_mann3
Active Contributor
0 Kudos

it seems to be o.k.

pls debug : what's in table r_risklevel and r_status

befor select ?

Andreas

13 REPLIES 13

andreas_mann3
Active Contributor
0 Kudos

it seems to be o.k.

pls debug : what's in table r_risklevel and r_status

befor select ?

Andreas

Former Member
0 Kudos

See this example

* Populate range table
   <b>r_vrgar-sign = c_i.(constants with value I)</b>    
    r_vrgar-option = c_eq.
    r_vrgar-low = c_b.
    APPEND r_vrgar.

    r_vrgar-sign = c_i.
    r_vrgar-option = c_eq.
    r_vrgar-low = c_c.
    APPEND r_vrgar.

    r_vrgar-sign = c_i.
    r_vrgar-option = c_eq.
    r_vrgar-low = c_i.
    APPEND r_vrgar.

    SELECT rbeln
           rposn
           prodh
           INTO TABLE i_ce1mcc3
           FROM ce1mcc3
           WHERE rbeln    = w_temp_ce1mcc3-belnr AND
                 rposn    = w_temp_ce1mcc3-buzei AND
                 perio    = w_temp_ce1mcc3-perio AND
                 paledger = c_b0 AND
                 vrgar    IN r_vrgar.

In ur code

IF var1 NE 'y'.

r_risklevel-low = <b>'ABC'</b>.

Similarly Make changes and try it will work.

Former Member
0 Kudos

Hi,

<b>RANGES:

r_matnr for mara-matnr.</b>

r_matnr-low = '000000000000009999'.

r_matnr-option = 'BT'.

r_matnr-sign = 'I'.

APPEND r_matnr.

The selection is as follows:

SELECT * FROM mara WHERE matnt in r_matnr.

Check the declaration for the ranges.

Hope you got the idea.

Regards,

Anjali

Vinod_Chandran
Active Contributor
0 Kudos

Hi,

Pls check the following.

Declaration for r_risklevel and r_status.

Is these referring to the fields priority and status of the database table?

Try giving the value of low inside quotes.

i.e. r_risklevel-low = 'abc'.

r_status-low = 'xyz'.

Also make sure that you have records in the database table which statisfies your WHERE condition.

Thanks

Vinod

Former Member
0 Kudos

abc and xyz are variables. that is ok, so i think i am using it in right way. but in help of RANGES i read this line, can someone explain what does this mean.

If you use the IN operator in conjunction with SUBMIT, CHECK, IF, WHILE or SELECT, <b>always define the associated </b><b>internal table</b> using SELECT-OPTIONS or RANGES (never directly).

thanks for replying

regards.

0 Kudos

Yes. It is true. That is what I asked you, whether you are referring to the database table field using RAGES.

The declaration should be.

RANGES: r_risklevel for dbtab-fieldname OCCURS 0.

0 Kudos

Hi,

Here is the sample code.It is working perfectly.

In your program,just check the database table for the values you are passing.

ranges r_matnr for mara-matnr.

data v_matnr type mara-matnr.

r_matnr-low = '000000000000000033'.

r_matnr-sign = 'I'.

r_matnr-option = 'EQ'.

append r_matnr.

select single matnr from mara into v_matnr where matnr in r_matnr.

write v_matnr.

Here in this sample code,you can see the ranges declaration.

Kindly reward points for the useful answers.

0 Kudos

hello vinod

i have declared as

ranges : r_risklevel for dbtable-risklevel.

should i change it

regards

0 Kudos

Hi,

It seems the way you have done is correct. Now check the values of these ranges whether you have corresponding records in the database table.

If the above is not helpful;

You have mentioned that you are not getting the desired result. Could pls explain more on this?

Thanks

Vinod

0 Kudos

Vinod ,

thanks for your time.

sorry i have to go in meeting, i will do some debugging, look like this data is not in database table.

regards.

Former Member
0 Kudos

Hi,

U have to define

DATA: r_risklevel FOR dbtable-priority,

r_status FOR dbtable-status.

U can reward points and close the thread.

0 Kudos

hello friends,

i found the root cause, it was the way select was used, let me do it , soon i will get back to you.

regards.

*thread can't be closed yet

0 Kudos

Hi,

see that there is data in db table for the selection criteria. And moreover, use conversion exit where ever possible.

eg: if material number is 100, you should use '0000000100' during selection or else, the system will look for exactly '100' for selection. You can achieve by conversion exit CONVERSION_EXIT_ALPHA_OUTPUT

I think this should solve your problem.

thanks

vamsi