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

Accessing Objects from a Class

Former Member
0 Likes
1,287

Hello,

I have a process that calls a method from a class, at runtime, the object creates a reference and in the reference I need to access an object, basically this is what I have at run time:

Object: WA_OBJECT

Reference:

If I double click on my object I get the following sub objects:

CL_PT_REQ_HEADER

IF_PT_REQ_HEADER~CURRENT_VERSION

IF_PT_REQ_HEADER~MAX_VERSION_NO

IF_PT_REQ_HEADER~MY_REQUEST

ITEM_TAB

if I double click on any of those items, it is fine in debugging, I can see the values, but in my program, I need to access the ITEM_TAB internal table, now I cannot use WA_OBJECT-ITEM_TAB. If I double click on the ITEM_TAB, now the main object becomes -ITEM_TAB[1], so cannot reference to that object in my program, so the question is how do I access the table?

Thanks for any answers.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,056

Hello

I would like to add that you are dealing with a <b>persistence class</b>. Perhaps the following thread may be of use since persistence classes require a specific logic.

Regards

Uwe

4 REPLIES 4
Read only

uwe_schieferstein
Active Contributor
0 Likes
1,056

Hello Enrique

ITEM_TAB is a <i>public </i>instance attribute of class CL_PT_REQ_HEADER. Thus, you can directly access them using

DATA:
  ls_item    TYPE PTREQ_ITEMS_STRUC,
  lo_item    TYPE IF_PT_REQ_ITEM.

  LOOP AT wa_object->item_tab INTO ls_item.
    lo_item = ls_item-item.
  ENDLOOP.

Regards

Uwe

Read only

0 Likes
1,056

Uwe,

thanks for your prompt answer. Now that you mention it, I forgot to specify the fact that only the first Items are public, but the table is protected and I cannot do a simple loop at it the way you mentioned. That is the first thing I tried but wa_object->item_tab is not recognized when I ckeck syntax. I should have also mentioned that WA_OBJECT gets referenced ar runtime.

Read only

Former Member
0 Likes
1,056

Hopefully there is a method of WA_OBJECT which can give you the information you need.

Trying to directly read the contents of a private table is defeating the whole philosophy of object oriented programming.

Michael

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,057

Hello

I would like to add that you are dealing with a <b>persistence class</b>. Perhaps the following thread may be of use since persistence classes require a specific logic.

Regards

Uwe