Skip to Content
author's profile photo Former Member
Former Member

ABAP Objects-attribute accessability issue

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 28, 2005 at 10:39 AM

    Post what ever coding you have done

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Posted on Jul 28, 2005 at 10:57 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 28, 2005 at 11:09 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.