2019 Apr 17 11:03 AM
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
2019 Jun 07 7: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.
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
2019 Apr 17 2:23 PM
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.
2019 Apr 17 5:39 PM
I see you commented on my answer, which I later removed as I felt it wasn't relevant.
2019 Apr 18 10: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>.
2019 Apr 18 12:00 PM
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.
2019 Apr 18 12:10 PM
7.52.
In my opinion the one step and two step approaches should (must?) behave the same.
2019 Jun 06 1:37 PM
2019 Jun 06 6:31 PM
2019 Jun 06 7:21 PM
2019 Jun 07 6:26 AM
Here is another link for the 7.50 release. In point 4 there is also stated, that it probably should work.
2019 Jun 07 7: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.
2019 Jun 07 8:16 AM
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 🙂
2019 Jun 07 8:27 AM
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: