Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Why does FILTER-Statement with secondaray key on table_line not work?

Former Member

Hi,

we expected that the following code always results with a table size of 1. But the filter for "my_tab_f2" returns an empty table.

Something i am missing here? Or is this some kind of bug?

  TYPES:
    BEGIN OF ty_my_struct,
      k1 TYPE char1,
      k2 TYPE char1,
      f1 TYPE char1,
    END OF ty_my_struct,
    ty_my_tab1 TYPE STANDARD TABLE OF ty_my_struct WITH DEFAULT KEY
      WITH NON-UNIQUE SORTED KEY k1 COMPONENTS k1 k2 f1
      WITH NON-UNIQUE SORTED KEY k2 COMPONENTS table_line.


  DATA(my_tab1) = VALUE ty_my_tab1(
    ( k1 = 'a' k2 = 'a' f1 = 'a' )
    ( k1 = 'b' k2 = 'b' f1 = 'b' )
  ).

  DATA(my_tab2) = VALUE ty_my_tab1(
    ( k1 = 'a' k2 = 'a' f1 = 'a' )
  ).

  DATA(my_tab_f1) = FILTER #( 
     my_tab1 IN my_tab2 USING KEY k1 
     WHERE k1 = k1 AND k2 = k2 AND f1 = f1 ).

  DATA(my_tab_f2) = FILTER #( 
     my_tab1 IN my_tab2 USING KEY k2 
     WHERE k1 = k1 AND k2 = k2 AND f1 = f1 ).

  DATA(my_tab_f3) = FILTER #( 
     my_tab1 IN my_tab2 USING KEY k2 
     WHERE table_line = table_line ).

  WRITE: / lines( my_tab_f1 ). " Result: 1
  WRITE: / lines( my_tab_f2 ). " Result: 0
  WRITE: / lines( my_tab_f3 ). " Result: 1
1 ACCEPTED SOLUTION

horst_keller
Product and Topic Expert
Product and Topic Expert

Lo and behold!

I even get an

ABAP_ASSERT

Internal error: Unexpected state in ABAP runtime environment

for that expression in my 7.52 development system.

That promptly goes to DEV ...

4 REPLIES 4

horst_keller
Product and Topic Expert
Product and Topic Expert

Lo and behold!

I even get an

ABAP_ASSERT

Internal error: Unexpected state in ABAP runtime environment

for that expression in my 7.52 development system.

That promptly goes to DEV ...

0 Kudos

Thanks for the quick check!

Do you assume that other statements or combinations with "table_line" are affected?

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

I see the behavior described by you in release 7.51 too. Until convinced otherwise I'd say it's a bug (especially since the syntax warning says that the keys k1 and k2 are identical).

There have been issues with FILTER and table_line before, but I hope there aren't many any more.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

Solved with SAP Note 2451130.

Community -> SAP Note, yay!