2023 May 16 1:22 PM
Compilation Error Message: The data object "LAYOUT KEY" has no structure therefore no component called "Report"
need help is resolving this compilation error as highlighted below(bold and italics).
sap-community-question-alv-report.txt
METHOD SET_LAYOUT.
DATA: LAYOUT TYPE REF TO CL_SALV_LAYOUT,
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT = ALV_TABLE_OBJECT->GET_LAYOUT( ).
LAYOUT->SET_KEY(LAYOUT_KEY).
LAYOUT->SET_SAVE_RESTRICTION(IF_SALV_C_LAYOUT=>RESTRICT_NONE).
ENDMETHOD.
ENDCLASS.
2023 May 17 7:43 PM
You probably didn't post the code corresponding to the error message:
The data object “LAYOUT_KEY” has no structure and therefore no component called “REPORT”
But in your post, you had these lines:
DATA:
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT->SET_KEY(LAYOUT_KEY).
so I guess you have in the actual code something like this:
DATA:
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT_KEY-REPORT = sy-repid.
the issue being that you defined LAYOUT_KEY as a reference variable (REF TO) to a structure, a reference variable has no structure itself, it just contains a reference
So either don't define it as a reference:
DATA:
LAYOUT_KEY TYPE SALV_S_LAYOUT_KEY.
LAYOUT_KEY-REPORT = sy-repid.
or refer to the referenced object using the dereferencing operator like that:
DATA:
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT_KEY->REPORT = sy-repid.
2023 May 16 1:37 PM
Edit your question, select your coding and press the CODE button to make it more readable. Thanks 😛
2023 May 16 4:02 PM
After you have better formatted your code, please also explain which "compiler error" message you have, and we'll answer to you.
2023 May 16 4:10 PM
It's (I guess) at the beginning of the post:
Compilation Error Message: The data object "LAYOUT KEY" has no structure therefore no component called "Report"
I guessed it's because the data object "layout key" has been declared as a reference of something. But I can be wrong (I use to be).
2023 May 17 9:49 AM
Attn Sandra/Vicenc - have reformatted the relevant part of code as below, trust it will be more helpful. ERP 6.0 EHP7 system.
METHOD SET_LAYOUT.
DATA: LAYOUT TYPE REF TO CL_SALV_LAYOUT,
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT = ALV_TABLE_OBJECT->GET_LAYOUT ( ).
LAYOUT_KEY-REPORT = SY-REPID.
LAYOUT->SET_KEY(LAYOUT_KEY).
LAYOUT->SET_SAVE_RESTRICTION(IF_SALV_C_LAYOUT=>RESTRICT_NONE).
ENDMETHOD.
Syntax Error for Program ZRS_ALV3 (ref line highlighted above)
Error Type
Line
Description
Error
61
The data object “LAYOUT_KEY” has no structure and therefore no component called “REPORT”
as Vicenc there seems to be a type ref problem in the highlighted statement as "SALV_S_LAYOUT_KEY." has 3 components name as below but these are not being transferred to "LAYOUT_KEY". Will be very grateful for your help thanks:
REPORT
HANDLE
LOGICAL_GROUP
I am working on the ALV examples given in the SAP Press Book - "ABAP - An Introduction" by Brian O'Neill and Jelena Perfiljeva
2023 May 17 9:53 AM
apologies the formatting of the error message has become garbled above, below picture may be more helpful
2023 May 17 10:09 AM
Attn Sandra/Vicenc - apologies the question was formatted on a word doc which could not be replicated here. Please close this question .
I will repost the same and ensure the formatting is good
apologies once again
thanks
Raman
2023 May 17 7:35 PM
Sorry, but only you can close the question.
Avoid closing + reposting the same. Simply use Actions > Edit to edit your question.
2023 May 17 7:31 PM
Sorry but good formatting is as follows:
METHOD SET_LAYOUT.
DATA: LAYOUT TYPE REF TO CL_SALV_LAYOUT,
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT = ALV_TABLE_OBJECT->GET_LAYOUT( ).
LAYOUT->SET_KEY(LAYOUT_KEY).
LAYOUT->SET_SAVE_RESTRICTION(IF_SALV_C_LAYOUT=>RESTRICT_NONE).
ENDMETHOD.
ENDCLASS.
2023 May 17 7:43 PM
You probably didn't post the code corresponding to the error message:
The data object “LAYOUT_KEY” has no structure and therefore no component called “REPORT”
But in your post, you had these lines:
DATA:
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT->SET_KEY(LAYOUT_KEY).
so I guess you have in the actual code something like this:
DATA:
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT_KEY-REPORT = sy-repid.
the issue being that you defined LAYOUT_KEY as a reference variable (REF TO) to a structure, a reference variable has no structure itself, it just contains a reference
So either don't define it as a reference:
DATA:
LAYOUT_KEY TYPE SALV_S_LAYOUT_KEY.
LAYOUT_KEY-REPORT = sy-repid.
or refer to the referenced object using the dereferencing operator like that:
DATA:
LAYOUT_KEY TYPE REF TO SALV_S_LAYOUT_KEY.
LAYOUT_KEY->REPORT = sy-repid.
2023 May 19 4:49 AM
2023 May 19 8:52 AM
Please use the button COMMENT if it's just about to provide information or reply to someone. The button ANSWER is only for providing the solutions, as you can see the text from SAP when you answer "Please provide a distinct answer and use the comment option for clarifying purposes"