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

what does this statement mean?

Former Member
0 Likes
1,270

can anyone tell me what the statement in bold here is?

CREATE OBJECT obj1->o2.


what does this create object implying an attribute of class c1? create object will just create and instance of class right? what exactly is this sentence?


CLASS c1 DEFINITION.

  PUBLIC SECTION.

  DATA o2 TYPE REF TO c2.

ENDCLASS.

CLASS c2 DEFINITION.

PUBLIC SECTION.

  DATA : num TYPE i VALUE 5.

ENDCLASS.

START-OF-SELECTION.

  DATA : obj1 TYPE REF TO c1.

  CREATE OBJECT obj1.

  CREATE OBJECT obj1->o2.

  WRITE : /5 obj1->o2->num.

Thanks & Regards

1 ACCEPTED SOLUTION
Read only

0 Likes
1,066

Hi Anjali,

In your above code CREATE OBJECT obj1->o2 is used for creating object o2 for class c2.

As because you have declared the object O2 inside the class C1 you can't directly access to the object O2 outside the class.

CLASS c1 DEFINITION.

  PUBLIC SECTION.

  DATA o2 TYPE REF TO c2.

ENDCLASS

You need an Instance of the class C1 ie obj1. Through the instance or object you can create the object of class c2 or object O2.

Regards,

Swaroop

3 REPLIES 3
Read only

0 Likes
1,067

Hi Anjali,

In your above code CREATE OBJECT obj1->o2 is used for creating object o2 for class c2.

As because you have declared the object O2 inside the class C1 you can't directly access to the object O2 outside the class.

CLASS c1 DEFINITION.

  PUBLIC SECTION.

  DATA o2 TYPE REF TO c2.

ENDCLASS

You need an Instance of the class C1 ie obj1. Through the instance or object you can create the object of class c2 or object O2.

Regards,

Swaroop

Read only

SharathYaralkattimath
Contributor
0 Likes
1,066

This message was moderated.

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,066

Hi,

Seems like you creating an inner object (O2) (and this is working) .

I put c2 before c1 .

Regards .