[Home] [Help]
PACKAGE BODY: APPS.IEU_UWQ_DISTRIBUTE_ITEMS
Source
1 PACKAGE BODY IEU_UWQ_DISTRIBUTE_ITEMS AS
2 /* $Header: IEUTKDFB.pls 120.0.12020000.2 2013/04/02 16:39:51 rgandhi ship $ */
3
4
5 PROCEDURE DISTRIBUTE_TASKS
6 (P_RESOURCE_ID IN NUMBER,
7 P_LANGUAGE IN VARCHAR2,
8 P_SOURCE_LANG IN VARCHAR2,
9 P_NUM_OF_ITEMS IN NUMBER,
10 P_DIST_BUS_RULES IN SYSTEM.DIST_BUS_RULES_NST,
11 P_WS_INPUT_DATA IN OUT NOCOPY SYSTEM.WR_ITEM_DATA_NST,
12 X_MSG_COUNT OUT NOCOPY NUMBER,
13 X_MSG_DATA OUT NOCOPY VARCHAR2,
14 X_RETURN_STATUS OUT NOCOPY VARCHAR2) IS
15
16 l_distributed_from varchar2(100);
17 l_distributed_to varchar2(100);
18 l_dist_st_based_on_parent_flag varchar2(1);
19
20 l_grp_owner number;
21 l_group_id varchar2(1);
22 l_task_distributed_to number;
23
24 l_source_object_id number;
25 l_source_object_code varchar2(30);
26 l_distribution_status number;
27
28 l_msg_count number;
29 l_msg_data varchar2(2000);
30 l_return_status varchar2(1);
31 l_task_assignment_id number;
32 l_assignment_id number;
33 l_object_version_number number;
34 l_sr_task_exist varchar2(1); /*Added for 16585596*/
35
36 BEGIN
37
38 if p_dist_bus_rules.count <= 0 then
39 x_return_status := 'E';
40 end if;
41 if p_ws_input_data.count <= 0 then
42 x_return_status := 'E';
43 end if;
44
45 -- Loop thru the Business rules per Work Source
46
47 For i in P_DIST_BUS_RULES.first.. P_DIST_BUS_RULES.last
48 Loop
49
50 --insert into temp_f values('in the first loop');commit;
51
52 l_distributed_from := P_DIST_BUS_RULES(i).DISTRIBUTE_FROM;
53 l_distributed_to := P_DIST_BUS_RULES(i).DISTRIBUTE_TO;
54 l_dist_st_based_on_parent_flag := P_DIST_BUS_RULES(i).DIST_ST_BASED_ON_PARENT_FLAG;
55
56 -- For each Work Source, Get the Details of the Work Item to be distributed and the
57 -- Distribution Rules. Try to Distribute the Work Item.
58
59 /* commented work_source = 'TASK' check so, this same distribution function can be used for TASK and SR-TASK work source */
60
61 -- if (P_DIST_BUS_RULES(i).work_source = 'TASK') then
62
63 -- Loop thru Work Item Details
64 For j in p_WS_INPUT_DATA .first.. p_WS_INPUT_DATA.last
65 loop
66
67 -- if (p_WS_INPUT_DATA(j).Work_source = 'TASK') then
68
69 if (l_distributed_from = 'GROUP_OWNED')
70 then
71 l_grp_owner := p_WS_INPUT_DATA(j).OWNER_ID;
72 else
73 l_grp_owner := p_WS_INPUT_DATA(j).ASSIGNEE_ID;
74 end if;
75
76 l_task_distributed_to := p_resource_id;
77
78 begin
79 select 'X' into l_group_id
80 from jtf_rs_group_members
81 where resource_id = p_resource_id
82 and group_id = l_grp_owner
83 and nvl(delete_flag, 'N') = 'N'
84 and rownum < 2;
85 exception when no_data_found then x_return_status := 'E';
86 end;
87
88 if l_group_id = 'X' then
89 if l_dist_st_based_on_parent_flag = 'Y' then
90
91
92 -- Code changes required. This will be required only for 'Association' work source like SR-TASK
93 -- The object code should be selected from ieu_uwqm_work_sources_b for parent work source
94
95 -- if p_ws_input_data(j).source_object_type_code = 'SR' then
96 l_source_object_code := p_ws_input_data(j).source_object_type_code;
97 l_source_object_id := p_ws_input_data(j).source_object_id;
98
99 begin
100 select distribution_status_id into l_distribution_status
101 from ieu_uwqm_items
102 where workitem_pk_id = l_source_object_id
103 and workitem_obj_code = l_source_object_code;
104 exception when no_data_found then l_distribution_status := 0;
105 end;
106 -- end if;
107 end if;
108 if (l_distribution_status = 3 and l_dist_st_based_on_parent_flag = 'Y')
109 or (l_dist_st_based_on_parent_flag is null) then
110
111 If (l_distributed_to = 'INDIVIDUAL_ASSIGNED')
112 then
113 -- Distribute SR
114 /* in the following query we are doing rownum < 2 because we are ignoring assignment_status_id */
115 begin
116 select task_assignment_id, object_version_number
117 into l_assignment_id, l_object_version_number
118 from jtf_task_assignments
119 where resource_id = p_resource_id
120 and resource_type_code not in ('RS_TEAM', 'RS_GROUP')
121 and task_id = p_ws_input_data(j).workitem_pk_id
122 and rownum < 2;
123 exception when others then
124 l_assignment_id := null;
125 end;
126
127 IF (p_WS_INPUT_DATA(j).Work_source = 'SR_TASK') then/* Changed for 16585596 */
128 BEGIN
129 SELECT 'X' into l_sr_task_exist
130 FROM cs_incidents_b_sec inc,
131 jtf_tasks_b sel_task
132 where inc.incident_id=sel_task.source_object_id
133 and sel_task.task_id =p_ws_input_data(j).workitem_pk_id ;
134
135 EXCEPTION
136 WHEN NO_DATA_FOUND THEN
137 P_WS_INPUT_DATA(j).DISTRIBUTED := 'FALSE';
138 continue;
139 END;
140 END IF;
141
142 if l_assignment_id is not null then
143
144 jtf_task_assignments_pub.update_task_assignment(
145 p_api_version => 1.0,
146 p_object_version_number => l_object_version_number,
147 p_init_msg_list => fnd_api.g_false,
148 p_commit => fnd_api.g_true,
149 p_task_assignment_id => l_assignment_id,
150 p_task_id => p_ws_input_data(j).workitem_pk_id,
151 p_resource_type_code => 'RS_INDIVIDUAL',--l_resource_type_code,
152 p_resource_id => l_task_distributed_to, --l_resource_id,
153 p_actual_effort => null,
154 p_actual_effort_uom => null,
155 p_schedule_flag => null,
156 p_alarm_type_code => null,
157 p_alarm_contact => null,
158 p_sched_travel_distance => null,
159 p_sched_travel_duration => null,
160 p_sched_travel_duration_uom => null,
161 p_actual_travel_distance => null,
162 p_actual_travel_duration => null,
163 p_actual_travel_duration_uom => null,
164 p_actual_start_date => null,
165 p_actual_end_date => null,
166 p_palm_flag => null,
167 p_wince_flag => null,
168 p_laptop_flag => null,
169 p_device1_flag => null,
170 p_device2_flag => null,
171 p_device3_flag => null,
172 p_resource_territory_id => null,
173 p_shift_construct_id => null,
174 x_return_status => l_return_status,
175 x_msg_count => l_msg_count,
176 x_msg_data => l_msg_data
177 );
178 /*
179 IEU_WR_PUB.UPDATE_WR_ITEM(
180 p_api_version => 1.0,
181 p_init_msg_list => FND_API.G_TRUE,
182 p_commit => FND_API.G_true,
183 p_workitem_obj_code => p_ws_input_data(j).workitem_obj_code,
184 p_workitem_pk_id => p_ws_input_data(j).workitem_pk_id,
185 p_title => p_ws_input_data(j).title,
186 p_party_id => p_ws_input_data(j).party_id,
187 p_priority_code => p_ws_input_data(j).priority_code,
188 p_due_date => p_ws_input_data(j).due_date,
189 p_owner_id => p_ws_input_data(j).owner_id,
190 p_owner_type => p_ws_input_data(j).owner_type,
191 p_assignee_id => l_task_distributed_to,
192 p_assignee_type => 'RS_INDIVIDUAL',
193 p_source_object_id => p_ws_input_data(j).source_object_id,
194 p_source_object_type_code => p_ws_input_data(j).source_object_type_code,
195 p_application_id => p_ws_input_data(j).application_id,
196 p_work_item_status => p_ws_input_data(j).work_item_status,
197 p_user_id => FND_GLOBAL.USER_ID,
198 p_login_id => FND_GLOBAL.LOGIN_ID,
199 x_msg_count => l_msg_count,
200 x_msg_data => L_MSG_DATA,
201 x_return_status => L_RETURN_STATUS);
202 */
203 x_return_status := l_return_status;
204 x_msg_count := l_msg_count;
205 x_msg_data := l_msg_data;
206
207 else
208 jtf_task_assignments_pub.create_task_assignment (
209 p_api_version => 1.0,
210 p_init_msg_list => fnd_api.g_false,
211 p_commit => fnd_api.g_true,
212 p_task_id => p_ws_input_data(j).workitem_pk_id,
213 p_resource_type_code => 'RS_INDIVIDUAL',--l_resource_type_code,
214 p_resource_id => l_task_distributed_to, --l_resource_id,
215 p_actual_effort => null,
216 p_actual_effort_uom => null,
217 p_schedule_flag => null,
218 p_alarm_type_code => null,
219 p_alarm_contact => null,
220 p_sched_travel_distance => null,
221 p_sched_travel_duration => null,
222 p_sched_travel_duration_uom => null,
223 p_actual_travel_distance => null,
224 p_actual_travel_duration => null,
225 p_actual_travel_duration_uom => null,
226 p_actual_start_date => null,
227 p_actual_end_date => null,
228 p_palm_flag => null,
229 p_wince_flag => null,
230 p_laptop_flag => null,
231 p_device1_flag => null,
232 p_device2_flag => null,
233 p_device3_flag => null,
234 p_resource_territory_id => null,
235 p_assignment_status_id => 14,
236 p_shift_construct_id => null,
237 x_return_status => l_return_status,
238 x_msg_count => l_msg_count,
239 x_msg_data => l_msg_data,
240 x_task_assignment_id => l_task_assignment_id
241 );
242 x_return_status := l_return_status;
243 x_msg_count := l_msg_count;
244 x_msg_data := l_msg_data;
245 end if;
246 /* commented out because SR is not going to use Tasks Distribution Function
247 -- Update SR Item based on Business rules. This should
248 -- internally call Update UWQ Repository Item based on
249 -- Distribution rules. In this case, the Update should be done to
250 -- UWQ Assignee_id and Assignee_type
251
252 elsIf (l_distributed_to = 'INDIVIDUAL_OWNED')
253 Then
254 -- Distribute SR
255
256 IEU_WR_PUB.UPDATE_WR_ITEM(
257 p_api_version => 1.0,
258 p_init_msg_list => FND_API.G_TRUE,
259 p_commit => FND_API.G_true,
260 p_workitem_obj_code => p_ws_input_data(j).workitem_obj_code,
261 p_workitem_pk_id => p_ws_input_data(j).workitem_pk_id,
262 p_title => p_ws_input_data(j).title,
263 p_party_id => p_ws_input_data(j).party_id,
264 p_priority_code => p_ws_input_data(j).priority_code,
265 p_due_date => p_ws_input_data(j).due_date,
266 p_owner_id => l_task_distributed_to,
267 p_owner_type => 'RS_INDIVIDUAL',
268 p_assignee_id => p_ws_input_data(j).assignee_id,
269 p_assignee_type => p_ws_input_data(j).assignee_type,
270 p_source_object_id => p_ws_input_data(j).source_object_id,
271 p_source_object_type_code => p_ws_input_data(j).source_object_type_code,
272 p_application_id => p_ws_input_data(j).application_id,
273 p_user_id => FND_GLOBAL.USER_ID,
274 p_login_id => FND_GLOBAL.LOGIN_ID,
275 x_msg_count => l_msg_count,
276 x_msg_data => L_MSG_DATA,
277 x_return_status => L_RETURN_STATUS);
278
279 x_return_status := l_return_status;
280 x_msg_count := l_msg_count;
281 x_msg_data := l_msg_data;
282 *********************/
283 end if;
284 end if;
285 end if;
286 -- end if;
287 If x_return_status = 'S'
288 then
289 P_WS_INPUT_DATA(j).DISTRIBUTED := 'TRUE';
290 P_WS_INPUT_DATA(j).ASSIGNEE_ID := p_resource_id;
291 P_WS_INPUT_DATA(j).ASSIGNEE_TYPE := 'RS_INDIVIDUAL';
292 P_WS_INPUT_DATA(j).ITEM_INCLUDED_BY_APP := 'FALSE';
293 Else
294 P_WS_INPUT_DATA(j).DISTRIBUTED := 'FALSE';
295 End if;
296 End loop;
297 -- End if;
298 End loop;
299
300
301 END DISTRIBUTE_TASKS;
302
303 END IEU_UWQ_DISTRIBUTE_ITEMS;
304