
Iteration Through Element Content
Use
Activate this option in the Attributes display for the BSP element if this element is to run through its own content repeatedly, that is, it should implement a loop.
Activities
In addition to activating this option, you must also redefine the interface method
DO_AT_ITERATION of the element handler class.This method is called each time at the end of an iteration. Using the return parameter , you control whether the loop is ended
(RC=CO_ELEMENT_DONE) or run through once again (RC=CO_ELEMENT_CONTINUE).Example
Let us assume that you wish to have a repeated text call with a simple <do>-Element. The number of iterations is set through the corresponding attribute
howOften.Example:
<loops:do howOften = "10">
Hello World !
</loops:do>
The value of the attribute
howOften is used at the beginning of the element call in the method DO_AT_BEGINNING in order to initialize the loop counter count:|
method IF_BSP_ELEMENT~DO_AT_BEGINNING . if howOften > 0. count = howOften - 1. rc = CO_ELEMENT_CONTINUE. else. rc = CO_ELEMENT_DONE. endmethod. |

The method
The implementation of
DO_AT_ITERATION could look like this:|
method IF_BSP_ELEMENT~DO_AT_ITERATION . if count <> 0. count = count - 1. rc = CO_ELEMENT_CONTINUE. else. rc = CO_ELEMENT_DONE. endif. endmethod. |

Note that the method
DO_AT_ITERATION
is called as soon as the element content has been processed. The method DO_AT_END, on the other hand, is called whatever the case, but only once; in this case, the call takes place after the iteration has closed