on 07-28-2014 6:17 PM
How do I check if a table (structured or simple) contains a given value?
This is what I'd do in ABAP:
READ TABLE lt_table
WITH KEY text = 'foo'
TRANSPORTING NO FIELDS.
IF sy-subrc = 0.
rv_found = abap_true.
ENDIF.
My BRF+ solution is working (using the Loop expression), but appears to be clumsy to me. Is there a better solution?
As an extension: How would I check for a table containing any value from a given list?
ABAP is maybe better than English here:
LOOP AT lt_search ASSIGNING <search>.
READ lt_table WITH KEY text = <search>-value.
IF sy-subrc = 0.
rv_found = abap_true.
RETURN.
ENDIF.
ENDLOOP.
Hi Jürgen,
the table expression should solve your requirement. WIthin the expression you can specifiy several operations on internal tables like "HAS EXACTLY" or "HAS AT LEAST" with a corresponding selection condition. This would resemble your ABAP code and would solve your requirement
Attention: You first have to specifiy the table before you get the selection condition on screen.
Your second case would be a loop expression with a table expression in it.
BR
Christian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gotta love a Table Operation...! Fast become one of my favourite expression types. So often an elegant solution to what would otherwise be an awkward Loop. Just sayin.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.