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

Self Training on ALV Report - METHOD SET_LAYOUT - compilation error

raman_sethi
Explorer
0 Likes
4,102

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.

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
4,041

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

VXLozano
Active Contributor
4,038

Edit your question, select your coding and press the CODE button to make it more readable. Thanks 😛

Read only

Sandra_Rossi
Active Contributor
4,038

After you have better formatted your code, please also explain which "compiler error" message you have, and we'll answer to you.

Read only

VXLozano
Active Contributor
0 Likes
4,038

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).

Read only

raman_sethi
Explorer
0 Likes
4,038

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

Read only

raman_sethi
Explorer
0 Likes
4,038

apologies the formatting of the error message has become garbled above, below picture may be more helpful

Read only

raman_sethi
Explorer
0 Likes
4,038

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

Read only

0 Likes
4,038

Sorry, but only you can close the question.

Avoid closing + reposting the same. Simply use Actions > Edit to edit your question.

Read only

Sandra_Rossi
Active Contributor
4,038

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

Sandra_Rossi
Active Contributor
4,042

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

raman_sethi
Explorer
0 Likes
4,038

Thanks Sandra my issue is resolved

Read only

4,038

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"