02-28-2008 2:29 PM
Hi All,
I want to store a number of ZCL_BDC_FIELD objects into an internal table.
What is the easiest eay to do this? Here's my attempt...
Types: begin of ty_field_itab,
fld type ref to ZCL_BDC_FIELD,
end of ty_field_itab.
in the private section of another class
data: field_itab type table of ty_field_itab.
*still in other class,
append field to fielditab.
Which gives an error! Cannot convert field to field of type fielditab.
Think I have to use create data?
thanks
Dylan.
02-28-2008 2:56 PM
Even better would be a vector type table, that can store and retrieve any
object.
Anyone has the code for that? Should be long, maybe even write a nice class around it.
thanks
Dylan.
02-28-2008 2:56 PM
Even better would be a vector type table, that can store and retrieve any
object.
Anyone has the code for that? Should be long, maybe even write a nice class around it.
thanks
Dylan.
02-28-2008 3:29 PM
Try to use around your code... (take out the spaces after and before the bracket though! )
Assuming the type in your first class is public. I'll call your first class CL1.
Types: begin of ty_field_itab,
fld type ref to ZCL_BDC_FIELD,
end of ty_field_itab.
in the private section of another class
data: field_itab type table of CL1=>ty_field_itab,
_field like line of field_itab.
...
* _field gets filled...
*still in other class,
append _field to field_itab.
Re, your idea of a vector table... yes you can do it. Like this:
TYPES: BEGIN OF ty_vector_entry,
hdr TYPE ...some kind of header structure...
ref TYPE REF TO DATA,
END OF ty_vector,
ty_vector TYPE STANDARD/SORTED/HASHED TABLE OF ty_vector_entry ... key defn.
DATA: l_entry TYPE ty_vector_entry,
lt_vector TYPE ty_vector.
...
my_obj1 TYPE REF TO CL1,
* populate the l_entry-hdr appropriately
GET REFERENCE OF my_obj1 into l_entry-ref.
INSERT l_entry INTO TABLE lt_vector.
my_obj2 TYPE REF TO CL2,
* populate the l_entry-hdr appropriately
GET REFERENCE OF my_obj2 into l_entry-ref.
INSERT l_entry INTO TABLE lt_vector.
my_data TYPE string,
* populate the l_entry-hdr appropriately
GET REFERENCE OF my_data into l_entry-ref.
INSERT l_entry INTO TABLE lt_vector.
matt