2023 Sep 28 7:22 PM
Dear Experts,
If I get a pattern from selection screen as a range, how can I use the range to remove lines with patterns in range from internal table?
For example:
I have r_dummy as a range
r_dummy-low = Dummy
Recorded data in the field in the internal table be like: [ Dummy_aaaaaa, Dummy_123, name2, name2]
how to remove the line?
I tried add * to r_dummy-low
then try like below but it doesn’t work:
DELETE lt_data WHARE field NP r_dummy-low.
And I try use it as a part of selection statement like :
SELECT *
FROM table
INTO TABLE lt_data
WHERE field NOT IN r_dummy
it doesn’t work either.
I need a clue.
Best Regards,
2023 Sep 28 8:16 PM
Please use the CODE formatting button. The question would be much more legible:
Dear Experts,
If I get a pattern from selection screen as a range, how can I use the range to remove lines with patterns in range from internal table?
For example:
I have r_dummy as a range
r_dummy-low = Dummy
Recorded data in the field in the internal table be like: [ Dummy_aaaaaa, Dummy_123, name2, name2]
how to remove the line?
I tried add * to r_dummy-low
then try like below but it doesn’t work:
DELETE lt_data WHARE field NP r_dummy-low.
And I try use it as a part of selection statement like :
SELECT *
FROM table
INTO TABLE lt_data
WHERE field NOT IN r_dummy
it doesn’t work either.
I need a clue.
Best Regards,
2023 Sep 28 8:21 PM
I don't understand your question at all. Why "dummy"? Why do you need to transform your selection screen criteria into something else before using it in SELECT?
2023 Sep 29 7:40 AM
Hello,
range table (or SELECT-OPTION, which is also range table) has four fields:
If you want to use pattern correctly, then OPTION field needs to have value (operator) "CP" or "NP". These two are explained here: https://help.sap.com/doc/abapdocu_731_index_htm/7.31/en-US/abenlogexp_strings.htm
In your example r_dummy table should have:
If it is SELECT-OPTION, then user can enter "Dummy*" and this entry will automatically be with OPTION = CP.
2023 Sep 29 7:41 AM
First prepare your range accordingly to your requirement, so if you want to have Dummy* filtered it should be
r_dummy-sign = `I`. "Include
r_dummy-option = `CP`. "Contains pattern
r_dummy-low = `Dummy*`.
APPEND r_dummy TO rt_dummy.
And then you can either use FILTER statement for it:
DATA(filtered_data) = FILTER #( lt_data WHERE field IN rt_dummy ).
Or you can delete unwanted entries from the internal table instead.
DELETE lt_data WHERE field NOT IN rt_dummy.
2023 Sep 29 8:31 AM
It seems that your question is clear for other people, if I merge their interpretations and what I partly understand from your question, I would opt for a third "answer" which might correspond to what you're looking for:
DATA(r_range_without_dummy) = r_range.
r_range_without_dummy = VALUE #(
( LINES OF r_range_without_dummy )
( sign = 'E'
option = 'CP' " CP is case-insensitive
low = 'dummy*' ) ).
SELECT *
FROM table
INTO TABLE lt_data
WHERE field IN r_range_without_dummy.
2023 Sep 29 8:31 AM