‎2008 Apr 30 9:37 AM
Hi,
i need to find all values that are present in an internal table that matches the pattern(value) of a given variable.
for eg:
VAR(3) type c value 'B10'.
internal table consists of the following records
___itab-field1_______
B10AAAAA
B10BBBBB
B10CCCCC
B20CCCCC
B20ddddddd
if i have to loop on this internal table to get
B10AAAAA
B10BBBBB
B10CCCCC
what would be the where condition below
loop at itab into...where ????VAR?????
endloop.
your help will be rewarded
Thanks,
gopal.
‎2008 Apr 30 9:42 AM
Hi gopal,
you may try this:
loop at itab where field1 like 'B10_____'. "five underscores
...
endloop.
Each underscore stands for any single character.
Or also:
data: l_pattern(8) type c.
concatenate var '_____' into l_pattern.
loop at itab where field1 like l_pattern.
...
endloop.
I hope this helps. Best regards,
Alvaro
‎2008 Apr 30 9:44 AM
hi,
i write the code below. this may help.
DATA : BEGIN OF lt_table OCCURS 0,
f1(20) ,
END OF lt_table .
DATA : lv_var(3) .
lv_var = 'AAA' .
lt_table-f1 = 'AAA1'.
APPEND lt_table .
lt_table-f1 = 'AAA2'.
APPEND lt_table .
lt_table-f1 = 'BBB1'.
APPEND lt_table .
LOOP AT lt_table where f1+0(3) = lv_var.
write lt_table-f1 .
ENDLOOP.
‎2008 Apr 30 9:47 AM