Skip to Content
0
Jan 02, 2008 at 10:56 PM

How to access an object (-reference) in an internal table?

2384 Views

Hi everybody,

I've got a problem with Abap objects concerning object references in an ECC 6.0 system.

I try to read an iBase starting at an specified level.

To do so I'm using the function module 'IB_COM1_READ_LEVEL'.

... <snip>

CALL FUNCTION 'IB_COM1_READ_LEVEL'

EXPORTING

i_ibco_handle = lv_handle

i_ibase = lv_ibase

i_moment = lv_timestamp

i_par = ls_level_down

i_marked_obj_tab = lt_marked_obj_tab

IMPORTING

e_instance_tab1 = lt_instance

EXCEPTIONS

ib_handle_not_defined = 1

OTHERS = 2.

... <snip>

Everything is fine and I get the right data in the table lt_instance as I can see in the debugger.

The problem is, that one field of the table lt_instance contains an objects (field named object) which is a reference to different classes (here cl_ibase_r3_equipment and cl_ibase_r3_material depending on the content of the iBase).

As I need the material number of the materials rows, I need to call a method of cl_ibase_r3_material for each material row to get the material number.

BUT: How to access this reference?

In the debugger I can just navigate into the object, but currently I can't access it through my program.

I tried it using field symbols and assigned the field "object" of the table lt_instance (in a loop) to the field-symbol. But what type should the field symbol have?

If I define it as "any" the system tells me, that it is no reference.

Defined as "type ref to cl_ibase_r3_material" it doesn't work either because the field "object" is defined as "type ref to if_ibase_object" and they do not match.

I think I have implement anything using "create data" or something like this, but I have no idea how to do it.

If you have any suggestions, please let me know.

Thanks in advance.

Harry