cancel
Showing results for 
Search instead for 
Did you mean: 

Contains pattern in select

Former Member
0 Kudos

Hi All,

I have a requirment in select statement as below.

SELECT anln1

anln2

typbz

FROM anla

INTO TABLE it_anla

FOR ALL ENTRIES IN it_asset

WHERE typbz = it_asset-purch. "Contains pattern

IF sy-subrc EQ 0.

SORT it_anla BY typbz anln1 anln2.

ENDIF.

i need to select the ANLA table entries which contains the pattern IT_ASSET-purch which is not constant. like it_asset-purch* .

but its giving error if i write like this.

can any one suggest me good way of doing this.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member376453
Contributor
0 Kudos

Hi - Best way is using a range table :


"Define Range table and Work area
data:  i_rng    TYPE RANGE OF typbz   INITIAL SIZE 0,    "table 
data:  wa_wng LIKE LINE OF  i_rng    " Work area

wa_rng-sign = 'E'.
wa_rng-option = 'CP'
wa_rmg-low = " Put concatenated value

" Now use this range table for you selection, as you use select-option, when selecting.

Answers (3)

Answers (3)

awin_prabhu
Active Contributor
0 Kudos

Try this way..

SELECT anln1

anln2

typbz

FROM anla

INTO wa. <--- 'wa' workarea for table 'it_anla'

LOOP AT it_asset WHERE purch = wa-typbz.

IF sy-subrc EQ 0.

SORT it_anla BY typbz anln1 anln2.

ENDIF.

ENDLOOP.

ENDSELECT.

Edited by: Sap Fan on Mar 24, 2009 2:39 PM

former_member156446
Active Contributor
0 Kudos

you might have to create a range table.. and populate it and use that range in the select...

loop at it_asset into wa_asset.
ra-sign = 'E'.
ra-option = 'CP'
concatenate '*'  it_asset-purch '*' into ra-low.
append it_asset from wa_asset.
clear: wa_asset.
endloop.

select,,,,,

.. where t&*( in ra. "ra is the range table.

Former Member
0 Kudos

move the values from it_asset-purch table to a range and then use CP in the options.