DO x TIMES VARYING xx FROM xx NEXT

Question: I'm tidying up some code for our UC project and I've come across this code which doesn't look right because the range only includes one value. Am I missing something or is this code daft?

Do 6 times
   varying l_tdline from lv_zzsumd1 next lv_zzsumd1.
   clear l_tdline.
Enddo.


Answer:
It does seem a bit daft. Have you stepped through it in debug mode ?
_________________
Regards

R


Abap KC
SFMDR

Answer:
Yep, daft!

Clears the field lv_zzsumd1 6 times.

Could be a typo in the original code, should be -Do 6 times
   varying l_tdline from lv_zzsumd1 next  lv_zzsumd2.
   clear l_tdline.
Enddo. Or this has been changed so it only clears the first value.

Does this code ever get performed? Is there any other code that clears lv_zzsumd2 - lv_zzsumd6.
_________________
MattG.
Search SAPfans

Answer:
Here is more of the code. I have added the Range statement so that it is now Unicode compliant. But I'm sure that the code is supposed to read next lv_zzsumd6. Not my responsibility to fix it unfortunately as its working ok in Production so I'll just raise it as an issue. And add it to all the other issues I've found over the last 4 weeks......

FORM fetch_summary_desc                                          " §01
                USING    LV_VBELN   LIKE ZVEXAK10_P-VBELN
                         LV_zzsumd1 LIKE ZVEXAK10_P-zzsumd1
                         LV_zzsumd2 LIKE ZVEXAK10_P-zzsumd2
                         LV_zzsumd3 LIKE ZVEXAK10_P-zzsumd3
                         LV_zzsumd4 LIKE ZVEXAK10_P-zzsumd4
                         LV_zzsumd5 LIKE ZVEXAK10_P-zzsumd5
                         LV_zzsumd6 LIKE ZVEXAK10_P-zzsumd6.

field-symbols <fs>.
data:
  l_field   like tline-tdline,
  l_tdline  like ZVEXAK10_P-zzsumd1,
  l_indx    type n.

*{   REPLACE                                             1
*\Do 6 times
*\   varying l_tdline from lv_zzsumd1 next lv_zzsumd1.
*\   clear l_tdline.
*\Enddo.
* Perplexed  08/06/2006  Unicode Project
Do 6 times
   varying l_tdline from lv_zzsumd1 next lv_zzsumd1 range lv_zzsumd1.
   clear l_tdline.
Enddo.
*}   REPLACE


Answer:
Looks like an attempt to clear the 6 input parameters, but was changed to only the first when they found it did not work properly. The 6 fields have to be part of a single structure for this technique to work, not 6 fields with simular names.
_________________
MattG.
Search SAPfans

Answer:
Or, of course you could just simply say


clear: lv_zzsumd1,
         lv_zzsumd2,
         lv_zzsumb3............


Answer:
or use a macro.
Copyright ?2007 - 2008 www.jt77.com