Step by Step to Define a BI Publisher Report

这里演示一下,开发一个最简单BI Publisher Report的流程,下图为开发的基本流程.

Step by Step to Define a BI Publisher Report_第1张图片


Data Template(.xml) 作为Data Source,用于数据源的定义,以及取数的SQL语句;

Template(.rtf) 用于定义输出展示(Layout); (RTF:Rich Text Format)


1.首先创建一个Demo数据

CREATE TABLE demo_products
(  product_code   NUMBER,
   product_name   VARCHAR2 (100));


INSERT INTO demo_products
     VALUES (569, 'Oracle Cost Management');

INSERT INTO demo_products
     VALUES (401, 'Oracle Inventory Management');

COMMIT;

2.Define Data Template

Date Template为XML文件,基本的格式如下图

Step by Step to Define a BI Publisher Report_第2张图片

<parameters><parameter>为传入参数项

<dataQuery><sqlStatement>为Report所执行的Query语句

<dataTrigger>用于指定beforeReport或afterReport,调用那个Function/Procedure

<dataStructure>为XML输出的结构


这里创建我们的Data Template文件

<?xml version="1.0" encoding="UTF-8"?>
<dataTemplate name="demoProductsDT" description="Demo Products Details" version="1.0">
   <parameters>
     <parameter name="p_product_id" datatype="number"/>
   </parameters>
  <dataQuery>
    <sqlStatement name="DQ">
         <![CDATA[ SELECT product_code, product_name FROM demo_products
                            WHERE product_code = NVL(:p_product_id,product_code) ]]>
    </sqlStatement>
  </dataQuery>
  <dataStructure>
    <group name="G_DP" source="DQ">
      <element name="PRODUCT_CODE" value="product_code"/>
      <element name="PRODUCT_NAME" value="product_name"/>
    </group>
  </dataStructure>
</dataTemplate>
最后保存成ABC.xml

3.Create Data Definition & Associate with Data Template

XML Publisher Administrator -> Data Definitions -> Create Data Definition

Step by Step to Define a BI Publisher Report_第3张图片

这里的Code会被后边定义的Concurrent Program用到.

接下来,Data Template  'Add File',选择我们第二步定义的XML Data Template.

Step by Step to Define a BI Publisher Report_第4张图片

4.接下来切换到Application Developer职责下,定义一个新的Concurrent Program

Step by Step to Define a BI Publisher Report_第5张图片

注意:
1. Output format应该XML
2. Short Name和之前定义Data Definition中的Code完全一样

What is XDODTEXE used in the Executable section of Concurrent Program?

XDODTEXE is a BI Publisher Data Template Executable. The purpose of this executable is to identify data template file (.xml) and execute the data template to generate the raw xml data, that later can be used by BI Publisher formatting engine to format as as per the layout (RTF, PDF etc).
This executable will be used by all the BI Publisher reports (Concurrent Program) which are using Data Template to generate the xml data.

5.Concurrent Program Parameter

Step by Step to Define a BI Publisher Report_第6张图片

Note:Token is p_product_id. This is the bind parameter we have used in date template. For every bind parameter used in the data template, we have to define parameter in the concurrent program.

6.把这个新定义的Concurrent Program绑定到对应Request Group里

切换到System Admin职责,Security > Responsibility > Request,把刚定义好的Program绑定到一个Request Group里

Step by Step to Define a BI Publisher Report_第7张图片

7.运行Concurrent Program

Step by Step to Define a BI Publisher Report_第8张图片

8.Output

Step by Step to Define a BI Publisher Report_第9张图片

保存上面这个Output成XML格式,我们还需要基于这个xml output做RTF template,RTF Template为了让报表输出更友好,更灵活的展示,而不是只给用户一个XML结果。


9.下载安装XML Publisher Desktop

refer:http://blog.csdn.net/pan_tian/article/details/8283543


10.Define the RTF Template using the Generated Data XML

加载项 > 导入XML数据 导入第8步的output的xml文件

Step by Step to Define a BI Publisher Report_第10张图片

然后“插入” > “表向导”

Step by Step to Define a BI Publisher Report_第11张图片

掠过定义模板的几步,最终RTF模板文件样子大概如下,

11.Registering the Template with BI Publisher

XML Publisher Administrator -> Templates -> Create Template

Step by Step to Define a BI Publisher Report_第12张图片


12.Run the concurrent program to see the output

重新切换到Concurrent Program的定义Form上,更改输出的文件类型,然后文件输出的格式也就随之发生改变

Step by Step to Define a BI Publisher Report_第13张图片





你可能感兴趣的:(Step by Step to Define a BI Publisher Report)