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

RE:ABAP objects

alex_georgek
Associate
Associate
0 Likes
581

Hi all,

Please help me with this.I ahve written a code like this.

CLASS LCL_AIRPLANE DEFINITION.

PUBLIC SECTION.

PRIVATE SECTION.

types:BEGIN OF TY_PLANETYPES,

PLANETYPE TYPE SAPLANE-PLANETYPE,

END OF TY_PLANETYPES.

DATA: wa_LIST_OF_PLANETYPES TYPE TY_PLANETYPES,

LIST_OF_PLANETYPES TYPE STANDARD TABLE OF TY_PLANETYPES.

ENDCLASS. "lcl_airplane DEFINITION

CLASS LCL_AIRPLANE IMPLEMENTATION.

METHOD class_constructor.

SELECT * FROM saplane INTO TABLE list_of_planetypes.

ENDMETHOD.

ENDCLASS .

So now i am getting an error like this

'Within a static method ,you can only access class attributes without further specifications'...What can be the problem.Please correct the code.How to declare an internal table in OOPS ABAP.

Thanks in advance.

Alex.

3 REPLIES 3
Read only

Hannes_Kerber
Product and Topic Expert
Product and Topic Expert
0 Likes
513

Try using "constructor" instead of "class_constructor" for the name of your constructor.

That should work. If not, try selecting into table me->LIST_OF_PLANETYPES instead of just LIST_OF_PLANETYPES.

Hope that works.

Read only

Former Member
0 Likes
513

Since your coding is within a CLASS-CONSTRUCTOR you should define your internal table not with statement DATA but with CLASS-DATA.

Regards,

John.

Read only

Hannes_Kerber
Product and Topic Expert
Product and Topic Expert
0 Likes
513

This would also work. You should decide if you want to declare your internal table as class-data or object data.