<?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: do..varying..range.. error with dynamic variables in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/do-varying-range-error-with-dynamic-variables/m-p/1946335#M389979</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;U can use DO Varying in the case where u have fields in atable like belwo.&lt;/P&gt;&lt;P&gt;See this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF WORD, 
        ONE   VALUE 'E', 
        TWO   VALUE 'x', 
        THREE VALUE 'a', 
        FOUR  VALUE 'm', 
        FIVE  VALUE 'p', 
        SIX   VALUE 'l', 
        SEVEN VALUE 'e', 
        EIGHT VALUE '!', 
      END   OF WORD, 
      LETTER1, LETTER2. 
DO VARYING LETTER1 FROM WORD-ONE NEXT WORD-THREE 
   VARYING LETTER2 FROM WORD-TWO NEXT WORD-FOUR. 
  WRITE: LETTER1, LETTER2. 
  IF LETTER2 = '!'. 
    EXIT. 
  ENDIF. 
ENDDO.

DATA: i_knc1    TYPE STANDARD TABLE OF knc1,
         w_knc1        TYPE knc1,
        lv_debit  LIKE knc1-um01s,
        lv_credit LIKE knc1-um01h.
 
 
*Calculate AR Balance for each of the customer
  CLEAR lv_ar_bal.
 
  LOOP AT i_knc1 INTO w_knc1.
    lv_ar_bal  = w_knc1-umsav.
 
    DO 15 TIMES
     VARYING lv_debit  FROM w_knc1-um01s NEXT w_knc1-um02s
     VARYING lv_credit FROM w_knc1-um01h NEXT w_knc1-um02h.
      lv_ar_bal = lv_ar_bal + lv_debit - lv_credit.
    ENDDO.
 
    IF lv_ar_bal &amp;lt;= 0.
      DELETE i_knc1 WHERE kunnr = w_knc1-kunnr.
    ENDIF.
    CLEAR w_knc1.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this table KNC1 and compare the same with ur table.&lt;/P&gt;&lt;P&gt;Hope this clears you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Feb 2007 05:33:18 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-02-15T05:33:18Z</dc:date>
    <item>
      <title>do..varying..range.. error with dynamic variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/do-varying-range-error-with-dynamic-variables/m-p/1946334#M389978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Baper's,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm experiencing a 'DO_WHILE_VARY_NOT_IN_RANGE'&lt;/P&gt;&lt;P&gt;runtime error whilst attempting a do...varying statement. The problem is that the fields that vary are all dymnically determined at runtime and assigned to field symbols.  (see code snippet below).&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
   Data: l_percnt(2) type n.
   assign: hsl03 to &amp;lt;fs_loop_fld1&amp;gt;.
               hsl04 to &amp;lt;fs_loop_fld2&amp;gt;
  
   do l_percnt times varying l_amt from &amp;lt;fs_loop_fld1&amp;gt;
                                                 next &amp;lt;fs_loop_fld2&amp;gt;. 
 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The syntax check states that a range is required, but when I enter either &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;range glpct&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; or  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; assign glpct to &amp;lt;fs_work_area&amp;gt;.... range &amp;lt;fs_work_area&amp;gt; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;.  The runtime error dump is the same. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts on how to get this to work would be greatly appeciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2007 05:26:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/do-varying-range-error-with-dynamic-variables/m-p/1946334#M389978</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-15T05:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: do..varying..range.. error with dynamic variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/do-varying-range-error-with-dynamic-variables/m-p/1946335#M389979</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;U can use DO Varying in the case where u have fields in atable like belwo.&lt;/P&gt;&lt;P&gt;See this code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: BEGIN OF WORD, 
        ONE   VALUE 'E', 
        TWO   VALUE 'x', 
        THREE VALUE 'a', 
        FOUR  VALUE 'm', 
        FIVE  VALUE 'p', 
        SIX   VALUE 'l', 
        SEVEN VALUE 'e', 
        EIGHT VALUE '!', 
      END   OF WORD, 
      LETTER1, LETTER2. 
DO VARYING LETTER1 FROM WORD-ONE NEXT WORD-THREE 
   VARYING LETTER2 FROM WORD-TWO NEXT WORD-FOUR. 
  WRITE: LETTER1, LETTER2. 
  IF LETTER2 = '!'. 
    EXIT. 
  ENDIF. 
ENDDO.

DATA: i_knc1    TYPE STANDARD TABLE OF knc1,
         w_knc1        TYPE knc1,
        lv_debit  LIKE knc1-um01s,
        lv_credit LIKE knc1-um01h.
 
 
*Calculate AR Balance for each of the customer
  CLEAR lv_ar_bal.
 
  LOOP AT i_knc1 INTO w_knc1.
    lv_ar_bal  = w_knc1-umsav.
 
    DO 15 TIMES
     VARYING lv_debit  FROM w_knc1-um01s NEXT w_knc1-um02s
     VARYING lv_credit FROM w_knc1-um01h NEXT w_knc1-um02h.
      lv_ar_bal = lv_ar_bal + lv_debit - lv_credit.
    ENDDO.
 
    IF lv_ar_bal &amp;lt;= 0.
      DELETE i_knc1 WHERE kunnr = w_knc1-kunnr.
    ENDIF.
    CLEAR w_knc1.
  ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this table KNC1 and compare the same with ur table.&lt;/P&gt;&lt;P&gt;Hope this clears you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2007 05:33:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/do-varying-range-error-with-dynamic-variables/m-p/1946335#M389979</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-15T05:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: do..varying..range.. error with dynamic variables</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/do-varying-range-error-with-dynamic-variables/m-p/1946336#M389980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Judith,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the delay in responding.  Thanks for the information, but I knew that about 'do x times...', my issue was that I couldn't get it to work when using dynamic variables for the from...next...and range variables (i.e. ...from &amp;lt;field-symbol1&amp;gt; next &amp;lt;field-symbol2&amp;gt; range....).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As it was, I worked it out, I was assigning the field name to the field symbol, not the field value ( I was coding 'move  w_knc1-um01s to &amp;lt;field-symbol1&amp;gt;' rather than 'move (w_knc1-um01s) to &amp;lt;field-symbol1&amp;gt;').  Once I sorted that out, it worked a peach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Feb 2007 00:02:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/do-varying-range-error-with-dynamic-variables/m-p/1946336#M389980</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-02-21T00:02:41Z</dc:date>
    </item>
  </channel>
</rss>

