You are on page 1of 5

Data Template

Data Templates are XML documents used to generate the data XML files. These data XML files are used by ETEXT or any other layout template (RTF, PDF, XSLFO etc.) to generate the output in TEXT, PDF and EXCEL etc. XML Publisher Data Template Architecture

Data templates elements communicate primarily the following information to the data engine: Data Query: The SQL query with bind parameter specifying the data to be fetched. Bind Parameters: Definition of each bind parameter defined in the query. Data Structure: Definition of the Output XML Structure. Data Triggers: Triggers that should be executed before or after the data query execution. Triggers are used to either do initialization or do some post query operation. Hence Data Template is the means by which we inform the data engine to fetch the data of our interest. Some of the sections of a Data Template are given below with examples: Header element: where we provide a name and description for the Data Template. The name will be used as the root name of the element. Example:
<dataTemplate name="GBMRKTTRKR" description="This Data Template generates XML output for GB Market Tracker report" dataSourceRef="" defaultPackage="GB_MARKET_TRACKER_PKG" version="1.0">

Properties: these are the runtime switches for the extraction engine. Some of the parameters which may be set are: include_parameters decides whether the parameter values should be extracted to the data XML or not

include_null_Element - if a value when extracted is null do you want an empty element in the xml xml_tag_case - upper or lower case tag names db_fetch_size - maximum number of records to fetch scalable_mode - if you know this is going to be a large dataset or an intensive extract then set this to true include_rowsettag - for simple XML with no hierarchy do you want ROWSET as the root element debug_mode - generate a debug file while processing or not.
<properties> <property name="include_parameters" value="true" /> <property name="include_null_Element" value="true" /> <property name="xml_tag_case" value="upper" /> <property name="db_fetch_size" value="500" /> <property name="scalable_mode" value="off" /> <property name="include_rowsettag" value="true" /> <property name="debug_mode" value="on" /> </properties>

Example:

Parameters: these are the runtime parameters for the Data Template. The parameter names should be same as defined in the Concurrent Program registration. These parameters can be used by the SQL query as bind variables. Example:
<parameters> <parameter name="P_ORGANIZATION" dataType="number" defaultValue="" /> <parameter name="P_SOURCE_TYPE" dataType="varchar2" defaultValue="" /> </parameters>

Lexicals: these are EBS specific and will allow us to use flexfield values in Data Query. Example:
<lexicals> <lexical type="oracle.apps.fnd.flex.kff.select" name="FLEXDATA_DSP" comment="Comment" application_short_name="SQLGL" id_flex_code="GL#" id_flex_num=":STRUCT_NUM" multiple_id_flex_num="N" code_combination_table_alias="CC" segments="ALL" show_parent_segments="Y" output_type="VALUE" /> <lexical type="oracle.apps.fnd.flex.kff.select" name="FLEXDATA_SECURE" comment="Comment" application_short_name="SQLGL" id_flex_code="GL#" id_flex_num=":STRUCT_NUM" multiple_id_flex_num="N" code_combination_table_alias="CC" segments="ALL" show_parent_segments="Y" output_type="SECURITY" /> </lexicals>

DataQuery: this is where we define the SQL query(s) Example:


<dataQuery> <sqlStatement name="Q_MAIN" dataSourceRef=""><![CDATA[SELECT gmtt.item ITEM, gmtt.item_id INVENTORY_ITEM_ID, gmtt.user_item_FROM xx_text_tbl gmtt WHERE gmtt.request_id = fnd_profile.VALUE ('CONC_REQUEST_ID')]]></sqlStatement> <sqlStatement name="Q_SUPPLIER" dataSourceRef=""><![CDATA[select pov.vendor_name SUPPLIER_NAME from mtl_kanban_cards mkc, po_vendors pov where mkc.supplier_id = pov.vendor_id(+) and mkc.inventory_item_id = :INVENTORY_ITEM_ID and mkc.organization_id = NVL (:P_ORGANIZATION, mkc.organization_id) and mkc.source_type = 2]]></sqlStatement> </dataQuery>

Data Trigger: here we call any function (return type BOOLEAN) which can do some data manipulations or logical calculations before or after the report fires. We can use a package and get the input parameter values by defining the structure of the package as:
CREATE OR REPLACE PACKAGE gb_market_tracker_pkg AS P_ORGANIZATION NUMBER; P_SOURCE_TYPE NUMBER; FUNCTION beforereport RETURN BOOLEAN; END gb_market_tracker_pkg; /

Usually for Outbound interface if we are not able to fetch the data in unique SQL queries then we may use the beforeReport Trigger PL/SQL option to get the data, manipulate it and then we may insert it to a custom table. Then in Data Template SQL Statement we may fetch the processed data from the custom table with request_id. If we are to use Report delivery options like email, print, fax etc using bursting then we have to use the below code in afterReport Trigger:
function AfterReport return boolean is req_id number; begin --- calling Bursting Control req_id := fnd_request.submit_request('XDO','XDOBURSTREP','','',FALSE, :P_CONC_REQUEST_ID,'Y', chr(0),'','','','','','','', '','','','','','','','','','', '','','','','','','','','','', '','','','','','','','','','',

'','','','','','','','','','', '','','','','','','','','','', '','','','','','','','','','', '','','','','','','','','','', '','','','','','','','','','', '','','','','','','','','',''); if req_id = 0 then fnd_file.put_line (fnd_file.LOG, 'Failed to submit Bursting Program'); end if; return (TRUE); end;

In the Data Template the report Triggers are called using the below syntax:
<dataTrigger name="beforeReportTrigger" source="XX_TEST_PKG.BEFOREREPORT" />

Group: this section defines the structure of the data we want to see from a source query and contains: Element: the reference to the column in a specific query. These also have a name for the resulting XML element and we may include functions here. Example:
<dataStructure> <group name="G_KANBAN" source="Q_MAIN" groupFilter=""> <element name="ITEM" datatype="varchar2" value="ITEM" /> <group name="G_SUPPLIER" source="Q_SUPPLIER" groupFilter=""> <element name="SUPPLIER_NAME" datatype="varchar2" value="SUPPLIER_NAME" /> </group> </group> </dataStructure>

A Simple Data Template File may have the following structure:

D Da efin Tr ta e igg er

Define Data Structure/ Grouping

Define Data Query

Define Parameters Define Properties

You might also like