<?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 ABAP Object - beginner problems in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022365#M414040</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i got a little problem with understanding the logic of ABAP Objects. For example the object material. The material has a number, text, size and so on. That's no problem i can define a class with the attributes number, text size and so on and I can create an object. But how do I interact with more than one object. I want to read 100 materials from the database and after that i want to list them in an alv grid. Do I have to create hundred objects?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT Test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS material DEFINITION.&lt;/P&gt;&lt;P&gt;  PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;    DATA:&lt;/P&gt;&lt;P&gt;       number TYPE i,&lt;/P&gt;&lt;P&gt;       text(20) TYPE c,&lt;/P&gt;&lt;P&gt;       size TYPE c.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS material IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  obj_material TYPE REF TO material.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;????????&lt;/P&gt;&lt;P&gt; CREATE OBJCET obj_material.&lt;/P&gt;&lt;P&gt; SELECT * FROM mara INTO obj_material??????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't know how to....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matthias Tripp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Mar 2007 10:11:57 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-03-16T10:11:57Z</dc:date>
    <item>
      <title>ABAP Object - beginner problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022365#M414040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i got a little problem with understanding the logic of ABAP Objects. For example the object material. The material has a number, text, size and so on. That's no problem i can define a class with the attributes number, text size and so on and I can create an object. But how do I interact with more than one object. I want to read 100 materials from the database and after that i want to list them in an alv grid. Do I have to create hundred objects?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT Test.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS material DEFINITION.&lt;/P&gt;&lt;P&gt;  PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;    DATA:&lt;/P&gt;&lt;P&gt;       number TYPE i,&lt;/P&gt;&lt;P&gt;       text(20) TYPE c,&lt;/P&gt;&lt;P&gt;       size TYPE c.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS material IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;ENDCLASS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  obj_material TYPE REF TO material.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;P&gt;????????&lt;/P&gt;&lt;P&gt; CREATE OBJCET obj_material.&lt;/P&gt;&lt;P&gt; SELECT * FROM mara INTO obj_material??????&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Don't know how to....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Matthias Tripp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 10:11:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022365#M414040</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T10:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Object - beginner problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022366#M414041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Matthias&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not sure if there is already a standard class available for materials. For purchase orders, for example, there is a standard class available (search for CL&lt;STRONG&gt;PO&lt;/STRONG&gt;MM in SE24).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now back to your question. If you want to create hundreds of material object instances then you have create the same number of instances. I will give you another example. Class CF_REBD_BUILDING (RE-FX) has a method FIND which returns the instance of a building if it exists. Now if you you need a list of buildings then you have to loop over this list and create the instances, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA:
    lo_building   TYPE REF TO if_rebd_building,
    lt_buildings  TYPE TABLE OF if_rebd_building.  " not sure if it possible like this
  
  LOOP AT gt_itab INTO ls_entry.
    CLEAR: lo_building.

    lo_building = cf_rebd_building=&amp;gt;find(... ).
    IF ( lo_building IS BOUND ).
      APPEND lo_building TO lt_buildings.
    ENDIF.
  ENDLOOP.&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;P&gt;    &lt;/P&gt;&lt;P&gt;  ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 10:26:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022366#M414041</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2007-03-16T10:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Object - beginner problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022367#M414042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;there is a concept called POINTER TABLES in Abap objects.&lt;/P&gt;&lt;P&gt;check the below ex:&lt;/P&gt;&lt;P&gt;in a loop i am trying to create the same object many times and appending it to another table(table of objects).&lt;/P&gt;&lt;P&gt;you can apply this to ur program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;write a select-endselect in the method implementation fetching the values into your variables, and create the object in loop and append it.call it later as shown below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class testclass definition.&lt;/P&gt;&lt;P&gt; public section.&lt;/P&gt;&lt;P&gt;  methods : testmethod .&lt;/P&gt;&lt;P&gt;  class-data : num type i.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;class testclass implementation.&lt;/P&gt;&lt;P&gt; method : testmethod.&lt;/P&gt;&lt;P&gt;  num = num + 5.&lt;/P&gt;&lt;P&gt;  write:/5 num.&lt;/P&gt;&lt;P&gt; endmethod.&lt;/P&gt;&lt;P&gt;endclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;start-of-selection.&lt;/P&gt;&lt;P&gt;data : myobj type ref to testclass ,&lt;/P&gt;&lt;P&gt;       myobj_tab type table of ref to testclass.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;do 5 times.&lt;/P&gt;&lt;P&gt; create object myobj .&lt;/P&gt;&lt;P&gt; append myobj to myobj_tab.&lt;/P&gt;&lt;P&gt;enddo.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; loop at myobj_tab into myobj.&lt;/P&gt;&lt;P&gt;   call method : myobj-&amp;gt;testmethod.&lt;/P&gt;&lt;P&gt; endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 11:27:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022367#M414042</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T11:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Object - beginner problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022368#M414043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 11:52:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022368#M414043</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-16T11:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP Object - beginner problems</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022369#M414044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just want to add that creating objects is expensive performance wise. So you should always aim to create only objects which are absolutely necessary. So for example if a search returns 100 hits but the alv grid can show only 10 at once then try to create only 10 objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;Thomas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2007 14:29:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-object-beginner-problems/m-p/2022369#M414044</guid>
      <dc:creator>thomasalexander_ritter</dc:creator>
      <dc:date>2007-03-16T14:29:35Z</dc:date>
    </item>
  </channel>
</rss>

