[Home] [Help]
PACKAGE BODY: APPS.EAM_PM_CONCURRENT_REQUESTS
Source
1 PACKAGE BODY EAM_PM_CONCURRENT_REQUESTS AS
2 /* $Header: EAMPMCRB.pls 120.2 2006/03/16 02:33:03 kmurthy noship $ */
3
4 procedure generate_pm_schedules(
5 errbuf out NOCOPY varchar2,
6 retcode out NOCOPY varchar2,
7 p_start_date in varchar2,
8 p_end_date in varchar2,
9 p_org_id in number,
10 p_user_id in number,
11 p_location_id in number,
12 p_category_structure_id in number,
13 p_category_id in number,
14 p_owning_dept_id in number,
15 p_item_type_name in varchar2,
16 p_item_type in number,
17 p_inventory_item_name in varchar2,
18 p_asset_group_id in number,
19 p_asset_number in varchar2,
20 p_set_name in varchar2,
21 p_set_name_id in number,
22 p_view_only in number,
23 p_project_number in varchar2,
24 p_project_id in number,
25 p_task_number in varchar2,
26 p_task_id in number,
27 p_parent_wo in varchar2,
28 p_parent_wo_id in number) is
29 x_group_id number;
30 x_req_id number;
31 x_count number := null;
32 x_return_status varchar2(1);
33 x_msg varchar2(3000);
34 x_forecast_id number;
35 l_project_control_level number;
36 proj_val exception;
37
38 cursor sugg_c is
39 select pm_forecast_id
40 from eam_forecasted_work_orders
41 where group_id = x_group_id;
42
43 begin
44
45 --Validation for Project
46
47 if p_project_id is not null OR p_project_number is not null then
48 select project_control_level into l_project_control_level
49 from pjm_org_parameters where organization_id = p_org_id;
50
51 if l_project_control_level = 2 then
52 -- project control is at task level
53 -- task is mandatory
54 if p_task_number is null AND p_task_id is null then
55 --FND_MESSAGE.SET_NAME ('EAM', 'EAM_PROJ_TSK_REQD');
56 --FND_MSG_PUB.ADD;
57 --RAISE FND_API.G_EXC_ERROR;
58 RAISE proj_val;
59 end if;
60 end if;
61 end if;
62
63
64 retcode := '0';
65
66 select wip_job_schedule_interface_s.nextval
67 into x_group_id
68 from dual;
69
70 eam_pm_engine.run_pm_scheduler(1, -- create mode
71 'N', -- excludes non scheduled pm
72 fnd_date.canonical_to_date(p_start_date),
73 fnd_date.canonical_to_date(p_end_date),
74 x_group_id,
75 p_org_id,
76 p_user_id,
77 p_location_id,
78 p_category_id,
79 p_owning_dept_id,
80 p_item_type,
81 p_asset_group_id,
82 p_asset_number,
83 p_set_name_id );
84
85 --added for p_view_only, if it is yes, then don't perform the real action
86 --1 is Yes
87 if ( p_view_only = 1) then
88 return;
89 end if;
90
91 open sugg_c;
92 fetch sugg_c into x_forecast_id;
93 if ( sugg_c%NOTFOUND ) then
94 close sugg_c;
95 return;
96 end if;
97
98 LOOP
99 eam_wb_utils.add_forecast(x_forecast_id);
100 fetch sugg_c into x_forecast_id;
101 EXIT WHEN ( sugg_c%NOTFOUND );
102 END LOOP;
103 close sugg_c;
104
105
106 eam_wb_utils.convert_work_orders2(x_group_id,
107 p_project_id, p_task_id, p_parent_wo_id,
108 x_return_status, x_msg);
109 commit;
110
111 exception
112 when proj_val then
113 retcode := '2';
114 errbuf := 'Specified project has control at task level. The task is required for further processing.';
115 fnd_file.put_line(FND_FILE.LOG, 'Exception: ' || errbuf);
116 when others then
117 retcode := '2';
118 errbuf := 'PM Schedule Engine: ORA-' || -sqlcode;
119 fnd_file.put_line(FND_FILE.LOG, 'Exception' || errbuf);
120 end generate_pm_schedules;
121
122
123 procedure convert_forecast_work_orders(
124 errbuf out NOCOPY varchar2,
125 retcode out NOCOPY varchar2,
126 p_group_id in number) is
127 x_count number;
128 x_req_id number;
129 begin
130 eam_pm_utils.transfer_to_wdj(p_group_id);
131
132 select count(*) into x_count
133 from wip_job_schedule_interface
134 where group_id = p_group_id;
135
136 if ( x_count > 0 ) then
137 x_req_id := fnd_request.submit_request(
138 'WIP', 'WICMLP', NULL, NULL, FALSE,
139 to_char(p_group_id), '0', '2');
140
141 commit;
142
143 if ( x_req_id = 0 ) then
144 retcode := '2';
145 errbuf := 'Unexpected error when submitting wip mass load concurrent request';
146 end if;
147 end if;
148 exception when others then
149 retcode := '2';
150 errbuf := 'Converting Forecasted Work Orders: ORA-' || -sqlcode;
151 end convert_forecast_work_orders;
152
153 END eam_pm_concurrent_requests;
154