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 statment

Former Member
0 Likes
681

I want select data from ztable.

ztable contains fields like objnr,stat,acc.

i want to read records from Objnr like 'OR.....'.

I have some exclude conditions.

stat = '23' and acc = ' '.

stat = '28' and acc = ' '.

stat = '39' and acc = ' '.

please the provide the logic.

Regards,

Suresh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
654

Hi,

Ex:

  • Ranges declaration

DATA: r_bukrs TYPE RANGE OF tka02-bukrs.

rs_bukrs-sign = 'I'

rs_bukrs-option = 'EQ'

rs_bukrs-low = 'IN01'.

APPEND rs_bukrs TO r_bukrs.

Regards,

Kalp...

5 REPLIES 5
Read only

former_member404244
Active Contributor
0 Likes
654

Hi,

create two range tables as r_stat and r_acc with the values u want to exclde..

Select * from ztable where objnr like 'OR%'

and stat not in r_stat

and acc not in r_acc.

Regards,

Nagaraj

Read only

0 Likes
654

Hi,

How to bulid range table give me simple example

Regards,

Suresh

Read only

Former Member
0 Likes
655

Hi,

Ex:

  • Ranges declaration

DATA: r_bukrs TYPE RANGE OF tka02-bukrs.

rs_bukrs-sign = 'I'

rs_bukrs-option = 'EQ'

rs_bukrs-low = 'IN01'.

APPEND rs_bukrs TO r_bukrs.

Regards,

Kalp...

Read only

Former Member
0 Likes
654
Select * from ztable INTO TABLE itab where objnr like 'OR%'
and stat NOT in ( '23', '28', '29')
and acc NE ''.
Read only

Former Member
0 Likes
654

Hi Suresh,

You can try something like this,

tables ztable.

ranges: r_stat for ztable-stat,

r_acc for ztable-acc.

r_stat-sign = 'E'.

r_stat-option = 'EQ'.

r_stat-low = '23'.

append r_stat.

r_stat-sign = 'E'.

r_stat-option = 'EQ'.

r_stat-low = '28'.

append r_stat.

r_stat-sign = 'E'.

r_stat-option = 'EQ'.

r_stat-low = '39'.

append r_stat.

r_acc-sign = 'E'.

r_acc-option = 'EQ'.

r_acc-low = ''.

append r_acc.

now use the select statement and use these ranges to be excludes in the where clause as follows

select * from ztable into table itab where objnr like 'OR%' and stat in r_stat and acc in r_acc.

This should exclude all values in the r_stat and r_acc along with objnr like OR.

Thanks and Regards,

Sachin Dargan