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

Pattern in select statement.

Former Member
0 Likes
8,134

Hi,

I have to use pattern in select..where statment.

Required value(for select) I am passing from Parameter.

parameter: p_groupid like apqi-groupid.

Here in the selection screen, I can give any pattern like

GPC* or GPC or GPC* etc.....

Thease values should pass to the select.. where.

please let me know how can I do.

Thanks and Regards

Harish

5 REPLIES 5
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
3,507

You should use a SELECT-OPTION instead and make it look like a parameter.

Select-options: s_group for apqi-groupid <b>no intervals no-extension</b>.


*
*
select .....

           where groupid in s_group.

Now you can enter such patterns in your selection screen and the select-option will handle all patterns.

Regards,

Rich Heilman

Read only

suresh_datti
Active Contributor
0 Likes
3,507

You can use pattern in the where clause as follows..


select fld1 fld2 from <dbtab>
                 into table itab
                 where ( groupid like 'GPC%' or
                         groupid like '%GPC%' or
                         groupid like '%G*PC%' or
                         groupid like '%G%P%C%' ).

regards,

Suresh Datti

Read only

0 Likes
3,507

Hi ,

You can use LIKE addition in the select statement.

In your case you can write in the where clause as

where p_groupid like %GPC% .

Just refer this link

http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3a1f358411d1829f0000e829fbfe/content.htm

Regards,

SP.

Read only

Former Member
0 Likes
3,507

Use the LIKE syntax in where:

DATA SCUSTOM_WA TYPE SCUSTOM.

SELECT ID NAME FROM SCUSTOM

INTO CORRESPONDING FIELDS OF SCUSTOM_WA

WHERE NAME LIKE 'M%'.

WRITE: / SCUSTOM_WA-ID, SCUSTOM_WA-NAME.

ENDSELECT.

Example to select all customers whose name contains 'huber':

DATA SCUSTOM_WA TYPE SCUSTOM.

SELECT ID NAME FROM SCUSTOM

INTO CORRESPONDING FIELDS OF SCUSTOM_WA

WHERE NAME LIKE '%huber%'.

WRITE: / SCUSTOM_WA-ID, SCUSTOM_WA-NAME.

ENDSELECT.

Example to select all customers whose name does not contain 'n' as the second character:

DATA SCUSTOM_WA TYPE SCUSTOM.

SELECT ID NAME FROM SCUSTOM

INTO CORRESPONDING FIELDS OF SCUSTOM_WA

WHERE NAME NOT LIKE '_n%'.

WRITE: / SCUSTOM_WA-ID, SCUSTOM_WA-NAME.

ENDSELECT.

REgards,

Ravi

Read only

Former Member
0 Likes
3,507

Hi,

you need to use like option in where clause. and where ever you have * replace it with %

some thing like this..

GPC* you can use like 'GPC%'

or like '%GPC%'...etc.

in your where clause.

Regards

vijay