2022 Feb 15 10:17 AM
Hello,
I had a question regarding the syntax of the ASSIGN keyword. What is the difference between ASSIGN X TO Y and ASSIGN X->* TO Y? I noticed that this allowed the passage of a TYPE REF TO DATA variable to a STANDARD TABLE field symbol i had, but what exactly does the ->* do?
2022 Feb 28 3:19 PM
Hi edisnord,
->* is a dereferencing operator. It means follow the pointer (->) and show what's behind (*). In your case you're having a dereferenced data reference X that is assigned to Y. This syntax might help:
DATA X TYPE REF TO data.
CREATE DATA X TYPE type.
ASSIGN X->* TO FIELD-SYMBOL(<Y>).
You can find more information here ASSIGN, dynamic_dobj - ABAP Keyword Documentation (sap.com) and here Dereferencing Operator - ABAP Keyword Documentation (sap.com).
Best regards,
Lena
2022 Feb 28 3:19 PM
Hi edisnord,
->* is a dereferencing operator. It means follow the pointer (->) and show what's behind (*). In your case you're having a dereferenced data reference X that is assigned to Y. This syntax might help:
DATA X TYPE REF TO data.
CREATE DATA X TYPE type.
ASSIGN X->* TO FIELD-SYMBOL(<Y>).
You can find more information here ASSIGN, dynamic_dobj - ABAP Keyword Documentation (sap.com) and here Dereferencing Operator - ABAP Keyword Documentation (sap.com).
Best regards,
Lena
2022 Mar 28 2:31 PM
Note than in newer ABAP releases you can use X->* directly in most places in ABAP without using the ASSIGN command.
2022 Apr 07 8:36 AM
Thanks Lena and Kilian, your comments were very informative 🙂