Skip to Content

ABAP OO: how to pass a internal table with objects as a method parameter

Hello all,

I have a class "ZCL_VEHICLE", this class contains the attribute WHEELS.

This attribute contains objects of the class ZCL_WHEEL.

(definition: data WHEELS TYPE TABLE OF REF TO zcl_wheel.).

I now need a method that gives this table back (as return or export parameter). How can I define a parameter for this method that will contain this table?

Thanks for the help.

Best regards,

Wim

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 18, 2005 at 02:07 PM

    hi, you can define a table type, assume named as ZWHEELTB.

    From se11, you can create a table type,

    in the LineType tab, you choose 'Reference type' and choose the class ZCL_WHEEL as the line type.

    Then in the method, you just need to define an o/p, type ZWHEELTB.

    My suggestion is base on WAS 6.4.

    Hope it will be helpful

    Thanks

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 18, 2005 at 02:22 PM

    Hi

    You can use the same statamen used to define attribute WHEELS:

    DATA: MY_WHEELS TYPE TABLE OF REF TO ZCL_VEHICLE.

    But remember: this statament defines a table without header line, so you need to define it.

    Max

    Message was edited by: max bianchi

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 18, 2005 at 03:02 PM

    Check the method GUI_DOWNLOAD of Class CL_GUI_FRONTEND_SERVICES . The parameter DATA_TAB is capable of accepting any type of standard table. You can define similarly .

    Cheers.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 18, 2005 at 03:26 PM

    hi, Wim Verschueren

    you mentioned:

    'There I can choose only between the types "TYPE REF TO", "TYPE" or "LIKE". Not "TYPE TABLE OF REF TO".'

    yeah, that's right. That's also why I suggested you to create a table type yourself, and through it you can specify a class as a line type in your table type. Then the target achieve.

    you also mentioned

    'Does anybody now how I can jump to the changeable code view of the public method definitions? If that would succeed, I think my problem would be solved.'

    it's simple. just into se24, open you class, and go 'method' tab, double click the method name. then you can turn to the method edit mode.

    by the way, creat a table type is not a strange thing, SAP create many table type for their table.

    Hope it will be helpful

    thanks

    Message was edited by: zhenglin gu

    Add comment
    10|10000 characters needed characters exceeded