declare
l_request_id number;
l_return_flag boolean;
l_num_user_id number;
l_num_resp_id number;
l_num_resp_appl_id number;
call_status BOOLEAN;
rphase VARCHAR2(80);
rstatus VARCHAR2(80);
dphase VARCHAR2(30);
dstatus VARCHAR2(30);
message VARCHAR2(240);
cursor w is
select t.so_dept_code
from cux_rao_temp t;
begin
/*初始化环境*/
SELECT user_id
INTO l_num_user_id
FROM applsys.fnd_user
WHERE user_name ='xxxxx'; -----EBS用户名
SELECT responsibility_id
INTO l_num_resp_id
FROM apps.fnd_responsibility_vl
WHERE responsibility_name ='xxxxxx'; ----职责
SELECT application_id
INTO l_num_resp_appl_id
FROM applsys.fnd_application
WHERE application_short_name = 'MFG'; ------职责对应的 应用简称
fnd_global.apps_initialize (user_id => l_num_user_id,
resp_id => l_num_resp_id,
resp_appl_id => l_num_resp_appl_id
);
/*MO_GLOBAL.SET_POLICY_CONTEXT('S','89');
FND_GLOBAL.SET_NLS_CONTEXT('AMERICAN'); --This is for Language specific view
MO_GLOBAL.INIT('INV');*/
/* l_return_flag :=fnd_request.add_layout(template_appl_name => 'CUX', ---应用简称
template_code =>'CUXWIPMAT', ---模板CODE
template_language =>'ZH',---模板定义时选择的语言
template_territory =>'CN', ---模板定义时选择的区域
output_format => 'EXCEL'---输出的格式
);*/
for a in w loop
l_request_id :=fnd_request.submit_request(application =>'WIP',---并发程序所属 应用简称
program =>'WICDCL',
description => null,
start_time => to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),
sub_request => FALSE,
argument1 => 89, ---Organization ID
argument2 => 1, ----Class Type 分类类型 1:标准离散
argument3 => null, ---From Class 自分类
argument4 => null, ---To Class 至类
argument5 => a.so_dept_code, ---From Job 自任务
argument6 => a.so_dept_code, ---To Job 至任务
argument7 => null,---From Job Release Date 起始任务发放日期
argument8 => null,---To Job Release Date 终止任务发放日期
argument9 => null,---From Job Start Date 起始任务起始日期
argument10 => null,---To Job Start Date 终止任务起始日期
argument11 => null,---From Job Completion Date 起始任务完成日期
argument12 => null,---To Job Completion Date 终止任务完成日期
argument13 => 7, ---Status 状态 7:已取消 4:已完成 5:完成-不计费
argument14 => wip_dj_close_temp_s.nextval, ---Group ID 组标识
argument15 => 1,---Select Jobs Option 选择任务选项 默认不显示参数为1
argument16 => 1,---Exclude Reserved Jobs 排除保留的任务 1:是 2:否
argument17 => 1,---Exclude Un-Completed Jobs 排除未完成的任务 1:是 2:否
argument18 => 2, ---Exclude Pending Trans Jobs 排除包含待定事务处理的任务 1:是 2:否
argument19 => 1,---Report Type 报表类型 4---汇总
/* 1 汇总
2 使用计划起始数量的明细
3 使用实际完成数量的明细
4 无报表
*/
argument20 => to_char(sysdate,'yyyy/mm/dd hh24:mi:ss')---Actual Close Date 实际关闭日期
);
commit;
----dbms_output.put_line(l_request_id);
/*检查请求运行状态*/
call_status := fnd_concurrent.wait_for_request( l_request_id, ---并发请求的id
10, ---检查时间间隔
300,---最大等待时间
rphase,
rstatus,
dphase, --请求运行阶段
dstatus,--各个阶段状态
message --运行完成后输出信息
);
IF call_status THEN
dbms_output.put_line('请求ID:'|| l_request_id || '工单号:' || a.so_dept_code || '请求状态:'|| rphase || '|' || rstatus || '|' || message);
END IF;
end loop;
EXCEPTION WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE||' Error :'||SQLERRM);
end;
##############################
通往精神的路很多,物质只是其中一种
##############################
http://www.onejava.com/article/oracle/wip/wiptop.htm
https://docs.oracle.com/cd/A60725_05/html/comnls/us/index.htm
http://www.oracle.com/technetwork/cn/developer-tools/apex/getting-started-094884-zhs.html
https://docs.oracle.com/cd/B34956_01/current/html/docset.html