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

Need Hello with select statement

Former Member
0 Likes
431

Hi Experts ,

I How can i select all record in where MATNR starl with 1 or 2 or 3 (if there is zero it should not be consider ) I can not use

c_webaz TYPE i.

SELECT rsnum

rspos

rsart

matnr

werks

lgort

charg

bdter

bdmng

meins

enmng

bwart

INTO TABLE gt_resb

FROM resb

WHERE xloek EQ 'X'

AND xwaok EQ space

AND kzear EQ space

AND bwart IN ('201','261','221') .

AND MATNR LIKE '1%'

because if leading zero there it not selection this recode .

Waiting for reply.

3 REPLIES 3
Read only

Former Member
0 Likes
407

Hi Ajay,

First define '1%' in a local variable of type MATNR, and then use that variable in your select stmt. The select stmt. which you have written is fine.

Hope this will resolve your query.

Regards

Nagaraj T

Read only

former_member156446
Active Contributor
0 Likes
407

you can build a range like the sample below and use that in select

MOVE 'I' TO ra_labor-sign.
MOVE 'EQ' TO ra_labor-option.
MOVE c_02 TO ra_labor-low.
APPEND ra_labor.
* CLEAR ra_labor.
MOVE c_21 TO ra_labor-low.
APPEND ra_labor.
* CLEAR ra_labor.
MOVE c_31 TO ra_labor-low. " added
APPEND ra_labor.
CLEAR ra_labor.


SELECT rsnum rspos rsart matnr werks lgort charg bdter bdmng
meins enmng bwart
INTO TABLE gt_resb
FROM resb
WHERE xloek EQ 'X'
AND xwaok EQ space
AND kzear EQ space
AND bwart IN ('201','261','221') .
AND MATNR in ra_matnr              "<<< range you created above

Read only

Former Member
0 Likes
407

Hi,

You can make use of the CP (contains pattern) and NP (does not contain pattern) Options in a WHERE clause range as shown below to achieve your goal.


RANGES: r_matnr FOR mara-matnr.
CLEAR r_matnr.
r_matnr-option = 'NP'.
r_matnr-sign = 'I'.
r_matnr-low = '*0*'.
APPEND r_matnr.
r_matnr-option = 'CP'.
r_matnr-low = '1*'.
append r_matnr.

r_matnr-low = '2*'.
append r_matnr.

r_matnr-low = '3*'.
append r_matnr.

DATA: BEGIN OF itab OCCURS 0, matnr TYPE mara-matnr , END OF itab.

SELECT matnr FROM mara INTO TABLE itab
UP TO 10 ROWS
WHERE matnr IN r_matnr.

What this does is, eliminates all material numbers which have a 0 in them and only includes those which start with 1, 2 or 3 as required.