废话:
有一段时间没搞过开发了,做项目又要重新找回点开发的记忆。重新拾回一点点零碎。
跑多了产线,配置的一些参数也忘记得差不多了,长时间没动就是易遗忘,找点资料做个笔记就是时间保镖。
正题:
FND_REQUEST.SUBMIT_REQUEST 函数是用来提交一个请求的,它返回一个NUMBER值.具体调用如下
:result := fnd_request.submit_request(application CHAR, --模快
program CHAR, --应用程式
description CHAR, --请求说明(可选)
start_time CHAR, --RUN 时间(可选)
sub_request BOOLEAN, --立刻提交请求
argument1 CHAR, --参数1
argument2 CHAR, --参数2
argument3 CHAR, --参数3
argument4 CHAR, --参数4
argument5 CHAR, --参数5.......
argument100 CHAR);
英文说明 :
Parameters are as follows:
> application - Short name of the application associated with the concurrent request to be submitted.
> program - Short name of the concurrent program (not the executable) for which the request should be submitted.
> description - Description of the request that is displayed in the Concurrent Requests form. (Optional.)
> start_time - Time at which the request should start running, formatted as HH24:MI or HH24:MI:SS (Optional.)
> sub_request - Set to TRUE if the request is submitted from another request and should be treated as a sub-request.
> argument1...100 - Arguments for the concurrent request; up to 100 arguments are permitted. If submitted from Oracle Forms, you must specify all 100 arguments.
补充说明:
在用fnd_request.submit_request的时候,第五个参数用false,不要被参数名称误导;
这个函数有105个参数,前面五个定义请求本身,后面100个是传递给请求的具体参数,都是Char类型,
我们需要转换,默认值是chr(0),代表这个参数不用传递给调用的请求;
注意:
1. 在Package里面调用只需要传递需要的参数个数,因为它有默认值指示结束;
2. 在form里面则不行,要写满105个,而且我们参数结束之后要用一个chr(0)来表示结束 。
如何查Application(模块), program(程序)
有两种方法:一种是从界面上去查,第二种通过SQL去查。
方法一:
首先你需得先知道要执行哪支程序(名称)。查到后你可以看到有:简称,应用产品。简称就是Request中的Program项的值。
然后依据对应的“应用产品”名称,到“注册”中去查找,会发现有个简称,而这个“简称”就是Request对应的Application的值。
方法二:
SELECT DISTINCT
fa.APPLICATION_SHORT_NAME,
fa.BASEPATH,
fat.APPLICATION_NAME,
fe.EXECUTABLE_NAME,
fe.EXECUTION_FILE_NAME,
fcp.CONCURRENT_PROGRAM_NAME,
fcp.OUTPUT_FILE_TYPE,
fcp.OUTPUT_PRINT_STYLE,
fcpT.USER_CONCURRENT_PROGRAM_NAME,
fcpT.LANGUAGE,
fcpT.DESCRIPTION
FROM fnd_application_tl fat,
fnd_application fa,
fnd_concurrent_programs_tl fcpt,
fnd_concurrent_programs fcp,
fnd_executables fe
WHERE 1 = 1
AND fat.APPLICATION_ID = fa.APPLICATION_ID
AND fat.LANGUAGE = fcpt.LANGUAGE
AND fa.APPLICATION_ID = fcp.APPLICATION_ID
AND fcpt.LANGUAGE = 'ZHS'
AND fcpt.CONCURRENT_PROGRAM_ID = fcp.CONCURRENT_PROGRAM_ID
AND fcp.executable_id = fe.executable_id
--AND fcp.enabled_flag = 'Y'
AND fe.EXECUTABLE_NAME = 'RVCTP' -- 要查询的报表简称
在FORM里提交REQUEST(模板)
在Form里面,可以用APPS.FND_REQUEST.SUBMIT_REQUEST
提交一个Request到Oracle Request Manager。
如果提交成功,该函数返回Request ID,否则,返回0。
初始化
在提交一个Request之前,我们会调用Oracle Standard的Procedure对这个Request做一些基本的参数的初始化。
APPS.FND_GLOBAL.apps_initialize
user_id =>APPS.FND_GLOBAL.user_id,
resp_id =>APPS.FND_GLOBAL.resp_id,
resp_appl_id =>APPS.FND_GLOBAL.resp_appl_id
);
FND_REQUEST.SUBMIT_REQUEST
函数APPS.FND_REQUEST.SUBMIT_REQUEST有105个参数:
APPS.FND_REQUEST.SUBMIT_REQUEST
(
APPLICATION IN VARCHAR2 DEFAULT NULL,
PROGRAM IN VARCHAR2 DEFAULT NULL,
DESCRIPTION IN VARCHAR2 DEFAULT NULL,
START_TIME IN VARCHAR2 DEFAULT NULL,
SUB_REQUEST IN BOOLEAN DEFAULT FALSE,
chr(0),'','','','','','','','','','','','','','','','','','','',
'','','','','','','','','','', '','','','','','','','','','',
'','','','','','','','','','', '','','','','','','','','','',
'','','','','','','','','','', '','','','','','','','','','',
'','','','','','','','','','', '','','','','','','','','',''
)
RETURN NUMBER;
例子
PROCEDURE SUBMIT_REQUEST(p_group_id number) IS
v_request_id number;
v_org_id number;
BEGIN
FND_GLOBAL.APPS_INITIALIZE(FND_GLOBAL.USER_ID,
FND_GLOBAL.RESP_ID,
FND_GLOBAL.RESP_APPL_ID);
select OPERATING_UNIT
into v_org_id
from ORG_ORGANIZATION_DEFINITIONS
where 1=1
and organization_id = :parameter.org_id;
v_request_id := FND_request.SUBMIT_request( 'PO', 'RVCTP', '', '', false,
'BATCH', p_group_id, v_org_id, CHR(0), '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '',
'', '', '', '', '', '', '', '', '', '' );
Commit;
FND_MESSAGE.DEBUG('已提交后台程序'||':'||'Request_Id='||v_request_id);
END;
Oracle ERP等待报表运行机制
主要是用到了Fnd_concurrent.wait_for_ruqest这个function.
Fnd_concurrent.wait_for_request返回Boolean值,主要参数如下:
function FND_CONCURRENT.WAIT_FOR_REQUEST
(request_id IN number default NULL, --请求ID
interval IN number default 60, --检查时间间隔
max_wait IN number default 0, --最大等待时间
phase OUT varchar2,
status OUT varchar2,
dev_phase OUT varchar2, --请求运行阶段
dev_status OUT varchar2, --各个阶段状态
message OUT varchar2 --运行完成后输出信息)
return boolean;
dev_phase有Pending,Running,Complete,Inactive等几种,每种对应不同的Dev-Status,比如Complete阶段后就有Normal,Error,Warning,Cancelled,Terminated等几种状态。
例如:
BEGIN
l_request_status := fnd_concurrent.wait_for_request(l_request_id,
5,
0,
l_phase,
l_status,
l_dev_phase,
l_dev_status,
l_message);
IF l_request_status THEN
IF l_dev_status = 'NORMAL' THEN
NULL;
ELSE
fnd_message.debug ('请求运行不成功:' || l_dev_status);
RETURN;
END IF;
ELSE
fnd_message.debug ('请求未完成,无法查看报表内容!');
RETURN;
END IF;
editor_pkg.report (l_request_id, 'Y');
END;
总结:FND_REQUEST.SUBMIT_REQUEST是一种通过后台方式提交请教的方法,可以在pkg和 form中使用,在form中使用要将参数写全。 FND_CONCURRENT.WAIT_FOR_REQUEST是一个等待当前请求运行完毕的程序,可以利用这个等待当前的请求程序运行完毕再运行下面的程序。
有时候提交请求一直会返回0的情况:
检查是否有初始化环境:
-- 在PLSQL中设定初始的方法
SELECT user_id
INTO l_num_user_id
FROM applsys.fnd_user
WHERE user_name ='user_name';
SELECT responsibility_id
INTO l_num_resp_id
FROM apps.fnd_responsibility_vl
WHERE responsibility_name ='responsibility_name';
SELECT application_id
INTO l_num_resp_appl_id
FROM applsys.fnd_application
WHERE application_short_name = 'app_short_name';
fnd_global.apps_initialize (user_id => l_num_user_id,
resp_id => l_num_resp_id,
resp_appl_id => l_num_resp_appl_id
);
-- 在Form设定初始的方法
-- 可直接引用全局变量
FND_GLOBAL.APPS_INITIALIZE(FND_GLOBAL.USER_ID,
FND_GLOBAL.RESP_ID,
FND_GLOBAL.RESP_APPL_ID);
转载请注明出处:
未经允许不得转载:lxfamn » Oracle Submit Request – 请求的调用方法: FND_REQUEST.SUBMIT_REQUEST