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: 

How do I pass a table of objects to global classes (creatd in class buildr)

Former Member
0 Kudos

Using local classes where I type everything in SE38, this is done using the following:


METHOD some_method
    IMPORTING table_of_objects TYPE TABLE OF REF TO z_class

However, I don't know how to do this in the class builder. In the PARAMETER subscreen of the methods tab, the type column only has TYPE, LIKE, and TYPE REF TO.

Please help. Thanks!

--

Kyle

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You need to define a table type in the dictionary (transaction se11). The line type of the table should be a reference type. You can enter the name of your global class in the field for the referenced type. You can then use the table type to declare your method parameter.

-- Sebastian

4 REPLIES 4

Former Member
0 Kudos

You need to define a table type in the dictionary (transaction se11). The line type of the table should be a reference type. You can enter the name of your global class in the field for the referenced type. You can then use the table type to declare your method parameter.

-- Sebastian

uwe_schieferstein
Active Contributor
0 Kudos

Hello Kyle

If you are working already on ERP 6.0 then have a look at class CL_SWF_UTL_ITERATOR and its attribute MT_OBJECT_LIST (of table type SWF_UTL_OBJECT_TAB ).

This table type can hold any type of class. When you iterate over the instances you just need to cast them back into the right class.

Regards

Uwe

naimesh_patel
Active Contributor
0 Kudos

You can also define the PUBLIC table type in the PUBLIC section. Use this table type as the type for your parameter.

In class ZCLASS, create a public table type. use Go to > Public Section and create the type, like:


  types: ty_t_zclass type standard table of ref to zclass.

In your other method, use this type to define the parameter (or attributes)


  IT_ZCLASS_OBJ    IMPORTING    TYPE    ZCLASS=>TY_T_ZCLASS

Regards,

Naimesh Patel

Former Member
0 Kudos

Thanks Naimesh! I think that should be the most elegant solution but it is not working the way we expect it to (the type is not seen by the parameters subscreen).

I have found a workaround though. I hardcoded everything in the public section like you told me to but did not create the type. I created one attribute that is a TYPE TABLE OF REF TO zclass. And whenever I needed to pass data that is also a table of zclass, I just use the LIKE typing.

Thanks all for your inputs!

--

Kyle