Application Development 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: 

ABAP Objects-attribute accessability issue

Former Member
0 Kudos
267

Hi,

Let me introduce the problem.

I have a class c1 which has a public attribute a1.

a1 is of table type which refers to a class c2. c2 has an attribute a2 which is public.

With the object o1 of class c1 I need to access a2.

Please help me solve the problem.

Regards,

Ravi

Message was edited by: Ravi Prasad Reddy L

4 REPLIES 4

Former Member
0 Kudos
54

Post what ever coding you have done

0 Kudos
54

Ok, let me give the actual classes and attributes.

The class c1 is "cl_merep_syncbo_meta"

a1 is "field_groups"

field_groups is declared as follows(in the public section of c1):

data FIELD_GROUPS type MEREP_TSYNCBO_FIELD_GROUP read-only .

MEREP_TSYNCBO_FIELD_GROUP is a table type which refers to class CL_MEREP_SYNCBO_FIELD_GROUP (class c2 say)

c2 has the attribute NAME.

I have an object of class c1 as "syncboaccessor"

I tried with this:

syncboaccessor->field_groups->name.

The error I get is "field_groups is not a reference variable".

Regards,

Ravi

manuel_bassani
Contributor
0 Kudos
54

Hi !

if i well undestood your problem this code should works fine..

data: c1 type ref to zc1,

c2 type ref to zc2.

  • ZTAB is a table type containing references of classes ZC2

data: tab type ztab,

wa like line of tab.

create object c1.

create object c2.

  • set values in c2

c2->a2 = 'X'.

  • append c2 into c1 table

append c2 to c1->a1.

  • for all entries in c1 table, retrieve the object reference and prints a2

loop at c1->a1 into wa.

write wa->a2.

endloop.

Best regards, Manuel

Former Member
0 Kudos
54

HI,

Check the below code....

Hope it solves your purpose.

class b definition deferred.

class a definition.

public section.

data : obj2 type ref to b.

methods : write_data.

endclass.

class b definition.

public section.

data : v_num type i.

methods : assign_value.

endclass.

class a implementation.

method write_data.

create object obj2.

call method obj2->assign_value.

write:/1 'Hello Everybody'.

endmethod.

endclass.

class b implementation.

method assign_value.

v_num = 100.

endmethod.

endclass.

data : obj1 type ref to a.

start-of-selection.

create object obj1.

call method obj1->write_data.

write:/1 obj1->obj2->v_num.

Regards,

Vara