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 select

Former Member
0 Likes
554

hi all

Parameters : p_fam(3) type c.

Select single Prodh8(3) from t179 into gv_family where prodh8(3) = p_fam.

write : gv_family.

I need to validation like this.

But this code is not working, let anybody know how to solve this substring.

any keyword help is appreciable.

Regards,

Madhavi

3 REPLIES 3
Read only

naimesh_patel
Active Contributor
0 Likes
490

You can't use the substring directly in the select query.

Try to get all relevent records into an internal table and than do the substring processing.

Regards,

Naimesh Patel

Read only

0 Likes
490

Hi,

Just copy the following code & execute it. This pgm selects all records from MAKT where 3rd character of the description is 'E'. You may run & see. This is the code.

TYPES: BEGIN OF t_makt.

INCLUDE STRUCTURE makt.

TYPES: END OF t_makt.

DATA: t_makt TYPE TABLE OF t_makt,

t_makt_wa TYPE t_makt.

data: w_ii type i.

*

tables makt.

Select * from makt into table t_makt

where maktx like '__E%'.

break-point.

I hope this helps,

Regards

Raju Chitale

Read only

Former Member
0 Likes
490

DATA: gv_fam_pattern TYPE prodh,
      gv_prodh TYPE prodh.

CONCATENATE '________' p_fam '%' INTO gv_fam_pattern.
SELECT SINGLE prodh 
         INTO gv_prodh 
         FROM t179 
        WHERE prodh LIKE gv_fam_pattern.
gv_family = gv_prodh+8(3).

Note: above code was not checked or tested, use at your own risk. For one, it will not handle families of less than 3 characters nicely.

Or use native SQL.

Oh, and tell your analysts to not put smarts or meaning into object ID's.

Greetings,

Gert.