<?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: DOUBLE LOOP WITH APPEND STATEMENTS in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707568#M1295985</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Below code would work as per the requirement.. kindly chk..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

data: w_tabix type i,
      w_index type i,
      w_counter type i.

LOOP AT lt_head INTO wa_head.	u201C Loop -A
      CHECK .
      APPEND wa_output TO lt_output. u201C Append -A
      w_tabix = sy-tabix.

      // append statement sets sy-tabix to the last appended row.
      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B
        CHECK .
        APPEND wa_output TO lt_output. u201C Append -B
        w_index = sy-tabix.
        add 1 to w_counter.

      // if counter eq  index thn record gets inserted each time.if not thn delete record from lt_output.

        if w_counter ne w_index.
          delete lt_output
          INDEX w_tabix.
        endif.
      ENDLOOP.

    &amp;lt;CONDITION IF APPEND-B STATEMENT NOT INSERT ANY RECORD.
   &amp;lt; THEN DELETE INSERTED RECORD BY APPEND -A.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 May 2009 06:43:33 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-05-27T06:43:33Z</dc:date>
    <item>
      <title>DOUBLE LOOP WITH APPEND STATEMENTS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707562#M1295979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;i have below code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_head INTO wa_head.	u201C Loop -A
      CHECK &amp;lt;&amp;gt;.
      APPEND wa_output TO lt_output. u201C Append -A
      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B
        CHECK &amp;lt;&amp;gt;.
        APPEND wa_output TO lt_output. u201C Append -B
      ENDLOOP.
    &amp;lt;CONDITION IF APPEND-B STATEMENT NOT INSERT ANY RECORD.
   &amp;lt; THEN DELETE INSERTED RECORD BY APPEND -A.
    ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My problem is that if Append - B statement append at least one record&lt;/P&gt;&lt;P&gt;then the Append -A record is store in table lt_output.&lt;/P&gt;&lt;P&gt;otherwise delete the append A statement.&lt;/P&gt;&lt;P&gt;ANYONE HAVE SOLUTION????&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 06:13:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707562#M1295979</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T06:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: DOUBLE LOOP WITH APPEND STATEMENTS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707563#M1295980</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;Try like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT lt_head INTO wa_head.	u201C Loop -A
      CHECK .
      flag = 0.
      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B
        CHECK .
        APPEND wa_output TO lt_output. u201C Append -B
flag = 1.
      ENDLOOP.
if flag = 1.
APPEND wa_output TO lt_output. u201C Append -A
endif.
    &amp;lt;CONDITION IF APPEND-B STATEMENT NOT INSERT ANY RECORD.
   &amp;lt; THEN DELETE INSERTED RECORD BY APPEND -A.
    ENDLOOP.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;alternatively you can append-a at first and based on flag write a DELETE statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jyothi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 06:21:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707563#M1295980</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T06:21:04Z</dc:date>
    </item>
    <item>
      <title>Re: DOUBLE LOOP WITH APPEND STATEMENTS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707564#M1295981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;DATA: L_CHECK TYPE C,&lt;/P&gt;&lt;P&gt;           L_CNT(3) TYPE N.&lt;/P&gt;&lt;P&gt;        &lt;/P&gt;&lt;P&gt;LOOP AT lt_head INTO wa_head.	u201C Loop -A&lt;/P&gt;&lt;P&gt;      CHECK .&lt;/P&gt;&lt;P&gt;      APPEND wa_output TO lt_output. u201C Append -A&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DESCRIBE TABLE lt_output LINES INTO L_CNT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B&lt;/P&gt;&lt;P&gt;        CHECK .&lt;/P&gt;&lt;P&gt;        APPEND wa_output TO lt_output. u201C Append -B&lt;/P&gt;&lt;P&gt;IF SY-SUBRC EQ 0.&lt;/P&gt;&lt;P&gt;L_CHECK = 'X'.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF L_CHECK EQ ' '.&lt;/P&gt;&lt;P&gt;DELETE FROM IT_OUTPUT INDEX L_CNT.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;CLEAR; L_CNT,&lt;/P&gt;&lt;P&gt;             L_CHECK.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &amp;lt;CONDITION IF APPEND-B STATEMENT NOT INSERT ANY RECORD.&lt;/P&gt;&lt;P&gt;   &amp;lt; THEN DELETE INSERTED RECORD BY APPEND -A.&lt;/P&gt;&lt;P&gt;    ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Poorna Chandrasekhar on May 27, 2009 11:52 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Poorna Chandrasekhar on May 27, 2009 11:53 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 06:21:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707564#M1295981</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T06:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: DOUBLE LOOP WITH APPEND STATEMENTS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707565#M1295982</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;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_head INTO wa_head.	u201C Loop -A
      CHECK .
*    APPEND wa_output TO lt_output. u201C Append -A  " Comment 
     CLEAR Insertb_flag.            " Insert
      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B
        CHECK .
         Insertb_flag = 'X'                                       " Insert 
        APPEND wa_output TO lt_output. u201C Append -B
      ENDLOOP.
      IF Insertb_flag EQ 'X'.                        " Insert
        APPEND wa_output TO lt_output. u201C Append -A Insert
      ENDIF.                                           " Insert
    ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the order to be maintained i.e first record from A and second record from B then try this way.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

LOOP AT lt_head INTO wa_head.	u201C Loop -A
      CHECK .
*    APPEND wa_output TO lt_output. u201C Append -A  " Comment 
     CLEAR Count.            " Insert
      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B
        CHECK .
        IF COUNT EQ '0'.                        " Insert
*          Take another variable wa_output1 
            APPEND wa_output1 TO lt_output. u201C Append -A Insert
         COUNT = COunt + 1.                 " insert
         ENDIF.                                           " Insert
        APPEND wa_output TO lt_output. u201C Append -B
      ENDLOOP.
    ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 06:23:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707565#M1295982</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T06:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: DOUBLE LOOP WITH APPEND STATEMENTS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707566#M1295983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Do as follows&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT lt_head INTO wa_head.	u201C Loop -A
      CHECK .
      APPEND wa_output TO lt_output. u201C Append -A
{color:red}
* add code here.
DESCRIBE IT_OUTPUT LINES v_index.
{color}

      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B
        CHECK .
        APPEND wa_output TO lt_output. u201C Append -B
      ENDLOOP.

{color:red}* add code here
   IF SY_SUBRC NE 0.
      DELETE IT_OUTPUT index  v_index.
   ENDIF.
{color}

    ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ankur Parab&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 06:29:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707566#M1295983</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T06:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: DOUBLE LOOP WITH APPEND STATEMENTS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707567#M1295984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;SELF SOLVED&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 06:37:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707567#M1295984</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T06:37:43Z</dc:date>
    </item>
    <item>
      <title>Re: DOUBLE LOOP WITH APPEND STATEMENTS</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707568#M1295985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Below code would work as per the requirement.. kindly chk..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

data: w_tabix type i,
      w_index type i,
      w_counter type i.

LOOP AT lt_head INTO wa_head.	u201C Loop -A
      CHECK .
      APPEND wa_output TO lt_output. u201C Append -A
      w_tabix = sy-tabix.

      // append statement sets sy-tabix to the last appended row.
      LOOP AT lt_i INTO ls_i.   "aDDED	Loop -B
        CHECK .
        APPEND wa_output TO lt_output. u201C Append -B
        w_index = sy-tabix.
        add 1 to w_counter.

      // if counter eq  index thn record gets inserted each time.if not thn delete record from lt_output.

        if w_counter ne w_index.
          delete lt_output
          INDEX w_tabix.
        endif.
      ENDLOOP.

    &amp;lt;CONDITION IF APPEND-B STATEMENT NOT INSERT ANY RECORD.
   &amp;lt; THEN DELETE INSERTED RECORD BY APPEND -A.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 May 2009 06:43:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/double-loop-with-append-statements/m-p/5707568#M1295985</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-05-27T06:43:33Z</dc:date>
    </item>
  </channel>
</rss>

