How to set a variable in rtf Template | xdoxslt:set_variable

image 1 set a variable in rtf Template 1

In Bi Publisher , this is a very common requirement to set a variable in RTF template to do some data manipulation activities.

Set variable is used to declare the variable in the BI publisher reports. We need to declare the variable first and then initialize with some value. Set variable helps to Declare and initialize the value to the variable in the XML/BI publisher report.

Some examples are to set a Running Total in BIP , Count Records in a Group etc.

Steps to add a variable in RTF

  • From the bi publiser menu in word insert the form field in RTF and add below code in the form field.
  • Make sure Variable form field is outside the grouping loop.
  • Add the below codes for each of the variables in its form field help text.
<?xdoxslt:set_variable($_XDOCTX, 'counter', 0)?>
<?xdoxslt:set_variable($_XDOCTX, 'lines_page', 4)?>
<?xdoxslt:set_variable($_XDOCTX, 'tot_lines', count(.//G_SLNO))?>
<?xdoxslt:set_variable($_XDOCTX,'remainder',0)?>

The above code will create variables counter, lines_page, tot_lines, remainder

G_SLNO is the example group name.

Use the following syntax to declare/set a variable value:

<?xdoxslt:set_variable($_XDOCTX, 'variable name', value)?>

Use the following syntax to retrieve a variable value:

Copy<?xdoxslt:get_variable($_XDOCTX, 'variable name')?>

For example, you can retrieve a variable value based on a condition:

Copy<?if:'column name'=xdoxslt:get_variable($_XDOCTX, 'variable name')?>

For example, you can perform calculations:

Copy<?xdoxslt:set_variable($_XDOCTX, 'x', xdoxslt:get_variable($_XDOCTX, 'x' + 1)?> 

This sets the value of variable ‘x’ to its original value plus 1, much like using “x = x + 1”.

For page break Use

  • Call the below code in form field before end the loop (Inside the loop)
xslt:get_variable($_XDOCTX, ‘lines_page’) <= 0?><?call:breaking?>

Running Total Variable in BIP

  • For taking Running total, use below code.
  • Make sure Variable outside the loop.
  • Add the code in the form field.
<?xdoxslt:set_variable($_XDOCTX, ‘counter’, 0)?>

  • call the below code in form field before end the loop (Inside the loop)
xslt:get_variable($_XDOCTX, counter + <ColumnName>) 

Column name is the field you want to have a running total.

wpsadmin
We will be happy to hear your thoughts

Leave a reply

Cloud Technologies Blog
Logo
Enable registration in settings - general
Compare items
  • Total (0)
Compare
0
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock
Shopping cart