2014-01-09 Created By BaoXinjian

 Form_Form Builder Export导出为Excel(案例)_菜单项一、摘要


以下是关于解决EBS标准导出功能无法导出主从关系数据的方法。

解决思路:

1. 在form上增加一个导出按钮,或者在工具栏注册一个菜单项。

2. 用制作一个报表,或者模仿系统标准的导出功能。然后用上面的按钮或者菜单项直接调用。

这里主要介绍模仿系统标准导出功能


Form_Form Builder Export导出为Excel(案例)_Form Builder_02二、开发


Step1. 直接修改form级trigger EXPORT,把默认的 app_standard.event('EXPORT')注释掉。把下面的代码复制进去。

 Form_Form Builder Export导出为Excel(案例)_.net_03

Step2. 具体代码


DECLARE
--以上五个变量照搬即可
URL VARCHAR2 (2000);
DB_FILE NUMBER;
WEB_SERVER_PREFIX VARCHAR2 (255);
RES BOOLEAN;
MIME_TYPE VARCHAR2 (255);
L_ORGANZIATION_ID NUMBER;

--定义一个包含主从关系数据的CURSOR
CURSOR CSR ( V_ORGANIZATION_ID IN NUMBER)
IS
SELECT CST.COST_GROUP_CODE,
CST.COST_GROUP_DESCRIPTION,
CST.COST_GROUP_DISABLE_DATE,
CAP.CAPABILITY,
EQP.EQP_CAP_DESC DESCRIPTION,
CAP.ACTIVE
FROM CUX2_CST_COST_GROUP_ALL CST,
CUX2_CST_COST_GROUP_EQPS_ALL CAP,
CUX2_BOM_EQP_CAP_TYPE EQP
WHERE CAP.COST_GROUP_ID(+) = CST.COST_GROUP_ID
AND EQP.EQP_CAP_CODE(+) = CAP.CAPABILITY
AND EQP.ORGANIZATION_ID(+) = CAP.ORGANIZATION_ID
AND CAP.ORGANIZATION_ID(+) = CST.ORGANIZATION_ID
AND CST.ORGANIZATION_ID = V_ORGANIZATION_ID
ORDER BY CST.ORGANIZATION_ID, CST.COST_GROUP_CODE, CAP.CAPABILITY;
BEGIN
--获取Organzition_id
L_ORGANZIATION_ID := FND_PROFILE.VALUE ('MFG_ORGANIZATION_ID');
--更改鼠标式样:漏斗鼠标(忙状态)
SET_APPLICATION_PROPERTY (CURSOR_STYLE, 'BUSY');
--显示进度条窗口,并设置进度为0
APP_WINDOW.PROGRESS (0);
--创建数据包,并设置文件头类型。
DB_FILE :=
FND_GFM.FILE_CREATE (CONTENT_TYPE => 'text/html',
PROGRAM_NAME => 'export');
--输出题头行 注:chr(9) 为 tab键
FND_GFM.FILE_WRITE_LINE (
DB_FILE,'Cost Group Code'|| CHR (9)|| 'Cost Group Description'|| CHR (9)|| 'Cost Group Disable Date'|| CHR (9)
|| 'Capability'|| CHR (9)|| 'Description'|| CHR (9)|| 'Active'
);

--循环数据行
FOR R IN CSR (L_ORGANZIATION_ID)
LOOP
FND_GFM.FILE_WRITE_LINE (
DB_FILE,R.COST_GROUP_CODE|| CHR (9)|| R.COST_GROUP_DESCRIPTION|| CHR (9)|| TO_CHAR (R.COST_GROUP_DISABLE_DATE, 'YYYY-MM-DD HH24:MI:SS')
|| CHR (9)|| R.CAPABILITY|| CHR (9)|| R.DESCRIPTION|| CHR (9)|| R.ACTIVE
);
END LOOP;

--关闭数据包
DB_FILE := FND_GFM.FILE_CLOSE (DB_FILE);
--将数据包提交给客户端
URL := FND_GFM.CONSTRUCT_DOWNLOAD_URL (WEB_SERVER_PREFIX, DB_FILE, TRUE);
--DBMS_OUTPUT.PUT_LINE(URL);
--打开URL地址下载
FND_UTILITIES.OPEN_URL (URL);
--更改鼠标式样:默认指针(常规状态)
SET_APPLICATION_PROPERTY (CURSOR_STYLE, 'DEFAULT');
APP_WINDOW.PROGRESS (1); --显示进度条窗口,并设置进度为1(100%)
END;


Step3. 导出Execl

 Form_Form Builder Export导出为Excel(案例)_菜单项_04

 Step4. 导出条形图

 Form_Form Builder Export导出为Excel(案例)_.net_05

Step5.  导出的Execel

Form_Form Builder Export导出为Excel(案例)_数据_06

Thanks and Regards

参考:kawontony - http://blog.itpub.net/24627116/viewspace-754506/

参考:kawontony - http://blog.itpub.net/24627116/viewspace-754513/