<?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 Insert statement in to internal table in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270266#M493080</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an editable ALV LIST report with the check box to it. When the user checks the check box on the report and hits a push Button it should copy the row from the internal table and insert the row to the same internal table in the next line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had my code in this way,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    WHEN 'COPY'.
      LOOP AT t_output INTO wa_output.
        IF wa_output-chkbox = 'X'.
          wa_output-zactual = 0.
          wa_output-zqty = 0.
          INSERT wa_output INTO t_output INDEX sy-tabix.
        ENDIF.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the problem was,&lt;/P&gt;&lt;P&gt;For e.g. let say I have only 3 rows in the internal table. So when the user selects the last, 3rd row and hits the push button the 3rd row copied and is inserted in the 3rd row. The user wanted the copied row in the next row, ie the 4th row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO I changed the above code as below and now it goes to an endless loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    WHEN 'COPY'.
      LOOP AT t_output INTO wa_output.
        IF wa_output-chkbox = 'X'.
          wa_output-zactual = 0.
          wa_output-zqty = 0.
          Sy-tabix = sy-tabix + 1.
          INSERT wa_output INTO t_output INDEX sy-tabix.
        ENDIF.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;I dont want to use another internal table.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;I hope I am clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest,&lt;/P&gt;&lt;P&gt;Ster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 May 2007 15:51:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-05-16T15:51:40Z</dc:date>
    <item>
      <title>Insert statement in to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270266#M493080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have an editable ALV LIST report with the check box to it. When the user checks the check box on the report and hits a push Button it should copy the row from the internal table and insert the row to the same internal table in the next line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had my code in this way,&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    WHEN 'COPY'.
      LOOP AT t_output INTO wa_output.
        IF wa_output-chkbox = 'X'.
          wa_output-zactual = 0.
          wa_output-zqty = 0.
          INSERT wa_output INTO t_output INDEX sy-tabix.
        ENDIF.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the problem was,&lt;/P&gt;&lt;P&gt;For e.g. let say I have only 3 rows in the internal table. So when the user selects the last, 3rd row and hits the push button the 3rd row copied and is inserted in the 3rd row. The user wanted the copied row in the next row, ie the 4th row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SO I changed the above code as below and now it goes to an endless loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;    WHEN 'COPY'.
      LOOP AT t_output INTO wa_output.
        IF wa_output-chkbox = 'X'.
          wa_output-zactual = 0.
          wa_output-zqty = 0.
          Sy-tabix = sy-tabix + 1.
          INSERT wa_output INTO t_output INDEX sy-tabix.
        ENDIF.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;I dont want to use another internal table.&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;I hope I am clear.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest,&lt;/P&gt;&lt;P&gt;Ster.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 15:51:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270266#M493080</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-16T15:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Insert statement in to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270267#M493081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try the  following..&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
data :w_indx like sy-tabix.

WHEN 'COPY'.
      LOOP AT t_output INTO wa_output
                         where chkbox = 'X'
                            and zactual = 0
                            and zqty = 0.
         if w_indx ne sy-tabix.
          w_indx = sy-tabix + 1.
          INSERT wa_output INTO t_output INDEX w_indx.
        ENDIF.
      ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;~Suresh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 16:00:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270267#M493081</guid>
      <dc:creator>suresh_datti</dc:creator>
      <dc:date>2007-05-16T16:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Insert statement in to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270268#M493082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Declare one variable like &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data : v_tabix like sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;WHEN 'COPY'.&lt;/P&gt;&lt;P&gt;      LOOP AT t_output INTO wa_output.&lt;/P&gt;&lt;P&gt;        IF wa_output-chkbox = 'X'.&lt;/P&gt;&lt;P&gt;          wa_output-zactual = 0.&lt;/P&gt;&lt;P&gt;          wa_output-zqty = 0.&lt;/P&gt;&lt;P&gt;          clear v_tabix.&lt;/P&gt;&lt;P&gt;          v_tabix = sy-tabix + 1.&lt;/P&gt;&lt;P&gt;          INSERT wa_output INTO t_output INDEX V-tabix.&lt;/P&gt;&lt;P&gt;        ENDIF.&lt;/P&gt;&lt;P&gt;      ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the output and let me know the status&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Seshu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 16:01:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270268#M493082</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-16T16:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Insert statement in to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270269#M493083</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;Change the code as follows.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  data: lv_cnt type i.
     
    describe table t_output lines lv_cnt.
     LOOP AT t_output INTO wa_output where wa_output-chkbox = 'X'           
                                                            and  wa_output-zactual = 0
                                                            and  wa_output-zqty = 0.
          lv_cnt = lv_cnt + 1.
          INSERT wa_output INTO t_output INDEX lv_cnt.
      ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Sailaja.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 16:05:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270269#M493083</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-16T16:05:37Z</dc:date>
    </item>
    <item>
      <title>Re: Insert statement in to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270270#M493084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Suresh.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shreekant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 16:05:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270270#M493084</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-16T16:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Insert statement in to internal table</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270271#M493085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Everyone.&lt;/P&gt;&lt;P&gt;Problem Solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shreekant&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2007 16:07:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/insert-statement-in-to-internal-table/m-p/2270271#M493085</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-16T16:07:42Z</dc:date>
    </item>
  </channel>
</rss>

