<?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: select from itab in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397857#M192571</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;Consider this ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    DATA : ind1 TYPE   sy-tabix,
           ind2 TYPE   sy-tabix.
    READ TABLE it_test INTO wa_test WITH TABLE KEY k1 = v1
                                   kn = v2.
    IF sy-subrc EQ 0.
      ind1 = sy-tabix + 1.
      ind2 = sy-tabix - 1.

      READ TABLE it_test INTO wa_after INDEX ind1.

      READ TABLE it_test INTO wa_before INDEX ind2.


    ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arun Sambargi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Arun Sambargi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Arun Sambargi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Jun 2006 14:38:22 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-29T14:38:22Z</dc:date>
    <item>
      <title>select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397847#M192561</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i need to find line in itab.&lt;/P&gt;&lt;P&gt;when i find it i need to take the line before and the line after how i can do it?&lt;/P&gt;&lt;P&gt;PLS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:30:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397847#M192561</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397848#M192562</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt; could u pls explain clearly ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ramesh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:33:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397848#M192562</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397849#M192563</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;  Use SY-Tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sy-tabix will point to current line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_next_line type I.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lv_next_line = sytabix + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;take temp work area.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wa_temp &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table itab into wa_temp index lv_next_line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;update current line with wa_temp.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;update next line with previous data&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:34:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397849#M192563</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397850#M192564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi rani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;use read stmt.&lt;/P&gt;&lt;P&gt;im not sure but try this..&lt;/P&gt;&lt;P&gt;read table itab index sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to read before the line&lt;/P&gt;&lt;P&gt;data: v_tabix type sy-tabix.&lt;/P&gt;&lt;P&gt;v_tabix = sy-tabix  - 1.&lt;/P&gt;&lt;P&gt;read table itab index v_tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to read after the line&lt;/P&gt;&lt;P&gt;data: v_tabix1 type sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;v_tabix1 = sy-tabix  + 1.&lt;/P&gt;&lt;P&gt;read table itab index v_tabix1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:34:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397850#M192564</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397851#M192565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;READ table something with key = sometning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp = sy-tabix + 1.&lt;/P&gt;&lt;P&gt;temp2= sy-tabix - 1.&lt;/P&gt;&lt;P&gt;READ table something index temp.&lt;/P&gt;&lt;P&gt;read table something index temp2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Something like that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR, JAcek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:34:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397851#M192565</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:34:47Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397852#M192566</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i have loop on mardh and before i have mard.        &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT imardh ASSIGNING &amp;lt;ls_mardh&amp;gt;.&lt;/P&gt;&lt;P&gt;          IF &amp;lt;ls_mardh&amp;gt;-lfmon = z_period+0(2) AND&lt;/P&gt;&lt;P&gt;             &amp;lt;ls_mardh&amp;gt;-lfgja = z_period+2(4).&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;here i found the line and end stock now i need to find the start and it's the line before&lt;/P&gt;&lt;P&gt;and if i didnt find i need to take the line before and after&amp;lt;/b&amp;gt;      &lt;/P&gt;&lt;P&gt;      &amp;lt;ls_mard&amp;gt;-e_stock = &amp;lt;ls_mardh&amp;gt;-labst.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          ENDIF.&lt;/P&gt;&lt;P&gt;        ENDLOOP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:36:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397852#M192566</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397853#M192567</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use the READ statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

data: index type i.

* Read the line with key
read table itab with key field1 = 'some_value'.

* Read the line before it
index = sy-tabix - 1.
read table itab index index.

* Read the line after it
index = sy-tabix + 1.
read table itab index index.








&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rich Heilman&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:36:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397853#M192567</guid>
      <dc:creator>RichHeilman</dc:creator>
      <dc:date>2006-06-29T14:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397854#M192568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi rani,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;u can find it thru sy-tabix. &lt;/P&gt;&lt;P&gt;example.&lt;/P&gt;&lt;P&gt;loop at itab.&lt;/P&gt;&lt;P&gt;l_tabix = sy-tabix." current line no.&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;For line before&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table itab index l_tabix -1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;For line after&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;read table itab index l_tabix +1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;kiran B&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:37:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397854#M192568</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397855#M192569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rani,&lt;/P&gt;&lt;P&gt;   The line you find in the itab will have a specific index. So you can do index + 1 and index - 1 to get the next and the before line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ex: your internal table has 5 records. you are taking the the 3rd record, your tabix will be 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;lws_index = sy-tabix + 1.&lt;/P&gt;&lt;P&gt;lws_ind   = sy-tabix - 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read table index lws_index. (next record)&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;read table index lws_ind. (before record)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:37:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397855#M192569</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397856#M192570</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;loop at itab where 'condition'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab_index = sy-tabix.&lt;/P&gt;&lt;P&gt;itab_prev_index = itab_index - 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read itab index itab_prev_index .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab_next_index = itab_index + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;read itab index itab_next_index .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:37:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397856#M192570</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397857#M192571</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;Consider this ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
    DATA : ind1 TYPE   sy-tabix,
           ind2 TYPE   sy-tabix.
    READ TABLE it_test INTO wa_test WITH TABLE KEY k1 = v1
                                   kn = v2.
    IF sy-subrc EQ 0.
      ind1 = sy-tabix + 1.
      ind2 = sy-tabix - 1.

      READ TABLE it_test INTO wa_after INDEX ind1.

      READ TABLE it_test INTO wa_before INDEX ind2.


    ENDIF.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arun Sambargi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Arun Sambargi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Arun Sambargi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:38:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397857#M192571</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: select from itab</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397858#M192572</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is the pseudo-code for your reqmt.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;*- 
data: l_tabix1 like sy-tabix.
data: l_tabix2 like sy-tabix.
*-
data: g_s_itab1 like line of g_t_itab.
data: g_s_itab2 like line of g_t_itab.

READ TABLE g_t_itab 
TRANSPORTING NO FIELDS WITH KEY 
key = 'KEY'
BINARY SEARCH. 
*-                                     
 if sy-subrc = 0.
 clear: l_tabix1, l_tabix2,g_s_itab1, g_s_itab2.
 l_tabix1 = sy-tabix - 1.
 l_tabix2 = sy-tabix + 1.
 read table g_t_itab into g_s_itab1 index l_tabix1.
*- check SY-SUBRC
 read table g_t_itab into g_s_itab2 index l_tabix2.
*- check SY-SUBRC
 endif.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps&lt;/P&gt;&lt;P&gt;best regards, Murugesh AS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2006 14:44:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/select-from-itab/m-p/1397858#M192572</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-29T14:44:20Z</dc:date>
    </item>
  </channel>
</rss>

