‎2008 May 16 5:30 PM
Hi,
I need return from a method ( GET_XXX ) one Table ( Internal ) with references to another objects , for example:
thear is one relation between Customer and Account Object, ( one to Many )
DATA: oCustomer TYPE REF TO CL_CUSTOMER.
DATA: oTable_Account TYPE TABLE OF REF TO CL_ACCOUNT.
oTable_Account = oCustomer.GET_CUENTAS ( )
can I to do some like this??? and how??
Thanks !!!!!!!!
‎2008 May 16 8:45 PM
Do like this:
- You have to declare a table type for the returning table, which must have the same visibility (PUBLIC / PROTECTED / PRIVATE) as the GET method.
Check this code:
CLASS lcl_customer DEFINITION.
PUBLIC SECTION.
TYPES:
tyt_ref_acc TYPE TABLE OF REF TO CL_ACCOUNT
WITH DEFAULT KEY.
METHODS:
get_cuentas
RETURNING VALUE(rt_acc_refs) TYPE tyt_ref_acc.
ENDCLASS.
CLASS lcl_customer IMPLEMENTATION.
METHOD get_cuentas.
* Append to rt_acc_refs your account references.
ENDMETHOD.
ENDCLASS.
- Declare oTable_Account as:
TYPE lcl_customer=>tyt_ref_acc.
- When you must use the method:
oTable_Account = oCustomer->get_cuentas( ).
Note that code hasn't been syntax checked but with minor adjustments you should be fine.
Regards
‎2008 May 22 1:25 PM