Application Development 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: 

BETWEEN 'abc*' and 'xyz'

Former Member
0 Kudos

Hello Friends,

I need to select following stuff:

e.g All plants starting as abc1, abc2 abc3 ....etc and 'GGAZ'.

so in sql statemtns can I do like this...

SELECT bla bla FROM tab

INTO itab

WHERE ( matnr EQ lv_matnr

AND werks BETWEEN 'abc*' and 'GGAZ'.

Regards,

9 REPLIES 9

Former Member
0 Kudos

define range or select-option and use like this:

r_werks-low = 'ABC*'.

r_werks-high = 'GGAZ'.

r_werks-sign = 'I'.

r_werks-option = 'BT'.

append r_werks.

select ...

where werks in r_werks.

0 Kudos

Hi Tomasz,

in the way I mentioed it will not work ?

Regards,

0 Kudos

The best would be to define select-option and fill default values in initialization event. You will not have to make any changes to your code when new plant appears, just add it to select-option field in selection screen...

Former Member
0 Kudos

hi,

declare a select-optioins for plant,

and select the data in the enterd range

parameters:p_matnr like <tab>-matnr.

select-options:s_werks for <tab>-werks.

<<you can also give the default values for the select-opiton field using initialization event.>>

INITIALIZATION.

s_werks-low = 'ABC'.

s_werks-high = 'GGAH'.

append s_werks.

<<on the screen the above values will be displayed automatically for plant.>>

start-of-selection.

select * from <tab>

into table itab

where matnr = p_matnr

and werks in s_werks.

do assign points for helpful answers

Message was edited by: sowjanya s

Former Member
0 Kudos

yeah u can .

r_werks-sign = 'I'.

r_weers-option = 'BT'.

r_weers-low = 'ABC*'.

r_weers-high = 'GGAZ'.

append r_werks.

clear r_werks.

if r_werks[] is not initial.

SELECT bla bla FROM tab

INTO itab

WHERE matnr EQ lv_matnr

AND werks in r_werks.

endif.

regards

Prabhu

Former Member
0 Kudos

Better option is to define a range for werks and populate it.

r_werks-sign = 'I'.

r_werks-option = 'CP'.

r_werks-low ='abc*'.

append r_werks.

r_werks-option = 'EQ'.

r_werks-low ='GGAZ'.

append r_werks.

When you said abc* and GGAZ...in that case the above range should help as between would give you all the other plants even between the defined range.

Former Member
0 Kudos

SELECT bla bla FROM tab

INTO itab

WHERE ( matnr EQ lv_matnr

AND werks Between 'abc1' to 'GGAZ'.

should work.

santhosh

Former Member
0 Kudos

Hi ,

It may not work.

By defining selection option you can use it with IN operator but I am doughtful about between operator in where clause.

Pankaj

Former Member
0 Kudos

Hi shah,

1. working with such wild card characters *

is very tricky, and sometimes will not suffice the requirement, directly with the sql.

2. Hence, first get all works in an itab.

3.

DATA : TABIX LIKE SY-TABIX.

LOOP AT ITAB.

TABIX = SY-TABIX.

IF ITAB-WERKS CS 'ABC' AND ITAB-WERKS >= 'ABC'.

ELSE.

DELETE ITAB INDEX TABIX.

ENDIF.

ENDLOOP.

regards,

amit m.