SELECT GEH.REFERENCE_NO,
  GEH.TRANSACTION_ID,
  GEH.TRANSACTION_DATE,
  gel.line_number,
  gel.journal_line_type,
  gel.entered_amount,
  gel.accounted_amount,
  FND_FLEX_EXT.GET_SEGS(‘SQLGL’, ‘GL#’,gcc.chart_of_accounts_id,gcc.code_combination_id) account,
  GL_FLEXFIELDS_PKG.get_concat_description( gcc.chart_of_accounts_id, gcc.code_combination_id) acc_description
FROM gl_code_combinations gcc,
  xla_ae_lines al,
  xla_distribution_links dl,
  gmf_xla_extract_headers geh,
  gmf_xla_extract_lines gel
WHERE gcc.code_combination_id       = al.code_combination_id
AND al.ae_header_id                 = dl.ae_header_id
AND al.ae_line_num                  = dl.ae_line_num
AND dl.event_id                     = geh.event_id
AND dl.application_id               = 555
AND dl.source_distribution_type     = geh.entity_code
AND dl.source_distribution_id_num_1 = gel.line_id
AND geh.header_id                   = gel.header_id
and geh.event_id                    = gel.event_id
–AND gel.journal_line_type          IN (‘COGS’,’DCOG’)
AND geh.transaction_date           >= TO_DATE(‘&&fromDate’
  ||’ 00:00:00′,’MM/DD/YYYY hh24:mi:ss’) –period start date 01/01/2011
AND geh.transaction_date <= TO_DATE(‘&&toDate’
  ||’ 23:59:59′,’MM/DD/YYYY hh24:mi:ss’) –Period end date 01/31/2011 
When you start developing RTF Templates and try to do something a bit advanced most likely you start seeing these words, XSL, XSLT, XPATH, XSL-FO…. And they might have scared or confused you. I’ve met many people use those terms without a correct understanding and everybody uses them in different ways so even I get sometimes confused when I talk with them. 😉 I think the part of the reason is coming from its own history.

What is XSL?

XSL stands for ‘Extensible Stylesheet Language’ and it was designed to describe how to transform and format XML files. But it split into different specifications (or languages) as listed below. So this XSL itself actually is really anything today, it rather be a family name if you will, which contains all the three related languages below.

Here is a list of the three languages that comprise the XSL.

  • XPATH – a language for navigating in XML documents
  • XSLT – a language for transforming XML documents
  • XSL-FO – a language for formatting XML documents


Let’s take at look at each language in more detail and why we need to know them for BI Publisher reports development.

Start from XPath…
XPath is a language for finding information in an XML document. XPath is used to navigate through elements and attributes in an XML document. XPath uses path expressions to navigate in XML documents. It is very similar to what we call ‘Path’ on Unix file system. Basically it acts as a navigation in XML files. Let’s say there is a parent node called ‘Department’ and it has a child node called ‘Employee’. Now you’re processing Employee node and want to get some data from the parent node, Department. This is where the XPath comes in. And it is in fact very simple to do this. You can type something like ‘../Department/BUDGET’. Yes, that’s it and it’s very similar to the path we use at the file system, right?

Path Expression
What makes XPath different from the path is its Path Expression. The Path Expression is very powerful and makes it much easier to access to any vaues in the XML files.
For example you can use ‘//’ (double slashes) to indicate that you want to get any Element and it doesn’t matter if what level the element is.

Here is a list of commonly used Path Expressions.

/ – Selects from the root node

Example:
/Department (Selects the root element Department)
Department/Employee (Selects all Employee elements that are children of Department)

// – Selects nodes in the document from the current node that match the selection no matter where they are

Example:
//Department (Selects all Department elements no matter where they are in the XML)

Department//Employee (Selects all Employee elements that are descendant of the Department element, no matter where they are under the Department element)

. – Selects the current node

.. – Selects the parent of the current node

@ – Selects attributes

Example:
//@type (Selects all attributes that are named type)

Predicates

Also, there are some advanced expressions called ‘Predicates’. Predicates are something you might have seen in your template They are presented with square brackets. They are used to find a specific node and can have specific conditions to specify the node. For example, ‘/Department[1]’ will return the first Department node while ‘/Department[2]’ will return the second Department node. You can also have a condition in the predicates to pick a certain set of nodes only when the condition matches. For example, if you specify ‘/Department[Salary>5000]’ then it will return only the Department nodes that contains Salary element whose values are greater than 5000.

You can also specify relative position. The above example of ‘/Department[1]’ will always return the first Department node in the XML file. But if you have many groups or you’re grouping by a certain value (e.g. Department name) and you might want to pick the first node in the each group. In this case you can use ‘Department[first()]’ or ‘Department[position()=1].

Operators (Functions)
Also, XPath has its own Operators (or functions) that you can use to process or calculate your data in the XML file. For example there is a ‘substring’ function, which you can use to get a part of the data you want from a specified Element values. There are many other useful functions and all of the standard XPath functions can be used in the BI Publisher’s RTF Template. Here is a set of XPATH functions that are useful and we use in many cases with the RTF Template.

List of XPATH functions

  1. substring()
  2. substring-before(’12/10′,’/’)
  3. replace(“Bella Italia”, “l”, “”)
  4. upper-case() /lower-case()
  5. contains()
  6. distinct-values()
  7. false()
  8. sum()


Why this is for BI Publisher?
Now you have gone though the XPath basic and wondering ‘why do I need to know this?’ Here is list of example use cases where we think it is critical and very useful if you understand the XPath appropriately.

  1. With for-each-group you need to specify a parent node and an element node where you want to group by with XPath appropriately
  2. When you want to access to a parent node’s element values when you are processing tis child node.
  3. For IF condition you might want to process data to build some valid conditions. For example if you want to get Employee name ‘Smith’ regardless whether it’s in upper case, lower case or the combination, you can use ‘upper-case()’ so that every type of ‘Smith’ will be matched.
  4. Inside Chart definition you need to specify all the Element names appropriately with XPath. Also you can use the XPath functions to have conditions or process data inside the Chart.


These are just a few examples to list, but there are many other cases you can take advantage of the XPath and make your RTF Template development much easier and more flexible and powerful.

Also, note that using the XPath without an appropriate understanding might cause performance and resource allocation problems. Due to its flexibility you can achieve what you want to do by using many different ways with XPath. However, you might end up typing XPath codes that cause very resource intensive or unnecessary processing. The key is to have a right understanding of XPath and write the code in the most optimized way from maintenance and performance perspective.

What is XSLT? 
Today, I’ll cover the basic of the XSLT. Basic development of BI Publisher RTF Template doesn’t require the XSLT coding. However, when you start developing advanced reports having a good understanding of the XSLT will help you to develop the RTF Template efficiently and provide richer functionality. I’ll cover the benefit of using XSLT at the end of this posting. 

XSLT stands for XSL Transformations and XSL stands for Extensible Style sheet Language. XSLT is a language for transforming XML documents into another form of documents such as XML, HTML, XHTML, etc. When you use XSLT to transform the original XML documents you will also use XPath to navigate through the documents. So in this process of transforming the documents you use a combination of XSLT and XPath together. 

How to use? 
Here is a list of basic steps to use XSLT. 

1. Declare XSL namespace 
2. Create XSL style sheet 
3. Add a link to the style sheet 

1. Declare XSL namespace 
First you need to declare XSL namespace like follows at the top of the XML document.

<xsl:stylesheet version=”1.0″
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>

2. Create XSL style sheet 
Then you can start developing the XSL style sheet. How you can develop the style sheet will be covered later. 

3. Add a link to the style sheet 
Once you have created the style sheet now you can add a link to the style sheet in the original XML document. Then when you process the XML document whatever the standard XSL processor you’re using would transform the XML document following the transformation rules designed in the XSL style sheet is linked in the XML document. 

Example:

<?xml-stylesheet type=”text/xsl” href=”sample.xsl”?> 
XSL Element (or function)

XSL transformation rules are defined with XSL Elements. Here is a set of the most commonly used XSL elements.

  • <xsl:template>
  • <xsl:value-of>
  • <xsl:for-each>
  • <xsl:sort>
  • <xsl:if>
  • <xsl:choose>
  • <xsl:apply-templates>
Since most of the XSLT coding can be also done by the native BI Publisher coding, at each of the following Element example section I’ll also show how to do the same with the BI Publisher coding.

XSL:TEMPLATE
This element is used to specify what part of the XML document should be transformed or be applied with the rules described in the XSL stylesheet. You can use ‘match’ attribute specifying the section of the XML with XPath. For example, if you specify ‘/’ (Root) then the XSL stylesheet will be applied to the entire XML document.

Example: 

<xsl:template match=”/”> 

XSL:VALUE-OF
This element is used to retrieve a value from a specified Element or Attribute. For example, if you used this element specifying ‘/DATA/DEPARTMENT/NAME’ then you can retrieve a value that is presented in the NAME element in the XML document.

Example:

<xsl:value-of select=’/DATA/DEPARTMENT/NAME’/> 
With BI Publisher tags, you can just type the following to do the same.
<?/DATA/DEPARTMENT/NAME?> 

XSL:FOR-EACH
When you just use the <xsl:value-of> element you will get the first value of the specified element. With the above case, you will get the first Department name. But what if you have 5 departments and want to display all the names together?

You can use this ‘for-each’ element to repeat through a specified node. It works the same way as ‘for loop’ in any typical programming language such as C, Java. For example, if you specify ‘/DATA/DEPARTMENT’ as a node and use the ‘for-each’ element to repeat then the XSL processor will repeat through the Department node and display all the department names.

Example:

<xsl:for-each select=’/DATA/DEPARTMENT’>
  <xsl:value-of select=’NAME’/>
</xsl:for-each>
With BI Publisher tags, you can type the following to do the same.
<?for-each:/DATA/DEPARTMENT?>
  <?NAME?>
<?end for-each?>

XSL:SORT
Inside the previous ‘for-each’ loop you might want to sort the data by alphabetically or based on the ID, etc. You can use this ‘sort’ element to do the sorting.

Example: 

<xsl:for-each select=’/DATA/DEPARTMENT’>
<xsl:sort select=’NAME’/>
  <xsl:value-of select=’NAME’/>
</xsl:for-each>
Also you can specify the data type and whether it should be ascending or descending order.

Example: 

  <xsl:sort select=’NAME’ data-type=’text’ order=’descending’/>
With BI Publisher you can do the following to achieve the same. 
  <?sort:NAME;’ascending’;data-type=’text’?>

XSL:IF
You can use this element to have a condition in the XSL transformation logic. This is also pretty much the same as other programming language’s ‘if’ condition. For example, if you want to display manager name only when Department name is ‘Consulting’ you can specify something like the below.

Example: 

<xsl:for-each select=’/DATA/DEPARTMENT’>
  <xsl:if test=”NAME=’Consulting’”>
    <xsl:value-of select=’MANAGER_NAME’/>
  </xsl:if>
</xsl:for-each>
You can do the same with BI Publisher tags as follows.
<?for-each:/DATA/DEPARTMENT?>
  <?if:NAME=’Consulting’?>
    <?NAME?>
  <?end if?>
<?end for-each?>
XSL:CHOOSE
As an alternative or for better reasons you can also use CHOOSE/WHEN elements to do the condition. One thing to note is that XSL doesn’t support IF/ELESE condition as native, so if you have multiple conditions to use together in a form of IF/ELSE then CHOOSE/WHEN/OTHERWISE elements would serve you better.

Example: 

<xsl:for-each select=’/DATA/DEPARTMENT’>
  <xsl:choose>
  <xsl:when ”NAME=’Consulting’”>
    <xsl:value-of select=’MANAGER_NAME’/> 
    <xsl:value-of select=’DEPARTMENT_NAME’/>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select=’DEPARTMENT_NAME’/>
  </xsl:otherwise>
</xsl:for-each>
With BI Publisher you can do the below to have the same condition. 
<?for-each:/DATA/DEPARTMENT?>
  <?choose:?>
  <?when:NAME=’Consulting’>
    <?MANAGER_NAME?>
    <?DEPARTMENT_NAME?>
  <?end when?>
  <?otherwise:?>
    <?DEPARTMENT_NAME?>
  <?end otherwise?>
  <?end choose?>
<?end for-each?>
Why XSLT is needed for BI Publisher?

Though you can type any XSLT coding and BI Publisher can understand it, typical RTF Template development doesn’t require the use of the XSLT. In fact BI Publisher’s tags, which are surrounded by ‘?’ marks, covers the native XSLT functionality for the most so that you don’t need to type the XSLT code. As you have seen, what you can do with XSLT can also be done by the BI Publisher tags and visaversa. When you develop the RTF Template you can use the BI Publisher’s tags then at the run time BI Publisher translate the tags to the XSL codes internally. BI Publisher’s tags are there to make the template development much easier for those who do not have any XML/XSL or programming experience.

However, there are certain situations where you might want to use XSLT over BI Publisher’s tags. Such situation includes the Chart development and variable handling. As you might have known behind the Chart definition is XSLT code. You can insert a chart from the Template Builder (MS Word Add-in) Chart wizard to start with. But once you want to customize the default chart formatting or logic’s to handle the data then you need to modify the XSLT code behind the Chart definition.

Also, sometimes it’s very useful when you want to use variables. There is a BI Publisher’s tag for variable handling but sometimes I find using XSLT’s variable is easier though it depends on the requirements.

Lastly, you can create a set of custom functions in XSL template and call them from your RTF Template as external functions. This is very useful especially when you have common logic’s that contain custom functions or calculations and can be used in many different BI Publisher’s text forms or different templates, yet don’t want to maintain them in each text form or each template. Once you have developed a single XSL template where you create such logics or functions then you can import the XSL template from any of your RTF template and call any of the custom function to do the same process. 

Sometimes we will face below issues in R12.

Issue 1:
You have insufficient privileges for the current operation. Please contact your System Administrator.

You cannot run a page which is not Self Secured when the MAC fails.

Resolution:
 
Set the below 3 profiles to None
1) FND Function Validation Level
2) FND Validation Level
3) Framework Validation Level
JDev-2
Issue 2:
Unexpected URL parameters have been detected and will be ignored Solution:
 
Resolution:

In JDeveloper, go to menu Tools–>Embedded OC4J Server Preferences–>Global–>Startup–>Select Default Local IP Address.
JDev-3
 
 
Autoconfig log file:
Apps:
$INST_TOP/appl/$CONTEXT_NAME/admin/log/$MMDDHHMM/adconfig.log

Db:
$ORACLE_HOME/appsutil/log/$CONTEXT_NAME/adconfig.log $ORACLE_HOME/appsutil/log/$CONTEXT_NAME/NetServiceHandler.log

Startup/Shutdown Log files:

$INST_TOP/logs/appl/admin/log

Apache, OC4J and OPMN:

$LOG_HOME/ora/10.1.3/Apache 
$LOG_HOME/ora/10.1.3/j2ee 
$LOG_HOME/ora/10.1.3/opmn

Patch log:

$APPL_TOP/admin/$SID/log/
Workflow Mailer log:
$APPLCSF/$APPLLOG/FNDCPGSC*.txt

Concurrent log:

$INST_TOP/apps/$CONTEXT_NAME/logs/appl/conc/log
OAM (Oracle Application Manager) log:
$APPLRGF/oam/

Clone log:

Preclone log files in source instance

Apps:
$INST_TOP/apps/$CONTEXT_NAME/admin/log/ (StageAppsTier_MMDDHHMM.log)

Db:
$ORACLE_HOME/appsutil/log/$CONTEXT_NAME/(StageDBTier_MMDDHHMM.log)

Clone log files in target instance:

Apps :
$INST_TOP/apps/$CONTEXT_NAME/admin/log/ApplyAppsTier_.log

Db:
$ORACLE_HOME/appsutil/log/$CONTEXT_NAME/ApplyDBTier_.log

– Alert Log File:
$ORACLE_HOME/admin/$CONTEXT_NAME/bdump/alert_$SID.log

Concurrent OUT Directory:
$APPLCSF/$APPLOUT  or $APPLCSF/out
APPL_TOP – this is the top level directory for the Applications
  • $APPLCSF – the top level directory where the concurrent manager stores the log and out files of concurrent requests
  • $APPLCSF/$APPLLOG – concurrent request log files( As describe above)
  • $APPLCSF/$APPLOUT – concurrent request out files( As describe above)
  • $APPLTMP – Applications temporary files
  • $APPLPTMP – PL/SQL temporary files   or /usr/tmp (default tmp directory)
Startup and shutdown messages:
–Startup/Shutdown error message related to tech stack (10.1.2, 10.1.3 forms/reports/web)
$INST_TOP/logs/ora/ (10.1.2 & 10.1.3)
$INST_TOP/logs/ora/10.1.3/Apache/error_log[timestamp]
$INST_TOP/logs/ora/10.1.3/opmn/ (OC4J~…, oa*, opmn.log)$INST_TOP/apps/$CONTEXT_NAME/logs/ora/10.1.2/network/ (listener log)
$INST_TOP/logs/appl/conc/log (CM log files)
Other log files in R12

1) Database Tier
1.1) Relink Log files :
$ORACLE_HOME/appsutil/log/$CONTEXT_NAME /MMDDHHMM/ make_$MMDDHHMM.log

1.2) Alert Log Files :
$ORACLE_HOME/admin/$CONTEXT_NAME/bdump/alert_$SID.log

1.3) Network Logs :
$ORACLE_HOME/network/admin/$SID.log

1.4) OUI Logs :
OUI Inventory Logs :
$ORACLE_HOME/admin/oui/$CONTEXT_NAME/oraInventory/logs

2) Application Tier

$ORACLE_HOME/j2ee/DevSuite/log
$ORACLE_HOME/opmn/logs
$ORACLE_HOME/network/logs

Tech Stack Patch 10.1.3 (Web/HTTP Server)
$IAS_ORACLE_HOME/j2ee/forms/log
$IAS_ORACLE_HOME/j2ee/oafm/log
$IAS_ORACLE_HOME/j2ee/oacore/log
$IAS_ORACLE_HOME/opmn/logs
$IAS_ORACLE_HOME/network/log
$INST_TOP/logs/ora/10.1.2
$INST_TOP/logs/ora/10.1.3
$INST_TOP/logs/appl/conc/log
$INST_TOP/logs/appl/admin/log

Patching related log files in R12 :
Application Tier– adpatch log – $APPL_TOP/admin//log/
Developer (Developer/Forms & Reports 10.1.2) Patch – $ORACLE_HOME/.patch_storage
Web Server (Apache) patch – $IAS_ORACLE_HOME/.patch_storage
Database Tier opatch log – $ORACLE_HOME/.patch_storage