Difference between repeat and do block

Shubham Pipada

New Member
Hi everyone,
Can someone please provide me the differences between the repeat block and do block and when to use what!
I had read somewhere that repeat provides e.g transaction management and default frame management whereas do block doesn't.
Also , why is it recommended to have a single mainloop(repeat) and then inside that if we want to do more looping then to use do-undo-retry instead of repeat?
How would the performance be affected if we use too many repeats or use do blocks inside a repeat?
And what are the features of both!
Also if we use some validation,and if some condition fails, then we for e.g if using repeat - we use next xyz loop.....and if using do - we use do on error undo retry.......so whats the difference in these 2 cases and how would even they rollback the changes?

Thanks in advance.
 
Last edited:

RealHeavyDude

Well-Known Member
The secret lies in standard block behavior which differ between a do - which does not have any scoping capabilities and and loops like repeat or for which do have scoping capabilities. Scoping capabilities - that is buffer or transaction scope.

Understanding buffer and transaction scope is fundamental for writing efficient ABL code that scales. Not understanding buffer and transaction scope is the road to hell. You need to make yourself familiar with buffer and transaction scoping.

For the nesting of loops - I can't tell. As always it depends on what it is that you need to achieve and what type of error handling you need. Do you like to code a logic that retries potentially for ever when there is no hope that the root cause for the error automagically goes away or leave the block and abort the processing because of the error so that it can be fixed by somebody.

Please don't get me wrong - but neither is this an education forum nor do we like to spend much time on a lot of theoretical questions from different areas in one post.
If you need support - please come up with a real world example that you have an issue with or which does not behave in the way you expect it to.
And - please - provide sufficient information. Then we are glad to help.
 

tamhas

ProgressTalk.com Sponsor
Note that one can scope a buffer or transaction to a DO loop, but one has to state it explicitly instead of it being implicit like with REPEAT.
 
Top