[Home] [Help]
PACKAGE BODY: APPS.PJM_TASK_AUTO_ASSIGN
Source
1 PACKAGE BODY pjm_task_auto_assign AS
2 /* $Header: PJMTKASB.pls 120.2 2011/02/16 01:02:03 yaoli ship $ */
3
4 -- ---------------------------------------------------------------------
5 -- Private Functions and Procedures
6 -- ---------------------------------------------------------------------
7
8 --
9 -- Name : Is_Project
10 --
11 -- Function : This boolean function checks whether a given
12 -- project_id references a PA project or a seiban
13 -- number.
14 --
15 -- Returns : TRUE if a PA project, FALSE otherwise
16 --
17 -- Parameters :
18 -- IN : X_project_id NUMBER
19 --
20 FUNCTION is_project (X_project_id IN NUMBER) RETURN BOOLEAN
21 IS
22 CURSOR p IS
23 SELECT 1
24 FROM pa_projects_all
25 WHERE project_id = X_project_id;
26 L_project_flag NUMBER;
27 BEGIN
28 if (X_project_id is null) then
29 return FALSE;
30 end if;
31
32 OPEN p;
33 FETCH p INTO L_project_flag;
34 CLOSE p;
35
36 if (L_project_flag = 1) then
37 return TRUE;
38 else
39 return FALSE;
40 end if;
41
42 EXCEPTION
43 WHEN NO_DATA_FOUND THEN
44 return FALSE;
45 WHEN OTHERS THEN
46 raise;
47
48 END is_project;
49
50
51 --
52 -- Name : Get_Item_Category
53 --
54 -- Function : This function returns the category associated
55 -- with the item in the Inventory functional
56 -- area.
57 --
58 -- Returns : Category_Id
59 --
60 -- Parameters :
61 -- IN : X_org_id NUMBER
62 -- : X_item_id NUMBER
63 --
64 FUNCTION Get_Item_Category ( X_org_id IN NUMBER
65 , X_item_id IN NUMBER )
66 RETURN NUMBER IS
67
68 L_category_id NUMBER;
69
70 CURSOR c ( C_org_id NUMBER
71 , C_item_id NUMBER )
72 IS
73 SELECT mic.category_id
74 FROM mtl_item_categories mic
75 , mtl_default_category_sets mdcs
76 WHERE mdcs.functional_area_id = 1
77 AND mic.category_set_id = mdcs.category_set_id
78 AND mic.inventory_item_id = C_item_id
79 AND mic.organization_id = C_org_id;
80
81 BEGIN
82 if ( X_item_id is not null ) then
83 open c ( X_org_id, X_item_id);
84 fetch c into L_category_id;
85 close c;
86 else
87 L_Category_id := NULL;
88 end if;
89 return ( L_Category_id );
90
91 EXCEPTION
92 WHEN OTHERS THEN
93 raise;
94
95 END Get_Item_Category;
96
97
98 --
99 -- Name : Flag_INV_Error
100 --
101 -- Function : This procedure marks the transaction as Cost
102 -- Collection failed and populates the appropriate
103 -- error columns in MTL_MATERIAL_TRANSACTIONS
104 --
105 -- Parameters :
106 -- IN : X_transaction_id NUMBER
107 --
108 -- IN OUT : X_error_num NUMBER
109 -- : X_error_code VARCHAR2
110 -- : X_error_msg VARCHAR2
111 --
112 PROCEDURE flag_inv_error
113 ( X_transaction_id IN NUMBER
114 , X_error_num IN OUT NOCOPY NUMBER
115 , X_error_code IN VARCHAR2
116 , X_error_msg IN OUT NOCOPY VARCHAR2)
117 IS
118 L_stmt_num NUMBER;
119 BEGIN
120
121 L_stmt_num := 10;
122
123 UPDATE mtl_material_transactions
124 SET error_code = X_error_code
125 , error_explanation = X_error_msg
126 , pm_cost_collected = 'E'
127 , last_update_date = sysdate
128 , last_updated_by = fnd_global.user_id
129 , request_id = fnd_global.conc_request_id
130 , program_application_id = fnd_global.prog_appl_id
131 , program_id = fnd_global.conc_program_id
132 , program_update_date = sysdate
133 WHERE transaction_id = X_transaction_id;
134
135 EXCEPTION
136 WHEN OTHERS THEN
137 X_error_num := sqlcode;
138 X_error_msg := 'TKAA-INVE(' || L_stmt_num || ')->' || sqlerrm;
139
140 END flag_inv_error;
141
142 --
143 -- Name : Flag_WIP_Error
144 --
145 -- Function : This procedure marks the transaction as Cost
146 -- Collection failed and creates the appropriate
147 -- entry in the WIP transaction error table
148 --
149 -- Parameters :
150 -- IN : X_transaction_id NUMBER
151 --
152 -- IN OUT : X_error_num NUMBER
153 -- : X_error_msg VARCHAR2
154 --
155 PROCEDURE flag_wip_error
156 ( X_transaction_id IN NUMBER
157 , X_error_num IN OUT NOCOPY NUMBER
158 , X_error_msg IN OUT NOCOPY VARCHAR2)
159 IS
160 L_user_id NUMBER;
161 L_request_id NUMBER;
162 L_prog_appl_id NUMBER;
163 L_prog_id NUMBER;
164 L_login_id NUMBER;
165 L_stmt_num NUMBER;
166 BEGIN
167
168 L_user_id := fnd_global.user_id;
169 L_login_id := fnd_global.conc_login_id;
170 L_request_id := fnd_global.conc_request_id;
171 L_prog_appl_id := fnd_global.prog_appl_id;
172 L_prog_id := fnd_global.conc_program_id;
173
174 L_stmt_num := 10;
175
176 UPDATE wip_transactions
177 SET pm_cost_collected = 'E'
178 , last_update_date = sysdate
179 , last_updated_by = L_user_id
180 , request_id = L_request_id
181 , program_application_id = L_prog_appl_id
182 , program_id = L_prog_id
183 , program_update_date = sysdate
184 WHERE transaction_id = X_transaction_id;
185
186 L_stmt_num := 20;
187
188 UPDATE wip_txn_interface_errors
189 SET error_message = X_error_msg
190 , last_update_date = sysdate
191 , last_updated_by = L_user_id
192 , request_id = L_request_id
193 , program_application_id = L_prog_appl_id
194 , program_id = L_prog_id
195 , program_update_date = sysdate
196 WHERE transaction_id = X_transaction_id
197 AND error_column = 'TASK_ID';
198
199 if sql%notfound then
200
201 L_stmt_num := 30;
202
203 INSERT INTO wip_txn_interface_errors
204 ( transaction_id
205 , error_message
206 , error_column
207 , last_update_date
208 , last_updated_by
209 , creation_date
210 , created_by
211 , last_update_login
212 , request_id
213 , program_application_id
214 , program_id
215 , program_update_date)
216 VALUES ( X_transaction_id
217 , X_error_msg
218 , 'TASK_ID'
219 , sysdate
220 , L_user_id
221 , sysdate
222 , L_user_id
223 , L_login_id
224 , L_request_id
225 , L_prog_appl_id
226 , L_prog_id
227 , sysdate
228 );
229
230 end if;
231
232 EXCEPTION
233 WHEN OTHERS THEN
234 X_error_num := sqlcode;
235 X_error_msg := 'TKAA-WIPE(' || L_stmt_num || ')->' || sqlerrm;
236
237 END flag_wip_error;
238
239 -- ---------------------------------------------------------------------
240 -- Public Functions and Procedures
241 -- ---------------------------------------------------------------------
242
243 --
244 -- Name : Inv_Task_WNPS
245 --
246 -- Function : This function returns a task based on predefined
247 -- rules and is specially designed for using in
248 -- views.
249 --
250 -- Parameters :
251 -- IN : X_org_id NUMBER
252 -- : X_project_id NUMBER
253 -- : X_item_id NUMBER
254 -- : X_po_header_id NUMBER
255 -- : X_category_id NUMBER
256 -- : X_subinv_code VARCHAR2
257 --
258 FUNCTION Inv_Task_WNPS ( X_org_id IN NUMBER
259 , X_project_id IN NUMBER
260 , X_item_id IN NUMBER
261 , X_po_header_id IN NUMBER
262 , X_category_id IN NUMBER
263 , X_subinv_code IN VARCHAR2 )
264 RETURN NUMBER IS
265
266 L_task_id NUMBER;
267 L_category_id NUMBER;
268 L_procured VARCHAR2(1);
269 i NUMBER := 1;
270 TYPE t_AttributeTable IS TABLE OF pjm_task_attr_usages.attribute_code%TYPE
271 INDEX BY BINARY_INTEGER;
272 v_Attributes t_AttributeTable;
273
274 CURSOR c1 IS
275 SELECT attribute_code
276 FROM pjm_task_attr_usages
277 WHERE assignment_type = 'MATERIAL'
278 ORDER BY sequence_number;
279
280 CURSOR c2 ( C_org_id NUMBER
281 , C_proj_id NUMBER
282 , C_item_id NUMBER
283 , C_po_header_id NUMBER
284 , C_cat_id NUMBER
285 , C_procured VARCHAR2
286 , C_subinv_code VARCHAR2 )
287 IS
288 SELECT task_id
289 FROM pjm_default_tasks
290 WHERE organization_id = C_org_id
291 AND project_id = C_proj_id
292 AND NVL(inventory_item_id, nvl(C_item_id,-1)) = nvl(C_item_id,-1)
293 AND NVL(po_header_id, nvl(C_po_header_id,-1)) = nvl(C_po_header_id,-1)
294 AND NVL(category_id, nvl(C_cat_id,-1)) = nvl(C_cat_id,-1)
295 AND NVL(subinventory_code, nvl(C_subinv_code,' ')) =
296 nvl(C_subinv_code,' ')
297 AND NVL(procure_flag, nvl(C_procured,'*')) = nvl(C_procured,'*')
298 AND assignment_type = 'MATERIAL'
299 ORDER BY decode(v_attributes(1), 'ITEM_NUMBER', to_char(inventory_item_id),
300 'PO_NUMBER', to_char(po_header_id),
301 'CATEGORY', to_char(category_id),
302 'SUBINVENTORY',subinventory_code,
303 'PROCURE_FLAG',procure_flag) ASC
304
305 , decode(v_attributes(2), 'ITEM_NUMBER', to_char(inventory_item_id),
306 'PO_NUMBER', to_char(po_header_id),
307 'CATEGORY', to_char(category_id),
308 'SUBINVENTORY',subinventory_code,
309 'PROCURE_FLAG',procure_flag) ASC
310
311 , decode(v_attributes(3), 'ITEM_NUMBER', to_char(inventory_item_id),
312 'PO_NUMBER', to_char(po_header_id),
313 'CATEGORY', to_char(category_id),
314 'SUBINVENTORY',subinventory_code,
315 'PROCURE_FLAG',procure_flag) ASC
316
317 , decode(v_attributes(4), 'ITEM_NUMBER', to_char(inventory_item_id),
318 'PO_NUMBER', to_char(po_header_id),
319 'CATEGORY', to_char(category_id),
320 'SUBINVENTORY',subinventory_code,
321 'PROCURE_FLAG',procure_flag) ASC
322
323 , decode(v_attributes(5), 'ITEM_NUMBER', to_char(inventory_item_id),
324 'PO_NUMBER', to_char(po_header_id),
325 'CATEGORY', to_char(category_id),
326 'SUBINVENTORY',subinventory_code,
327 'PROCURE_FLAG',procure_flag) ASC;
328
329 BEGIN
330 if ( X_category_id is not null ) then
331 L_category_id := X_category_id;
332 else
333 L_category_id := Get_Item_Category(X_org_id, X_item_id);
334 end if;
335
336 if ( X_po_header_id > 0 ) then
337 L_procured := 'Y';
338 else
339 L_procured := 'N';
340 end if;
341 /* Added the initialization code for the bug 1777435 */
342 for i in 1..5
343 loop
344 v_attributes(i) := NULL;
345 end loop;
346 open c1;
347 loop
348 fetch c1 into v_attributes(i);
349 if c1%notfound then
350 exit;
351 end if;
352 i := i + 1;
353 end loop;
354
355 close c1; /*Bug 6716738 (FP of 6622081): Close the cursor C1*/
356
357 open c2 ( X_org_id
358 , X_project_id
359 , X_item_id
360 , X_po_header_id
361 , L_category_id
362 , L_procured
363 , X_subinv_code );
364 fetch c2 into L_task_id;
365 close c2;
366 return L_task_id;
367
368 end Inv_Task_WNPS;
369
370
371 --
372 -- Name : Wip_Task_WNPS
373 --
374 -- Function : This function returns a task based on predefined
375 -- rules and is specially designed for using in
376 -- views.
377 --
378 -- Parameters :
379 -- IN : X_org_id NUMBER
380 -- : X_project_id NUMBER
381 -- : X_operation_id NUMBER
382 -- : X_wip_entity_id NUMBER
383 -- : X_assy_item_id NUMBER
384 -- : X_dept_id NUMBER
385 --
386 FUNCTION Wip_Task_WNPS ( X_org_id IN NUMBER
387 , X_project_id IN NUMBER
388 , X_operation_id IN NUMBER
389 , X_wip_entity_id IN NUMBER
390 , X_assy_item_id IN NUMBER
391 , X_dept_id IN NUMBER )
392 RETURN NUMBER IS
393
394 L_task_id NUMBER;
395 L_wip_entity VARCHAR2(240);
396 i NUMBER := 1;
397 TYPE t_AttributeTable IS TABLE OF pjm_task_attr_usages.attribute_code%TYPE
398 INDEX BY BINARY_INTEGER;
399 v_Attributes t_AttributeTable;
400
401 CURSOR c1 IS
402 SELECT attribute_code
403 FROM pjm_task_attr_usages
404 WHERE assignment_type = 'RESOURCE'
405 ORDER BY sequence_number;
406
407 CURSOR c2 ( C_org_id NUMBER
408 , C_proj_id NUMBER
409 , C_operation_id NUMBER
410 , C_wip_entity VARCHAR2
411 , C_assy_item_id NUMBER
412 , C_dept_id NUMBER )
413 IS
414 SELECT task_id
415 FROM pjm_default_tasks
416 WHERE organization_id = C_org_id
417 AND project_id = C_proj_id
418 AND NVL(standard_operation_id,
419 nvl(C_operation_id,-1)) = nvl(C_operation_id,-1)
420 AND C_wip_entity like nvl(wip_entity_pattern , '%')
421 AND NVL(assembly_item_id,
422 nvl(C_assy_item_id,-1)) = nvl(C_assy_item_id,-1)
423 AND NVL(department_id, nvl(C_dept_id,-1)) = nvl(C_dept_id,-1)
424 AND assignment_type = 'RESOURCE'
425 ORDER BY decode(v_attributes(1),
426 'DEPARTMENT', department_id,
427 'STANDARD_OPERATION', standard_operation_id,
428 'ASSEMBLY_ITEM', assembly_item_id,
429 'WIP_ENTITY', sign(length(wip_entity_pattern))
430 ) ASC
431 , decode(v_attributes(2),
432 'DEPARTMENT', department_id,
433 'STANDARD_OPERATION', standard_operation_id,
434 'ASSEMBLY_ITEM', assembly_item_id,
435 'WIP_ENTITY', sign(length(wip_entity_pattern))
436 ) ASC
437 , decode(v_attributes(3),
438 'DEPARTMENT', department_id,
439 'STANDARD_OPERATION', standard_operation_id,
440 'ASSEMBLY_ITEM', assembly_item_id,
441 'WIP_ENTITY', sign(length(wip_entity_pattern))
442 ) ASC
443 , decode(v_attributes(4),
444 'DEPARTMENT', department_id,
445 'STANDARD_OPERATION', standard_operation_id,
446 'ASSEMBLY_ITEM', assembly_item_id,
447 'WIP_ENTITY', sign(length(wip_entity_pattern))
448 ) ASC
449 , instr(wip_entity_pattern||'*%','%') DESC
450 ;
451
452 CURSOR c_wip ( C_org_id NUMBER
453 , C_wip_entity_id NUMBER )
454 IS
455 SELECT wip_entity_name
456 FROM wip_entities
457 WHERE organization_id = C_org_id
458 AND wip_entity_id = C_wip_entity_id;
459
460 BEGIN
461 /* Added the initialization code for the bug 1777435 */
462 for i in 1..4
463 loop
464 v_attributes(i) := NULL;
465 end loop;
466 open c1;
467 loop
468 fetch c1 into v_attributes(i);
469 if c1%notfound then
470 exit;
471 end if;
472 i := i + 1;
473 end loop;
474
475 close c1; /*Bug 6716738 (FP of 6622081): Close the cursor C1*/
476
477 open c_wip ( X_org_id, X_wip_entity_id );
478 fetch c_wip into L_wip_entity;
479 close c_wip;
480 open c2 ( X_org_id
481 , X_project_id
482 , X_operation_id
483 , L_wip_entity
484 , X_assy_item_id
485 , X_dept_id );
486 fetch c2 into L_task_id;
487 close c2;
488
489 return( L_task_id );
490 END Wip_Task_WNPS;
491
492 -- Name : WipMat_Task_WNPS
493 --
494 -- Function : This function returns a task based on predefined
495 -- rules and is specially designed for using in
496 -- views.
497 --
498 -- Parameters :
499 -- IN : X_org_id NUMBER
500 -- : X_project_id NUMBER
501 -- : X_item_id NUMBER
502 -- : X_category_id NUMBER
503 -- : X_subinv_code VARCHAR2
504 -- : X_wip_matl_txn_type VARCHAR2
505 -- : X_wip_entity_id NUMBER
506 -- : X_assy_item_id NUMBER
507 -- : X_operation_id NUMBER
508 -- : X_dept_id NUMBER
509 --
510
511 FUNCTION WipMat_Task_WNPS ( X_org_id IN NUMBER
512 , X_project_id IN NUMBER
513 , X_item_id IN NUMBER
514 , X_category_id IN NUMBER
515 , X_subinv_code IN VARCHAR2
516 , X_wip_matl_txn_type IN VARCHAR2
517 , X_wip_entity_id IN NUMBER
518 , X_assy_item_id IN NUMBER
519 , X_operation_id IN NUMBER
520 , X_dept_id IN NUMBER )
521 RETURN NUMBER IS
522
523 L_task_id NUMBER;
524 L_category_id NUMBER;
525 L_wip_entity VARCHAR2(240);
526 i NUMBER := 1;
527 TYPE t_AttributeTable IS TABLE OF pjm_task_attr_usages.attribute_code%TYPE
528 INDEX BY BINARY_INTEGER;
529 v_Attributes t_AttributeTable;
530
531 CURSOR c1 IS
532 SELECT attribute_code
533 FROM pjm_task_attr_usages
534 WHERE assignment_type = 'WIPMAT'
535 ORDER BY sequence_number;
536
537 CURSOR c2 ( C_org_id NUMBER
538 , C_proj_id NUMBER
539 , C_item_id NUMBER
540 , C_cat_id NUMBER
541 , C_subinv_code VARCHAR2
542 , C_wip_matl_txn_type VARCHAR2
543 , C_wip_entity VARCHAR2
544 , C_assy_item_id NUMBER
545 , C_operation_id NUMBER
546 , C_dept_id NUMBER )
547 IS
548 SELECT task_id
549 FROM pjm_default_tasks
550 WHERE organization_id = C_org_id
551 AND project_id = C_proj_id
552 AND NVL(inventory_item_id, nvl(C_item_id,-1)) = nvl(C_item_id,-1)
553 AND NVL(category_id, nvl(C_cat_id,-1)) = nvl(C_cat_id,-1)
554 AND NVL(subinventory_code, nvl(C_subinv_code,' ')) =
555 nvl(C_subinv_code,' ')
556 AND NVL(wip_matl_txn_type, nvl(C_wip_matl_txn_type,'ANY')) =
557 nvl(C_wip_matl_txn_type,'ANY')
558 AND C_wip_entity like nvl(wip_entity_pattern , '%')
559 AND NVL(assembly_item_id, nvl(C_assy_item_id,-1)) =
560 nvl(C_assy_item_id,-1)
561 AND NVL(standard_operation_id, nvl(C_operation_id,-1)) =
562 nvl(C_operation_id,-1)
563 AND NVL(department_id, nvl(C_dept_id,-1)) = nvl(C_dept_id,-1)
564 AND assignment_type = 'WIPMAT'
565 ORDER BY decode(v_attributes(1),
566 'ITEM_NUMBER', to_char(inventory_item_id),
567 'CATEGORY', to_char(category_id),
568 'SUBINVENTORY', subinventory_code,
569 'DEPARTMENT', department_id,
570 'STANDARD_OPERATION', standard_operation_id,
571 'ASSEMBLY_ITEM', assembly_item_id,
572 'WIP_ENTITY', sign(length(wip_entity_pattern)),
573 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
574 ) ASC
575 , decode(v_attributes(2),
576 'ITEM_NUMBER', to_char(inventory_item_id),
577 'CATEGORY', to_char(category_id),
578 'SUBINVENTORY', subinventory_code,
579 'DEPARTMENT', department_id,
580 'STANDARD_OPERATION', standard_operation_id,
581 'ASSEMBLY_ITEM', assembly_item_id,
582 'WIP_ENTITY', sign(length(wip_entity_pattern)),
583 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
584 ) ASC
585 , decode(v_attributes(3),
586 'ITEM_NUMBER', to_char(inventory_item_id),
587 'CATEGORY', to_char(category_id),
588 'SUBINVENTORY', subinventory_code,
589 'DEPARTMENT', department_id,
590 'STANDARD_OPERATION', standard_operation_id,
591 'ASSEMBLY_ITEM', assembly_item_id,
592 'WIP_ENTITY', sign(length(wip_entity_pattern)),
593 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
594 ) ASC
595 , decode(v_attributes(4),
596 'ITEM_NUMBER', to_char(inventory_item_id),
597 'CATEGORY', to_char(category_id),
598 'SUBINVENTORY', subinventory_code,
599 'DEPARTMENT', department_id,
600 'STANDARD_OPERATION', standard_operation_id,
601 'ASSEMBLY_ITEM', assembly_item_id,
602 'WIP_ENTITY', sign(length(wip_entity_pattern)),
603 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
604 ) ASC
605 , decode(v_attributes(5),
606 'ITEM_NUMBER', to_char(inventory_item_id),
607 'CATEGORY', to_char(category_id),
608 'SUBINVENTORY', subinventory_code,
609 'DEPARTMENT', department_id,
610 'STANDARD_OPERATION', standard_operation_id,
611 'ASSEMBLY_ITEM', assembly_item_id,
612 'WIP_ENTITY', sign(length(wip_entity_pattern)),
613 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
614 ) ASC
615 , decode(v_attributes(6),
616 'ITEM_NUMBER', to_char(inventory_item_id),
617 'CATEGORY', to_char(category_id),
618 'SUBINVENTORY', subinventory_code,
619 'DEPARTMENT', department_id,
620 'STANDARD_OPERATION', standard_operation_id,
621 'ASSEMBLY_ITEM', assembly_item_id,
622 'WIP_ENTITY', sign(length(wip_entity_pattern)),
623 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
624 ) ASC
625 , decode(v_attributes(7),
626 'ITEM_NUMBER', to_char(inventory_item_id),
627 'CATEGORY', to_char(category_id),
628 'SUBINVENTORY', subinventory_code,
629 'DEPARTMENT', department_id,
630 'STANDARD_OPERATION', standard_operation_id,
631 'ASSEMBLY_ITEM', assembly_item_id,
632 'WIP_ENTITY', sign(length(wip_entity_pattern)),
633 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
634 ) ASC
635 , decode(v_attributes(8),
636 'ITEM_NUMBER', to_char(inventory_item_id),
637 'CATEGORY', to_char(category_id),
638 'SUBINVENTORY', subinventory_code,
639 'DEPARTMENT', department_id,
640 'STANDARD_OPERATION', standard_operation_id,
641 'ASSEMBLY_ITEM', assembly_item_id,
642 'WIP_ENTITY', sign(length(wip_entity_pattern)),
643 'WIP_MATL_TXN_TYPE', wip_matl_txn_type
644 ) ASC
645 , instr(wip_entity_pattern||'*%','%') DESC
646 ;
647
648 CURSOR c_wip ( C_org_id NUMBER
649 , C_wip_entity_id NUMBER )
650 IS
651 SELECT wip_entity_name
652 FROM wip_entities
653 WHERE organization_id = C_org_id
654 AND wip_entity_id = C_wip_entity_id;
655
656 BEGIN
657 if ( X_category_id is not null ) then
658 L_category_id := X_category_id;
659 else
660 L_category_id := Get_Item_Category(X_org_id, X_item_id);
661 end if;
662
663 for i in 1..8
664 loop
665 v_attributes(i) := NULL;
666 end loop;
667
668 open c1;
669 loop
670 fetch c1 into v_attributes(i);
671 if c1%notfound then
672 exit;
673 end if;
674 i := i + 1;
675 end loop;
676
677 --
678 -- To preserve backward compatibility, if WIP material FlexSequences
679 -- are not defined, use Material rules instead
680 --
681 if ( v_attributes(1) is NULL ) then
682
683 L_task_id := Inv_Task_WNPS( X_org_id
684 , X_project_id
685 , X_item_id
686 , NULL
687 , L_category_id
688 , X_subinv_code );
689
690 else
691
692 open c_wip ( X_org_id, X_wip_entity_id );
693 fetch c_wip into L_wip_entity;
694 close c_wip;
695
696 open c2 ( X_org_id
697 , X_project_id
698 , X_item_id
699 , L_category_id
700 , X_subinv_code
701 , X_wip_matl_txn_type
702 , L_wip_entity
703 , X_assy_item_id
704 , X_operation_id
705 , X_dept_id );
706 fetch c2 into L_task_id;
707 close c2;
708
709 end if;
710
711 return L_task_id;
712
713 end WipMat_Task_WNPS;
714
715
716 -- Function : This function returns a task based on predefined
717 -- rules and is specially designed for using in
718 -- views.
719 --
720 -- Parameters :
721 -- IN : X_org_id NUMBER
722 -- : X_project_id NUMBER
723 -- : X_item_id NUMBER
724 -- : X_category_id NUMBER
725 -- : X_to_org_id NUMBER
726 --
727
728 FUNCTION SCP_Task_WNPS ( X_org_id IN NUMBER
729 , X_project_id IN NUMBER
730 , X_item_id IN NUMBER
731 , X_category_id IN NUMBER
732 , X_to_org_id IN NUMBER )
733 RETURN NUMBER IS
734
735 L_task_id NUMBER;
736 L_category_id NUMBER;
737
738 CURSOR c ( C_org_id NUMBER
739 , C_proj_id NUMBER
740 , C_item_id NUMBER
741 , C_cat_id NUMBER
742 , C_to_org_id NUMBER )
743 IS
744 SELECT task_id
745 FROM pjm_default_tasks
746 WHERE organization_id = c_org_id
747 AND project_id = c_proj_id
748 AND NVL(inventory_item_id, nvl(c_item_id, -1)) = nvl(c_item_id, -1)
749 AND NVL(category_id, nvl(c_cat_id, -1)) = nvl(c_cat_id, -1)
750 AND NVL(to_organization_id, nvl(c_to_org_id, -1)) = nvl(c_to_org_id,-1)
751 AND assignment_type = 'SUPPLY CHAIN'
752 ORDER BY inventory_item_id ASC
753 , category_id ASC
754 , to_organization_id ASC;
755
756 BEGIN
757 if ( X_category_id is not null ) then
758 L_category_id := X_category_id;
759 else
760 L_category_id := Get_Item_Category(X_org_id, X_item_id);
761 end if;
762
763 open c( X_org_id
764 , X_project_id
765 , X_item_id
766 , L_category_id
767 , X_to_org_id );
768 fetch c into L_task_id;
769 close c;
770 return L_task_id;
771
772 END SCP_Task_WNPS;
773
774
775
776 --
777 -- Name : Assign_Task_Inv
778 --
779 -- Function : This procedure assigns a task based on predefined
780 -- rules if a material transaction has project
781 -- references but no task references. If assignment
782 -- rule cannot be found, the transaction will be
783 -- flagged as error and Cost Collection will not be
784 -- performed
785 --
786 -- Parameters :
787 -- IN : X_transaction_id NUMBER
788 --
789 -- IN OUT : X_error_num NUMBER
790 -- : X_error_msg VARCHAR2
791 --
792 PROCEDURE assign_task_inv
793 ( X_transaction_id IN NUMBER
794 , X_error_num IN OUT NOCOPY NUMBER
795 , X_error_msg IN OUT NOCOPY VARCHAR2)
796 IS
797
798 L_txn_src_type NUMBER;
799 L_item_id NUMBER;
800 L_po_header_id NUMBER;
801 L_cat_id NUMBER;
802 L_org_id NUMBER;
803 L_subinv_code VARCHAR2(10);
804 L_proj_id NUMBER;
805 L_task_id NUMBER;
806 L_txfr_org_id NUMBER;
807 L_txfr_txn_id NUMBER;
808 L_txfr_subinv VARCHAR2(10);
809 L_to_org_id NUMBER;
810 L_to_subinv VARCHAR2(10);
811 L_to_cat_id NUMBER;
812 L_to_proj_id NUMBER;
813 L_to_task_id NUMBER;
814 L_src_proj_id NUMBER;
815 L_src_task_id NUMBER;
816 L_direction NUMBER;
817 L_txn_type VARCHAR2(30);
818 L_wip_entity NUMBER;
819 L_assy_item_id NUMBER;
820 L_dept_id NUMBER;
821 L_operation_id NUMBER;
822 L_stmt_num NUMBER;
823 L_proj_check BOOLEAN;
824 L_error_code VARCHAR2(50);
825
826 Rule_not_found EXCEPTION;
827
828 CURSOR c1 ( C_transaction_id NUMBER )
829 IS
830 SELECT organization_id
831 , inventory_item_id
832 , subinventory_code
833 , transaction_source_type_id
834 , decode(transaction_source_type_id,
835 1, transaction_source_id,
836 -1)
837 , project_id
838 , task_id
839 , sign(primary_quantity)
840 , transfer_organization_id
841 , transfer_transaction_id
842 , transfer_subinventory
843 , to_project_id
844 , to_task_id
845 , source_project_id
846 , source_task_id
847 FROM mtl_material_transactions
848 WHERE transaction_id = C_transaction_id;
849
850 CURSOR c_wip ( C_transaction_id NUMBER )
851 IS
852 SELECT decode(t.transaction_type_id,
853 35 , 'ISSUE' , -- WIP component issue
854 38 , 'ISSUE' , -- WIP Neg Comp Issue
855 43 , 'ISSUE' , -- WIP Component Return
856 48 , 'ISSUE' , -- WIP Neg Comp Return
857 17 , 'COMPLETION' , -- WIP Assembly Return
858 44 , 'COMPLETION' , -- WIP Assy Completion
859 NULL)
860 , decode(t.transaction_source_type_id,
861 5, t.transaction_source_id,
862 null)
863 , e.primary_item_id
864 , t.department_id
865 , o.standard_operation_id
866 FROM mtl_material_transactions t
867 , wip_entities e
868 , wip_operations o
869 WHERE transaction_id = C_transaction_id
870 AND e.organization_id = t.organization_id
871 AND e.wip_entity_id = t.transaction_source_id
872 AND o.organization_id (+) = t.organization_id
873 AND o.wip_entity_id (+) = t.transaction_source_id
874 AND o.operation_seq_num (+) = t.operation_seq_num;
875
876 --
877 -- This cursor returns the intransit owning org for a transfer
878 -- transaction. The rules from the intransit owning org should
879 -- be used to derive the opposite task of a transfer transaction
880 --
881 CURSOR o ( C_org_id NUMBER
882 , C_txfr_org_id NUMBER
883 , C_direction NUMBER )
884 IS
885 SELECT decode( fob_point
886 , 1 , to_organization_id
887 , 2 , from_organization_id
888 , C_txfr_org_id ) intransit_org_id
889 FROM mtl_interorg_parameters
890 WHERE C_org_id <> C_txfr_org_id
891 AND from_organization_id =
892 decode(C_direction , 1 , C_txfr_org_id , -1 , C_org_id)
893 AND to_organization_id =
894 decode(C_direction , 1 , C_org_id , -1 , C_txfr_org_id)
895 ;
896
897 BEGIN
898
899 SAVEPOINT start_of_autoassign;
900
901 PJM_CONC.put_line( 'Processing material transaction ' || X_transaction_id );
902
903 X_error_num := 0;
904 X_error_msg := NULL;
905
906 --
907 -- Retrieving relevant information from the transaction
908 --
909 L_stmt_num := 10;
910 open c1 (X_transaction_id);
911 fetch c1
912 into L_org_id
913 , L_item_id
914 , L_subinv_code
915 , L_txn_src_type
916 , L_po_header_id
917 , L_proj_id
918 , L_task_id
919 , L_direction
920 , L_txfr_org_id
921 , L_txfr_txn_id
922 , L_txfr_subinv
923 , L_to_proj_id
924 , L_to_task_id
925 , L_src_proj_id
926 , L_src_task_id;
927 close c1;
928
929 if ((L_proj_id is not null and L_task_id is null) or
930 (L_to_proj_id is not null and L_to_task_id is null) or
931 (L_txn_src_type = 5 and L_src_proj_id is not null and
932 L_src_task_id is null)) then
933 --
934 -- Getting the Inventory category for the item
935 --
936 L_stmt_num := 20;
937 L_cat_id := Get_Item_Category(L_org_id, L_item_id);
938
939 end if;
940
941 --
942 -- If there is project information and there is no task
943 -- information, perform Task AutoAssign
944 --
945 L_proj_check := is_project(L_proj_id);
946
947 if (L_proj_id is not null and
948 L_proj_check and
949 L_task_id is null) then
950
951 PJM_CONC.put_line('Task ID : Input => ' || L_org_id ||
952 ' / ' || L_proj_id ||
953 ' / ' || L_item_id ||
954 ' / ' || L_po_header_id ||
955 ' / ' || L_cat_id ||
956 ' / ' || L_subinv_code);
957
958 L_stmt_num := 30;
959 L_task_id := Inv_Task_WNPS( L_org_id
960 , L_proj_id
961 , L_item_id
962 , L_po_header_id
963 , L_cat_id
964 , L_subinv_code );
965
966 PJM_CONC.put_line('Task ID => ' || L_task_id);
967
968 if (L_task_id is not null) then
969
970 L_stmt_num := 40;
971 UPDATE mtl_material_transactions m
972 SET task_id = L_task_id
973 WHERE transaction_id = X_transaction_id;
974
975 else
976 L_error_code := 'TASK-RULE NOT FOUND(TASK_ID)';
977 raise Rule_not_found;
978 end if;
979
980 end if;
981
982 --
983 -- Now assign task for the to project.
984 --
985 L_proj_check := is_project(L_to_proj_id);
986
987 if (L_to_proj_id is not null and
988 L_proj_check and
989 L_to_task_id is null) then
990
991 L_stmt_num := 45;
992 --
993 -- Bug 2253420
994 --
995 -- Previously the transfer organization is used to derive TO_TASK_ID
996 -- based on TO_PROJECT_ID. It should be determined from the FOB
997 -- point of the transfer transaction. Subinv transfer are not
998 -- affected as the org does not change.
999 --
1000 if ( L_txfr_org_id <> L_org_id ) then
1001 OPEN o ( L_org_id , L_txfr_org_id , L_direction );
1002 FETCH o INTO L_to_org_id;
1003 CLOSE o;
1004 if ( L_to_org_id = L_org_id ) then
1005 L_to_subinv := L_subinv_code;
1006 L_to_cat_id := L_cat_id;
1007 else
1008 L_to_subinv := L_txfr_subinv;
1009 L_to_cat_id := Get_Item_Category(L_to_org_id, L_item_id);
1010 end if;
1011 else
1012 L_to_org_id := L_txfr_org_id;
1013 L_to_subinv := L_txfr_subinv;
1014 L_to_cat_id := L_cat_id;
1015 end if;
1016
1017 PJM_CONC.put_line('To Task ID : Input => ' || L_to_org_id ||
1018 ' / ' || L_to_proj_id ||
1019 ' / ' || L_item_id ||
1020 ' / ' || L_po_header_id ||
1021 ' / ' || L_to_cat_id ||
1022 ' / ' || L_to_subinv);
1023
1024 L_stmt_num := 50;
1025 L_to_task_id := Inv_Task_WNPS( L_to_org_id
1026 , L_to_proj_id
1027 , L_item_id
1028 , L_po_header_id
1029 , L_to_cat_id
1030 , L_to_subinv );
1031
1032 PJM_CONC.put_line('To Task ID => ' || L_to_task_id);
1033
1034 if (L_to_task_id is not null) then
1035
1036 L_stmt_num := 60;
1037 UPDATE mtl_material_transactions m
1038 SET to_task_id = L_to_task_id
1039 WHERE transaction_id = X_transaction_id;
1040
1041 else
1042 L_error_code := 'TASK-RULE NOT FOUND(TO_TASK_ID)';
1043 raise Rule_not_found;
1044 end if;
1045
1046 end if;
1047
1048 --
1049 -- If the transaction_source_type_id = 5 (Job / Schedule)
1050 -- we need to assign task for source project (Job) also.
1051 --
1052 -- Converted to use new WIP Material assignment rules
1053 --
1054 L_proj_check := is_project(L_src_proj_id);
1055
1056 if (L_txn_src_type = 5 and
1057 L_src_proj_id is not null and
1058 L_proj_check and
1059 L_src_task_id is null) then
1060
1061 L_stmt_num := 70;
1062
1063 open c_wip (X_transaction_id);
1064 fetch c_wip
1065 into L_txn_type
1066 , L_wip_entity
1067 , L_assy_item_id
1068 , L_dept_id
1069 , L_operation_id;
1070 close c_wip;
1071
1072 PJM_CONC.put_line('Src Task ID : Input => ' || L_org_id ||
1073 ' / ' || L_src_proj_id ||
1074 ' / ' || L_item_id ||
1075 ' / ' || L_cat_id ||
1076 ' / ' || L_subinv_code ||
1077 ' / ' || L_txn_type ||
1078 ' / ' || L_wip_entity ||
1079 ' / ' || L_assy_item_id ||
1080 ' / ' || L_operation_id ||
1081 ' / ' || L_dept_id);
1082
1083 L_stmt_num := 75;
1084
1085 L_src_task_id := WipMat_Task_WNPS( L_org_id
1086 , L_src_proj_id
1087 , L_item_id
1088 , L_cat_id
1089 , L_subinv_code
1090 , L_txn_type
1091 , L_wip_entity
1092 , L_assy_item_id
1093 , L_operation_id
1094 , L_dept_id );
1095
1096 PJM_CONC.put_line('Src Task ID => ' || L_src_task_id);
1097
1098 if (L_src_task_id is not null) then
1099
1100 L_stmt_num := 80;
1101 UPDATE mtl_material_transactions m
1102 SET source_task_id = L_src_task_id
1103 WHERE transaction_id = X_transaction_id;
1104
1105 else
1106 L_error_code := 'TASK-RULE NOT FOUND(SOURCE_TASK_ID)';
1107 raise Rule_not_found;
1108 end if;
1109
1110 end if;
1111
1112 return;
1113
1114 EXCEPTION
1115 when Rule_not_found then
1116 ROLLBACK TO SAVEPOINT start_of_autoassign;
1117 X_error_num := 1403;
1118 fnd_message.set_name('PJM','TASK-RULE NOT FOUND');
1119 X_error_msg := fnd_message.get;
1120 flag_inv_error(X_transaction_id,
1121 X_error_num,
1122 L_error_code,
1123 X_error_msg);
1124
1125 when others then
1126 X_error_num := sqlcode;
1127 X_error_msg := 'TKAA-INV(' || L_stmt_num || ')->' || sqlerrm;
1128
1129 END assign_task_inv;
1130
1131
1132 --
1133 -- Name : Assign_Task_WIPL
1134 --
1135 -- Function : This procedure assigns a task based on predefined
1136 -- rules if a WIP resource/overhead transaction has
1137 -- project references but no task references. If
1138 -- assignment rule cannot be found, the transaction
1139 -- will beflagged as error and Cost Collection will
1140 -- not be performed
1141 --
1142 -- Parameters :
1143 -- IN : X_transaction_id NUMBER
1144 --
1145 -- IN OUT : X_error_num NUMBER
1146 -- : X_error_msg VARCHAR2
1147 --
1148 PROCEDURE assign_task_wipl
1149 ( X_transaction_id IN NUMBER
1150 , X_error_num IN OUT NOCOPY NUMBER
1151 , X_error_msg IN OUT NOCOPY VARCHAR2)
1152 IS
1153
1154 L_operation_id NUMBER;
1155 L_wip_entity_id NUMBER;
1156 L_assy_item_id NUMBER;
1157 L_org_id NUMBER;
1158 L_proj_id NUMBER;
1159 L_dept_id NUMBER;
1160 L_task_id NUMBER;
1161 L_stmt_num NUMBER;
1162
1163 L_transaction_type NUMBER; /*Added for Bug 7028109 (FP of 6820737)*/
1164 L_cost_elm_id NUMBER; /*Added for Bug 7028109 (FP of 6820737)*/
1165
1166 /*Start : Added for bug 6785540 (FP of 6339257)*/
1167 L_operation_seq_num NUMBER;
1168 L_entity_type NUMBER;
1169 Entity_type_not_supported EXCEPTION;
1170 /*End : Added for bug 6785540 (FP of 6339257)*/
1171
1172 Rule_not_found EXCEPTION;
1173
1174 /*Bug 7028109 (FP of 6820737): Changed below cursor c1 to add WTA and fetch transaction type and cost element id also.*/
1175 /*Start : Bug 6785540 (FP of 6339257): Changed cursor c1. Added cursors d1 and f1*/
1176 CURSOR c1 ( C_transaction_id NUMBER )
1177 IS
1178 SELECT t.wip_entity_id
1179 , t.organization_id
1180 , t.operation_seq_num
1181 , t.project_id
1182 , t.task_id
1183 , t.department_id
1184 , t.transaction_type /*Added for Bug 7028109 (FP of 6820737)*/
1185 , e.primary_item_id
1186 , e.entity_type
1187 , wta.cost_element_id /*Added for Bug 7028109 (FP of 6820737)*/
1188 FROM wip_transactions t
1189 , wip_entities e
1190 , wip_transaction_accounts wta
1191 WHERE t.transaction_id = C_transaction_id
1192 AND t.wip_entity_id = e.wip_entity_id
1193 AND t.organization_id = e.organization_id
1194 AND t.transaction_id = wta.transaction_id
1195 AND t.organization_id = wta.organization_id
1196 AND wta.accounting_line_type = 7; /*Accounting line type 7 = WIP Valuation*/
1197
1198 -- for discrete job
1199 CURSOR d1 ( C_organization_id NUMBER, C_wip_entity_id NUMBER, C_operation_seq_num NUMBER )
1200 IS
1201 SELECT o.standard_operation_id
1202 FROM wip_entities e
1203 , wip_operations o
1204 WHERE e.organization_id = C_organization_id
1205 AND e.wip_entity_id = C_wip_entity_id
1206 AND o.organization_id = e.organization_id
1207 AND o.wip_entity_id = e.wip_entity_id
1208 AND o.operation_seq_num = C_operation_seq_num;
1209
1210 -- for flow schedule
1211 CURSOR f1 ( C_organization_id NUMBER, C_wip_entity_id NUMBER, C_operation_seq_num NUMBER, C_primary_item_id NUMBER )
1212 IS
1213 SELECT s.standard_operation_id
1214 FROM wip_flow_schedules f
1215 , bom_operational_routings r
1216 , bom_operation_sequences s
1217 WHERE f.wip_entity_id = C_wip_entity_id
1218 AND f.organization_id = C_organization_id
1219 AND nvl(f.alternate_routing_designator, 'a') = nvl(r.alternate_routing_designator, 'a')
1220 AND r.assembly_item_id = C_primary_item_id
1221 AND r.routing_sequence_id = s.routing_sequence_id
1222 AND r.organization_id = f.organization_id
1223 AND s.operation_seq_num = C_operation_seq_num
1224 AND f.scheduled_completion_date BETWEEN s.effectivity_date AND nvl(s.disable_date, sysdate + 1)
1225 AND s.operation_type = 1;
1226 /*End : Bug 6785540 (FP of 6339257): Changed cursor c1. Added cursors d1 and f1*/
1227
1228 BEGIN
1229
1230 SAVEPOINT start_of_autoassign;
1231
1232 X_error_num := 0;
1233 X_error_msg := NULL;
1234
1235 PJM_CONC.put_line( 'Processing resource transaction ' || X_transaction_id );
1236
1237 L_stmt_num := 10;
1238 DELETE FROM wip_txn_interface_errors
1239 WHERE transaction_id = X_transaction_id
1240 AND error_column = 'TASK_ID';
1241
1242 --
1243 -- Retrieving relevant information from the transaction
1244 --
1245 L_stmt_num := 20;
1246 open c1 (X_transaction_id);
1247 /*Bug 6785540 (FP of 6339257): Changed fetch of cursor c1.*/
1248 fetch c1
1249 into L_wip_entity_id
1250 , L_org_id
1251 , L_operation_seq_num
1252 , L_proj_id
1253 , L_task_id
1254 , L_dept_id
1255 , L_transaction_type /*Added for Bug 7028109 (FP of 6820737)*/
1256 , L_assy_item_id
1257 , L_entity_type
1258 , L_cost_elm_id; /*Added for Bug 7028109 (FP of 6820737)*/
1259
1260 close c1;
1261
1262 if (L_proj_id is not null and
1263 is_project(L_proj_id) and
1264 L_task_id is null) then
1265
1266 PJM_CONC.put_line('Input => ' || L_org_id ||
1267 ' / ' || L_proj_id ||
1268 ' / ' || L_operation_id ||
1269 ' / ' || L_wip_entity_id ||
1270 ' / ' || L_assy_item_id ||
1271 ' / ' || L_dept_id ||
1272 ' / ' || L_entity_type); /*Bug 6785540 (FP of 6339257): Print entity type also.*/
1273
1274
1275 /*Start : Bug 6785540 (FP of 6339257): Fetch operation based on entity type.*/
1276 -- Bug 11775962 FP of Bug 11691916 to enable other entity types
1277 if (L_entity_type <> 4 ) then
1278 open d1 (L_org_id, L_wip_entity_id, L_operation_seq_num);
1279 fetch d1
1280 into L_operation_id;
1281 close d1;
1282 elsif (L_entity_type = 4) then
1283 open f1 (L_org_id, L_wip_entity_id, L_operation_seq_num, L_assy_item_id);
1284 fetch f1
1285 into L_operation_id;
1286 close f1;
1287 else
1288 raise Entity_type_not_supported;
1289 end if;
1290
1291 PJM_CONC.put_line('Operation ID => ' || L_operation_id);
1292 /*End : Bug 6785540 (FP of 6339257): Fetch operation based on entity type.*/
1293
1294 /*Bug 7028109 (FP of 6820737): Follow normal flow if txn is not for direct item. Also check for cost element id.
1295 If it is 1/2 then treat txn as material txn else as resource transaction.*/
1296 if( L_transaction_type <> 17 OR L_cost_elm_id NOT IN (1,2) ) then
1297 PJM_CONC.put_line('Calling Wip_Task_WNPS to get task for resource txn.');
1298 L_stmt_num := 30;
1299 L_task_id := Wip_Task_WNPS ( L_org_id
1300 , L_proj_id
1301 , L_operation_id
1302 , L_wip_entity_id
1303 , L_assy_item_id
1304 , L_dept_id );
1305 /*Start - Bug 7028109 (FP of 6820737): For direct item, call material rule engine. */
1306 else
1307 PJM_CONC.put_line('Calling WipMat_Task_WNPS to get task for resource txn. (For direct item txn)');
1308 L_task_id := WipMat_Task_WNPS(X_org_id => L_org_id
1309 , X_project_id => L_proj_id
1310 , X_item_id => null
1311 , X_category_id => null
1312 , X_subinv_code => null
1313 , X_wip_matl_txn_type => null
1314 , X_wip_entity_id => L_wip_entity_id
1315 , X_assy_item_id => L_assy_item_id
1316 , X_operation_id => L_operation_id
1317 , X_dept_id => L_dept_id );
1318 end if;
1319 /*End - Bug 7028109 (FP of 6820737): For direct item, check the cost element id and treat txn accordingly.*/
1320
1321 PJM_CONC.put_line('Task ID => ' || L_task_id);
1322
1323 if (L_task_id is not null) then
1324
1325 L_stmt_num := 40;
1326 UPDATE wip_transactions w
1327 SET task_id = L_task_id
1328 WHERE transaction_id = X_transaction_id;
1329
1330 else
1331 raise Rule_Not_Found;
1332 end if;
1333 end if;
1334
1335 EXCEPTION
1336 /*Start : Bug 6785540 (FP of 6339257): Added exception handling.*/
1337 when Entity_type_not_supported then
1338 ROLLBACK TO SAVEPOINT start_of_autoassign;
1339 X_error_num := 1403;
1340 fnd_message.set_name('PJM','ENTITY-TYPE NOT SUPPORTED');
1341 X_error_msg := fnd_message.get;
1342 flag_wip_error(X_transaction_id,
1343 X_error_num,
1344 X_error_msg);
1345 /*End : Bug 6785540 (FP of 6339257): Added exception handling.*/
1346 when Rule_not_found then
1347 ROLLBACK TO SAVEPOINT start_of_autoassign;
1348 X_error_num := 1403;
1349 fnd_message.set_name('PJM','TASK-RULE NOT FOUND');
1350 X_error_msg := fnd_message.get;
1351 flag_wip_error(X_transaction_id,
1352 X_error_num,
1353 X_error_msg);
1354
1355 when others then
1356 X_error_num := sqlcode;
1357 X_error_msg := 'TKAA-WIP(' || L_stmt_num || ')->' || sqlerrm;
1358
1359 END assign_task_wipl;
1360
1361 END pjm_task_auto_assign;