cancel
Showing results for 
Search instead for 
Did you mean: 

How to check if BRF+ table contains value(s)

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

christianlechne
Active Contributor
0 Kudos

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

carsten_ziegler
Active Contributor
0 Kudos

To be precise, it's called "Table Operation" expression

christianlechne
Active Contributor
0 Kudos

Thanks for the clarification ... somehow missed the word in the middle when typing the answer

Jocelyn_Dart
Product and Topic Expert
Product and Topic Expert

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.

Answers (0)