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... where... question

Former Member
0 Likes
671

Hi,

We need to do a select single only for a part of a field...

something like...

select single bktxt

into w_bktxt

from bkpf

where bktxt(4) eq '1234'.

Thanks In Advance

Juan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
651

select single bktxt
into w_bktxt
from bkpf
where bktxt like '1234%'.

Greetings,

Blag.

5 REPLIES 5
Read only

Former Member
0 Likes
651

HI,

you cannot use the offset specification for a database field.

rather u try this.

select single bktxt

into w_bktxt

from bkpf

where bktxt like '1234%'.

Thanks

Mahesh

Read only

Former Member
0 Likes
652

select single bktxt
into w_bktxt
from bkpf
where bktxt like '1234%'.

Greetings,

Blag.

Read only

0 Likes
651

Thanks Mahesh and Alvaro...

Can i do this?

data w_ad(4) type c.

concatenate w_ad '%' into w_ad

and then

select single bktxt

into w_bktxt

from bkpf

where bktxt like w_ad.

if w_ad is '123 ' the select will be sy-subrc = 4 ?

Thanks In Advance

Juan

Read only

0 Likes
651

> Can i do this?

>

> data w_ad(4) type c.

>

> concatenate w_ad '%' into w_ad

Sure, the code it's ok -:) But w_ad must have a value first -;)

w_ad = '123'.

concatenate w_ad '%' into w_ad.

> and then

>

> select single bktxt

> into w_bktxt

> from bkpf

> where bktxt like w_ad.

Yes...It can be done that way...

> if w_ad is '123 ' the select will be sy-subrc = 4 ?

The <b>%</b> works like this....123% is equal as saying....123(and every number)...

So if you perform your SELECT and the value stored in the DB is 123, the SY-SUBRC is going to 0...But if the value stored in the DB is for example 132, then the SY-SURBC is going to be 4 -:)

Greetings,

Blag.

Read only

0 Likes
651

Yes if you have w_ad defined with length 5 and default it to 1234.

data w_ad(5) type c value '1234'.

concatenate w_ad '%' into w_ad

condense w_ad no-gaps.

select single bktxt

into w_bktxt

from bkpf

where bktxt like w_ad.

This will bring any document that has a BKTXT value that starts with 1234