<?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: create range table from single values in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990720#M706352</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Hong,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;seems to be perfect... &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;ec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Nov 2007 10:04:03 GMT</pubDate>
    <dc:creator>JozsefSzikszai</dc:creator>
    <dc:date>2007-11-05T10:04:03Z</dc:date>
    <item>
      <title>create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990714#M706346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a number (several thousands) of single values. I want to create a range table from these single values (as you can see there are gaps in the numbers). What is the best way to achieve that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Values I have (in an internal table):&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;13&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;15&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;should be converted to:&lt;/P&gt;&lt;P&gt;I BT 1 3&lt;/P&gt;&lt;P&gt;I BT 5 6&lt;/P&gt;&lt;P&gt;I BT 9 9 (or I EQ 9 )&lt;/P&gt;&lt;P&gt;I BT 12 15&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;ec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 07:42:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990714#M706346</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2007-11-05T07:42:37Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990715#M706347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Suppose &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Values I have (in an internal table):&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;9&lt;/P&gt;&lt;P&gt;12&lt;/P&gt;&lt;P&gt;13&lt;/P&gt;&lt;P&gt;14&lt;/P&gt;&lt;P&gt;15&lt;/P&gt;&lt;P&gt;20&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;values are stored in a table: IT_value and in the field fld1. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now create a range table gr_value. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Loop at IT_value into wa_values.
   gr_value-low = wa_values-fld1.
   gr_value-sign = 'I'.
   gr_value-option = 'EQ'.
   append gr_value to gr_value.
   clear: wa_values, gr_value. 
endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now you can use the range table gr_value/&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 07:47:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990715#M706347</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-05T07:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990716#M706348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;LOOP AT itab INTO wa_itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;l_index = sy-tabix + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;READ table itab into wa_itab2 INDEX l_index.&lt;/P&gt;&lt;P&gt;IF sy-subrc = 0.&lt;/P&gt;&lt;P&gt;IF &amp;lt;wa_itab2-f1 - wa_itab1-f1 &amp;gt; EQ 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fill with EQ&lt;/P&gt;&lt;P&gt;ELSE &lt;/P&gt;&lt;P&gt;Fill with BT&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you got the logic, just do some corrections.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 07:50:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990716#M706348</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-05T07:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990717#M706349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Abhishek,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;your 'solution' is:&lt;/P&gt;&lt;P&gt;I EQ 1&lt;/P&gt;&lt;P&gt;I EQ 2&lt;/P&gt;&lt;P&gt;I EQ 3&lt;/P&gt;&lt;P&gt;I EQ 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is not what I want, pls. read the question again, before answering.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks ec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 08:20:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990717#M706349</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2007-11-05T08:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990718#M706350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Atish,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;good to start from but the main thing is when and how the low and high value of the range have to be handled and when to append...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 08:38:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990718#M706350</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2007-11-05T08:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990719#M706351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Herewith is code for reference:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  TYPES: BEGIN OF ST_NUM,
           NUM TYPE I,
         END OF ST_NUM.
  DATA: IT_NUM TYPE TABLE OF ST_NUM,
        WA_NUM LIKE LINE OF IT_NUM.

  WA_NUM-NUM = 1.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 2.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 3.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 5.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 6.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 9.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 12.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 13.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 14.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 15.
  APPEND WA_NUM TO IT_NUM.
  WA_NUM-NUM = 20.
  APPEND WA_NUM TO IT_NUM.

  DATA: NEXT TYPE SY-TABIX,
        WA_NEXT LIKE LINE OF IT_NUM,
        WA_CURR LIKE LINE OF IT_NUM,
        DIFF TYPE I.
  TYPES: BEGIN OF SEL,
           SIGN(1),
           OPTION(2),
           LOW TYPE I,
           HIGH TYPE I,
         END OF SEL.
  DATA:  S_SEL TYPE TABLE OF SEL,
         WA_SEL LIKE LINE OF S_SEL,
         JUMP  TYPE SY-TABIX.

  JUMP = 1.
  LOOP AT IT_NUM INTO WA_NUM.
    CHECK JUMP EQ SY-TABIX.
    NEXT = SY-TABIX + 1.
    READ TABLE IT_NUM INTO WA_NEXT INDEX NEXT.
    IF SY-SUBRC EQ 0.
      DIFF = WA_NEXT-NUM - WA_NUM-NUM.
      IF DIFF EQ 1.
        WA_SEL-LOW = WA_NUM-NUM.
        WA_SEL-SIGN = 'I'.
        WA_SEL-OPTION = 'BT'.
        WHILE DIFF EQ 1.
          WA_CURR = WA_NEXT.
          ADD 1 TO NEXT.
          READ TABLE IT_NUM INTO WA_NEXT INDEX NEXT.
          DIFF = WA_NEXT-NUM - WA_CURR-NUM.
        ENDWHILE.
        WA_SEL-HIGH = WA_CURR-NUM.
        APPEND WA_SEL TO S_SEL.
        CLEAR WA_SEL.
        JUMP = NEXT.
      ELSE.
        WA_SEL-LOW = WA_NUM-NUM.
        WA_SEL-SIGN = 'I'.
        WA_SEL-OPTION = 'EQ'.
        APPEND WA_SEL TO S_SEL.
        CLEAR WA_SEL.
        JUMP = NEXT.
      ENDIF.
    ELSE.
      WA_SEL-LOW = WA_NUM-NUM.
      WA_SEL-SIGN = 'I'.
      WA_SEL-OPTION = 'EQ'.
      APPEND WA_SEL TO S_SEL.
      CLEAR WA_SEL.
    ENDIF.
  ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 09:57:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990719#M706351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-05T09:57:15Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990720#M706352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Hong,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;seems to be perfect... &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;ec&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 10:04:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990720#M706352</guid>
      <dc:creator>JozsefSzikszai</dc:creator>
      <dc:date>2007-11-05T10:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990721#M706353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you got the answer..just on the way I thought :). Good your problem solved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Atish&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 10:32:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990721#M706353</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-05T10:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990722#M706354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also check this one&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt; BEGIN OF itab OCCURS 0,&lt;/P&gt;&lt;P&gt;   index TYPE sy-index,&lt;/P&gt;&lt;P&gt; END OF itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RANGES:&lt;/P&gt;&lt;P&gt; r_index FOR sy-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;itab-index = 1.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 2.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 3.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 5.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 6.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 9.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 12.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 13.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 14.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 15.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;itab-index = 16.&lt;/P&gt;&lt;P&gt;APPEND itab.&lt;/P&gt;&lt;P&gt;*itab-index = 20.&lt;/P&gt;&lt;P&gt;*APPEND itab.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;  w_index TYPE sy-tabix,&lt;/P&gt;&lt;P&gt;  w_temp_index TYPE sy-tabix.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SORT itab BY index.&lt;/P&gt;&lt;P&gt;READ TABLE itab INDEX 1.&lt;/P&gt;&lt;P&gt;r_index-sign =  'I'.&lt;/P&gt;&lt;P&gt;r_index-option = 'BT'.&lt;/P&gt;&lt;P&gt;r_index-low = w_temp_index = itab-index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT itab FROM 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  w_index = itab-index - w_temp_index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  IF w_index = 1.&lt;/P&gt;&lt;P&gt;    r_index-high = itab-index.&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    IF r_index-high IS INITIAL.&lt;/P&gt;&lt;P&gt;      r_index-high = r_index-low.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt;    APPEND r_index.&lt;/P&gt;&lt;P&gt;    CLEAR r_index-high.&lt;/P&gt;&lt;P&gt;    r_index-low = itab-index.&lt;/P&gt;&lt;P&gt;  ENDIF.                              " IF itab-index&lt;/P&gt;&lt;P&gt;  w_temp_index = itab-index.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;IF r_index-high IS INITIAL.&lt;/P&gt;&lt;P&gt;  r_index-high = r_index-low.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;APPEND r_index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;loop at r_index.&lt;/P&gt;&lt;P&gt;  write:/ r_index-low, r_index-high.&lt;/P&gt;&lt;P&gt;endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Rajesh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2007 10:58:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990722#M706354</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-05T10:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: create range table from single values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990723#M706355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like this. Excellent!! &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Nov 2007 00:58:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/create-range-table-from-single-values/m-p/2990723#M706355</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-11-06T00:58:39Z</dc:date>
    </item>
  </channel>
</rss>

