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: 

Select Query.

Former Member
0 Kudos

Hi,

I am trying to fetch data from a data base table, checking some conditions. My trying like this,

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu

AND moabw = '25'

AND (awart = '0210' or awart = '0220' or awart = '0230' or awart = '0930').

But it showing error for the field AWART. Could you please anybody suggest me how to correct my query.

Thanks,

Ram.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI,

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu

AND moabw = '25'

AND awart IN ( '0210' , '0220' , '0230' , '0930').

8 REPLIES 8

nikhil_chitre
Active Participant
0 Kudos

Hi,

Create a Range for field AWART.

Fill this range with desider values for selection.

And then use the select query.

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu

AND moabw = '25'

AND awart IN r_awart.

Hope this helps.

Regards,

Nikhil

Edited by: Nikhil A Chitre on Jun 23, 2008 12:17 PM

Former Member
0 Kudos

try this,

used ranges.

*Create range for awart

r_awart-sign = 'I'.

r_awart-option = 'EQ'.

r_awart-low = '0210'.

append r_awart.

r_awart-low = '0220'.

append r_awart.

r_awart-low = '0230'.

append r_awart.

r_awart-low = '0930'.

append r_awart.

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu

AND moabw = '25'

AND awart in r_awart.

reward if its useful.

Link : [ABAP Tips|http://abap4beginner.blogspot.com]

Former Member
0 Kudos

Hi Ram,

Try this way...

SELECT SINGLE atext
  INTO p_leave_type_text
  FROM t554t
 WHERE sprsl = sy-langu
   AND moabw = '25'
   AND ( awart = '0210'
    OR   awart = '0220'
    OR   awart = '0230'
    OR   awart = '0930' ).

Best regards,

raam

Former Member
0 Kudos

HI,

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu

AND moabw = '25'

AND awart IN ( '0210' , '0220' , '0230' , '0930').

kesavadas_thekkillath
Active Contributor
0 Kudos

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE moabw = '25'

AND awart in ('0210','0220','0230','0930')

and sprsl = sy-langu.

former_member598013
Active Contributor
0 Kudos

Hi Ram,

Create a Range and append all the data in the range and pass it in the select query.

RANGES: R_AWART FOR T554T-AWART.

R_AWART-SIGN = 'I'.

R_AWART-OPTION = 'EQ'.

R_AWART-LOW = '0210'.

APPEND R_AWART.

R_AWART-SIGN = 'I'.

R_AWART-OPTION = 'EQ'.

R_AWART-LOW = '0220'.

APPEND R_AWART.

R_AWART-SIGN = 'I'.

R_AWART-OPTION = 'EQ'.

R_AWART-LOW = '0230'.

APPEND R_AWART.

R_AWART-SIGN = 'I'.

R_AWART-OPTION = 'EQ'.

R_AWART-LOW = '0930'.

APPEND R_AWART.

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu

AND moabw = '25'

AND awart IN R_AWART.

&***********Reward Point if helpful****************&

Former Member
0 Kudos

Hi,

Either you need to create a Range table or use IN clause or use Select-options.

1. Ranges:

Ranges: r_awart for t554t-awart.

*Create range for awart
r_awart-sign = 'I'.
r_awart-option = 'EQ'.
r_awart-low = '0210'.
append r_awart.
r_awart-low = '0220'.
append r_awart.
r_awart-low = '0230'.
append r_awart.
r_awart-low = '0930'.
append r_awart.

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu
AND moabw = '25'
AND awart *in*  r_awart.

2. Use IN clause :

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE sprsl = sy-langu
AND moabw = '25'
AND awart *IN* ( '0210' , '0220' , '0230' , '0930').

3. Use Select-options instead of parameter for awart :

select-options: s_awart for t554t-awart no intervals.

this will work same as parameter and even you can have any values for awart.

SELECT SINGLE atext I
NTO p_leave_type_text 
FROM t554t 
WHERE sprsl = sy-langu
AND moabw = '25'
AND awart *IN* s_awart.

This will surely help you.

Plz reward if useful.

Thanks,

Dhanashri.

Edited by: Dhanashri Pawar on Jun 23, 2008 8:22 AM

Edited by: Dhanashri Pawar on Jun 23, 2008 8:23 AM

Former Member
0 Kudos

Hi,

Use your query like this .

SELECT SINGLE atext INTO p_leave_type_text FROM t554t WHERE moabw = '25'

AND and sprsl = sy-langu

AND awart in ('0210','0220','0230','0930')

Other wise you can made range for the field awart but if you write like this your query will run faster and data fetching will be efficient and your code lines will be reduced.

I hope this will help you.

Help children of U.N World Food Program by rewarding points and encourage others to answer your queries.