<?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: DIFFICULT LOOP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700677#M1104643</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;U can try to do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;parameters: p_class type SEOMETAREL-CLSNAME.

data: _class type SEOMETAREL-CLSNAME.

DATA: BEGIN OF ITAB OCCURS 0,
       LIVEL(4)  TYPE N,
       SUBCLASS  type SEOMETAREL-CLSNAME,
      END OF ITAB.

data: _level type i.

data: itab_temp like table of itab WITH HEADER LINE.
data: itab_temp2 like table of itab WITH HEADER LINE.

start-of-selection.

  move  p_class to itab-subclass.
  append itab.

  MOVE 1 TO itab_temp-livel.
  SELECT * FROM SEOMETAREL WHERE CLSNAME = p_class.
    move SEOMETAREL-REFCLSNAME to itab_temp-subclass.
    append itab_temp.
    append itab_temp to itab.
  ENDSELECT.

  _level = 1.

  loop at itab_temp.
    _level = _level + 1.
    move _level to itab_temp2-livel.
    SELECT * FROM SEOMETAREL WHERE CLSNAME = itab_temp-subclass.
      MOVE SEOMETAREL-REFCLSNAME TO itab_temp2-subclass.
      APPEND itab_temp2.
    ENDSELECT.
    delete itab_temp.
    append lines of: itab_temp2 to itab,
                     itab_temp2 to itab_temp.
    refresh itab_temp2.
  endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.s.: I can't try to run this code now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Nov 2008 19:39:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-11-05T19:39:02Z</dc:date>
    <item>
      <title>DIFFICULT LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700674#M1104640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to write a little program: when a user enters a classname:&lt;/P&gt;&lt;P&gt;I need to collect all the subclasses of this class and subclasses of this subclasses &lt;STRONG&gt;and so on...&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
CLASS-&amp;gt;S_CLASS_1
     -&amp;gt;S_CLASS_2
     -&amp;gt;S_CLASS_3-&amp;gt;S_CLASS4
                -&amp;gt;S_CLASS5
	        -&amp;gt;S_CLASS6-&amp;gt;.....
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CLASS has 3 subclasses en S_CLASS_3 also has 3 subclasses ...&lt;/P&gt;&lt;P&gt;I need to collect all these classes in one itab. how do i do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 18:40:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700674#M1104640</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-05T18:40:44Z</dc:date>
    </item>
    <item>
      <title>Re: DIFFICULT LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700675#M1104641</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;U can create an internal table where the first field is the level and the second the subclass:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF ITAB OCCURS 0,
             LIVEL(4) TYPE N,
             SUBCLASS(20) TYPE C,
          END OF ITAB.

DATA: N_CLASS(4) TYPE N.

DATA: POS TYPE I.
DATA: COUNT TYPE I.

MOVE 0 TO ITAB-LIVEL.
MOVE 'CLASS' TO ITAB-SUBCLASS.
APPEND ITAB.

DO 10 TIMES.
  MOVE SY-INDEX TO ITAB-LIVEL.
  DO 3 TIMES.
    N_CLASS = N_CLASS + 1.
    ITAB-SUBCLASS = 'S_CALLS_X'.
    REPLACE 'X' WITH N_CLASS INTO ITAB-SUBCLASS.
    APPEND ITAB.
  ENDDO.

ENDDO.

LOOP AT ITAB.
  IF SY-TABIX &amp;lt;&amp;gt; 1.
    COUNT = COUNT + 1.
  ELSE.
    COUNT = 3.
  ENDIF.
  WRITE: AT /POS ITAB-LIVEL, ITAB-SUBCLASS.

  CHECK COUNT = 3.
  CLEAR COUNT.
  POS = POS + 4.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 19:01:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700675#M1104641</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-05T19:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: DIFFICULT LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700676#M1104642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;okey but it is more difficult then that. there is a parameter where the user can enter a class: example class ZCAR. then i need to check if ZCAR has subclasses(table SEOMETAREL). then for each subclass of the class ZCAR i need to collect there subclasses to and so on.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 19:10:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700676#M1104642</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-05T19:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: DIFFICULT LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700677#M1104643</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;U can try to do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;parameters: p_class type SEOMETAREL-CLSNAME.

data: _class type SEOMETAREL-CLSNAME.

DATA: BEGIN OF ITAB OCCURS 0,
       LIVEL(4)  TYPE N,
       SUBCLASS  type SEOMETAREL-CLSNAME,
      END OF ITAB.

data: _level type i.

data: itab_temp like table of itab WITH HEADER LINE.
data: itab_temp2 like table of itab WITH HEADER LINE.

start-of-selection.

  move  p_class to itab-subclass.
  append itab.

  MOVE 1 TO itab_temp-livel.
  SELECT * FROM SEOMETAREL WHERE CLSNAME = p_class.
    move SEOMETAREL-REFCLSNAME to itab_temp-subclass.
    append itab_temp.
    append itab_temp to itab.
  ENDSELECT.

  _level = 1.

  loop at itab_temp.
    _level = _level + 1.
    move _level to itab_temp2-livel.
    SELECT * FROM SEOMETAREL WHERE CLSNAME = itab_temp-subclass.
      MOVE SEOMETAREL-REFCLSNAME TO itab_temp2-subclass.
      APPEND itab_temp2.
    ENDSELECT.
    delete itab_temp.
    append lines of: itab_temp2 to itab,
                     itab_temp2 to itab_temp.
    refresh itab_temp2.
  endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.s.: I can't try to run this code now.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Max&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 19:39:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700677#M1104643</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-05T19:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: DIFFICULT LOOP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700678#M1104644</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;See if this program gives you the basis for what you are looking for.  The internal table it_all will contain all the subclasses, and subclasses of all subclasses, etc. starting with the class entered in the parameter.  Of course, you don't need it_all since the lcl_relations-&amp;gt;subclasses internal table attribute also has the info.  I just included it_all as an example of how to get a separate itab (in case you need a different structure for example).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
REPORT  ztemp.

PARAMETERS: p_class TYPE seoclsname DEFAULT 'CL_SALV_MODEL'.

TYPE-POOLS: seor.

TYPES: BEGIN OF ty_all,
         clsname TYPE seoclsname,
       END OF ty_all.

DATA: lcl_relations TYPE REF TO cl_oo_class_relations,
      it_all       TYPE TABLE OF ty_all.

FIELD-SYMBOLS: &amp;lt;fs_subclass&amp;gt; TYPE seor_inheritance_r,
               &amp;lt;fs_all&amp;gt;      TYPE ty_all.

CREATE OBJECT lcl_relations
  EXPORTING
    clsname  = p_class.

LOOP AT lcl_relations-&amp;gt;subclasses ASSIGNING &amp;lt;fs_subclass&amp;gt;.
  APPEND INITIAL LINE TO it_all ASSIGNING &amp;lt;fs_all&amp;gt;.
  &amp;lt;fs_all&amp;gt;-clsname = &amp;lt;fs_subclass&amp;gt;-clsname.
  WRITE: /1 &amp;lt;fs_all&amp;gt;-clsname.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Jamie&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2008 20:09:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/difficult-loop/m-p/4700678#M1104644</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-05T20:09:02Z</dc:date>
    </item>
  </channel>
</rss>

