<?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: Deleting internal table using index in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618071#M1663616</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jagdish,&lt;/P&gt;&lt;P&gt;One thumb rule: Don't change the System variable as this keep changing. &lt;/P&gt;&lt;P&gt;Store the value in variable and play with&lt;/P&gt;&lt;P&gt;Please check for SY-SUBRC = 0 .&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Sridhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 16 Mar 2012 07:38:33 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2012-03-16T07:38:33Z</dc:date>
    <item>
      <title>Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618066#M1663611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Sap All.&lt;/P&gt;&lt;P&gt;when i try to delete the data in the Internal table using index,iam getting the short dump as mentioned below :&lt;/P&gt;&lt;P&gt;Error in ABAP/4 statement when processing an internal table.&lt;/P&gt;&lt;P&gt;t happened?&lt;BR /&gt;Error in the ABAP Application Program&lt;/P&gt;&lt;P&gt;The current ABAP program "ZRECHECKDOCU_LICENSEUPD" had to be terminated because&lt;BR /&gt;&amp;nbsp; it has&lt;BR /&gt;come across a statement that unfortunately cannot be executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or analysis&lt;BR /&gt;When changing or deleting one or more lines of the internal table&lt;BR /&gt;"\PROGRAM=ZRECHECKDOCU_LICENSEUPD\DATA=ITAB" or when inserting in the table&lt;BR /&gt;&amp;nbsp; "\PROGRAM=ZRECHECKDOCU_LICENSEUPD\DATA=ITAB", 0 was used as&lt;BR /&gt;the line index. An index less than or equal to zero is not&lt;BR /&gt;allowed.&lt;/P&gt;&lt;P&gt;The error can occur when using the following options:&lt;BR /&gt;1. "INDEX idx" for specifying the line number in the table&lt;BR /&gt;&amp;nbsp; "\PROGRAM=ZRECHECKDOCU_LICENSEUPD\DATA=ITAB"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where you want to change, insert or delete.&lt;BR /&gt;2. "FROM idx" for specifying the start index when deleting a line&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; area from or inserting a line area into the table&lt;BR /&gt;&amp;nbsp; "\PROGRAM=ZRECHECKDOCU_LICENSEUPD\DATA=ITAB".&lt;BR /&gt;3. "TO idx" for specifying the end index when deleting a line&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; area from or inserting a line area into the table&lt;BR /&gt;&amp;nbsp; "\PROGRAM=ZRECHECKDOCU_LICENSEUPD\DATA=ITAB".&lt;/P&gt;&lt;P&gt;At the time of the termination, the table contained 1140 lines.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;delete itab index SY-TABIX.&lt;/P&gt;&lt;P&gt;The&amp;nbsp; soucre code of the program is as below :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;loop at itab into wa_itab.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sy-tabix = '384'.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break Varma.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if wa_itab-msgv1 = '400040'.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Break varma.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if wa_itab-msgno = '159' AND wa_itab-MSGV1 EQ 'Checked / Available: Serv'.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DELETE itab index sy-tabix .&lt;BR /&gt;*from wa_messtab2.&lt;BR /&gt;*where msgno = '159' AND MSGV1 EQ 'Checked / Available: Serv'.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sy-subrc = 0.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sy-tabix = sy-tabix - 1.&lt;BR /&gt;*loop at it_messtab2 into wa_messtab2 from&amp;nbsp; sy-tabix.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read table itab into wa_itab index sy-tabix.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if sy-tabix &amp;gt; 0.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TAB = sy-tabix + 1.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; read table itab into wa_itab2 index TAB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if wa_itab-msgno = '159' AND wa_itab-MSGV1 EQ 'Checked / Blocked: Servic'.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif wa_itab-msgno = '159' AND wa_itab-MSGV1 EQ 'Checked / Blocked: Servic' AND&amp;nbsp; wa_itab2-msgno = '159' AND wa_itab2-MSGV1 EQ 'Checked / Blocked: Servic' .&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete itab index sy-tabix.(the Shordump is directing to this line)**********************************************&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;BR /&gt;*&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endloop.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endif.&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;will be waiting for best answer.&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;P&gt;Varma&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Moderator Message: Please use the code formatting options via: Insert --&amp;gt; Syntax highlighting. I don't see any option available for ABAP though &lt;SPAN __jive_emoticon_name="shocked" __jive_macro_name="emoticon" class="jive_macro jive_macro_emoticon jive_emote" height="1" src="https://community.sap.com/5.0.1/images/emoticons/shocked.gif" width="1"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Suhas Saha&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2012 13:18:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618066#M1663611</guid>
      <dc:creator>venkatasap</dc:creator>
      <dc:date>2012-03-13T13:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618067#M1663612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The dump itself say the index which you are trying to use is 0 or less than 0. Secondly please dont modify sy-tabix. Make a local variable and check. It is also good practice to put a check if lv_tabix gt 0 before deleting using index option.&lt;/P&gt;&lt;P&gt;Also note that sy-tabix value will not remain same for each read you are doing on table or modify etc it will update this tabix.&lt;/P&gt;&lt;P&gt;Nabheet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2012 13:23:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618067#M1663612</guid>
      <dc:creator>nabheetscn</dc:creator>
      <dc:date>2012-03-13T13:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618068#M1663613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Gagdish,&lt;/P&gt;&lt;P&gt; DELETE &amp;lt;itab&amp;gt; [INDEX &amp;lt;idx&amp;gt;].&lt;/P&gt;&lt;P&gt; Here the line with the specified index will be deleted. We can use the same statement without INDEX addition within a loop. That time it will delete the current line.&lt;/P&gt;&lt;P&gt;Use Counter variable inside the loop. &lt;/P&gt;&lt;P&gt;Hope this will help.&lt;/P&gt;&lt;P&gt; BR, Mantu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Mar 2012 19:11:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618068#M1663613</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-03-13T19:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618069#M1663614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please do not modify the system variable sy-tabix.&lt;/P&gt;&lt;P&gt;Since you are using READ statement inside a LOOP the sy-tabix will get changed. &lt;/P&gt;&lt;P&gt;Better option is to create a local variable (TYPE SY-TABIX) and use the same ,clear it after completing each loop.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Arun &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2012 07:25:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618069#M1663614</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-03-14T07:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618070#M1663615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt; can you check&amp;nbsp; this code .&lt;/P&gt;&lt;P&gt;Loop at itab into wa-itab..&lt;/P&gt;&lt;P&gt; lv_tabix = sy-tabix. &lt;/P&gt;&lt;P&gt; *Check the conditions&lt;/P&gt;&lt;P&gt; if lv_tabix = '399'.&lt;/P&gt;&lt;P&gt;&amp;lt;Code&amp;gt;.&lt;/P&gt;&lt;P&gt;*deleting.&lt;/P&gt;&lt;P&gt;delete itab form wa_itab index lv_tabix.&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;Endloop.&lt;/P&gt;&lt;P&gt;*while modifying table also use like this.&lt;/P&gt;&lt;P&gt;modify itab index lv_index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gurunath Kumar D&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2012 10:29:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618070#M1663615</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-03-14T10:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618071#M1663616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jagdish,&lt;/P&gt;&lt;P&gt;One thumb rule: Don't change the System variable as this keep changing. &lt;/P&gt;&lt;P&gt;Store the value in variable and play with&lt;/P&gt;&lt;P&gt;Please check for SY-SUBRC = 0 .&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;P&gt;Sridhar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Mar 2012 07:38:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618071#M1663616</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-03-16T07:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618072#M1663617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jagdish,&lt;/P&gt;&lt;P&gt;The same issue I had in the past, and my best solutions to you is.....&lt;/P&gt;&lt;P&gt;1) As Sridhar said, You must not modify the system variables, even if you change it don't have any impact on system variable (System will automatically modify them, in debug mode you can check this).&lt;/P&gt;&lt;P&gt;2) The error clearly says that, your are trying to delete a row which is not exist in &lt;STRONG&gt;itab.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2) So, before you use&lt;STRONG style="color: #000000; font-size: 12px; background-color: #ffffff; font-family: helvetica, arial;"&gt;&amp;nbsp; DELETE itab index sy-tabix .&amp;nbsp; &lt;/STRONG&gt;&lt;SPAN style="color: #000000; font-size: 12px; background-color: #ffffff; font-family: helvetica, arial;"&gt;I would request you to please check whether your internal tab has data or not by using Syntax &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If itab[] is not initial.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: helvetica, arial; font-size: 12px; background-color: #ffffff;"&gt; DELETE itab index sy-tabix .&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: helvetica, arial; font-size: 12px; background-color: #ffffff;"&gt;endif.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: helvetica, arial; font-size: 12px; background-color: #ffffff;"&gt;&lt;SPAN style="color: #000000; font-size: 12px; font-family: helvetica, arial;"&gt;I believe this will definitely solve your problem&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rajesh Sadula&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 17 Mar 2012 17:13:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618072#M1663617</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2012-03-17T17:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting internal table using index</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618073#M1663618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Varma,&lt;/P&gt;&lt;P&gt;Sy-tabix changes with Loop as well as your READ statement.&lt;/P&gt;&lt;P&gt;Like all others here mentioned, it would be better to capture the index you'd like to use into a variable, say l_tabix.&lt;/P&gt;&lt;P&gt;Also, keeping performance issues in mind, I would advice you to add a DEL_FLAG field of char1 to your structure/type,&lt;/P&gt;&lt;P&gt;set the flag for lines you want to delete and Delete them after the loop. &lt;/P&gt;&lt;P&gt;Sample code is something like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TYPES: BEGIN OF TY_TAB,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ... "other variables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEL_FLAG type CHAR1,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END OF TY_TAB.&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: ITAB type table of TY_TAB.&lt;BR /&gt; FIELD-SYMBOLS: &amp;lt;FS_TAB&amp;gt; type TY_TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;LOOP AT ITAB ASSIGNING &amp;lt;FS_TAB&amp;gt;.&lt;/P&gt;&lt;P&gt;IF YOUR_CONDITION = TRUE.&lt;/P&gt;&lt;P&gt;&amp;lt;FS_TAB&amp;gt;-DEL_FLAG = 'X'&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;BR /&gt; &lt;/P&gt;&lt;P&gt;DELETE ITAB where DEL_FLAG = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Mar 2012 07:25:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/deleting-internal-table-using-index/m-p/8618073#M1663618</guid>
      <dc:creator>vimalv</dc:creator>
      <dc:date>2012-03-19T07:25:55Z</dc:date>
    </item>
  </channel>
</rss>

