<?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: loop internal table to insert/replace in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442882#M1648783</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to loop the internal table to check between X123 and X124 if there is any text line in betweeen.&lt;/P&gt;&lt;P&gt;If yes, then replace with 'testing'.&lt;/P&gt;&lt;P&gt;If no text line between X123 and X124, then insert 'testing' in between.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X123 500 something something   "What about the text in this line. is to be replaced or kept as it is ?&lt;/P&gt;&lt;P&gt;something something something&lt;/P&gt;&lt;P&gt;X124 2345 something something&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Dec 2011 06:51:39 GMT</pubDate>
    <dc:creator>kesavadas_thekkillath</dc:creator>
    <dc:date>2011-12-30T06:51:39Z</dc:date>
    <item>
      <title>loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442874#M1648775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have an internal table &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X123 500 something something&lt;/P&gt;&lt;P&gt;something something something&lt;/P&gt;&lt;P&gt;X124 2345 something something&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to loop the internal table to check between X123 and X124 if there is any text line in betweeen.&lt;/P&gt;&lt;P&gt;If yes, then replace with 'testing'.&lt;/P&gt;&lt;P&gt;If no text line between X123 and X124, then insert 'testing' in between.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can give a hint.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:22:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442874#M1648775</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T06:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442875#M1648776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Will you be knowing the fileds to be compared before hand&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nabheet&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:30:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442875#M1648776</guid>
      <dc:creator>nabheetscn</dc:creator>
      <dc:date>2011-12-30T06:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442876#M1648777</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It is actually a string base on FPM_FILE.&lt;/P&gt;&lt;P&gt;Need to loop to detect in between X123 and X124 has a text line. if yes, change the text line to 'testing'. if no text line in between X123 and X124 then insert a text line 'testing'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:34:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442876#M1648777</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T06:34:01Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442877#M1648778</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you please let us know the fields of internal table like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;COLA    COLB    COLC&lt;/P&gt;&lt;P&gt;TEXT1   12          23322&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;nABHEET&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:37:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442877#M1648778</guid>
      <dc:creator>nabheetscn</dc:creator>
      <dc:date>2011-12-30T06:37:04Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442878#M1648779</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please read the available SAP documentation of the string functions. Your problem will be solved. read about &lt;STRONG&gt;REPLACE SECTION OF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kesav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:40:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442878#M1648779</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-12-30T06:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442879#M1648780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;as i said, it is based on FPM_FILE. and the text is in component line.&lt;/P&gt;&lt;P&gt;at the first 4 position, i can check X123 and X124.&lt;/P&gt;&lt;P&gt;now i not sure in the loop, how can i check in between X123 and X124 has text line in between as i need to work on it as per what i explained above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:41:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442879#M1648780</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T06:41:08Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442880#M1648781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friend,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From your post i am getting that you need to compare two internal table and based on the internal table values you need to assign value 'Testing' to a text field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am proceeding my answer with that assumption,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use one loop to loop one internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on the value just use read statement to read the value from other table and compare the values and use modify statement modify the values in that internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can understand what i have mentioned to get any sample code just tell me the exact scenario i will help with a sample code if needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sri Hari.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:41:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442880#M1648781</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T06:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442881#M1648782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;it is only 1 internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:42:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442881#M1648782</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T06:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442882#M1648783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to loop the internal table to check between X123 and X124 if there is any text line in betweeen.&lt;/P&gt;&lt;P&gt;If yes, then replace with 'testing'.&lt;/P&gt;&lt;P&gt;If no text line between X123 and X124, then insert 'testing' in between.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X123 500 something something   "What about the text in this line. is to be replaced or kept as it is ?&lt;/P&gt;&lt;P&gt;something something something&lt;/P&gt;&lt;P&gt;X124 2345 something something&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:51:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442882#M1648783</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-12-30T06:51:39Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442883#M1648784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;anyways your aim is to have 'testing' in between X* lines...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so why dont you delete all the lines which do not start with X&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;delete itab where f1+0(1) NE 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;after this,&lt;/P&gt;&lt;P&gt;start looping and keep inserting&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:54:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442883#M1648784</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T06:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442884#M1648785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;2 cases below. it is string and in a single internal table.&lt;/P&gt;&lt;P&gt;there are some other lines before X123 and after X124 which i cannot delete. must remain.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;X123 500 something something &lt;/P&gt;&lt;P&gt;something something something&lt;/P&gt;&lt;P&gt;X124 2345 something something&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;X123 500 something something  &lt;/P&gt;&lt;P&gt;testing&lt;/P&gt;&lt;P&gt;X124 2345 something something&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;from&lt;/P&gt;&lt;P&gt;X123 500 something something &lt;/P&gt;&lt;P&gt;X124 2345 something something&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;X123 500 something something  &lt;/P&gt;&lt;P&gt;testing&lt;/P&gt;&lt;P&gt;X124 2345 something something&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 06:55:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442884#M1648785</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T06:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442885#M1648786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check this example. Please note that this can be written in a better way.  As of now no time to think &lt;SPAN __jive_emoticon_name="wink"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

types:begin of ty,
      field type string,
end of ty.

data:it type table of ty,
     wa type ty,
     start_pos type i,
     end_pos type i,
     diff type i.
field-symbols:&amp;lt;fs&amp;gt; type ty.

constants:start_val(4) type c value 'X123'.
constants:end_val(4) type c value 'X124'.

wa-field = 'X123 500 something something'.
append wa to it.
wa-field = 'something something something'.
append wa to it.
wa-field = 'X124 2345 something something'.
append wa to it.

loop at it assigning &amp;lt;fs&amp;gt;.
  if &amp;lt;fs&amp;gt;-field cs start_val.
    start_pos = sy-tabix.
  endif.
  if &amp;lt;fs&amp;gt;-field cs end_val.
    end_pos = sy-tabix.
   exit.
  endif.
endloop.

diff = end_pos - start_pos.
if diff &amp;gt; 1.
  wa-field = 'Testing'.
  start_pos = start_pos + 1.
  end_pos = end_pos - 1.
  loop at it assigning &amp;lt;fs&amp;gt; from start_pos.
    &amp;lt;fs&amp;gt;-field = 'Testing'.
    if sy-tabix = end_pos.
      exit.
    endif.
  endloop.
else.
  start_pos = start_pos + 1.
  insert initial line into it index start_pos.
  read table it assigning &amp;lt;fs&amp;gt; index start_pos.
  if sy-subrc = 0.
    &amp;lt;fs&amp;gt;-field = 'Testing'.
  endif.
endif.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 07:04:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442885#M1648786</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-12-30T07:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442886#M1648787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi friend,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Move the table data into a structure and then try to find whether there is any text in between the two fields and then change the structure and modify the table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make a duplicate of an internal table and then check the field 1 with field 4 or any of the duplicate table and then modify any one table based on the value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think this will solve your issue. Please revert back to me if your problem still exists.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sri Hari&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 07:04:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442886#M1648787</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T07:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442887#M1648788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this: &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below code considers anything that does not start with X123 or X124 as text.&lt;/P&gt;&lt;P&gt;The logic used below is ... It would delete all text line between X123 and X124 ...&lt;/P&gt;&lt;P&gt;And insert a testing line in between....&lt;/P&gt;&lt;P&gt;I have tried this and it has worked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT itab.
  v_tabix = sy-tabix.
  IF itab+0(4) = 'X123'.
    v_start = 'X'.
    CONTINUE.
  ENDIF.
  IF v_start = 'X'.
    IF itab+0(4) NE 'X124'.
      DELETE itab INDEX v_tabix.
    ELSE.
      CLEAR: v_start .
      itab = 'testing'.
      v_tabix = v_tabix.
      INSERT itab INDEX v_tabix.
    ENDIF.
  ENDIF.
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 07:05:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442887#M1648788</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-12-30T07:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: loop internal table to insert/replace</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442888#M1648789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Work ;)..But OP has to Confirm If there are more than one lines in between , whether he needs all the lines with a single line or all the lines in between needs to be replaced with 'Testing' in each line. In this case you have to modify your code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Dec 2011 07:10:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/loop-internal-table-to-insert-replace/m-p/8442888#M1648789</guid>
      <dc:creator>kesavadas_thekkillath</dc:creator>
      <dc:date>2011-12-30T07:10:32Z</dc:date>
    </item>
  </channel>
</rss>

