<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Storing and retrieving objects from an internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968857#M397728</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please consider that there isn't in ABAP  a concept of 'generics', like the last Java versions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the standard iterator class CL_SWF_UTL_ITERATOR operates on an internal table based on the generic OBJECT superclass. the programmer should take care to handle properly the actual types. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Massimo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Jan 2008 14:37:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-01-02T14:37:53Z</dc:date>
    <item>
      <title>Storing and retrieving objects from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968851#M397722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear ABAPers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure how to do that in an elegant way. I need to store objects of any class (lets say that I will cast them to OBJECT) into an internal table. How could I define such a table? What would be the instructions to store and get back the objects then?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Olivier MATT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 14:02:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968851#M397722</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T14:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and retrieving objects from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968852#M397723</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Olivier&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is an example using an &amp;lt;b&amp;gt;iterator class&amp;lt;/b&amp;gt; (similar like in Java):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZUS_SDN_ITERATOR
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*

REPORT  zus_sdn_iterator.


DATA:
  gd_text        TYPE string,
  gs_viob03      TYPE viob03,
  gt_viob03      TYPE re_t_viob03,
*
  go_object      TYPE REF TO object,
  gto_list       TYPE swf_utl_object_tab,
  go_building    TYPE REF TO if_rebd_building,
  go_iterator    TYPE REF TO cl_swf_utl_iterator.


START-OF-SELECTION.

  SELECT * FROM  viob03 INTO TABLE gt_viob03
         WHERE  bukrs  = '1000'
         AND    swenr  = '00001000'.
  " selects three buildings on IDES ECC 5.0




  LOOP AT gt_viob03 INTO gs_viob03.
    CLEAR: go_building.

    CALL METHOD cf_rebd_building=&amp;gt;find
      EXPORTING
        id_bukrs       = gs_viob03-bukrs
        id_swenr       = gs_viob03-swenr
        id_sgenr       = gs_viob03-sgenr
         id_activity    = reca1_activity-display
         if_auth_check  = abap_false
*        IF_ENQUEUE     = ABAP_TRUE
*        IF_USE_ARCHIVE = ABAP_TRUE
      RECEIVING
        ro_instance    = go_building
       EXCEPTIONS
         error          = 1
         OTHERS         = 2.
    IF sy-subrc &amp;lt;&amp;gt; 0.
*     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    IF ( go_building IS BOUND ).
      APPEND go_building TO gto_list.
    ENDIF.

  ENDLOOP.


  " create iterator
  CREATE OBJECT go_iterator
    EXPORTING
      im_object_list = gto_list
*      IM_STARTPOINT = MC_START_TOP
      .


  CLEAR: go_building.
  go_building ?= go_iterator-&amp;gt;get_first( ).  " casting OR
  "  go_object    = go_iterator-&amp;gt;get_first( ).
  "  go_building ?= go_object.

  WHILE ( go_building IS BOUND ).
*   do something with the instance
    gd_text = go_building-&amp;gt;get_text( ).
    WRITE: / go_building-&amp;gt;ms_detail-bukrs,
             go_building-&amp;gt;ms_detail-swenr,
             go_building-&amp;gt;ms_detail-sgenr,
             gd_text.

    go_building ?= go_iterator-&amp;gt;get_next( ).
  ENDWHILE.


END-OF-SELECTION.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 14:34:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968852#M397723</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-03-02T14:34:19Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and retrieving objects from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968853#M397724</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This example shows how to build an internal table full of instances of classes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zrich_0001 .

*---------------------------------------------------------------------*
*       CLASS lcl_app DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class lcl_app definition.


  public section.

    types: begin of ttab,
           fld1(10) type c,
           fld2(10)  type c,
           fld3(10)  type c,
           end of ttab.
    data: itab type table of ttab.
    data: xtab type ttab.

    methods: constructor, do_this.

endclass.

*---------------------------------------------------------------------*
*       CLASS lcl_app IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
class lcl_app implementation.

  method constructor.

    xtab-fld1 = 'ABC'.
    xtab-fld2 = 'DEF'.
    xtab-fld3 = 'GHI'.
    append xtab to itab.

  endmethod.

  method do_this.

    loop at itab into xtab.
      write:/ xtab-fld1, xtab-fld2, xtab-fld3.
    endloop.

  endmethod.

endclass.

data: a_app type ref to lcl_app.
data: a_app_list type table of ref to lcl_app.

start-of-selection.

  do 10 times.
    create object a_app.
    append a_app to a_app_list.
  enddo.

  loop at a_app_list into a_app.
    call method a_app-&amp;gt;do_this( ).
  endloop.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 14:58:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968853#M397724</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2007-03-02T14:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and retrieving objects from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968854#M397725</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, I forgot to mention that I have a special case. I need to use an internal table (TYPE TABLE OF REF TO some_object_class) as an attribute of a class. &lt;/P&gt;&lt;P&gt;The Class Builder doesnt seem to allow me to enter such a type.&lt;/P&gt;&lt;P&gt;Is there any special trick to enforce this barrier? As I am pretty new to ABAP, I also wonder if there is a pure text-editing mode for classes (like in Java when you open the .java file of a class).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Olivier MATT&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 15:18:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968854#M397725</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-02T15:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and retrieving objects from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968855#M397726</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to create a type type via SE11 which is TYPE REF to your class.  Then use this table type in class builder when defining your attribute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, about pure text-editing, you can when it comes to local classes, but not really with global classes(SE24) &amp;lt;i&amp;gt;yet&amp;lt;/i&amp;gt;.  There are options in the SE24 where  you can go to the public sections, the private, and so on.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 15:26:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968855#M397726</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2007-03-02T15:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and retrieving objects from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968856#M397727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Oliver&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The table type &amp;lt;b&amp;gt;SWF_UTL_OBJECT_TAB&amp;lt;/b&amp;gt; does already fulfill your requirement in its &amp;lt;b&amp;gt;most generic&amp;lt;/b&amp;gt; form (reference type is class OBJECT, the ROOT class of all ABAP classes). However, in order to develop more "Java-like" you could use the iterator class &amp;lt;b&amp;gt;CL_SWF_UTL_ITERATOR&amp;lt;/b&amp;gt; as&amp;lt;i&amp;gt; instance attribute&amp;lt;/i&amp;gt; of your class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2007 20:07:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968856#M397727</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-03-02T20:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Storing and retrieving objects from an internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968857#M397728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please consider that there isn't in ABAP  a concept of 'generics', like the last Java versions. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the standard iterator class CL_SWF_UTL_ITERATOR operates on an internal table based on the generic OBJECT superclass. the programmer should take care to handle properly the actual types. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Massimo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jan 2008 14:37:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/storing-and-retrieving-objects-from-an-internal-table/m-p/1968857#M397728</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-01-02T14:37:53Z</dc:date>
    </item>
  </channel>
</rss>

