Skip to Content
2

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

Mar 21, 2017 at 12:39 PM

101

avatar image

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
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Horst Keller
Mar 21, 2017 at 12:56 PM
2

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 ...

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks for the quick check!

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

0

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.

0
Horst Keller
Apr 03, 2017 at 03:52 PM
0

Solved with SAP Note 2451130.

Community -> SAP Note, yay!

Share
10 |10000 characters needed characters left characters exceeded