‎2007 Feb 15 5:26 AM
Hi Baper's,
I'm experiencing a 'DO_WHILE_VARY_NOT_IN_RANGE'
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).
Data: l_percnt(2) type n.
assign: hsl03 to <fs_loop_fld1>.
hsl04 to <fs_loop_fld2>
do l_percnt times varying l_amt from <fs_loop_fld1>
next <fs_loop_fld2>.
The syntax check states that a range is required, but when I enter either
range glpctor
assign glpct to <fs_work_area>.... range <fs_work_area> . The runtime error dump is the same.
Any thoughts on how to get this to work would be greatly appeciated.
Cheers,
Stephen
‎2007 Feb 15 5:33 AM
Hi,
U can use DO Varying in the case where u have fields in atable like belwo.
See this code
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 <= 0.
DELETE i_knc1 WHERE kunnr = w_knc1-kunnr.
ENDIF.
CLEAR w_knc1.
ENDLOOP.Check this table KNC1 and compare the same with ur table.
Hope this clears you.
‎2007 Feb 21 12:02 AM
Hi Judith,
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 <field-symbol1> next <field-symbol2> range....).
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 <field-symbol1>' rather than 'move (w_knc1-um01s) to <field-symbol1>'). Once I sorted that out, it worked a peach.
Cheers,
Stephen