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: 

Return Internal table

mariano_boni
Explorer
0 Kudos
95

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 !!!!!!!!

2 REPLIES 2

alejandro_bindi
Active Contributor
0 Kudos
49

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

0 Kudos
49

Thank you for your response !!!!