Thursday 25 October 2018

bi publisher tips and tricks



<?xml version = '1.0' encoding = 'utf-8'?>
<data>
<RequisitioningBU>bu name</RequisitioningBU>
</data>


-> working code for boilerplate (xdofx with upper), does not work in non-boilerplate type

<?xdofx:if upper(RequisitioningBU) ='BU NAME' then 'A' else if upper(RequisitioningBU) ='BU2 NAME' then 'B' else  'ORACLE' end if?>


-> working code for tags (xdofx with upper)

<?choose:?>
<?when:substring(RequisitioningBU,1,7)= "BU NAME"?> stuff <?end when?>
<?when:substring(RequisitioningBU,1,8)= "BU2 NAME"?> stuff <?end when?>
<?end choose?>


Adding IF condition in rtf with OR

<?if: not(substring(ReportNumber,1,2) = "PG" or substring(ReportNumber,1,2)= "NA") ?>


Define a xsl variable [xsl definition works under bi form elements only]

define:

<xsl:variable name="no_of_lines_per_page" select="number(26)"/>

print variables

<?$no_of_lines_per_page?>


Access tags a a particular level: relative retrival

./ mean at same level there should be a tag Payee, and under that Name tag should be present

<?./Payee/Name?>


Access tags a a particular level: absolute retrival

You can get absolute value using below logic

<?/OutboundPaymentInstruction/OutboundPayment/Beneficiary/Name?>




Test a condition with absolute path data 


Data:


<?xml version = '1.0' encoding = 'utf-8'?>
<A>
               <B ID="12345">
                              <C>data</C>
               </B>
</A>


Below syntax will 
1. create a variable v1
2. select value of A/B/@ID into v1
3. checks if value of v1 12345, if true prints SUCCESS
4. to use it within rtf, we need to create a rtf element [ex. xsl_var_if_test], and insert below syntax into that. 

<xsl:variable name="v1" select="A/B/@ID"/>
<xsl:if test="$v1 = '12345'">SUCCESS</xsl:if>



Combining XSL with for-each
May be you need to extract values from levels under a repeating element, and print them

Data:

<?xml version="1.0" encoding="utf-8"?>
<A>
  <B ID="12345">
    <C>data</C>
  </B>
  <B ID="123451">
    <C>data-1</C>
  </B>
  <B ID="123452">
    <C>data-2</C>
  </B>
  <B ID="123453">
    <C>data-3</C>
  </B>
  <B ID="123454">
    <C>data-4</C>
  </B>
  <B ID="123455">
    <C>data-5</C>
  </B>
</A>


Below syntax will 
1. create a variables v<>
2. select value of ./@ID into v<>
3. checks if value of v1 12345, if true prints SUCCESS

write in rtf like below:

<?for-each: B?>
xsl_var_if_test2
<?end for-each?>



where xsl_var_if_test2 is a element with boilerplate text as below
<xsl:variable name="v1" select="./@ID"/><xsl:if test="$v1 = '12345'">SUCCESS-0</xsl:if>
<xsl:variable name="v2" select="./@ID"/><xsl:if test="$v2 = '123451'">SUCCESS-1</xsl:if>
<xsl:variable name="v3" select="./@ID"/><xsl:if test="$v3 = '123452'">SUCCESS-2</xsl:if>
<xsl:variable name="v4" select="./@ID"/><xsl:if test="$v4 = '123453'">SUCCESS-3</xsl:if>
<xsl:variable name="v5" select="./@ID"/><xsl:if test="$v5 = '123454'">SUCCESS-4</xsl:if>


prints:

SUCCESS-1
SUCCESS-2
SUCCESS-3
SUCCESS-4

Subtraction in rtf:

<?(ACCTED_DR)-xdoxslt:sum(ACTUAL_DR)?>

---------------------------

ELSE IF
<?xdofx:if COMM!='' then SAL+COMM else SAL end if?>

DECODE TAG:
<?xdofx:decode(COMM,’’,’sry’,COMM)?>
<?xdofx:decode(COMM,’’,ENAME,COMM||’, ’||ENAME)?>

CHOOSE WHEN
<?choose:?> <?when: x == y?> ... <?end when?> <?otherwise:?> ... <?end otherwise?> <?end choose?>


No comments:

Post a Comment