[Home] [Help]
Skip to content
PACKAGE BODY: APPS.PA_ASGMT_WFSTD
Source
1 PACKAGE BODY PA_ASGMT_WFSTD AS
2 -- $Header: PAWFAAPB.pls 120.26 2011/04/29 18:37:42 svmohamm ship $
3 -- forward declarations
4 --------------------------------------------------------------------------------------------------------------
5 -- This procedure prints the text which is being passed as the input
6 -- Input parameters
7 -- Parameters Type Required Description
8 -- p_log_msg VARCHAR2 YES It stores text which you want to print on screen
9 -- Out parameters
10 ----------------------------------------------------------------------------------------------------------------
11 PROCEDURE log_message (p_log_msg IN VARCHAR2)
12 IS
13 BEGIN
14 --dbms_output.put_line('Log : ' || p_log_msg);
15 NULL;
16 END log_message;
17
18 PROCEDURE Capture_approver_response (p_item_type IN VARCHAR2,
19 p_item_key IN VARCHAR2) ;
20
21 PROCEDURE Set_Nf_Error_Msg_Attr (p_item_type IN VARCHAR2,
22 p_item_key IN VARCHAR2,
23 p_msg_count IN NUMBER,
24 p_msg_data IN VARCHAR2 ) ;
25 PROCEDURE get_primary_contact_info
26 (p_resource_id IN NUMBER
27 , p_assignment_id IN NUMBER
28 , p_approver1_person_id IN NUMBER
29 , p_approver1_type IN VARCHAR2
30 , p_approver2_person_id IN NUMBER
31 , p_approver2_type IN VARCHAR2
32 , x_PrimaryContactId OUT NOCOPY NUMBER ); --File.Sql.39 bug 4440895
33
34 PROCEDURE populate_wf_performers
35 ( p_wf_type_code IN VARCHAR2
36 ,p_item_type IN VARCHAR2
37 ,p_item_key IN VARCHAR2
38 ,p_object_id1 IN VARCHAR2
39 ,p_object_id2 IN VARCHAR2
40 ,p_in_performers_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp
41 ,p_current_approver_flag IN VARCHAR2
42 ,x_number_of_performers OUT NOCOPY NUMBER ); --File.Sql.39 bug 4440895
43
44 PROCEDURE get_wf_performer (p_wf_type_code IN VARCHAR2,
45 p_item_type IN VARCHAR2,
46 p_item_key IN VARCHAR2,
47 p_routing_order IN NUMBER,
48 p_object_id1 IN VARCHAR2 ,
49 x_performer_name OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
50 x_performer_type OUT NOCOPY VARCHAR2 ); --File.Sql.39 bug 4440895
51
52 PROCEDURE Set_approver_comments (p_apprvl_item_type VARCHAR2,
53 p_apprvl_item_key VARCHAR2,
54 p_item_type VARCHAR2,
55 p_item_key VARCHAR2,
56 p_assignment_id NUMBER ) ;
57
58 PROCEDURE Set_Comment_Attributes (p_item_type IN VARCHAR2,
59 p_item_key IN VARCHAR2,
60 p_rect_type IN VARCHAR2 );
61
62 /*PROCEDURE Check_And_Get_Proj_Customer ( p_project_id IN NUMBER
63 ,x_customer_id OUT NUMBER
64 ,x_customer_name OUT VARCHAR2 );*/
65
66 PROCEDURE Set_NF_Subject_and_Desc (p_item_type IN VARCHAR2,
67 p_item_key IN VARCHAR2,
68 p_assignment_type IN VARCHAR2,
69 p_reapproval_flag IN VARCHAR2,
70 p_msg_type IN VARCHAR2 );
71
72 -- end forward declarations
73
74 PROCEDURE Start_Workflow ( p_project_id IN NUMBER DEFAULT NULL
75 , p_assignment_id IN NUMBER
76 , p_status_code IN VARCHAR2 DEFAULT NULL
77 , p_person_id IN NUMBER DEFAULT NULL
78 , p_wf_item_type IN VARCHAR2
79 , p_wf_process IN VARCHAR2
80 , p_approver1_person_id IN NUMBER DEFAULT NULL
81 , p_approver1_type IN VARCHAR2 DEFAULT NULL
82 , p_approver2_person_id IN NUMBER DEFAULT NULL
83 , p_approver2_type IN VARCHAR2 DEFAULT NULL
84 , p_apprvl_item_type IN VARCHAR2 DEFAULT NULL
85 , p_apprvl_item_key IN VARCHAR2 DEFAULT NULL
86 , p_conflict_group_id IN NUMBER DEFAULT NULL
87 , x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
88 , x_msg_data OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
89 , x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
90 , x_error_message_code OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
91 IS
92
93 CURSOR l_assignments_csr IS
94 SELECT ppa.assignment_id,
95 ppa.assignment_name,
96 ppa.assignment_effort,
97 ppa.additional_information,
98 ppa.description,
99 ppa.note_to_approver,
100 ppa.project_id,
101 ppa.resource_id,
102 ppa.start_date,
103 ppa.end_date,
104 ppa.status_code,
105 ppa.apprvl_status_code,
106 ppa.pending_approval_flag,
107 ppa.assignment_type,
108 ppa.revenue_bill_rate,
109 ppa.revenue_currency_code,
110 ppa.bill_rate_override,
111 ppa.bill_rate_curr_override,
112 ppa.markup_percent_override,
113 ppa.fcst_tp_amount_type_name,
114 ppa.tp_rate_override,
115 ppa.tp_currency_override,
116 ppa.tp_calc_base_code_override,
117 ppa.tp_percent_applied_override,
118 ppa.work_type_name,
119 ppa.transfer_price_rate, -- Added for bug 3051110
120 ppa.transfer_pr_rate_curr
121 FROM pa_project_assignments_v ppa
122 WHERE assignment_id = p_assignment_id;
123
124 CURSOR csr_get_override_basis_name (p_override_basis_code IN VARCHAR2) IS
125 SELECT plks.meaning
126 FROM pa_lookups plks
127 WHERE plks.lookup_type = 'CC_MARKUP_BASE_CODE'
128 AND plks.lookup_code = p_override_basis_code;
129
130 CURSOR l_stus_csr (c_status_code IN VARCHAR2) IS
131 SELECT ps.wf_success_status_code,
132 ps.wf_failure_status_code,
133 ps.project_status_name
134 FROM pa_project_statuses ps
135 WHERE project_status_code = c_status_code;
136
137 CURSOR l_resource_csr(l_resource_id IN NUMBER, p_start_date IN DATE) IS
138 SELECT per.full_name resource_name,
139 rta.person_id resource_person_id,
140 rta.resource_id resource_id,
141 hou.name resource_organization_name,
142 assign.supervisor_id manager_id
143 FROM per_all_people_f per,
144 per_all_assignments_f assign,
145 hr_all_organization_units hou,
146 pa_resource_txn_attributes rta
147 WHERE rta.resource_id = l_resource_id
148 AND rta.person_id = per.person_id
149 AND rta.person_id = assign.person_id
150 AND assign.primary_flag = 'Y'
151 AND assign.assignment_type in ('E','C')
152 AND hou.organization_id = assign.organization_id
153 AND trunc(p_start_date) BETWEEN assign.effective_start_date AND assign.effective_end_date /*bug 8817301 */
154 AND trunc(p_start_date) BETWEEN per.effective_start_date AND per.effective_end_date /*bug 8817301 */ /* 2983985 - Added this condition */
155 ;
156
157
158 CURSOR l_projects_csr(l_project_id IN NUMBER) IS
159 SELECT pap.project_id project_id,
160 pap.name name,
161 pap.segment1 segment1,
162 pap.carrying_out_organization_id carrying_out_organization_id,
163 pap.location_id,
164 hr.name organization_name,
165 NVL(pt.administrative_flag,'N') admin_flag
166 FROM pa_projects_all pap,
167 hr_all_organization_units hr,
168 pa_project_types_all pt
169 WHERE pap.project_id = l_project_id
170 AND pap.carrying_out_organization_id =
171 hr.organization_id
172 AND pap.org_id = pt.org_id -- Added for Bug 5389093
173 AND pt.project_type = pap.project_type;
174
175 /* Commenting Below and changing cursor query for bug 7640483
176 CURSOR l_prev_asgmt_info_csr (l_assignment_id IN NUMBER)
177 IS
178 SELECT assignment_effort prev_effort,
179 (trunc(end_date) -
180 (trunc(start_date)+1)) prev_duration
181 FROM pa_assignments_history
182 WHERE assignment_id = l_assignment_id
183 AND nvl(last_approved_flag,'N') = 'Y';
184 */
185
186 CURSOR l_prev_asgmt_info_csr (l_assignment_id IN NUMBER)
187 IS
188 SELECT assignment_effort prev_effort,
189 (trunc(end_date) - trunc(start_date) + 1) prev_duration
190 FROM pa_assignments_history
191 WHERE assignment_id = l_assignment_id
192 AND nvl(last_approved_flag,'N') = 'Y';
193
194 l_assignments_rec l_assignments_csr%ROWTYPE;
195 l_resource_rec l_resource_csr%ROWTYPE;
196 l_projects_rec l_projects_csr%ROWTYPE;
197 l_prev_asgmt_info_rec l_prev_asgmt_info_csr%ROWTYPE;
198 l_asgmt_details_url VARCHAR2(600);
199 l_resource_details_url VARCHAR2(600);
200 l_resource_schedules_url VARCHAR2(600);
201 l_itemkey VARCHAR2(30);
202 l_responsibility_id NUMBER;
203 l_resp_appl_id NUMBER;
204 l_wf_started_date DATE;
205 l_wf_started_by_id NUMBER;
206 l_wf_started_by_full_name per_people_f.full_name%TYPE;
207 l_wf_started_by_email_address per_people_f.email_address%TYPE;
208 l_wf_started_by_username fnd_user.user_name%TYPE;
209 l_display_name wf_users.display_name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
210 l_project_manager_person_id NUMBER ;
211 l_project_manager_name per_all_people_f.full_name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
212 l_project_manager_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
213 l_project_party_id NUMBER ;
214 l_project_role_id NUMBER ;
215 l_project_role_name pa_project_role_types.meaning%TYPE; ---- VARCHAR2(80); Changed for bug 3267790
216 l_approver1_user_name wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
217 l_approver2_user_name wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
218 l_approver1_type VARCHAR2(200);
219 l_approver2_type VARCHAR2(200);
220 l_apprvl_nf_rec1_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
221 l_apprvl_nf_rec2_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
222 l_apprvl_nf_rec3_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
223 l_apprvl_nf_rec4_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
224 l_apprvl_nf_rec1_utype VARCHAR2(30);
225 l_apprvl_nf_rec2_utype VARCHAR2(30);
226 l_apprvl_nf_rec3_utype VARCHAR2(30);
227 l_apprvl_nf_rec4_utype VARCHAR2(30);
228 l_apprvl_nf_rec1_person_id NUMBER := 0;
229 l_apprvl_nf_rec2_person_id NUMBER := 0;
230 l_apprvl_nf_rec3_person_id NUMBER := 0;
231 l_apprvl_nf_rec4_person_id NUMBER := 0;
232
233 l_reject_nf_rec1_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
234 l_reject_nf_rec2_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
235 l_reject_nf_rec3_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
236 l_reject_nf_rec4_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
237 l_reject_nf_rec1_utype VARCHAR2(30);
238 l_reject_nf_rec2_utype VARCHAR2(30);
239 l_reject_nf_rec3_utype VARCHAR2(30);
240 l_reject_nf_rec4_utype VARCHAR2(30);
241 l_reject_nf_rec1_person_id NUMBER := 0;
242 l_reject_nf_rec2_person_id NUMBER := 0;
243 l_reject_nf_rec3_person_id NUMBER := 0;
244 l_reject_nf_rec4_person_id NUMBER := 0;
245
246 l_cancel_nf_rec1_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
247 l_cancel_nf_rec2_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
248 l_cancel_nf_rec3_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
249 l_cancel_nf_rec4_uname wf_users.name%TYPE; ---- VARCHAR2(200); Changed for bug 3267790
250 l_cancel_nf_rec1_utype VARCHAR2(30);
251 l_cancel_nf_rec2_utype VARCHAR2(30);
252 l_cancel_nf_rec3_utype VARCHAR2(30);
253 l_cancel_nf_rec4_utype VARCHAR2(30);
254 l_cancel_nf_rec1_person_id NUMBER := 0;
255 l_cancel_nf_rec2_person_id NUMBER := 0;
256 l_cancel_nf_rec3_person_id NUMBER := 0;
257 l_cancel_nf_rec4_person_id NUMBER := 0;
258 l_number_of_approvers NUMBER := 0;
259 l_number_of_apprvl_nf_rects NUMBER := 0;
260 l_number_of_reject_nf_rects NUMBER := 0;
261 l_number_of_cancel_nf_rects NUMBER := 0;
262
263 l_return_status VARCHAR2(1);
264 l_error_message_code VARCHAR2(30);
265 l_wf_success_status_code pa_project_statuses.project_status_code%TYPE;
266 l_wf_failure_status_code pa_project_statuses.project_status_code%TYPE;
267 l_project_status_name pa_project_statuses.project_status_name%TYPE;
268 l_resource_person_id NUMBER;
269 l_reapproval_flag VARCHAR2(1);
270 l_country_name VARCHAR2(200);
271 l_city VARCHAR2(200);
272 l_region VARCHAR2(200);
273 l_country_code VARCHAR2(30);
274 l_err_code NUMBER := 0;
275 l_err_stage VARCHAR2(2000);
276 l_err_stack VARCHAR2(2000);
277 l_msg_count NUMBER ;
278 l_msg_index_out NUMBER ;
279 l_msg_data VARCHAR2(2000);
280 l_data VARCHAR2(2000);
281 l_primarycontactid NUMBER := 0;
282 l_primarycontactname wf_users.name%TYPE; ---- VARCHAR2(240); Changed for bug 3267790
283 l_resource_start_date DATE;
284
285 -- 4363092 TCA changes, replaced RA views with HZ tables
286 /*
287 l_customer_id ra_customers.customer_id%TYPE;
288 l_customer_name ra_customers.customer_name%TYPE;
289 */
290
291 l_customer_id hz_cust_accounts.cust_account_id%TYPE;
292 l_customer_name hz_parties.party_name%TYPE;
293
294 -- 4363092 end
295
296 l_workflow_started_by_uname fnd_user.user_name%TYPE; ----VARCHAR2(100); Changed for bug 3267790 /* Increased length from 30 to 100 for bug 3148857 */
297 l_waiting_time NUMBER := 0;
298 l_number_of_reminders NUMBER := 0;
299 l_save_threshold NUMBER;
300 l_override_basis_name VARCHAR2(80) := NULL;
301
302 l_last_approver_uname fnd_user.USER_NAME%TYPE; --- VARCHAR2(240); -- Added for the bug 3817940
303 l_res_manager_id PER_PEOPLE_F.PERSON_ID%TYPE; -- Added for bug 4334741
304 BEGIN
305 -- dbms_output.put_line ('inside start workflow');
306 x_return_status := FND_API.G_RET_STS_SUCCESS;
307 /*
308 IF fnd_msg_pub.count_msg > 0 THEN
309 insert_into_temp ('msgs in stack inside start_workflow is',
310 fnd_msg_pub.count_msg);
311 END IF;
312 */
313 fnd_msg_pub.initialize;
314 pa_debug.init_err_stack ('pa_asgmt_wfstd.start_workflow');
315 x_msg_count := 0;
316 -- Create the unique item key to launch WF with
317 SELECT pa_prm_wf_item_key_s.nextval
318 INTO l_itemkey
319 FROM dual;
320
321 l_wf_started_by_id := FND_GLOBAL.user_id;
322 l_responsibility_id := FND_GLOBAL.resp_id;
323 l_resp_appl_id := FND_GLOBAL.resp_appl_id;
324
325 FND_GLOBAL.Apps_Initialize ( user_id => l_wf_started_by_id
326 , resp_id => l_responsibility_id
327 , resp_appl_id => l_resp_appl_id );
328
329 -- Setting thresold value to run the process in background
330 l_save_threshold := wf_engine.threshold;
331 wf_engine.threshold := -1;
332
333
334 -- Now start fetching the details
335 OPEN l_assignments_csr;
336 FETCH l_assignments_csr INTO l_assignments_rec;
337 IF l_assignments_csr%NOTFOUND THEN
338 x_return_status := FND_API.G_RET_STS_ERROR;
339 pa_utils.add_message (p_app_short_name => 'PA',
340 p_msg_name => 'PA_INVALID_ASMGT_ID');
341 x_error_message_code := 'PA_INVALID_ASMGT_ID'; -- msg already avail
342 CLOSE l_assignments_csr;
343 x_msg_count := x_msg_count + 1;
344 ELSE
345 CLOSE l_assignments_csr;
346 END IF;
347 -- := l_assignments_rec.apprvl_status_code;
348 /*
349 -- Do not launch a workflow if an approval is already pending
350 IF NVL(l_assignments_rec.pending_approval_flag, 'N') = 'Y' THEN
351 x_return_status := FND_API.G_RET_STS_ERROR;
352 pa_utils.add_message (p_app_short_name => 'PA',
353 p_msg_name =>
354 'PA_ASG_APPROVAL_PENDING' );
355 x_error_message_code := 'PA_ASG_APPROVAL_PENDING';
356 x_msg_count := x_msg_count + 1;
357 END IF;
358 */
359 OPEN l_stus_csr(l_assignments_rec.apprvl_status_code);
360 FETCH l_stus_csr INTO
361 l_wf_success_status_code,
362 l_wf_failure_status_code,
363 l_project_status_name ;
364 IF l_stus_csr%NOTFOUND THEN
365 x_return_status := FND_API.G_RET_STS_ERROR;
366 pa_utils.add_message (p_app_short_name => 'PA',
367 p_msg_name => 'PA_INVALID_STATUS_CODE');
368 x_error_message_code := 'PA_INVALID_STATUS_CODE';-- msg already avail
369 CLOSE l_stus_csr;
370 x_msg_count := x_msg_count + 1;
371 ELSE
372 CLOSE l_stus_csr;
373 END IF;
374
375 OPEN l_projects_csr(l_assignments_rec.project_id);
376 FETCH l_projects_csr INTO l_projects_rec;
377 IF l_projects_csr%NOTFOUND THEN
378 x_return_status := FND_API.G_RET_STS_ERROR;
379 x_error_message_code := 'PA_INVALID_PROJECT_ID'; -- msg already avail
380 pa_utils.add_message (p_app_short_name => 'PA',
381 p_msg_name => 'PA_INVALID_PROJECT_ID');
382 CLOSE l_projects_csr;
383 x_msg_count := x_msg_count + 1;
384 ELSE
385 CLOSE l_projects_csr;
386 END IF;
387
388 Check_And_Get_Proj_Customer
389 (p_project_id => l_assignments_rec.project_id
390 ,x_customer_id => l_customer_id
391 ,x_customer_name => l_customer_name );
392 -- Get the previously approved effort and duration
393 -- in case of re-approvals
394 OPEN l_prev_asgmt_info_csr (l_assignments_rec.assignment_id) ;
395 FETCH l_prev_asgmt_info_csr INTO
396 l_prev_asgmt_info_rec;
397 IF l_prev_asgmt_info_csr%NOTFOUND THEN
398 l_reapproval_flag := 'N';
399 ELSE
400 l_reapproval_flag := 'Y';
401 END IF;
402 CLOSE l_prev_asgmt_info_csr;
403
404 -- Get the Location details of the project location
405 IF l_projects_rec.location_id IS NOT NULL THEN
406 pa_location_utils.Get_PA_Location_Details
407 ( p_location_id => l_projects_rec.location_id
408 ,x_country_name => l_country_name
409 ,x_city => l_city
410 ,x_region => l_region
411 ,x_country_code => l_country_code
412 ,x_return_status => l_return_status
413 ,x_error_message_code => l_error_message_code );
414 -- dbms_output.put_line ('after pa_location_utils');
415
416 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
417 x_return_status := l_return_status;
418 x_error_message_code := l_error_message_code ;
419 pa_utils.add_message (p_app_short_name => 'PA',
420 p_msg_name => l_error_message_code);
421 END IF;
422 END IF;
423
424 -- Bug 5362698 - use sysdate to get the name so that the latest name
425 -- is obtained.
426 -- OPEN l_resource_csr(l_assignments_rec.resource_id, l_assignments_rec.start_date);
427 -- Need to get the Max of StartDate or the Sysdate for future hire. Fix
428 -- for Bug# 7585927.
429 if(l_assignments_rec.start_date > sysdate) then
430 l_resource_start_date := l_assignments_rec.start_date;
431 else
432 l_resource_start_date := sysdate;
433 end if;
434
435 OPEN l_resource_csr(l_assignments_rec.resource_id, l_resource_start_date );
436 FETCH l_resource_csr INTO l_resource_rec;
437 IF l_resource_csr%NOTFOUND THEN
438 x_return_status := FND_API.G_RET_STS_ERROR;
439 x_error_message_code := 'PA_INVALID_PERSON_ID'; --msg already avail
440 pa_utils.add_message (p_app_short_name => 'PA',
441 p_msg_name => 'PA_INVALID_PERSON_ID');
442 CLOSE l_resource_csr;
443 x_msg_count := x_msg_count + 1;
444 ELSE
445 CLOSE l_resource_csr;
446 END IF;
447
448 -- Get the project manager details
449 pa_project_parties_utils.get_curr_proj_mgr_details
450 (p_project_id => l_projects_rec.project_id
451 ,x_manager_person_id => l_project_manager_person_id
452 ,x_manager_name => l_project_manager_name
453 ,x_project_party_id => l_project_party_id
454 ,x_project_role_id => l_project_role_id
455 ,x_project_role_name => l_project_role_name
456 ,x_return_status => l_return_status
457 ,x_error_message_code => l_error_message_code );
458
459 -- dbms_output.put_line ('after pa_project_parties_utils');
460 -- Only non-admin projects require a manager
461 IF l_projects_rec.admin_flag = 'N' THEN
462 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
463 x_return_status := l_return_status;
464 x_error_message_code := l_error_message_code;
465 pa_utils.add_message (p_app_short_name => 'PA',
466 p_msg_name => l_error_message_code);
467 END IF;
468 END IF;
469 -- If there are any busines rules violations , then do
470 -- not proceed. Return
471 l_msg_count := fnd_msg_pub.count_msg;
472 IF l_msg_count > 0 THEN
473 IF l_msg_count = 1 THEN
474 pa_interface_utils_pub.get_messages
475 (p_encoded => FND_API.G_TRUE,
476 p_msg_index => 1,
477 p_msg_count => l_msg_count,
478 p_msg_data => l_msg_data ,
479 p_data => l_data,
480 p_msg_index_out => l_msg_index_out );
481 x_msg_data := l_data;
482 x_msg_count := l_msg_count;
483 ELSE
484 x_msg_count := l_msg_count;
485 END IF;
486 pa_debug.reset_err_stack;
487 RETURN;
488 END IF;
489 -- Get the approvers user name
490 IF p_approver1_person_id IS NOT NULL THEN
491 wf_directory.getusername
492 (p_orig_system => 'PER',
493 p_orig_system_id => p_approver1_person_id,
494 p_name => l_approver1_user_name,
495 p_display_name => l_display_name);
496 l_number_of_approvers := l_number_of_approvers + 1;
497 l_approver1_type := p_approver1_type;
498 END IF;
499
500 IF p_approver2_person_id IS NOT NULL THEN
501 wf_directory.getusername
502 (p_orig_system => 'PER',
503 p_orig_system_id => p_approver2_person_id,
504 p_name => l_approver2_user_name,
505 p_display_name => l_display_name);
506 l_number_of_approvers := l_number_of_approvers + 1;
507 l_approver2_type := p_approver2_type;
508 END IF;
509
510 -- get the recipients user name (resource , project manager ,
511 -- If person_id is passed use that value to get the user name
512 -- of the resource, otherwise, use the person id fetched from resources
513 IF p_person_id IS NULL THEN
514 l_resource_person_id := l_resource_rec.resource_person_id;
515 ELSE
516 l_resource_person_id := p_person_id;
517 END IF;
518 wf_directory.getusername
519 (p_orig_system => 'PER',
520 p_orig_system_id => l_resource_person_id,
521 p_name => l_apprvl_nf_rec1_uname,
522 p_display_name => l_display_name);
523 l_reject_nf_rec1_uname := l_apprvl_nf_rec1_uname;
524 l_cancel_nf_rec1_uname := l_apprvl_nf_rec1_uname;
525 l_apprvl_nf_rec1_utype := 'RESOURCE';
526 l_apprvl_nf_rec1_person_id := l_resource_person_id;
527 l_reject_nf_rec1_utype := 'RESOURCE';
528 l_reject_nf_rec1_person_id := l_resource_person_id;
529 l_cancel_nf_rec1_utype := 'RESOURCE';
530 l_cancel_nf_rec1_person_id := l_resource_person_id;
531 l_number_of_apprvl_nf_rects := l_number_of_apprvl_nf_rects +1;
532 l_number_of_reject_nf_rects := l_number_of_reject_nf_rects +1;
533 l_number_of_cancel_nf_rects := l_number_of_cancel_nf_rects +1;
534
535 -- Now get the resource's manager name , since the approvers may or
536 -- may not be the resource's manager
537 -- Begin changes for Bug 4334741 Changed resource manager from l_resource_rec.manager_id to l_res_manager_id
538 -- Bug 4473484
539 -- l_res_manager_id := pa_resource_utils.get_hr_manager_id(l_resource_rec.resource_id,l_assignments_rec.assignment_id);
540 l_res_manager_id := pa_resource_utils.get_hr_manager_id(p_resource_id => l_resource_rec.resource_id,
541 p_start_date => l_assignments_rec.start_date);
542 IF l_res_manager_id IS NOT NULL THEN
543 wf_directory.getusername
544 (p_orig_system => 'PER',
545 p_orig_system_id => l_res_manager_id,
546 p_name => l_apprvl_nf_rec2_uname,
547 p_display_name => l_display_name);
548 l_reject_nf_rec2_uname := l_apprvl_nf_rec2_uname;
549 l_cancel_nf_rec2_uname := l_apprvl_nf_rec2_uname;
550 l_apprvl_nf_rec2_utype := 'RESOURCE_MANAGER';
551 l_apprvl_nf_rec2_person_id := l_res_manager_id;
552 l_reject_nf_rec2_utype := 'RESOURCE_MANAGER';
553 l_reject_nf_rec2_person_id := l_res_manager_id;
554 l_cancel_nf_rec2_utype := 'RESOURCE_MANAGER';
555 l_cancel_nf_rec2_person_id := l_res_manager_id;
556 l_number_of_apprvl_nf_rects := l_number_of_apprvl_nf_rects +1;
557 l_number_of_reject_nf_rects := l_number_of_reject_nf_rects +1;
558 l_number_of_cancel_nf_rects := l_number_of_cancel_nf_rects +1;
559
560 END IF;
561 -- End changes for Bug 4334741 Changed resource manager from l_resource_rec.manager_id to l_res_manager_id
562 -- Now get the project manager's user name
563 IF l_project_manager_person_id IS NOT NULL THEN
564 wf_directory.getusername
565 (p_orig_system => 'PER',
566 p_orig_system_id => l_project_manager_person_id,
567 p_name => l_project_manager_uname,
568 p_display_name => l_display_name);
569 l_apprvl_nf_rec3_uname := l_project_manager_uname;
570 l_reject_nf_rec3_uname := l_project_manager_uname;
571 l_cancel_nf_rec3_uname := l_project_manager_uname;
572 l_apprvl_nf_rec3_utype := 'PROJECT_MANAGER';
573 l_apprvl_nf_rec3_person_id := l_project_manager_person_id;
574 l_reject_nf_rec3_utype := 'PROJECT_MANAGER';
575 l_reject_nf_rec3_person_id := l_project_manager_person_id;
576 l_cancel_nf_rec3_utype := 'PROJECT_MANAGER';
577 l_cancel_nf_rec3_person_id := l_project_manager_person_id;
578 l_number_of_apprvl_nf_rects := l_number_of_apprvl_nf_rects +1;
579 l_number_of_reject_nf_rects := l_number_of_reject_nf_rects +1;
580 l_number_of_cancel_nf_rects := l_number_of_cancel_nf_rects +1;
581 END IF;
582
583 -- Ramesh 07/11/00
584 -- Primary contact would be one of the two approvers
585 -- Call the procedure to get the primary contact id
586 get_primary_contact_info
587 (p_resource_id => l_resource_rec.resource_id
588 ,p_assignment_id => l_assignments_rec.assignment_id
589 ,p_approver1_person_id => p_approver1_person_id
590 ,p_approver1_type => p_approver1_type
591 ,p_approver2_person_id => p_approver2_person_id
592 ,p_approver2_type => p_approver2_type
593 ,x_PrimaryContactId => l_primarycontactid );
594 -- dbms_output.put_line ('after resource utils - primary contact');
595 -- Now get the primary contact's user name
596 IF l_primarycontactid IS NOT NULL THEN
597 wf_directory.getusername
598 (p_orig_system => 'PER',
599 p_orig_system_id => l_primarycontactid,
600 p_name => l_primarycontactname,
601 p_display_name => l_display_name);
602 l_apprvl_nf_rec4_uname := l_primarycontactname;
603 l_reject_nf_rec4_uname := l_primarycontactname;
604 l_cancel_nf_rec4_uname := l_primarycontactname;
605 l_apprvl_nf_rec4_utype := 'ORG_PRIMARY_CONTACT';
606 l_apprvl_nf_rec4_person_id := l_primarycontactid;
607 l_reject_nf_rec4_utype := 'ORG_PRIMARY_CONTACT';
608 l_reject_nf_rec4_person_id := l_primarycontactid;
609 l_cancel_nf_rec4_utype := 'ORG_PRIMARY_CONTACT';
610 l_cancel_nf_rec4_person_id := l_primarycontactid;
611 l_number_of_apprvl_nf_rects := l_number_of_apprvl_nf_rects +1;
612 l_number_of_reject_nf_rects := l_number_of_reject_nf_rects +1;
613 l_number_of_cancel_nf_rects := l_number_of_cancel_nf_rects +1;
614 END IF;
615 -- End 07/11/00 changes
616 -- We now have all the values in local variables
617 -- Create the WF process
618 wf_engine.CreateProcess ( ItemType => p_wf_item_type
619 , ItemKey => l_itemkey
620 , process => p_wf_process
621 );
622
623 --Set approval type
624 wf_engine.SetItemAttrText
625 ( itemtype => p_wf_item_type
626 , itemkey => l_itemkey
627 , aname => 'APPROVAL_TYPE'
628 , avalue => PA_ASGMT_WFSTD.G_SINGLE_APPROVAL );
629
630 -- Now set the values as appropriate in the WF attributes
631 -- Set Project details attributes
632 wf_engine.SetItemAttrNumber
633 ( itemtype => p_wf_item_type
634 , itemkey => l_itemkey
635 , aname => 'PROJECT_ID'
636 , avalue => l_projects_rec.project_id
637 );
638
639 wf_engine.SetItemAttrText
640 ( itemtype => p_wf_item_type
641 , itemkey => l_itemkey
642 , aname => 'PROJECT_NUMBER'
643 , avalue => l_projects_rec.segment1
644 );
645
646 wf_engine.SetItemAttrText
647 ( itemtype => p_wf_item_type
648 , itemkey => l_itemkey
649 , aname => 'PROJECT_NAME'
650 , avalue => l_projects_rec.name
651 );
652
653 wf_engine.SetItemAttrText
654 ( itemtype => p_wf_item_type
655 , itemkey => l_itemkey
656 , aname => 'PROJECT_ORGANIZATION'
657 , avalue => l_projects_rec.organization_name
658 );
659 /*Commented the code for the bug 3595857
660 Bug 3595857 - Adding the FROM_ROLE_VALUE Attribute
661 wf_engine.SetItemAttrText
662 ( itemtype => p_wf_item_type
663 , itemkey => l_itemkey
664 , aname => 'FROM_ROLE_VALUE'
665 , avalue => fnd_global.user_name
666 );*/
667
668 wf_engine.SetItemAttrText
669 ( itemtype => p_wf_item_type
670 , itemkey => l_itemkey
671 , aname => 'PROJECT_LOCATION'
672 , avalue => l_city||' , ' ||l_region||
673 ' , ' ||l_country_name
674 );
675 -- Set the customer name if it is not null
676 IF l_customer_name IS NOT NULL THEN
677 wf_engine.SetItemAttrText
678 ( itemtype => p_wf_item_type
679 , itemkey => l_itemkey
680 , aname => 'PROJECT_CUSTOMER'
681 , avalue => l_customer_name
682 );
683 END IF;
684
685
686 -- Set Assignment related attributes
687
688 wf_engine.SetItemAttrNumber
689 ( itemtype => p_wf_item_type
690 , itemkey => l_itemkey
691 , aname => 'ASSIGNMENT_ID'
692 , avalue => l_assignments_rec.assignment_id
693 );
694
695 wf_engine.SetItemAttrText
696 ( itemtype => p_wf_item_type
697 , itemkey => l_itemkey
698 , aname => 'ASSIGNMENT_NAME'
699 , avalue => l_assignments_rec.assignment_name
700 );
701
702 wf_engine.SetItemAttrText
703 ( itemtype => p_wf_item_type
704 , itemkey => l_itemkey
705 , aname => 'ASSIGNMENT_TYPE'
706 , avalue => l_assignments_rec.assignment_type
707 );
708
709 wf_engine.SetItemAttrText
710 ( itemtype => p_wf_item_type
711 , itemkey => l_itemkey
712 , aname => 'DESCRIPTION'
713 , avalue => l_assignments_rec.description
714 );
715
716 /* Added for bug 3051110 */
717
718 wf_engine.SetItemAttrNumber(itemtype => p_wf_item_type
719 , Itemkey => l_itemkey
720 , aname => 'TRANSFER_PRICE_RATE'
721 , avalue => l_assignments_rec.transfer_price_rate);
722
723 wf_engine.SetItemAttrtext(itemtype => p_wf_item_type
724 , Itemkey => l_itemkey
725 , aname => 'TRANSFER_PR_RATE_CURR'
726 , avalue => l_assignments_rec.transfer_pr_rate_curr);
727
728 wf_engine.SetItemAttrText
729 ( itemtype => p_wf_item_type
730 , itemkey => l_itemkey
731 , aname => 'ADDITIONAL_INFORMATION'
732 , avalue =>
733 l_assignments_rec.additional_information
734 );
735
736 wf_engine.SetItemAttrDate
737 (itemtype => p_wf_item_type
738 , itemkey => l_itemkey
739 , aname => 'START_DATE'
740 , avalue => l_assignments_rec.start_date
741 );
742
743 wf_engine.SetItemAttrDate
744 (itemtype => p_wf_item_type
745 , itemkey => l_itemkey
746 , aname => 'END_DATE'
747 , avalue => l_assignments_rec.end_date
748 );
749
750 wf_engine.SetItemAttrNumber
751 ( itemtype => p_wf_item_type
752 , itemkey => l_itemkey
753 , aname => 'ASSIGNMENT_DURATION'
754 , avalue =>
755 (trunc(l_assignments_rec.end_date) -
756 trunc(l_assignments_rec.start_date)+1)
757 );
758
759 wf_engine.SetItemAttrNumber
760 ( itemtype => p_wf_item_type
761 , itemkey => l_itemkey
762 , aname => 'ASSIGNMENT_EFFORT'
763 , avalue => l_assignments_rec.assignment_effort
764 );
765
766 -- Start Additions by RM for bug 2274426
767 wf_engine.SetItemAttrNumber
768 ( itemtype => p_wf_item_type
769 , itemkey => l_itemkey
770 , aname => 'REVENUE_BILL_RATE'
771 , avalue => l_assignments_rec.revenue_bill_rate
772 );
773 wf_engine.SetItemAttrText
774 ( itemtype => p_wf_item_type
775 , itemkey => l_itemkey
776 , aname => 'REVENUE_BILL_RATE_CURR'
777 , avalue => l_assignments_rec.revenue_currency_code
778 );
779 wf_engine.SetItemAttrNumber
780 ( itemtype => p_wf_item_type
781 , itemkey => l_itemkey
782 , aname => 'BILL_RATE_OVERRIDE'
783 , avalue => l_assignments_rec.bill_rate_override
784 );
785 wf_engine.SetItemAttrText
786 ( itemtype => p_wf_item_type
787 , itemkey => l_itemkey
788 , aname => 'BILL_RATE_OVERRIDE_CURR'
789 , avalue => l_assignments_rec.bill_rate_curr_override
790 );
791 IF l_assignments_rec.markup_percent_override IS NOT NULL THEN
792 wf_engine.SetItemAttrText
793 ( itemtype => p_wf_item_type
794 , itemkey => l_itemkey
795 , aname => 'MARKUP_PCT_OVERRIDE'
796 , avalue => to_char(l_assignments_rec.markup_percent_override)||'%'
797 );
798 ELSE
799 wf_engine.SetItemAttrText
800 ( itemtype => p_wf_item_type
801 , itemkey => l_itemkey
802 , aname => 'MARKUP_PCT_OVERRIDE'
803 , avalue => to_char(l_assignments_rec.markup_percent_override)
804 );
805 END IF;
806 wf_engine.SetItemAttrText
807 ( itemtype => p_wf_item_type
808 , itemkey => l_itemkey
809 , aname => 'TP_AMT_TYPE_NAME'
810 , avalue => l_assignments_rec.fcst_tp_amount_type_name
811 );
812 wf_engine.SetItemAttrNumber
813 ( itemtype => p_wf_item_type
814 , itemkey => l_itemkey
815 , aname => 'TP_RATE_OVERRIDE'
816 , avalue => l_assignments_rec.tp_rate_override
817 );
818 wf_engine.SetItemAttrText
819 ( itemtype => p_wf_item_type
820 , itemkey => l_itemkey
821 , aname => 'TP_RATE_OVERRIDE_CURR'
822 , avalue => l_assignments_rec.tp_currency_override
823 );
824 IF l_assignments_rec.tp_calc_base_code_override IS NOT NULL THEN
825 open csr_get_override_basis_name(l_assignments_rec.tp_calc_base_code_override);
826 fetch csr_get_override_basis_name into l_override_basis_name;
827 close csr_get_override_basis_name;
828 END IF;
829 wf_engine.SetItemAttrText
830 ( itemtype => p_wf_item_type
831 , itemkey => l_itemkey
832 , aname => 'OVERRIDE_BASIS_NAME'
833 , avalue => l_override_basis_name
834 );
835 IF l_assignments_rec.tp_percent_applied_override IS NOT NULL THEN
836 IF l_override_basis_name IS NOT NULL THEN
837 wf_engine.SetItemAttrText
838 ( itemtype => p_wf_item_type
839 , itemkey => l_itemkey
840 , aname => 'TP_PCT_APPLIED_OVERRIDE'
841 , avalue => ', '||to_char(l_assignments_rec.tp_percent_applied_override)||'%'
842 );
843 ELSE
844 wf_engine.SetItemAttrText
845 ( itemtype => p_wf_item_type
846 , itemkey => l_itemkey
847 , aname => 'TP_PCT_APPLIED_OVERRIDE'
848 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)||'%'
849 );
850 END IF;
851 ELSE
852 wf_engine.SetItemAttrText
853 ( itemtype => p_wf_item_type
854 , itemkey => l_itemkey
855 , aname => 'TP_PCT_APPLIED_OVERRIDE'
856 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)
857 );
858 END IF;
859 wf_engine.SetItemAttrText
860 ( itemtype => p_wf_item_type
861 , itemkey => l_itemkey
862 , aname => 'WORK_TYPE_NAME'
863 , avalue => l_assignments_rec.work_type_name
864 );
865 -- End of Additions by RM
866
867 wf_engine.SetItemAttrText
868 ( itemtype => p_wf_item_type
869 , itemkey => l_itemkey
870 , aname => 'CURRENT_ASGMT_STATUS_CODE'
871 , avalue => l_assignments_rec.apprvl_status_code
872 );
873
874 wf_engine.SetItemAttrText
875 ( itemtype => p_wf_item_type
876 , itemkey => l_itemkey
877 , aname => 'NOTE_TO_APPROVER'
878 , avalue => l_assignments_rec.note_to_approver
879 );
880 wf_engine.SetItemAttrText
881 ( itemtype => p_wf_item_type
882 , itemkey => l_itemkey
883 , aname => 'ASGMT_FAILURE_STATUS_CODE'
884 , avalue => l_wf_failure_status_code
885 );
886
887 wf_engine.SetItemAttrText
888 ( itemtype => p_wf_item_type
889 , itemkey => l_itemkey
890 , aname => 'ASGMT_SUCCESS_STATUS_CODE'
891 , avalue => l_wf_success_status_code
892 );
893 wf_engine.SetItemAttrText
894 ( itemtype => p_wf_item_type
895 , itemkey => l_itemkey
896 , aname => 'PROJECT_STATUS_NAME'
897 , avalue => l_project_status_name
898 );
899
900 wf_engine.SetItemAttrText
901 ( itemtype => p_wf_item_type
902 , itemkey => l_itemkey
903 , aname => 'REAPPROVAL_FLAG'
904 , avalue => l_reapproval_flag
905 );
906 -- Set the previously approved values , if it is a re-approval
907 IF l_reapproval_flag = 'Y' THEN
908 wf_engine.SetItemAttrNumber
909 ( itemtype => p_wf_item_type
910 , itemkey => l_itemkey
911 , aname => 'PREV_DURATION'
912 , avalue => l_prev_asgmt_info_rec.prev_duration );
913 wf_engine.SetItemAttrNumber
914 ( itemtype => p_wf_item_type
915 , itemkey => l_itemkey
916 , aname => 'PREV_EFFORT'
917 , avalue => l_prev_asgmt_info_rec.prev_effort );
918 END IF;
919
920 -- Set resource related attributes
921
922 wf_engine.SetItemAttrNumber
923 ( itemtype => p_wf_item_type
924 , itemkey => l_itemkey
925 , aname => 'RESOURCE_ID'
926 , avalue => l_resource_rec.resource_id
927 );
928
929 wf_engine.SetItemAttrNumber
930 ( itemtype => p_wf_item_type
931 , itemkey => l_itemkey
932 , aname => 'RESOURCE_PERSON_ID'
933 , avalue => l_resource_person_id
934 );
935
936 wf_engine.SetItemAttrText
937 ( itemtype => p_wf_item_type
938 , itemkey => l_itemkey
939 , aname => 'RESOURCE_NAME'
940 , avalue => l_resource_rec.resource_name
941 );
942
943 wf_engine.SetItemAttrText
944 ( itemtype => p_wf_item_type
945 , itemkey => l_itemkey
946 , aname => 'RESOURCE_ORGANIZATION'
947 , avalue =>
948 l_resource_rec.resource_organization_name
949 );
950
951 -- Set project manager attributes
952
953 wf_engine.SetItemAttrNumber
954 ( itemtype => p_wf_item_type
955 , itemkey => l_itemkey
956 , aname => 'PROJECT_MANAGER_PERSON_ID'
957 , avalue => l_project_manager_person_id
958 );
959
960 wf_engine.SetItemAttrText
961 ( itemtype => p_wf_item_type
962 , itemkey => l_itemkey
963 , aname => 'PROJECT_MANAGER_NAME'
964 , avalue => l_project_manager_name
965 );
966
967 wf_engine.SetItemAttrText
968 ( itemtype => p_wf_item_type
969 , itemkey => l_itemkey
970 , aname => 'PROJECT_MANAGER_UNAME'
971 , avalue =>
972 l_project_manager_uname
973 );
974 -- Set the other attributes
975
976 wf_engine.SetItemAttrNumber
977 ( itemtype => p_wf_item_type
978 , itemkey => l_itemkey
979 , aname => 'NUMBER_OF_APPROVERS'
980 , avalue => l_number_of_approvers
981 );
982
983 wf_engine.SetItemAttrNumber
984 ( itemtype => p_wf_item_type
985 , itemkey => l_itemkey
986 , aname => 'NUMBER_OF_APPRVL_NF_RECIPIENTS'
987 , avalue => l_number_of_apprvl_nf_rects
988 );
989
990 wf_engine.SetItemAttrNumber
991 ( itemtype => p_wf_item_type
992 , itemkey => l_itemkey
993 , aname => 'NUMBER_OF_REJECT_NF_RECIPIENTS'
994 , avalue => l_number_of_reject_nf_rects
995 );
996
997 wf_engine.SetItemAttrNumber
998 ( itemtype => p_wf_item_type
999 , itemkey => l_itemkey
1000 , aname => 'NUMBER_OF_CANCEL_NF_RECIPIENTS'
1001 , avalue => l_number_of_reject_nf_rects
1002 );
1003
1004
1005 wf_engine.SetItemAttrNumber
1006 ( itemtype => p_wf_item_type
1007 , itemkey => l_itemkey
1008 , aname => 'APPROVER_LOOP_COUNTER'
1009 , avalue => 0
1010 );
1011 wf_engine.SetItemAttrNumber
1012 ( itemtype => p_wf_item_type
1013 , itemkey => l_itemkey
1014 , aname => 'APPROVAL_NF_LOOP_COUNTER'
1015 , avalue => 0
1016 );
1017 wf_engine.SetItemAttrNumber
1018 ( itemtype => p_wf_item_type
1019 , itemkey => l_itemkey
1020 , aname => 'REJECTION_NF_LOOP_COUNTER'
1021 , avalue => 0
1022 );
1023
1024 wf_engine.SetItemAttrNumber
1025 ( itemtype => p_wf_item_type
1026 , itemkey => l_itemkey
1027 , aname => 'CANCELLATION_NF_LOOP_COUNTER'
1028 , avalue => 0
1029 );
1030
1031 wf_engine.SetItemAttrNumber
1032 ( itemtype => p_wf_item_type
1033 , itemkey => l_itemkey
1034 , aname => 'APPROVER_1_PERSON_ID'
1035 , avalue => p_approver1_person_id
1036 );
1037
1038 wf_engine.SetItemAttrNumber
1039 ( itemtype => p_wf_item_type
1040 , itemkey => l_itemkey
1041 , aname => 'APPROVER_2_PERSON_ID'
1042 , avalue => p_approver2_person_id
1043 );
1044
1045 wf_engine.SetItemAttrText
1046 ( itemtype => p_wf_item_type
1047 , itemkey => l_itemkey
1048 , aname => 'APPROVER1_USER_NAME'
1049 , avalue => l_approver1_user_name
1050 );
1051
1052 wf_engine.SetItemAttrText
1053 ( itemtype => p_wf_item_type
1054 , itemkey => l_itemkey
1055 , aname => 'APPROVER2_USER_NAME'
1056 , avalue => l_approver2_user_name
1057 );
1058 wf_engine.SetItemAttrText
1059 ( itemtype => p_wf_item_type
1060 , itemkey => l_itemkey
1061 , aname => 'APPROVER_1_TYPE'
1062 , avalue => l_approver1_type
1063 );
1064 wf_engine.SetItemAttrText
1065 ( itemtype => p_wf_item_type
1066 , itemkey => l_itemkey
1067 , aname => 'APPROVER_2_TYPE'
1068 , avalue => l_approver2_type
1069 );
1070 wf_engine.SetItemAttrText
1071 ( itemtype => p_wf_item_type
1072 , itemkey => l_itemkey
1073 , aname => 'APPROVAL_NF_REC1_USER_NAME'
1074 , avalue => l_apprvl_nf_rec1_uname
1075 );
1076
1077 wf_engine.SetItemAttrText
1078 ( itemtype => p_wf_item_type
1079 , itemkey => l_itemkey
1080 , aname => 'APPROVAL_NF_REC1_USER_TYPE'
1081 , avalue => l_apprvl_nf_rec1_utype
1082 );
1083 wf_engine.SetItemAttrNumber
1084 ( itemtype => p_wf_item_type
1085 , itemkey => l_itemkey
1086 , aname => 'APPROVAL_NF_REC1_PERSON_ID'
1087 , avalue => l_apprvl_nf_rec1_person_id
1088 );
1089 wf_engine.SetItemAttrText
1090 ( itemtype => p_wf_item_type
1091 , itemkey => l_itemkey
1092 , aname => 'APPROVAL_NF_REC2_USER_NAME'
1093 , avalue => l_apprvl_nf_rec2_uname
1094 );
1095 wf_engine.SetItemAttrText
1096 ( itemtype => p_wf_item_type
1097 , itemkey => l_itemkey
1098 , aname => 'APPROVAL_NF_REC2_USER_TYPE'
1099 , avalue => l_apprvl_nf_rec2_utype
1100 );
1101 wf_engine.SetItemAttrNumber
1102 ( itemtype => p_wf_item_type
1103 , itemkey => l_itemkey
1104 , aname => 'APPROVAL_NF_REC2_PERSON_ID'
1105 , avalue => l_apprvl_nf_rec2_person_id
1106 );
1107 wf_engine.SetItemAttrText
1108 ( itemtype => p_wf_item_type
1109 , itemkey => l_itemkey
1110 , aname => 'APPROVAL_NF_REC3_USER_NAME'
1111 , avalue => l_apprvl_nf_rec3_uname
1112 );
1113 wf_engine.SetItemAttrText
1114 ( itemtype => p_wf_item_type
1115 , itemkey => l_itemkey
1116 , aname => 'APPROVAL_NF_REC3_USER_TYPE'
1117 , avalue => l_apprvl_nf_rec3_utype
1118 );
1119 wf_engine.SetItemAttrNumber
1120 ( itemtype => p_wf_item_type
1121 , itemkey => l_itemkey
1122 , aname => 'APPROVAL_NF_REC3_PERSON_ID'
1123 , avalue => l_apprvl_nf_rec3_person_id
1124 );
1125 -- Ramesh 07/11/00
1126 IF l_apprvl_nf_rec4_uname IS NOT NULL THEN
1127 wf_engine.SetItemAttrText
1128 ( itemtype => p_wf_item_type
1129 , itemkey => l_itemkey
1130 , aname => 'APPROVAL_NF_REC4_USER_NAME'
1131 , avalue => l_apprvl_nf_rec4_uname
1132 );
1133 wf_engine.SetItemAttrText
1134 ( itemtype => p_wf_item_type
1135 , itemkey => l_itemkey
1136 , aname => 'APPROVAL_NF_REC4_USER_TYPE'
1137 , avalue => l_apprvl_nf_rec4_utype
1138 );
1139 wf_engine.SetItemAttrNumber
1140 ( itemtype => p_wf_item_type
1141 , itemkey => l_itemkey
1142 , aname => 'APPROVAL_NF_REC4_PERSON_ID'
1143 , avalue => l_apprvl_nf_rec4_person_id
1144 );
1145 END IF;
1146 -- End 07/11/00 changes
1147
1148 wf_engine.SetItemAttrText
1149 ( itemtype => p_wf_item_type
1150 , itemkey => l_itemkey
1151 , aname => 'REJECT_NF_REC1_USER_NAME'
1152 , avalue => l_reject_nf_rec1_uname
1153 );
1154 wf_engine.SetItemAttrText
1155 ( itemtype => p_wf_item_type
1156 , itemkey => l_itemkey
1157 , aname => 'REJECT_NF_REC1_USER_TYPE'
1158 , avalue => l_reject_nf_rec1_utype
1159 );
1160 wf_engine.SetItemAttrNumber
1161 ( itemtype => p_wf_item_type
1162 , itemkey => l_itemkey
1163 , aname => 'REJECT_NF_REC1_PERSON_ID'
1164 , avalue => l_reject_nf_rec1_person_id
1165 );
1166 wf_engine.SetItemAttrText
1167 ( itemtype => p_wf_item_type
1168 , itemkey => l_itemkey
1169 , aname => 'REJECT_NF_REC2_USER_NAME'
1170 , avalue => l_reject_nf_rec2_uname
1171 );
1172 wf_engine.SetItemAttrText
1173 ( itemtype => p_wf_item_type
1174 , itemkey => l_itemkey
1175 , aname => 'REJECT_NF_REC2_USER_TYPE'
1176 , avalue => l_reject_nf_rec2_utype
1177 );
1178 wf_engine.SetItemAttrNumber
1179 ( itemtype => p_wf_item_type
1180 , itemkey => l_itemkey
1181 , aname => 'REJECT_NF_REC2_PERSON_ID'
1182 , avalue => l_reject_nf_rec2_person_id
1183 );
1184 wf_engine.SetItemAttrText
1185 ( itemtype => p_wf_item_type
1186 , itemkey => l_itemkey
1187 , aname => 'REJECT_NF_REC3_USER_NAME'
1188 , avalue => l_reject_nf_rec3_uname
1189 );
1190 wf_engine.SetItemAttrText
1191 ( itemtype => p_wf_item_type
1192 , itemkey => l_itemkey
1193 , aname => 'REJECT_NF_REC3_USER_TYPE'
1194 , avalue => l_reject_nf_rec3_utype
1195 );
1196 wf_engine.SetItemAttrNumber
1197 ( itemtype => p_wf_item_type
1198 , itemkey => l_itemkey
1199 , aname => 'REJECT_NF_REC3_PERSON_ID'
1200 , avalue => l_reject_nf_rec3_person_id
1201 );
1202 -- Ramesh 07/11/00 changes
1203 IF l_reject_nf_rec4_uname IS NOT NULL THEN
1204 wf_engine.SetItemAttrText
1205 ( itemtype => p_wf_item_type
1206 , itemkey => l_itemkey
1207 , aname => 'REJECT_NF_REC4_USER_NAME'
1208 , avalue => l_reject_nf_rec4_uname
1209 );
1210 wf_engine.SetItemAttrText
1211 ( itemtype => p_wf_item_type
1212 , itemkey => l_itemkey
1213 , aname => 'REJECT_NF_REC4_USER_TYPE'
1214 , avalue => l_reject_nf_rec4_utype
1215 );
1216 wf_engine.SetItemAttrNumber
1217 ( itemtype => p_wf_item_type
1218 , itemkey => l_itemkey
1219 , aname => 'REJECT_NF_REC4_PERSON_ID'
1220 , avalue => l_reject_nf_rec4_person_id
1221 );
1222 END IF;
1223 -- End 07/11/00 changes
1224
1225 wf_engine.SetItemAttrText
1226 ( itemtype => p_wf_item_type
1227 , itemkey => l_itemkey
1228 , aname => 'CANCEL_NF_REC1_USER_NAME'
1229 , avalue => l_cancel_nf_rec1_uname
1230 );
1231 wf_engine.SetItemAttrText
1232 ( itemtype => p_wf_item_type
1233 , itemkey => l_itemkey
1234 , aname => 'CANCEL_NF_REC1_USER_TYPE'
1235 , avalue => l_cancel_nf_rec1_utype
1236 );
1237 wf_engine.SetItemAttrNumber
1238 ( itemtype => p_wf_item_type
1239 , itemkey => l_itemkey
1240 , aname => 'CANCEL_NF_REC1_PERSON_ID'
1241 , avalue => l_cancel_nf_rec1_person_id
1242 );
1243 wf_engine.SetItemAttrText
1244 ( itemtype => p_wf_item_type
1245 , itemkey => l_itemkey
1246 , aname => 'CANCEL_NF_REC2_USER_NAME'
1247 , avalue => l_cancel_nf_rec2_uname
1248 );
1249 wf_engine.SetItemAttrText
1250 ( itemtype => p_wf_item_type
1251 , itemkey => l_itemkey
1252 , aname => 'CANCEL_NF_REC2_USER_TYPE'
1253 , avalue => l_cancel_nf_rec2_utype
1254 );
1255 wf_engine.SetItemAttrNumber
1256 ( itemtype => p_wf_item_type
1257 , itemkey => l_itemkey
1258 , aname => 'CANCEL_NF_REC2_PERSON_ID'
1259 , avalue => l_cancel_nf_rec2_person_id
1260 );
1261 wf_engine.SetItemAttrText
1262 ( itemtype => p_wf_item_type
1263 , itemkey => l_itemkey
1264 , aname => 'CANCEL_NF_REC3_USER_NAME'
1265 , avalue => l_cancel_nf_rec3_uname
1266 );
1267 wf_engine.SetItemAttrText
1268 ( itemtype => p_wf_item_type
1269 , itemkey => l_itemkey
1270 , aname => 'CANCEL_NF_REC3_USER_TYPE'
1271 , avalue => l_cancel_nf_rec3_utype
1272 );
1273 wf_engine.SetItemAttrNumber
1274 ( itemtype => p_wf_item_type
1275 , itemkey => l_itemkey
1276 , aname => 'CANCEL_NF_REC3_PERSON_ID'
1277 , avalue => l_cancel_nf_rec3_person_id
1278 );
1279 -- Ramesh 07/11/00 changes
1280 IF l_cancel_nf_rec4_uname IS NOT NULL THEN
1281 wf_engine.SetItemAttrText
1282 ( itemtype => p_wf_item_type
1283 , itemkey => l_itemkey
1284 , aname => 'CANCEL_NF_REC4_USER_NAME'
1285 , avalue => l_cancel_nf_rec4_uname
1286 );
1287 wf_engine.SetItemAttrText
1288 ( itemtype => p_wf_item_type
1289 , itemkey => l_itemkey
1290 , aname => 'CANCEL_NF_REC4_USER_TYPE'
1291 , avalue => l_cancel_nf_rec4_utype
1292 );
1293 wf_engine.SetItemAttrNumber
1294 ( itemtype => p_wf_item_type
1295 , itemkey => l_itemkey
1296 , aname => 'CANCEL_NF_REC4_PERSON_ID'
1297 , avalue => l_cancel_nf_rec4_person_id
1298 );
1299 END IF;
1300 -- End 07/11/00 changes
1301
1302 -- Set the item attributes for apprvl item type
1303 -- and apprvl item key . This would be the item type
1304 -- and item key of the approval process
1305 IF (p_apprvl_item_type IS NOT NULL AND p_apprvl_item_key
1306 IS NOT NULL ) THEN
1307 wf_engine.SetItemAttrText
1308 ( itemtype => p_wf_item_type
1309 , itemkey => l_itemkey
1310 , aname => 'APPRVL_ITEM_TYPE'
1311 , avalue => p_apprvl_item_type
1312 );
1313 wf_engine.SetItemAttrText
1314 ( itemtype => p_wf_item_type
1315 , itemkey => l_itemkey
1316 , aname => 'APPRVL_ITEM_KEY'
1317 , avalue => p_apprvl_item_key
1318 );
1319 /*Bug 3817940 : Code addition Starts*/
1320 if p_wf_process = 'PA_APRVL_NF_SP' or p_wf_process = 'PA_CANCEL_NF_SP' or p_wf_process = 'PA_REJ_NF_SP'
1321 Then
1322 l_last_approver_uname := wf_engine.GetItemAttrText
1323 ( itemtype => p_apprvl_item_type
1324 , itemkey => p_apprvl_item_key
1325 , aname => 'APPROVER_UNAME');
1326
1327 wf_engine.SetItemAttrText
1328 ( itemtype => p_wf_item_type
1329 , itemkey => l_itemkey
1330 , aname => 'FROM_ROLE_VALUE1'
1331 , avalue => l_last_approver_uname
1332 );
1333 END IF;
1334 /*Bug 3817940 : Code addition ends*/
1335 END IF;
1336
1337 --
1338 --Bug 1733307: set URL
1339 --
1340 /*Code modified for bug 6408552*/
1341 /*For Admin Assignment, we should call with paCalledPage as 'AdminAsmt'*/
1342 IF (l_assignments_rec.assignment_type = 'STAFFED_ADMIN_ASSIGNMENT') THEN
1343
1344 l_asgmt_details_url :=
1345 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_ASMT_LAYOUT&paCalledPage=AdminAsmt&paAssignmentId='||p_assignment_id||'&addBreadCrumb=RP';
1346
1347 ELSE -- Old code that was being called generically
1348
1349 l_asgmt_details_url :=
1350 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_ASMT_LAYOUT&paCalledPage=ProjStaffedAsmt&paAssignmentId='||p_assignment_id||'&addBreadCrumb=RP';
1351
1352 END IF ;
1353 /*Code modification ends for bug 6408552*/
1354 l_resource_schedules_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_VIEW_RESOURCE_LAYOUT&paResourceId='||l_resource_rec.resource_id||'&addBreadCrumb=RP';
1355
1356 wf_engine.SetItemAttrText
1357 ( itemtype => p_wf_item_type
1358 , itemkey => l_itemkey
1359 , aname => 'ASSIGNMENT_DETAILS_URL_INFO'
1360 , avalue => l_asgmt_details_url
1361 );
1362 wf_engine.SetItemAttrText
1363 ( itemtype => p_wf_item_type
1364 , itemkey => l_itemkey
1365 , aname => 'RESOURCE_DETAILS_URL_INFO'
1366 , avalue => l_resource_details_url
1367 );
1368 wf_engine.SetItemAttrText
1369 ( itemtype => p_wf_item_type
1370 , itemkey => l_itemkey
1371 , aname => 'RESOURCE_SCHEDULES_URL_INFO'
1372 , avalue => l_resource_schedules_url
1373 );
1374
1375 wf_engine.SetItemAttrNumber
1376 ( itemtype => p_wf_item_type
1377 , itemkey => l_itemkey
1378 , aname => 'CONFLICT_GROUP_ID'
1379 , avalue => p_conflict_group_id
1380 );
1381
1382 -- Set workflow started by attributes
1383 -- Get the current user_id using FND_GLOBAL.USER_ID
1384 -- Get the user name from the user id
1385 -- Set the workflow started by user name
1386 l_workflow_started_by_uname := FND_GLOBAL.USER_NAME;
1387 wf_engine.SetItemAttrText
1388 ( itemtype => p_wf_item_type
1389 , itemkey => l_itemkey
1390 , aname => 'WORKFLOW_STARTED_BY_UNAME'
1391 , avalue => l_workflow_started_by_uname
1392 );
1393
1394 -- Call the client extensions to set the waiting period
1395 -- for reminders as well as the number of times to remind
1396 PA_CLIENT_EXTN_ASGMT_WF.Set_Timeout_And_Reminders
1397 ( p_assignment_id => l_assignments_rec.assignment_id
1398 ,p_project_id => l_projects_rec.project_id
1399 ,x_waiting_time => l_waiting_time
1400 ,x_number_of_reminders => l_number_of_reminders );
1401
1402 IF l_waiting_time IS NULL THEN
1403 -- If the client extension did not return a valid
1404 -- waiting time , then set it to the default defined
1405 -- by the product , which is 3 days (expressed in minutes)
1406 -- (3 * 24 * 60) = 4320
1407 l_waiting_time := 4320;
1408 END IF;
1409 IF l_number_of_reminders IS NULL THEN
1410 -- If the client extension did not return a valid
1411 -- waiting time , then set it to the default defined
1412 -- by the product , which is 3
1413 l_number_of_reminders := 3;
1414 END IF;
1415 -- Now set the appropriate attributes in the workflow process
1416 wf_engine.SetItemAttrNumber
1417 ( itemtype => p_wf_item_type
1418 , itemkey => l_itemkey
1419 , aname => 'TIMEOUT_WAITING_PERIOD'
1420 , avalue => l_waiting_time
1421 );
1422
1423 wf_engine.SetItemAttrNumber
1424 ( itemtype => p_wf_item_type
1425 , itemkey => l_itemkey
1426 , aname => 'NUMBER_OF_REMINDERS'
1427 , avalue => l_number_of_reminders
1428 );
1429 -- Now start the WF process
1430 wf_engine.StartProcess ( itemtype => p_wf_item_type
1431 , itemkey => l_itemkey );
1432 PA_WORKFLOW_UTILS.Insert_WF_Processes
1433 (p_wf_type_code => 'ASSIGNMENT_APPROVAL'
1434 ,p_item_type => p_wf_item_type
1435 ,p_item_key => l_itemkey
1436 ,p_entity_key1 => to_char(l_projects_rec.project_id)
1437 ,p_entity_key2 => to_char(p_assignment_id)
1438 ,p_description => NULL
1439 ,p_err_code => l_err_code
1440 ,p_err_stage => l_err_stage
1441 ,p_err_stack => l_err_stack
1442 );
1443 --Setting the original value
1444 wf_engine.threshold := l_save_threshold;
1445
1446 -- dbms_output.put_line ('after pa_workflow_utils ');
1447 EXCEPTION
1448 WHEN OTHERS THEN
1449 --Setting the original value
1450 wf_engine.threshold := l_save_threshold;
1451
1452 -- dbms_output.put_line ('others exception raised ');
1453 -- dbms_output.put_line ('error is '||SQLERRM);
1454
1455 -- 4537865 : RESET other OUT params also
1456 x_msg_data := SUBSTRB(SQLERRM,1,240);
1457 x_error_message_code := SQLCODE ;
1458 -- 4537865 : End
1459 fnd_msg_pub.add_exc_msg
1460 (p_pkg_name => 'PA_ASGMT_WFSTD',
1461 p_procedure_name => pa_debug.g_err_stack );
1462 x_msg_count := fnd_msg_pub.count_msg;
1463 x_return_status:= FND_API.G_RET_STS_UNEXP_ERROR;
1464 END Start_Workflow ;
1465
1466
1467
1468 PROCEDURE get_workflow_process_info
1469 (p_status_code IN VARCHAR2
1470 ,x_wf_item_type OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1471 ,x_wf_process OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1472 ,x_wf_type OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1473 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
1474 ,x_msg_data OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1475 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1476 ,x_error_message_code OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
1477 CURSOR l_stus_csr IS
1478 SELECT ps.wf_success_status_code,
1479 ps.wf_failure_status_code,
1480 ps.workflow_item_type,
1481 ps.workflow_process,
1482 ps.project_system_status_code ,
1483 ps.enable_wf_flag
1484 FROM pa_project_statuses ps
1485 WHERE project_status_code = p_status_code;
1486
1487 l_stus_rec l_stus_csr%ROWTYPE;
1488 l_msg_count NUMBER :=0;
1489 l_msg_index_out NUMBER ;
1490 l_msg_data VARCHAR2(2000);
1491 l_data VARCHAR2(2000);
1492 BEGIN
1493 -- This procedure returns whether wf is enabled for the given
1494 -- assignment approval status and if so, the item type and process
1495 -- It also returns whether the WF is an approval WF or an FYI WF
1496 -- The logic is
1497 -- If the approval status is a SUBMITTED status , then the
1498 -- workflow is an APPROVAL WORKFLOW. else if the status
1499 -- is an APPROVED or REJECTED status, the workflow is a FYI only
1500 x_return_status := FND_API.G_RET_STS_SUCCESS;
1501 x_msg_count := 0;
1502 pa_debug.init_err_stack ('pa_asgmt_wfstd.get_workflow_process_info');
1503 OPEN l_stus_csr;
1504 FETCH l_stus_csr INTO l_stus_rec;
1505 IF l_stus_csr%NOTFOUND THEN
1506 x_return_status := FND_API.G_RET_STS_ERROR;
1507 x_error_message_code := 'PA_INVALID_STATUS_CODE';-- msg already avail
1508 pa_utils.add_message (p_app_short_name => 'PA',
1509 p_msg_name => 'PA_INVALID_STATUS_CODE');
1510 l_msg_count := l_msg_count + 1;
1511 CLOSE l_stus_csr;
1512 -- RETURN;
1513 ELSE
1514 CLOSE l_stus_csr;
1515 END IF;
1516
1517 IF l_msg_count > 0 THEN
1518 IF l_msg_count = 1 THEN
1519 pa_interface_utils_pub.get_messages
1520 (p_encoded => FND_API.G_TRUE,
1521 p_msg_index => 1,
1522 p_msg_count => l_msg_count,
1523 p_msg_data => l_msg_data ,
1524 p_data => l_data,
1525 p_msg_index_out => l_msg_index_out );
1526 x_msg_data := l_data;
1527 x_msg_count := l_msg_count;
1528 ELSE
1529 x_msg_count := l_msg_count;
1530 END IF;
1531 pa_debug.reset_err_stack;
1532 x_return_status := FND_API.G_RET_STS_ERROR;
1533 RETURN;
1534 END IF;
1535
1536 IF NVL(l_stus_rec.enable_wf_flag,'N') = 'N' THEN
1537 x_wf_type := 'NOT_ENABLED';
1538 END IF ;
1539 IF NVL(l_stus_rec.enable_wf_flag,'N') = 'Y' THEN
1540 x_wf_item_type := l_stus_rec.workflow_item_type;
1541 x_wf_process := l_stus_rec.workflow_process;
1542 IF l_stus_rec.project_system_status_code =
1543 'ASGMT_APPRVL_SUBMITTED' THEN
1544 x_wf_type := 'APPROVAL_PROCESS';
1545 ELSIF l_stus_rec.project_system_status_code IN
1546 ('ASGMT_APPRVL_APPROVED','ASGMT_APPRVL_REJECTED','ASGMT_APPRVL_CANCELED') THEN
1547 x_wf_type := 'FYI_NF';
1548 END IF;
1549 END IF;
1550 EXCEPTION
1551 WHEN OTHERS THEN
1552 -- 4537865 : RESET other OUT params also
1553 x_msg_data := SUBSTRB(SQLERRM,1,240);
1554 x_error_message_code := SQLCODE ;
1555 x_wf_item_type := NULL ;
1556 x_wf_process := NULL ;
1557 x_wf_type := NULL ;
1558
1559 -- 4537865 : End
1560 fnd_msg_pub.add_exc_msg
1561 (p_pkg_name => 'PA_ASGMT_WFSTD',
1562 p_procedure_name => pa_debug.g_err_stack );
1563 x_msg_count := fnd_msg_pub.count_msg;
1564 x_return_status:= FND_API.G_RET_STS_UNEXP_ERROR;
1565 RAISE ;
1566 END Get_workflow_process_info ;
1567
1568 FUNCTION Is_approval_pending (p_assignment_id IN NUMBER) RETURN VARCHAR2
1569 IS
1570 CURSOR l_asgmt_csr IS
1571 SELECT NVL(pending_approval_flag,'N')
1572 FROM pa_project_assignments
1573 WHERE assignment_id = p_assignment_id;
1574 l_pending_approval_flag pa_project_assignments.pending_approval_flag%TYPE;
1575 BEGIN
1576 OPEN l_asgmt_csr;
1577 FETCH l_asgmt_csr INTO l_pending_approval_flag;
1578 IF l_asgmt_csr%NOTFOUND THEN
1579 l_pending_approval_flag := 'N';
1580 END IF;
1581 CLOSE l_asgmt_csr;
1582 RETURN l_pending_approval_flag;
1583 EXCEPTION
1584 WHEN OTHERS THEN
1585 RAISE ;
1586 END Is_Approval_Pending ;
1587
1588
1589
1590 PROCEDURE Generate_URL ( itemtype IN VARCHAR2
1591 , itemkey IN VARCHAR2
1592 , actid IN NUMBER
1593 , funcmode IN VARCHAR2
1594 , resultout OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1595 ) IS
1596
1597 l_asgmt_details_url VARCHAR2(600);
1598 l_resource_details_url VARCHAR2(600);
1599 l_resource_schedules_url VARCHAR2(600);
1600 l_view_conflict_url VARCHAR2(600);
1601 l_overcom_description VARCHAR2(600);
1602 l_resolve_conflicts_by_rmvl VARCHAR2(1);
1603 l_assignment_id NUMBER;
1604 l_resource_person_id NUMBER;
1605 l_resource_id NUMBER;
1606 l_conflict_group_id NUMBER;
1607 l_asgmt_start_date DATE;
1608 l_asgmt_end_date DATE;
1609 l_return_status VARCHAR2(1);
1610 l_msg_count NUMBER;
1611 l_msg_data VARCHAR2(2000);
1612
1613 l_asgmt_type pa_project_assignments.assignment_type%TYPE; /*Added for bug 6408552*/
1614 BEGIN
1615
1616 pa_debug.init_err_stack ('pa_asgmt_wfstd.Generate_URL');
1617 -- Return if WF Not Running
1618 IF (funcmode <> wf_engine.eng_run) THEN
1619 resultout := wf_engine.eng_null;
1620 RETURN;
1621 END IF;
1622 l_assignment_id := wf_engine.GetItemAttrNumber
1623 (itemtype => itemtype,
1624 itemkey => itemkey,
1625 aname => 'ASSIGNMENT_ID');
1626
1627 l_resource_person_id := wf_engine.GetItemAttrNumber
1628 (itemtype => itemtype,
1629 itemkey => itemkey,
1630 aname => 'RESOURCE_PERSON_ID');
1631
1632 l_resource_id := wf_engine.GetItemAttrNumber
1633 (itemtype => itemtype,
1634 itemkey => itemkey,
1635 aname => 'RESOURCE_ID');
1636
1637 l_asgmt_start_date := wf_engine.GetItemAttrDate
1638 (itemtype => itemtype,
1639 itemkey => itemkey,
1640 aname => 'START_DATE');
1641
1642 l_asgmt_end_date := wf_engine.GetItemAttrDate
1643 (itemtype => itemtype,
1644 itemkey => itemkey,
1645 aname => 'END_DATE');
1646
1647 l_conflict_group_id := wf_engine.GetItemAttrNumber
1648 (itemtype => itemtype,
1649 itemkey => itemkey,
1650 aname => 'CONFLICT_GROUP_ID');
1651
1652 /*Added for bug 6408552*/
1653 l_asgmt_type := wf_engine.GetItemAttrText
1654 (itemtype => itemtype,
1655 itemkey => itemkey,
1656 aname => 'ASSIGNMENT_TYPE');
1657 resultout := wf_engine.eng_completed||':'||'S';
1658 -- call to the generate url api goes here
1659 -- If unable to generate url return
1660 -- resultout := wf_engine.eng_completed||':'||'F';
1661 -- If such URL generation succeded then set the appropriate attributes
1662 -- so that it gets displayed in the NF
1663 /*Code modified for bug 6408552*/
1664 /*make url with paCalledPage as 'AdminAsmt' for an Admin Assignment*/
1665 IF (l_asgmt_type = 'STAFFED_ADMIN_ASSIGNMENT') THEN
1666
1667 l_asgmt_details_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_ASMT_LAYOUT'
1668 || '&paCalledPage=AdminAsmt&paAssignmentId=' || l_assignment_id
1669 ||'&addBreadCrumb=RP';
1670
1671 ELSE -- old code that was being called generically
1672
1673 l_asgmt_details_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_ASMT_LAYOUT'
1674 || '&paCalledPage=ProjStaffedAsmt&paAssignmentId=' || l_assignment_id
1675 ||'&addBreadCrumb=RP';
1676
1677 END IF ;
1678 /*Code modifications end for bug 6408552*/
1679 l_resource_schedules_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode='
1680 || 'PA_VIEW_RESOURCE_LAYOUT&paResourceId=' || l_resource_id
1681 || '&addBreadCrumb=RP';
1682
1683 wf_engine.SetItemAttrText
1684 ( itemtype => itemtype
1685 , itemkey => itemkey
1686 , aname => 'ASSIGNMENT_DETAILS_URL_INFO'
1687 , avalue => l_asgmt_details_url
1688 );
1689 wf_engine.SetItemAttrText
1690 ( itemtype => itemtype
1691 , itemkey => itemkey
1692 , aname => 'RESOURCE_DETAILS_URL_INFO'
1693 , avalue => l_resource_details_url
1694 );
1695 wf_engine.SetItemAttrText
1696 ( itemtype => itemtype
1697 , itemkey => itemkey
1698 , aname => 'RESOURCE_SCHEDULES_URL_INFO'
1699 , avalue => l_resource_schedules_url
1700 );
1701
1702 -- Display the overcommitment description and URL only when there is any conflict.
1703 IF (l_conflict_group_id IS NOT NULL) THEN
1704 PA_SCHEDULE_PVT.will_resolve_conflicts_by_rmvl
1705 ( p_conflict_group_id => l_conflict_group_id
1706 , x_resolve_conflicts_by_rmvl => l_resolve_conflicts_by_rmvl
1707 , x_msg_count => l_msg_count
1708 , x_msg_data => l_msg_data
1709 , x_return_status => l_return_status);
1710
1711 -- set overcommitment description
1712 IF (l_resolve_conflicts_by_rmvl = 'Y') THEN
1713 l_overcom_description := 'If approved, this assignment will result in the removal of conflicting '
1714 || 'hours from an existing assignment of the resource.';
1715 ELSE
1716 l_overcom_description := 'If approved, this assignment will result in an overcommitment of the resource.';
1717 END IF;
1718
1719 wf_engine.SetItemAttrText
1720 ( itemtype => itemtype
1721 , itemkey => itemkey
1722 , aname => 'OVERCOM_DESCRIPTION'
1723 , avalue => l_overcom_description );
1724
1725 -- set 'Number of Assignments Resulting in Resource Overcommitment -1/0' for single approval
1726 -- required notification.
1727 wf_engine.SetItemAttrNumber
1728 ( itemtype => itemtype
1729 , itemkey => itemkey
1730 , aname => 'NUMBER_OF_OVERCOM_ASGMT'
1731 , avalue => 1 );
1732 ELSE
1733 wf_engine.SetItemAttrNumber
1734 ( itemtype => itemtype
1735 , itemkey => itemkey
1736 , aname => 'NUMBER_OF_OVERCOM_ASGMT'
1737 , avalue => 0 );
1738 END IF; -- IF (l_conflict_group_id IS NULL)
1739
1740 -- set overcommitment url
1741 l_view_conflict_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_RES_OVERCOMMITMENT_LAYOUT'
1742 || '&paAssignmentId=' || l_assignment_id || '&paConflictGroupId=' || l_conflict_group_id
1743 || '&paCallingPage=Default&addBreadCrumb=RP';
1744
1745 wf_engine.SetItemAttrText
1746 ( itemtype => itemtype
1747 , itemkey => itemkey
1748 , aname => 'VIEW_CONFLICT_URL_INFO'
1749 , avalue => l_view_conflict_url );
1750
1751 pa_debug.reset_err_stack;
1752
1753 EXCEPTION
1754 WHEN OTHERS THEN
1755 WF_CORE.CONTEXT
1756 ('PA_ASGMT_WFSTD',
1757 'Generate_URL',
1758 itemtype,
1759 itemkey,
1760 to_char(actid),
1761 funcmode);
1762 resultout := wf_engine.eng_completed||':'||'F';
1763 RAISE;
1764
1765 END Generate_URL ;
1766
1767 PROCEDURE Generate_URL_failure
1768 ( itemtype IN VARCHAR2
1769 , itemkey IN VARCHAR2
1770 , actid IN NUMBER
1771 , funcmode IN VARCHAR2
1772 , resultout OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
1773 ) IS
1774 l_mesg VARCHAR2(240);
1775 BEGIN
1776 -- Return if WF Not Running
1777 IF (funcmode <> wf_engine.eng_run) THEN
1778 resultout := wf_engine.eng_null;
1779 RETURN;
1780 END IF;
1781 FND_MESSAGE.SET_NAME ('PA','PA_ASGMT_URL_GEN_FAILURE');
1782 l_mesg := FND_MESSAGE.GET;
1783 wf_engine.SetItemAttrText
1784 (itemtype => itemtype
1785 ,itemkey => itemkey
1786 ,aname => 'URL_FAILURE_INFO'
1787 ,avalue => l_mesg
1788 );
1789 EXCEPTION
1790 WHEN OTHERS THEN
1791 WF_CORE.CONTEXT
1792 ('PA_ASGMT_WFSTD',
1793 'Generate_URL_Failure',
1794 itemtype,
1795 itemkey,
1796 to_char(actid),
1797 funcmode);
1798 RAISE;
1799 END Generate_URL_failure;
1800
1801 PROCEDURE Start_New_WF (itemtype IN VARCHAR2
1802 , itemkey IN VARCHAR2
1803 , actid IN NUMBER
1804 , funcmode IN VARCHAR2
1805 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
1806
1807 l_new_item_type VARCHAR2(30);
1808 l_new_process VARCHAR2(30);
1809 l_new_item_key VARCHAR2(30);
1810 l_project_id NUMBER;
1811 l_assignment_id NUMBER;
1812 l_resource_person_id NUMBER;
1813 l_new_asgmt_status_code VARCHAR2(30);
1814 l_conflict_group_id NUMBER;
1815 l_msg_count NUMBER;
1816 l_msg_data VARCHAR2(200);
1817 l_error_message_code VARCHAR2(200);
1818 l_return_status VARCHAR2(30);
1819 BEGIN
1820 pa_debug.init_err_stack ('pa_asgmt_wfstd.start_new_wf');
1821 -- Return if WF Not Running
1822 IF (funcmode <> wf_engine.eng_run) THEN
1823 resultout := wf_engine.eng_null;
1824 RETURN;
1825 END IF;
1826 l_new_item_type := wf_engine.GetItemAttrText
1827 (itemtype => itemtype,
1828 itemkey => itemkey,
1829 aname => 'NEW_WF_ITEM_TYPE');
1830
1831 l_new_process := wf_engine.GetItemAttrText
1832 (itemtype => itemtype,
1833 itemkey => itemkey,
1834 aname => 'NEW_WF_PROCESS_NAME');
1835 IF (l_new_item_type IS NOT NULL AND
1836 l_new_process IS NOT NULL ) THEN
1837 -- Get the necessary details from the item attributes
1838 l_new_asgmt_status_code :=
1839 wf_engine.GetItemAttrText
1840 (itemtype => itemtype,
1841 itemkey => itemkey,
1842 aname => 'NEW_ASGMT_STATUS_CODE' );
1843 l_project_id := wf_engine.GetItemAttrNumber
1844 (itemtype => itemtype,
1845 itemkey => itemkey,
1846 aname => 'PROJECT_ID' );
1847 l_assignment_id := wf_engine.GetItemAttrNumber
1848 (itemtype => itemtype,
1849 itemkey => itemkey,
1850 aname => 'ASSIGNMENT_ID');
1851 l_resource_person_id := wf_engine.GetItemAttrNumber
1852 (itemtype => itemtype,
1853 itemkey => itemkey,
1854 aname => 'RESOURCE_PERSON_ID');
1855 l_conflict_group_id := wf_engine.GetItemAttrNumber
1856 (itemtype => itemtype,
1857 itemkey => itemkey,
1858 aname => 'CONFLICT_GROUP_ID');
1859
1860 Start_Workflow
1861 ( p_project_id => l_project_id
1862 , p_assignment_id => l_assignment_id
1863 , p_status_code => l_new_asgmt_status_code
1864 , p_person_id => l_resource_person_id
1865 , p_wf_item_type => l_new_item_type
1866 , p_wf_process => l_new_process
1867 , p_approver1_person_id => NULL
1868 , p_approver1_type => NULL
1869 , p_approver2_person_id => NULL
1870 , p_approver2_type => NULL
1871 , p_apprvl_item_type => itemtype
1872 , p_apprvl_item_key => itemkey
1873 , p_conflict_group_id => l_conflict_group_id
1874 , x_msg_count => l_msg_count
1875 , x_msg_data => l_msg_data
1876 , x_return_status => l_return_status
1877 , x_error_message_code => l_error_message_code);
1878 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1879 raise_application_error(-20001, l_error_message_code);
1880 END IF;
1881 END IF;
1882 resultout := wf_engine.eng_completed||':'||'S';
1883 pa_debug.reset_err_stack;
1884 EXCEPTION
1885 WHEN OTHERS THEN
1886 WF_CORE.CONTEXT
1887 ('PA_ASGMT_WFSTD',
1888 'Start_New_WF',
1889 itemtype,
1890 itemkey,
1891 to_char(actid),
1892 funcmode);
1893 resultout := wf_engine.eng_completed||':'||'F';
1894 RAISE ;
1895 END Start_New_WF ;
1896
1897 PROCEDURE Set_Success_Status (itemtype IN VARCHAR2
1898 , itemkey IN VARCHAR2
1899 , actid IN NUMBER
1900 , funcmode IN VARCHAR2
1901 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
1902
1903 ---l_asgmt_success_status_code pa_project_statuses.project_status_code%TYPE;
1904 l_asgmt_success_status_code VARCHAR2(30);
1905 -- l_assignment_id pa_project_assignments.assignment_id%TYPE;
1906 l_assignment_id NUMBER;
1907 l_msg_count NUMBER;
1908 l_msg_data VARCHAR2(200);
1909 l_error_message_code VARCHAR2(200);
1910 l_return_status VARCHAR2(30);
1911 l_schedule_exception_id NUMBER;
1912 l_is_new_assignment_flag VARCHAR2(1);
1913 BEGIN
1914 pa_debug.init_err_stack ('pa_asgmt_wfstd.Set_Success_Status');
1915 -- Return if WF Not Running
1916 IF (funcmode <> wf_engine.eng_run) THEN
1917 resultout := wf_engine.eng_null;
1918 RETURN;
1919 END IF;
1920 l_asgmt_success_status_code :=
1921 wf_engine.GetItemAttrText
1922 (itemtype => itemtype,
1923 itemkey => itemkey,
1924 aname => 'ASGMT_SUCCESS_STATUS_CODE');
1925 l_assignment_id :=
1926 wf_engine.GetItemAttrText
1927 (itemtype => itemtype,
1928 itemkey => itemkey,
1929 aname => 'ASSIGNMENT_ID');
1930 -- Now store the approvers' response in the global variable
1931 Capture_approver_response (p_item_type => itemtype,
1932 p_item_key => itemkey );
1933 Set_Asgmt_wf_result_Status
1934 (p_assignment_id => l_assignment_id,
1935 p_status_code => l_asgmt_success_status_code,
1936 p_result_type => 'APPROVE',
1937 p_item_type => itemtype,
1938 p_item_key => itemkey ,
1939 x_return_status => l_return_status );
1940
1941 -- Any additional API for schedules goes here
1942 -- IF l_schedule_exception_id IS NOT NULL THEN
1943 /*
1944 SAVEPOINT asgmt_success;
1945 pa_schedule_pvt.update_asgn_wf_success (
1946 P_ASSIGNMENT_ID => l_assignment_id
1947 ,P_IS_NEW_ASSIGNMENT_FLAG => l_is_new_assignment_flag
1948 ,P_SCH_EXCEPTION_ID => l_schedule_exception_id
1949 ,P_SUCCESS_STATUS_CODE => l_asgmt_success_status_code
1950 ,X_RETURN_STATUS => l_return_status
1951 ,X_MSG_COUNT => l_msg_count
1952 ,X_MSG_DATA => l_msg_data );
1953 */
1954 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1955 resultout := wf_engine.eng_completed||':'||'F';
1956 RETURN;
1957 END IF;
1958 resultout := wf_engine.eng_completed||':'||'S';
1959 pa_debug.reset_err_stack;
1960
1961 EXCEPTION
1962 WHEN OTHERS THEN
1963 WF_CORE.CONTEXT
1964 ('PA_ASGMT_WFSTD',
1965 'Set_Success_Status',
1966 itemtype,
1967 itemkey,
1968 to_char(actid),
1969 funcmode);
1970 resultout := wf_engine.eng_completed||':'||'F';
1971 RAISE;
1972
1973 END Set_Success_Status ;
1974
1975
1976 PROCEDURE Set_Failure_Status (itemtype IN VARCHAR2
1977 , itemkey IN VARCHAR2
1978 , actid IN NUMBER
1979 , funcmode IN VARCHAR2
1980 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
1981
1982 l_asgmt_failure_status_code pa_project_statuses.project_status_code%TYPE;
1983 l_assignment_id pa_project_assignments.assignment_id%TYPE;
1984 l_msg_count NUMBER;
1985 l_msg_data VARCHAR2(200);
1986 l_error_message_code VARCHAR2(200);
1987 l_return_status VARCHAR2(30);
1988 l_schedule_exception_id pa_schedule_exceptions.schedule_exception_id%TYPE;
1989 l_is_new_assignment_flag VARCHAR2(1);
1990 BEGIN
1991 pa_debug.init_err_stack ('pa_asgmt_wfstd.Set_Failure_Status');
1992 -- Return if WF Not Running
1993 IF (funcmode <> wf_engine.eng_run) THEN
1994 resultout := wf_engine.eng_null;
1995 RETURN;
1996 END IF;
1997 l_asgmt_failure_status_code :=
1998 wf_engine.GetItemAttrText
1999 (itemtype => itemtype,
2000 itemkey => itemkey,
2001 aname => 'ASGMT_FAILURE_STATUS_CODE');
2002 l_assignment_id :=
2003 wf_engine.GetItemAttrText
2004 (itemtype => itemtype,
2005 itemkey => itemkey,
2006 aname => 'ASSIGNMENT_ID');
2007 -- Now store the approvers' response in the global variable
2008 Capture_approver_response (p_item_type => itemtype,
2009 p_item_key => itemkey );
2010 Set_Asgmt_wf_result_Status
2011 (p_assignment_id => l_assignment_id,
2012 p_status_code => l_asgmt_failure_status_code,
2013 p_result_type => 'REJECT',
2014 p_item_type => itemtype,
2015 p_item_key => itemkey,
2016 x_return_status => l_return_status );
2017
2018 -- Any additional API for schedules goes here
2019 -- IF l_schedule_exception_id IS NOT NULL THEN
2020 /*
2021 SAVEPOINT asgmt_failure;
2022 pa_schedule_pvt.update_asgn_wf_failure
2023 (p_assignment_id => l_assignment_id
2024 ,p_is_new_assignment_flag => l_is_new_assignment_flag
2025 ,p_sch_exception_id => l_schedule_exception_id
2026 ,p_failure_status_code => l_asgmt_failure_status_code
2027 ,x_return_status => l_return_status
2028 ,x_msg_count => l_msg_count
2029 ,x_msg_data => l_msg_data );
2030 */
2031 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2032 resultout := wf_engine.eng_completed||':'||'F';
2033 RETURN;
2034 END IF;
2035 resultout := wf_engine.eng_completed||':'||'S';
2036 pa_debug.reset_err_stack;
2037
2038 EXCEPTION
2039 WHEN OTHERS THEN
2040 WF_CORE.CONTEXT
2041 ('PA_ASGMT_WFSTD',
2042 'Set_Failure_Status',
2043 itemtype,
2044 itemkey,
2045 to_char(actid),
2046 funcmode);
2047 resultout := wf_engine.eng_completed||':'||'F';
2048 RAISE;
2049 END Set_Failure_Status ;
2050
2051 PROCEDURE Check_Wf_Enabled (itemtype IN VARCHAR2
2052 , itemkey IN VARCHAR2
2053 , actid IN NUMBER
2054 , funcmode IN VARCHAR2
2055 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2056
2057 l_assignment_id pa_project_statuses.project_status_code%TYPE;
2058 l_new_item_type VARCHAR2(30);
2059 l_new_process VARCHAR2(30);
2060 l_new_asgmt_status_code pa_project_statuses.project_status_code%TYPE;
2061 l_return_status VARCHAR2(1);
2062 l_error_message_code VARCHAR2(30);
2063 l_wf_type VARCHAR2(30);
2064 l_msg_count NUMBER;
2065 l_msg_data VARCHAR2(200);
2066
2067 BEGIN
2068 /*
2069 Get the foll item attr
2070 'NEW_ASGMT_STATUS_CODE'
2071 Get the WF enabled flag, item type and process name
2072 of the new asgmt status code
2073 If wf enabled flag = 'N' then resultout = 'F'
2074 else
2075 set the new wf item type and new wf process attr
2076 resultout = 'T'
2077 */
2078 pa_debug.init_err_stack ('pa_asgmt_wfstd.Check_Wf_Enabled');
2079 -- Return if WF Not Running
2080 IF (funcmode <> wf_engine.eng_run) THEN
2081 resultout := wf_engine.eng_null;
2082 RETURN;
2083 END IF;
2084 l_new_asgmt_status_code :=
2085 wf_engine.GetItemAttrText
2086 (itemtype => itemtype,
2087 itemkey => itemkey,
2088 aname => 'NEW_ASGMT_STATUS_CODE' );
2089 get_workflow_process_info
2090 (p_status_code => l_new_asgmt_status_code
2091 ,x_wf_item_type => l_new_item_type
2092 ,x_wf_process => l_new_process
2093 ,x_wf_type => l_wf_type
2094 ,x_msg_count => l_msg_count
2095 ,x_msg_data => l_msg_data
2096 ,x_return_status => l_return_status
2097 ,x_error_message_code => l_error_message_code );
2098
2099 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2100 resultout := wf_engine.eng_completed||':'||'N';
2101 RETURN;
2102 END IF;
2103 IF l_wf_type = 'NOT_ENABLED' THEN
2104 resultout := wf_engine.eng_completed||':'||'N';
2105 ELSE
2106 IF (l_new_item_type IS NOT NULL AND
2107 l_new_process IS NOT NULL ) THEN
2108 wf_engine.SetItemAttrText
2109 (itemtype => itemtype
2110 ,itemkey => itemkey
2111 ,aname => 'NEW_WF_ITEM_TYPE'
2112 ,avalue => l_new_item_type
2113 );
2114 wf_engine.SetItemAttrText
2115 (itemtype => itemtype
2116 ,itemkey => itemkey
2117 ,aname => 'NEW_WF_PROCESS_NAME'
2118 ,avalue => l_new_process
2119 );
2120 resultout := wf_engine.eng_completed||':'||'Y';
2121 ELSE
2122 resultout := wf_engine.eng_completed||':'||'N';
2123 END IF;
2124 END IF;
2125 pa_debug.reset_err_stack;
2126 EXCEPTION
2127 WHEN OTHERS THEN
2128 WF_CORE.CONTEXT
2129 ('PA_ASGMT_WFSTD',
2130 'Check_Wf_Enabled',
2131 itemtype,
2132 itemkey,
2133 to_char(actid),
2134 funcmode);
2135 RAISE;
2136 END Check_Wf_Enabled ;
2137
2138
2139 PROCEDURE Generate_Approvers (itemtype IN VARCHAR2
2140 , itemkey IN VARCHAR2
2141 , actid IN NUMBER
2142 , funcmode IN VARCHAR2
2143 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2144
2145 l_approvers_list_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2146 l_out_approvers_list_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2147 l_number_of_approvers NUMBER := 0;
2148 l_approvers_list_rec PA_CLIENT_EXTN_ASGMT_WF.Users_List_Rectyp ;
2149 l_assignment_id pa_project_assignments.assignment_id%TYPE;
2150 l_project_id pa_projects_all.project_id%TYPE;
2151 l_approver_user_name wf_users.name%type; ----- VARCHAR2(30); Commented for bug 3267790 VARCHAR2(100);
2152 /* Modified length from 30 to 100 for bug 3148857 */
2153 l_approver_person_id NUMBER := 0;
2154 l_approver_type VARCHAR2(30);
2155 l_item_attr_name VARCHAR2(30);
2156 l_approvers_list_tbl_idx NUMBER := 1;
2157 l_user_exists BOOLEAN := FALSE; -- Bug#11769582
2158 BEGIN
2159 pa_debug.init_err_stack ('pa_asgmt_wfstd.Generate_Approvers');
2160 -- Return if WF Not Running
2161 IF (funcmode <> wf_engine.eng_run) THEN
2162 resultout := wf_engine.eng_null;
2163 RETURN;
2164 END IF;
2165 NULL;
2166 l_assignment_id := wf_engine.GetItemAttrNumber
2167 (itemtype => itemtype,
2168 itemkey => itemkey,
2169 aname => 'ASSIGNMENT_ID');
2170 l_project_id := wf_engine.GetItemAttrNumber
2171 (itemtype => itemtype,
2172 itemkey => itemkey,
2173 aname => 'PROJECT_ID' );
2174 -- Now populate the PL/SQL table with the 2 approvers
2175 -- which are done by the product by default
2176 FOR i IN 1..2
2177 LOOP
2178 l_item_attr_name := 'APPROVER_'||i||'_PERSON_ID';
2179 l_approver_person_id :=
2180 wf_engine.GetItemAttrNumber
2181 ( itemtype => itemtype
2182 , itemkey => itemkey
2183 , aname => l_item_attr_name
2184 );
2185
2186 l_item_attr_name := 'APPROVER'||i||'_USER_NAME';
2187 l_approver_user_name := wf_engine.GetItemAttrText
2188 ( itemtype => itemtype
2189 , itemkey => itemkey
2190 , aname => l_item_attr_name
2191 );
2192 l_item_attr_name := 'APPROVER_'||i||'_TYPE';
2193 l_approver_type := wf_engine.GetItemAttrText
2194 ( itemtype => itemtype
2195 , itemkey => itemkey
2196 , aname => l_item_attr_name
2197 );
2198 IF l_approver_user_name IS NOT NULL THEN
2199 -- Bug#11769582 start
2200 IF l_approvers_list_tbl_idx = 2 THEN
2201 IF l_approvers_list_tbl(1).User_Name = l_approver_user_name THEN
2202 l_user_exists := TRUE;
2203 END IF;
2204 END IF;
2205 -- Bug#11769582 end
2206 IF l_user_exists = FALSE THEN -- Bug#11769582
2207 l_approvers_list_rec.User_Name := l_approver_user_name;
2208 l_approvers_list_rec.Person_id := l_approver_person_id;
2209 l_approvers_list_rec.Type := l_approver_type;
2210 l_approvers_list_rec.Routing_Order := i;
2211 l_approvers_list_tbl(l_approvers_list_tbl_idx) := l_approvers_list_rec;
2212 l_approvers_list_tbl_idx := l_approvers_list_tbl_idx + 1;
2213 END IF; -- Bug#11769582
2214 END IF;
2215 END LOOP;
2216 -- Pass the pl/sql table to the client extension so
2217 -- users can customize the approvers
2218 PA_CLIENT_EXTN_ASGMT_WF.Generate_Assignment_Approvers
2219 (p_assignment_id => l_assignment_id
2220 ,p_project_id => l_project_id
2221 ,p_in_list_of_approvers => l_approvers_list_tbl
2222 ,x_out_list_of_approvers => l_out_approvers_list_tbl
2223 ,x_number_of_approvers => l_number_of_approvers );
2224
2225 -- Call the populate_wf_performers procedure
2226 populate_wf_performers
2227 ( p_wf_type_code => 'ASSIGNMENT_APPROVAL'
2228 ,p_item_type => itemtype
2229 ,p_item_key => itemkey
2230 ,p_object_id1 => l_assignment_id
2231 ,p_object_id2 => l_project_id
2232 ,p_in_performers_tbl => l_out_approvers_list_tbl
2233 ,p_current_approver_flag => 'N'
2234 ,x_number_of_performers => l_number_of_approvers );
2235
2236 -- Now set the number of approvers
2237 wf_engine.SetItemAttrNumber
2238 ( itemtype => itemtype
2239 , itemkey => itemkey
2240 , aname => 'NUMBER_OF_APPROVERS'
2241 , avalue => l_number_of_approvers
2242 );
2243 pa_debug.reset_err_stack;
2244
2245 EXCEPTION
2246 WHEN OTHERS THEN
2247 WF_CORE.CONTEXT
2248 ('PA_ASGMT_WFSTD',
2249 'Generate_Approvers',
2250 itemtype,
2251 itemkey,
2252 to_char(actid),
2253 funcmode);
2254 RAISE;
2255 END Generate_Approvers ;
2256
2257 PROCEDURE get_Approver (itemtype IN VARCHAR2
2258 ,itemkey IN VARCHAR2
2259 ,actid IN NUMBER
2260 ,funcmode IN VARCHAR2
2261 ,resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2262 l_number_of_approvers NUMBER := 0;
2263 l_approver_loop_counter NUMBER := 0;
2264 l_approver_item_attr_name VARCHAR2(30);
2265 l_approver_user_name pa_wf_ntf_performers.user_name%TYPE; ----VARCHAR2(240); Commented for bug 3267790
2266 l_prev_approver_user_name wf_users.name%TYPE; ----VARCHAR2(240); Commented for bug 3267790 as this takes the value from wf_users
2267 l_approver_type VARCHAR2(30);
2268 l_assignment_id NUMBER;
2269 l_wf_startedby_uname fnd_user.user_name%type;
2270
2271 BEGIN
2272 /*
2273 Get item attr approvals loop counter and number of approvers
2274 Approvals loop counter := approvals loop counter + 1;
2275 If approvals loop counter > number of approvers , resultout = 'F'
2276 and return
2277 Else if approval loop counter = 1, set performer to approver1
2278 and so on.
2279 Set performer item attr concat with approvals loop counter
2280 Set approvals loop counter
2281 Resultout = 'S'
2282 */
2283 -- Return if WF Not Running
2284 pa_debug.init_err_stack ('pa_asgmt_wfstd.get_approver');
2285 IF (funcmode <> wf_engine.eng_run) THEN
2286 resultout := wf_engine.eng_null;
2287 RETURN;
2288 END IF;
2289 l_number_of_approvers := wf_engine.GetItemAttrNumber
2290 ( itemtype => itemtype
2291 , itemkey => itemkey
2292 , aname => 'NUMBER_OF_APPROVERS'
2293 );
2294 l_approver_loop_counter := wf_engine.getItemAttrNumber
2295 ( itemtype => itemtype
2296 , itemkey => itemkey
2297 , aname => 'APPROVER_LOOP_COUNTER'
2298 );
2299 l_assignment_id := wf_engine.GetItemAttrNumber
2300 (itemtype => itemtype,
2301 itemkey => itemkey,
2302 aname => 'ASSIGNMENT_ID');
2303
2304 l_approver_loop_counter := l_approver_loop_counter + 1;
2305 IF l_approver_loop_counter > l_number_of_approvers THEN
2306 resultout := wf_engine.eng_completed||':'||'F';
2307 RETURN ;
2308 END IF;
2309 get_wf_performer (p_wf_type_code => 'ASSIGNMENT_APPROVAL'
2310 ,p_item_type => itemtype
2311 ,p_item_key => itemkey
2312 ,p_routing_order => l_approver_loop_counter
2313 ,p_object_id1 => l_assignment_id
2314 ,x_performer_name => l_approver_user_name
2315 ,x_performer_type => l_approver_type );
2316
2317 IF l_approver_user_name IS NULL THEN
2318 resultout := wf_engine.eng_completed||':'||'F';
2319 RETURN ;
2320 END IF;
2321 -- In order to set the forwarded from, capture the current
2322 -- approver before modifying the same
2323 -- Set the current approver as the previous approver
2324 -- Handling a NULL previous approver (which is likely when
2325 -- the current approver is the first approver) is done
2326 -- in the Set forwarded from procedure
2327 l_prev_approver_user_name := wf_engine.GetItemAttrText
2328 ( itemtype => itemtype
2329 , itemkey => itemkey
2330 , aname => 'APPROVER_UNAME'
2331 );
2332 wf_engine.SetItemAttrText
2333 ( itemtype => itemtype
2334 , itemkey => itemkey
2335 , aname => 'PREV_APPROVER_UNAME'
2336 , avalue => l_prev_approver_user_name
2337 );
2338 wf_engine.SetItemAttrText
2339 ( itemtype => itemtype
2340 , itemkey => itemkey
2341 , aname => 'APPROVER_UNAME'
2342 , avalue => l_approver_user_name
2343 );
2344 wf_engine.SetItemAttrNumber
2345 ( itemtype => itemtype
2346 , itemkey => itemkey
2347 , aname => 'APPROVER_LOOP_COUNTER'
2348 , avalue => l_approver_loop_counter
2349 );
2350
2351 /*Added the code for the bug 3595857*/
2352 IF l_approver_loop_counter = 1 THEN
2353 l_wf_startedby_uname := wf_engine.GetItemAttrText
2354 ( itemtype => itemtype
2355 , itemkey => itemkey
2356 , aname => 'WORKFLOW_STARTED_BY_UNAME'
2357 );
2358
2359 wf_engine.SetItemAttrText
2360 ( itemtype => itemtype
2361 , itemkey => itemkey
2362 , aname => 'FROM_ROLE_VALUE'
2363 , avalue => l_wf_startedby_uname
2364 );
2365 ELSE
2366 wf_engine.SetItemAttrText
2367 ( itemtype => itemtype
2368 , itemkey => itemkey
2369 , aname => 'FROM_ROLE_VALUE'
2370 , avalue => l_prev_approver_user_name
2371 );
2372 END IF;
2373 /*End of the code addition for the bug 3595857*/
2374
2375 -- Need to set the current user as the current approver
2376 -- and set the flag to 'N' for the rest
2377 --
2378 UPDATE pa_wf_ntf_performers
2379 SET current_approver_flag =
2380 (DECODE(user_name,l_approver_user_name,'Y','N'))
2381 WHERE item_type = itemtype
2382 AND item_key = itemkey
2383 AND object_id1 = l_assignment_id;
2384 resultout := wf_engine.eng_completed||':'||'S';
2385 pa_debug.reset_err_stack;
2386 EXCEPTION
2387 WHEN OTHERS THEN
2388 WF_CORE.CONTEXT
2389 ('PA_ASGMT_WFSTD',
2390 'Get_Approver',
2391 itemtype,
2392 itemkey,
2393 to_char(actid),
2394 funcmode);
2395 RAISE;
2396 END Get_Approver ;
2397
2398 PROCEDURE Generate_apprvl_nf_recipients
2399 (itemtype IN VARCHAR2
2400 , itemkey IN VARCHAR2
2401 , actid IN NUMBER
2402 , funcmode IN VARCHAR2
2403 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2404
2405 l_approval_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2406 l_out_approval_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2407 l_number_of_recipients NUMBER := 0;
2408 l_approval_nf_rects_rec PA_CLIENT_EXTN_ASGMT_WF.Users_List_Rectyp ;
2409 l_assignment_id pa_project_assignments.assignment_id%TYPE;
2410 l_project_id pa_projects_all.project_id%TYPE;
2411 l_approval_nf_rect_username VARCHAR2(100); /* Modified length from 30 to 100 for bug 3148857 */
2412 l_rect_person_id NUMBER := 0;
2413 l_recipient_type VARCHAR2(30);
2414 l_item_attr_name VARCHAR2(30);
2415 l_number_of_apprvl_nf_rects NUMBER := 0;
2416 l_approval_nf_loop_counter NUMBER := 0;
2417 l_ntfy_rect_item_attr_name VARCHAR2(30);
2418 l_ntfy_apprvl_recipient_name wf_users.name%TYPE; ---VARCHAR2(240); Changed for bug 3267790
2419 l_ntfy_apprvl_rect_person_id NUMBER := 0;
2420 l_ntfy_apprvl_rect_type VARCHAR2(30);
2421 l_apprvl_item_type VARCHAR2(30);
2422 l_apprvl_item_key VARCHAR2(30);
2423 l_number_of_apprvl_recipients NUMBER := 0;
2424
2425 BEGIN
2426 -- This will not do anything in milestone 1. In version 1
2427 -- appropriate client extensions will be called
2428
2429 pa_debug.init_err_stack ('pa_asgmt_wfstd.Generate_apprvl_nf_recipients');
2430 -- Return if WF Not Running
2431 IF (funcmode <> wf_engine.eng_run) THEN
2432 resultout := wf_engine.eng_null;
2433 RETURN;
2434 END IF;
2435 l_assignment_id := wf_engine.GetItemAttrNumber
2436 (itemtype => itemtype,
2437 itemkey => itemkey,
2438 aname => 'ASSIGNMENT_ID');
2439 l_project_id := wf_engine.GetItemAttrNumber
2440 (itemtype => itemtype,
2441 itemkey => itemkey,
2442 aname => 'PROJECT_ID' );
2443 -- Now populate the PL/SQL table with the 4 recipients
2444 -- which are done by the product by default
2445 l_number_of_apprvl_nf_rects := wf_engine.GetItemAttrNumber
2446 ( itemtype => itemtype
2447 , itemkey => itemkey
2448 , aname => 'NUMBER_OF_APPRVL_NF_RECIPIENTS'
2449 );
2450
2451 l_apprvl_item_type := wf_engine.getItemAttrText
2452 ( itemtype => itemtype
2453 , itemkey => itemkey
2454 , aname => 'APPRVL_ITEM_TYPE' );
2455
2456 l_apprvl_item_key := wf_engine.getItemAttrText
2457 ( itemtype => itemtype
2458 , itemkey => itemkey
2459 , aname => 'APPRVL_ITEM_KEY');
2460
2461 FOR i IN 1..l_number_of_apprvl_nf_rects LOOP
2462 l_ntfy_rect_item_attr_name :=
2463 'APPROVAL_NF_REC'||i||'_USER_NAME';
2464 l_ntfy_apprvl_recipient_name := wf_engine.getItemAttrText
2465 ( itemtype => itemtype
2466 , itemkey => itemkey
2467 , aname => l_ntfy_rect_item_attr_name
2468 );
2469 l_ntfy_rect_item_attr_name :=
2470 'APPROVAL_NF_REC'||i||'_USER_TYPE';
2471 l_ntfy_apprvl_rect_type := wf_engine.getItemAttrText
2472 ( itemtype => itemtype
2473 , itemkey => itemkey
2474 , aname => l_ntfy_rect_item_attr_name
2475 );
2476 l_ntfy_rect_item_attr_name :=
2477 'APPROVAL_NF_REC'||i||'_PERSON_ID';
2478 l_ntfy_apprvl_rect_person_id := wf_engine.getItemAttrNumber
2479 ( itemtype => itemtype
2480 , itemkey => itemkey
2481 , aname => l_ntfy_rect_item_attr_name
2482 );
2483
2484 IF l_ntfy_apprvl_recipient_name IS NOT NULL THEN
2485 l_number_of_apprvl_recipients := l_number_of_apprvl_recipients + 1;
2486 l_approval_nf_rects_rec.User_Name := l_ntfy_apprvl_recipient_name;
2487 l_approval_nf_rects_rec.Person_id := l_ntfy_apprvl_rect_person_id;
2488 l_approval_nf_rects_rec.Type := l_ntfy_apprvl_rect_type;
2489 l_approval_nf_rects_rec.Routing_Order := l_number_of_apprvl_recipients;
2490 l_approval_nf_rects_tbl(l_number_of_apprvl_recipients) := l_approval_nf_rects_rec;
2491 END IF;
2492 END LOOP;
2493 -- Pass the pl/sql table to the client extension so
2494 -- users can customize the approvers
2495
2496 PA_CLIENT_EXTN_ASGMT_WF.Generate_NF_Recipients
2497 (p_assignment_id => l_assignment_id
2498 ,p_project_id => l_project_id
2499 ,p_notification_type => 'APPROVAL_FYI'
2500 ,p_in_list_of_recipients => l_approval_nf_rects_tbl
2501 ,x_out_list_of_recipients => l_out_approval_nf_rects_tbl
2502 ,x_number_of_recipients => l_number_of_recipients );
2503
2504 populate_wf_performers
2505 ( p_wf_type_code => 'APPROVAL_FYI'
2506 ,p_item_type => itemtype
2507 ,p_item_key => itemkey
2508 ,p_object_id1 => l_assignment_id
2509 ,p_object_id2 => l_project_id
2510 ,p_in_performers_tbl => l_out_approval_nf_rects_tbl
2511 ,p_current_approver_flag => 'N'
2512 ,x_number_of_performers => l_number_of_recipients );
2513
2514 -- Now set the number of approvl nf recipients based
2515 -- on how many records were inserted
2516
2517 wf_engine.SetItemAttrNumber
2518 (itemtype => itemtype
2519 ,itemkey => itemkey
2520 ,aname => 'NUMBER_OF_APPRVL_NF_RECIPIENTS'
2521 ,avalue => l_number_of_recipients
2522 );
2523 -- Now populate the Comments fields, which would have
2524 -- been stored in the pa_wf_ntf_performers table
2525 IF (l_apprvl_item_type IS NOT NULL AND l_apprvl_item_key
2526 IS NOT NULL ) THEN
2527 Set_approver_comments (p_apprvl_item_type => l_apprvl_item_type
2528 ,p_apprvl_item_key => l_apprvl_item_key
2529 ,p_item_type => itemtype
2530 ,p_item_key => itemkey
2531 ,p_assignment_id => l_assignment_id);
2532 END IF;
2533
2534 EXCEPTION
2535 WHEN OTHERS THEN
2536 WF_CORE.CONTEXT
2537 ('PA_ASGMT_WFSTD',
2538 'Generate_apprvl_nf_recipients',
2539 itemtype,
2540 itemkey,
2541 to_char(actid),
2542 funcmode);
2543 RAISE;
2544 END Generate_apprvl_nf_recipients ;
2545
2546 PROCEDURE Get_Approval_NF_Recipient
2547 (itemtype IN VARCHAR2
2548 , itemkey IN VARCHAR2
2549 , actid IN NUMBER
2550 , funcmode IN VARCHAR2
2551 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2552
2553 l_number_of_apprvl_nf_rects NUMBER := 0;
2554 l_approval_nf_loop_counter NUMBER := 0;
2555 l_ntfy_rect_item_attr_name VARCHAR2(30);
2556 l_ntfy_apprvl_recipient_name pa_wf_ntf_performers.user_name%TYPE; ---VARCHAR2(240); Changed for bug 3267790
2557 l_ntfy_apprvl_rect_type VARCHAR2(30);
2558 l_assignment_id NUMBER := 0;
2559
2560 BEGIN
2561 /*
2562 Get item attr approval nf rect loop counter and number of rects
2563 Approvals nf rect loop counter := approvals nf rect loop counter + 1;
2564 If loop counter > number of rcts , resultout = 'F'
2565 and return
2566 Read the wf performers table and get the
2567 recipient record based on the loop counter.
2568 Set performer to the retrieved record
2569 If performer = resource , remove all comments
2570 else restore the comments
2571 Set loop counter
2572 Resultout = 'T'
2573 */
2574 -- Return if WF Not Running
2575 IF (funcmode <> wf_engine.eng_run) THEN
2576 resultout := wf_engine.eng_null;
2577 RETURN;
2578 END IF;
2579 l_number_of_apprvl_nf_rects := wf_engine.GetItemAttrNumber
2580 ( itemtype => itemtype
2581 , itemkey => itemkey
2582 , aname => 'NUMBER_OF_APPRVL_NF_RECIPIENTS'
2583 );
2584 l_approval_nf_loop_counter := wf_engine.getItemAttrNumber
2585 ( itemtype => itemtype
2586 , itemkey => itemkey
2587 , aname => 'APPROVAL_NF_LOOP_COUNTER'
2588 );
2589 l_assignment_id := wf_engine.getItemAttrNumber
2590 ( itemtype => itemtype
2591 , itemkey => itemkey
2592 , aname => 'ASSIGNMENT_ID'
2593 );
2594 l_approval_nf_loop_counter := l_approval_nf_loop_counter + 1;
2595 IF l_approval_nf_loop_counter > l_number_of_apprvl_nf_rects THEN
2596 resultout := wf_engine.eng_completed||':'||'F';
2597 RETURN;
2598 END IF;
2599 get_wf_performer (p_wf_type_code => 'APPROVAL_FYI'
2600 ,p_item_type => itemtype
2601 ,p_item_key => itemkey
2602 ,p_routing_order => l_approval_nf_loop_counter
2603 ,p_object_id1 => l_assignment_id
2604 ,x_performer_name =>l_ntfy_apprvl_recipient_name
2605 ,x_performer_type =>l_ntfy_apprvl_rect_type );
2606 wf_engine.SetItemAttrText
2607 ( itemtype => itemtype
2608 , itemkey => itemkey
2609 , aname => 'NTFY_APPRVL_RECIPIENT_NAME'
2610 , avalue => l_ntfy_apprvl_recipient_name
2611 );
2612 wf_engine.SetItemAttrNumber
2613 ( itemtype => itemtype
2614 , itemkey => itemkey
2615 , aname => 'APPROVAL_NF_LOOP_COUNTER'
2616 , avalue => l_approval_nf_loop_counter
2617 );
2618 -- Do not show comments if the recipient is the resource
2619 -- otherwise show the comments. To achieve this, set the
2620 -- displayed comments field appropriately
2621 -- This is done in the set_comments procedure
2622 Set_Comment_Attributes (p_item_type => itemtype,
2623 p_item_key => itemkey ,
2624 p_rect_type =>
2625 l_ntfy_apprvl_rect_type );
2626
2627 resultout := wf_engine.eng_completed||':'||'S';
2628 EXCEPTION
2629 WHEN OTHERS THEN
2630 WF_CORE.CONTEXT
2631 ('PA_ASGMT_WFSTD',
2632 'Get_Approval_NF_Recipient',
2633 itemtype,
2634 itemkey,
2635 to_char(actid),
2636 funcmode);
2637 RAISE;
2638 END Get_Approval_NF_Recipient ;
2639
2640 PROCEDURE Generate_reject_nf_recipients
2641 (itemtype IN VARCHAR2
2642 , itemkey IN VARCHAR2
2643 , actid IN NUMBER
2644 , funcmode IN VARCHAR2
2645 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2646 l_reject_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2647 l_out_reject_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2648 l_number_of_recipients NUMBER := 0;
2649 l_reject_nf_rects_rec PA_CLIENT_EXTN_ASGMT_WF.Users_List_Rectyp ;
2650 l_assignment_id pa_project_assignments.assignment_id%TYPE;
2651 l_project_id pa_projects_all.project_id%TYPE;
2652 l_reject_nf_rect_username wf_users.name%type; ---VARCHAR2(100); /* Modified length from 30 to 100 for bug 3148857 */ -- Changed for bug 3267790
2653 l_rect_person_id NUMBER := 0;
2654 l_recipient_type VARCHAR2(30);
2655 l_item_attr_name VARCHAR2(30);
2656 l_number_of_reject_nf_rects NUMBER := 0;
2657 l_reject_nf_loop_counter NUMBER := 0;
2658 l_ntfy_rect_item_attr_name VARCHAR2(30);
2659 l_ntfy_reject_recipient_name wf_users.name%type; ----- VARCHAR2(240);Changed for bug 3267790
2660 l_ntfy_reject_rect_person_id NUMBER := 0;
2661 l_ntfy_reject_rect_type VARCHAR2(30);
2662 l_apprvl_item_type VARCHAR2(30);
2663 l_apprvl_item_key VARCHAR2(30);
2664
2665 l_counter NUMBER := 0; -- local variable Bug #11841318
2666
2667 BEGIN
2668 -- Return if WF Not Running
2669 IF (funcmode <> wf_engine.eng_run) THEN
2670 resultout := wf_engine.eng_null;
2671 RETURN;
2672 END IF;
2673 l_assignment_id := wf_engine.GetItemAttrNumber
2674 (itemtype => itemtype,
2675 itemkey => itemkey,
2676 aname => 'ASSIGNMENT_ID');
2677 l_project_id := wf_engine.GetItemAttrNumber
2678 (itemtype => itemtype,
2679 itemkey => itemkey,
2680 aname => 'PROJECT_ID' );
2681 -- Now populate the PL/SQL table with the 4 recipients
2682 -- which are done by the product by default
2683 l_number_of_reject_nf_rects := wf_engine.GetItemAttrNumber
2684 ( itemtype => itemtype
2685 , itemkey => itemkey
2686 , aname => 'NUMBER_OF_REJECT_NF_RECIPIENTS'
2687 );
2688
2689 l_apprvl_item_type := wf_engine.getItemAttrText
2690 ( itemtype => itemtype
2691 , itemkey => itemkey
2692 , aname => 'APPRVL_ITEM_TYPE' );
2693
2694 l_apprvl_item_key := wf_engine.getItemAttrText
2695 ( itemtype => itemtype
2696 , itemkey => itemkey
2697 , aname => 'APPRVL_ITEM_KEY');
2698
2699 FOR i IN 1..l_number_of_reject_nf_rects
2700 LOOP
2701 l_ntfy_rect_item_attr_name :=
2702 'REJECT_NF_REC'||i||'_USER_NAME';
2703 l_ntfy_reject_recipient_name := wf_engine.getItemAttrText
2704 ( itemtype => itemtype
2705 , itemkey => itemkey
2706 , aname => l_ntfy_rect_item_attr_name
2707 );
2708 l_ntfy_rect_item_attr_name :=
2709 'REJECT_NF_REC'||i||'_USER_TYPE';
2710 l_ntfy_reject_rect_type := wf_engine.getItemAttrText
2711 ( itemtype => itemtype
2712 , itemkey => itemkey
2713 , aname => l_ntfy_rect_item_attr_name
2714 );
2715 l_ntfy_rect_item_attr_name :=
2716 'REJECT_NF_REC'||i||'_PERSON_ID';
2717 l_ntfy_reject_rect_person_id := wf_engine.getItemAttrNumber
2718 ( itemtype => itemtype
2719 , itemkey => itemkey
2720 , aname => l_ntfy_rect_item_attr_name
2721 );
2722 IF l_ntfy_reject_recipient_name IS NOT NULL THEN
2723
2724 l_counter := l_counter + 1; --Bug #11841318
2725 l_reject_nf_rects_rec.User_Name := l_ntfy_reject_recipient_name;
2726 l_reject_nf_rects_rec.Person_id := l_ntfy_reject_rect_person_id;
2727 l_reject_nf_rects_rec.Type := l_ntfy_reject_rect_type;
2728 -- l_reject_nf_rects_rec.Routing_Order := i;
2729 -- l_reject_nf_rects_tbl(i) := l_reject_nf_rects_rec;
2730 l_reject_nf_rects_rec.Routing_Order := l_counter; -- Bug #11841318
2731 l_reject_nf_rects_tbl(l_counter) := l_reject_nf_rects_rec; -- Bug #11841318
2732 END IF;
2733 END LOOP;
2734 -- Pass the pl/sql table to the client extension so
2735 -- users can customize the approvers
2736
2737 PA_CLIENT_EXTN_ASGMT_WF.Generate_NF_Recipients
2738 (p_assignment_id => l_assignment_id
2739 ,p_project_id => l_project_id
2740 ,p_notification_type => 'REJECTION_FYI'
2741 ,p_in_list_of_recipients => l_reject_nf_rects_tbl
2742 ,x_out_list_of_recipients => l_out_reject_nf_rects_tbl
2743 ,x_number_of_recipients => l_number_of_recipients );
2744
2745 populate_wf_performers
2746 ( p_wf_type_code => 'REJECTION_FYI'
2747 ,p_item_type => itemtype
2748 ,p_item_key => itemkey
2749 ,p_object_id1 => l_assignment_id
2750 ,p_object_id2 => l_project_id
2751 ,p_in_performers_tbl => l_out_reject_nf_rects_tbl
2752 ,p_current_approver_flag => 'N'
2753 ,x_number_of_performers => l_number_of_recipients );
2754
2755 -- Now set the number of reject nf recipients based
2756 -- on how many records were inserted
2757
2758 wf_engine.SetItemAttrNumber
2759 (itemtype => itemtype
2760 ,itemkey => itemkey
2761 ,aname => 'NUMBER_OF_REJECT_NF_RECIPIENTS'
2762 ,avalue => l_number_of_recipients
2763 );
2764 -- Now populate the Comments fields, which would have
2765 -- been stored in the pa_wf_ntf_performers table
2766 IF (l_apprvl_item_type IS NOT NULL AND l_apprvl_item_key
2767 IS NOT NULL ) THEN
2768 Set_approver_comments (p_apprvl_item_type => l_apprvl_item_type
2769 ,p_apprvl_item_key => l_apprvl_item_key
2770 ,p_item_type => itemtype
2771 ,p_item_key => itemkey
2772 ,p_assignment_id => l_assignment_id);
2773 END IF;
2774 EXCEPTION
2775 WHEN OTHERS THEN
2776 WF_CORE.CONTEXT
2777 ('PA_ASGMT_WFSTD',
2778 'Generate_reject_nf_recipients',
2779 itemtype,
2780 itemkey,
2781 to_char(actid),
2782 funcmode);
2783 RAISE;
2784 END Generate_reject_nf_recipients ;
2785
2786 PROCEDURE Get_Reject_NF_Recipient
2787 (itemtype IN VARCHAR2
2788 , itemkey IN VARCHAR2
2789 , actid IN NUMBER
2790 , funcmode IN VARCHAR2
2791 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2792
2793 l_number_of_reject_nf_rects NUMBER := 0;
2794 l_rejection_nf_loop_counter NUMBER := 0;
2795 l_ntfy_rect_item_attr_name VARCHAR2(30);
2796 l_ntfy_reject_recipient_name pa_wf_ntf_performers.user_name%type; ----- VARCHAR2(240);Changed for bug 3267790
2797 l_ntfy_reject_rect_type VARCHAR2(30);
2798 l_assignment_id NUMBER := 0;
2799
2800 BEGIN
2801 /*
2802 Get item attr reject nf rect loop counter and number of rects
2803 reject nf rect loop counter := reject nf rect loop counter + 1;
2804 If loop counter > number of rcts , resultout = 'F'
2805 and return
2806 Read the wf performers table and get the
2807 recipient record based on the loop counter.
2808 Set performer to the retrieved record
2809 If performer = resource , remove all comments
2810 else restore the comments
2811 Set loop counter
2812 Resultout = 'T'
2813 */
2814 -- Return if WF Not Running
2815 IF (funcmode <> wf_engine.eng_run) THEN
2816 resultout := wf_engine.eng_null;
2817 RETURN;
2818 END IF;
2819 l_number_of_reject_nf_rects := wf_engine.GetItemAttrNumber
2820 ( itemtype => itemtype
2821 , itemkey => itemkey
2822 , aname => 'NUMBER_OF_REJECT_NF_RECIPIENTS'
2823 );
2824 l_rejection_nf_loop_counter := wf_engine.getItemAttrNumber
2825 ( itemtype => itemtype
2826 , itemkey => itemkey
2827 , aname => 'REJECTION_NF_LOOP_COUNTER'
2828 );
2829
2830 l_assignment_id := wf_engine.getItemAttrNumber
2831 ( itemtype => itemtype
2832 , itemkey => itemkey
2833 , aname => 'ASSIGNMENT_ID'
2834 );
2835 l_rejection_nf_loop_counter := l_rejection_nf_loop_counter + 1;
2836 IF l_rejection_nf_loop_counter > l_number_of_reject_nf_rects THEN
2837 resultout := wf_engine.eng_completed||':'||'F';
2838 RETURN;
2839 END IF;
2840 get_wf_performer (p_wf_type_code => 'REJECTION_FYI'
2841 ,p_item_type => itemtype
2842 ,p_item_key => itemkey
2843 ,p_routing_order => l_rejection_nf_loop_counter
2844 ,p_object_id1 => l_assignment_id
2845 ,x_performer_name =>l_ntfy_reject_recipient_name
2846 ,x_performer_type =>l_ntfy_reject_rect_type );
2847 wf_engine.SetItemAttrText
2848 ( itemtype => itemtype
2849 , itemkey => itemkey
2850 , aname => 'NTFY_REJECT_RECIPIENT_NAME'
2851 , avalue => l_ntfy_reject_recipient_name
2852 );
2853 wf_engine.SetItemAttrNumber
2854 ( itemtype => itemtype
2855 , itemkey => itemkey
2856 , aname => 'REJECTION_NF_LOOP_COUNTER'
2857 , avalue => l_rejection_nf_loop_counter
2858 );
2859 -- Do not show comments if the recipient is the resource
2860 -- otherwise show the comments. To achieve this, set the
2861 -- displayed comments field appropriately
2862 -- This is done in the set_comments procedure
2863 Set_Comment_Attributes (p_item_type => itemtype,
2864 p_item_key => itemkey ,
2865 p_rect_type =>
2866 l_ntfy_reject_rect_type );
2867 resultout := wf_engine.eng_completed||':'||'S';
2868 EXCEPTION
2869 WHEN OTHERS THEN
2870 WF_CORE.CONTEXT
2871 ('PA_ASGMT_WFSTD',
2872 'Get_Reject_NF_Recipient',
2873 itemtype,
2874 itemkey,
2875 to_char(actid),
2876 funcmode);
2877 RAISE;
2878 END Get_Reject_NF_Recipient ;
2879
2880
2881
2882 PROCEDURE Generate_cancel_nf_recipients
2883 (itemtype IN VARCHAR2
2884 , itemkey IN VARCHAR2
2885 , actid IN NUMBER
2886 , funcmode IN VARCHAR2
2887 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
2888 l_cancel_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2889 l_out_cancel_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
2890 l_number_of_recipients NUMBER := 0;
2891 l_cancel_nf_rects_rec PA_CLIENT_EXTN_ASGMT_WF.Users_List_Rectyp ;
2892 l_assignment_id pa_project_assignments.assignment_id%TYPE;
2893 l_project_id pa_projects_all.project_id%TYPE;
2894 l_cancel_nf_rect_username wf_users.name%type; ----- VARCHAR2(30);Changed for bug 3267790
2895 --VARCHAR2(100); /* Modified length from 30 to 100 for bug 3148857 */
2896 l_rect_person_id NUMBER := 0;
2897 l_recipient_type VARCHAR2(30);
2898 l_item_attr_name VARCHAR2(30);
2899 l_number_of_cancel_nf_rects NUMBER := 0;
2900 l_cancel_nf_loop_counter NUMBER := 0;
2901 l_ntfy_rect_item_attr_name VARCHAR2(30);
2902 l_ntfy_cancel_recipient_name wf_users.name%type; --- VARCHAR2(240);Changed for bug 3267790
2903 l_ntfy_cancel_rect_person_id NUMBER := 0;
2904 l_ntfy_cancel_rect_type VARCHAR2(30);
2905 l_apprvl_item_type VARCHAR2(30);
2906 l_apprvl_item_key VARCHAR2(30);
2907
2908 l_counter NUMBER := 0; -- local variable for bug 7511389
2909
2910 BEGIN
2911 -- Return if WF Not Running
2912 IF (funcmode <> wf_engine.eng_run) THEN
2913 resultout := wf_engine.eng_null;
2914 RETURN;
2915 END IF;
2916 l_assignment_id := wf_engine.GetItemAttrNumber
2917 (itemtype => itemtype,
2918 itemkey => itemkey,
2919 aname => 'ASSIGNMENT_ID');
2920 l_project_id := wf_engine.GetItemAttrNumber
2921 (itemtype => itemtype,
2922 itemkey => itemkey,
2923 aname => 'PROJECT_ID' );
2924 -- Now populate the PL/SQL table with the 4 recipients
2925 -- which are done by the product by default
2926 l_number_of_cancel_nf_rects := wf_engine.GetItemAttrNumber
2927 ( itemtype => itemtype
2928 , itemkey => itemkey
2929 , aname => 'NUMBER_OF_CANCEL_NF_RECIPIENTS'
2930 );
2931
2932 l_apprvl_item_type := wf_engine.getItemAttrText
2933 ( itemtype => itemtype
2934 , itemkey => itemkey
2935 , aname => 'APPRVL_ITEM_TYPE' );
2936
2937 l_apprvl_item_key := wf_engine.getItemAttrText
2938 ( itemtype => itemtype
2939 , itemkey => itemkey
2940 , aname => 'APPRVL_ITEM_KEY');
2941
2942 FOR i IN 1..l_number_of_cancel_nf_rects
2943 LOOP
2944 l_ntfy_rect_item_attr_name :=
2945 'CANCEL_NF_REC'||i||'_USER_NAME';
2946 l_ntfy_cancel_recipient_name := wf_engine.getItemAttrText
2947 ( itemtype => itemtype
2948 , itemkey => itemkey
2949 , aname => l_ntfy_rect_item_attr_name
2950 );
2951 l_ntfy_rect_item_attr_name :=
2952 'CANCEL_NF_REC'||i||'_USER_TYPE';
2953 l_ntfy_cancel_rect_type := wf_engine.getItemAttrText
2954 ( itemtype => itemtype
2955 , itemkey => itemkey
2956 , aname => l_ntfy_rect_item_attr_name
2957 );
2958 l_ntfy_rect_item_attr_name :=
2959 'CANCEL_NF_REC'||i||'_PERSON_ID';
2960 l_ntfy_cancel_rect_person_id := wf_engine.getItemAttrNumber
2961 ( itemtype => itemtype
2962 , itemkey => itemkey
2963 , aname => l_ntfy_rect_item_attr_name
2964 );
2965 IF l_ntfy_cancel_recipient_name IS NOT NULL THEN
2966
2967 /*Bug 7511389 : increasing the counter */
2968 l_counter := l_counter + 1;
2969
2970 l_cancel_nf_rects_rec.User_Name := l_ntfy_cancel_recipient_name;
2971 l_cancel_nf_rects_rec.Person_id :=
2972 l_ntfy_cancel_rect_person_id;
2973 l_cancel_nf_rects_rec.Type :=
2974 l_ntfy_cancel_rect_type;
2975
2976 /*For bug 7511389 : removing 'i' and using 'l_counter' instead */
2977 -- l_cancel_nf_rects_rec.Routing_Order := i;
2978 -- l_cancel_nf_rects_tbl(i) := l_cancel_nf_rects_rec;
2979 l_cancel_nf_rects_rec.Routing_Order := l_counter;
2980 l_cancel_nf_rects_tbl(l_counter) := l_cancel_nf_rects_rec;
2981 END IF;
2982 END LOOP;
2983 -- Pass the pl/sql table to the client extension so
2984 -- users can customize the approvers
2985
2986 PA_CLIENT_EXTN_ASGMT_WF.Generate_NF_Recipients
2987 (p_assignment_id => l_assignment_id
2988 ,p_project_id => l_project_id
2989 ,p_notification_type => 'CANCELLATION_FYI'
2990 ,p_in_list_of_recipients => l_cancel_nf_rects_tbl
2991 ,x_out_list_of_recipients => l_out_cancel_nf_rects_tbl
2992 ,x_number_of_recipients => l_number_of_recipients );
2993
2994 populate_wf_performers
2995 ( p_wf_type_code => 'CANCELLATION_FYI'
2996 ,p_item_type => itemtype
2997 ,p_item_key => itemkey
2998 ,p_object_id1 => l_assignment_id
2999 ,p_object_id2 => l_project_id
3000 ,p_in_performers_tbl => l_out_cancel_nf_rects_tbl
3001 ,p_current_approver_flag => 'N'
3002 ,x_number_of_performers => l_number_of_recipients );
3003
3004 -- Now set the number of cancel nf recipients based
3005 -- on how many records were inserted
3006
3007 wf_engine.SetItemAttrNumber
3008 (itemtype => itemtype
3009 ,itemkey => itemkey
3010 ,aname => 'NUMBER_OF_CANCEL_NF_RECIPIENTS'
3011 ,avalue => l_number_of_recipients
3012 );
3013 -- Now populate the Comments fields, which would have
3014 -- been stored in the pa_wf_ntf_performers table
3015 IF (l_apprvl_item_type IS NOT NULL AND l_apprvl_item_key
3016 IS NOT NULL ) THEN
3017 Set_approver_comments (p_apprvl_item_type => l_apprvl_item_type
3018 ,p_apprvl_item_key => l_apprvl_item_key
3019 ,p_item_type => itemtype
3020 ,p_item_key => itemkey
3021 ,p_assignment_id => l_assignment_id);
3022 END IF;
3023 EXCEPTION
3024 WHEN OTHERS THEN
3025 WF_CORE.CONTEXT
3026 ('PA_ASGMT_WFSTD',
3027 'Generate_cancel_nf_recipients',
3028 itemtype,
3029 itemkey,
3030 to_char(actid),
3031 funcmode);
3032 RAISE;
3033 END Generate_cancel_nf_recipients ;
3034
3035
3036 PROCEDURE Get_Cancel_NF_Recipient
3037 (itemtype IN VARCHAR2
3038 , itemkey IN VARCHAR2
3039 , actid IN NUMBER
3040 , funcmode IN VARCHAR2
3041 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
3042
3043 l_number_of_cancel_nf_rects NUMBER := 0;
3044 l_cancellation_nf_loop_counter NUMBER := 0;
3045 l_ntfy_rect_item_attr_name VARCHAR2(30);
3046 l_ntfy_cancel_recipient_name pa_wf_ntf_performers.user_name%TYPE; ----- VARCHAR2(240);Changed for bug 3267790
3047 l_ntfy_cancel_rect_type VARCHAR2(30);
3048 l_assignment_id NUMBER := 0;
3049
3050 BEGIN
3051 /*
3052 Get item attr cancel nf rect loop counter and number of rects
3053 cancel nf rect loop counter := cancel nf rect loop counter + 1;
3054 If loop counter > number of rcts , resultout = 'F'
3055 and return
3056 Read the wf performers table and get the
3057 recipient record based on the loop counter.
3058 Set performer to the retrieved record
3059 If performer = resource , remove all comments
3060 else restore the comments
3061 Set loop counter
3062 Resultout = 'T'
3063 */
3064 -- Return if WF Not Running
3065 IF (funcmode <> wf_engine.eng_run) THEN
3066 resultout := wf_engine.eng_null;
3067 RETURN;
3068 END IF;
3069 l_number_of_cancel_nf_rects := wf_engine.GetItemAttrNumber
3070 ( itemtype => itemtype
3071 , itemkey => itemkey
3072 , aname => 'NUMBER_OF_CANCEL_NF_RECIPIENTS'
3073 );
3074 l_cancellation_nf_loop_counter := wf_engine.getItemAttrNumber
3075 ( itemtype => itemtype
3076 , itemkey => itemkey
3077 , aname => 'CANCELLATION_NF_LOOP_COUNTER'
3078 );
3079
3080 l_assignment_id := wf_engine.getItemAttrNumber
3081 ( itemtype => itemtype
3082 , itemkey => itemkey
3083 , aname => 'ASSIGNMENT_ID'
3084 );
3085 l_cancellation_nf_loop_counter := l_cancellation_nf_loop_counter + 1;
3086 IF l_cancellation_nf_loop_counter > l_number_of_cancel_nf_rects THEN
3087 resultout := wf_engine.eng_completed||':'||'F';
3088 RETURN;
3089 END IF;
3090 get_wf_performer (p_wf_type_code => 'CANCELLATION_FYI'
3091 ,p_item_type => itemtype
3092 ,p_item_key => itemkey
3093 ,p_routing_order => l_cancellation_nf_loop_counter
3094 ,p_object_id1 => l_assignment_id
3095 ,x_performer_name =>l_ntfy_cancel_recipient_name
3096 ,x_performer_type =>l_ntfy_cancel_rect_type );
3097 wf_engine.SetItemAttrText
3098 ( itemtype => itemtype
3099 , itemkey => itemkey
3100 , aname => 'NTFY_CANCEL_RECIPIENT_NAME'
3101 , avalue => l_ntfy_cancel_recipient_name
3102 );
3103 wf_engine.SetItemAttrNumber
3104 ( itemtype => itemtype
3105 , itemkey => itemkey
3106 , aname => 'CANCELLATION_NF_LOOP_COUNTER'
3107 , avalue => l_cancellation_nf_loop_counter
3108 );
3109 -- Do not show comments if the recipient is the resource
3110 -- otherwise show the comments. To achieve this, set the
3111 -- displayed comments field appropriately
3112 -- This is done in the set_comments procedure
3113 Set_Comment_Attributes (p_item_type => itemtype,
3114 p_item_key => itemkey ,
3115 p_rect_type =>
3116 l_ntfy_cancel_rect_type );
3117 resultout := wf_engine.eng_completed||':'||'S';
3118 EXCEPTION
3119 WHEN OTHERS THEN
3120 WF_CORE.CONTEXT
3121 ('PA_ASGMT_WFSTD',
3122 'Get_Cancel_NF_Recipient',
3123 itemtype,
3124 itemkey,
3125 to_char(actid),
3126 funcmode);
3127 RAISE;
3128 END Get_Cancel_NF_Recipient ;
3129
3130
3131
3132 PROCEDURE Set_Forwarded_From (itemtype IN VARCHAR2
3133 , itemkey IN VARCHAR2
3134 , actid IN NUMBER
3135 , funcmode IN VARCHAR2
3136 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
3137 l_forwarded_from wf_users.name%type; ----- VARCHAR2(240); Changed for bug 3267790
3138 BEGIN
3139
3140 -- Return if WF Not Running
3141 IF (funcmode <> wf_engine.eng_run) THEN
3142 resultout := wf_engine.eng_null;
3143 RETURN;
3144 END IF;
3145 -- The approval notification would have been forwarded
3146 -- from either the initial submittor or the last approver
3147 -- Prev Approver uname is set only in get approver node
3148 -- Hence, if that value is not set, get the value
3149 -- from workflow started by uname attribute, which
3150 -- is always set at the time of starting the workflow
3151 l_forwarded_from := wf_engine.GetItemAttrText
3152 ( itemtype => itemtype
3153 , itemkey => itemkey
3154 , aname => 'PREV_APPROVER_UNAME'
3155 );
3156 IF l_forwarded_from IS NULL THEN
3157 l_forwarded_from := wf_engine.GetItemAttrText
3158 ( itemtype => itemtype
3159 , itemkey => itemkey
3160 , aname => 'WORKFLOW_STARTED_BY_UNAME'
3161 );
3162 END IF;
3163 -- Now set the forwarded from field
3164 wf_engine.SetItemAttrText
3165 ( itemtype => itemtype
3166 , itemkey => itemkey
3167 , aname => 'FORWARDED_FROM'
3168 , avalue => l_forwarded_from
3169 );
3170 EXCEPTION
3171 WHEN OTHERS THEN
3172 WF_CORE.CONTEXT
3173 ('PA_ASGMT_WFSTD',
3174 'Set_Forwarded_From',
3175 itemtype,
3176 itemkey,
3177 to_char(actid),
3178 funcmode);
3179 RAISE;
3180 END Set_Forwarded_From;
3181
3182 PROCEDURE Set_Approval_Reqd_Msg (itemtype IN VARCHAR2
3183 , itemkey IN VARCHAR2
3184 , actid IN NUMBER
3185 , funcmode IN VARCHAR2
3186 , resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
3187 IS
3188 l_assignment_type pa_project_assignments.assignment_type%TYPE;
3189 l_reapproval_flag VARCHAR2(1);
3190 BEGIN
3191 IF (funcmode <> wf_engine.eng_run) THEN
3192 resultout := wf_engine.eng_null;
3193 RETURN;
3194 END IF;
3195 -- Check whether the assignment is work or admin assignment
3196 -- If work assignment check whether this is a reapproval
3197 -- Accordingly set the attributes for MSG_SUBJECT and MSG_DESCRIPTION
3198 -- All this is done in the Set_NF_Subject_and_Desc procedure
3199
3200 l_assignment_type := wf_engine.GetItemAttrText
3201 (itemtype => itemtype,
3202 itemkey => itemkey,
3203 aname => 'ASSIGNMENT_TYPE');
3204
3205 l_reapproval_flag := wf_engine.GetItemAttrText
3206 (itemtype => itemtype,
3207 itemkey => itemkey,
3208 aname => 'REAPPROVAL_FLAG');
3209
3210 -- Set the appropriate notification subject and description
3211 -- item attributes
3212
3213 Set_NF_Subject_and_Desc (p_item_type => itemtype,
3214 p_item_key => itemkey,
3215 p_assignment_type => l_assignment_type,
3216 p_reapproval_flag => l_reapproval_flag,
3217 p_msg_type => 'ASSIGNMENT_APPROVAL');
3218
3219 EXCEPTION
3220 WHEN OTHERS THEN
3221 WF_CORE.CONTEXT
3222 ('PA_ASGMT_WFSTD',
3223 'Set_Approval_Reqd_Msg',
3224 itemtype,
3225 itemkey,
3226 to_char(actid),
3227 funcmode);
3228 RAISE;
3229 END Set_Approval_Reqd_Msg ;
3230
3231 PROCEDURE Set_Approved_Msg (itemtype IN VARCHAR2
3232 , itemkey IN VARCHAR2
3233 , actid IN NUMBER
3234 , funcmode IN VARCHAR2
3235 , resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
3236 IS
3237 BEGIN
3238 IF (funcmode <> wf_engine.eng_run) THEN
3239 resultout := wf_engine.eng_null;
3240 RETURN;
3241 END IF;
3242
3243 -- Set the appropriate notification subject and description
3244 -- item attributes
3245 -- assignment type and re-approval flags are not needed for
3246 -- the approved FYI messages
3247
3248 Set_NF_Subject_and_Desc (p_item_type => itemtype,
3249 p_item_key => itemkey,
3250 p_assignment_type => NULL,
3251 p_reapproval_flag => NULL,
3252 p_msg_type => 'APPROVAL_FYI');
3253
3254 EXCEPTION
3255 WHEN OTHERS THEN
3256 WF_CORE.CONTEXT
3257 ('PA_ASGMT_WFSTD',
3258 'Set_Approved_Msg',
3259 itemtype,
3260 itemkey,
3261 to_char(actid),
3262 funcmode);
3263 RAISE;
3264 END Set_Approved_Msg;
3265
3266 PROCEDURE Set_Rejected_Msg (itemtype IN VARCHAR2
3267 ,itemkey IN VARCHAR2
3268 ,actid IN NUMBER
3269 ,funcmode IN VARCHAR2
3270 ,resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
3271
3272 IS
3273 BEGIN
3274 IF (funcmode <> wf_engine.eng_run) THEN
3275 resultout := wf_engine.eng_null;
3276 RETURN;
3277 END IF;
3278
3279 -- Set the appropriate notification subject and description
3280 -- item attributes
3281 -- assignment type and re-approval flags are not needed for
3282 -- the rejected FYI messages
3283
3284 Set_NF_Subject_and_Desc (p_item_type => itemtype,
3285 p_item_key => itemkey,
3286 p_assignment_type => NULL,
3287 p_reapproval_flag => NULL,
3288 p_msg_type => 'REJECTION_FYI');
3289 EXCEPTION
3290 WHEN OTHERS THEN
3291 WF_CORE.CONTEXT
3292 ('PA_ASGMT_WFSTD',
3293 'Set_Rejected_Msg',
3294 itemtype,
3295 itemkey,
3296 to_char(actid),
3297 funcmode);
3298 RAISE;
3299 END Set_Rejected_Msg;
3300
3301
3302 PROCEDURE Set_Canceled_Msg (itemtype IN VARCHAR2
3303 ,itemkey IN VARCHAR2
3304 ,actid IN NUMBER
3305 ,funcmode IN VARCHAR2
3306 ,resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
3307
3308 IS
3309 BEGIN
3310 IF (funcmode <> wf_engine.eng_run) THEN
3311 resultout := wf_engine.eng_null;
3312 RETURN;
3313 END IF;
3314
3315 -- Set the appropriate notification subject and description
3316 -- item attributes
3317 -- assignment type and re-approval flags are not needed for
3318 -- the rejected FYI messages
3319
3320 Set_NF_Subject_and_Desc (p_item_type => itemtype,
3321 p_item_key => itemkey,
3322 p_assignment_type => NULL,
3323 p_reapproval_flag => NULL,
3324 p_msg_type => 'CANCELLATION_FYI');
3325 EXCEPTION
3326 WHEN OTHERS THEN
3327 WF_CORE.CONTEXT
3328 ('PA_ASGMT_WFSTD',
3329 'Set_Canceled_Msg',
3330 itemtype,
3331 itemkey,
3332 to_char(actid),
3333 funcmode);
3334 RAISE;
3335 END Set_Canceled_Msg;
3336
3337
3338 PROCEDURE Validate_Forwarded_User
3339 ( itemtype IN VARCHAR2
3340 , itemkey IN VARCHAR2
3341 , actid IN NUMBER
3342 , funcmode IN VARCHAR2
3343 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
3344 l_msg_text VARCHAR2(240);
3345 invalid_user_exception EXCEPTION;
3346 BEGIN
3347 /*
3348 IF funcmode = 'FORWARD' THEN
3349 Notification assignee validations go here
3350 get the assigned user which is available in wf_engine.context_text
3351 validate this user
3352 If not valid user fnd_message.set_name ('PA','PA_NO_RESOURCE_AUTHORITY');
3353 l_msg_text := fnd_message.get;
3354 RAISE invalid_user_exception;
3355 END IF;
3356 */
3357 NULL;
3358 EXCEPTION
3359 WHEN invalid_user_exception THEN
3360 WF_CORE.CONTEXT
3361 ('PA_ASGMT_WFSTD',
3362 'Validate_Forwarded_User',
3363 l_msg_text,
3364 NULL,
3365 NULL,
3366 NULL);
3367 RAISE;
3368
3369 WHEN OTHERS THEN
3370 WF_CORE.CONTEXT
3371 ('PA_ASGMT_WFSTD',
3372 'Validate_Forwarded_User',
3373 itemtype,
3374 itemkey,
3375 to_char(actid),
3376 funcmode);
3377 RAISE;
3378
3379 END Validate_Forwarded_User ;
3380
3381 PROCEDURE Set_Approval_Pending (itemtype IN VARCHAR2
3382 , itemkey IN VARCHAR2
3383 , actid IN NUMBER
3384 , funcmode IN VARCHAR2
3385 , resultout OUT NOCOPY VARCHAR2 ) IS --File.Sql.39 bug 4440895
3386
3387 l_assignment_id pa_project_assignments.assignment_id%TYPE;
3388 BEGIN
3389 l_assignment_id := wf_engine.GetItemAttrNumber
3390 (itemtype => itemtype,
3391 itemkey => itemkey,
3392 aname => 'ASSIGNMENT_ID');
3393 Maintain_wf_pending_flag
3394 (p_assignment_id => l_assignment_id,
3395 p_mode => 'PENDING_APPROVAL'
3396 ) ;
3397
3398 EXCEPTION
3399 WHEN OTHERS THEN
3400 WF_CORE.CONTEXT
3401 ('PA_ASGMT_WFSTD',
3402 'Set_Approval_Pending',
3403 itemtype,
3404 itemkey,
3405 to_char(actid),
3406 funcmode);
3407 RAISE;
3408 END Set_Approval_Pending;
3409
3410 PROCEDURE Maintain_wf_pending_flag (p_assignment_id IN NUMBER,
3411 p_mode IN VARCHAR2 ) IS
3412 l_pending_approval_flag VARCHAR2(1);
3413 BEGIN
3414 -- if mode = 'PENDING_APPROVAL' set pending_approval_flag = 'Y'
3415 -- elseif mode = 'APPROVAL_PROCESS_COMPLETED' set
3416 --- pending_approval_flag = 'N'
3417 -- This is de-coupled from update status (though updating
3418 -- the same entity, since status may be maintained in multiple
3419 -- places and the pending flag has to be maintained both at the
3420 --start and completeion of the approval WF.
3421 IF p_mode = 'PENDING_APPROVAL' THEN
3422 l_pending_approval_flag := 'Y';
3423 ELSIF
3424 p_mode = 'APPROVAL_PROCESS_COMPLETED' THEN
3425 l_pending_approval_flag := 'N';
3426 ELSE
3427 -- placeholder for any possible future values
3428 l_pending_approval_flag := 'N';
3429 END IF;
3430 UPDATE pa_project_assignments
3431 SET pending_approval_flag = l_pending_approval_flag,
3432 record_version_number = record_version_number + 1
3433 WHERE assignment_id = p_assignment_id;
3434 EXCEPTION
3435 WHEN OTHERS THEN
3436 RAISE;
3437 END Maintain_wf_pending_flag ;
3438
3439
3440 PROCEDURE Set_Asgmt_wf_result_Status
3441 (p_assignment_id IN pa_project_assignments.assignment_id%TYPE,
3442 p_status_code IN pa_project_statuses.project_status_code%TYPE,
3443 p_result_type IN VARCHAR2,
3444 p_item_type IN VARCHAR2,
3445 p_item_key IN VARCHAR2,
3446 x_return_status OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
3447 IS
3448 l_apprvl_status_code pa_project_statuses.project_status_code%TYPE;
3449 l_change_id pa_assignments_history.change_id%TYPE;
3450 l_return_status VARCHAR2(30);
3451 l_msg_count NUMBER := 0;
3452 l_msg_data VARCHAR2(500);
3453 l_record_version_number NUMBER := 0;
3454 l_out_record_version_number NUMBER := 0;
3455 l_conflict_group_id NUMBER;
3456 l_submitter_uname wf_users.name%type; --- VARCHAR2(100); Changed for bug 3267790
3457 /* Modified length from 30 to 100 for bug 3148857 */
3458 NO_ASSIGNMENT_ID EXCEPTION;
3459
3460 CURSOR l_get_record_version_csr IS
3461 SELECT record_version_number FROM
3462 pa_project_assignments
3463 WHERE assignment_id = p_assignment_id;
3464
3465 BEGIN
3466 OPEN l_get_record_version_csr;
3467 FETCH l_get_record_version_csr
3468 INTO l_record_version_number;
3469
3470 IF l_get_record_version_csr%NOTFOUND THEN
3471 CLOSE l_get_record_version_csr;
3472 RAISE NO_ASSIGNMENT_ID;
3473 END IF;
3474 CLOSE l_get_record_version_csr;
3475
3476 -- call the pa_asgmt_approval_pvt to update the
3477 -- assignment approval status and the schedules
3478 x_return_status := FND_API.G_RET_STS_SUCCESS ;
3479 SAVEPOINT asgmt_apprvl;
3480
3481 pa_assignment_approval_pvt.update_approval_status
3482 (p_assignment_id => p_assignment_id,
3483 p_action_code => p_result_type,
3484 p_record_version_number => l_record_version_number,
3485 x_apprvl_status_code => l_apprvl_status_code,
3486 x_change_id => l_change_id,
3487 x_record_version_number => l_out_record_version_number,
3488 x_return_status => l_return_status ,
3489 x_msg_count => l_msg_count,
3490 x_msg_data => l_msg_data );
3491
3492 -- if return status <> SUCCESS, populate the error messages rollback to asgmt_apprvl
3493 -- and return error
3494 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3495 set_nf_error_msg_attr (p_item_type => p_item_type,
3496 p_item_key => p_item_key,
3497 p_msg_count => l_msg_count,
3498 p_msg_data => l_msg_data);
3499 ROLLBACK TO asgmt_apprvl;
3500 x_return_status := l_return_status;
3501 ELSE
3502 -------------------------------------------------------------------
3503 -- Resolve Overcommitment conflict for Approve
3504 -------------------------------------------------------------------
3505 l_conflict_group_id := wf_engine.GetItemAttrNumber
3506 (itemtype => p_item_type,
3507 itemkey => p_item_key,
3508 aname => 'CONFLICT_GROUP_ID');
3509
3510 l_submitter_uname := wf_engine.GetItemAttrText
3511 ( itemtype => p_item_type
3512 , itemkey => p_item_key
3513 , aname => 'WORKFLOW_STARTED_BY_UNAME');
3514
3515 IF (l_conflict_group_id IS NOT NULL AND p_result_type=PA_ASSIGNMENT_APPROVAL_PUB.g_approve_action) THEN
3516 -- resolve remaining conflicts by taking action chosen by user
3517 PA_SCHEDULE_PVT.RESOLVE_CONFLICTS (p_conflict_group_id => l_conflict_group_id
3518 ,p_assignment_id => p_assignment_id
3519 ,x_return_status => l_return_status
3520 ,x_msg_count => l_msg_count
3521 ,x_msg_data => l_msg_data);
3522 /*IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3523 RAISE FND_API.G_EXC_ERROR;
3524 END IF;*/
3525
3526 -- complete post overcommitment processing
3527 PA_SCHEDULE_PVT.OVERCOM_POST_APRVL_PROCESSING
3528 (p_conflict_group_id => l_conflict_group_id
3529 ,p_fnd_user_name => l_submitter_uname
3530 ,x_return_status => l_return_status
3531 ,x_msg_count => l_msg_count
3532 ,x_msg_data => l_msg_data);
3533 /*IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3534 RAISE FND_API.G_EXC_ERROR;
3535 END IF;*/
3536 END IF; -- IF (l_conflict_group_id IS NOT NULL...
3537 END IF;
3538
3539 Maintain_wf_pending_flag
3540 (p_assignment_id => p_assignment_id,
3541 p_mode => 'APPROVAL_PROCESS_COMPLETED');
3542
3543 -- Set the attribute NEW_ASGMT_STATUS_CODE
3544 wf_engine.SetItemAttrText
3545 ( itemtype => p_item_type
3546 , itemkey => p_item_key
3547 , aname => 'NEW_ASGMT_STATUS_CODE'
3548 , avalue => l_apprvl_status_code);
3549 EXCEPTION
3550 WHEN NO_ASSIGNMENT_ID THEN
3551 WF_CORE.CONTEXT
3552 ('PA_ASGMT_WFSTD',
3553 'Set_Asgmt_wf_result_status',
3554 p_item_type,
3555 p_item_key,
3556 'INVALID_ASSIGNMENT_ID',
3557 NULL );
3558 RAISE;
3559 WHEN OTHERS THEN RAISE;
3560 END Set_Asgmt_wf_result_status;
3561
3562
3563
3564 PROCEDURE Capture_approver_comment (itemtype IN VARCHAR2
3565 , itemkey IN VARCHAR2
3566 , actid IN NUMBER
3567 , funcmode IN VARCHAR2
3568 , resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
3569 IS
3570 l_comment VARCHAR2(4000); --VARCHAR2(2000); Bug 7459451 : Changed the length to accomodate max length returned by wf_engine.getItemAttrText
3571 l_approver_user_name wf_users.name%type; ----- VARCHAR2(240);Changed for bug 3267790
3572 /* Modified length from 30 to 100 for bug 3148857 */
3573 l_assignment_id NUMBER;
3574 l_wf_context_user pa_wf_ntf_performers.user_name%TYPE;
3575 l_reassignee_user_name pa_wf_ntf_performers.user_name%TYPE;
3576 l_object_id1 pa_wf_ntf_performers.object_id1%TYPE;
3577 l_object_id2 pa_wf_ntf_performers.object_id2%TYPE;
3578 l_prev_approver_user_name pa_wf_ntf_performers.user_name%TYPE;
3579
3580 CURSOR get_reassignee IS
3581 SELECT USER_NAME
3582 FROM pa_wf_ntf_performers
3583 WHERE user_name = l_wf_context_user
3584 AND wf_type_code = 'ASSIGNMENT_APPROVAL'
3585 AND item_type = itemtype
3586 AND item_key = itemkey;
3587
3588 CURSOR get_objectids IS
3589 SELECT object_id1, object_id2
3590 FROM pa_wf_ntf_performers
3591 WHERE wf_type_code = 'ASSIGNMENT_APPROVAL'
3592 AND item_type = itemtype
3593 AND item_key = itemkey
3594 AND current_approver_flag = 'Y';
3595
3596 BEGIN
3597 l_comment := wf_engine.GetItemAttrText
3598 ( itemtype => itemtype
3599 , itemkey => itemkey
3600 , aname => 'APPROVER_RESPONSE'
3601 );
3602 IF l_comment IS NOT NULL THEN
3603 l_approver_user_name := wf_engine.GetItemAttrText
3604 ( itemtype => itemtype
3605 , itemkey => itemkey
3606 , aname => 'APPROVER_UNAME'
3607 );
3608 l_assignment_id := wf_engine.GetItemAttrNumber
3609 ( itemtype => itemtype
3610 , itemkey => itemkey
3611 , aname => 'ASSIGNMENT_ID'
3612 );
3613 UPDATE pa_wf_ntf_performers
3614 SET approver_comments = substr(l_comment,1,255)
3615 WHERE item_type = itemtype
3616 AND item_key = itemkey
3617 AND object_id1 = l_assignment_id
3618 AND user_name = l_approver_user_Name;
3619 -- Now reset the approver response attribute
3620 -- so that the next approver can add his/her comments
3621 wf_engine.SetItemAttrText
3622 ( itemtype => itemtype
3623 , itemkey => itemkey
3624 , aname => 'APPROVER_RESPONSE'
3625 , avalue => NULL
3626 );
3627 END IF;
3628
3629 --IF the user reassigns the notification to another person, two things need to be done
3630 --1) If the reassignee is not already in the notification table, insert into notification and
3631 -- set current_approver_flag to 'Y'. If reassignee is already in the table, then just set flag to 'Y'
3632 --2) Set the Forwarded_From attribute for display
3633 IF funcmode IN ('TRANSFER', 'FORWARD') THEN
3634
3635 l_wf_context_user := WF_ENGINE.context_text;
3636
3637 --Check to see if the reassignee already in the table
3638 OPEN get_reassignee;
3639 FETCH get_reassignee INTO l_reassignee_user_name;
3640 CLOSE get_reassignee;
3641
3642 --IF not in the table, then insert and set current_approver_flag to 'Y'
3643 IF l_reassignee_user_name IS NULL THEN
3644
3645
3646 --Get object_ids for inserting into the new record
3647 OPEN get_objectids;
3648 FETCH get_objectids INTO l_object_id1, l_object_id2;
3649 CLOSE get_objectids;
3650
3651 INSERT INTO pa_wf_ntf_performers (WF_TYPE_CODE, ITEM_TYPE, ITEM_KEY,
3652 OBJECT_ID1, OBJECT_ID2, USER_NAME,
3653 USER_TYPE, CURRENT_APPROVER_FLAG)
3654 VALUES ('ASSIGNMENT_APPROVAL', itemtype, itemkey,
3655 l_object_id1, l_object_id2, l_wf_context_user,
3656 'REASSIGNEE', 'Y');
3657
3658 END IF;
3659
3660
3661 --Set current_approver_flag to 'N' for the previous current_approver
3662 UPDATE pa_wf_ntf_performers
3663 SET current_approver_flag = (DECODE(user_name,l_wf_context_user,'Y','N'))
3664 WHERE wf_type_code = 'ASSIGNMENT_APPROVAL'
3665 AND item_type = itemtype
3666 AND item_key = itemkey
3667 AND current_approver_flag = 'Y';
3668
3669
3670 --
3671 --Correctly set the forwarded_from attribute
3672 --
3673
3674 --set the previous_approver attribute correctly
3675 l_prev_approver_user_name :=
3676 wf_engine.GetItemAttrText
3677 ( itemtype => itemtype
3678 , itemkey => itemkey
3679 , aname => 'APPROVER_UNAME');
3680 wf_engine.SetItemAttrText
3681 ( itemtype => itemtype
3682 , itemkey => itemkey
3683 , aname => 'PREV_APPROVER_UNAME'
3684 , avalue => l_prev_approver_user_name
3685 );
3686
3687 --set current_approver to be the reassignee
3688 wf_engine.SetItemAttrText
3689 ( itemtype => itemtype
3690 , itemkey => itemkey
3691 , aname => 'APPROVER_UNAME'
3692 , avalue => l_wf_context_user
3693 );
3694
3695
3696 --call set_forwarded_from procedure
3697 Set_Forwarded_From (itemtype => itemtype
3698 , itemkey => itemkey
3699 , actid => actid
3700 , funcmode => funcmode
3701 , resultout => resultout);
3702
3703 --set notification attribute forwarded_from to let the change show up
3704 WF_NOTIFICATION.SetAttrText (nid => WF_ENGINE.context_nid
3705 ,aname => 'FORWARDED_FROM'
3706 ,avalue => l_prev_approver_user_name);
3707
3708 /*
3709
3710 INSERT INTO pa_wf_ntf_performers (WF_TYPE_CODE, ITEM_TYPE, ITEM_KEY,
3711 OBJECT_ID1, OBJECT_ID2, USER_NAME,
3712 USER_TYPE, CURRENT_APPROVER_FLAG)
3713 VALUES ('ASSIGNMENT_APPROVAL', itemtype, itemkey,
3714 1, 2, l_wf_context_user,
3715 'REASSIGNEE', 'Y');
3716 */
3717 END IF; --end of checking in 'TRANSFER'/'FORWARD' mode
3718 exception
3719 WHEN OTHERS THEN
3720 wf_core.context
3721 ('PA_ASGMT_WFSTD',
3722 'Capture_approver_comment',
3723 itemtype,
3724 itemkey);
3725 RAISE;
3726 END Capture_approver_comment;
3727
3728 PROCEDURE Capture_approver_response (p_item_type IN VARCHAR2,
3729 p_item_key IN VARCHAR2)
3730 IS
3731 BEGIN
3732 g_approver_response :=
3733 wf_engine.GetItemAttrText
3734 ( itemtype => p_item_type
3735 , itemkey => p_item_key
3736 , aname => 'APPROVER_RESPONSE'
3737 );
3738 EXCEPTION
3739 WHEN OTHERS THEN RAISE;
3740 END Capture_approver_response;
3741
3742 PROCEDURE Populate_approval_NF_comments (itemtype IN VARCHAR2
3743 , itemkey IN VARCHAR2
3744 , actid IN NUMBER
3745 , funcmode IN VARCHAR2
3746 , resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
3747 IS
3748 l_assignment_id pa_project_assignments.assignment_id%TYPE;
3749
3750 BEGIN
3751 -- Call the set_approver_comments procedure.
3752 -- Since populate_approval_NF_comments is being called from the
3753 -- approval process, pass the same item type and item key values
3754 -- for both p_apprvl and p_item parameters
3755
3756 l_assignment_id := wf_engine.GetItemAttrNumber
3757 (itemtype => itemtype,
3758 itemkey => itemkey,
3759 aname => 'ASSIGNMENT_ID');
3760
3761 Set_approver_comments (p_apprvl_item_type => itemtype
3762 ,p_apprvl_item_key => itemkey
3763 ,p_item_type => itemtype
3764 ,p_item_key => itemkey
3765 ,p_assignment_id => l_assignment_id);
3766
3767 -- Now call the set comment attributes procedure
3768 -- This will copy the comments from the internal comments
3769 -- attribute to the displayed comments attributes
3770 -- Since the comments are to be displayed only to
3771 -- an approver, there is no need to send a value for
3772 -- p_rect_type parameter. A value for this parameter
3773 -- is needed only if the recipient is the RESOURCE
3774 -- since all comments have to be suppressed in a notification
3775 -- a Resource recieves. A Resource would never recieve an
3776 -- 'Approval required ' notification
3777
3778 Set_Comment_Attributes (p_item_type => itemtype,
3779 p_item_key => itemkey ,
3780 p_rect_type => NULL );
3781 EXCEPTION
3782 WHEN OTHERS THEN
3783 wf_core.context
3784 ('PA_ASGMT_WFSTD',
3785 'Populate_approval_NF_comments' ,
3786 itemtype,
3787 itemkey);
3788 RAISE;
3789
3790 END Populate_approval_NF_comments;
3791
3792 PROCEDURE generate_sch_err_msg
3793 (document_id IN VARCHAR2,
3794 display_type IN VARCHAR2,
3795 document IN OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
3796 document_type IN OUT NOCOPY VARCHAR2) IS --File.Sql.39 bug 4440895
3797 l_msg_count NUMBER ;
3798 l_msg_index_out NUMBER ;
3799 l_msg_data VARCHAR2(2000);
3800 l_data VARCHAR2(2000);
3801 l_newline VARCHAR2(10);
3802 l_item_type VARCHAR2(200);
3803 l_item_key VARCHAR2(200);
3804 l_msg_text VARCHAR2(300);
3805 CURSOR l_nf_csr IS
3806 SELECT item_type, item_key
3807 FROM wf_item_activity_statuses
3808 WHERE notification_id = document_id;
3809
3810 BEGIN
3811 l_newline := FND_GLOBAL.newline;
3812 l_msg_count := FND_MSG_PUB.Count_Msg;
3813 OPEN l_nf_csr;
3814 FETCH l_nf_csr INTO l_item_type, l_item_key;
3815 IF l_nf_csr%NOTFOUND THEN
3816 document := 'Item Key not found';
3817 CLOSE l_nf_csr;
3818 RETURN;
3819 ELSE
3820 CLOSE l_nf_csr;
3821 END IF;
3822 -- document := '<html>';
3823 document_type := 'text/html';
3824 l_msg_data := wf_engine.GetItemAttrText
3825 ( itemtype => l_item_type
3826 , itemkey => l_item_key
3827 , aname => 'L_MSG_DATA'
3828 );
3829 IF l_msg_count = 0 THEN
3830 document := 'No errors in the stack';
3831 RETURN;
3832 END IF;
3833
3834 IF l_msg_count > 1 THEN
3835 FOR i in 1..l_msg_count LOOP
3836 pa_interface_utils_pub.get_messages
3837 (p_encoded => FND_API.G_FALSE,
3838 p_msg_index => i,
3839 p_msg_count => l_msg_count ,
3840 p_msg_data => l_msg_data ,
3841 p_data => l_data,
3842 p_msg_index_out => l_msg_index_out );
3843 document := document || ' <p>' || l_data ||' </p>';
3844 END LOOP;
3845 ELSIF l_msg_count = 1 THEN
3846 FND_MESSAGE.SET_ENCODED (l_msg_data);
3847 l_data := FND_MESSAGE.GET;
3848 document := document || ' <p>' || l_data ||' </p>';
3849 END IF;
3850
3851 exception
3852 WHEN OTHERS THEN
3853 wf_core.context('PA_ASGMT_WFSTD','Generate_sch_err_msg',Document_id,NULL);
3854 RAISE;
3855 END generate_sch_err_msg;
3856
3857 PROCEDURE set_nf_error_msg_attr (p_item_type IN VARCHAR2,
3858 p_item_key IN VARCHAR2,
3859 p_msg_count IN NUMBER,
3860 p_msg_data IN VARCHAR2 ) IS
3861
3862 l_msg_index_out NUMBER ;
3863 l_msg_data VARCHAR2(2000);
3864 l_data VARCHAR2(2000);
3865 l_item_attr_name VARCHAR2(30);
3866 BEGIN
3867 IF p_msg_count = 0 THEN
3868 RETURN;
3869 END IF;
3870
3871 IF p_msg_count = 1 THEN
3872 IF p_msg_data IS NOT NULL THEN
3873 FND_MESSAGE.SET_ENCODED (p_msg_data);
3874 l_data := FND_MESSAGE.GET;
3875 wf_engine.SetItemAttrText
3876 ( itemtype => p_item_type
3877 , itemkey => p_item_key
3878 , aname => 'ERROR_MSG1'
3879 , avalue => l_data
3880 );
3881 END IF;
3882 RETURN ;
3883 END IF;
3884
3885 IF p_msg_count > 1 THEN
3886 FOR i in 1..p_msg_count
3887 LOOP
3888 IF i > 5 THEN
3889 EXIT;
3890 END IF;
3891 pa_interface_utils_pub.get_messages
3892 (p_encoded => FND_API.G_FALSE,
3893 p_msg_index => i,
3894 p_msg_count => p_msg_count ,
3895 p_msg_data => p_msg_data ,
3896 p_data => l_data,
3897 p_msg_index_out => l_msg_index_out );
3898 l_item_attr_name := 'ERROR_MSG'||i;
3899 wf_engine.SetItemAttrText
3900 ( itemtype => p_item_type
3901 , itemkey => p_item_key
3902 , aname => l_item_attr_name
3903 , avalue => l_data
3904 );
3905 END LOOP;
3906 END IF;
3907 EXCEPTION
3908 WHEN OTHERS THEN RAISE;
3909 END set_nf_error_msg_attr;
3910
3911 PROCEDURE get_primary_contact_info
3912 (p_resource_id IN NUMBER
3913 , p_assignment_id IN NUMBER
3914 , p_approver1_person_id IN NUMBER
3915 , p_approver1_type IN VARCHAR2
3916 , p_approver2_person_id IN NUMBER
3917 , p_approver2_type IN VARCHAR2
3918 , x_PrimaryContactId OUT NOCOPY NUMBER ) --File.Sql.39 bug 4440895
3919 IS
3920 l_primarycontactname per_all_people_f.full_name%type; ----- VARCHAR2(240);Changed for bug 3267790
3921 l_managerid NUMBER := 0;
3922 l_managername per_all_people_f.full_name%type;----- VARCHAR2(240);Changed for bug 3267790
3923 l_return_status VARCHAR2(1);
3924 l_msg_count NUMBER ;
3925 l_msg_data VARCHAR2(2000);
3926 BEGIN
3927 -- If the primary contact was either the 1st or 2nd approver
3928 -- then return the appropriate person id
3929 IF p_approver1_type = 'ORG_PRIMARY_CONTACT' THEN
3930 x_PrimaryContactId := p_approver1_person_id;
3931 RETURN;
3932 ELSIF p_approver2_type = 'ORG_PRIMARY_CONTACT' THEN
3933 x_PrimaryContactId := p_approver2_person_id;
3934 RETURN;
3935 END IF;
3936 -- If the primary contact is neither of the two approvers,
3937 -- then get that info from the DB
3938 pa_resource_utils.get_org_primary_contact
3939 (P_ResourceId => p_resource_id
3940 ,p_assignment_id => p_assignment_id
3941 ,x_PrimaryContactId => x_primarycontactid
3942 ,x_PrimaryContactName => l_primarycontactname
3943 ,x_ManagerId => l_managerid
3944 ,x_ManagerName => l_managername
3945 ,x_return_Status => l_return_status
3946 ,x_msg_count => l_msg_count
3947 ,x_msg_data => l_msg_data
3948 ) ;
3949 EXCEPTION
3950 WHEN OTHERS THEN RAISE;
3951
3952 END get_primary_contact_info;
3953
3954 PROCEDURE populate_wf_performers
3955 ( p_wf_type_code IN VARCHAR2
3956 ,p_item_type IN VARCHAR2
3957 ,p_item_key IN VARCHAR2
3958 ,p_object_id1 IN VARCHAR2
3959 ,p_object_id2 IN VARCHAR2
3960 ,p_in_performers_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp
3961 ,p_current_approver_flag IN VARCHAR2
3962 ,x_number_of_performers OUT NOCOPY NUMBER ) --File.Sql.39 bug 4440895
3963 IS
3964 l_number_of_performers NUMBER := 0;
3965 BEGIN
3966 -- Need to insert the user names into
3967 -- the members table. To validate the users first
3968 -- to ensure that notifications can be appropriately sent
3969 -- Insert only active users
3970 x_number_of_performers := 0;
3971 IF p_in_performers_tbl.EXISTS(1) THEN
3972 FOR i IN 1..p_in_performers_tbl.COUNT LOOP
3973 IF wf_directory.UserActive
3974 (p_in_performers_tbl(i).User_Name) THEN
3975 INSERT INTO pa_wf_ntf_performers (
3976 Wf_Type_Code,Item_Type,
3977 Item_Key,object_id1,
3978 object_id2,User_Name,User_Type,
3979 Routing_Order,Current_Approver_flag
3980 )
3981 VALUES
3982 ( p_wf_type_code,
3983 p_item_type,
3984 p_item_key,
3985 p_object_id1,
3986 p_object_id2,
3987 p_in_performers_tbl(i).User_Name,
3988 p_in_performers_tbl(i).Type,
3989 p_in_performers_tbl(i).Routing_Order,
3990 p_current_approver_flag );
3991 l_number_of_performers := l_number_of_performers + 1;
3992 END IF;
3993 END LOOP;
3994 END IF;
3995 x_number_of_performers := l_number_of_performers;
3996 EXCEPTION
3997 WHEN OTHERS THEN RAISE;
3998 END populate_wf_performers;
3999
4000 PROCEDURE get_wf_performer (p_wf_type_code IN VARCHAR2,
4001 p_item_type IN VARCHAR2,
4002 p_item_key IN VARCHAR2,
4003 p_routing_order IN NUMBER,
4004 p_object_id1 IN VARCHAR2 ,
4005 x_performer_name OUT NOCOPY VARCHAR2, --File.Sql.39 bug 4440895
4006 x_performer_type OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
4007 IS
4008 CURSOR l_get_next_performer_csr
4009 IS
4010 SELECT User_Name , User_Type FROM pa_wf_ntf_performers
4011 WHERE wf_type_code = p_wf_type_code
4012 AND item_type = p_item_type
4013 AND item_key = p_item_key
4014 AND routing_order = p_routing_order
4015 AND object_id1 = p_object_id1;
4016
4017 l_user_name pa_wf_ntf_performers.user_name%TYPE;
4018
4019 BEGIN
4020
4021 OPEN l_get_next_performer_csr ;
4022 FETCH l_get_next_performer_csr INTO
4023 x_performer_name, x_performer_type ;
4024 IF l_get_next_performer_csr%NOTFOUND THEN
4025 x_performer_name := NULL;
4026 x_performer_type := NULL;
4027 END IF;
4028
4029 CLOSE l_get_next_performer_csr;
4030
4031
4032 --Bug 1770103: do not send FYI notification to the user logged in.
4033
4034 IF p_wf_type_code like '%FYI' THEN
4035
4036 --Get the Name of the User logged In.
4037 l_user_name := wf_engine.GetItemAttrText
4038 ( itemtype => p_item_type
4039 , itemkey => p_item_key
4040 , aname => 'WORKFLOW_STARTED_BY_UNAME');
4041 /* IF x_performer_name = l_user_name THEN
4042 x_performer_name := NULL;
4043 x_performer_type := NULL;
4044 END IF;*/
4045 END IF;
4046 --end of bug 1770103
4047
4048 EXCEPTION
4049 WHEN OTHERS THEN RAISE;
4050 END get_wf_performer ;
4051
4052 PROCEDURE Set_approver_comments (p_apprvl_item_type VARCHAR2,
4053 p_apprvl_item_key VARCHAR2,
4054 p_item_type VARCHAR2,
4055 p_item_key VARCHAR2,
4056 p_assignment_id NUMBER )
4057 IS
4058 CURSOR l_get_approver_comments_csr IS
4059 SELECT user_Name,approver_comments
4060 FROM pa_wf_ntf_performers
4061 WHERE item_type = p_apprvl_item_type
4062 AND item_key = p_apprvl_item_key
4063 AND object_id1 = p_assignment_id
4064 AND approver_comments IS NOT NULL;
4065 l_get_approver_comments_rec l_get_approver_comments_csr%ROWTYPE;
4066 l_counter NUMBER := 0;
4067 l_item_attr_name VARCHAR2(30);
4068 BEGIN
4069 -- Using the approval item type , get the
4070 -- comments of the approvers.
4071 -- p_apprvl_item_type and p_item_type
4072 -- would be different if the FYI notification wf is triggered
4073 -- by the approval workflow.
4074 -- When this procedure is invoked by the approval workflow
4075 -- p_apprvl_item_type and p_item_type would be the same
4076
4077 IF (p_apprvl_item_type IS NOT NULL AND p_apprvl_item_key
4078 IS NOT NULL ) THEN
4079 OPEN l_get_approver_comments_csr;
4080 LOOP
4081 FETCH l_get_approver_comments_csr INTO
4082 l_get_approver_comments_rec;
4083 IF l_get_approver_comments_csr%NOTFOUND THEN
4084 EXIT;
4085 END IF;
4086 l_counter := l_counter + 1;
4087 IF l_counter > 5 THEN
4088 EXIT;
4089 END IF;
4090 -- Now set the appropriate comments attributes for this WF
4091 -- Populate the internal comments only . displayed comments
4092 -- will be done by the get_recipients nodes
4093 l_item_attr_name := 'INTERNAL_APPROVER_COMMENTS_'||l_counter ;
4094 wf_engine.SetItemAttrText
4095 ( itemtype => p_item_type
4096 , itemkey => p_item_key
4097 , aname => l_item_attr_name
4098 , avalue =>
4099 l_get_approver_comments_rec.user_name ||
4100 ' : ' ||
4101 l_get_approver_comments_rec.approver_comments
4102 );
4103 END LOOP;
4104 CLOSE l_get_approver_comments_csr;
4105 END IF;
4106
4107 EXCEPTION
4108 WHEN OTHERS THEN RAISE;
4109 END Set_Approver_Comments;
4110
4111 PROCEDURE Set_Comment_Attributes (p_item_type IN VARCHAR2,
4112 p_item_key IN VARCHAR2,
4113 p_rect_type IN VARCHAR2 ) IS
4114 l_comments_item_attr_name VARCHAR2(30);
4115 l_comments VARCHAR2(4000); -- VARCHAR2(255); Bug 7459451 : Changed the length to accomodate max length returned by wf_engine.getItemAttrText
4116 BEGIN
4117 -- Set displayed comments to NULL if the recipient is resource
4118 -- otherwise set the displayed comments to the internal comments
4119 FOR i IN 1..5 LOOP
4120 l_comments_item_attr_name := 'INTERNAL_APPROVER_COMMENTS_'||i;
4121 l_comments := wf_engine.getItemAttrText
4122 ( itemtype => p_item_type
4123 , itemkey => p_item_key
4124 , aname => l_comments_item_attr_name
4125 );
4126 IF p_rect_type = 'RESOURCE' THEN
4127 l_comments := NULL;
4128 END IF;
4129 wf_engine.SetItemAttrText
4130 ( itemtype => p_item_type
4131 , itemkey => p_item_key
4132 , aname => 'APPROVER_COMMENTS_'||i
4133 , avalue => l_comments
4134 );
4135 END LOOP;
4136
4137 EXCEPTION
4138 WHEN OTHERS THEN RAISE;
4139 END Set_Comment_Attributes;
4140
4141 PROCEDURE Check_And_Get_Proj_Customer ( p_project_id IN NUMBER
4142 ,x_customer_id OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
4143 ,x_customer_name OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
4144 IS
4145
4146 l_customer_id pa_project_customers.customer_id%TYPE;
4147 l_num_ids NUMBER;
4148
4149 CURSOR l_check_one_cust_only_csr IS
4150 SELECT customer_id FROM pa_project_customers
4151 WHERE project_id = p_project_id;
4152
4153 /*
4154 CURSOR l_get_cust_csr IS
4155 SELECT ppc.customer_id,rac.customer_name
4156 FROM pa_project_customers ppc,
4157 ra_customers rac
4158 WHERE ppc.project_id = p_project_id
4159 AND rac.customer_id = ppc.customer_id ;
4160 */
4161
4162 -- 4363092 TCA changes, replaced RA views with HZ tables
4163 /*
4164 CURSOR l_get_cust_csr IS
4165 SELECT customer_name
4166 FROM ra_customers
4167 WHERE customer_id = l_customer_id;
4168 */
4169 CURSOR l_get_cust_csr IS
4170 SELECT substrb(party.party_name,1,50) customer_name
4171 FROM hz_parties party, hz_cust_accounts cust_acct
4172 WHERE cust_acct.cust_account_id = l_customer_id
4173 and cust_acct.party_id = party.party_id ;
4174 -- 4363092 end
4175
4176 BEGIN
4177 OPEN l_check_one_cust_only_csr;
4178
4179 LOOP
4180 FETCH l_check_one_cust_only_csr INTO l_customer_id;
4181 EXIT WHEN (l_check_one_cust_only_csr%ROWCOUNT > 1 OR l_check_one_cust_only_csr%NOTFOUND);
4182 END LOOP;
4183 l_num_ids := l_check_one_cust_only_csr%ROWCOUNT;
4184
4185 CLOSE l_check_one_cust_only_csr;
4186
4187 IF (l_num_ids = 1) THEN
4188 x_customer_id := l_customer_id;
4189
4190 OPEN l_get_cust_csr;
4191 FETCH l_get_cust_csr INTO
4192 x_customer_name;
4193 CLOSE l_get_cust_csr;
4194 END IF;
4195
4196 EXCEPTION
4197 WHEN OTHERS THEN RAISE;
4198
4199 END Check_And_Get_proj_customer;
4200
4201 PROCEDURE Set_NF_Subject_and_Desc (p_item_type IN VARCHAR2,
4202 p_item_key IN VARCHAR2,
4203 p_assignment_type IN VARCHAR2,
4204 p_reapproval_flag IN VARCHAR2,
4205 p_msg_type IN VARCHAR2) IS
4206 l_msg_subj_code VARCHAR2(30);
4207 l_msg_desc_code VARCHAR2(30);
4208 l_msg_subj_text VARCHAR2(2000);
4209 l_msg_desc_text VARCHAR2(2000);
4210 l_msg_subj_itemattr_name VARCHAR2(30);
4211 l_msg_desc_itemattr_name VARCHAR2(30);
4212 l_assignment_id NUMBER ;
4213 l_conflict_group_id NUMBER ;
4214 l_resolve_conflicts_by_rmvl VARCHAR2(1);
4215 l_view_conflict_url VARCHAR2(2000);
4216 l_return_status VARCHAR2(1);
4217 l_msg_count NUMBER ;
4218 l_msg_data VARCHAR2(2000);
4219
4220 BEGIN
4221
4222 /*
4223 Pass the following . assignment_type,reapproval_flag
4224 ,msg_type - ASSIGNMENT_APPROVAL
4225 , APPROVAL_FYI , REJECTION_FYI
4226 If assignment approval ,
4227 If admin assignment
4228 Set msg subj and header as Admin approval
4229 Else
4230 If reapproval set msg subj and header as reapproval
4231 End if
4232 Elsif
4233 approval FYI set msg subj and header FYI depends on ovecommitment result.
4234 Elsif
4235 rejection FYI set msg subj and header FYI as rejected
4236 Elsif
4237 cancellation FYI set msg subj and header FYI as canceled
4238 End if
4239 */
4240 IF p_msg_type = 'ASSIGNMENT_APPROVAL' THEN
4241 l_msg_subj_itemattr_name := 'MSG_SUBJECT';
4242 l_msg_desc_itemattr_name := 'MSG_DESCRIPTION';
4243
4244 IF p_assignment_type = 'STAFFED_ADMIN_ASSIGNMENT' THEN
4245 l_msg_subj_code := 'PA_NFSUBJ_ADM_ASG_APRVL_REQD';
4246 l_msg_desc_code := 'PA_NFDESC_ADM_ASG_APRVL_REQD';
4247 ELSIF p_assignment_type = 'STAFFED_ASSIGNMENT' THEN
4248 IF p_reapproval_flag = 'Y' THEN
4249 l_msg_subj_code := 'PA_NFSUBJ_ASG_REAPRVL_REQD';
4250 l_msg_desc_code := 'PA_NFDESC_ASG_REAPRVL_REQD';
4251 ELSE
4252 l_msg_subj_code := 'PA_NFSUBJ_ASG_APRVL_REQD';
4253 l_msg_desc_code := 'PA_NFDESC_ASG_APRVL_REQD';
4254 END IF;
4255 END IF;
4256
4257 ELSIF p_msg_type = 'APPROVAL_FYI' THEN
4258 l_assignment_id := wf_engine.GetItemAttrNumber
4259 (itemtype => p_item_type,
4260 itemkey => p_item_key,
4261 aname => 'ASSIGNMENT_ID');
4262 l_conflict_group_id := wf_engine.GetItemAttrNumber
4263 (itemtype => p_item_type,
4264 itemkey => p_item_key,
4265 aname => 'CONFLICT_GROUP_ID');
4266
4267 -- If there is no overcommitment conflict
4268 IF (l_conflict_group_id IS NULL) THEN
4269 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_APPROVED';
4270 l_msg_desc_code := 'PA_NFDESC_ASGMT_APPROVED';
4271
4272 -- set 'Number of Assignments Resulting in Resource Overcommitment -1/0' for single
4273 -- approval FYI notification.
4274 wf_engine.SetItemAttrNumber
4275 ( itemtype => p_item_type
4276 , itemkey => p_item_key
4277 , aname => 'NUMBER_OF_OVERCOM_ASGMT'
4278 , avalue => 0 );
4279 -- If there is any overcommitment conflict
4280 ELSE
4281 PA_SCHEDULE_PVT.has_resolved_conflicts_by_rmvl
4282 ( p_conflict_group_id => l_conflict_group_id
4283 , p_assignment_id => l_assignment_id
4284 , x_resolve_conflicts_by_rmvl => l_resolve_conflicts_by_rmvl
4285 , x_return_status => l_return_status
4286 , x_msg_count => l_msg_count
4287 , x_msg_data => l_msg_data);
4288 IF (l_resolve_conflicts_by_rmvl = 'Y') THEN
4289 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_APPR_CONF_REM';
4290 l_msg_desc_code := 'PA_NFDESC_ASGMT_APPR_CONF_REM';
4291 ELSE
4292 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_APPR_KP_CONF';
4293 l_msg_desc_code := 'PA_NFDESC_ASGMT_APPR_KP_CONF';
4294 END IF;
4295
4296 -- set 'Number of Assignments Resulting in Resource Overcommitment -1/0' for single
4297 -- approval FYI notification.
4298 wf_engine.SetItemAttrNumber
4299 ( itemtype => p_item_type
4300 , itemkey => p_item_key
4301 , aname => 'NUMBER_OF_OVERCOM_ASGMT'
4302 , avalue => 1 );
4303 END IF; -- If (l_conflict_group_id IS NULL)
4304
4305 -- set resource overcommitment url
4306 l_view_conflict_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode='
4307 || 'PA_RES_OVERCOMMITMENT_LAYOUT&paAssignmentId=' || l_assignment_id
4308 || '&paConflictGroupId=' || l_conflict_group_id
4309 || '&paCallingPage=Default&addBreadCrumb=RP';
4310
4311 wf_engine.SetItemAttrText
4312 ( itemtype => p_item_type
4313 , itemkey => p_item_key
4314 , aname => 'VIEW_CONFLICT_URL_INFO'
4315 , avalue => l_view_conflict_url );
4316 ELSIF p_msg_type = 'REJECTION_FYI' OR p_msg_type = 'CANCELLATION_FYI' THEN
4317 -- set 'Number of Assignments Resulting in Resource Overcommitment -0' for single
4318 -- reject/cancel FYI notification.
4319 wf_engine.SetItemAttrNumber
4320 ( itemtype => p_item_type
4321 , itemkey => p_item_key
4322 , aname => 'NUMBER_OF_OVERCOM_ASGMT'
4323 , avalue => 0 );
4324
4325 l_assignment_id := wf_engine.GetItemAttrNumber
4326 (itemtype => p_item_type,
4327 itemkey => p_item_key,
4328 aname => 'ASSIGNMENT_ID');
4329 -- set resource overcommitment url
4330 l_view_conflict_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode='
4331 || 'PA_RES_OVERCOMMITMENT_LAYOUT&paAssignmentId=' || l_assignment_id
4332 || '&paConflictGroupId=&paCallingPage=Default&addBreadCrumb=RP';
4333
4334 wf_engine.SetItemAttrText
4335 ( itemtype => p_item_type
4336 , itemkey => p_item_key
4337 , aname => 'VIEW_CONFLICT_URL_INFO'
4338 , avalue => l_view_conflict_url );
4339
4340 IF p_msg_type = 'REJECTION_FYI' THEN
4341 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_REJECTED';
4342 l_msg_desc_code := 'PA_NFDESC_ASGMT_REJECTED';
4343 ELSIF p_msg_type = 'CANCELLATION_FYI' THEN
4344 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_CANCELED';
4345 l_msg_desc_code := 'PA_NFDESC_ASGMT_CANCELED';
4346 END IF;
4347 END IF;
4348
4349 IF p_msg_type IN ('APPROVAL_FYI','REJECTION_FYI','CANCELLATION_FYI') THEN
4350 l_msg_subj_itemattr_name := 'MSG_SUBJECT_FYI';
4351 l_msg_desc_itemattr_name := 'MSG_DESCRIPTION_FYI';
4352 END IF;
4353
4354 -- Now that the message codes have been set,
4355 -- get the message from fnd messages
4356 FND_MESSAGE.SET_NAME ('PA',l_msg_subj_code);
4357 l_msg_subj_text := FND_MESSAGE.GET;
4358 FND_MESSAGE.SET_NAME ('PA',l_msg_desc_code);
4359 l_msg_desc_text := FND_MESSAGE.GET;
4360
4361 wf_engine.SetItemAttrText
4362 ( itemtype => p_item_type
4363 , itemkey => p_item_key
4364 , aname => l_msg_subj_itemattr_name
4365 , avalue => l_msg_subj_text
4366 );
4367 wf_engine.SetItemAttrText
4368 ( itemtype => p_item_type
4369 , itemkey => p_item_key
4370 , aname => l_msg_desc_itemattr_name
4371 , avalue => l_msg_desc_text
4372 );
4373 EXCEPTION
4374 WHEN OTHERS THEN RAISE;
4375
4376 END Set_NF_Subject_and_Desc ;
4377
4378
4379
4380 PROCEDURE Delete_Assignment_WF_Records (p_assignment_id IN pa_project_assignments.assignment_id%TYPE,
4381 p_project_id IN pa_project_assignments.project_id%TYPE)
4382 IS
4383
4384 /*CURSOR get_project_id IS
4385 SELECT project_id
4386 FROM pa_project_assignments
4387 WHERE assignment_id = p_assignment_id;
4388
4389 l_project_id pa_project_assignments.project_id%TYPE;*/
4390
4391 BEGIN
4392
4393 /*OPEN get_project_id;
4394 FETCH get_project_id INTO l_project_id;
4395 CLOSE get_project_id;*/
4396
4397 DELETE FROM pa_wf_processes
4398 WHERE entity_key1 = to_char(p_project_id)
4399 AND entity_key2 = to_char(p_assignment_id)
4400 AND wf_type_code = 'ASSIGNMENT_APPROVAL';
4401
4402
4403 DELETE FROM pa_wf_ntf_performers
4404 WHERE wf_type_code in ('ASSIGNMENT_APPROVAL','REJECTION_FYI','APPROVAL_FYI','CANCELLATION_FYI')
4405 AND object_id1 = p_assignment_id;
4406
4407 END Delete_Assignment_WF_Records;
4408
4409 ---------------------------------------------------------------------------------------------------
4410 -- Workflow apis for mass assignment approval
4411 ---------------------------------------------------------------------------------------------------
4412 --Begin Forward declaration
4413 PROCEDURE process_approval_result
4414 ( p_project_id IN NUMBER
4415 ,p_mode IN VARCHAR2
4416 ,p_assignment_id_tbl IN SYSTEM.pa_num_tbl_type
4417 ,p_approval_status_tbl IN SYSTEM.pa_varchar2_30_tbl_type
4418 ,p_group_id IN NUMBER
4419 ,p_approver_group_id IN NUMBER
4420 ,p_routing_order IN NUMBER
4421 ,p_num_of_assignments IN NUMBER
4422 ,p_submitter_user_name IN VARCHAR2
4423 ,p_conflict_group_id IN NUMBER
4424 ,p_update_info_doc IN VARCHAR2
4425 ,p_forwarded_from IN VARCHAR2
4426 ,p_note_to_approvers IN VARCHAR2);
4427
4428
4429
4430 --END Forward declarations
4431
4432 --------------------------------------------
4433 --This API starts the mass approval workflow
4434 --It is called when a notification needs to
4435 --be sent to approver for assignment approval
4436 --This API is called in mass_assignment_approval
4437 --and in process_approval_result_wf
4438 --------------------------------------------
4439 PROCEDURE start_mass_approval_flow
4440 ( p_project_id IN NUMBER := FND_API.G_MISS_NUM
4441 ,p_mode IN VARCHAR2 := FND_API.G_MISS_CHAR
4442 ,p_note_to_approvers IN VARCHAR2 := FND_API.G_MISS_CHAR
4443 ,p_forwarded_from IN VARCHAR2
4444 ,p_performer_user_name IN VARCHAR2 := FND_API.G_MISS_CHAR
4445 ,p_routing_order IN NUMBER := FND_API.G_MISS_NUM
4446 ,p_group_id IN NUMBER := FND_API.G_MISS_NUM
4447 ,p_approver_group_id IN NUMBER := FND_API.G_MISS_NUM
4448 ,p_submitter_user_name IN VARCHAR2 := FND_API.G_MISS_CHAR
4449 ,p_update_info_doc IN VARCHAR2 := FND_API.G_MISS_CHAR
4450 ,p_project_name IN VARCHAR2
4451 ,p_project_number IN VARCHAR2
4452 ,p_project_manager IN VARCHAR2
4453 ,p_project_org IN VARCHAR2
4454 ,p_project_cus IN VARCHAR2
4455 ,p_conflict_group_id IN NUMBER := FND_API.G_MISS_NUM
4456 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
4457 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
4458 ,x_msg_data OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
4459 IS
4460
4461 l_itemkey VARCHAR2(30);
4462 l_responsibility_id NUMBER;
4463 l_resp_appl_id NUMBER;
4464 l_wf_started_date DATE;
4465 l_wf_started_by_id NUMBER;
4466 l_return_status VARCHAR2(1);
4467 l_error_message_code VARCHAR2(30);
4468 l_save_threshold NUMBER;
4469 l_msg_count NUMBER ;
4470 l_msg_index_out NUMBER ;
4471 l_msg_data VARCHAR2(2000);
4472 l_wf_item_type VARCHAR2(2000):= 'PAWFAAP'; --Assignment Approval Item type
4473 l_wf_process VARCHAR2(2000):= 'PA_ASGMT_APPRVL_MP'; --Assignment Approval process
4474 l_err_code NUMBER := 0;
4475 l_err_stage VARCHAR2(2000);
4476 l_err_stack VARCHAR2(2000);
4477
4478 l_ntfy_apprvl_recipient_name pa_wf_ntf_performers.user_name%TYPE; --- Commented for 3267790 fnd_user.user_name%TYPE; --used to set NTFY_APPRVL_RECIPIENT_NAME attribute
4479 l_prev_user fnd_user.user_name%TYPE; --used to set FORWARDED_FROM attribute
4480 l_number_of_assignments NUMBER;
4481 l_mass_approve_url VARCHAR2(2000); --Mass Approve page URL
4482 l_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N'); -- 5345171
4483
4484 BEGIN
4485
4486 -- Initialize the Error Stack
4487 PA_DEBUG.init_err_stack('PA_ASGMT_WFSTD.start_mass_approval_flow');
4488
4489 --Log Message
4490 IF l_debug_mode = 'Y' THEN -- 5345171
4491 PA_DEBUG.write_log
4492 ( x_module => 'pa.plsql.PA_ASGMT_WFSTD.start_mass_approval_flow.begin'
4493 ,x_msg => 'Beginning of mass approval workflow api'
4494 ,x_log_level => 1);
4495 END IF;
4496
4497 -- Initialize the return status to success
4498 x_return_status := FND_API.G_RET_STS_SUCCESS;
4499
4500 --Clear the global PL/SQL message table
4501 FND_MSG_PUB.initialize;
4502
4503 log_message('Inside Start mass approval flow: 0');
4504 log_message('Value of updated info doc:' || p_update_info_doc);
4505
4506 -- Create the unique item key to launch WF with
4507 SELECT pa_prm_wf_item_key_s.nextval
4508 INTO l_itemkey
4509 FROM dual;
4510
4511 l_wf_started_by_id := FND_GLOBAL.user_id;
4512 l_responsibility_id := FND_GLOBAL.resp_id;
4513 l_resp_appl_id := FND_GLOBAL.resp_appl_id;
4514
4515 FND_GLOBAL.Apps_Initialize ( user_id => l_wf_started_by_id
4516 , resp_id => l_responsibility_id
4517 , resp_appl_id => l_resp_appl_id );
4518
4519 -- Setting thresold value to run the process in background
4520 l_save_threshold := wf_engine.threshold;
4521 wf_engine.threshold := -1;
4522
4523 -----------------------------------
4524 --Getting the current approver name
4525 -----------------------------------
4526 BEGIN
4527 SELECT user_name
4528 INTO l_ntfy_apprvl_recipient_name
4529 FROM pa_wf_ntf_performers
4530 WHERE group_id = p_group_id
4531 AND approver_group_id = p_approver_group_id
4532 AND routing_order = p_routing_order
4533 AND rownum = 1;
4534 EXCEPTION
4535 WHEN NO_DATA_FOUND THEN
4536 null;
4537 END;
4538
4539 log_message('l_ntfy_apprvl_recipient_name:' || l_ntfy_apprvl_recipient_name);
4540 log_message('Inside Start mass approval flow: 1');
4541
4542 ----------------------------------------------------------
4543 --Getting the Forwared From (Submitter/previous approver)
4544 ----------------------------------------------------------
4545 IF p_forwarded_from IS NULL THEN
4546 l_prev_user := p_submitter_user_name;
4547 ELSE
4548 l_prev_user := p_forwarded_from;
4549 END IF;
4550
4551 log_message('Inside Start mass approval flow: 2');
4552
4553 --------------------------------------------
4554 --Getting number of assignments for approval
4555 --------------------------------------------
4556 BEGIN
4557 SELECT count(object_id1)
4558 INTO l_number_of_assignments
4559 FROM pa_wf_ntf_performers pf,
4560 pa_project_assignments asmt
4561 WHERE pf.group_id = p_group_id
4562 AND pf.approver_group_id = p_approver_group_id
4563 AND pf.routing_order = p_routing_order
4564 AND pf.object_id1 = asmt.assignment_id
4565 AND asmt.apprvl_status_code <> PA_ASSIGNMENT_APPROVAL_PUB.g_rejected;
4566 EXCEPTION
4567 WHEN NO_DATA_FOUND THEN
4568 l_number_of_assignments := 0;
4569 END;
4570
4571 log_message('Inside Start mass approval flow: 3');
4572 log_message('Conflict group_id:' || p_conflict_group_id);
4573
4574 IF l_number_of_assignments > 0 THEN
4575 ----------------------------------
4576 --Constructing mass approve URL
4577 ---------------------------------
4578 l_mass_approve_url := 'JSP:/OA_HTML/OA.jsp?akRegionCode=PA_MASS_APPR_LAYOUT' ||
4579 '&akRegionApplicationId=275' ||
4580 '&paProjectId='||
4581 p_project_id || '&paGroupId=' ||
4582 p_group_id || '&paApproverGroupId=' ||
4583 p_approver_group_id ||
4584 '&paRoutingOrder=' || p_routing_order ||
4585 '&paMode=' || p_mode || '&paNotificationId=' ||
4586 'NID' || '&paItemKey=' || l_itemkey ||
4587 '&paSubmitterUserName=' || p_submitter_user_name ||
4588 '&paConflictGroupId=' || p_conflict_group_id || '&addBreadCrumb=RP';
4589
4590 log_message('l_mass_approve_url:' || l_mass_approve_url);
4591
4592 -- Create the WF process
4593 wf_engine.CreateProcess
4594 ( ItemType => l_wf_item_type
4595 , ItemKey => l_itemkey
4596 , process => l_wf_process );
4597
4598 log_message('Inside Start mass approval flow : 4');
4599
4600 ----------------------------------------------------------------
4601 --Set all the required workflow attributes and start the workflow
4602 -----------------------------------------------------------------
4603 --set group_id
4604 wf_engine.SetItemAttrNumber
4605 ( itemtype => l_wf_item_type
4606 , itemkey => l_itemkey
4607 , aname => 'GROUP_ID'
4608 , avalue => p_group_id);
4609
4610 wf_engine.SetItemAttrNumber
4611 ( itemtype => l_wf_item_type
4612 , itemkey => l_itemkey
4613 , aname => 'APPROVER_GROUP_ID'
4614 , avalue => p_approver_group_id);
4615
4616 wf_engine.SetItemAttrNumber
4617 ( itemtype => l_wf_item_type
4618 , itemkey => l_itemkey
4619 , aname => 'ROUTING_ORDER'
4620 , avalue => p_routing_order);
4621
4622 --This is required for check_notiifcation_completed API logic
4623 wf_engine.SetItemAttrText
4624 ( itemtype => l_wf_item_type
4625 , itemkey => l_itemkey
4626 , aname => 'MODE'
4627 , avalue => p_mode);
4628
4629 wf_engine.SetItemAttrText
4630 ( itemtype => l_wf_item_type
4631 , itemkey => l_itemkey
4632 , aname => 'SUBMITTER_UNAME'
4633 , avalue => p_submitter_user_name);
4634
4635 wf_engine.SetItemAttrDocument
4636 ( itemtype => l_wf_item_type
4637 , itemkey => l_itemkey
4638 , aname => 'UPDATED_INFO_DOC'
4639 , documentid => p_update_info_doc );
4640
4641 --Set approval type
4642 wf_engine.SetItemAttrText
4643 ( itemtype => l_wf_item_type
4644 , itemkey => l_itemkey
4645 , aname => 'APPROVAL_TYPE'
4646 , avalue => PA_ASGMT_WFSTD.G_MASS_APPROVAL );
4647
4648 --Setting Mass Assignments details
4649 wf_engine.SetItemAttrText
4650 ( itemtype => l_wf_item_type
4651 , itemkey => l_itemkey
4652 , aname => 'NTFY_APPRVL_RECIPIENT_NAME'
4653 , avalue => l_ntfy_apprvl_recipient_name );
4654
4655 wf_engine.SetItemAttrText
4656 ( itemtype => l_wf_item_type
4657 , itemkey => l_itemkey
4658 , aname => 'FORWARDED_FROM'
4659 , avalue => l_prev_user );
4660
4661 wf_engine.SetItemAttrText
4662 ( itemtype => l_wf_item_type
4663 , itemkey => l_itemkey
4664 , aname => 'NOTE_TO_APPROVER'
4665 , avalue => p_note_to_approvers );
4666
4667 wf_engine.SetItemAttrText
4668 ( itemtype => l_wf_item_type
4669 , itemkey => l_itemkey
4670 , aname => 'NUMBER_OF_ASSIGNMENTS'
4671 , avalue => l_number_of_assignments );
4672
4673 wf_engine.SetItemAttrText
4674 ( itemtype => l_wf_item_type
4675 , itemkey => l_itemkey
4676 , aname => 'MASS_APPROVE_URL_INFO'
4677 , avalue => l_mass_approve_url );
4678
4679 --Setting the Upadate info document
4680 wf_engine.SetItemAttrDocument
4681 ( itemtype => l_wf_item_type
4682 , itemkey => l_itemkey
4683 , aname => 'UPDATED_INFO_DOC'
4684 , documentid => p_update_info_doc );
4685
4686 --Setting Project Details
4687 IF p_project_manager IS NOT NULL THEN
4688 wf_engine.SetItemAttrText
4689 ( itemtype => l_wf_item_type
4690 , itemkey => l_itemkey
4691 , aname => 'PROJECT_MANAGER_NAME'
4692 , avalue => p_project_manager );
4693 END IF;
4694
4695 wf_engine.SetItemAttrNumber
4696 ( itemtype => l_wf_item_type
4697 , itemkey => l_itemkey
4698 , aname => 'PROJECT_ID'
4699 , avalue => p_project_id);
4700
4701 wf_engine.SetItemAttrText
4702 ( itemtype => l_wf_item_type
4703 , itemkey => l_itemkey
4704 , aname => 'PROJECT_NUMBER'
4705 , avalue => p_project_number);
4706
4707 wf_engine.SetItemAttrText
4708 ( itemtype => l_wf_item_type
4709 , itemkey => l_itemkey
4710 , aname => 'PROJECT_NAME'
4711 , avalue => p_project_name);
4712
4713 wf_engine.SetItemAttrText
4714 ( itemtype => l_wf_item_type
4715 , itemkey => l_itemkey
4716 , aname => 'PROJECT_ORGANIZATION'
4717 , avalue => p_project_org);
4718
4719 if wf_directory.UserActive(p_submitter_user_name) then -- Bug # 9837538
4720 wf_engine.SetItemAttrText
4721 ( itemtype => l_wf_item_type
4722 , itemkey => l_itemkey
4723 , aname => 'FROM_ROLE_VALUE'
4724 , avalue => p_submitter_user_name); --Added for bug 4535838
4725 end if; -- Bug # 9837538
4726 -- Set the customer name if it is not null
4727 IF p_project_cus IS NOT NULL THEN
4728 wf_engine.SetItemAttrText
4729 ( itemtype => l_wf_item_type
4730 , itemkey => l_itemkey
4731 , aname => 'PROJECT_CUSTOMER'
4732 , avalue => p_project_cus);
4733 END IF;
4734
4735 log_message('Starting process');
4736 -----------------------------
4737 --Start the workflow process
4738 -----------------------------
4739 wf_engine.StartProcess ( itemtype => l_wf_item_type
4740 ,itemkey => l_itemkey );
4741
4742 PA_WORKFLOW_UTILS.Insert_WF_Processes
4743 (p_wf_type_code => 'MASS_ASSIGNMENT_APPROVAL'
4744 ,p_item_type => l_wf_item_type
4745 ,p_item_key => l_itemkey
4746 ,p_entity_key1 => to_char(p_project_id)
4747 ,p_entity_key2 => to_char(p_group_id)
4748 ,p_description => NULL
4749 ,p_err_code => l_err_code
4750 ,p_err_stage => l_err_stage
4751 ,p_err_stack => l_err_stack );
4752
4753 END IF; --l_num_of_assignments > 0
4754
4755 --Setting the original value
4756 wf_engine.threshold := l_save_threshold;
4757
4758 EXCEPTION
4759 WHEN OTHERS THEN
4760
4761 --Setting the original value
4762 wf_engine.threshold := l_save_threshold;
4763
4764 -- Set the excetption Message and the stack
4765 FND_MSG_PUB.add_exc_msg
4766 ( p_pkg_name => 'PA_ASGMT_WFSTD.start_mass_Approval_flow'
4767 ,p_procedure_name => PA_DEBUG.G_Err_Stack );
4768
4769 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
4770 RAISE;
4771 END start_mass_approval_flow;
4772
4773
4774 /** This API starts the FYI notifications to indicate if
4775 * asignments have been approved or rejected. It sends the following notification.
4776 * 1. Resource FYI for every assignment approved/rejected
4777 */
4778 PROCEDURE process_res_fyi_notification
4779 ( p_project_id IN NUMBER := FND_API.G_MISS_NUM
4780 ,p_assignment_id IN NUMBER := FND_API.G_MISS_NUM
4781 ,p_mode IN VARCHAR2
4782 ,p_project_name IN VARCHAR2
4783 ,p_project_number IN VARCHAR2
4784 ,p_project_manager IN VARCHAR2
4785 ,p_project_org IN VARCHAR2
4786 ,p_project_cus IN VARCHAR2
4787 ,p_conflict_group_id IN NUMBER := NULL
4788 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
4789 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
4790 ,x_msg_data OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
4791 IS
4792
4793 l_itemkey VARCHAR2(30);
4794 l_responsibility_id NUMBER;
4795 l_resp_appl_id NUMBER;
4796 l_wf_started_date DATE;
4797 l_wf_started_by_id NUMBER;
4798 l_return_status VARCHAR2(1);
4799 l_error_message_code VARCHAR2(30);
4800 x_error_message_code VARCHAR2(30);
4801 l_save_threshold NUMBER;
4802 l_msg_count NUMBER ;
4803 l_msg_index_out NUMBER ;
4804 l_msg_data VARCHAR2(2000);
4805 l_wf_item_type VARCHAR2(2000):= 'PARMAAP'; --Assignment Approval Item type
4806 l_wf_process VARCHAR2(2000):= 'PA_MASS_APRVL_RES_FP';
4807 l_err_code NUMBER := 0;
4808 l_err_stage VARCHAR2(2000);
4809 l_err_stack VARCHAR2(2000);
4810 l_display_name wf_users.display_name%TYPE; ---VARCHAR2(200); Changed for bug 3267790
4811 l_approver_name VARCHAR2(200);
4812 l_resource_id NUMBER;
4813 --l_res_user_name VARCHAR2(200);
4814 l_msg_subj_code VARCHAR2(30);
4815 l_msg_desc_code VARCHAR2(30);
4816 l_msg_subj_text VARCHAR2(2000);
4817 l_msg_desc_text VARCHAR2(2000);
4818 l_resolve_conflicts_by_rmvl VARCHAR2(1);
4819 l_view_conflict_url VARCHAR2(2000);
4820
4821 l_approval_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
4822 l_out_approval_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
4823 l_number_of_recipients NUMBER := 0;
4824 l_approval_nf_rects_rec PA_CLIENT_EXTN_ASGMT_WF.Users_List_Rectyp ;
4825 l_ntfy_apprvl_recipient_name wf_users.name%TYPE; ---VARCHAR2(240); Changed for bug 3267790
4826 l_ntfy_apprvl_rect_person_id NUMBER := 0;
4827 l_ntfy_apprvl_rect_type VARCHAR2(30);
4828 l_notification_type VARCHAR2(30);
4829
4830 l_asgmt_details_url VARCHAR2(600);
4831 l_resource_schedules_url VARCHAR2(600);
4832 l_reapproval_flag VARCHAR2(1);
4833 l_aprvl_status pa_project_assignments.apprvl_status_code%TYPE;
4834 l_override_basis_name VARCHAR2(80) := NULL;
4835 l_resource_start_date DATE;
4836
4837 CURSOR l_prev_asgmt_info_csr (l_assignment_id IN NUMBER)
4838 IS
4839 SELECT assignment_effort prev_effort,
4840 (trunc(end_date) -
4841 (trunc(start_date)+1)) prev_duration
4842 FROM pa_assignments_history
4843 WHERE assignment_id = l_assignment_id
4844 AND nvl(last_approved_flag,'N') = 'Y';
4845
4846 CURSOR l_assignments_csr IS
4847 SELECT
4848 ppa.assignment_name,
4849 ppa.assignment_effort,
4850 ppa.additional_information,
4851 ppa.description,
4852 ppa.start_date,
4853 ppa.end_date,
4854 ppa.apprvl_status_code,
4855 ppa.revenue_bill_rate,
4856 ppa.revenue_currency_code,
4857 ppa.bill_rate_override,
4858 ppa.bill_rate_curr_override,
4859 ppa.markup_percent_override,
4860 ppa.fcst_tp_amount_type_name,
4861 ppa.tp_rate_override,
4862 ppa.tp_currency_override,
4863 ppa.tp_calc_base_code_override,
4864 ppa.tp_percent_applied_override,
4865 ppa.work_type_name,
4866 ppa.transfer_price_rate, -- Added for bug 3051110
4867 ppa.transfer_pr_rate_curr
4868 FROM pa_project_assignments_v ppa
4869 WHERE assignment_id = p_assignment_id;
4870
4871 CURSOR csr_get_override_basis_name (p_override_basis_code IN VARCHAR2) IS
4872 SELECT plks.meaning
4873 FROM pa_lookups plks
4874 WHERE plks.lookup_type = 'CC_MARKUP_BASE_CODE'
4875 AND plks.lookup_code = p_override_basis_code;
4876
4877 -- Bug 5362698 - Get the name from HR instead of pa_resources_denorm so
4878 -- that the latest name is obtained.
4879 /*
4880 CURSOR l_resource_csr (l_resource_id IN NUMBER, l_start_date IN DATE) IS
4881 SELECT res.resource_name,
4882 hr.name
4883 FROM pa_resources_denorm res,
4884 hr_all_organization_units hr
4885 WHERE res.resource_id = l_resource_id
4886 AND hr.organization_id = res.resource_organization_id
4887 AND l_start_date between resource_effective_start_date and resource_effective_end_date;
4888 */
4889
4890 CURSOR l_resource_csr(l_resource_id IN NUMBER, p_start_date IN DATE) IS
4891 SELECT per.full_name resource_name,
4892 hou.name
4893 FROM per_people_f per,
4894 per_assignments_f assign,
4895 hr_all_organization_units hou,
4896 pa_resource_txn_attributes rta
4897 WHERE rta.resource_id = l_resource_id
4898 AND rta.person_id = per.person_id
4899 AND rta.person_id = assign.person_id
4900 AND assign.primary_flag = 'Y'
4901 AND assign.assignment_type in ('E','C')
4902 AND hou.organization_id = assign.organization_id
4903 AND trunc(p_start_date) BETWEEN assign.effective_start_date /*bug 8817301 */
4904 AND assign.effective_end_date
4905 AND trunc(p_start_date) BETWEEN per.effective_start_date /*bug 8817301 */
4906 AND per.effective_end_date;
4907
4908 l_prev_asgmt_info_rec l_prev_asgmt_info_csr%ROWTYPE;
4909 l_assignments_rec l_assignments_csr%ROWTYPE;
4910 l_resource_rec l_resource_csr%ROWTYPE;
4911 l_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N'); -- 5345171
4912
4913 BEGIN
4914
4915 -- Initialize the Error Stack
4916 PA_DEBUG.init_err_stack('PA_ASGMT_WFSTD.process_res_fyi_notification');
4917
4918 --Log Message
4919 IF l_debug_mode = 'Y' THEN -- 5345171
4920 PA_DEBUG.write_log
4921 ( x_module => 'pa.plsql.PA_ASGMT_WFSTD.process_res_fyi_notification.begin'
4922 ,x_msg => 'Beginning of mass fyi workflow api'
4923 ,x_log_level => 1);
4924 END IF;
4925 log_message('Inside process res mgr');
4926
4927 -- Initialize the return status to success
4928 x_return_status := FND_API.G_RET_STS_SUCCESS;
4929
4930 --Clear the global PL/SQL message table
4931 FND_MSG_PUB.initialize;
4932 x_msg_count := 0;
4933
4934 ---------------------------------
4935 --Set the pending approval flag
4936 ---------------------------------
4937 Maintain_wf_pending_flag
4938 (p_assignment_id => p_assignment_id,
4939 p_mode => 'APPROVAL_PROCESS_COMPLETED') ;
4940
4941 log_message('After Maintain pending flag for assignment id:' || p_assignment_id);
4942
4943 ---------------------------
4944 --Set the mass wf flag
4945 ---------------------------
4946 UPDATE pa_project_assignments
4947 SET mass_wf_in_progress_flag = 'N'
4948 WHERE assignment_id = p_assignment_id;
4949
4950 log_message('After setting mass wf flag');
4951
4952 SELECT resource_id
4953 INTO l_resource_id
4954 FROM pa_project_assignments
4955 WHERE assignment_id = p_assignment_id;
4956
4957 log_message('After getting resource_id:'|| l_resource_id);
4958
4959 --------------------------------------------------------------
4960 --Call Client extension to get the resource recepient(s)
4961 --------------------------------------------------------------
4962 --Getting recepients approval type
4963 SELECT apprvl_status_code
4964 INTO l_aprvl_status
4965 FROM pa_project_assignments
4966 WHERE assignment_id = p_assignment_id;
4967
4968 log_message('After getting recepients approval type:' || l_aprvl_status);
4969
4970 IF l_aprvl_status = PA_ASSIGNMENT_APPROVAL_PUB.g_approved THEN
4971 l_notification_type := 'APPROVAL_FYI';
4972 ELSE l_notification_type := 'REJECTION_FYI';
4973 END IF;
4974
4975 --Getting recepients person_id
4976 SELECT res.person_id
4977 INTO l_ntfy_apprvl_rect_person_id
4978 FROM pa_resources_denorm res
4979 WHERE res.resource_id = l_resource_id
4980 AND rownum = 1;
4981
4982 log_message('After getting person_id:' || l_ntfy_apprvl_rect_person_id);
4983
4984 --Getting recepients fnd user name
4985 wf_directory.getusername
4986 (p_orig_system => 'PER'
4987 ,p_orig_system_id => l_ntfy_apprvl_rect_person_id
4988 ,p_name => l_ntfy_apprvl_recipient_name
4989 ,p_display_name => l_display_name);
4990
4991 l_ntfy_apprvl_rect_type := 'RESOURCE';
4992
4993 log_message('After getting l_ntfy_apprvl_recipient_name:' || l_ntfy_apprvl_recipient_name);
4994
4995 --ceating the recipient in table
4996 IF l_ntfy_apprvl_recipient_name IS NOT NULL THEN
4997 l_approval_nf_rects_rec.User_Name := l_ntfy_apprvl_recipient_name;
4998 l_approval_nf_rects_rec.Person_id := l_ntfy_apprvl_rect_person_id;
4999 l_approval_nf_rects_rec.Type := l_ntfy_apprvl_rect_type;
5000 --l_approval_nf_rects_rec.Routing_Order := ?;
5001 l_approval_nf_rects_tbl(1) := l_approval_nf_rects_rec;
5002
5003
5004 log_message('Before Calling client extension to get all recipients');
5005 log_message('Recipient count:' || l_approval_nf_rects_tbl.COUNT);
5006
5007 --Calling client extension to get all recipients
5008 PA_CLIENT_EXTN_ASGMT_WF.Generate_NF_Recipients
5009 (p_assignment_id => p_assignment_id
5010 ,p_project_id => p_project_id
5011 ,p_notification_type => l_notification_type
5012 ,p_in_list_of_recipients => l_approval_nf_rects_tbl
5013 ,x_out_list_of_recipients => l_out_approval_nf_rects_tbl
5014 ,x_number_of_recipients => l_number_of_recipients );
5015
5016 log_message('After Calling client extension');
5017 log_message('Recipient count:' || l_out_approval_nf_rects_tbl.COUNT);
5018
5019 IF (l_out_approval_nf_rects_tbl.COUNT > 0 ) THEN --GSI Bug 7430471
5020
5021 --Getting the out recipient record
5022 l_approval_nf_rects_rec := l_out_approval_nf_rects_tbl(1);
5023
5024 l_ntfy_apprvl_recipient_name := l_approval_nf_rects_rec.User_Name;
5025 l_ntfy_apprvl_rect_person_id := l_approval_nf_rects_rec.Person_id;
5026 l_ntfy_apprvl_rect_type := l_approval_nf_rects_rec.Type;
5027
5028 log_message('After getting out recipient recoed');
5029
5030 --------------------------------------
5031 --Start Resource Notification workflow
5032 --------------------------------------
5033 l_wf_started_by_id := FND_GLOBAL.user_id;
5034 l_responsibility_id := FND_GLOBAL.resp_id;
5035 l_resp_appl_id := FND_GLOBAL.resp_appl_id;
5036
5037 FND_GLOBAL.Apps_Initialize ( user_id => l_wf_started_by_id
5038 , resp_id => l_responsibility_id
5039 , resp_appl_id => l_resp_appl_id );
5040
5041 -- Setting thresold value to run the process in background
5042 l_save_threshold := wf_engine.threshold;
5043 wf_engine.threshold := -1;
5044
5045 log_message('RESOURCE PERSON ID:' || l_ntfy_apprvl_rect_person_id);
5046 log_message('RESOURCE UNAME:' || l_ntfy_apprvl_recipient_name);
5047
5048 ----------------------------------------------------------------
5049 --Getting all local variables required for workflow attributes
5050 ---------------------------------------------------------------
5051 OPEN l_assignments_csr;
5052 FETCH l_assignments_csr INTO l_assignments_rec;
5053
5054 IF l_assignments_csr%NOTFOUND THEN
5055 x_return_status := FND_API.G_RET_STS_ERROR;
5056 pa_utils.add_message (p_app_short_name => 'PA',
5057 p_msg_name => 'PA_INVALID_ASMGT_ID');
5058 x_msg_count := x_msg_count + 1;
5059
5060 END IF;
5061 CLOSE l_assignments_csr;
5062
5063 l_asgmt_details_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_ASMT_LAYOUT' ||
5064 '&paCalledPage=ProjStaffedAsmt&paAssignmentId='||p_assignment_id||'&addBreadCrumb=RP';
5065
5066 l_resource_schedules_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_VIEW_RESOURCE_LAYOUT' ||
5067 '&paResourceId='||l_resource_id||'&addBreadCrumb=RP';
5068
5069 OPEN l_prev_asgmt_info_csr (p_assignment_id) ;
5070 FETCH l_prev_asgmt_info_csr INTO
5071 l_prev_asgmt_info_rec;
5072 IF l_prev_asgmt_info_csr%NOTFOUND THEN
5073 l_reapproval_flag := 'N';
5074 ELSE
5075 l_reapproval_flag := 'Y';
5076 END IF;
5077 CLOSE l_prev_asgmt_info_csr;
5078
5079 -- Bug 5362698 - use sysdate to get the name so that the latest name
5080 -- is obtained.
5081 -- Need to get the Max of StartDate or the Sysdate for future hire. Fix
5082 -- for Bug# 7585927.
5083 if(l_assignments_rec.start_date > sysdate) then
5084 l_resource_start_date := l_assignments_rec.start_date;
5085 else
5086 l_resource_start_date := sysdate;
5087 end if;
5088 OPEN l_resource_csr(l_resource_id, l_resource_start_date);
5089 FETCH l_resource_csr INTO l_resource_rec;
5090
5091 IF l_resource_csr%NOTFOUND THEN
5092 x_return_status := FND_API.G_RET_STS_ERROR;
5093 pa_utils.add_message (p_app_short_name => 'PA',
5094 p_msg_name => 'PA_INVALID_PERSON_ID');
5095 x_msg_count := x_msg_count + 1;
5096 END IF;
5097 CLOSE l_resource_csr;
5098
5099 -- Create the unique item key to launch WF with
5100 SELECT pa_prm_wf_item_key_s.nextval
5101 INTO l_itemkey
5102 FROM dual;
5103
5104 -- Create the WF process
5105 wf_engine.CreateProcess
5106 ( ItemType => l_wf_item_type
5107 , ItemKey => l_itemkey
5108 , process => l_wf_process );
5109
5110 ----------------------------------------------------------------
5111 -- Set subject, description and overcommiment conflict detail URL
5112 ---------------------------------------------------------------
5113 IF (l_assignments_rec.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_approved) THEN
5114
5115 -- If there is no overcommitment conflict
5116 IF (p_conflict_group_id IS NULL) THEN
5117 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_APPROVED';
5118 l_msg_desc_code := 'PA_NFDESC_ASGMT_APPROVED';
5119
5120 -- If there is any overcommitment conflict
5121 ELSE
5122 PA_SCHEDULE_PVT.has_resolved_conflicts_by_rmvl
5123 ( p_conflict_group_id => p_conflict_group_id
5124 , p_assignment_id => p_assignment_id
5125 , x_resolve_conflicts_by_rmvl => l_resolve_conflicts_by_rmvl
5126 , x_return_status => l_return_status
5127 , x_msg_count => l_msg_count
5128 , x_msg_data => l_msg_data);
5129 IF (l_resolve_conflicts_by_rmvl = 'Y') THEN
5130 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_APPR_CONF_REM';
5131 l_msg_desc_code := 'PA_NFDESC_ASGMT_APPR_CONF_REM';
5132 ELSE
5133 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_APPR_KP_CONF';
5134 l_msg_desc_code := 'PA_NFDESC_ASGMT_APPR_KP_CONF';
5135 END IF;
5136 END IF; -- If (p_conflict_group_id IS NULL)
5137 ELSE
5138 l_msg_subj_code := 'PA_NFSUBJ_ASGMT_REJECTED';
5139 l_msg_desc_code := 'PA_NFDESC_ASGMT_REJECTED';
5140 END IF; -- IF (l_assignments_rec.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_approved)
5141
5142 -- get the message from fnd messages for subject and description
5143 FND_MESSAGE.SET_NAME ('PA',l_msg_subj_code);
5144 l_msg_subj_text := FND_MESSAGE.GET;
5145 FND_MESSAGE.SET_NAME ('PA',l_msg_desc_code);
5146 l_msg_desc_text := FND_MESSAGE.GET;
5147
5148 -- set resource overcommitment url
5149 l_view_conflict_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode='
5150 || 'PA_RES_OVERCOMMITMENT_LAYOUT&paAssignmentId=' || p_assignment_id
5151 || '&paConflictGroupId=' || p_conflict_group_id
5152 || '&paCallingPage=Default&addBreadCrumb=RP';
5153
5154 log_message('Setting item attributes Inside process res mgr');
5155
5156 ------------------------------------------------------------
5157 --Set the item attributes required for resource notification
5158 ------------------------------------------------------------
5159 -- setting subject, description, conflict URL for overcommitment
5160 wf_engine.SetItemAttrText
5161 ( itemtype => l_wf_item_type
5162 , itemkey => l_itemkey
5163 , aname => 'MSG_SUBJECT'
5164 , avalue => l_msg_subj_text);
5165
5166 wf_engine.SetItemAttrText
5167 ( itemtype => l_wf_item_type
5168 , itemkey => l_itemkey
5169 , aname => 'MSG_DESCRIPTION'
5170 , avalue => l_msg_desc_text );
5171
5172 -- IF (l_assignments_rec.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_approved AND
5173 -- p_conflict_group_id IS NOT NULL) THEN
5174 wf_engine.SetItemAttrText
5175 ( itemtype => l_wf_item_type
5176 , itemkey => l_itemkey
5177 , aname => 'CONFLICT_URL'
5178 , avalue => l_view_conflict_url );
5179 -- END IF;
5180
5181 --Setting Resource attributes
5182 wf_engine.SetItemAttrText
5183 ( itemtype => l_wf_item_type
5184 , itemkey => l_itemkey
5185 , aname => 'NTFY_FYI_USER_NAME'
5186 , avalue => l_ntfy_apprvl_recipient_name);
5187
5188 wf_engine.SetItemAttrText
5189 ( itemtype => l_wf_item_type
5190 , itemkey => l_itemkey
5191 , aname => 'RESOURCE_NAME'
5192 , avalue => l_resource_rec.resource_name );
5193
5194 wf_engine.SetItemAttrText
5195 ( itemtype => l_wf_item_type
5196 , itemkey => l_itemkey
5197 , aname => 'RESOURCE_ORGANIZATION'
5198 , avalue => l_resource_rec.name );
5199
5200
5201 --Setting URL information
5202 wf_engine.SetItemAttrText
5203 ( itemtype => l_wf_item_type
5204 , itemkey => l_itemkey
5205 , aname => 'ASSIGNMENT_DETAILS_URL'
5206 , avalue => l_asgmt_details_url );
5207
5208 wf_engine.SetItemAttrText
5209 ( itemtype => l_wf_item_type
5210 , itemkey => l_itemkey
5211 , aname => 'RESOURCE_SCHEDULES_URL'
5212 , avalue => l_resource_schedules_url );
5213
5214 --Setting assignment attributes
5215 IF l_reapproval_flag = 'Y' THEN
5216 wf_engine.SetItemAttrNumber
5217 ( itemtype => l_wf_item_type
5218 , itemkey => l_itemkey
5219 , aname => 'PREV_DURATION'
5220 , avalue => l_prev_asgmt_info_rec.prev_duration );
5221
5222 wf_engine.SetItemAttrNumber
5223 ( itemtype => l_wf_item_type
5224 ,itemkey => l_itemkey
5225 , aname => 'PREV_EFFORT'
5226 , avalue => l_prev_asgmt_info_rec.prev_effort );
5227 END IF;
5228
5229 -- Start Additions by RM for bug 2274426
5230 wf_engine.SetItemAttrNumber
5231 ( itemtype => l_wf_item_type
5232 , itemkey => l_itemkey
5233 , aname => 'REVENUE_BILL_RATE'
5234 , avalue => l_assignments_rec.revenue_bill_rate
5235 );
5236 wf_engine.SetItemAttrText
5237 ( itemtype => l_wf_item_type
5238 , itemkey => l_itemkey
5239 , aname => 'REVENUE_BILL_RATE_CURR'
5240 , avalue => l_assignments_rec.revenue_currency_code
5241 );
5242 wf_engine.SetItemAttrNumber
5243 ( itemtype => l_wf_item_type
5244 , itemkey => l_itemkey
5245 , aname => 'BILL_RATE_OVERRIDE'
5246 , avalue => l_assignments_rec.bill_rate_override
5247 );
5248 wf_engine.SetItemAttrText
5249 ( itemtype => l_wf_item_type
5250 , itemkey => l_itemkey
5251 , aname => 'BILL_RATE_OVERRIDE_CURR'
5252 , avalue => l_assignments_rec.bill_rate_curr_override
5253 );
5254 IF l_assignments_rec.markup_percent_override IS NOT NULL THEN
5255 wf_engine.SetItemAttrText
5256 ( itemtype => l_wf_item_type
5257 , itemkey => l_itemkey
5258 , aname => 'MARKUP_PCT_OVERRIDE'
5259 , avalue => to_char(l_assignments_rec.markup_percent_override)||'%'
5260 );
5261 ELSE
5262 wf_engine.SetItemAttrText
5263 ( itemtype => l_wf_item_type
5264 , itemkey => l_itemkey
5265 , aname => 'MARKUP_PCT_OVERRIDE'
5266 , avalue => to_char(l_assignments_rec.markup_percent_override)
5267 );
5268 END IF;
5269 wf_engine.SetItemAttrText
5270 ( itemtype => l_wf_item_type
5271 , itemkey => l_itemkey
5272 , aname => 'TP_AMT_TYPE_NAME'
5273 , avalue => l_assignments_rec.fcst_tp_amount_type_name
5274 );
5275 wf_engine.SetItemAttrNumber
5276 ( itemtype => l_wf_item_type
5277 , itemkey => l_itemkey
5278 , aname => 'TP_RATE_OVERRIDE'
5279 , avalue => l_assignments_rec.tp_rate_override
5280 );
5281 wf_engine.SetItemAttrText
5282 ( itemtype => l_wf_item_type
5283 , itemkey => l_itemkey
5284 , aname => 'TP_RATE_OVERRIDE_CURR'
5285 , avalue => l_assignments_rec.tp_currency_override
5286 );
5287 IF l_assignments_rec.tp_calc_base_code_override IS NOT NULL THEN
5288 open csr_get_override_basis_name(l_assignments_rec.tp_calc_base_code_override);
5289 fetch csr_get_override_basis_name into l_override_basis_name;
5290 close csr_get_override_basis_name;
5291 END IF;
5292 wf_engine.SetItemAttrText
5293 ( itemtype => l_wf_item_type
5294 , itemkey => l_itemkey
5295 , aname => 'OVERRIDE_BASIS_NAME'
5296 , avalue => l_override_basis_name
5297 );
5298 IF l_assignments_rec.tp_percent_applied_override IS NOT NULL THEN
5299 IF l_override_basis_name IS NOT NULL THEN
5300 wf_engine.SetItemAttrText
5301 ( itemtype => l_wf_item_type
5302 , itemkey => l_itemkey
5303 , aname => 'TP_PCT_APPLIED_OVERRIDE'
5304 , avalue => ', '||to_char(l_assignments_rec.tp_percent_applied_override)||'%'
5305 );
5306 ELSE
5307 wf_engine.SetItemAttrText
5308 ( itemtype => l_wf_item_type
5309 , itemkey => l_itemkey
5310 , aname => 'TP_PCT_APPLIED_OVERRIDE'
5311 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)||'%'
5312 );
5313 END IF;
5314 ELSE
5315 wf_engine.SetItemAttrText
5316 ( itemtype => l_wf_item_type
5317 , itemkey => l_itemkey
5318 , aname => 'TP_PCT_APPLIED_OVERRIDE'
5319 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)
5320 );
5321 END IF;
5322 wf_engine.SetItemAttrText
5323 ( itemtype => l_wf_item_type
5324 , itemkey => l_itemkey
5325 , aname => 'WORK_TYPE_NAME'
5326 , avalue => l_assignments_rec.work_type_name
5327 );
5328 -- End of Additions by RM
5329
5330 wf_engine.SetItemAttrText
5331 ( itemtype => l_wf_item_type
5332 , itemkey => l_itemkey
5333 , aname => 'ASSIGNMENT_NAME'
5334 , avalue => l_assignments_rec.assignment_name );
5335
5336 wf_engine.SetItemAttrNumber
5337 ( itemtype => l_wf_item_type
5338 , itemkey => l_itemkey
5339 , aname => 'ASSIGNMENT_DURATION'
5340 , avalue => (trunc(l_assignments_rec.end_date) -
5341 trunc(l_assignments_rec.start_date)+1) );
5342
5343 wf_engine.SetItemAttrNumber
5344 ( itemtype => l_wf_item_type
5345 , itemkey => l_itemkey
5346 , aname => 'ASSIGNMENT_EFFORT'
5347 , avalue => l_assignments_rec.assignment_effort );
5348
5349 wf_engine.SetItemAttrText
5350 ( itemtype => l_wf_item_type
5351 , itemkey => l_itemkey
5352 , aname => 'DESCRIPTION'
5353 , avalue => l_assignments_rec.description );
5354
5355 wf_engine.SetItemAttrText
5356 ( itemtype => l_wf_item_type
5357 , itemkey => l_itemkey
5358 , aname => 'ADDITIONAL_INFORMATION'
5359 , avalue => l_assignments_rec.additional_information );
5360
5361 --Setting Project attributes
5362 wf_engine.SetItemAttrText
5363 ( itemtype => l_wf_item_type
5364 , itemkey => l_itemkey
5365 , aname => 'PROJECT_NAME'
5366 , avalue => p_project_name );
5367
5368 wf_engine.SetItemAttrText
5369 ( itemtype => l_wf_item_type
5370 , itemkey => l_itemkey
5371 , aname => 'PROJECT_NUMBER'
5372 , avalue => p_project_number );
5373
5374 wf_engine.SetItemAttrText
5375 ( itemtype => l_wf_item_type
5376 , itemkey => l_itemkey
5377 , aname => 'PROJECT_MANAGER_NAME'
5378 , avalue => p_project_manager );
5379
5380 wf_engine.SetItemAttrText
5381 ( itemtype => l_wf_item_type
5382 , itemkey => l_itemkey
5383 , aname => 'PROJECT_ORGANIZATION'
5384 , avalue => p_project_org );
5385
5386 wf_engine.SetItemAttrText
5387 ( itemtype => l_wf_item_type
5388 , itemkey => l_itemkey
5389 , aname => 'PROJECT_CUSTOMER'
5390 , avalue => p_project_cus );
5391
5392 wf_engine.SetItemAttrDate
5393 ( itemtype => l_wf_item_type
5394 , itemkey => l_itemkey
5395 , aname => 'START_DATE'
5396 , avalue => l_assignments_rec.start_date);
5397
5398 wf_engine.SetItemAttrDate
5399 ( itemtype => l_wf_item_type
5400 , itemkey => l_itemkey
5401 , aname => 'END_DATE'
5402 , avalue => l_assignments_rec.end_date);
5403
5404 /* Added for bug 3051110 */
5405
5406 wf_engine.SetItemAttrNumber
5407 ( itemtype => l_wf_item_type
5408 , Itemkey => l_itemkey
5409 , aname => 'TRANSFER_PRICE_RATE'
5410 , avalue => l_assignments_rec.transfer_price_rate);
5411
5412 wf_Engine.SetItemAttrText
5413 (itemtype => l_wf_item_type
5414 , itemkey => l_itemkey
5415 , aname => 'TRANSFER_PR_RATE_CURR'
5416 , avalue => l_assignments_rec.transfer_pr_rate_curr);
5417
5418 --Start the workflow process
5419 wf_engine.StartProcess ( itemtype => l_wf_item_type
5420 ,itemkey => l_itemkey );
5421
5422 PA_WORKFLOW_UTILS.Insert_WF_Processes
5423 (p_wf_type_code => 'MASS_ASSIGNMENT_APPROVAL'
5424 ,p_item_type => l_wf_item_type
5425 ,p_item_key => l_itemkey
5426 ,p_entity_key1 => to_char(p_project_id)
5427 ,p_entity_key2 => to_char(p_assignment_id)
5428 ,p_description => NULL
5429 ,p_err_code => l_err_code
5430 ,p_err_stage => l_err_stage
5431 ,p_err_stack => l_err_stack );
5432
5433 END IF ; -- GSI Bug 7430471
5434 END IF;--end recipient name is null (no fnd_user for this resource)
5435
5436
5437 --Setting the original value
5438 wf_engine.threshold := l_save_threshold;
5439
5440 -- IF the number of messages is 1 then fetch the message code from
5441 -- the stack and return its text
5442 x_msg_count := FND_MSG_PUB.Count_Msg;
5443
5444 IF x_msg_count = 1 THEN
5445 pa_interface_utils_pub.get_messages
5446 ( p_encoded => FND_API.G_TRUE
5447 ,p_msg_index => 1
5448 ,p_data => x_msg_data
5449 ,p_msg_index_out => l_msg_index_out );
5450 END IF;
5451
5452 -- Reset the error stack when returning to the calling program
5453 PA_DEBUG.Reset_Err_Stack;
5454
5455 -- If g_error_exists is TRUE then set the x_return_status to 'E'
5456 IF FND_MSG_PUB.Count_Msg >0 THEN
5457 x_return_status := FND_API.G_RET_STS_ERROR;
5458 END IF;
5459
5460 EXCEPTION
5461 WHEN OTHERS THEN
5462
5463 --Setting the original value
5464 wf_engine.threshold := l_save_threshold;
5465
5466 -- Set the excetption Message and the stack
5467 FND_MSG_PUB.add_exc_msg
5468 ( p_pkg_name => 'PA_ASGMT_WFSTD.process_res_fyi_notification'
5469 ,p_procedure_name => PA_DEBUG.G_Err_Stack );
5470
5471 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
5472 RAISE;
5473 END process_res_fyi_notification;
5474
5475 --------------------------------------------------------
5476 --This API sets the workflow attributes for Manager FYIs
5477 --Manager FYIs include notifications to Resource Manager
5478 --Staffing Manager and Project Managers
5479 ---------------------------------------------------------
5480 PROCEDURE set_manager_attributes
5481 ( itemtype IN VARCHAR2
5482 ,itemkey IN VARCHAR2
5483 ,p_group_id IN NUMBER
5484 ,p_mode IN VARCHAR2
5485 ,p_update_info_doc IN VARCHAR2 := FND_API.G_MISS_CHAR
5486 ,p_num_apr_asgns IN NUMBER
5487 ,p_num_rej_asgns IN NUMBER
5488 ,p_project_name IN VARCHAR2
5489 ,p_project_number IN VARCHAR2
5490 ,p_project_manager IN VARCHAR2
5491 ,p_project_org IN VARCHAR2
5492 ,p_project_cus IN VARCHAR2
5493 ,p_conflict_group_id IN NUMBER := FND_API.G_MISS_NUM
5494 ,p_notified_id IN NUMBER
5495 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5496 ,x_msg_count OUT NOCOPY NUMBER ) --File.Sql.39 bug 4440895
5497 IS
5498
5499 l_assignment_id NUMBER;
5500 l_msg_count NUMBER := 0;
5501 l_error_message_code VARCHAR2(30);
5502 l_return_status VARCHAR2(1);
5503 l_wf_item_type VARCHAR2(30);
5504 l_itemkey NUMBER;
5505 l_conflict_url VARCHAR2(600);
5506 l_selected_roles_url VARCHAR2(600);
5507 l_selected_roles2_url VARCHAR2(600);
5508 l_selected_resources_url VARCHAR2(600);
5509 l_selected_resources2_url VARCHAR2(600);
5510 l_conflict_group_id NUMBER;
5511
5512 CURSOR l_assignments_csr (l_assignment_id IN NUMBER ) IS
5513 SELECT
5514 ppa.project_id,
5515 ppa.assignment_name,
5516 ppa.assignment_effort,
5517 ppa.additional_information,
5518 ppa.description,
5519 ppa.start_date,
5520 ppa.end_date,
5521 ppa.revenue_bill_rate,
5522 ppa.revenue_currency_code,
5523 ppa.bill_rate_override,
5524 ppa.bill_rate_curr_override,
5525 ppa.markup_percent_override,
5526 ppa.fcst_tp_amount_type_name,
5527 ppa.tp_rate_override,
5528 ppa.tp_currency_override,
5529 ppa.tp_calc_base_code_override,
5530 ppa.tp_percent_applied_override,
5531 ppa.work_type_name,
5532 hr.name
5533 FROM pa_project_assignments_v ppa,
5534 pa_resources_denorm res,
5535 hr_all_organization_units hr
5536 WHERE ppa.assignment_id = l_assignment_id
5537 AND res.resource_id = ppa.resource_id
5538 AND ppa.start_date BETWEEN res.resource_effective_start_date
5539 AND res.resource_effective_end_date
5540 AND hr.organization_id = res.resource_organization_id;
5541
5542 CURSOR csr_get_override_basis_name (p_override_basis_code IN VARCHAR2) IS
5543 SELECT plks.meaning
5544 FROM pa_lookups plks
5545 WHERE plks.lookup_type = 'CC_MARKUP_BASE_CODE'
5546 AND plks.lookup_code = p_override_basis_code;
5547
5548 l_assignments_rec l_assignments_csr%ROWTYPE;
5549 l_override_basis_name VARCHAR2(80) := NULL;
5550
5551 BEGIN
5552
5553 log_message('Inside set manager attributes');
5554
5555 l_wf_item_type := itemtype;
5556 l_itemkey := itemkey;
5557
5558 BEGIN
5559 SELECT object_id1
5560 INTO l_assignment_id
5561 FROM pa_wf_ntf_performers
5562 WHERE group_id = p_group_id
5563 AND rownum = 1;
5564 EXCEPTION
5565 WHEN OTHERS THEN
5566 null;
5567 END;
5568
5569 OPEN l_assignments_csr (l_assignment_id);
5570 FETCH l_assignments_csr INTO l_assignments_rec;
5571
5572 IF l_assignments_csr%NOTFOUND THEN
5573 x_return_status := FND_API.G_RET_STS_ERROR;
5574 pa_utils.add_message (p_app_short_name => 'PA',
5575 p_msg_name => 'PA_INVALID_ASMGT_ID');
5576 l_msg_count := l_msg_count + 1;
5577
5578 END IF;
5579 CLOSE l_assignments_csr;
5580
5581 l_selected_roles_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275' ||
5582 '&akRegionCode=PA_SELECTED_ROLES_LAYOUT&paCallingPage=WF_Notifications' ||
5583 '&paProjectId=' || l_assignments_rec.project_id || '&paNotifiedId=' ||
5584 p_notified_id || '&paGroupId=' || p_group_id || '&paApprovalStatus=Approved&addBreadCrumb=RP';
5585
5586 l_selected_roles2_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275' ||
5587 '&akRegionCode=PA_SELECTED_ROLES_LAYOUT&paCallingPage=WF_Notifications' ||
5588 '&paProjectId=' || l_assignments_rec.project_id || '&paNotifiedId=' ||
5589 p_notified_id || '&paGroupId=' || p_group_id || '&paApprovalStatus=Rejected&addBreadCrumb=RP';
5590
5591 ------------------------------------------------------------
5592 --If this is assignment creation mode set assignment info
5593 --else set Updated Info attributes
5594 -----------------------------------------------------------
5595
5596 IF p_mode = PA_MASS_ASGMT_TRX.G_MASS_ASGMT THEN
5597
5598 l_selected_resources_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275' ||
5599 '&akRegionCode=PA_SELECTED_RESOURCES_LAYOUT&paCallingPage=WF_Notifications' ||
5600 '&paProjectId=' || l_assignments_rec.project_id || '&paNotifiedId=' ||
5601 p_notified_id || '&paGroupId=' || p_group_id || '&paApprovalStatus=Approved&addBreadCrumb=RP';
5602
5603 l_selected_resources2_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275' ||
5604 '&akRegionCode=PA_SELECTED_RESOURCES_LAYOUT&paCallingPage=WF_Notifications' ||
5605 '&paProjectId=' || l_assignments_rec.project_id || '&paNotifiedId=' ||
5606 p_notified_id || '&paGroupId=' || p_group_id || '&paApprovalStatus=Rejected&addBreadCrumb=RP';
5607
5608 wf_engine.SetItemAttrText
5609 ( itemtype => l_wf_item_type
5610 , itemkey => l_itemkey
5611 , aname => 'SELECTED_RESOURCES_URL'
5612 , avalue => l_selected_resources_url);
5613
5614 wf_engine.SetItemAttrText
5615 ( itemtype => l_wf_item_type
5616 , itemkey => l_itemkey
5617 , aname => 'SELECTED_RESOURCES2_URL'
5618 , avalue => l_selected_resources2_url);
5619
5620 wf_engine.SetItemAttrText
5621 ( itemtype => l_wf_item_type
5622 , itemkey => l_itemkey
5623 , aname => 'ASSIGNMENT_NAME'
5624 , avalue => l_assignments_rec.assignment_name );
5625
5626 wf_engine.SetItemAttrText
5627 ( itemtype => l_wf_item_type
5628 , itemkey => l_itemkey
5629 , aname => 'RESOURCE_ORGANIZATION'
5630 , avalue => l_assignments_rec.name );
5631
5632 wf_engine.SetItemAttrNumber
5633 ( itemtype => l_wf_item_type
5634 , itemkey => l_itemkey
5635 , aname => 'ASSIGNMENT_DURATION'
5636 , avalue => (trunc(l_assignments_rec.end_date) -
5637 trunc(l_assignments_rec.start_date)+1) );
5638
5639 wf_engine.SetItemAttrNumber
5640 ( itemtype => l_wf_item_type
5641 , itemkey => l_itemkey
5642 , aname => 'ASSIGNMENT_EFFORT'
5643 , avalue => l_assignments_rec.assignment_effort );
5644
5645 wf_engine.SetItemAttrText
5646 ( itemtype => l_wf_item_type
5647 , itemkey => l_itemkey
5648 , aname => 'DESCRIPTION'
5649 , avalue => l_assignments_rec.description );
5650
5651 wf_engine.SetItemAttrText
5652 ( itemtype => l_wf_item_type
5653 , itemkey => l_itemkey
5654 , aname => 'ADDITIONAL_INFORMATION'
5655 , avalue => l_assignments_rec.additional_information );
5656
5657 wf_engine.SetItemAttrDate
5658 (itemtype => l_wf_item_type
5659 , itemkey => l_itemkey
5660 , aname => 'START_DATE'
5661 , avalue => l_assignments_rec.start_date
5662 );
5663
5664 wf_engine.SetItemAttrDate
5665 (itemtype => l_wf_item_type
5666 , itemkey => l_itemkey
5667 , aname => 'END_DATE'
5668 , avalue => l_assignments_rec.end_date
5669 );
5670 -- Start Additions by RM for bug 2274426
5671 wf_engine.SetItemAttrNumber
5672 ( itemtype => l_wf_item_type
5673 , itemkey => l_itemkey
5674 , aname => 'REVENUE_BILL_RATE'
5675 , avalue => l_assignments_rec.revenue_bill_rate
5676 );
5677 wf_engine.SetItemAttrText
5678 ( itemtype => l_wf_item_type
5679 , itemkey => l_itemkey
5680 , aname => 'REVENUE_BILL_RATE_CURR'
5681 , avalue => l_assignments_rec.revenue_currency_code
5682 );
5683 wf_engine.SetItemAttrNumber
5684 ( itemtype => l_wf_item_type
5685 , itemkey => l_itemkey
5686 , aname => 'BILL_RATE_OVERRIDE'
5687 , avalue => l_assignments_rec.bill_rate_override
5688 );
5689 wf_engine.SetItemAttrText
5690 ( itemtype => l_wf_item_type
5691 , itemkey => l_itemkey
5692 , aname => 'BILL_RATE_OVERRIDE_CURR'
5693 , avalue => l_assignments_rec.bill_rate_curr_override
5694 );
5695 IF l_assignments_rec.markup_percent_override IS NOT NULL THEN
5696 wf_engine.SetItemAttrText
5697 ( itemtype => l_wf_item_type
5698 , itemkey => l_itemkey
5699 , aname => 'MARKUP_PCT_OVERRIDE'
5700 , avalue => to_char(l_assignments_rec.markup_percent_override)||'%'
5701 );
5702 ELSE
5703 wf_engine.SetItemAttrText
5704 ( itemtype => l_wf_item_type
5705 , itemkey => l_itemkey
5706 , aname => 'MARKUP_PCT_OVERRIDE'
5707 , avalue => to_char(l_assignments_rec.markup_percent_override)
5708 );
5709 END IF;
5710 wf_engine.SetItemAttrText
5711 ( itemtype => l_wf_item_type
5712 , itemkey => l_itemkey
5713 , aname => 'TP_AMT_TYPE_NAME'
5714 , avalue => l_assignments_rec.fcst_tp_amount_type_name
5715 );
5716 wf_engine.SetItemAttrNumber
5717 ( itemtype => l_wf_item_type
5718 , itemkey => l_itemkey
5719 , aname => 'TP_RATE_OVERRIDE'
5720 , avalue => l_assignments_rec.tp_rate_override
5721 );
5722 wf_engine.SetItemAttrText
5723 ( itemtype => l_wf_item_type
5724 , itemkey => l_itemkey
5725 , aname => 'TP_RATE_OVERRIDE_CURR'
5726 , avalue => l_assignments_rec.tp_currency_override
5727 );
5728 IF l_assignments_rec.tp_calc_base_code_override IS NOT NULL THEN
5729 open csr_get_override_basis_name(l_assignments_rec.tp_calc_base_code_override);
5730 fetch csr_get_override_basis_name into l_override_basis_name;
5731 close csr_get_override_basis_name;
5732 END IF;
5733 wf_engine.SetItemAttrText
5734 ( itemtype => l_wf_item_type
5735 , itemkey => l_itemkey
5736 , aname => 'OVERRIDE_BASIS_NAME'
5737 , avalue => l_override_basis_name
5738 );
5739 IF l_assignments_rec.tp_percent_applied_override IS NOT NULL THEN
5740 IF l_override_basis_name IS NOT NULL THEN
5741 wf_engine.SetItemAttrText
5742 ( itemtype => l_wf_item_type
5743 , itemkey => l_itemkey
5744 , aname => 'TP_PCT_APPLIED_OVERRIDE'
5745 , avalue => ', '||to_char(l_assignments_rec.tp_percent_applied_override)||'%'
5746 );
5747 ELSE
5748 wf_engine.SetItemAttrText
5749 ( itemtype => l_wf_item_type
5750 , itemkey => l_itemkey
5751 , aname => 'TP_PCT_APPLIED_OVERRIDE'
5752 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)||'%'
5753 );
5754 END IF;
5755 ELSE
5756 wf_engine.SetItemAttrText
5757 ( itemtype => l_wf_item_type
5758 , itemkey => l_itemkey
5759 , aname => 'TP_PCT_APPLIED_OVERRIDE'
5760 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)
5761 );
5762 END IF;
5763 wf_engine.SetItemAttrText
5764 ( itemtype => l_wf_item_type
5765 , itemkey => l_itemkey
5766 , aname => 'WORK_TYPE_NAME'
5767 , avalue => l_assignments_rec.work_type_name
5768 );
5769 -- End of Additions by RM
5770
5771 ELSIF (p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_ASGMT_BASIC_INFO OR
5772 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_COMPETENCIES OR
5773 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_FORECAST_ITEMS OR
5774 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_SCHEDULE )
5775
5776 THEN
5777
5778 wf_engine.SetItemAttrDocument
5779 ( itemtype => l_wf_item_type
5780 , itemkey => l_itemkey
5781 , aname => 'UPDATED_INFO_DOC'
5782 , documentid => p_update_info_doc );
5783
5784 END IF;
5785
5786 ---------------------------------------------------------------------
5787 --Setting Common attributes for CRN / UPD / APS
5788 --------------------------------------------------------------------
5789
5790 --Setting Assignment Attributes
5791 wf_engine.SetItemAttrNumber
5792 ( itemtype => l_wf_item_type
5793 , itemkey => l_itemkey
5794 , aname => 'APPROVED_ASSIGNMENTS'
5795 , avalue => p_num_apr_asgns );
5796
5797 wf_engine.SetItemAttrText
5798 ( itemtype => l_wf_item_type
5799 , itemkey => l_itemkey
5800 , aname => 'SELECTED_ROLES_URL'
5801 , avalue => l_selected_roles_url);
5802
5803 wf_engine.SetItemAttrText
5804 ( itemtype => l_wf_item_type
5805 , itemkey => l_itemkey
5806 , aname => 'SELECTED_ROLES2_URL'
5807 , avalue => l_selected_roles2_url);
5808
5809 wf_engine.SetItemAttrNumber
5810 ( itemtype => l_wf_item_type
5811 , itemkey => l_itemkey
5812 , aname => 'REJECTED_ASSIGNMENTS'
5813 , avalue => p_num_rej_asgns );
5814
5815 --Setting Project attributes
5816 wf_engine.SetItemAttrText
5817 ( itemtype => l_wf_item_type
5818 , itemkey => l_itemkey
5819 , aname => 'PROJECT_NAME'
5820 , avalue => p_project_name );
5821
5822 wf_engine.SetItemAttrText
5823 ( itemtype => l_wf_item_type
5824 , itemkey => l_itemkey
5825 , aname => 'PROJECT_NUMBER'
5826 , avalue => p_project_number );
5827
5828 wf_engine.SetItemAttrText
5829 ( itemtype => l_wf_item_type
5830 , itemkey => l_itemkey
5831 , aname => 'PROJECT_MANAGER_NAME'
5832 , avalue => p_project_manager );
5833
5834 wf_engine.SetItemAttrText
5835 ( itemtype => l_wf_item_type
5836 , itemkey => l_itemkey
5837 , aname => 'PROJECT_ORGANIZATION'
5838 , avalue => p_project_org );
5839
5840 wf_engine.SetItemAttrText
5841 ( itemtype => l_wf_item_type
5842 , itemkey => l_itemkey
5843 , aname => 'PROJECT_CUSTOMER'
5844 , avalue => p_project_cus );
5845
5846 -- Always display View Conflict link
5847 IF (p_conflict_group_id IS NUll OR p_conflict_group_id = FND_API.G_MISS_NUM) THEN
5848 l_conflict_group_id := '';
5849 ELSE
5850 l_conflict_group_id := p_conflict_group_id;
5851 END IF;
5852
5853 l_conflict_url := 'JSP:/OA_HTML/OA.jsp?akRegionApplicationId=275&akRegionCode=PA_VIEW_CONFLICTS_LAYOUT&paProjectId=' ||
5854 l_assignments_rec.project_id || '&paCallingPage=MassAsmtFYINotif&paConflictGroupId=' ||
5855 l_conflict_group_id || '&addBreadCrumb=RP';
5856
5857 wf_engine.SetItemAttrText
5858 ( itemtype => l_wf_item_type
5859 , itemkey => l_itemkey
5860 , aname => 'CONFLICT_URL'
5861 , avalue => l_conflict_url );
5862
5863 x_msg_count := l_msg_count;
5864
5865 END set_manager_attributes;
5866
5867 /** This API starts the FYI notifications to indicate if
5868 * asignments have been approved or rejected. It sends the following notification.
5869 * 1. Staffing Manager FYI for the mass txn
5870 * 2. Resource Manager FYI for the mass txn
5871 * 3. Project Manager FYI for the mass txn
5872 * The logic involves calling the client extension for every
5873 * assignment and populating pa_wf_ntf_performers table
5874 * Notifications are then sent to recipients from the pa_wf_ntf_performers table
5875 */
5876 PROCEDURE process_mgr_fyi_notification
5877 ( p_assignment_id_tbl IN SYSTEM.pa_num_tbl_type
5878 ,p_project_id IN NUMBER := FND_API.G_MISS_NUM
5879 ,p_group_id IN NUMBER := FND_API.G_MISS_NUM
5880 ,p_mode IN VARCHAR2
5881 ,p_update_info_doc IN VARCHAR2 := FND_API.G_MISS_CHAR
5882 ,p_num_apr_asgns IN NUMBER
5883 ,p_num_rej_asgns IN NUMBER
5884 ,p_project_name IN VARCHAR2
5885 ,p_project_number IN VARCHAR2
5886 ,p_project_manager IN VARCHAR2
5887 ,p_project_org IN VARCHAR2
5888 ,p_project_cus IN VARCHAR2
5889 ,p_submitter_user_name IN VARCHAR2
5890 ,p_conflict_group_id IN NUMBER := FND_API.G_MISS_NUM
5891 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5892 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
5893 ,x_msg_data OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
5894 IS
5895
5896 l_itemkey VARCHAR2(30);
5897 l_responsibility_id NUMBER;
5898 l_resp_appl_id NUMBER;
5899 l_wf_started_date DATE;
5900 l_wf_started_by_id NUMBER;
5901 l_return_status VARCHAR2(1);
5902 l_error_message_code VARCHAR2(30);
5903 l_save_threshold NUMBER;
5904 l_msg_count NUMBER ;
5905 l_msg_index_out NUMBER ;
5906 l_msg_data VARCHAR2(2000);
5907 l_wf_item_type VARCHAR2(2000):= 'PARMAAP'; --Assignment Approval Item type
5908 l_wf_process VARCHAR2(2000);
5909 l_err_code NUMBER := 0;
5910 l_err_stage VARCHAR2(2000);
5911 l_err_stack VARCHAR2(2000);
5912 l_assignment_id NUMBER;
5913 l_recipients_tbl SYSTEM.pa_varchar2_240_tbl_type; /*Commented SYSTEM.pa_varchar2_30_tbl_type for the bug 3311991*/
5914 l_recipients_type_tbl SYSTEM.pa_varchar2_30_tbl_type;
5915
5916 l_approval_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
5917 l_out_approval_nf_rects_tbl PA_CLIENT_EXTN_ASGMT_WF.Users_List_Tbltyp ;
5918 l_number_of_recipients NUMBER := 0;
5919 l_approval_nf_rects_rec PA_CLIENT_EXTN_ASGMT_WF.Users_List_Rectyp ;
5920 l_ntfy_apprvl_recipient_name wf_users.name%TYPE; ---VARCHAR2(240); Changer for 3267790
5921 l_ntfy_apprvl_rect_person_id NUMBER := 0;
5922 l_ntfy_apprvl_rect_type VARCHAR2(30);
5923 l_notification_type VARCHAR2(30);
5924
5925 l_res_mgr_person_id NUMBER;
5926 l_staff_mgr_person_id NUMBER;
5927 l_project_manager_person_id NUMBER ;
5928 l_project_manager_name per_all_people_f.full_name%TYPE; --VARCHAR2(200); Changed for bug 3267790
5929 l_project_party_id NUMBER ;
5930 l_project_role_id NUMBER ;
5931 l_project_role_name VARCHAR2(80);
5932 l_admin_project VARCHAR2(1); --Variable which denotes if a project is an admin project or not
5933 l_num_apr_asgns NUMBER ;
5934 l_num_rej_asgns NUMBER ;
5935 l_display_name wf_users.display_name%TYPE; --VARCHAR2(360); Commented VARCHAR2(360) for bug 3267790 --Commented VARCHAR2(200) for bug 3311991
5936 l_approver_name wf_users.display_name%TYPE; --VARCHAR2(320); Commented VARCHAR2(320) for bug 3267790 --Commented VARCHAR2(200) for bug 3311991
5937 l_aprvl_status_code pa_project_assignments.apprvl_status_code%TYPE;
5938 l_assignment_id_tbl SYSTEM.pa_num_tbl_type;
5939
5940 CURSOR Resource_Manager IS
5941 SELECT distinct res.manager_id
5942 FROM pa_resources_denorm res,
5943 pa_project_assignments asgn,
5944 pa_wf_ntf_performers ntf,
5945 fnd_user fnd
5946 WHERE ntf.group_id = p_group_id
5947 AND asgn.assignment_id = l_assignment_id
5948 AND asgn.assignment_id = ntf.object_id1
5949 AND res.resource_id = asgn.resource_id
5950 AND asgn.start_date BETWEEN res.resource_effective_start_date
5951 AND res.resource_effective_end_date
5952 AND res.manager_id = fnd.employee_id
5953 AND fnd.user_name <> ntf.user_name;
5954
5955 CURSOR Staffing_Manager IS
5956 SELECT distinct per.person_id as staffing_mgr_id
5957 FROM fnd_grants fg,
5958 fnd_objects fob,
5959 fnd_user fnd,
5960 pa_resources_denorm res,
5961 /* Commenting this for performance tuning Bug#2499051
5962 (select pa_security_pvt.get_menu_id('PA_PRM_RES_PRMRY_CONTACT') menu_id
5963 from dual) temp, */
5964 pa_project_assignments asgn,
5965 pa_wf_ntf_performers ntf,
5966 wf_roles wf,
5967 per_all_people_f per
5968 WHERE ntf.group_id = p_group_id
5969 AND asgn.assignment_id = l_assignment_id
5970 AND asgn.assignment_id = ntf.object_id1
5971 AND res.resource_id = asgn.resource_id
5972 AND asgn.start_date BETWEEN res.resource_effective_start_date
5973 AND res.resource_effective_end_date
5974 --AND fnd.employee_id = to_number(substr(fg.grantee_key,instr(fg.grantee_key,':')+1))
5975 AND fnd.employee_id = per.person_id
5976 AND per.party_id = wf.orig_system_id
5977 AND sysdate between per.effective_start_date and per.effective_end_date
5978 AND wf.orig_system = 'HZ_PARTY'
5979 AND fg.grantee_key = wf.name
5980 AND fnd.user_name <> ntf.user_name
5981 AND fg.instance_pk1_value = TO_CHAR(res.resource_organization_id)
5982 AND fg.instance_type = 'INSTANCE'
5983 AND fg.object_id = fob.object_id
5984 AND fob.obj_name = 'ORGANIZATION'
5985 AND fg.menu_id = pa_security_pvt.get_menu_id('PA_PRM_RES_PRMRY_CONTACT') /* temp.menu_id commented for bug#2499051 */
5986 AND fg.grantee_type = 'USER'
5987 AND trunc(SYSDATE) BETWEEN trunc(fg.start_date)
5988 AND trunc(NVL(fg.END_DATE, SYSDATE+1));
5989
5990 l_index NUMBER;
5991
5992 CURSOR get_managers IS
5993 SELECT distinct user_name,
5994 user_type
5995 FROM pa_wf_ntf_performers
5996 WHERE wf_type_code = 'MASS_APPROVAL_FYI'
5997 AND group_id = p_group_id;
5998 l_notified_id NUMBER;
5999 l_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N'); -- 5345171
6000
6001 BEGIN
6002
6003 -- Initialize the Error Stack
6004 PA_DEBUG.init_err_stack('PA_ASGMT_WFSTD.process_mgr_fyi_notification');
6005
6006 --Log Message
6007 IF l_debug_mode = 'Y' THEN -- 5345171
6008 PA_DEBUG.write_log
6009 ( x_module => 'pa.plsql.PA_ASGMT_WFSTD.process_mgr_fyi_notification.begin'
6010 ,x_msg => 'Beginning of mass fyi workflow api'
6011 ,x_log_level => 1);
6012 END IF;
6013
6014 -- Initialize the return status to success
6015 x_return_status := FND_API.G_RET_STS_SUCCESS;
6016
6017 --Clear the global PL/SQL message table
6018 FND_MSG_PUB.initialize;
6019
6020 --------------------------------------------
6021 --Get Project Manager for these assignments
6022 --------------------------------------------
6023 --Get the project type
6024 --MOAC Changes: Bug 4363092 : removed nvl usage with org_id
6025 SELECT NVL(pt.administrative_flag,'N') admin_flag
6026 INTO l_admin_project
6027 FROM pa_projects_all pap,
6028 pa_project_types_all pt
6029 WHERE pap.project_id = p_project_id
6030 AND pt.project_type = pap.project_type
6031 AND pap.org_id = pt.org_id;
6032
6033 --Only Non-admin Projects have managers
6034 IF l_admin_project = 'N' THEN
6035
6036 --Log Message
6037 IF l_debug_mode = 'Y' THEN -- 5345171
6038 PA_DEBUG.write_log
6039 (x_module => 'pa.plsql.PA_ASGMT_WFSTD.process_mgr_fyi_notification.check_prj_manager.'
6040 ,x_msg => 'Check if project manger exists.'
6041 ,x_log_level => 1);
6042 END IF;
6043
6044 pa_project_parties_utils.get_curr_proj_mgr_details
6045 ( p_project_id => p_project_id
6046 ,x_manager_person_id => l_project_manager_person_id
6047 ,x_manager_name => l_project_manager_name
6048 ,x_project_party_id => l_project_party_id
6049 ,x_project_role_id => l_project_role_id
6050 ,x_project_role_name => l_project_role_name
6051 ,x_return_status => l_return_status
6052 ,x_error_message_code => l_error_message_code );
6053
6054 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
6055 PA_UTILS.Add_Message( p_app_short_name => 'PA'
6056 ,p_msg_name => l_error_message_code);
6057 END IF;
6058
6059 l_return_status := FND_API.G_MISS_CHAR;
6060 l_error_message_code := FND_API.G_MISS_CHAR;
6061
6062 END IF; --end l_admin_project = 'N'
6063
6064 log_message('After Getting manager');
6065
6066 l_assignment_id_tbl := p_assignment_id_tbl;
6067
6068 ---------------------------------------------------------
6069 --For every assignment in this mass transaction populate
6070 --pa_wf_ntf_performers with recipients
6071 --Assumptions: The project manager remains the same for
6072 --all assignments in the client extension
6073 --------------------------------------------------------
6074 FOR i in 1..l_assignment_id_tbl.COUNT LOOP
6075
6076 --Getting recepients approval type
6077 SELECT apprvl_status_code
6078 INTO l_aprvl_status_code
6079 FROM pa_project_assignments
6080 WHERE assignment_id = l_assignment_id_tbl(i);
6081
6082 IF l_aprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_approved THEN
6083 l_notification_type := 'APPROVAL_FYI';
6084 ELSE l_notification_type := 'REJECTION_FYI';
6085 END IF;
6086
6087 --Get Resource Manager and Staffing Manager for this
6088 --assignment and pass to client extension along with
6089 --Project Manager
6090 l_assignment_id := l_assignment_id_tbl(i);
6091
6092 --Getting Resource manager
6093 OPEN Resource_Manager;
6094 FETCH Resource_manager INTO l_res_mgr_person_id;
6095 CLOSE Resource_Manager;
6096
6097 --Getting Staffing Manager
6098 OPEN Staffing_Manager;
6099 FETCH Staffing_manager INTO l_staff_mgr_person_id;
6100 CLOSE Staffing_Manager;
6101
6102 ----------------------------------------------
6103 --Build recipient IN table for client extensions
6104 ----------------------------------------------
6105
6106 l_index := 0;
6107
6108 --Populating Resource manager in recipient table
6109 ------------------------------------------------
6110 IF l_res_mgr_person_id IS NOT NULL THEN
6111
6112 --Getting recepients fnd user name
6113 wf_directory.getusername
6114 (p_orig_system => 'PER'
6115 ,p_orig_system_id => l_res_mgr_person_id
6116 ,p_name => l_ntfy_apprvl_recipient_name
6117 ,p_display_name => l_display_name);
6118
6119 l_ntfy_apprvl_rect_type := 'RESOURCE_MANAGER';
6120
6121 --ceating the recipient in table
6122 IF l_ntfy_apprvl_recipient_name IS NOT NULL THEN
6123 l_approval_nf_rects_rec.User_Name := l_ntfy_apprvl_recipient_name;
6124 l_approval_nf_rects_rec.Person_id := l_res_mgr_person_id;
6125 l_approval_nf_rects_rec.Type := l_ntfy_apprvl_rect_type;
6126 --l_approval_nf_rects_rec.Routing_Order := ?;
6127 l_approval_nf_rects_tbl(l_index + 1) := l_approval_nf_rects_rec;
6128 l_index := l_index + 1;
6129 END IF;
6130
6131 END IF;
6132
6133 log_message('Resource Mgr name:' || l_ntfy_apprvl_recipient_name);
6134
6135
6136 --Populating Staffing manager in recipient table
6137 ------------------------------------------------
6138 IF l_staff_mgr_person_id IS NOT NULL THEN
6139
6140 --Getting recepients fnd user name
6141 wf_directory.getusername
6142 (p_orig_system => 'PER'
6143 ,p_orig_system_id => l_staff_mgr_person_id
6144 ,p_name => l_ntfy_apprvl_recipient_name
6145 ,p_display_name => l_display_name);
6146
6147 l_ntfy_apprvl_rect_type := 'STAFFING_MANAGER';
6148
6149 IF l_ntfy_apprvl_recipient_name IS NOT NULL THEN
6150 l_approval_nf_rects_rec.User_Name := l_ntfy_apprvl_recipient_name;
6151 l_approval_nf_rects_rec.Person_id := l_staff_mgr_person_id;
6152 l_approval_nf_rects_rec.Type := l_ntfy_apprvl_rect_type;
6153 --l_approval_nf_rects_rec.Routing_Order := ?;
6154 l_approval_nf_rects_tbl(l_index + 1) := l_approval_nf_rects_rec;
6155 l_index := l_index + 1;
6156 END IF;
6157
6158 END IF;
6159
6160 log_message('Staff Mgr name:' || l_ntfy_apprvl_recipient_name);
6161
6162
6163 --Populating Project manager in recipient table
6164 -----------------------------------------------
6165 IF l_project_manager_person_id IS NOT NULL THEN
6166
6167 --Getting recepients fnd user name
6168 wf_directory.getusername
6169 (p_orig_system => 'PER'
6170 ,p_orig_system_id => l_project_manager_person_id
6171 ,p_name => l_ntfy_apprvl_recipient_name
6172 ,p_display_name => l_display_name);
6173
6174 l_ntfy_apprvl_rect_type := 'PROJECT_MANAGER';
6175
6176 IF l_ntfy_apprvl_recipient_name IS NOT NULL THEN
6177 l_approval_nf_rects_rec.User_Name := l_ntfy_apprvl_recipient_name;
6178 l_approval_nf_rects_rec.Person_id := l_project_manager_person_id;
6179 l_approval_nf_rects_rec.Type := l_ntfy_apprvl_rect_type;
6180 --l_approval_nf_rects_rec.Routing_Order := ?;
6181 l_approval_nf_rects_tbl(l_index + 1) := l_approval_nf_rects_rec;
6182 l_index := l_index + 1;
6183 END IF;
6184
6185 END IF;
6186
6187 log_message('Before calling mgr client extensions');
6188 log_message('Project Mgr name:' || l_ntfy_apprvl_recipient_name);
6189 log_message('assignment_id:' || l_assignment_id);
6190 log_message('Before COUNT:' || l_approval_nf_rects_tbl.COUNT);
6191
6192 -------------------------------------------------
6193 --Calling client extension to get all recipients
6194 -------------------------------------------------
6195 PA_CLIENT_EXTN_ASGMT_WF.Generate_NF_Recipients
6196 (p_assignment_id => l_assignment_id
6197 ,p_project_id => p_project_id
6198 ,p_notification_type => l_notification_type
6199 ,p_in_list_of_recipients => l_approval_nf_rects_tbl
6200 ,x_out_list_of_recipients => l_out_approval_nf_rects_tbl
6201 ,x_number_of_recipients => l_number_of_recipients );
6202
6203 log_message('After calling mgr client extensions');
6204 log_message('After COUNT:' || l_out_approval_nf_rects_tbl.COUNT);
6205 log_message('Total number of managers is:' || l_number_of_recipients );
6206
6207 IF l_out_approval_nf_rects_tbl.COUNT > 0 THEN
6208
6209 ---------------------------------------------------------
6210 --Get Recipients and populate pa_wf_ntf_performers table
6211 --Use WF_TYPE_CODE as MASS_APPROVAL_FYI
6212 ---------------------------------------------------------
6213 FOR j IN 1..l_out_approval_nf_rects_tbl.COUNT LOOP
6214 l_approval_nf_rects_rec := l_out_approval_nf_rects_tbl(j);
6215
6216 log_message('User Name ' || j || ':' || l_approval_nf_rects_rec.user_name);
6217
6218 IF l_approval_nf_rects_rec.user_name IS NOT NULL THEN
6219
6220 log_message('Insert in loop:' || j);
6221
6222 INSERT INTO pa_wf_ntf_performers(
6223 WF_TYPE_CODE
6224 ,ITEM_TYPE
6225 ,ITEM_KEY
6226 ,OBJECT_ID1
6227 ,GROUP_ID
6228 ,USER_NAME
6229 ,USER_TYPE
6230 ,ROUTING_ORDER )
6231 VALUES ('MASS_APPROVAL_FYI'
6232 ,'-1'
6233 ,'-1'
6234 ,l_assignment_id
6235 ,p_group_id
6236 ,l_approval_nf_rects_rec.user_name
6237 ,l_approval_nf_rects_rec.type
6238 ,l_approval_nf_rects_rec.routing_order
6239 );
6240 END IF;--end l_approval_nf_rects_rec.user_name
6241
6242 END LOOP;--end j loop
6243
6244 END IF;
6245
6246 END LOOP;--end i loop
6247
6248 log_message('After inserting manager records');
6249
6250 --------------------------------------------------------
6251 --Select distinct recipients for this mass transaction
6252 --from pa_wf_ntf_performers table and send notifications
6253 --------------------------------------------------------
6254 OPEN get_managers;
6255 FETCH get_managers BULK COLLECT INTO l_recipients_tbl, l_recipients_type_tbl;
6256 CLOSE get_managers;
6257
6258 log_message('Number of manangers :' || l_recipients_tbl.COUNT);
6259
6260 --Delete recipients from pa_wf_ntf_performers table
6261 --for this mass transaction
6262 DELETE
6263 FROM pa_wf_ntf_performers
6264 WHERE wf_type_code = 'MASS_APPROVAL_FYI'
6265 AND group_id = p_group_id;
6266
6267 --------------------------------------------------------
6268 --Start Notification Workflow for all manager recipients
6269 --------------------------------------------------------
6270 l_wf_started_by_id := FND_GLOBAL.user_id;
6271 l_responsibility_id := FND_GLOBAL.resp_id;
6272 l_resp_appl_id := FND_GLOBAL.resp_appl_id;
6273
6274 FND_GLOBAL.Apps_Initialize ( user_id => l_wf_started_by_id
6275 , resp_id => l_responsibility_id
6276 , resp_appl_id => l_resp_appl_id );
6277
6278 -- Setting thresold value to run the process in background
6279 l_save_threshold := wf_engine.threshold;
6280 wf_engine.threshold := -1;
6281
6282 -----------------------------------------------------------------------------
6283 --Setting Process Creation / Update / Aproval submission mode for assignments
6284 -----------------------------------------------------------------------------
6285 IF p_mode = PA_MASS_ASGMT_TRX.G_MASS_ASGMT THEN
6286
6287 l_wf_process := 'PA_MASS_APRVL_CRN_FP';
6288
6289 ELSIF (p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_ASGMT_BASIC_INFO OR
6290 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_COMPETENCIES OR
6291 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_FORECAST_ITEMS OR
6292 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_SCHEDULE )
6293 THEN
6294
6295 l_wf_process := 'PA_MASS_APRVL_UPD_FP';
6296
6297 ELSIF p_mode = PA_MASS_ASGMT_TRX.G_MASS_SUBMIT_FOR_APPROVAL THEN
6298
6299 l_wf_process := 'PA_MASS_APRVL_APS_FP';
6300
6301 END IF;
6302
6303
6304 For k IN 1..l_recipients_tbl.COUNT LOOP
6305
6306 -- Create the unique item key to launch WF with
6307 SELECT pa_prm_wf_item_key_s.nextval
6308 INTO l_itemkey
6309 FROM dual;
6310
6311 -- Create the WF process
6312 wf_engine.CreateProcess
6313 ( ItemType => l_wf_item_type
6314 , ItemKey => l_itemkey
6315 , process => l_wf_process );
6316
6317 ------------------------------------------------------------
6318 --Set the item attributes required for manager notifications
6319 ------------------------------------------------------------
6320 wf_engine.SetItemAttrText
6321 ( itemtype => l_wf_item_type
6322 , itemkey => l_itemkey
6323 , aname => 'NTFY_FYI_USER_NAME'
6324 , avalue => l_recipients_tbl(k));
6325
6326 ------------------------------------------------------------------
6327 --Getting manager person_id
6328 --The logic below gets the manager person id only for
6329 --Staffing and Resource managers. For Project managers
6330 --notified_id will be null and selected roles and selected resources
6331 --pages should display all resources/roles in the mass transaction
6332 -------------------------------------------------------------------
6333 l_notified_id := null;
6334 BEGIN
6335
6336 IF l_recipients_type_tbl(k) <> 'PROJECT_MANAGER' THEN
6337 SELECT employee_id
6338 INTO l_notified_id
6339 FROM fnd_user
6340 WHERE user_name = l_recipients_tbl(k)
6341 AND rownum = 1;
6342
6343 -- bug 2475300 : added following two select stmt to set # of approved/rejected
6344 -- asmt according to the resource/staffing manager. Resource/staffing mgr should
6345 -- see the # of asmt which is related to only their resources.
6346 SELECT count(*)
6347 INTO l_num_apr_asgns
6348 FROM pa_res_aprvl_roles_v ar
6349 WHERE ar.notified_id = l_notified_id
6350 AND ar.group_id = p_group_id
6351 AND ar.approval_status = 'ASGMT_APPRVL_APPROVED';
6352
6353 SELECT count(*)
6354 INTO l_num_rej_asgns
6355 FROM pa_res_aprvl_roles_v ar
6356 WHERE ar.notified_id = l_notified_id
6357 AND ar.group_id = p_group_id
6358 AND ar.approval_status = 'ASGMT_APPRVL_REJECTED';
6359 ELSE
6360 l_num_apr_asgns := p_num_apr_asgns;
6361 l_num_rej_asgns := p_num_rej_asgns;
6362 END IF;
6363
6364 EXCEPTION
6365 WHEN OTHERS THEN
6366 null;
6367 END;
6368
6369 log_message('Before Calling set manager attributes');
6370
6371 set_manager_attributes
6372 ( itemtype => l_wf_item_type
6373 ,itemkey => l_itemkey
6374 ,p_group_id => p_group_id
6375 ,p_mode => p_mode
6376 ,p_update_info_doc => p_update_info_doc
6377 ,p_num_apr_asgns => p_num_apr_asgns
6378 ,p_num_rej_asgns => p_num_rej_asgns
6379 ,p_project_name => p_project_name
6380 ,p_project_number => p_project_number
6381 ,p_project_manager => p_project_manager
6382 ,p_project_org => p_project_org
6383 ,p_project_cus => p_project_cus
6384 ,p_conflict_group_id => p_conflict_group_id
6385 ,p_notified_id => l_notified_id
6386 ,x_return_status => l_return_status
6387 ,x_msg_count => l_msg_count );
6388
6389 log_message('After Calling set manager attributes');
6390
6391 --Start the workflow process
6392 wf_engine.StartProcess ( itemtype => l_wf_item_type
6393 ,itemkey => l_itemkey );
6394
6395 PA_WORKFLOW_UTILS.Insert_WF_Processes
6396 (p_wf_type_code => 'MASS_ASSIGNMENT_APPROVAL'
6397 ,p_item_type => l_wf_item_type
6398 ,p_item_key => l_itemkey
6399 ,p_entity_key1 => to_char(p_project_id)
6400 ,p_entity_key2 => to_char(p_group_id)
6401 ,p_description => NULL
6402 ,p_err_code => l_err_code
6403 ,p_err_stage => l_err_stage
6404 ,p_err_stack => l_err_stack );
6405
6406 END LOOP;--end k loop
6407
6408
6409 --Setting the original value
6410 wf_engine.threshold := l_save_threshold;
6411
6412 -- IF the number of messages is 1 then fetch the message code from
6413 -- the stack and return its text
6414 x_msg_count := FND_MSG_PUB.Count_Msg;
6415
6416 IF x_msg_count = 1 THEN
6417 pa_interface_utils_pub.get_messages
6418 ( p_encoded => FND_API.G_TRUE
6419 ,p_msg_index => 1
6420 ,p_data => x_msg_data
6421 ,p_msg_index_out => l_msg_index_out );
6422 END IF;
6423
6424 -- Reset the error stack when returning to the calling program
6425 PA_DEBUG.Reset_Err_Stack;
6426
6427 -- If g_error_exists is TRUE then set the x_return_status to 'E'
6428 IF FND_MSG_PUB.Count_Msg >0 THEN
6429 x_return_status := FND_API.G_RET_STS_ERROR;
6430 END IF;
6431
6432 EXCEPTION
6433 WHEN OTHERS THEN
6434
6435 -- Set the excetption Message and the stack
6436 FND_MSG_PUB.add_exc_msg
6437 ( p_pkg_name => 'PA_ASGMT_WFSTD.process_mgr_fyi_notification'
6438 ,p_procedure_name => PA_DEBUG.G_Err_Stack );
6439
6440 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6441 RAISE;
6442 END process_mgr_fyi_notification;
6443
6444
6445
6446 ----------------------------------------------------------------
6447 --This API is called inside the workflow to make the processing
6448 --of approval result a background process
6449 --It doest the processing of approval result by calling API
6450 --process_approval_result
6451 ----------------------------------------------------------------
6452 PROCEDURE process_approval_result_wf
6453 ( itemtype IN VARCHAR2
6454 ,itemkey IN VARCHAR2
6455 ,actid IN NUMBER
6456 ,funcmode IN VARCHAR2
6457 ,resultout OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
6458 )
6459 IS
6460 l_msg_index_out NUMBER;
6461 l_msg_count NUMBER;
6462 l_msg_data VARCHAR2(2000);
6463 l_return_status VARCHAR2(1);
6464 x_return_status VARCHAR2(1);
6465 x_msg_count NUMBER;
6466 x_msg_data VARCHAR2(2000);
6467
6468 l_project_id pa_project_assignments.project_id%TYPE;
6469 l_mode VARCHAR2(30);
6470 l_assignment_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
6471 l_approval_status_tbl SYSTEM.pa_varchar2_30_tbl_type:= SYSTEM.pa_varchar2_30_tbl_type();
6472 l_group_id NUMBER;
6473 l_approver_group_id NUMBER;
6474 l_routing_order NUMBER;
6475 l_num_assignments NUMBER;
6476 l_conflict_group_id NUMBER;
6477 l_update_info_doc VARCHAR2(2000);
6478 l_submitter_user_name fnd_user.user_name%type; /* Commeted for bug 3261755 VARCHAR2(30); */
6479 l_note_to_approvers VARCHAR2(2000);
6480 l_forwarded_from fnd_user.user_name%type; /* Commeted for bug 3261755 VARCHAR2(30); */
6481 l_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N'); -- 5345171
6482
6483 BEGIN
6484 log_message('Inside mass_process_approval_result_wf');
6485
6486 -- Initialize the Error Stack
6487 PA_DEBUG.init_err_stack('PA_ASGMT_WFSTD.mass_process_approval_result_wf');
6488
6489 --Log Message
6490 IF l_debug_mode = 'Y' THEN -- 5345171
6491 PA_DEBUG.write_log
6492 ( x_module => 'pa.plsql.PA_ASGMT_WFSTD.mass_process_approval_result_wf.begin'
6493 ,x_msg => 'Beginning of mass_assignment_approval'
6494 ,x_log_level => 1);
6495 END IF;
6496
6497 -- Initialize the return status to success
6498 x_return_status := FND_API.G_RET_STS_SUCCESS;
6499
6500 --Clear the global PL/SQL message table
6501 FND_MSG_PUB.initialize;
6502
6503 log_message('Inside mass_process_approval_result_wf 2');
6504
6505 ---------------------------------------------------
6506 --Get the values required from the item attributes
6507 ---------------------------------------------------
6508 l_project_id := wf_engine.getItemAttrNumber
6509 ( itemtype => itemtype
6510 , itemkey => itemkey
6511 , aname => 'PROJECT_ID' );
6512
6513 l_mode := wf_engine.getItemAttrText
6514 ( itemtype => itemtype
6515 , itemkey => itemkey
6516 , aname => 'MODE' );
6517
6518 l_group_id := wf_engine.getItemAttrNumber
6519 ( itemtype => itemtype
6520 , itemkey => itemkey
6521 , aname => 'GROUP_ID' );
6522
6523 l_approver_group_id := wf_engine.getItemAttrNumber
6524 ( itemtype => itemtype
6525 , itemkey => itemkey
6526 , aname => 'APPROVER_GROUP_ID' );
6527
6528 l_routing_order := wf_engine.getItemAttrNumber
6529 ( itemtype => itemtype
6530 , itemkey => itemkey
6531 , aname => 'ROUTING_ORDER' );
6532
6533 l_num_assignments := wf_engine.getItemAttrNumber
6534 ( itemtype => itemtype
6535 , itemkey => itemkey
6536 , aname => 'NUMBER_OF_ASSIGNMENTS' );
6537
6538 --Get the Update Info document
6539 l_update_info_doc := wf_engine.getItemAttrDocument
6540 ( itemtype => itemtype
6541 , itemkey => itemkey
6542 , aname => 'UPDATED_INFO_DOC' );
6543
6544 l_submitter_user_name := wf_engine.getItemAttrText
6545 ( itemtype => itemtype
6546 , itemkey => itemkey
6547 , aname => 'SUBMITTER_UNAME');
6548
6549 l_conflict_group_id := wf_engine.getItemAttrNumber
6550 ( itemtype => itemtype
6551 , itemkey => itemkey
6552 , aname => 'CONFLICT_GROUP_ID' );
6553
6554 l_forwarded_from := wf_engine.getItemAttrText
6555 ( itemtype => itemtype
6556 , itemkey => itemkey
6557 , aname => 'NTFY_APPRVL_RECIPIENT_NAME');
6558
6559 l_note_to_approvers := wf_engine.getItemAttrText
6560 ( itemtype => itemtype
6561 , itemkey => itemkey
6562 , aname => 'NOTE_TO_APPROVER');
6563
6564 -----------------------------------------------------------
6565 --Loop through all assignments and populate the assignment
6566 --and status tables
6567 --Also get number of approved and rejected assignments
6568 -----------------------------------------------------------
6569 FOR i IN 1..l_num_assignments LOOP
6570 l_assignment_id_tbl.extend;
6571 l_assignment_id_tbl(i) := wf_engine.getItemAttrNumber
6572 ( itemtype => itemtype
6573 ,itemkey => itemkey
6574 ,aname => 'ASSIGNMENT_'|| i );
6575
6576 l_approval_status_tbl.extend;
6577 l_approval_status_tbl(i) := wf_engine.getItemAttrText
6578 ( itemtype => itemtype
6579 ,itemkey => itemkey
6580 ,aname => 'STATUS_'|| i );
6581 END LOOP;
6582
6583 log_message('Before Calling process approval_result');
6584
6585 process_approval_result
6586 ( p_project_id => l_project_id
6587 ,p_mode => l_mode
6588 ,p_assignment_id_tbl => l_assignment_id_tbl
6589 ,p_approval_status_tbl => l_approval_status_tbl
6590 ,p_group_id => l_group_id
6591 ,p_approver_group_id => l_approver_group_id
6592 ,p_routing_order => l_routing_order
6593 ,p_num_of_assignments => l_num_assignments
6594 ,p_submitter_user_name => l_submitter_user_name
6595 ,p_conflict_group_id => l_conflict_group_id
6596 ,p_update_info_doc => l_update_info_doc
6597 ,p_forwarded_from => l_forwarded_from
6598 ,p_note_to_approvers => l_note_to_approvers);
6599
6600 log_message('After Calling process approval_result');
6601
6602 ------------------------------------------------------------------
6603 -- IF the number of messages is 1 then fetch the message code from
6604 -- the stack and return its text
6605 ------------------------------------------------------------------
6606 x_msg_count := FND_MSG_PUB.Count_Msg;
6607
6608 IF x_msg_count = 1 THEN
6609 pa_interface_utils_pub.get_messages
6610 ( p_encoded => FND_API.G_TRUE
6611 ,p_msg_index => 1
6612 ,p_data => x_msg_data
6613 ,p_msg_index_out => l_msg_index_out );
6614 END IF;
6615
6616 -- Reset the error stack when returning to the calling program
6617 PA_DEBUG.Reset_Err_Stack;
6618
6619 -- If g_error_exists is TRUE then set the x_return_status to 'E'
6620 IF FND_MSG_PUB.Count_Msg >0 THEN
6621 x_return_status := FND_API.G_RET_STS_ERROR;
6622 END IF;
6623
6624 EXCEPTION
6625 WHEN OTHERS THEN
6626
6627 -- Set the excetption Message and the stack
6628 FND_MSG_PUB.add_exc_msg
6629 ( p_pkg_name => 'PA_ASGMT_WFSTD.process_approval_result_wf'
6630 ,p_procedure_name => PA_DEBUG.G_Err_Stack );
6631
6632 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6633 RAISE;
6634 END process_approval_result_wf;
6635
6636 -----------------------------------------------------------
6637 --This Procedure reverts the assignment status to
6638 --Working or Requires Re-submission from
6639 --submitted in case of errors
6640 -----------------------------------------------------------
6641 PROCEDURE Revert_assignment_status(
6642 p_assignment_id IN NUMBER
6643 ,p_group_id IN NUMBER
6644 ,x_return_status OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
6645 IS
6646
6647 CURSOR get_status_and_rec_num IS
6648 SELECT record_version_number
6649 FROM pa_project_assignments
6650 WHERE assignment_id = p_assignment_id;
6651
6652 CURSOR get_assignment_status IS
6653 SELECT approval_status
6654 FROM pa_wf_ntf_performers
6655 WHERE group_id = p_group_id
6656 AND object_id1 = p_assignment_id
6657 AND rownum = 1;
6658
6659 l_record_version_number NUMBER;
6660 l_apprvl_status_code pa_project_statuses.project_status_code%TYPE;
6661 l_return_status VARCHAR2(1);
6662
6663 BEGIN
6664
6665 OPEN get_status_and_rec_num;
6666 FETCH get_status_and_rec_num INTO l_record_version_number;
6667 CLOSE get_status_and_rec_num;
6668
6669 OPEN get_assignment_status;
6670 FETCH get_assignment_status INTO l_apprvl_status_code ;
6671 CLOSE get_assignment_status;
6672
6673 PA_PROJECT_ASSIGNMENTS_PKG.Update_Row (
6674 p_assignment_id => p_assignment_id
6675 ,p_record_version_number => l_record_version_number
6676 ,p_apprvl_status_code => l_apprvl_status_code
6677 ,x_return_status => l_return_status );
6678
6679 x_return_status := l_return_status;
6680
6681 ---------------------------------
6682 --Set the pending approval flag
6683 ---------------------------------
6684 Maintain_wf_pending_flag
6685 (p_assignment_id => p_assignment_id,
6686 p_mode => 'APPROVAL_PROCESS_COMPLETED') ;
6687
6688 log_message('After Maintain pending flag for assignment id:' || p_assignment_id);
6689
6690 ---------------------------
6691 --Set the mass wf flag
6692 ---------------------------
6693 UPDATE pa_project_assignments
6694 SET mass_wf_in_progress_flag = 'N'
6695 WHERE assignment_id = p_assignment_id;
6696
6697 EXCEPTION
6698 WHEN OTHERS THEN
6699
6700 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
6701 RAISE;
6702 END Revert_assignment_status;
6703
6704 ----------------------------------------------------------
6705 --This procedure does the per assignment approval processing
6706 --tasks
6707 -----------------------------------------------------------
6708 PROCEDURE process_assignment_tasks (
6709 p_assignment_id IN NUMBER
6710 ,p_approval_status IN pa_project_assignments.apprvl_status_code%TYPE
6711 ,p_action_code IN VARCHAR2
6712 ,p_conflict_group_id IN NUMBER
6713 ,p_project_id IN NUMBER
6714 ,p_mode IN VARCHAR2
6715 ,p_project_name IN VARCHAR2
6716 ,p_project_number IN VARCHAR2
6717 ,p_project_manager IN VARCHAR2
6718 ,p_project_org IN VARCHAR2
6719 ,p_project_cus IN VARCHAR2
6720 ,p_submitter_user_name IN VARCHAR2
6721 ,p_group_id IN NUMBER
6722 ,p_routing_order IN NUMBER)
6723
6724 IS
6725 PRAGMA AUTONOMOUS_TRANSACTION;
6726
6727 l_change_id NUMBER;
6728 l_aprvl_status_code pa_project_assignments.apprvl_status_code%TYPE;
6729 l_resource_id NUMBER;
6730 l_submitter_user_id NUMBER;
6731 l_record_version_number1 NUMBER;
6732 l_record_version_number2 NUMBER;
6733 l_return_status VARCHAR2(1);
6734 l_msg_count NUMBER;
6735 l_msg_data VARCHAR2(2000);
6736
6737 CURSOR pending_approvals (c_assignment_id IN NUMBER) IS
6738 SELECT user_name
6739 FROM pa_wf_ntf_performers ntf
6740 WHERE ntf.group_id = p_group_id
6741 AND ntf.routing_order = p_routing_order + 1
6742 AND ntf.object_id1 = c_assignment_id;
6743
6744 l_pending_approvals pending_approvals%ROWTYPE;
6745
6746 CURSOR get_rec_num ( p_assignment_id IN NUMBER )IS
6747 SELECT record_version_number
6748 FROM pa_project_assignments
6749 WHERE assignment_id = p_assignment_id;
6750
6751 BEGIN
6752
6753 SAVEPOINT UPDATE_APPROVAL_STATUS;
6754
6755 OPEN pending_approvals (p_assignment_id);
6756 FETCH pending_approvals INTO l_pending_approvals;
6757
6758 IF (pending_approvals%NOTFOUND) OR (p_approval_status = PA_ASSIGNMENT_APPROVAL_PUB.g_reject_action) THEN
6759
6760 log_message('No pending approvals for assignment:' || p_assignment_id);
6761
6762 OPEN get_rec_num ( p_assignment_id );
6763 FETCH get_rec_num INTO l_record_version_number1;
6764 CLOSE get_rec_num;
6765
6766 log_message('Record version number:' || l_record_version_number1);
6767 log_message('Before calling Update approval status');
6768
6769 PA_ASSIGNMENT_APPROVAL_PVT.Update_Approval_Status
6770 ( p_assignment_id => p_assignment_id
6771 ,p_action_code => p_action_code
6772 ,p_note_to_approver => null
6773 ,p_record_version_number => l_record_version_number1
6774 ,x_apprvl_status_code => l_aprvl_status_code
6775 ,x_change_id => l_change_id
6776 ,x_record_version_number => l_record_version_number2
6777 ,x_return_status => l_return_status
6778 ,x_msg_count => l_msg_count
6779 ,x_msg_data => l_msg_data);
6780
6781 log_message('After calling Update approval status');
6782 log_message('Before Calling resolve conflicts:' || p_conflict_group_id);
6783
6784 If (p_conflict_group_id IS NOT NULL) THEN
6785 PA_SCHEDULE_PVT.resolve_conflicts
6786 ( p_conflict_group_id => p_conflict_group_id
6787 ,p_assignment_id => p_assignment_id
6788 ,x_return_status => l_return_status
6789 ,x_msg_count => l_msg_count
6790 ,x_msg_data => l_msg_data);
6791 END IF;
6792
6793 log_message('After Calling resolve conflicts');
6794
6795 --------------------------------
6796 --Call resource fyi notification
6797 --------------------------------
6798 log_message('Before Calling process res fyi');
6799
6800 process_res_fyi_notification
6801 ( p_project_id => p_project_id
6802 ,p_mode => p_mode
6803 ,p_assignment_id => p_assignment_id
6804 ,p_project_name => p_project_name
6805 ,p_project_number => p_project_number
6806 ,p_project_manager => p_project_manager
6807 ,p_project_org => p_project_org
6808 ,p_project_cus => p_project_cus
6809 ,p_conflict_group_id => p_conflict_group_id
6810 ,x_return_status => l_return_status
6811 ,x_msg_count => l_msg_count
6812 ,x_msg_data => l_msg_data);
6813
6814 log_message('After Calling process res fyi');
6815
6816 IF FND_MSG_PUB.Count_Msg > 0 THEN
6817
6818 log_message('Error in res_fyi');
6819
6820 ROLLBACK TO UPDATE_APPROVAL_STATUS;
6821
6822 SELECT user_id
6823 INTO l_submitter_user_id
6824 FROM fnd_user
6825 WHERE user_name = p_submitter_user_name;
6826
6827 SELECT resource_id
6828 INTO l_resource_id
6829 FROM pa_project_assignments
6830 WHERE assignment_id = p_assignment_id;
6831
6832 --Revert assignment status back to Working or Requires Re-submission
6833 Revert_assignment_status(
6834 p_assignment_id => p_assignment_id
6835 ,p_group_id => p_group_id
6836 ,x_return_status => l_return_status);
6837
6838 PA_MESSAGE_UTILS.save_messages
6839 (p_user_id => l_submitter_user_id,
6840 p_source_type1 => PA_MASS_ASGMT_TRX.G_SOURCE_TYPE1,
6841 p_source_type2 => 'MASS_APPROVAL',
6842 p_source_identifier1 => 'PAWFAAP',
6843 p_source_identifier2 => p_group_id,
6844 p_context1 => p_project_id,
6845 p_context2 => p_assignment_id,
6846 p_context3 => l_resource_id,
6847 p_commit => FND_API.G_TRUE,
6848 x_return_status => l_return_status);
6849
6850 log_message('After Error in res_fyi');
6851
6852 ELSE
6853 ----------------------------
6854 --Commit per assignment
6855 ----------------------------
6856 COMMIT;
6857 END IF; --end l_return_status <> success
6858
6859 ELSE
6860
6861 COMMIT; --When pending_approvals not found
6862
6863 END IF;--end pending_approvals%NOTFOUND
6864 CLOSE pending_approvals;
6865
6866 EXCEPTION
6867 WHEN OTHERS THEN
6868
6869 ROLLBACK TO UPDATE_APPROVAL_STATUS;
6870
6871 RAISE;
6872 END process_assignment_tasks;
6873
6874 ------------------------------------------------------------------
6875 --This API is called by the workflow API process_approval_result_wf
6876 --This API does the processing of approval result including sending
6877 --notifications to managers and resource
6878 -------------------------------------------------------------------
6879 PROCEDURE process_approval_result
6880 ( p_project_id IN NUMBER
6881 ,p_mode IN VARCHAR2
6882 ,p_assignment_id_tbl IN SYSTEM.pa_num_tbl_type
6883 ,p_approval_status_tbl IN SYSTEM.pa_varchar2_30_tbl_type
6884 ,p_group_id IN NUMBER
6885 ,p_approver_group_id IN NUMBER
6886 ,p_routing_order IN NUMBER
6887 ,p_num_of_assignments IN NUMBER
6888 ,p_submitter_user_name IN VARCHAR2
6889 ,p_conflict_group_id IN NUMBER
6890 ,p_update_info_doc IN VARCHAR2
6891 ,p_forwarded_from IN VARCHAR2
6892 ,p_note_to_approvers IN VARCHAR2)
6893 IS
6894 l_approval_status pa_project_assignments.apprvl_status_code%TYPE;
6895 l_aprvl_status_code pa_project_assignments.apprvl_status_code%TYPE;
6896 l_change_id NUMBER;
6897 l_action_code VARCHAR2(30);
6898 l_approver_group_id NUMBER;
6899 l_assignment_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
6900 l_msg_index_out NUMBER;
6901 l_msg_count NUMBER;
6902 l_msg_data VARCHAR2(2000);
6903 l_return_status VARCHAR2(1);
6904 x_return_status VARCHAR2(1);
6905 x_msg_count NUMBER;
6906 x_msg_data VARCHAR2(2000);
6907 l_error_message_code VARCHAR(30);
6908 x_error_message_code VARCHAR2(30);
6909
6910 /* Commented and altered as below for bug 5595003
6911 CURSOR distinct_approvers IS
6912 SELECT distinct user_name
6913 FROM pa_wf_ntf_performers ntf,
6914 pa_project_assignments asgn
6915 WHERE ntf.group_id = p_group_id
6916 AND ntf.object_id1 = asgn.assignment_id
6917 AND asgn.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_submitted
6918 AND ntf.routing_order = p_routing_order + 1; */
6919
6920 CURSOR distinct_approvers IS
6921 SELECT distinct ntf.user_name
6922 FROM pa_wf_ntf_performers ntf,
6923 pa_project_assignments asgn,
6924 pa_wf_ntf_performers ntf1
6925 WHERE ntf.group_id = p_group_id
6926 AND ntf.object_id1 = asgn.assignment_id
6927 AND asgn.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_submitted
6928 AND ntf.routing_order = p_routing_order + 1
6929 AND ntf1.group_id = p_group_id
6930 AND ntf1.object_id1 = asgn.assignment_id
6931 AND ntf1.routing_order = p_routing_order
6932 AND ntf1.approver_group_id = p_approver_group_id;
6933
6934 CURSOR pending_txn_approvals IS
6935 SELECT 'Y'
6936 FROM pa_wf_ntf_performers ntf,
6937 pa_project_assignments asgn
6938 WHERE ntf.group_id = p_group_id
6939 AND ntf.object_id1 = asgn.assignment_id
6940 AND asgn.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_submitted;
6941
6942 l_pending_txn_approvals pending_txn_approvals%ROWTYPE;
6943
6944 l_num_apr_asgns NUMBER;
6945 l_num_rej_asgns NUMBER;
6946
6947 l_customer_id NUMBER;
6948 l_customer_name VARCHAR2(2000);
6949 l_project_manager_person_id NUMBER ;
6950 l_project_manager_name per_all_people_f.full_name%TYPE;--VARCHAR2(200); Commented For 3267790
6951 l_project_party_id NUMBER ;
6952 l_project_role_id NUMBER ;
6953 l_project_role_name VARCHAR2(80);
6954
6955 CURSOR l_projects_csr(l_project_id IN NUMBER) IS
6956 SELECT pap.project_id project_id,
6957 pap.name name,
6958 pap.segment1 segment1,
6959 pap.carrying_out_organization_id carrying_out_organization_id,
6960 pap.location_id,
6961 hr.name organization_name,
6962 NVL(pt.administrative_flag,'N') admin_flag
6963 FROM pa_projects_all pap,
6964 hr_all_organization_units hr,
6965 pa_project_types_all pt
6966 WHERE pap.project_id = l_project_id
6967 AND pap.carrying_out_organization_id = hr.organization_id
6968 AND pap.org_id = pt.org_id -- Added for Bug 5389093
6969 AND pt.project_type = pap.project_type;
6970
6971 l_projects_rec l_projects_csr%ROWTYPE;
6972 l_update_info_doc VARCHAR2(2000);
6973
6974 l_submitter_user_id NUMBER;
6975
6976 CURSOR sub_not_required_csr IS
6977 SELECT 'Y'
6978 FROM PA_REPORTING_EXCEPTIONS
6979 WHERE user_id = l_submitter_user_id
6980 AND context = PA_MASS_ASGMT_TRX.G_SOURCE_TYPE1
6981 AND sub_context = 'MASS_APPROVAL'
6982 AND source_identifier1 = 'PAWFAAP'
6983 AND source_identifier2 = p_group_id;
6984
6985 l_sub_not_required_rec sub_not_required_csr%ROWTYPE;
6986
6987
6988 BEGIN
6989
6990 log_message('Inside process approval result');
6991 -----------------------------------------------------------
6992 --Get the Project information for FYI notifications
6993 -------------------------------------------------------
6994 OPEN l_projects_csr( p_project_id);
6995 FETCH l_projects_csr INTO l_projects_rec;
6996 IF l_projects_csr%NOTFOUND THEN
6997 pa_utils.add_message (p_app_short_name => 'PA',
6998 p_msg_name => 'PA_INVALID_PROJECT_ID');
6999 END IF;
7000 CLOSE l_projects_csr;
7001
7002 Check_And_Get_Proj_Customer
7003 (p_project_id => p_project_id
7004 ,x_customer_id => l_customer_id
7005 ,x_customer_name => l_customer_name );
7006
7007 -- Get the project manager details
7008 pa_project_parties_utils.get_curr_proj_mgr_details
7009 (p_project_id => l_projects_rec.project_id
7010 ,x_manager_person_id => l_project_manager_person_id
7011 ,x_manager_name => l_project_manager_name
7012 ,x_project_party_id => l_project_party_id
7013 ,x_project_role_id => l_project_role_id
7014 ,x_project_role_name => l_project_role_name
7015 ,x_return_status => l_return_status
7016 ,x_error_message_code => l_error_message_code );
7017
7018 -- Only non-admin projects require a manager
7019 IF l_projects_rec.admin_flag = 'N' THEN
7020 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
7021 x_return_status := l_return_status;
7022 x_error_message_code := l_error_message_code;
7023 pa_utils.add_message (p_app_short_name => 'PA',
7024 p_msg_name => l_error_message_code);
7025 END IF;
7026 END IF;
7027
7028 ----------------------------------------
7029 --Start processing the approval result
7030 ----------------------------------------
7031
7032 FOR i IN 1..p_assignment_id_tbl.COUNT LOOP
7033
7034 l_approval_status := p_approval_status_tbl(i);
7035
7036 IF l_approval_status = PA_ASSIGNMENT_APPROVAL_PUB.g_approve_action THEN
7037
7038 l_action_code := PA_ASSIGNMENT_APPROVAL_PUB.g_approve_action;
7039 --l_num_apr_asgns := l_num_apr_asgns + 1;
7040
7041 ELSIF l_approval_status = PA_ASSIGNMENT_APPROVAL_PUB.g_reject_action THEN
7042
7043 l_action_code := PA_ASSIGNMENT_APPROVAL_PUB.g_reject_action;
7044 --l_num_rej_asgns := l_num_rej_asgns + 1;
7045
7046 END IF;
7047
7048 ----------------------------------------------------------------------
7049 --The API below does the per assignment approval result processing tasks
7050 ----------------------------------------------------------------------
7051 log_message('Check if there are any pending approvals for assignment:' ||p_assignment_id_tbl(i) );
7052 log_message('Routing order:' || p_routing_order);
7053
7054 process_assignment_tasks (
7055 p_assignment_id => p_assignment_id_tbl(i)
7056 ,p_approval_status => l_approval_status
7057 ,p_action_code => l_action_code
7058 ,p_conflict_group_id => p_conflict_group_id
7059 ,p_project_id => p_project_id
7060 ,p_mode => p_mode
7061 ,p_project_name => l_projects_rec.name
7062 ,p_project_number => l_projects_rec.segment1
7063 ,p_project_manager => l_project_manager_name
7064 ,p_project_org => l_projects_rec.organization_name
7065 ,p_project_cus => l_customer_name
7066 ,p_submitter_user_name => p_submitter_user_name
7067 ,p_group_id => p_group_id
7068 ,p_routing_order => p_routing_order
7069 );
7070
7071 END LOOP; --end i loop
7072
7073 ---------------------------------------------------
7074 --For each distinct approvers in next routing order
7075 --start approval required notification
7076 ---------------------------------------------------
7077 FOR rec IN distinct_approvers LOOP
7078
7079 SELECT PA_WF_NTF_PERFORMERS_S.nextval
7080 INTO l_approver_group_id
7081 FROM dual;
7082
7083 /* Commented and altered as below for bug 5595003
7084 UPDATE pa_wf_ntf_performers
7085 SET approver_group_id = l_approver_group_id
7086 WHERE group_id = p_group_id
7087 AND user_name = rec.user_name
7088 AND routing_order = p_routing_order + 1; */
7089
7090 FORALL k in p_assignment_id_tbl.first..p_assignment_id_tbl.last
7091 UPDATE pa_wf_ntf_performers
7092 SET approver_group_id = l_approver_group_id
7093 WHERE group_id = p_group_id
7094 AND user_name = rec.user_name
7095 AND routing_order = p_routing_order + 1
7096 AND object_id1 = p_assignment_id_tbl(k)
7097 AND p_approval_status_tbl(k) = PA_ASSIGNMENT_APPROVAL_PUB.g_approve_action;
7098
7099 log_message('New approver group id:' || l_approver_group_id);
7100
7101 ----------------------------------------------------------
7102 --Call API to start one workflow for each grouped approver
7103 ----------------------------------------------------------
7104 log_message('Before Calling start_mass_approval_flow for approver :' || rec.user_name);
7105
7106 start_mass_approval_flow
7107 (p_project_id => p_project_id
7108 ,p_mode => p_mode
7109 ,p_note_to_approvers => p_note_to_approvers
7110 ,p_forwarded_from => p_forwarded_from
7111 ,p_performer_user_name => rec.user_name
7112 ,p_routing_order => p_routing_order + 1
7113 ,p_group_id => p_group_id
7114 ,p_approver_group_id => l_approver_group_id
7115 ,p_project_name => l_projects_rec.name
7116 ,p_project_number => l_projects_rec.segment1
7117 ,p_project_manager => l_project_manager_name
7118 ,p_project_org => l_projects_rec.organization_name
7119 ,p_project_cus => l_customer_name
7120 ,p_conflict_group_id => p_conflict_group_id
7121 ,p_submitter_user_name => p_submitter_user_name
7122 ,x_return_status => l_return_status
7123 ,x_msg_count => l_msg_count
7124 ,x_msg_data => l_msg_data);
7125
7126 log_message('After Calling start_mass_approval_flow for approver :' || rec.user_name);
7127
7128 END LOOP;--end distinct approvers loop
7129
7130 ---------------------------------------------------------------------
7131 -- Call FYI Notifications for Managers if all status have been changed
7132 -- for this mass transaction
7133 -- And call schedule APIs to resolve overcommitment conflict.
7134 ---------------------------------------------------------------------
7135 log_message('Checking pending txn approvals');
7136
7137 OPEN pending_txn_approvals;
7138 FETCH pending_txn_approvals INTO l_pending_txn_approvals;
7139
7140 IF pending_txn_approvals%NOTFOUND THEN
7141
7142 BEGIN
7143
7144 --Get all assignments in this mass transaction
7145 SELECT ntf.object_id1
7146 BULK COLLECT INTO l_assignment_id_tbl
7147 FROM pa_wf_ntf_performers ntf
7148 WHERE ntf.group_id = p_group_id
7149 AND ntf.routing_order = 1;
7150 EXCEPTION
7151 WHEN NO_DATA_FOUND THEN
7152 null;
7153 END;
7154
7155 --Reset the number of approved and rejected assignments
7156 l_num_apr_asgns := 0;
7157 l_num_rej_asgns := 0;
7158
7159 FOR i IN 1..l_assignment_id_tbl.COUNT LOOP
7160
7161 l_approval_status := null;
7162
7163 BEGIN
7164 SELECT apprvl_status_code
7165 INTO l_approval_status
7166 FROM pa_project_assignments
7167 WHERE assignment_id = l_assignment_id_tbl(i);
7168 EXCEPTION
7169 WHEN NO_DATA_FOUND THEN
7170 null;
7171 END;
7172
7173 IF l_approval_status = PA_ASSIGNMENT_APPROVAL_PUB.g_approved THEN
7174
7175 l_num_apr_asgns := l_num_apr_asgns + 1;
7176
7177 ELSIF l_approval_status = PA_ASSIGNMENT_APPROVAL_PUB.g_rejected THEN
7178
7179 l_num_rej_asgns := l_num_rej_asgns + 1;
7180
7181 END IF;
7182 END LOOP;
7183
7184 log_message('Calling mgr fyi notification');
7185
7186 process_mgr_fyi_notification
7187 ( p_assignment_id_tbl => l_assignment_id_tbl
7188 ,p_project_id => p_project_id
7189 ,p_mode => p_mode
7190 ,p_group_id => p_group_id
7191 ,p_update_info_doc => l_update_info_doc
7192 ,p_num_apr_asgns => l_num_apr_asgns
7193 ,p_num_rej_asgns => l_num_rej_asgns
7194 ,p_project_name => l_projects_rec.name
7195 ,p_project_number => l_projects_rec.segment1
7196 ,p_project_manager => l_project_manager_name
7197 ,p_project_org => l_projects_rec.organization_name
7198 ,p_project_cus => l_customer_name
7199 ,p_submitter_user_name => p_submitter_user_name
7200 ,p_conflict_group_id => p_conflict_group_id
7201 ,x_return_status => l_return_status
7202 ,x_msg_count => l_msg_count
7203 ,x_msg_data => l_msg_data);
7204
7205 log_message('Calling overcom_post_aprvl_processing');
7206
7207 ------------------------------------------------------------------
7208 --This API is called to send notifications to conflicting managers
7209 ------------------------------------------------------------------
7210 PA_SCHEDULE_PVT.overcom_post_aprvl_processing
7211 ( p_conflict_group_id => p_conflict_group_id
7212 ,p_fnd_user_name => p_submitter_user_name
7213 ,x_return_status => l_return_status
7214 ,x_msg_count => l_msg_count
7215 ,x_msg_data => l_msg_data);
7216
7217 BEGIN
7218 SELECT user_id
7219 INTO l_submitter_user_id
7220 FROM fnd_user
7221 WHERE user_name = p_submitter_user_name;
7222 EXCEPTION
7223 WHEN NO_DATA_FOUND THEN
7224 null;
7225 END;
7226 ------------------------------------------------
7227 --This API processes the submitter notifcations
7228 ------------------------------------------------
7229
7230 OPEN sub_not_required_csr;
7231 FETCH sub_not_required_csr INTO l_sub_not_required_rec;
7232
7233 IF sub_not_required_csr%FOUND THEN
7234
7235 log_message('Calling submitter notification');
7236
7237 process_submitter_notification
7238 (p_project_id => p_project_id
7239 ,p_mode => p_mode
7240 ,p_group_id => p_group_id
7241 ,p_update_info_doc => l_update_info_doc
7242 ,p_num_apr_asgns => l_num_apr_asgns
7243 ,p_num_rej_asgns => l_num_rej_asgns
7244 ,p_project_name => l_projects_rec.name
7245 ,p_project_number => l_projects_rec.segment1
7246 ,p_project_manager => l_project_manager_name
7247 ,p_project_org => l_projects_rec.organization_name
7248 ,p_project_cus => l_customer_name
7249 ,p_submitter_user_name => p_submitter_user_name
7250 ,x_return_status => l_return_status
7251 ,x_msg_count => l_msg_count
7252 ,x_msg_data => l_msg_data);
7253
7254 END IF;
7255 CLOSE sub_not_required_csr;
7256
7257 END IF; --end call to fyi notifications
7258 CLOSE pending_txn_approvals;
7259
7260 log_message('After call to mgr fyi');
7261
7262 EXCEPTION
7263 WHEN OTHERS THEN
7264 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7265 RAISE;
7266 END process_approval_result;
7267
7268 -----------------------------------------------------------
7269 --This API processes the notification sent to the submitter
7270 --if there are errors in the end of the mass transaction
7271 --approval process
7272 --This API raises a NO_ASSIGNMENT_ERRORS EXCEPTION
7273 --when there are no errors and in that case notification
7274 --is not sent to the submitter
7275 -----------------------------------------------------------
7276 PROCEDURE process_submitter_notification
7277 ( p_project_id IN NUMBER := FND_API.G_MISS_NUM
7278 ,p_mode IN VARCHAR2
7279 ,p_group_id IN NUMBER := FND_API.G_MISS_NUM
7280 ,p_update_info_doc IN VARCHAR2 := FND_API.G_MISS_CHAR
7281 ,p_num_apr_asgns IN NUMBER
7282 ,p_num_rej_asgns IN NUMBER
7283 ,p_project_name IN VARCHAR2
7284 ,p_project_number IN VARCHAR2
7285 ,p_project_manager IN VARCHAR2
7286 ,p_project_org IN VARCHAR2
7287 ,p_project_cus IN VARCHAR2
7288 ,p_submitter_user_name IN VARCHAR2
7289 ,p_assignment_id IN NUMBER := FND_API.G_MISS_NUM
7290 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
7291 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
7292 ,x_msg_data OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
7293 IS
7294
7295 l_itemkey VARCHAR2(30);
7296 l_responsibility_id NUMBER;
7297 l_resp_appl_id NUMBER;
7298 l_wf_started_date DATE;
7299 l_wf_started_by_id NUMBER;
7300 l_return_status VARCHAR2(1);
7301 l_error_message_code VARCHAR2(30);
7302 x_error_message_code VARCHAR2(30);
7303 l_save_threshold NUMBER;
7304 l_msg_count NUMBER ;
7305 l_msg_index_out NUMBER ;
7306 l_msg_data VARCHAR2(2000);
7307 l_wf_item_type VARCHAR2(2000):= 'PARMAAP'; --Assignment Approval Item type
7308 l_wf_process VARCHAR2(2000);
7309 l_err_code NUMBER := 0;
7310 l_err_stage VARCHAR2(2000);
7311 l_err_stack VARCHAR2(2000);
7312 l_assignment_id NUMBER;
7313 l_error_asgns_count NUMBER := 0;
7314 l_view_errors_url VARCHAR2(2000);
7315
7316 CURSOR l_assignments_csr (l_assignment_id IN NUMBER ) IS
7317 SELECT
7318 ppa.project_id,
7319 ppa.assignment_name,
7320 ppa.assignment_effort,
7321 ppa.additional_information,
7322 ppa.description,
7323 ppa.start_date,
7324 ppa.end_date,
7325 ppa.revenue_bill_rate,
7326 ppa.revenue_currency_code,
7327 ppa.bill_rate_override,
7328 ppa.bill_rate_curr_override,
7329 ppa.markup_percent_override,
7330 ppa.fcst_tp_amount_type_name,
7331 ppa.tp_rate_override,
7332 ppa.tp_currency_override,
7333 ppa.tp_calc_base_code_override,
7334 ppa.tp_percent_applied_override,
7335 ppa.work_type_name,
7336 hr.name
7337 FROM pa_project_assignments_v ppa,
7338 pa_resources_denorm res,
7339 hr_all_organization_units hr
7340 WHERE assignment_id = l_assignment_id
7341 AND res.resource_id = ppa.resource_id
7342 AND ppa.start_date BETWEEN res.resource_effective_start_date
7343 AND res.resource_effective_end_date
7344 AND hr.organization_id = res.resource_organization_id;
7345
7346 l_assignments_rec l_assignments_csr%ROWTYPE;
7347
7348 CURSOR csr_get_override_basis_name (p_override_basis_code IN VARCHAR2) IS
7349 SELECT plks.meaning
7350 FROM pa_lookups plks
7351 WHERE plks.lookup_type = 'CC_MARKUP_BASE_CODE'
7352 AND plks.lookup_code = p_override_basis_code;
7353
7354 CURSOR count_error_asgns IS
7355 SELECT count( distinct ( attribute2))
7356 FROM PA_REPORTING_EXCEPTIONS
7357 WHERE context = PA_MASS_ASGMT_TRX.G_SOURCE_TYPE1
7358 AND sub_context = 'MASS_APPROVAL'
7359 AND source_identifier1 = 'PAWFAAP'
7360 AND source_identifier2 = p_group_id;
7361
7362 NO_ASSIGNMENT_ERRORS EXCEPTION;
7363
7364 l_override_basis_name VARCHAR2(80) := NULL;
7365 l_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N'); -- 5345171
7366
7367
7368 BEGIN
7369
7370 -- Initialize the Error Stack
7371 PA_DEBUG.init_err_stack('PA_ASGMT_WFSTD.process_submitter_notification');
7372
7373 --Log Message
7374 IF l_debug_mode = 'Y' THEN -- 5345171
7375 PA_DEBUG.write_log
7376 ( x_module => 'pa.plsql.PA_ASGMT_WFSTD.process_submitter_notification.begin'
7377 ,x_msg => 'Beginning of mass fyi workflow api'
7378 ,x_log_level => 1);
7379 END IF;
7380
7381 -- Initialize the return status to success
7382 x_return_status := FND_API.G_RET_STS_SUCCESS;
7383
7384 --Clear the global PL/SQL message table
7385 FND_MSG_PUB.initialize;
7386 x_msg_count := 0;
7387
7388 log_message('Inside submitter notification');
7389
7390 --Setting local variables
7391 OPEN count_error_asgns;
7392 FETCH count_error_asgns INTO l_error_asgns_count;
7393 CLOSE count_error_asgns;
7394
7395 log_message('Error messages:' || l_error_asgns_count);
7396
7397 -----------------------------------------------------------
7398 --If there are no errors this notiifcation must not be sent
7399 -----------------------------------------------------------
7400 IF l_error_asgns_count = 0 THEN
7401 RAISE NO_ASSIGNMENT_ERRORS;
7402 END IF;
7403 --------------------------------------
7404 --Start Submitter Notification workflow
7405 --------------------------------------
7406 l_wf_started_by_id := FND_GLOBAL.user_id;
7407 l_responsibility_id := FND_GLOBAL.resp_id;
7408 l_resp_appl_id := FND_GLOBAL.resp_appl_id;
7409
7410 FND_GLOBAL.Apps_Initialize ( user_id => l_wf_started_by_id
7411 , resp_id => l_responsibility_id
7412 , resp_appl_id => l_resp_appl_id );
7413
7414 -- Setting thresold value to run the process in background
7415 l_save_threshold := wf_engine.threshold;
7416 wf_engine.threshold := -1;
7417
7418 ----------------------------------------------------------------
7419 --Getting all local variables required for workflow attributes
7420 ---------------------------------------------------------------
7421
7422 -- Create the unique item key to launch WF with
7423 SELECT pa_prm_wf_item_key_s.nextval
7424 INTO l_itemkey
7425 FROM dual;
7426
7427 log_message('The value of p_mode is:' || p_mode );
7428 log_message('The value of item_key is :' || l_itemkey );
7429 -----------------------------------------------------------------------------
7430 --Setting Process Creation / Update / Aproval submission mode
7431 -----------------------------------------------------------------------------
7432 IF p_mode = PA_MASS_ASGMT_TRX.G_MASS_ASGMT THEN
7433
7434 l_wf_process := 'PA_MASS_APRVL_SUB_CRN';
7435
7436 ELSIF (p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_ASGMT_BASIC_INFO OR
7437 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_COMPETENCIES OR
7438 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_FORECAST_ITEMS OR
7439 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_SCHEDULE )
7440 THEN
7441
7442 l_wf_process := 'PA_MASS_APRVL_SUB_UPD';
7443
7444 ELSIF p_mode = PA_MASS_ASGMT_TRX.G_MASS_SUBMIT_FOR_APPROVAL THEN
7445
7446 l_wf_process := 'PA_MASS_APRVL_SUB_APS';
7447
7448 END IF;
7449
7450 -- Create the WF process
7451 wf_engine.CreateProcess
7452 ( ItemType => l_wf_item_type
7453 , ItemKey => l_itemkey
7454 , process => l_wf_process );
7455
7456 log_message('After creating process');
7457
7458 ------------------------------------------------------------
7459 --Set the item attributes required for submitter notification
7460 --based on the mode
7461 ------------------------------------------------------------
7462 IF p_mode = PA_MASS_ASGMT_TRX.G_MASS_ASGMT THEN
7463
7464 BEGIN
7465 SELECT object_id1
7466 INTO l_assignment_id
7467 FROM pa_wf_ntf_performers
7468 WHERE group_id = p_group_id
7469 AND rownum = 1;
7470 EXCEPTION
7471 WHEN NO_DATA_FOUND THEN
7472 l_assignment_id := p_assignment_id;
7473 WHEN OTHERS THEN
7474 null;
7475 END;
7476
7477 OPEN l_assignments_csr (l_assignment_id);
7478 FETCH l_assignments_csr INTO l_assignments_rec;
7479
7480 IF l_assignments_csr%NOTFOUND THEN
7481 x_return_status := FND_API.G_RET_STS_ERROR;
7482 pa_utils.add_message (p_app_short_name => 'PA',
7483 p_msg_name => 'PA_INVALID_ASMGT_ID');
7484 END IF;
7485
7486 CLOSE l_assignments_csr;
7487
7488 wf_engine.SetItemAttrText
7489 ( itemtype => l_wf_item_type
7490 , itemkey => l_itemkey
7491 , aname => 'ASSIGNMENT_NAME'
7492 , avalue => l_assignments_rec.assignment_name );
7493
7494 wf_engine.SetItemAttrText
7495 ( itemtype => l_wf_item_type
7496 , itemkey => l_itemkey
7497 , aname => 'RESOURCE_ORGANIZATION'
7498 , avalue => l_assignments_rec.name );
7499
7500 wf_engine.SetItemAttrNumber
7501 ( itemtype => l_wf_item_type
7502 , itemkey => l_itemkey
7503 , aname => 'ASSIGNMENT_DURATION'
7504 , avalue => (trunc(l_assignments_rec.end_date) -
7505 trunc(l_assignments_rec.start_date)+1) );
7506
7507 wf_engine.SetItemAttrNumber
7508 ( itemtype => l_wf_item_type
7509 , itemkey => l_itemkey
7510 , aname => 'ASSIGNMENT_EFFORT'
7511 , avalue => l_assignments_rec.assignment_effort );
7512
7513 wf_engine.SetItemAttrText
7514 ( itemtype => l_wf_item_type
7515 , itemkey => l_itemkey
7516 , aname => 'DESCRIPTION'
7517 , avalue => l_assignments_rec.description );
7518
7519 wf_engine.SetItemAttrText
7520 ( itemtype => l_wf_item_type
7521 , itemkey => l_itemkey
7522 , aname => 'ADDITIONAL_INFORMATION'
7523 , avalue => l_assignments_rec.additional_information );
7524
7525 -- Start Additions by RM for bug 2274426
7526 wf_engine.SetItemAttrNumber
7527 ( itemtype => l_wf_item_type
7528 , itemkey => l_itemkey
7529 , aname => 'REVENUE_BILL_RATE'
7530 , avalue => l_assignments_rec.revenue_bill_rate
7531 );
7532 wf_engine.SetItemAttrText
7533 ( itemtype => l_wf_item_type
7534 , itemkey => l_itemkey
7535 , aname => 'REVENUE_BILL_RATE_CURR'
7536 , avalue => l_assignments_rec.revenue_currency_code
7537 );
7538 wf_engine.SetItemAttrNumber
7539 ( itemtype => l_wf_item_type
7540 , itemkey => l_itemkey
7541 , aname => 'BILL_RATE_OVERRIDE'
7542 , avalue => l_assignments_rec.bill_rate_override
7543 );
7544 wf_engine.SetItemAttrText
7545 ( itemtype => l_wf_item_type
7546 , itemkey => l_itemkey
7547 , aname => 'BILL_RATE_OVERRIDE_CURR'
7548 , avalue => l_assignments_rec.bill_rate_curr_override
7549 );
7550 IF l_assignments_rec.markup_percent_override IS NOT NULL THEN
7551 wf_engine.SetItemAttrText
7552 ( itemtype => l_wf_item_type
7553 , itemkey => l_itemkey
7554 , aname => 'MARKUP_PCT_OVERRIDE'
7555 , avalue => to_char(l_assignments_rec.markup_percent_override)||'%'
7556 );
7557 ELSE
7558 wf_engine.SetItemAttrText
7559 ( itemtype => l_wf_item_type
7560 , itemkey => l_itemkey
7561 , aname => 'MARKUP_PCT_OVERRIDE'
7562 , avalue => to_char(l_assignments_rec.markup_percent_override)
7563 );
7564 END IF;
7565 wf_engine.SetItemAttrText
7566 ( itemtype => l_wf_item_type
7567 , itemkey => l_itemkey
7568 , aname => 'TP_AMT_TYPE_NAME'
7569 , avalue => l_assignments_rec.fcst_tp_amount_type_name
7570 );
7571 wf_engine.SetItemAttrNumber
7572 ( itemtype => l_wf_item_type
7573 , itemkey => l_itemkey
7574 , aname => 'TP_RATE_OVERRIDE'
7575 , avalue => l_assignments_rec.tp_rate_override
7576 );
7577 wf_engine.SetItemAttrText
7578 ( itemtype => l_wf_item_type
7579 , itemkey => l_itemkey
7580 , aname => 'TP_RATE_OVERRIDE_CURR'
7581 , avalue => l_assignments_rec.tp_currency_override
7582 );
7583 IF l_assignments_rec.tp_calc_base_code_override IS NOT NULL THEN
7584 open csr_get_override_basis_name(l_assignments_rec.tp_calc_base_code_override);
7585 fetch csr_get_override_basis_name into l_override_basis_name;
7586 close csr_get_override_basis_name;
7587 END IF;
7588 wf_engine.SetItemAttrText
7589 ( itemtype => l_wf_item_type
7590 , itemkey => l_itemkey
7591 , aname => 'OVERRIDE_BASIS_NAME'
7592 , avalue => l_override_basis_name
7593 );
7594 IF l_assignments_rec.tp_percent_applied_override IS NOT NULL THEN
7595 IF l_override_basis_name IS NOT NULL THEN
7596 wf_engine.SetItemAttrText
7597 ( itemtype => l_wf_item_type
7598 , itemkey => l_itemkey
7599 , aname => 'TP_PCT_APPLIED_OVERRIDE'
7600 , avalue => ', '||to_char(l_assignments_rec.tp_percent_applied_override)||'%'
7601 );
7602 ELSE
7603 wf_engine.SetItemAttrText
7604 ( itemtype => l_wf_item_type
7605 , itemkey => l_itemkey
7606 , aname => 'TP_PCT_APPLIED_OVERRIDE'
7607 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)||'%'
7608 );
7609 END IF;
7610 ELSE
7611 wf_engine.SetItemAttrText
7612 ( itemtype => l_wf_item_type
7613 , itemkey => l_itemkey
7614 , aname => 'TP_PCT_APPLIED_OVERRIDE'
7615 , avalue => to_char(l_assignments_rec.tp_percent_applied_override)
7616 );
7617 END IF;
7618 wf_engine.SetItemAttrText
7619 ( itemtype => l_wf_item_type
7620 , itemkey => l_itemkey
7621 , aname => 'WORK_TYPE_NAME'
7622 , avalue => l_assignments_rec.work_type_name
7623 );
7624 -- End of Additions by RM
7625
7626 --Setting Successful assignments count
7627 wf_engine.SetItemAttrNumber
7628 ( itemtype => l_wf_item_type
7629 , itemkey => l_itemkey
7630 , aname => 'APPROVED_ASSIGNMENTS'
7631 , avalue => p_num_apr_asgns + p_num_rej_asgns);
7632
7633 ELSIF (p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_ASGMT_BASIC_INFO OR
7634 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_COMPETENCIES OR
7635 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_FORECAST_ITEMS OR
7636 p_mode = PA_MASS_ASGMT_TRX.G_MASS_UPDATE_SCHEDULE )
7637
7638 THEN
7639 wf_engine.SetItemAttrDocument
7640 ( itemtype => l_wf_item_type
7641 , itemkey => l_itemkey
7642 , aname => 'UPDATED_INFO_DOC'
7643 , documentid => p_update_info_doc );
7644
7645 --Setting Successful assignments count
7646 wf_engine.SetItemAttrNumber
7647 ( itemtype => l_wf_item_type
7648 , itemkey => l_itemkey
7649 , aname => 'APPROVED_ASSIGNMENTS'
7650 , avalue => p_num_apr_asgns + p_num_rej_asgns);
7651
7652 END IF;
7653
7654 ---------------------------------------------------------------------
7655 --Setting Common Assignment attributes for CRN / UPD / APS
7656 --------------------------------------------------------------------
7657
7658 log_message('Setting common attributes');
7659
7660 --Setting total assignments count
7661 wf_engine.SetItemAttrNumber
7662 ( itemtype => l_wf_item_type
7663 , itemkey => l_itemkey
7664 , aname => 'NUMBER_OF_ASSIGNMENTS'
7665 , avalue => p_num_apr_asgns + p_num_rej_asgns + l_error_asgns_count);
7666
7667 --Setting failed assignments count
7668 wf_engine.SetItemAttrNumber
7669 ( itemtype => l_wf_item_type
7670 , itemkey => l_itemkey
7671 , aname => 'REJECTED_ASSIGNMENTS'
7672 , avalue => l_error_asgns_count);
7673
7674 --Setting Project attributes
7675 wf_engine.SetItemAttrText
7676 ( itemtype => l_wf_item_type
7677 , itemkey => l_itemkey
7678 , aname => 'PROJECT_NAME'
7679 , avalue => p_project_name );
7680
7681 wf_engine.SetItemAttrText
7682 ( itemtype => l_wf_item_type
7683 , itemkey => l_itemkey
7684 , aname => 'PROJECT_NUMBER'
7685 , avalue => p_project_number );
7686
7687 wf_engine.SetItemAttrText
7688 ( itemtype => l_wf_item_type
7689 , itemkey => l_itemkey
7690 , aname => 'PROJECT_MANAGER_NAME'
7691 , avalue => p_project_manager );
7692
7693 wf_engine.SetItemAttrText
7694 ( itemtype => l_wf_item_type
7695 , itemkey => l_itemkey
7696 , aname => 'PROJECT_ORGANIZATION'
7697 , avalue => p_project_org );
7698
7699 wf_engine.SetItemAttrText
7700 ( itemtype => l_wf_item_type
7701 , itemkey => l_itemkey
7702 , aname => 'PROJECT_CUSTOMER'
7703 , avalue => p_project_cus );
7704
7705 wf_engine.SetItemAttrText
7706 ( itemtype => l_wf_item_type
7707 , itemkey => l_itemkey
7708 , aname => 'SUBMITTER_UNAME'
7709 , avalue => p_submitter_user_name);
7710
7711 l_view_errors_url := 'JSP:/OA_HTML/OA.jsp?akRegionCode=PA_ERROR_LAYOUT&akRegionApplicationId=275&paProjectId='
7712 || p_project_id ||'&paSrcType1=MASS_ASSIGNMENT_TRANSACTION&paSrcType2=MASS_APPROVAL&paSrcId1=PAWFAAP&paSrcId2='
7713 || p_group_id || '&addBreadCrumb=RP' ;
7714
7715 wf_engine.SetItemAttrText
7716 ( itemtype => l_wf_item_type
7717 , itemkey => l_itemkey
7718 , aname => 'VIEW_ERRORS_URL'
7719 , avalue => l_view_errors_url );
7720
7721 log_message('Staring process for :' || l_wf_item_type || ':' || l_itemkey);
7722
7723 --Start the workflow process
7724 wf_engine.StartProcess ( itemtype => l_wf_item_type
7725 ,itemkey => l_itemkey );
7726
7727 PA_WORKFLOW_UTILS.Insert_WF_Processes
7728 (p_wf_type_code => 'MASS_ASSIGNMENT_APPROVAL'
7729 ,p_item_type => l_wf_item_type
7730 ,p_item_key => l_itemkey
7731 ,p_entity_key1 => to_char(p_project_id)
7732 ,p_entity_key2 => to_char(p_group_id)
7733 ,p_description => NULL
7734 ,p_err_code => l_err_code
7735 ,p_err_stage => l_err_stage
7736 ,p_err_stack => l_err_stack );
7737
7738 log_message('Out of submitter notification');
7739
7740
7741 --Setting the original value
7742 wf_engine.threshold := l_save_threshold;
7743
7744 -- IF the number of messages is 1 then fetch the message code from
7745 -- the stack and return its text
7746 x_msg_count := FND_MSG_PUB.Count_Msg;
7747
7748 IF x_msg_count = 1 THEN
7749 pa_interface_utils_pub.get_messages
7750 ( p_encoded => FND_API.G_TRUE
7751 ,p_msg_index => 1
7752 ,p_data => x_msg_data
7753 ,p_msg_index_out => l_msg_index_out );
7754 END IF;
7755
7756 -- Reset the error stack when returning to the calling program
7757 PA_DEBUG.Reset_Err_Stack;
7758
7759 -- If g_error_exists is TRUE then set the x_return_status to 'E'
7760 IF FND_MSG_PUB.Count_Msg >0 THEN
7761 x_return_status := FND_API.G_RET_STS_ERROR;
7762 END IF;
7763
7764 EXCEPTION
7765 WHEN NO_ASSIGNMENT_ERRORS THEN
7766 x_return_status := FND_API.G_RET_STS_SUCCESS;
7767 WHEN OTHERS THEN
7768
7769 --Setting the original value
7770 wf_engine.threshold := l_save_threshold;
7771
7772 -- Set the excetption Message and the stack
7773 FND_MSG_PUB.add_exc_msg
7774 ( p_pkg_name => 'PA_ASGMT_WFSTD.process_submitter_notification'
7775 ,p_procedure_name => PA_DEBUG.G_Err_Stack );
7776
7777 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
7778 RAISE;
7779 END process_submitter_notification;
7780
7781 ---------------------------------------------------------
7782 --This API is called from Assignment Approval workflow
7783 --This determines if approval is for a single
7784 --transaction or a mass transaction
7785 ---------------------------------------------------------
7786 PROCEDURE Check_Approval_Type
7787 ( itemtype IN VARCHAR2
7788 ,itemkey IN VARCHAR2
7789 ,actid IN NUMBER
7790 ,funcmode IN VARCHAR2
7791 ,resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
7792 IS
7793
7794 l_approval_type VARCHAR2(10);
7795
7796 BEGIN
7797
7798 pa_debug.init_err_stack ('pa_asgmt_wfstd.Check_approval_type');
7799
7800 -- Return if WF Not Running
7801 IF (funcmode <> wf_engine.eng_run) THEN
7802 resultout := wf_engine.eng_null;
7803 RETURN;
7804 END IF;
7805
7806 l_approval_type := wf_engine.GetItemAttrText
7807 (itemtype => itemtype,
7808 itemkey => itemkey,
7809 aname => 'APPROVAL_TYPE');
7810
7811 IF l_approval_type = PA_ASGMT_WFSTD.G_MASS_APPROVAL THEN
7812
7813 resultout := wf_engine.eng_completed||':'||'M';
7814
7815 ELSIF l_approval_type = PA_ASGMT_WFSTD.G_SINGLE_APPROVAL THEN
7816
7817 resultout := wf_engine.eng_completed||':'||'S';
7818
7819 END IF;
7820
7821 pa_debug.reset_err_stack;
7822
7823 EXCEPTION
7824 WHEN OTHERS THEN
7825 WF_CORE.CONTEXT
7826 ('PA_ASGMT_WFSTD',
7827 'Check_approval_type',
7828 itemtype,
7829 itemkey,
7830 to_char(actid),
7831 funcmode);
7832 resultout := wf_engine.eng_completed||':'||'S';
7833 RAISE;
7834
7835 END Check_Approval_Type ;
7836
7837 -------------------------------------------------------------
7838 --This is a post notification function being called when user
7839 --either responds to notification by closing the notification
7840 --or when notification times out
7841 --This is called from approval required mass notification
7842 -------------------------------------------------------------
7843 PROCEDURE Check_Notification_Completed
7844 ( itemtype IN VARCHAR2
7845 ,itemkey IN VARCHAR2
7846 ,actid IN NUMBER
7847 ,funcmode IN VARCHAR2
7848 ,resultout OUT NOCOPY VARCHAR2 ) --File.Sql.39 bug 4440895
7849 IS
7850
7851 l_project_id pa_project_assignments.project_id%TYPE;
7852 l_mode VARCHAR2(30);
7853 l_assignment_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
7854 l_approval_status_tbl SYSTEM.pa_varchar2_30_tbl_type:= SYSTEM.pa_varchar2_30_tbl_type();
7855 l_group_id NUMBER;
7856 l_approver_group_id NUMBER;
7857 l_routing_order NUMBER;
7858 l_num_assignments NUMBER;
7859 l_conflict_group_id NUMBER;
7860 l_update_info_doc VARCHAR2(2000);
7861 l_submitter_user_name fnd_user.user_name%type; ----- VARCHAR2(30); Commented for bug 3267790
7862 l_note_to_approvers VARCHAR2(2000);
7863 l_forwarded_from fnd_user.user_name%type;--VARCHAR2(30); 5345171
7864 l_ntfy_apprvl_recip_name fnd_user.user_name%TYPE; --skkoppul commented for bug 6744129 VARCHAR2(30); -- added for bug 5488496
7865
7866 CURSOR pending_txn_approvals IS
7867 SELECT 'Y'
7868 FROM pa_wf_ntf_performers ntf,
7869 pa_project_assignments asgn
7870 WHERE ntf.group_id = l_group_id
7871 AND ntf.approver_group_id = l_approver_group_id --uncommented this line for Bug#5662785
7872 AND ntf.routing_order = l_routing_order
7873 AND ntf.user_name = l_ntfy_apprvl_recip_name -- added for bug 5488496
7874 AND ntf.object_id1 = asgn.assignment_id
7875 AND ntf.object_id2 <> 100
7876 AND ( asgn.apprvl_status_code <> PA_ASSIGNMENT_APPROVAL_PUB.g_rejected OR
7877 asgn.apprvl_status_code <> PA_ASSIGNMENT_APPROVAL_PUB.g_approved );
7878
7879 l_pending_txn_approvals pending_txn_approvals%ROWTYPE;
7880
7881 BEGIN
7882
7883 l_group_id := wf_engine.GetItemAttrNumber
7884 (itemtype => itemtype,
7885 itemkey => itemkey,
7886 aname => 'GROUP_ID');
7887
7888 l_approver_group_id := wf_engine.GetItemAttrNumber
7889 (itemtype => itemtype,
7890 itemkey => itemkey,
7891 aname => 'APPROVER_GROUP_ID');
7892
7893 l_routing_order := wf_engine.GetItemAttrNumber
7894 (itemtype => itemtype,
7895 itemkey => itemkey,
7896 aname => 'ROUTING_ORDER');
7897
7898 -- added for bug 5488496
7899 l_ntfy_apprvl_recip_name := wf_engine.getItemAttrText
7900 (itemtype => itemtype,
7901 itemkey => itemkey,
7902 aname => 'NTFY_APPRVL_RECIPIENT_NAME');
7903
7904 IF funcmode = 'RESPOND' THEN
7905
7906 ------------------------------------------------
7907 --Check if approver has handled the notification
7908 --Approver should have either approved/rejected
7909 --the assignments
7910 --In this case we check if assignment status is
7911 --approved/rejected
7912 -----------------------------------------------
7913 OPEN pending_txn_approvals;
7914 FETCH pending_txn_approvals INTO l_pending_txn_approvals;
7915
7916 IF pending_txn_approvals%FOUND THEN
7917
7918 -- resultout := 'ERROR:PA_NO_ACTION_ON_NOTIFCATIONS'; commented for Bug#5650363
7919 -- Added for the below line for Bug#5650363
7920 resultout := 'ERROR:' || substrb(fnd_message.get_string('PA','PA_NO_ACTION_ON_NOTIFCATIONS'),1,114);
7921
7922 CLOSE pending_txn_approvals; -- Added Close statement for BUG#6328067
7923 ELSE
7924 CLOSE pending_txn_approvals; -- Added Close statement for BUG#6328067
7925 END IF;
7926
7927 END IF;--end respond
7928
7929 ---------------------------------------------------------------
7930 --In the case of timeout all the assignments in the notifcation
7931 --have to be rejected. Get all relevant attributes from workflow
7932 --and call process_approval_result API
7933 ----------------------------------------------------------------
7934 IF funcmode = 'TIMEOUT' THEN
7935
7936 SELECT ntf.object_id1
7937 BULK COLLECT INTO l_assignment_id_tbl
7938 FROM pa_wf_ntf_performers ntf,
7939 pa_project_assignments asgn
7940 WHERE ntf.group_id = l_group_id
7941 AND ntf.approver_group_id = l_approver_group_id
7942 AND ntf.routing_order = l_routing_order
7943 AND ntf.object_id1 = asgn.assignment_id
7944 AND asgn.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_submitted;
7945
7946 l_project_id := wf_engine.getItemAttrNumber
7947 ( itemtype => itemtype
7948 , itemkey => itemkey
7949 , aname => 'PROJECT_ID' );
7950
7951 l_mode := wf_engine.getItemAttrText
7952 ( itemtype => itemtype
7953 , itemkey => itemkey
7954 , aname => 'MODE' );
7955
7956 l_num_assignments := l_assignment_id_tbl.COUNT;
7957
7958 --Get the Update Info document
7959 l_update_info_doc := wf_engine.getItemAttrDocument
7960 ( itemtype => itemtype
7961 , itemkey => itemkey
7962 , aname => 'UPDATED_INFO_DOC' );
7963
7964 l_submitter_user_name := wf_engine.getItemAttrText
7965 ( itemtype => itemtype
7966 , itemkey => itemkey
7967 , aname => 'SUBMITTER_UNAME');
7968
7969 l_conflict_group_id := wf_engine.getItemAttrNumber
7970 ( itemtype => itemtype
7971 , itemkey => itemkey
7972 , aname => 'CONFLICT_GROUP_ID' );
7973
7974 l_forwarded_from := wf_engine.getItemAttrText
7975 ( itemtype => itemtype
7976 , itemkey => itemkey
7977 , aname => 'NTFY_APPRVL_RECIPIENT_NAME');
7978
7979 l_note_to_approvers := wf_engine.getItemAttrText
7980 ( itemtype => itemtype
7981 , itemkey => itemkey
7982 , aname => 'NOTE_TO_APPROVER');
7983
7984 FOR i IN 1..l_assignment_id_tbl.COUNT LOOP
7985 l_approval_status_tbl.extend;
7986 l_approval_status_tbl(i) := PA_ASSIGNMENT_APPROVAL_PUB.g_reject_action;
7987 END LOOP;
7988
7989 process_approval_result
7990 ( p_project_id => l_project_id
7991 ,p_mode => l_mode
7992 ,p_assignment_id_tbl => l_assignment_id_tbl
7993 ,p_approval_status_tbl => l_approval_status_tbl
7994 ,p_group_id => l_group_id
7995 ,p_approver_group_id => l_approver_group_id
7996 ,p_routing_order => l_routing_order
7997 ,p_num_of_assignments => l_num_assignments
7998 ,p_submitter_user_name => l_submitter_user_name
7999 ,p_conflict_group_id => l_conflict_group_id
8000 ,p_update_info_doc => l_update_info_doc
8001 ,p_forwarded_from => l_forwarded_from
8002 ,p_note_to_approvers => l_note_to_approvers);
8003
8004 END IF; --end timeout case
8005 -- 4537865 : Included Exception Block
8006 EXCEPTION
8007 WHEN OTHERS THEN
8008 Wf_Core.Context('PA_ASGMT_WFSTD','Check_Notification_Completed',itemtype,itemkey,to_char(actid),funcmode);
8009 RAISE;
8010 END Check_Notification_Completed ;
8011
8012 PROCEDURE Set_Submitter_User_Name
8013 (p_item_type IN VARCHAR2,
8014 p_item_key IN VARCHAR2,
8015 p_actid IN NUMBER,
8016 p_funcmode IN VARCHAR2,
8017 p_result OUT NOCOPY VARCHAR2) --File.Sql.39 bug 4440895
8018 IS
8019
8020 l_error_item_type VARCHAR2(30);
8021 l_error_item_key NUMBER;
8022 l_submitter_user_name VARCHAR2(240);
8023
8024 BEGIN
8025
8026 log_message('Inside Set_Submitter_User_Name');
8027
8028
8029 --get the following wf attributes for the process that errored out.
8030 l_error_item_type := WF_ENGINE.GetItemAttrText(itemtype => p_item_type,
8031 itemkey => p_item_key,
8032 aname => 'ERROR_ITEM_TYPE');
8033
8034 l_error_item_key := WF_ENGINE.GetItemAttrText(itemtype => p_item_type,
8035 itemkey => p_item_key,
8036 aname => 'ERROR_ITEM_KEY');
8037
8038 l_submitter_user_name := WF_ENGINE.GetItemAttrText(itemtype => l_error_item_type,
8039 itemkey => l_error_item_key,
8040 aname => 'SUBMITTER_UNAME');
8041
8042 --SET the Text item attributes (these attributes were created at design time)
8043 WF_ENGINE.SetItemAttrText(itemtype => p_item_type,
8044 itemkey => p_item_key,
8045 aname => 'SUBMITTER_UNAME',
8046 avalue => l_submitter_user_name);
8047
8048 log_message('After Set_Submitter_User_Name');
8049 -- 4537865 : Included Exception Block
8050 EXCEPTION
8051 WHEN OTHERS THEN
8052 Wf_Core.Context('PA_ASGMT_WFSTD','Set_Submitter_User_Name',p_item_type,p_item_key,to_char(p_actid),p_funcmode);
8053 RAISE;
8054 END Set_Submitter_User_Name;
8055
8056 --if there is an unexpected error then the sysadmin can choose to abort or retry
8057 --the unprocessed items. If he chooses to abort then this API is called in
8058 --order to revert the errored assignments to previous status
8059
8060 PROCEDURE Abort_Remaining_Trx
8061 (p_item_type IN VARCHAR2,
8062 p_item_key IN VARCHAR2,
8063 p_actid IN NUMBER,
8064 p_funcmode IN VARCHAR2,
8065 p_result OUT NOCOPY VARCHAR2) --File.Sql.39 bug 4440895
8066
8067 IS
8068
8069 l_error_item_type VARCHAR2(30);
8070 l_submitter_uname fnd_user.user_name%type; ----- VARCHAR2(30); Commented for bug 3267790
8071 l_error_item_key NUMBER;
8072 l_submitter_user_id NUMBER;
8073 l_resource_id pa_resources_denorm.resource_id%TYPE;
8074 l_return_status VARCHAR2(1);
8075 l_group_id NUMBER;
8076 l_project_id NUMBER;
8077 l_assignment_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
8078
8079 BEGIN
8080
8081 log_message('Inside Abort_Remaining_Trx');
8082
8083 --aborting a wf happens when there is an unexpected error and
8084 --the sysadmin chooses to abort the workflow.
8085 --but we commit 1 at a time, so some of the transactions
8086 --may be complete - so we are only aborting the ones that are not yet processed.
8087
8088 --get the following wf attributes for the process that errored out.
8089 l_error_item_type := WF_ENGINE.GetItemAttrText(itemtype => p_item_type,
8090 itemkey => p_item_key,
8091 aname => 'ERROR_ITEM_TYPE');
8092
8093 l_error_item_key := WF_ENGINE.GetItemAttrText(itemtype => p_item_type,
8094 itemkey => p_item_key,
8095 aname => 'ERROR_ITEM_KEY');
8096
8097 l_project_id := WF_ENGINE.GetItemAttrText(itemtype => l_error_item_type,
8098 itemkey => l_error_item_key,
8099 aname => 'PROJECT_ID');
8100
8101 l_submitter_uname := WF_ENGINE.GetItemAttrText(itemtype => l_error_item_type,
8102 itemkey => l_error_item_key,
8103 aname => 'SUBMITTER_UNAME');
8104
8105 l_group_id := WF_ENGINE.GetItemAttrText(itemtype => l_error_item_type,
8106 itemkey => l_error_item_key,
8107 aname => 'GROUP_ID');
8108
8109 SELECT ntf.object_id1
8110 BULK COLLECT INTO l_assignment_id_tbl
8111 FROM pa_wf_ntf_performers ntf,
8112 pa_project_assignments asgn
8113 WHERE ntf.group_id = l_group_id
8114 AND ntf.routing_order = 1
8115 AND ntf.object_id1 = asgn.assignment_id
8116 AND asgn.apprvl_status_code = PA_ASSIGNMENT_APPROVAL_PUB.g_submitted;
8117
8118
8119 --if there are any aborted items then add a message to the stack
8120 --saying that those items were aborted by the sysadmin.
8121 IF l_assignment_id_tbl.COUNT > 0 THEN
8122
8123 FOR i IN l_assignment_id_tbl.FIRST .. l_assignment_id_tbl.LAST LOOP
8124
8125 FND_MSG_PUB.initialize;
8126
8127 PA_UTILS.Add_Message( p_app_short_name => 'PA'
8128 ,p_msg_name => 'PA_PROCESS_ABORTED_SYSADMIN');
8129
8130 SELECT user_id
8131 INTO l_submitter_user_id
8132 FROM fnd_user
8133 WHERE user_name = l_submitter_uname;
8134
8135 SELECT resource_id
8136 INTO l_resource_id
8137 FROM pa_project_assignments
8138 WHERE assignment_id = l_assignment_id_tbl(i);
8139
8140 --Revert assignment status back to previous status before approval
8141 Revert_assignment_status(
8142 p_assignment_id => l_assignment_id_tbl(i)
8143 ,p_group_id => l_group_id
8144 ,x_return_status => l_return_status);
8145
8146 PA_MESSAGE_UTILS.save_messages(p_user_id => l_submitter_user_id,
8147 p_source_type1 => PA_MASS_ASGMT_TRX.G_SOURCE_TYPE1,
8148 p_source_type2 => 'MASS_APPROVAL',
8149 p_source_identifier1 => 'PAWFAAP',
8150 p_source_identifier2 => l_group_id,
8151 p_context1 => l_project_id,
8152 p_context2 => l_assignment_id_tbl(i),
8153 p_context3 => l_resource_id,
8154 p_commit => FND_API.G_FALSE,
8155 x_return_status => l_return_status);
8156
8157 END LOOP;
8158
8159 END IF;
8160 log_message('Abort_Remaining_Trx');
8161
8162 EXCEPTION
8163 WHEN OTHERS THEN
8164 RAISE;
8165
8166 END Abort_Remaining_Trx;
8167
8168 END PA_ASGMT_WFSTD;