01-27-2010 9:18 AM
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
01-27-2010 11:00 AM
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
01-27-2010 11:00 AM
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
01-27-2010 11:49 AM
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
01-27-2010 2:49 PM
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
01-29-2010 6:05 AM
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