Application Development and Automation 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: 
Read only

Problem with select statement using Ranges

Former Member
0 Likes
1,202

Hi Guys,

I have used Ranges and used a select statement for selecting those ranges but I am facing a problem.


RANGES: r_doctyp for EDIDC-DOCTYP.
r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low  = 'DEBMAS'.
append r_doctyp.


r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low  = 'MATMAS'.
append r_doctyp.

r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low  = 'PRICAT'.
append r_doctyp.

r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low  = 'ORDERS'.
append r_doctyp.

r_doctyp-sign = 'I'.
r_doctyp-option = 'EQ'.
r_doctyp-low  = 'INVOIC'.
append r_doctyp.

Select DOCNUM                                " IDoc number
       DOCTYP                                " IDoc Type
             from  EDIDC into table IT_ZEDIDC
             where CREDAT EQ s_credat-low
             and   DOCTYP EQ r_doctyp        " IDOC Types
             and   DIRECT EQ '1'.

Here my select statement is only taking INVOIC.

But my statement should take any document type.

Thanks,

Prasad.

12 REPLIES 12
Read only

matt
Active Contributor
0 Likes
1,171

DOCTYP IN r_doctyp

Read only

Former Member
0 Likes
1,171

Hi all,

Even I have used IN but its not coming up.

Read only

Former Member
0 Likes
1,171

Hi,

Firstly check if the entries does exist in the database table for the conditions you have given....

if so,,

did you try with the select query I had written because even for select-options you have to use IN like I had given you in my post....

if that also does not work,

then provide us the select query you have changed and also try to debug what exactly the values are retrieved from the table...

Regards

Siddarth

Read only

Former Member
0 Likes
1,171

HI Try this:

Select DOCNUM " IDoc number

DOCTYP " IDoc Type

from EDIDC into table IT_ZEDIDC

where CREDAT IN s_credat

and DOCTYP IN r_doctyp " IDOC Types

and DIRECT EQ '1'.

Kiran

Read only

Former Member
0 Likes
1,171

Hi Siddarth,

Entries are there in Database.

Read only

Former Member
0 Likes
1,171

did you try with the select query I had given earlier...

I had given the same one as Kiran has given in his recent post....

Regards,

Siddarth

Edited by: Siddharth Chordia on May 5, 2009 2:21 PM

Read only

0 Likes
1,171

Hi...,

Your following select statement is correct.

Select DOCNUM                                " IDoc number
            DOCTYP                                " IDoc Type
            from  EDIDC into table IT_ZEDIDC
            where CREDAT IN s_credat
            and   DOCTYP IN r_doctyp        " IDOC Types
            and   DIRECT EQ '1'.

Why you are not getting result..

1. structure of the IT_ZEDIDC is having two fields DOCNUM , DOCTYP with same data lengths. If not it should be...

2. Order in the database table is must be similer to the order you maintained in the select statement.

3. As you are hard coding the input ranges make sure about every letter.

4. take a look at other where condition fields too.

5. check the table of the ranges in debugging mode.

6. why can't you declare separate work area and table for ranges...?

like .... data: r_tab type range of <field>

data: wa_tab like line of r_tab.

7. Use clear work area statement after the append statment.

--Naveen Inuganti.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,171

Hello Dheeru,

Can you just change your SELECT stmt to

Select            DOCNUM                                " IDoc number
                     DOCTYP                                " IDoc Type
             from  EDIDC into table IT_ZEDIDC
             where CREDAT EQ s_credat-low
             " and   DOCTYP EQ r_doctyp
             AND IDOCTP IN r_doctyp "--> use this clause
             and   DIRECT EQ '1'.

You can give this a try. I can see in my system DOCTYP is not populated. You can check EDIDC in your system for an existing Idoc & validate:-))

BR,

Suhas

Edited by: Suhas Saha on May 5, 2009 2:28 PM

Read only

Former Member
0 Likes
1,171

Select DOCNUM " IDoc number

DOCTYP " IDoc Type

from EDIDC into table IT_ZEDIDC

where CREDAT EQ s_credat-low

and DOCTYP IN r_doctyp " IDOC Types

and DIRECT EQ '1'.

Kiran

Read only

Former Member
0 Likes
1,171

Hi,

change the select statement as given below...

Select DOCNUM                                " IDoc number
       DOCTYP                                " IDoc Type
             from  EDIDC into table IT_ZEDIDC
             where CREDAT IN s_credat
             and   DOCTYP IN r_doctyp        " IDOC Types
             and   DIRECT EQ '1'.

Regards,

Siddarth

Read only

Former Member
0 Likes
1,171

Hi There,

Your "WHERE" clause is saying "EQ" to r_doctype so is matching to the last value you appended to your range table.

Range tables work like select-options

- you need the syntax to be "WHERE doctype IN r-doctype"

Hope that helps!

Robin

Read only

Former Member
0 Likes
1,171

Instead of EQ you must use IN in your select statement.

remember this when we are using select-options ,in select statement use "IN" only.

for parameters , you have to use "EQ".

Hope it will help you