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

select query problem?

Former Member
0 Likes
1,254

Guys,

with the following select statement data is not coming correctly.pleae help on this.

select werks lifnr from t001w into table int_t001w where

werks in s_werks and

werks in s_werks1.

regards,

vijay

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,219

select werks lifnr from t001w into table int_t001w where

werks in s_werks <b>or</b>

werks in s_werks1.

12 REPLIES 12
Read only

Former Member
0 Likes
1,220

select werks lifnr from t001w into table int_t001w where

werks in s_werks <b>or</b>

werks in s_werks1.

Read only

Former Member
0 Likes
1,219

hi

we use IN in the where clause when we deal with select options in reporting.

otherwise, to correct ur statement use '=' operator in where clause.

Reward points if helpful.

Naveen

Read only

Former Member
0 Likes
1,219

Or you can simply do away with one select-options

append lines of s_werks1 to s_werks.

select werks lifnr from t001w into table int_t001w where

werks in s_werks.

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

Former Member
0 Likes
1,219

Hi vijay,

Explain your requirement then we can come out with exact select statement.

Azaz Ali.

Read only

Former Member
0 Likes
1,219

Hi Vijay

select werks lifnr from t001w into table int_t001w where

werks in s_werks and

werks in s_werks1.

collect int_t001w.

You have to use collect statement.

Regards

Abhishek

Read only

Former Member
0 Likes
1,219

Hi,

What is the difference in S_WERKS and S_WERKS1??

Read only

Former Member
0 Likes
1,219

Hi Vijay,

your Problum is :

select werks lifnr from t001w into table int_t001w where

werks in s_werks and

werks in s_werks1.

append lines of s_werks1 to s_werks.

you can use collect statement through it you can add all the int. values.

Regards.

Ankur garg.

Message was edited by: Ankur Garg

Read only

Former Member
0 Likes
1,219

Hi Vijay,

I have made a slight change to your select statement.

Please find it below.


select werks lifnr from t001w 
                   into table int_t001w 
                   where werks in s_werks 
                <b> or </b> werks in s_werks1.

Hope it solves your problem.

Regards,

Anirban.

Read only

Former Member
0 Likes
1,219

Hi,

Combine both the select options and pass that only in where clause.

append lines of s_werks1 to s_werks.

select werks 
       lifnr
   from t001w 
   into table int_t001w
 where werks in s_werks.

Regards

vijay

Read only

abdul_hakim
Active Contributor
0 Likes
1,219

Hi

use the below code..

APPEND LINES OF s_werks1 TO s_werks.

select werks lifnr from t001w into table int_t001w where

werks in s_werks.

Cheers,

Abdul Hakim

Read only

Former Member
0 Likes
1,219

Hi Vijay,

I assume that your using <b>s_werks</b> and <b>s_werks1</b> to input multiple values and ranges for werks.

This can be done using a single <b>select-option</b>.

Consider this code.


REPORT zztest.

TABLES : t001w.

DATA : int_t001w TYPE STANDARD TABLE OF t001w WITH HEADER LINE.
SELECT-OPTIONS : s_werks FOR t001w-werks.


INITIALIZATION.

<b>*Values in Ranges</b>
  s_werks-sign = 'I'.
  s_werks-option = 'BT'.
  s_werks-low = '1000'.
  s_werks-high = '2000'.
  APPEND s_werks.
  CLEAR s_werks.

<b>*Values in Ranges</b>
  s_werks-sign = 'I'.
  s_werks-option = 'BT'.
  s_werks-low = '4000'.
  s_werks-high = '5000'.
  APPEND s_werks.
  CLEAR s_werks.

<b>*Single Value</b>
  s_werks-sign = 'I'.
  s_werks-option = 'EQ'.
  s_werks-low = '2200'.
  APPEND s_werks.
  CLEAR s_werks.


START-OF-SELECTION.

  SELECT werks lifnr FROM t001w INTO TABLE int_t001w WHERE
  <b>werks IN s_werks</b>.

Regarding you code,

Instead of <b>AND</b> put a <b>OR</b> condition



  SELECT werks lifnr FROM t001w INTO TABLE int_t001w WHERE
  werks IN s_werks <b>OR</b>
  werks IN s_werks1.

Regards,

Arun Sambargi.

Read only

Former Member
0 Likes
1,219

Thanks to all,problem is solved.