搜档网
当前位置:搜档网 › oracle erp报表开发开发培训教程

oracle erp报表开发开发培训教程

oracle erp报表开发开发培训教程
oracle erp报表开发开发培训教程

南京多茂科技发展有限公司Oracle ERP报表开发

培训教程

报表开发的总体步骤,及一些工具包的简单介绍 (1)

Pl/sql语法及pl/sql函数、数组、记录、游标、视图、基表、临时表、异常 (4)

HTML技术和CSS修饰 (10)

查找数据的方法及Oracle Application表命名的规律 (11)

可执行、并发程序、请求组和值集的定义 (12)

一个报表开发的实例 (15)

系统中部分表的介绍 (21)

开发分页报表(套打)的步骤 (22)

开发规范 (24)

附:记录和数组使用范例 (28)

所谓报表开发就是按照用户的需求,根据用户提供的样表,运用编程的手段,从ERP系统中取出数据展现在页面上的一个理解需求、查找数据、展现结果的过程。

目前开发报表的方法及工具有很多种,有专门针对报表需求定制的报表系统,通过对sql语句的改写能实现特别的报表需求,这样的系统有很强的针对性和限制性;还有运用报表开发工具根据用户需求临时开发报表,具有很强的灵活性和应用性。

本文档只关注运用Oracle 在DB中提供的一些开发工具包,及WEB技术开发报表的过程和方法。Oracle博大精深,如果在实际开发过程中遇到困难可以通过网上论坛和oracle网站获得技术帮助。

根据实际的开发过程,本文档从以下几个方面来说明:

一.报表开发的总体步骤,及一些工具包的简单介绍

开发步骤

1 分析客户提供的样表

2 向客户或者顾问征询报表中每个值的意思,务必理解所需开发报表的意向

3 需要客户在ERP指明数据的取处

4 自己动手在测试环境中做一遍,梳理一下流程

5 清楚报表的参数是什么

6 以包的形式组织数据,在包里面实现各种功能

7 在ERP中定义可执行,从而使ERP和DB建立联系

8 在ERP中定义并发程序,定义了报表的输出文件的类型和参数

9 在相应的请求组中加入已定义好的并发程序名称

工具包介绍

1 FND_PROFILE

Retrieve user profile values for the current run-time environment

Set user profile values for the current run-time environment

Fnd_profile.value(…ORG_ID?) 取配置文件的值

2 DBMS_OUTPUT

This package enables you to send messages from stored procedures, packages, and triggers Dbms_output.put_line 在sql window中输出结果

3 FND_GLOBAL

Fnd_global. APPS_INITIALIZE(user_id,resp_id,resp_appl_id) 模拟环境

其中user_id,resp_id,resp_appl_id可以通过这种方法获得:帮助->诊断->检查,在块中选择$PROFILES,在字段选择USER_ID可以获得USER_ID,同样方法可以获得RESP_ID,RESP_APPL_ID(可能有时你需要在Oracle Applications环境外运行一些PL/SQL语句,但是这些语句中需要访问系统相关的环境变量,例如view,这样你可以使用上述方法达到你的目的)

Fnd_global. User_name 得到当前用户的名称

Fnd_global. User_id 得到当前用户的id

4 UTL_FILE

The UTL_FILE package lets your PL/SQL programs read and write operating system (OS) text files.

It provides a restricted version of standard OS stream file input/output (I/O). The file I/O capabilities are similar to those of the standard operating system stream file I/O (OPEN, GET, PUT, CLOSE), with some limitations.

For example, call the FOPEN function to return a file handle, which you then use in subsequent calls to GET_LINE or PUT to perform stream I/O to a file. When you are done performing I/O on the file, call FCLOSE to complete any output and to free any resources associated with the file.

UTL_FILE.FILE_TYPE 定义文件指针

utl_file.put_line( , ) Writes a line to a file向文件中写数据

utl_file.fclose_all Closes all open file handles关闭所有已打开的文件指针

5 FJ_FUNC

客户化的函数包,定义了一些在实际开发过程中用到一些方法和变量

在实际开发过程中,如果需要一些方法时可以在这个包中查找,如果通用性比较强的过程也可以加到这个包里

详细可以参阅这个包

6 FJ_OUTPUT

客户化的报表格式生成包,封装了html语法

详细可以参阅这个包

二.Pl/sql语法及pl/sql函数、数组、记录、游标、视图、基表、临时表、异常、

Pl/sql基本元素的使用

Select

The SELECT statement allows you to retrieve records from one or more tables in your database.

The syntax for the SELECT statement is:

SELECT columns FROM tables WHERE predicates

Distinct

The DISTINCT clause allows you to remove duplicates from the result set. The DISTINCT clause can only be used with select statements

The syntax for the DISTINCT clause is:

SELECT DISTINCT columns

FROM tables WHERE predicates

EXISTS

The EXISTS condition is considered "to be met" if the subquery returns at least one row

The EXISTS condition can be used in any valid SQL statement - select, insert, update, or delete.

Example #1

The following is an SQL statement that uses the EXISTS condition:

SELECT * FROM suppliers

WHERE EXISTS

(select * from orders where suppliers.supplier_id = orders.supplier_id);

This select statement will return all records from the suppliers table where there is at least one record in the orders tableith the same supplier_id.

Example #2 - NOT EXISTS

The EXISTS condition can also be combined with the NOT operator.

For example,

SELECT * FROM suppliers

WHERE not exists (select * from orders Where suppliers.supplier_id = orders.supplier_id);

This will return all records from the suppliers table where there are no records in the orders table for the given supplier_id

In

The IN function helps reduce the need to use multiple OR conditions

T he IN function can be used in any valid SQL statement - select, insert, update, or delete.

Example #1

SELECT *

FROM supplier

WHERE supplier_name in ( 'IBM' , 'Hewlett Packard', 'Microsoft');

This would return all rows where the supplier_name is either IBM, Hewlett Packard, or Microsoft.

Because the * is used in the select, all fields from the supplier table would appear in the result set.

Example #2 "NOT IN"

The IN function can also be combined with the NOT operator.

For example,

SELECT *

FROM supplier

WHERE supplier_name not in ( 'IBM' , 'Hewlett Packard', 'Microsoft');

This would return all rows where the supplier_name is neither IBM, Hewlett Packard, or Microsoft. Sometimes, it is more efficient to list the values that you do not want, as opposed to the values that you do want.

Like

T he LIKE condition allows you to use wildcards in the where clause of an SQL statement. This allows you to perform pattern matching. The LIKE condition can be used in any valid SQL statement - select, insert, update, or delete.

The patterns that you can choose from are:

% allows you to match any string of any length (including zero length)

_ allows you to match on a single character

SELECT * FROM supplier WHERE supplier_name like 'Hew%';

SELECT * FROM supplier WHERE supplier_name like '%bob%';

SELECT * FROM supplier WHERE supplier_name not like 'T%';

SELECT * FROM supplier WHERE supplier_name like 'Sm_th'

GROUP BY

The GROUP BY clause can be used in a SELECT statement to collect data across multiple records and group the results by one or more columns.

The syntax for the GROUP BY clause is:

SELECT column1, column2, ... column_n, aggregate_function (expression)

FROM tables

WHERE predicates

GROUP BY column1, column2, ... column_n;

aggregate_function can be a function such as SUM, COUNT, MIN, or MAX.

Example using the SUM function

For example, you could also use the SUM function to return the name of the department and the total sales (in the associated department).

SELECT department, SUM (sales) as "Total sales"

FROM order_details

GROUP BY department;

Because you have listed one column in your SELECT statement that is not encapsulated in the SUM function, you must use a GROUP BY clause. The department field must, therefore, be listed

Having

The HAVING clause is used in combination with the GROUP BY clause. It can be used in a SELECT statement to filter the records that a GROUP BY returns.

The syntax for the HAVING clause is:

SELECT column1, column2, ... column_n, aggregate_function (expression)

FROM tables WHERE predicates GROUP BY column1, column2, ... column_n

HAVING condition1 ... condition_n;

aggregate_function can be a function such as SUM, COUNT, MIN, or MAX.

Example using the SUM function

For example, you could also use the SUM function to return the name of the department and the total sales (in the associated department). The HAVING clause will filter the results so that only departments with sales greater than $1000 will be returned.

SELECT department, SUM (sales) as "Total sales"

FROM order_details GROUP BY department HAVING SUM (sales) > 1000

ORDER BY

The ORDER BY clause allows you to sort the records in your result set. The ORDER BY clause can only be used in SELECT statements.

The syntax for the ORDER BY clause is:

SELECT columns FROM tables

WHERE predicates ORDER BY column ASC/DESC;

The ORDER BY clause sorts the result set based on the columns specified. If the ASC or DESC value is omitted, the system assumed ascending order.

ASC indicates ascending order. (default)

DESC indicates descending order.

Example #1

SELECT supplier_city FROM supplier WHERE supplier_name = 'IBM' ORDER BY supplier_city;

This would return all records sorted by the supplier_city field in ascending order.

Example #2

SELECT supplier_city FROM supplier WHERE supplier_name = 'IBM' ORDER BY supplier_city DESC;

This would return all records sorted by the supplier_city field in descending order.

UNION

The UNION query allows you to combine the result sets of 2 or more "select" queries. It removes duplicate rows between the various "select" statements.

Each SQL statement within the UNION query must have the same number of fields in the result sets with similar data types.

The syntax for a UNION query is:

select field1, field2, field_n from tables

UNION

select field1, field2, field_n from tables

UNION ALL

The UNION ALL query allows you to combine the result sets of 2 or more "select" queries.

Each SQL statement within the UNION ALL query must have the same number of fields in the result sets with similar data types.

The syntax for a UNION ALL query is:

select field1, field2, field_n from tables

UNION ALL

select field1, field2, field_n from tables;

UPDATE

The UPDATE statement allows you to update a single record or multiple records in a table.

The syntax the UPDATE statement is:

UPDATE table SET column = expression WHERE predicates

INSERT

The INSERT statement allows you to insert a single record or multiple records into a table.

The syntax for the INSERT statement is:

INSERT INTO table(column-1, column-2, ... column-n)

VALUES(value-1, value-2, ... value-n)

DELETE

The DELETE statement allows you to delete a single record or multiple records from a table The syntax for the DELETE statement is:

DELETE FROM table WHERE predicates

pl/sql函数

substr (string, start_position, [length])

This function allows you to extract a substring from a string

For Example:

substr ('This is a test', 6, 2) would return 'is'

substr ('This is a test', 6) would return 'is a test'

substr ('Tech on the Net', 1, 4) would return 'Tech'

decode( expression , search , result [, search , result]... [, default] )

This function has the functionality of an IF-THEN-ELSE statement

For Example:

SELECT supplier_name,decode (supplier_id, 10000,'IBM',

10001, 'Microsoft',10002, 'Hewlett Packard', 'Gateway') result

FROM suppliers

instr(string1, string2, [start_position], [nth_appearance])

This function returns the location of a substring in a string

For example:

instr ('Tech on the net', 'e') would return 2; the first occurrence of 'e'

instr ('Tech on the net', 'e', 1, 1) would return 2; the first occurrence of 'e'

instr ('Tech on the net', 'e', 1, 2) would return 11; the second occurrence of 'e'

instr ('Tech on the net', 'e', 1, 3) would return 14; the third occurrence of 'e'

Trim(text)

This function removes leading and trailing spaces from a string For example

Trim (" Tech on the Net") would return "Tech on the Net"

Trim (" Alphabet ") would return "Alphabet"

RTrim (text)

This function removes trailing spaces from a string

For example:

RTrim ("Tech on the Net ") would return "Tech on the Net"

RTrim (" Alphabet ") would return " Alphabet"

LTrim (text)

This function removes leading spaces from a string For example:

LTrim (" Tech on the Net") would return "Tech on the Net"

LTrim (" Alphabet ") would return "Alphabet "

to_number (string1, [format_mask], [nls_language] )

This function converts a string to a number

For example:

to_number ('1210.73', '9999.99') would return the number 1210.73 to_number ('546', '999') would return the number 546

to_number ('23', '99') would return the number 23

to_char (value, [format_mask], [nls_language] )

This function converts a number or date to a string

Examples - Numbers

The following are number examples for the to_char function.

to_char (1210.73, '9999.9') would return '1210.7'

to_char (1210.73, '9,999.99') would return '1,210.73'

to_char (1210.73, '$9,999.00') would return '$1,210.73'

to_char (21, '000099') would return '000021'

The following are date examples for the to_char function.

to_char (sysdate, 'yyyy/mm/dd'); would return '2003/07/09'

to_char (sysdate, 'Month DD, YYYY'); would return 'July 09, 2003' to_char (sysdate, 'FMMonth DD, YYYY'); would return 'July 9, 2003' to_char (sysdate, 'MON DDth, YYYY'); would return 'JUL 09TH, 2003' to_char (sysdate, 'FMMON DDth, YYYY'); would return 'JUL 9TH, 2003' to_char (sysdate, 'FMMon ddth, YYYY'); would return 'Jul 9th, 2003'

to_date (string1, [format_mask], [nls_language] )

This function converts a string to a date、nvl

to_date ('2003/07/09', 'yyyy/mm/dd'); would return a date value of July 9, 2003.

to_date ('070903', 'MMDDYY'); would return a date value of July 9, 2003.

to_date ('20020315', 'yyyymmdd'); would return a date value of Mar 15, 2002

nvl (string1, replace_with )

This function lets you substitutes a value when a null value is encountered

Example #1:

select NVL (supplier_city, 'n/a') from suppliers

***************************************************************************************** 数组的定义

Type NumArray Is Table Of Number Index By Binary_Integer

Type StrArray Is Table Of Varchar2(500) Index By Binary_Integer

记录的定义

Type rp_tb_type Is Record

(TbBorder Varchar2(10),

TbCss Boolean,

TdCss Boolean

)

游标的定义

Cursor cur_line Is

Select tb.Month, tb.loct_onhand

From fj_rp_opm003_tmp_tb tb

Where tb.item_no = row_head.item_no;

row_line cur_line%Rowtype;

视图的定义

视图是一个虚拟的、不是物理存在的表,他是通过sql语句把一个或多个表连接在一起形成的.

Create or replace view ic_item_v As

Select * from ic_item_mst_b

基表

是一个物理存在的表,能以表格的形式存储数据,是数据的载体

Create table table_name

(col1 varchar2(100),col2 varchar2(10))

临时表

1 会话特有的临时表

CREATE GLOBAL TEMPORARY ( )

ON COMMIT PRESERVE ROWS;

2 事务特有的临时表

CREATE GLOBAL TEMPORARY ( )

ON COMMIT DELETE ROWS;

CREATE GLOBAL TEMPORARY TABLE MyTempTable

--ON COMMIT DELETE ROWS 说明临时表是事务指定,每次提交后ORACLE将截断表(删除全部行)

--ON COMMIT PRESERVE ROWS 说明临时表是会话指定,当中断会话时ORACLE将截断表

异常

PL/SQL处理异常不同于其他程序语言的错误管理方法,PL/SQL的异常处理机制与ADA很相似,有一个处理错误的全包含方法。当发生错误时,程序无条件转到异常处理部分,这就要求代码要非常干净并把错误处理部分和程序的其它部分分开。oracle允许声明其他异常条件类型以扩展错误/异常处理。这种扩展使PL/SQL的异常处理非常灵活。

当一个运行时错误发生时,称为一个异常被抛出。PL/SQL程序编译时的错误不是能被处理得异常,只有在运行时的异常能被处理。在PL/SQL程序设计中异常的抛出和处理是非常重要的内容。由三种方式抛出异常

. 通过PL/SQL运行时引擎

. 使用RAISE语句

. 调用RAISE_APPLICATION_ERROR存储过程

当数据库或PL/SQL在运行时发生错误时,一个异常被PL/SQL运行时引擎自动抛出。异常也可以通过RAISE语句抛出RAISE exception_name;

三.HTML技术和CSS修饰

HTML技术

HTML英语意思是:Hypertext Marked Language,即超文本标记语言,是一种用来制作超文本文档的简单标记语言。

用HTML编写的超文本文档称为HTML文档,它能独立于各种操作系统平台(如UNIX,WINDOWS等)。

1 HTML的基本结构

超文本文档分文档头和文档体两部分,在文档头里,对这个文档进行了一些必要的定义,文档体中才是要显示的各种文档信息。

头部信息

文档主体,正文部分

其中在最外层,表示这对标记间的内容是HTML文档。我们还会看到一些Hompage省略标记,因为.html 或.htm 文件被Web浏览器默认为是HTML文档。 之间包括文档的头部信息,如文档总标题等,若不需头部信息则可省略此标记。 标记一般不省略,表示正文内容的开始。

2 在报表的实际过程中,最重要的是针对标记table的应用,

表格的基本结构

...
定义表格

...定义标题

定义表行

定义表头

定义表元(表格的具体数据)

表中数据左右排列方式通过align属性来定义left、right、center

表中数据上下排列方式通过valign属性来定义top、middle、bottom

3 跨多行、多列的表元

中要跨越的行或列的个数。

跨多列的表元

colspan表示跨越的列数,例如colspan=2表示这一格的宽度为两个列的宽度。

跨多行的表元

rowspan所要表示的意义是指跨越的行数,例如rowspan=2就表示这一格跨越表格两个行的高度

4 插入图象的标签是,其格式为:

SRC属性指明了所要链接的图象文件地址,这个图形文件可以是本地机器上的图形,也可以是位于远端主机上的图形。

地址的表示方法可以沿用上一篇内容“文件的链接”中URL地址表示方法。

例:

IMG还有两个属性是HEIGHT和WIDTH,分别表示图形的高和宽。通过这两个属性,可以改变图形的大小,如果没有

设置,图形按原大显示

CSS修饰

CSS是Cascading Style Sheets(层叠样式表单)的简称。更多的人把它称作样式表。顾名思义,它是一种设计网页样式的工具

实际上CSS的代码都是由一些最基本的语句构成的。它的基本语句的结构是这样的:

选择符{属性:属性值}一般说来,

四.查找数据的方法及Oracle Application表命名的规律

查找数据的方法

请参阅《在ERP系统中查找数据的方法》

Oracle Application表命名的规律

一般来说,在Applications中所有的表的命名都是相当规范,通过名字,一般都可以知道这个表是做什么用,而且还可以通过查看FND_TABLES和FND_COLUMNS来获得表的详细信息。除此之外,还有一些规则,例如以TL结尾表示带有语言信息的表,V结尾表示一般的视图,VL表示带有语言信息的视图,以V$开头代表动态性能试图,以FND开头是属于Application Object Library模块的,以AR,RA开头是属于Oracle Receivables模块的,以MTL开头是属于库存模块的,以AP开头是属于应收模块的,以GL开头是属于总帐模块的,以FA开头是属于资产模块的,以OE 开头的是属于订单模块的,以WSH开头是属于发运模块的,以WIP开头是属于在制车间模块的,以IBE开头是属于网上商店的,etc;

而且根据主从表的关系,Application表之间还有一定的对应关系,在应用中有好多类似订单头和订单行的表,例如销售订单(oe_order_headers_all 和 oe_order_lines_all)、采购订单(po_headers_all 和 po_lines_all)、请购单(po_requisition_headers_all 和 po_requisition_lines_all)等等,主从表之间的连接一般是根据Id。

_all,基表,保存多组织数据,里面有一个Org_Id字段,一般不直接出现在我们的DML中

去掉_all的视图,根据用户环境过滤掉组织,相当于普通的基表,我们直接使用它,就当它是基表

_v,视图,给Form用

_kfv,启用关键性弹性域的时候动态生成的视图,包含Concact过的字段组合

_dfv,启用描述性弹性域的时候动态生成的视图,我们取弹性域子段的描述的时候,需要用用户出口函数。。。。。。。。。。。

_tl,基表,有language字段,us肯定有,其他的看安装

_vl,视图,根据环境设置过滤语种,所以做报表用_vl

_s,序列号

_API,Package,保证向后兼容

_PKG,Package,Program

_SV,Package,供Form调用

五.可执行、并发程序、请求组和值集的定义

可执行、并发程序、请求组

1. 定义可执行并发程序;

菜单:系统管理员/并发/方案/可执行

把客户化的可执行程序记录到系统中去,在这一步中,主要是说明定义并发程序的所在应用产品,执行方法,执行文件名信息.

执行文件名处输入:开发包名.主要方法名

2.定义并发程序

菜单:系统管理员/并发/方案/定义

在定义了可执行并发程序后,就要在此基础上定义具体的并发请求来执行这个并发程序.在这个步骤中,指定并发请求的请求名称,使用到的参数信息,是否是必选等等.

在这个定义界面中,关键的是值集的使用,如果数据是一个特定的集合,可以通过定义值集的方式来确定,值集的定义方法不在此介绍了.

3.增加到报表组

菜单:系统管理员/安全性/责任/请求

并发请求定义好以后,用户是无法直接调用的,是通过职责作为桥梁,通过请求组来调用的.这就要求将不同的并发请求放到不同的请求组中.

值集的定义

在定义报表参数时用到的值集主要分两种:table类型的值集和独立值集

1 table类型的值集:在值集定义页面输入值集的名称,输入值集的说明,在最大尺寸处输入所包含值的大约最大宽度,值

验证类型选择表,然后点击编辑信息进入验证表信息窗体

2 选择表应用,也可以不输入,一般是所建立的值集输入在哪个模块而选择相应的应用,在表名处输入值集数据的表或视图,其中有三个字段其中value和Id都为值,Id的优先级高于Value,但一般我们只定义Value,类型一般选择“可变字符2”,大小输入字段的大约的最大值;在出处/排序依据处输入要限定和排序依据。

关联子集定义的语法为where field_name = $FLEX$. value_set_name;当然要求两个子集都在参数里面

2 独立值集:像定义Table类型的值集一样输入值集信息,只不过在值验证处选择独立

然后,进入独立值集值定义窗口,在名称处输入刚才定义的值集名称,然后点击查找按钮,进入值定义窗口

在值定义窗口,输入值,及相应的说明性文字

六.一个报表开发的实例

假设以开发一个“请购单”报表为例,表样如下:

请购单

参数:请购单号

1 通过分析报表及咨询顾问和客户,可以知道报表显示的是请购单的部分明细信息

路径:在职责FHSZ PO Super User ――》申请――》申请

在ERP界面如下可以找到数据的出处:

然后把光标定位与行上,点击菜单的“帮助”,进入路径:帮助――》诊断——》检查,在对话框中block中输入system,在field中输入last_query,然后把光标移到value中,系统会自动给出一段sql语句

然后把sql语句拷到sql window中找到from后的视图(表)是PO_REQUISITION_LINES_V,然后点击右键,选择Edit,又找到视图(表)Po_Requisition_Lines,然后再点击右键,选择Edit,找到基表Po_Requisition_Lines_All,看表名,可以知道是一个行表,根据以上的介绍,可以找到头表应为,Po_Requisition_headers_All。两个表之间应该通过%header_id等类似Id字段来连接。经测试两者的连接应为Select prh.*

From Po_Requisition_Lines_All prl

,Po_Requisition_headers_All prh

Where prh.requisition_header_id = prl.requisition_header_id

然后查找当前的请购单信息,再进入检查窗体,在feild在中输入requisition_header_id,得到requisition_header_id应该为8335,

然后带入sql语句中,最后通过和ERP做比较,得到以下正确的sql语句:

Select prh.segment1

, prl.item_description

, prl.unit_meas_lookup_code

, prl.quantity

From Po_Requisition_Lines_All prl

,Po_Requisition_headers_All prh

Where prh.requisition_header_id = prl.requisition_header_id

And prh.requisition_header_id = 8335

2 建立一个临时表用于存储数据

Create Global Temporary Table fh_po_requi_temp_tb

(

po_r_num Varchar2(20),

item_dsc Varchar2(100),

uom Varchar2(10),

quantity Number

)

On Commit Delete Rows;

3 建立包,用于生成报表

所建立的包遵从与作者的以往开发习惯

在pl/sql developer中新建立一个包,包名为:FH_RP_PO001,Purpose:请购单

然后从别的PKG中复制包头,修改用与要开发的包适合,然后把包体复制到FH_RP_PO001,

修改insert_table过程,

接着修改游标:

最后修改包的执行体(begin ―― end)

包头代码为:

create or replace package FH_RP_PO001 is

-- Author : LI.SR

-- Created : 2005-3-2 9:53:42

-- Purpose :请购单

rp_title Varchar2(100) := '请购单'; --报表标题

rp_id Varchar2(20) := '( FH_RP_PO001 )'; --报表系统编号

p Varchar2(10) := Null; --备用空值变量?

tb_outer fj_output.rp_tb_type; --外表格的属性

tb_inner fj_output.rp_tb_type; --内表格的属性 rp_style FJ_FUNC.StrArray; --样式数组,定义报表的样式 rp_blank Varchar2(100) := get_space(1);

arr_body Fj_Func.StrArray;

arr_end Fj_func.strarray;

procedure main_proc (

ERRBUF OUT VARCHAR2,

RETCODE OUT Number,

acNo In Varchar2 --请购单号

end FH_RP_PO001;

包体代码为:

create or replace package body FH_RP_PO001 is

procedure main_proc (

ERRBUF OUT VARCHAR2,

RETCODE OUT Number,

acNo In Varchar2 --请购单号

)

Is

----------------------------------游标定义区域--------------------------------

Cursor cur_head Is

Select tb.*

From fh_po_requi_temp_tb tb

Order By tb.segment1;

row_head cur_head%Rowtype;

----------------------------------方法定义区域--------------------------------

/****************************************************************************

* 定义了报表的一些基本参数每张报表基本有两个table嵌套而成,分为外表格和内表格

****************************************************************************/

Procedure init_rep_type

Is

Begin

---------定义具体TB/TD Css修饰-------------

rp_style(1) := '0,800,0,False,False'; --外表边线为/外表宽度/单元格内容与边线的距离/表的外边

线是否css修饰/表的格子是否css修饰

rp_style(2) := '1,100%,4,True,True'; --外表边线为/外表宽度/单元格内容与边线的距离/表的外边

线是否css修饰/表的格子是否css修饰

rp_style(3) := 'style="font-size:12pt;font-weight:bold;" colspan="2"';

rp_style(4) := 'style="font-size:24pt;text-align:center;font-weight:bold;"';

rp_style(5) := 'style="text-align:center;" colspan="3"';

rp_style(8) := 'style="text-align:center;"';

-------定义报表的标题及表格格式初始化------

fj_output.rp_td_align := 'right';

fj_output.rp_title := rp_title || rp_id; -- 生成的报表WEB页面的标题

fj_output.init_rp_tb_para(rp_style(1),tb_outer); -- 初始化报表的外表格

fj_output.init_rp_tb_para(rp_style(2),tb_inner); -- 初始化报表的内表格

End init_rep_type;

Procedure insert_table

Is

Begin

Insert Into fh_po_requi_temp_tb

Select prh.segment1

, prl.item_description

, prl.unit_meas_lookup_code

From Po_Requisition_Lines_All prl

, Po_Requisition_headers_All prh

Where prh.requisition_header_id = prl.requisition_header_id

And prh.segment1 = nvl(acNo,prh.segment1) ;

End insert_table;

------------------------------------------------------------------------------------ Begin

fj_Func.initArr(rp_body,1,10);

fj_Func.initArr(rp_end,1,5);

init_rep_type;

insert_table;

fj_output.put_html_begin;

fj_output.put_tb_begin(tb_outer);

fj_output.put_td(1,'100%',rp_blank,rp_style(6),tb_outer);

fj_output.put_td(0,'35%',fj_func.g_fj_img,rp_style(5),tb_outer);

fj_output.put_td(9,'30%',rp_title,rp_style(4),tb_outer);

fj_output.put_td(2,'35%',rp_blank,tb_outer);

fj_output.put_td(1,'100%',rp_blank,rp_style(3),tb_outer);

fj_output.put_td(0,'35%','请购单:' || acNo,rp_style(7),tb_outer);

fj_output.put_td(9,'30%',rp_blank,tb_outer);

fj_output.put_td(2,'35%',rp_blank,tb_outer);

fj_output.put_td(0,'colspan="3"',tb_outer);

------------------内表格定义-------------------

fj_output.put_tb_begin(tb_inner);

fj_output.put_td(0,'20%','请购单号',rp_style(8),tb_inner);

fj_output.put_td(9,'40%','物料说明',rp_style(8),tb_inner);

fj_output.put_td(9,'10%','单位',rp_style(8),tb_inner);

fj_output.put_td(2,'30%','数量',rp_style(8),tb_inner);

Open cur_head;

Loop

Fetch cur_head Into row_head;

Exit When cur_head%Notfound;

arr_body(1) := row_head.po_r_num;

arr_body(2) := row_head.item_dsc;

arr_body(3) := row_head.uom;

arr_body(4) := fj_func.NumToStr(row_head.quantity,'00,',2,Null);

fj_output.put_td(0,'20%',arr_body(1),rp_style(8),tb_inner);

fj_output.put_td(9,'40%',arr_body(2),'left',p,tb_inner);

fj_output.put_td(9,'10%',arr_body(2),rp_style(8),tb_inner);

fj_output.put_td(2,'30%',arr_body(4),tb_inner);

arr_end(1) := arr_end(1) + row_head.quantity;

相关主题