<?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: Looping through Objects in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283617#M153352</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; I Think there isn't a better way, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aw.. that's sad. I just realized i couldn't use binary searches on these cases.. unless of course i write my own search algos... arr.. thanks anyways!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Apr 2006 11:14:55 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-04-10T11:14:55Z</dc:date>
    <item>
      <title>Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283611#M153346</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'm trying to design business entities with ABAP Objects. I have been able to create internal tables of custom object types. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I stumbled into a very peculiar situation in which i have to loop through my custom object internal table. i couldn't use the WHERE specification since the line type is not a structure. READ TABLE doesnt work either. What i did to overcome the problem was to do a LOOP AT with an IF statement inside and an EXIT command to quit the search when found. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a better solution? And Is the whole idea of wrapping everything in classes and accessing the through an internal idea a good idea in the first place?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 07:11:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283611#M153346</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T07:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283612#M153347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;couldnt really understand the question. hereis what i understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;i&amp;gt;i have to loop through my custom object internal table&amp;lt;/i&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;whats this object (a class?) and itab is a attribute of the class?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;amy be post the piece of code your are using, we can see whether we can overcome the issue you are talking about.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 07:21:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283612#M153347</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2006-04-10T07:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283613#M153348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;heres an example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;* DEFINITIONS
* -----------
CLASS cl_drag_drop_picture DEFINITION INHERITING FROM cl_gui_picture.
  PUBLIC SECTION.
    DATA: row     TYPE I,
          col     TYPE I.

DATA: g_wa_pic_ctrl TYPE REF TO cl_drag_drop_picture.

DATA: g_it_pic_ctrl LIKE TABLE OF g_wa_pic_ctrl.

* PROCESS
* -------

* lets assume that g_it_pic_ctrl has several entries and
* each entry is uniquely identified by the attributes
* row AND col.
PERFORM GetObjectByRowCol USING p_row
                                p_col
                       CHANGING g_wa_pic_ctrl.

* SUBROUTINES
* -----------
FORM GetObjectByRowCol USING p_row
                             p_col
                    CHANGING r_pic_ctrl.

  DATA: l_wa_pic_ctrl LIKE g_wa_pic_ctrl.

* Search for picture
  LOOP AT g_it_pic_ctrl INTO l_wa_pic_ctrl.

    IF l_wa_pic_ctrl-&amp;gt;row EQ p_row AND
       l_wa_pic_ctrl-&amp;gt;col EQ p_col.
      r_pic_ctrl = l_wa_pic_ctrl.
      EXIT.
    ENDIF.

  ENDLOOP.

* Collect Garbage
  CLEAR l_wa_pic_ctrl.

ENDFORM.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I couldn't do is access my internal table like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;READ TABLE g_it_pic_ctrl 
      INTO r_pic_ctrl 
  WITH KEY row = p_row
           col = p_col.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT g_it_pic_ctrl INTO r_pic_ctrl 
                     WHERE row EQ p_row
                           col EQ p_col.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 08:14:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283613#M153348</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T08:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283614#M153349</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;these two stataments:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ TABLE g_it_pic_ctrl INTO r_pic_ctrl &lt;/P&gt;&lt;P&gt;WITH KEY row = p_row col = p_col.&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT g_it_pic_ctrl INTO r_pic_ctrl &lt;/P&gt;&lt;P&gt;WHERE row EQ p_row&lt;/P&gt;&lt;P&gt;      col EQ p_col.&lt;/P&gt;&lt;P&gt;EXIT.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;give the same result, only difference is in performance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This statament&lt;/P&gt;&lt;P&gt;LOOP AT g_it_pic_ctrl INTO r_pic_ctrl &lt;/P&gt;&lt;P&gt;WHERE row EQ p_row&lt;/P&gt;&lt;P&gt;      col EQ p_col.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;gives the last record satisfies the where condition, so you give us more details to say you which statament you should use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 08:20:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283614#M153349</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T08:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283615#M153350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, thanks for the quick response..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if we were dealing with a normal internal table, yes, it would only be a question of performance. However, we're using a class as a linetype so READ TABLE and LOOP AT WHERE wouldn't work since both row and col are not components of structure but rather attributes of a class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LOOP AT.. IF. works just fine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is actually a 'best practice' question rather than an issue... Is there a better way? or this shouldnt be done at all?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 08:29:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283615#M153350</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T08:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283616#M153351</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;OK! Now I've understood what you want...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Think there isn't a better way, it needs to check all objects (of internal tables), so only LOOP can be used and an exit condition is placed into the same loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway you can try to use the READ stataments:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DO.&lt;/P&gt;&lt;P&gt;  READ TABLE G_IT_PIC_CTRL INTO G_WA_PIC_CTRL INDEX SY-INDEX.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC &amp;lt;&amp;gt; 0. CLEAR G_WA_PIC_CTRL. EXIT. ENDIF.&lt;/P&gt;&lt;P&gt;    IF G_WA_PIC_CTRL-&amp;gt;ROW = ROW AND&lt;/P&gt;&lt;P&gt;       G_WA_PIC_CTRL-&amp;gt;COL = COL.&lt;/P&gt;&lt;P&gt;      EXIT.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;ENDDO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 09:16:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283616#M153351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T09:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283617#M153352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; I Think there isn't a better way, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;aw.. that's sad. I just realized i couldn't use binary searches on these cases.. unless of course i write my own search algos... arr.. thanks anyways!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 11:14:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283617#M153352</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T11:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283618#M153353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the delay.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is possible to use where class in the loop for objects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check out the following code sample.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: alv type ref to CL_GUI_FRONTEND_SERVICES .
data: begin of alv_tab occurs 0 ,
      alv_line type ref to CL_GUI_FRONTEND_SERVICES ,
      end of alv_tab .
data: wa like line of alv_tab .
do 10 times .
clear alv .
create object alv .
wa-alv_line =  alv .
append wa to alv_tab .
enddo .

loop at alv_tab into wa where alv_line-&amp;gt;ACTIVEX = 'X'.

endloop .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 11:35:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283618#M153353</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2006-04-10T11:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283619#M153354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Raja&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're right, I didn't try your solution, so what depends on how the table is declared:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS CL_DRAG_DROP_PICTURE DEFINITION INHERITING FROM CL_GUI_PICTURE.&lt;/P&gt;&lt;P&gt;  PUBLIC SECTION.&lt;/P&gt;&lt;P&gt;    DATA: ROW     TYPE I,&lt;/P&gt;&lt;P&gt;          COL     TYPE I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DATA: BEGIN OF G_WA_PIC_CTRL,&lt;/P&gt;&lt;P&gt;            CTRL_PICTYPE TYPE REF TO CL_DRAG_DROP_PICTURE,&lt;/P&gt;&lt;P&gt;          END   OF G_WA_PIC_CTRL.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    DATA: G_IT_PIC_CTRL LIKE TABLE OF G_WA_PIC_CTRL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    METHODS: READ.&lt;/P&gt;&lt;P&gt;ENDCLASS.    &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS CL_DRAG_DROP_PICTURE IMPLEMENTATION.&lt;/P&gt;&lt;P&gt;  METHOD READ.&lt;/P&gt;&lt;P&gt;    LOOP AT G_IT_PIC_CTRL INTO G_WA_PIC_CTRL&lt;/P&gt;&lt;P&gt;    WHERE CTRL_PICTYPE-&amp;gt;ROW = P_ROW&lt;/P&gt;&lt;P&gt;      AND CTRL_PICTYPE-&amp;gt;COL  = P_COL.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;  ENDMETHOD.                    "READ&lt;/P&gt;&lt;P&gt;ENDCLASS. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Apr 2006 11:51:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283619#M153354</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-10T11:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283620#M153355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;great stuff! hmmm.. i guess i'll have to redesign. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Apr 2006 07:06:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283620#M153355</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-04-11T07:06:20Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283621#M153356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you mark the thread as answered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Raja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Apr 2006 07:16:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283621#M153356</guid>
      <dc:creator>athavanraja</dc:creator>
      <dc:date>2006-04-11T07:16:39Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through Objects</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283622#M153357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is the same as with standard internal tables where you have no dedicated fields (for example: itab type standard table of string). For that you can refer to the current line with the keyword "&lt;STRONG&gt;table_line&lt;/STRONG&gt;", e.g. &lt;/P&gt;&lt;P&gt;LOOP AT g_it_pic_ctrl INTO l_wa_pic_ctrl.&lt;/P&gt;&lt;P&gt; WHERE table_line-&amp;gt;ROW = p_row&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; AND&amp;nbsp;&amp;nbsp;&amp;nbsp; table_line-&amp;gt;COL = p.col.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 12:40:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/looping-through-objects/m-p/1283622#M153357</guid>
      <dc:creator>Markus_Ebel</dc:creator>
      <dc:date>2015-07-17T12:40:50Z</dc:date>
    </item>
  </channel>
</rss>

