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 query

Former Member
0 Likes
557

hoe could i use like statement in select query?

plz reply............

Thanks in advance.

5 REPLIES 5
Read only

Former Member
0 Likes
541

yes

select * from mara where matnr like '100%'.

it will fetch the matnr which starts with 100.

if you want dynamic

data : mat(4).

concatenate '100' '%' into mat

select * from mara where matnr like mat.

regards

shiba dutta

Read only

former_member386202
Active Contributor
0 Likes
541

Hi,

Yes, you can use.

Regards,

Prashant

Read only

Former Member
0 Likes
541
Read only

Former Member
0 Likes
541

Hi,

Like 'Char%' in where condition.

select maktx from makt where maktx like 'MAT%'.

It will select all the records with MAT as starting letter.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
541

Hi,

In the select statement the use of LIKE is possible to get the values based on a pattern.

Code:

where matnr LIKE 'M1%' means all Matnr starts with M1

where matnr LIKE '%M1%' means all Matnr that contains M1

You have to use % for any combination of characters

and _ for single character in the LIKE operator.

Check the code.

SELECT DISTINCT MAT_SALES

FROM /BI0/PMAT_SALES

INTO TABLE i_mat_sales

WHERE /BIC/ZACCASGRP IS INITIAL

OR /BIC/ZACCASGRP LIKE '%'

OR /BIC/ZACCASGRP LIKE 'A1%' "Starts with A1

OR /BIC/ZACCASGRP LIKE 'C3%'.

LOOP AT SOURCE_PACKAGE into source_wa.

T_INDEX = SY-TABIX.

READ TABLE I_MAT_SALES WITH KEY MSALE =

source_wa-MAT_SALES TRANSPORTING NO FIELDS.

IF SY-SUBRC NE 0.

DELETE SOURCE_PACKAGE INDEX T_INDEX.

ENDIF.

Reward if Helpful.

Regards,

Harini.S