Skip to Content

A generic reference cannot be dereferenced (->) in the current statement.

Hello,

I am currently on SAP_BASIS 7.50 and I have this issue.

When I do a table expression in a ASSIGN statement and try to de-reference data in the same statement I get this error:

A generic reference cannot be de-referenced (->) in the current statement.

This is a rough construct of what I am trying to do:

TYPES: BEGIN OF t_test,
       key Type string,
       r_data TYPE REF TO data,
       END OF t_test.

DATA: lt_test TYPE TABLE OF t_test.

FIELD-SYMBOLS: <l_test> TYPE any.


ASSIGN lt_test[ key = '123123' ]-r_data->* TO <l_test>.

(It does also not work if the table is filled)

Did anyone run into the same error?

I also saw a Comment in this post from Horst Keller.

Amadeus Grabmayer had a different issue while trying the same thing.

It also says in my F1-Help that it should work. Am I doing something wrong syntax-wise?

I am looking forward to your answers.

Kind regards,

Kai

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 07 at 06:34 AM

    It's not a bug, it's a feature! (maybe that will be supported in future releases)

    The message says the issue is about generic references.

    If you don't type it generically, it will work. Example:

    TYPES: BEGIN OF t_test,
           key Type string,
           r_data TYPE REF TO scarr, " <--- a NON-generic reference
           END OF t_test.
    DATA: lt_test TYPE TABLE OF t_test.
    FIELD-SYMBOLS: <l_test> TYPE any.
    
    ASSIGN lt_test[ key = '123123' ]-r_data->* TO <l_test>.

    If you want to use a generic reference, do it in two steps.

    PS: that limit doesn't surprise me, ABAP has always been like that (especially for ->*). You can see that if you read the ABAP release notes in the ABAP documentation.

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 18 at 09:42 AM

    Looks like a kernel bug for me because this two step approach works:

    DATA(ls_test) = lt_test[ key = '123123' ].
    ASSIGN ls_test-r_data->* TO <l_test>.
    
    Add comment
    10|10000 characters needed characters exceeded