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

Substring in SELECT Statemen

Former Member
0 Likes
873

Hello I need to do something like this:

select single bukrs

from ce1xx00

into v_bukrs

where prctr+2(2) = 'ab'.

but is telling me prctr+2(2) is not valid.

How can I do that? I'm doing this in an RFC call and is not affordable to bring all the data from the table

Any ideas?

TIA

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
818

Scott, you can try to use a wildcard. Check this sample program. It will retrieve all program names that the 2nd and 3rd positions = 'RI'. I believe this is the type of functionality that you require.



data: itab type table of trdir with header line.

select * into table itab from trdir
              <b>where name like '_RI%'.</b>
  check sy-subrc  = 0.

REgards,

Rich Heilman

Hello I need to do something like this:

select single bukrs

from ce1xx00

into v_bukrs

where prctr+2(2) = 'ab'.

but is telling me prctr+2(2) is not valid.

How can I do that? I'm doing this in an RFC call and is not affordable to bring all the data from the table

Any ideas?

TIA

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
819

Scott, you can try to use a wildcard. Check this sample program. It will retrieve all program names that the 2nd and 3rd positions = 'RI'. I believe this is the type of functionality that you require.



data: itab type table of trdir with header line.

select * into table itab from trdir
              <b>where name like '_RI%'.</b>
  check sy-subrc  = 0.

REgards,

Rich Heilman

Read only

0 Likes
818

I appollogize for not document all the case from the begining. Table xxx have two fields yyy and zzz. yyy always have 4 letters and zzz have 6. the chars 2 to 6 must be equals to field yyyy. Because of a bug, there are some items that are not consistent. So I need to ask

Where zzz+2(4) ne yyy

Read only

0 Likes
818

Well this is a completely different requirement. Not sure that you can accomplish it with a single select statement.

REgards,

Rich Heilman

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
818

So in your case....



select single bukrs 
from ce1xx00 
into v_bukrs 
where prctr  = '__ab%'. 

You may have to use upper case.



select single bukrs 
from ce1xx00 
into v_bukrs 
where prctr  = '__AB%'. 

REgards,

Rich HEilman