Application Development and Automation 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: 
Read only

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

Former Member
9,307

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.

amadeusgrabmayer 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

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
5,470

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.

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.

amadeusgrabmayer 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

12 REPLIES 12
Read only

Former Member
0 Likes
5,470

Thanks for your reply.

Unfortunately this:

DATA: LT_TEST type TABLE OF T_TEST WITH DEFAULT KEY.

or this won't work too:

DATA: LT_TEST TYPE HASHED TABLE OF T_TEST WITH UNIQUE KEY key.

I get the same error.

Read only

matt
Active Contributor
0 Likes
5,470

I see you commented on my answer, which I later removed as I felt it wasn't relevant.

Read only

UweFetzer_se38
Active Contributor
5,470

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

0 Likes
5,470

Can you tell me what version you tired it on? I only tried it for version 7.50.

Yes the two step approach works for me too, but still one step would be cooler, right? 🙂

Also it would be very worrying if the two step approch wouldn't work.

Read only

5,470

7.52.

In my opinion the one step and two step approaches should (must?) behave the same.

Read only

Former Member
0 Likes
5,470

Here is the entry in the F1-Help

Read only

matt
Active Contributor
0 Likes
5,470

kai_busse that link seems broken.

Read only

Former Member
0 Likes
5,470

My bad. This is the link.

Read only

Former Member
0 Likes
5,470

Here is another link for the 7.50 release. In point 4 there is also stated, that it probably should work.

Read only

Sandra_Rossi
Active Contributor
5,471

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.

Read only

0 Likes
5,470

Oh, good to know that it works with a non generic reference, but I am wondering why it's working in two steps with a generic reference but not in one. Isn't that the same thing but the read table line is stored in a variable temporarily, instead of being passed directly to the Assign-Statement? (Maybe I can just not grasp the feature completely)

types: begin of T_TEST,
         KEY  type STRING,
         DATA type ref to data,
       end of T_TEST.

data: LT_TEST type TABLE OF T_TEST WITH DEFAULT KEY.

field-symbols: <L_TEST> type ANY.

data(ref) = LT_TEST[ KEY = '123123' ].

assign ref-DATA->* to <L_TEST>.

But thanks for clarifying 🙂

Read only

0 Likes
5,470

I just say that it makes no sense to have it in one line, I just say that ABAP has always been released with limited syntax for internal reasons. I can't explain why SAP delivers partial features. For instance: