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: 

Substring in SELECT Statemen

Former Member
0 Kudos

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

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

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

0 Kudos

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

REgards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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