Skip to Content
avatar image
Former Member

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

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
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Mar 21, 2017 at 12:56 PM

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

    Add comment
    10|10000 characters needed characters exceeded

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

  • Apr 03, 2017 at 03:52 PM

    Solved with SAP Note 2451130.

    Community -> SAP Note, yay!

    Add comment
    10|10000 characters needed characters exceeded