BI Report, Business Intelligence Report,, For Loop, Oracle Fusion, Rich Text Format, RTF

Looping Finite Number Of Times in RTF

if you develop only a handful of reports, you are bound to come across a report where looping is required to be done for a finite or predetermined number of times. An example can be invoice printing where client wants to print only say 10 invoice lines per page, then you may need to use this kind of looping in RTF. Or say check print, where only a certain number of invoices must be printed on each check.

Well, syntax for looping in RTF is pretty simple:

<?for-each:xdoxslt:foreach_number($_XDOCTX,1,4,1)?> Test <?end for-each?>

so what happens if one creates the report using above code. Word “Test” gets printed 4 times. now a puzzle, what will be the output of following code snippets:

  • <?for-each:xdoxslt:foreach_number($_XDOCTX,1,4,1)?> Test <?end for-each?>
  • <?for-each:xdoxslt:foreach_number($_XDOCTX,2,5,1)?> Test <?end for-each?>
  • <?for-each:xdoxslt:foreach_number($_XDOCTX,2,5,2)?> Test <?end for-each?>
Foreach_output

Conclusion: if you remember the for loop syntax of C language:

for (i=1, i<=5 , i++)

the 3 numbers in the syntax work exactly the same. first number denotes the initial value of the variable, second value is the highest value the variable can attain, and the last number is the increment of the variable in each iteration. Go ahead and try it out. it’s fun.

what did you say? you want to use variable in the foreach_number loop, certainly you can. a sample code looks like this:

<?xdoxslt:set_variable($_XDOCTX, ‘locVar’,5)?>

<?for-each:xdoxslt:foreach_number($_XDOCTX,1, xdoxslt:get_variable($_XDOCTX, ‘locVar’),1)?> Test <?end for-each?>

so here an RTF variable was declared with name locVar and the value was set to 5. Same variable was used in for loop. Here is how the output will look like:

Foreach_output-1

Related Posts
How To Develop an RTF Template
Fusion Report Job Parameters
Report Security Query – Data Access On Specific Entities
Report Security

Feedback:
Hope the article helped you. If it did, please rate the post. In case it didn’t, do leave a comment to let us know what did we miss.

Reference:
support.oracle.com

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?