DBA Data[Home] [Help]

PACKAGE BODY: APPS.IEU_WPACTIONS_PVT

Source


1 PACKAGE BODY IEU_WPACTIONS_PVT AS
2 /* $Header: IEUTKWPB.pls 120.3.12020000.2 2012/07/10 06:18:58 rgandhi ship $ */
3 
4 
5 PROCEDURE WP_TASK
6 ( P_RESOURCE_ID       IN NUMBER,
7   P_LANGUAGE          IN VARCHAR2,
8   P_SOURCE_LANG       IN VARCHAR2,
9   P_ACTION_KEY        IN VARCHAR2,
10   P_ACTION_INPUT_DATA IN SYSTEM.ACTION_INPUT_DATA_NST,
11   P_Action_Type       IN Varchar2,
15   X_RETURN_STATUS     OUT NOCOPY VARCHAR2
12   X_UWQ_ACTION_LIST   OUT NOCOPY SYSTEM.IEU_UWQ_WORK_ACTIONS_NST,
13   X_MSG_COUNT         OUT NOCOPY NUMBER,
14   X_MSG_DATA          OUT NOCOPY VARCHAR2,
16 )
17 IS
18     l_api_version           CONSTANT NUMBER      := 1.0;
19     l_valid_level_full      NUMBER      := 100;
20     l_note_status           VARCHAR2(3);
21 
22     -- only TASK from below is used for anything right now.
23     l_src_task              CONSTANT VARCHAR2(30) := 'TASK';
24     l_src_sr                CONSTANT VARCHAR2(30) := 'SR';
25     l_src_lead              CONSTANT VARCHAR2(30) := 'LEAD';
26     l_src_opp               CONSTANT VARCHAR2(30) := 'OPPORTUNITY';
27     l_src_rel1              CONSTANT VARCHAR2(30) := 'PARTY_RELATIONSHIP';
28     l_src_rel2              CONSTANT VARCHAR2(30) := 'PARTY_PERSON_RELATIONSHIP';
29 
30     -- for work to be done in uwq
31     l_uwq_actions_list      IEU_UWQ_WORK_PANEL_PUB.UWQ_ACTION_REC_LIST;
32 
33     --work action data items
34     l_dataSetType           VARCHAR2(50);
35     l_set_id                NUMBER;
36     l_name                  VARCHAR2(500);
37     l_value                 VARCHAR2(4000);  -- Niraj, 07-08-05, Bug 4482399: Increased from 500 to 4000
38 
39     -- parameters from the work item
40     l_task_rec_tbl          TASK_REC_TBL;
41     l_count                 NUMBER;
42     l_continue              NUMBER :=0;
43     -- parameters from the work panel
44     l_task_name             VARCHAR2(80);
45     l_type                  VARCHAR2(30); --NUMBER;
46     l_priority              VARCHAR2(30); --NUMBER;
47     l_status                VARCHAR2(30); --NUMBER;
48     l_date_type             VARCHAR2(30);   -- lookup code
49     l_planned_start         DATE;
50     l_planned_end           DATE;
51     l_actual_start          DATE;
52     l_actual_end            DATE;
53     l_sched_start           DATE;
54     l_sched_end             DATE;
55     l_description           VARCHAR2(4000);
56     l_note                  VARCHAR2(4000);
57     l_owner                 VARCHAR2(4000);
58     l_owner_tmp             VARCHAR2(4000);
59     l_assignee              VARCHAR2(4000);
60     l_auto_relate_note      NUMBER;
61     l_p_task_name             VARCHAR2(80);-- := g_miss_char;
62     l_p_type                  VARCHAR2(30);--  := g_miss_char;
63     l_p_priority              VARCHAR2(30);--  := g_miss_char;
64     l_p_status                VARCHAR2(30);--  := g_miss_char;
65     l_p_date_type             VARCHAR2(30) ;   -- lookup code
66     l_p_planned_start         DATE;--  := g_miss_date;
67     l_p_planned_end           DATE;--  := g_miss_date;
68     l_p_actual_start          DATE;--  := g_miss_date;
69     l_p_actual_end            DATE;--  := g_miss_date;
70     l_p_sched_start           DATE;--  := g_miss_date;
71     l_p_sched_end             DATE;--  := g_miss_date;
72     l_p_description           VARCHAR2(4000);--  := g_miss_char;
73     l_p_note                  VARCHAR2(4000);--  := g_miss_char;
74     l_p_owner                 VARCHAR2(4000) ;
75     l_p_owner_tmp             VARCHAR2(4000) ;
76     l_p_assignee              VARCHAR2(4000) ;
77     l_p_auto_relate_note      NUMBER;
78 
79 
80 
81     -- misc variables required for calling api
82     l_obj_type_code         VARCHAR2(60); -- Niraj, 07-08-05, Bug 4482399: Increased from 30 to 60
83     l_obj_id                NUMBER;
84     l_obj_name              VARCHAR2(80);
85     l_object_version_number NUMBER;
86     l_return_status         VARCHAR2(1);
87     l_msg_count             NUMBER;
88     l_msg_data              VARCHAR2(2000);
89     l_owner_id              NUMBER;
90     l_owner_type_code       VARCHAR2(30);
91     l_owner_id_tmp              NUMBER;
92     l_owner_type_code_tmp       VARCHAR2(30);
93 
94     l_assignee_id           NUMBER;
95     l_assignee_type_code    VARCHAR2(30);
96     l_idx                   NUMBER;
97     l_idx2                  NUMBER;
98     l_exist_assign_id       NUMBER;
99     l_new_assign_id         NUMBER;
100     l_exist_assign_ver      NUMBER;
101     l_new_assign_status     NUMBER := 3;      -- ACCEPTED status id
102     l_note_context_type_id  NUMBER;
103     l_source_object_id      NUMBER;
104 
105     CURSOR c_task_ass (b_task_id NUMBER) IS
106       SELECT task_assignment_id, object_version_number
107       FROM jtf_task_all_assignments
108       WHERE task_id = b_task_id AND
109             assignee_role <> 'OWNER';
110 
111     -- notes related parameters
112     l_note_id               NUMBER;
113     l_context_id            NUMBER;
114     l_note_ctxt_tbl         jtf_notes_pub.jtf_note_contexts_tbl_type;
115     l_note_ctxt_idx         NUMBER;
116 
117     cursor C_note_context_id(p_object_id NUMBER) is
118       select contact_id
119       from jtf_task_contacts
120       where task_id =  p_object_id
121       and (primary_flag is null or primary_flag = 'Y')
122       order by primary_flag;
123 
124 
125     CURSOR c_task_src (b_task_id NUMBER) IS
126       SELECT tb.source_object_type_code
127       FROM jtf_object_usages ou,
128            jtf_tasks_b tb
129       WHERE
130         tb.task_id = b_task_id and
131         ou.object_user_code = 'NOTES' and
132         ou.object_code = tb.source_object_type_code;
133 
134     -- exceptions raised in this procedure
135     null_fail_exception EXCEPTION;
136     fail_exception        EXCEPTION;
137     name_fail_exception        EXCEPTION;
138 
139     -- cheating GSCC
140     l_date_fmt             CONSTANT VARCHAR2(30) := 'DD-MON-RRRR HH24:MI:SS';
141 
142 
143 BEGIN
144 
145  l_note_status := nvl(fnd_profile.value('JTF_NTS_NOTE_STATUS'),'I');
146  --DELETE FROM msista_tmp;
147  --commit;
148  --INSERT INTO msista_Tmp values (11, 'P_Action_Type is '|| P_Action_Type);
149  --commit;
150 
151  SAVEPOINT update_task_savepoint;
152 
153  -- initialize fnd's message list
154  fnd_msg_pub.initialize();
155 
156  -- Get all the required parameters from Action Input List
157  -- required parameters are TBD.
158 
159   /*
160     To Do -
161     a. loop through the work_action_Data
162     b. identify 'work_item_data'
163     c. collect the task_id for each DataSetID that comes through into l_task_rec_tbl
164     d. collect the 'action_param_data' that comes through into the set of params
165     e. if task_Rec_tbl.count > 1 => multi-select mode
166     f. if multi-select mode, we should ignore some of the parameters (per reqmnt).
167     g. loop through l_task_rec_tbl and call update_task for each task_id - do not --commit.
168     g1. break out of loop if any update_task fails.
169     h. if all task items were updated successfully - --commit.
170     i. if any task update fails, roll back and return error message.
171   */
172   --INSERT  INTO msista_Tmp values (20, 'entering for(p_action_input_data) loop');
173   --commit;
174   --** These default values have been added as part of bug #4706930 - MS **---
175       l_p_task_name             := FND_API.G_MISS_CHAR;
176       l_p_type                  := FND_API.G_MISS_CHAR;
177       l_p_priority              := FND_API.G_MISS_CHAR;
178       l_p_status                := FND_API.G_MISS_CHAR;
179 
180       l_p_planned_start         := FND_API.G_MISS_DATE;
181       l_p_planned_end           := FND_API.G_MISS_DATE;
182       l_p_actual_start          := FND_API.G_MISS_DATE;
183       l_p_actual_end            := FND_API.G_MISS_DATE;
184       l_p_sched_start           := FND_API.G_MISS_DATE;
185       l_p_sched_end             := FND_API.G_MISS_DATE;
186       l_p_description           := FND_API.G_MISS_CHAR;
187       l_p_note                  := FND_API.G_MISS_CHAR;
188 
189   for i in 1..p_action_input_data.COUNT LOOP
190 
191       l_dataSetType := p_action_input_data(i).dataSetType;
192       if (l_dataSetType = 'WORK_ITEM_DATA')      then
193 
194         l_set_id := p_action_input_data(i).dataSetId;
195         l_name  := p_action_input_data (i).name;
196         l_value := p_action_input_data (i).value;
197 
198         --INSERT INTO msista_Tmp values (30, 'found WORK_ITEM_DATA, set_id = ' || l_set_id || ', name - ''' || l_name || ''', value = ''' || l_value || '''');
199         --commit;
200         if (l_name = 'TASK_ID') then
201           l_task_rec_tbl(l_set_id).id := l_value;
202         ELSIF (l_name = 'SOURCE_OBJECT_ID') THEN
203           l_task_rec_tbl(l_set_id).source_id := l_value;
204         ELSIF (l_name = 'IEU_ACTION_OBJECT_CODE') THEN
205           l_task_rec_tbl(l_set_id).source_type_code := l_value;
206 --        ELSIF (l_name = 'TASK_PRIORITY') THEN    ---- getting this value for reassign, reschedule, and transfer owner actions.
207 --          l_task_rec_tbl(l_set_id).priority_name := l_value;
208         ELSIF (l_name = 'OBJECT_VERSION_NUMBER') THEN
209           l_task_rec_tbl(l_set_id).object_version_number := l_value;
210          end if;
211 
212 
213       elsif (l_dataSetType = 'ACTION_PARAM_DATA')
214       then
215 
216         --don't care for l_set_id for action parameter data
217         l_name  := p_action_input_data (i).name;
218         l_value := p_action_input_data (i).value;
219 
220         --INSERT INTO msista_Tmp values (40, 'found ACTION_PARAM_DATA, name - ''' || l_name || ''', value = ''' || l_value || '''');
221         --commit;
222 
223         IF (l_name = 'TASK_NAME') THEN
224           l_p_task_name := l_value;
225         ELSIF (l_name = 'TASK_TYPE') THEN
226           l_p_type := l_value;
227         ELSIF (l_name = 'TASK_PRIORITY') THEN
228           l_p_priority := l_value;
229         ELSIF (l_name = 'TASK_STATUS') THEN
230           l_p_status := l_value;
231         ELSIF (l_name = 'PLANNED_START_DATE') THEN
232           l_p_planned_start := TO_DATE(l_value, l_date_fmt);
233         ELSIF (l_name = 'PLANNED_END_DATE') THEN
234           l_p_planned_end := TO_DATE(l_value, l_date_fmt);
235         ELSIF (l_name = 'ACTUAL_START_DATE') THEN
236           l_p_actual_start := TO_DATE(l_value, l_date_fmt);
237         ELSIF (l_name = 'ACTUAL_END_DATE') THEN
238           l_p_actual_end := TO_DATE(l_value, l_date_fmt);
239         ELSIF (l_name = 'SCHED_START_DATE') THEN
240           l_p_sched_start := TO_DATE(l_value, l_date_fmt);
241         ELSIF (l_name = 'SCHEDULED_END') THEN
242           l_p_sched_end := TO_DATE(l_value, l_date_fmt);
243         ELSIF (l_name = 'DESCRIPTION') THEN
247         ELSIF (l_name = 'OWNER') THEN
244           l_p_description := l_value;
245         ELSIF (l_name = 'NEW_NOTE') THEN
246           l_p_note := l_value;
248           l_p_owner := l_value;
249         ELSIF (l_name = 'ASSIGNEE') THEN
250           l_p_assignee := l_value;
251         END IF;
252       end if;
253   end loop;
254 
255   -- parameters validations
256   -- number of tasks selected in uwq
257   l_count := l_task_rec_tbl.COUNT;
258   if (l_count = 1) then -- single mode
259       -- single mode requires task type, priority, and status
260       /*
261       Update Task:
262         Checked by Form:N/A
263         Checked by API:Task Status, Task Type
264 
265        Close Task
266         Checked by Form: N/A
267         Checked by API:Task Status,Task Type
268 
269        Reassign  Task:
270         Checked by Form:Task Assignee
271         Checked by API: N/A
272 
273        Reschedule Task:
274         Checked by Form: N/A
275         Checked by API: N/A
276 
277        Transfer Task:
278         Checked by Form: Task Owner
279         Checked by API: N/A
280       */
281       if (l_p_task_name is null) then
282          RAISE name_fail_exception;
283       end if;
284       if ((p_Action_Type = 'UPDATE_TASK' or p_Action_TYPE = 'CLOSE_TASK')
285            and (l_p_type is null  or l_p_status is null)) then
286          -- ROLLBACK TO update_task_savepoint;
287           --INSERT INTO msista_Tmp values (45, 'null_fail_exception');
288           --commit;
289 
290           RAISE null_fail_exception;
291       end if;
292    END if;
293 
294   /*
295     e. if task_Rec_tbl.count > 1 => multi-select mode
296     f. if multi-select mode, we should ignore some of the parameters (per reqmnt).
297     g. loop through l_task_rec_tbl and call update_task for each task_id - do not --commit.
298     g1. break out of loop if any update_task fails.
299     h. if all task items were updated successfully - --commit.
300     i. if any task update fails, roll back and return error message.
301   */
302 
303    -- task api uses g_miss* values for defaults
304   IF (l_p_task_name is NULL) THEN
305       --INSERT INTO msista_Tmp values (42, 'l_task_name is null');
306       --commit;
307 
308       l_task_name := FND_API.G_MISS_CHAR;
309   ELSE
310       --INSERT INTO msista_Tmp values (42, 'l_task_name <> null');
311       --commit;
312 
313       l_task_name := l_p_task_name;
314   END IF;
315   IF ( l_p_type is NULL ) THEN
316       --INSERT INTO msista_Tmp values (42, 'l_type is null');
317       --commit;
318 
319       l_type := FND_API.G_MISS_CHAR;    --G_MISS_NUM;
320   ELSE
321       --INSERT INTO msista_Tmp values (42, 'l_type <> null');
322       --commit;
323 
324       l_type := l_p_type;
325   END IF;
326   IF (l_p_description is NULL ) THEN
327       --INSERT INTO msista_Tmp values (42, 'l_description is null');
328       --commit;
329         l_description := FND_API.G_MISS_CHAR;
330   ELSE
331       --INSERT INTO msista_Tmp values (42, 'l_description <> null');
332       --commit;
333 
334       l_description := l_p_description;
335   END IF;
336   IF (l_p_status is NULL ) THEN
337       --INSERT INTO msista_Tmp values (42, 'l_status is null');
338       --commit;
339 
340       l_status := FND_API.G_MISS_CHAR;    --g_miss_num;
341   ELSE
342       --INSERT INTO msista_Tmp values (42, 'l_status <> null');
343       --commit;
344 
345       l_status := l_p_status;
346   END IF;
347   IF ((l_count > 1 AND l_p_priority is NULL ) or
348       (l_count = 1 AND l_p_priority is NULL )) THEN
349       --INSERT INTO msista_Tmp values (42, 'l_priority is null');
350       --commit;
351 
352       l_priority := FND_API.G_MISS_CHAR;    --g_miss_num;
353   ELSE
354       --INSERT INTO msista_Tmp values (42, 'l_count is '||l_count||',l_priority <> null and it is '||l_p_priority);
355       --commit;
356 
357       l_priority := l_p_priority;
358   END IF;
359   IF (l_p_owner is NULL) THEN
360       --INSERT INTO msista_Tmp values (42, 'l_owner is null');
361       --commit;
362 
363       l_owner_id := FND_API.G_MISS_NUM;
364       l_owner_type_code := FND_API.G_MISS_CHAR;
365   ELSE
366       --INSERT INTO msista_Tmp values (42, 'l_owner <> null, parsing l_owner='||l_owner);
367       --commit;
368 
369       -- owner type code is bundled with owner code, need to break them apart
370       l_owner := l_p_owner;
371       l_idx := INSTR(l_owner, G_OPEN_SQBR, 1, 1);
372       l_idx2 := INSTR(l_owner, G_CLOSE_SQBR, -1, 1);
373       l_owner_id := TO_NUMBER(SUBSTR(l_owner, 1, l_idx-1));
374       l_owner_type_code := SUBSTR(l_owner, l_idx+1, l_idx2-l_idx-1);
375       --INSERT INTO msista_Tmp values (42, 'l_owner_id - ''' || l_owner_id || ''', l_owner_type_code - ''' || l_owner_type_code || '''');
376       --commit;
377 
378   END IF;
379   IF (l_p_assignee is NULL) THEN
380       --INSERT INTO msista_Tmp values (42, 'l_assignee is null');
381       --commit;
382 
383       l_assignee_id := FND_API.G_MISS_NUM;
384       l_assignee_type_code := FND_API.G_MISS_CHAR;
385   ELSE
386       --INSERT  INTO msista_Tmp values (42, 'l_assignee <> null, parsing');
387       --commit;
388 
389       -- assignee type code is bundled with assignee code, break them apart
390       l_assignee := l_p_assignee;
391       l_idx := INSTR(l_assignee, G_OPEN_SQBR, 1, 1);
392       l_idx2 := INSTR(l_assignee, G_CLOSE_SQBR, -1, 1);
393       l_assignee_id := TO_NUMBER(SUBSTR(l_assignee, 1, l_idx-1));
394       l_assignee_type_code := SUBSTR(l_assignee, l_idx+1, l_idx2-l_idx-1);
398   END IF;
395       --INSERT  INTO msista_Tmp values (42, 'l_assignee_id - ''' || l_assignee_id || ''', l_assignee_type_code - ''' || l_assignee_type_code || '''');
396       --commit;
397 
399   IF (l_count > 1 AND l_p_planned_start is NULL) THEN
400       --INSERT  INTO msista_Tmp values (42, 'l_planned_start is null');
401       --commit;
402 
403       l_planned_start := FND_API.G_MISS_DATE;
404   ELSE
405       --INSERT  INTO msista_Tmp values (42, 'l_planned_start <> null');
406       --commit;
407 
408       l_planned_start := l_p_planned_start;
409   END IF;
410   IF (l_count > 1 AND l_p_planned_end is NULL) THEN
411       --INSERT  INTO msista_Tmp values (42, 'l_planned_end is null');
412       --commit;
413 
414       l_planned_end := FND_API.G_MISS_DATE;
415   ELSE
416       --INSERT  INTO msista_Tmp values (42, 'l_planned_end <> null');
417       --commit;
418 
419       l_planned_end :=l_p_planned_end;
420   END IF;
421   IF (l_count > 1 AND l_p_actual_start is NULL) THEN
422       --INSERT  INTO msista_Tmp values (42, 'l_actual_start is null');
423       --commit;
424 
425       l_actual_start := FND_API.G_MISS_DATE;
426   ELSE
427       --INSERT  INTO msista_Tmp values (42, 'l_actual_start <> null');
428       --commit;
429 
430       l_actual_start := l_p_actual_start;
431   END IF;
432   IF (l_count > 1 AND l_p_actual_end is NULL) THEN
433       --INSERT  INTO msista_Tmp values (42, 'l_actual_end is null');
434       --commit;
435 
436       l_actual_end := FND_API.G_MISS_DATE;
437   ELSE
438       --INSERT  INTO msista_Tmp values (42, 'l_actual_end <> null');
439       --commit;
440 
441       l_actual_end := l_p_actual_end;
442   END IF;
443   IF (l_count > 1 AND l_p_sched_start is NULL) THEN
444       --INSERT  INTO msista_Tmp values (42, 'l_sched_start is null');
445       --commit;
446 
447       l_sched_start := FND_API.G_MISS_DATE;
448   ELSE
449       --INSERT  INTO msista_Tmp values (42, 'l_sched_start <> null');
450       --commit;
451 
452       l_sched_start := l_p_sched_start;
453   END IF;
454   IF (l_count > 1 AND l_p_sched_end is NULL) THEN
455 
456       --INSERT  INTO msista_Tmp values (42, 'l_sched_end is null');
457       --commit;
458 
459       l_sched_end := FND_API.G_MISS_DATE;
460   ELSE
461       --INSERT  INTO msista_Tmp values (42, 'l_sched_end <> null');
462       --commit;
463 
464       l_sched_end := l_p_sched_end;
465   END IF;
466 
467 
468   FOR i IN 1..l_count LOOP
469 
470     /* if actions are Reassign, Reschedule or Transfer Owner then get the priority name from work_item_data
471        else get the priority name from action_param_data
472 
473     if (p_action_type = 'REASSIGN_TASK' or p_action_type = 'RESCHEDULE_TASK'
474         or p_action_type = 'TRANSFER_TASK_OWNER_TASK') then
475        l_priority := l_task_rec_tbl(i).priority_name;
476     else
477        l_priority := l_p_priority;
478     end if;
479 
480     -- This code is not required because these changes now, update/close task actions in multi select mode
481     -- throws an error.
482 
483    */
484 
485     --INSERT  INTO msista_Tmp values (49, 'inside update task loop '|| i);
486     --  --commit;
487     -- get current object_version_number of task to updated
488 
489     -- 09/24/03 commented this code because getting the object_version_number from p_action_input_data. (fix bug 3127477)
490 /*
491     SELECT object_version_number INTO l_object_version_number
492     FROM jtf_tasks_b WHERE task_id = l_task_rec_tbl(i).id;
493 */
494 
495     -- call the update_task api to update the task object
496     --INSERT  INTO msista_Tmp values (50, 'calling update_task, with params :- ');
497     --INSERT  INTO msista_Tmp values (51, 'p_api_version                       => ''' || l_api_version || '''');
498     --INSERT  INTO msista_Tmp values (51, 'p_init_msg_list                     => ''' || G_FALSE || '''');
499     --INSERT  INTO msista_Tmp values (51, 'p_--commit                            => ''' || G_FALSE || '''');
500     --INSERT  INTO msista_Tmp values (51, 'p_object_version_number             => ''' || l_object_version_number || '''');
501     --INSERT  INTO msista_Tmp values (51, 'p_task_id                           => ''' || l_task_rec_tbl(i).id || '''');
502     --INSERT  INTO msista_Tmp values (51, 'p_task_name                         => ''' || l_task_name || '''');
503     --INSERT  INTO msista_Tmp values (51, 'p_task_type_name                    => ''' || l_type || '''');
504     --INSERT  INTO msista_Tmp values (51, 'p_description                       => ''' || l_description || '''');
505     --INSERT  INTO msista_Tmp values (51, 'p_task_status_name                  => ''' || l_status || '''');
506     --INSERT  INTO msista_Tmp values (51, 'p_task_priority_name                => ''' || l_priority || '''');
507     --INSERT  INTO msista_Tmp values (51, 'p_owner_type_code                   => ''' || l_owner_type_code || '''');
508     --INSERT  INTO msista_Tmp values (51, 'p_owner_id                          => ''' || l_owner_id || '''');
509     --INSERT  INTO msista_Tmp values (51, 'p_assigned_by_id                    => ''' || l_assignee_id || '''');
510     --INSERT  INTO msista_Tmp values (51, 'p_planned_start_date                => ''' || l_planned_start || '''');
511     --INSERT  INTO msista_Tmp values (51, 'p_planned_end_date                  => ''' || l_planned_end || '''');
512     --INSERT  INTO msista_Tmp values (51, 'p_scheduled_start_date              => ''' || l_actual_start || '''');
513     --INSERT  INTO msista_Tmp values (51, 'p_scheduled_end_date                => ''' || l_actual_end || '''');
514     --INSERT  INTO msista_Tmp values (51, 'p_actual_start_date                 => ''' || l_sched_start || '''');
515     --INSERT  INTO msista_Tmp values (51, 'p_actual_end_date                   => ''' || l_sched_end || '''');
516     --INSERT  INTO msista_Tmp values (51, 'x_return_status                     => ''' || l_return_status || '''');
517     --INSERT  INTO msista_Tmp values (51, 'x_msg_count                         => ''' || l_msg_count || '''');
518     --INSERT  INTO msista_Tmp values (51, 'x_msg_data                          => ''' || l_msg_data || '''');
519     --commit;
520 
521     jtf_tasks_pub.update_task(
522       p_api_version                       => l_api_version,
523       p_init_msg_list                     => G_FALSE,
524       p_commit                            => G_FALSE,
525       p_object_version_number             => l_task_rec_tbl(i).object_version_number,
526       p_task_id                           => l_task_rec_tbl(i).id,
527       p_task_name                         => l_task_name,
528       p_task_type_name                    => l_type,
529       p_description                       => l_description,
530       p_task_status_name                  => l_status,
531       p_task_priority_name                => l_priority,
532       p_owner_type_code                   => l_owner_type_code,
533       p_owner_id                          => l_owner_id,
534       p_planned_start_date                => l_planned_start,
535       p_planned_end_date                  => l_planned_end,
536       p_scheduled_start_date              => l_sched_start,
537       p_scheduled_end_date                => l_sched_end,
538       p_actual_start_date                 => l_actual_start,
539       p_actual_end_date                   => l_actual_end,
540       x_return_status                     => l_return_status,
541       x_msg_count                         => l_msg_count,
542       x_msg_data                          => l_msg_data
543     );
544 
545     --if call fails, break out of loop
546     IF NOT (l_return_status = G_SUCCESS) THEN
547       --INSERT  INTO msista_Tmp values (60, 'update_task failed, ret_status - ' || l_return_status);
548       --INSERT  INTO msista_Tmp values (60, 'update_task failed, msg_count - ' || l_msg_count);
549       --INSERT  INTO msista_Tmp values (60, 'update_task failed, msg_data - ' || l_msg_data);
550       --commit;
551 
552       --fnd_msg_pub.count_and_get (
553       --  p_count => l_msg_count,
554       --  p_data => l_msg_data
555       --);
556       --INSERT  INTO msista_Tmp values (60, 'update_task failed, msg_count - ' || l_msg_count);
557       --INSERT  INTO msista_Tmp values (60, 'update_task failed, msg_data - ' || l_msg_data);
558       --commit;
559 
560       RAISE fail_exception;
561     ELSE
562       --INSERT  INTO msista_Tmp values (60, 'update_task OK, ret_status - ' || l_return_status);
563       --commit;
564 
565       NULL;
566     END IF;
567 
568     -- if task assignment is being modified, it has to be dealt with separately
569     IF (l_assignee IS NOT NULL) THEN
570       /*
571        to do
572        a. delete all existing assignments
573        b. assign task to specified assignee
574        c. --commit
575       */
576       -- a
577       OPEN c_task_ass (l_task_rec_tbl(i).id);
578       LOOP
579         FETCH c_task_ass INTO l_exist_assign_id, l_exist_assign_ver;
580 
581         -- not a problem if task is not currently assigned, exit loop.
582         IF c_task_ass%FOUND THEN
583 
584           --INSERT  INTO msista_Tmp values (62, 'deleting task_assignment - ' || l_exist_assign_id);
585           --commit;
586 
587           -- delete assignments one by one
588 	  -- Commented the code by spamujul for 13386660
589          /* jtf_task_assignments_pub.delete_task_assignment(
590             p_api_version             => l_api_version,
591             p_object_version_number   => l_exist_assign_ver,
592             p_init_msg_list           => G_FALSE,
593             p_commit                  => G_FALSE,
594             p_task_assignment_id      => l_exist_assign_id,
595             x_return_status           => l_return_status,
596             x_msg_count               => l_msg_count,
597             x_msg_data                => l_msg_data
598           );
599 	  */
600 	  -- Added the below code by spamujul for Bug 13386660
601 	  jtf_task_assignments_pub.update_task_assignment
602 	   (
603 		p_api_version		  => l_api_version,
604 		p_object_version_number   => l_exist_assign_ver,
605 		p_init_msg_list           => G_FALSE,
606 		p_commit                  => G_FALSE,
607 		p_task_assignment_id      => l_exist_assign_id,
608 		p_task_id                 => l_task_rec_tbl(i).id,
609 		p_task_name               => l_task_name,
610 	        p_resource_type_code	  => l_assignee_type_code,
611 		p_resource_id		  => l_assignee_id,
612 		p_resource_name		  => l_assignee,
613 		x_return_status           => l_return_status,
614 	        x_msg_count               => l_msg_count,
615 		x_msg_data                => l_msg_data	);
616 	  -- End of Code change by spamujul for Bug 13386660
617 
618           IF NOT (l_return_status = G_SUCCESS) THEN
619             --INSERT  INTO msista_Tmp values (62, 'delete_task_assignment failed, ret_status - ' || l_return_status);
620             --INSERT  INTO msista_Tmp values (62, 'delete_task_assignment failed, msg_count - ' || l_msg_count);
621             --INSERT  INTO msista_Tmp values (62, 'delete_task_assignment failed, msg_data - ' || l_msg_data);
622             --commit;
623 
624             RAISE fail_exception;
625           ELSE
626             --INSERT  INTO msista_Tmp values (62, 'delete_task_assignment OK, ret_status - ' || l_return_status);
627             --commit;
628 
629 	    NULL;
630           END IF;
631         ELSE
632           EXIT;
633         END IF;
634       END LOOP;
635 
636       IF (c_task_ass%ISOPEN) THEN
637         CLOSE c_task_ass;
638       END IF;
639 
640       -- b
641       jtf_task_assignments_pub.create_task_assignment(
642         p_api_version                 => l_api_version,
643         p_init_msg_list               => G_FALSE,
644         p_commit                      => G_FALSE,
645         p_task_id                     => l_task_rec_tbl(i).id,
646         p_resource_type_code          => l_assignee_type_code,
647         p_resource_id                 => l_assignee_id,
648         p_assignment_status_id        => l_new_assign_status,
649         x_return_status               => l_return_status,
650         x_msg_count                   => l_msg_count,
651         x_msg_data                    => l_msg_data,
652         x_task_assignment_id          => l_new_assign_id,
653         p_show_on_calendar            => G_YES
654       );
655 
656       IF NOT (l_return_status = G_SUCCESS) THEN
657         --INSERT  INTO msista_Tmp values (64, 'create_task_assignment failed, ret_status - ' || l_return_status);
658         --INSERT  INTO msista_Tmp values (64, 'create_task_assignment failed, msg_count - ' || l_msg_count);
659         --INSERT  INTO msista_Tmp values (64, 'create_task_assignment failed, msg_data - ' || l_msg_data);
660         --commit;
661 
662         RAISE fail_exception;
663       ELSE
664         --INSERT  INTO msista_Tmp values (64, 'create_task_assignment OK, ret_status - ' || l_return_status);
665         --commit;
666 
667 	NULL;
668       END IF;
669     END IF;
670 
671     -- next, if there is note data to be applied
672     -- call note creation api
673     IF (l_p_note IS NOT NULL) THEN
674       -- by default the note has to be related to the task
675       l_note_ctxt_idx := 1;
676       l_note_ctxt_tbl(l_note_ctxt_idx).NOTE_CONTEXT_TYPE := l_src_task;
677       l_note_ctxt_tbl(l_note_ctxt_idx).NOTE_CONTEXT_TYPE_ID := l_task_rec_tbl(i).id;
678       l_note_ctxt_idx := l_note_ctxt_idx+1;
679 
680       jtf_notes_pub.create_note(
681           -- p_parent_note_id    => fnd_api.g_miss_num,
682           -- p_jtf_note_id            => fnd_api.g_miss_num,
683           p_api_version           => l_api_version,
684           p_init_msg_list         => G_FALSE,
685           p_commit                => G_FALSE,
686           p_validation_level      =>  l_valid_level_full,
687           x_return_status         => l_return_status,
688           x_msg_count             => l_msg_count,
689           x_msg_data              => l_msg_data,
690           -- p_org_id               =>   NULL,
691           p_source_object_id      => l_task_rec_tbl(i).id,
692           p_source_object_code    => l_src_task,
693           p_notes                 => l_p_note
694           --, p_notes_detail          => NULL
695           , p_note_status           => 'I'
696           ,p_entered_date          => TO_DATE('1','j'),
697           x_jtf_note_id           => l_note_id
698           , p_last_update_date      => TO_DATE('1','j')
699           , p_last_updated_by       => fnd_global.user_id
700           , p_creation_date         => TO_DATE('1','j')
701           --, p_created_by            => fnd_global.user_id
702           --, p_last_update_login     => fnd_global.login_id
703           /*, p_attribute1            => NULL
704           , p_attribute2            => NULL
705           , p_attribute3            => NULL
706           , p_attribute4            => NULL
707           , p_attribute5            => NULL
708           , p_attribute6            => NULL
709           , p_attribute7            => NULL
710           , p_attribute8            => NULL
711           , p_attribute9            => NULL
712           , p_attribute10           => NULL
713           , p_attribute11           => NULL
714           , p_attribute12           => NULL
715           , p_attribute13           => NULL
716           , p_attribute14           => NULL
717           , p_attribute15           => NULL
718           , p_context               => NULL
719           , p_note_type             => NULL*/,
720           p_jtf_note_contexts_tab => l_note_ctxt_tbl
721           ,        p_entered_by            => G_USER_ID
722       );
723 
724       IF NOT (l_return_status = G_SUCCESS) THEN
725         RAISE fail_exception;
726       ELSE
727         -- we have to do some additional work if 'auto-relate note' is true
728         IF (FND_PROFILE.VALUE('IEU_AUTO_RELATED') = 'Y') THEN -- this is for source document
729 	  l_continue := 0;
730 	  select count(source_object_id) into l_continue
731 	  from jtf_tasks_b
732 	  where task_id = l_task_rec_tbl(i).id;
733 
734           if (l_continue > 0) then
735 		  select source_object_id into l_note_context_type_id
736 		  from jtf_tasks_b
737 		  where task_id = l_task_rec_tbl(i).id;
738           else l_note_context_type_id := null;
739           end if;
740 
741           OPEN c_task_src(l_task_rec_tbl(i).id);
742           FETCH c_task_src INTO l_obj_type_code;
743 
744           -- if the source object type of the task is registered for notes usage,
745           -- create a note context for
746           IF (c_task_src%FOUND) THEN
747            if (l_note_context_type_id is not null) then
748 		    jtf_notes_pub.Create_note_context
749 		    ( p_validation_level     => l_valid_level_full,
750 		      p_jtf_note_id          => l_note_id,
751 		      p_last_update_date     => FND_API.G_MISS_DATE,
752 		      p_last_updated_by      => G_USER_ID,
753 		      p_creation_date        => FND_API.G_MISS_DATE,
754 		      p_note_context_type_id => l_note_context_type_id,
755 		      p_note_context_type    => l_obj_type_code,
756 		      x_return_status        => l_return_status,
757 		      x_note_context_id      => l_context_id
758 		    );
759 
760 
761 		    IF NOT (l_return_status = G_SUCCESS) THEN
762 		      RAISE fail_exception;
763 		    ELSE
764 		      NULL;
765 		    END IF;
766 	   end if;
767           END IF; -- if cursor%found
768 
769           IF (c_task_src%ISOPEN) THEN
770             CLOSE c_task_src;
771           END IF;
772 
773         END IF; -- auto_relate = 1
774 
775 	IF (FND_PROFILE.VALUE('AS_NOTES_LEAD_CUSTOMER') = 'Y') THEN
776 	  l_continue := 0;
777 	  select count(customer_id) into l_continue
778 	  from jtf_tasks_b
779 	  where task_id = l_task_rec_tbl(i).id;
780 
781           if (l_continue > 0) then
782 		  select customer_id into l_note_context_type_id
783 		  from jtf_tasks_b
784 		  where task_id = l_task_rec_tbl(i).id;
785           else l_note_context_type_id := null;
786           end if;
787 
788           OPEN c_task_src(l_task_rec_tbl(i).id);
789           FETCH c_task_src INTO l_obj_type_code;
790 
791           -- if the source object type of the task is registered for notes usage,
792           -- create a note context for
793 	  if (l_obj_type_code = 'LEAD'  ) then
794 		  IF (c_task_src%FOUND) THEN
795 			  if (l_note_context_type_id is not null) then
796 				    jtf_notes_pub.Create_note_context
797 				    ( p_validation_level     => l_valid_level_full,
798 				      p_jtf_note_id          => l_note_id,
799 				      p_last_update_date     => FND_API.G_MISS_DATE,
800 				      p_last_updated_by      => G_USER_ID,
801 				      p_creation_date        => FND_API.G_MISS_DATE,
802 				      p_note_context_type_id => l_note_context_type_id,
803 				      p_note_context_type    => 'PARTY',
804 				      x_return_status        => l_return_status,
805 				      x_note_context_id      => l_context_id
806 				    );
807 
808 
809 				    IF NOT (l_return_status = G_SUCCESS) THEN
810 				      RAISE fail_exception;
811 				    ELSE
812 				      NULL;
813 				    END IF;
814 			  end if;
815 		   end if;-- if c_task_src%FOUND
816           END IF; -- l_obj_type_code = 'LEAD'
817 
818           IF (c_task_src%ISOPEN) THEN
819             CLOSE c_task_src;
820           END IF;
821 
822         END IF; -- if AS_NOTES_LEAD_CUSTOMER
823 
824 
825 	IF (FND_PROFILE.VALUE('AS_NOTES_LEAD_CONTACT') = 'Y') THEN
826           --INSERT  INTO msista_Tmp values (70, 'auto related profile is YES' );
827           --commit;
828           l_continue := 0;
829 	  for c2_rec in  C_note_context_id (l_task_rec_tbl(i).id)
830 		LOOP
831                     if l_continue = 0 then
832 		       l_note_context_type_id := c2_rec.contact_id;
833 		       l_continue := l_continue +1;
834 		    end if;
835 	  end loop;
836 
837           OPEN c_task_src(l_task_rec_tbl(i).id);
838           FETCH c_task_src INTO l_obj_type_code;
839 
840           -- if the source object type of the task is registered for notes usage,
841           -- create a note context for
842 	  if ( l_obj_type_code = 'LEAD'  ) then
843 		  IF (c_task_src%FOUND) THEN
844 			  if (l_note_context_type_id is not null) then
845 				    jtf_notes_pub.Create_note_context
846 				    ( p_validation_level     => l_valid_level_full,
847 				      p_jtf_note_id          => l_note_id,
848 				      p_last_update_date     => FND_API.G_MISS_DATE,
849 				      p_last_updated_by      => G_USER_ID,
850 				      p_creation_date        => FND_API.G_MISS_DATE,
851 				      p_note_context_type_id => l_note_context_type_id,
852 				      p_note_context_type    => 'PARTY',
853 				      x_return_status        => l_return_status,
854 				      x_note_context_id      => l_context_id
855 				    );
856 
857 
858 				    IF NOT (l_return_status = G_SUCCESS) THEN
859 				      RAISE fail_exception;
860 				    ELSE
861 				      NULL;
862 				    END IF;
863 			   end if;
864 		   end if;-- if c_task_src%FOUND
865           END IF; -- if  l_obj_type_code = 'LEAD'
866 
867           IF (c_task_src%ISOPEN) THEN
868             CLOSE c_task_src;
869           END IF;
870 
871         END IF; -- IF (FND_PROFILE.VALUE('AS_NOTES_LEAD_CONTACT') = 'Y')
872 
873 	IF (FND_PROFILE.VALUE('AS_NOTES_OPP_CUSTOMER') = 'Y') THEN
874           --INSERT  INTO msista_Tmp values (70, 'auto related profile is YES' );
875           --commit;
876           l_continue := 0;
877           select count(customer_id) into l_continue
878 	  from jtf_tasks_b
879           where task_id = l_task_rec_tbl(i).id;
880 
881 	  if (l_continue > 0) then
882               select customer_id into l_note_context_type_id
883               from jtf_tasks_b
884               where task_id = l_task_rec_tbl(i).id;
885           else l_note_context_type_id := null;
886           end if;
887 
888           OPEN c_task_src(l_task_rec_tbl(i).id);
889           FETCH c_task_src INTO l_obj_type_code;
890 
891           -- if the source object type of the task is registered for notes usage,
892           -- create a note context for
893 	  if (l_obj_type_code = 'OPPORTUNITY'  ) then
894 		  IF (c_task_src%FOUND) THEN
895 			  if (l_note_context_type_id is not null) then
896 			    jtf_notes_pub.Create_note_context
897 			    ( p_validation_level     => l_valid_level_full,
898 			      p_jtf_note_id          => l_note_id,
899 			      p_last_update_date     => FND_API.G_MISS_DATE,
900 			      p_last_updated_by      => G_USER_ID,
901 			      p_creation_date        => FND_API.G_MISS_DATE,
902 			      p_note_context_type_id => l_note_context_type_id,
903 			      p_note_context_type    => 'PARTY',
904 			      x_return_status        => l_return_status,
905 			      x_note_context_id      => l_context_id
906 			    );
907 
908 
909 			    IF NOT (l_return_status = G_SUCCESS) THEN
910 			      --INSERT  INTO msista_Tmp values (74, 'create_note_context failed, ret_status - ' || l_return_status);
911 			      --INSERT  INTO msista_Tmp values (74, 'create_note_context failed, msg_count - ' || l_msg_count);
912 			      --INSERT  INTO msista_Tmp values (74, 'create_note_context failed, msg_data - ' || l_msg_data);
913 			      --commit;
914 
915 			      RAISE fail_exception;
916 			    ELSE
917 			      NULL;
918 			    END IF;
919 			  end if;
920 		  end if;-- if c_task_src%FOUND.
921           END IF; -- if l_obj_type_code = 'OPPORTUNITY'
922 
923           IF (c_task_src%ISOPEN) THEN
924             CLOSE c_task_src;
925           END IF;
926 
927         END IF; -- IF (FND_PROFILE.VALUE('AS_NOTES_OPP_CUSTOMER') = 'Y')
928 
929 
930 	IF (FND_PROFILE.VALUE('AS_NOTES_OPP_CONTACT') = 'Y') THEN
931           --INSERT  INTO msista_Tmp values (70, 'auto related profile is YES' );
932           --commit;
933           l_continue := 0;
934 	  for c2_rec in  C_note_context_id (l_task_rec_tbl(i).id)
935 		LOOP
936                     if l_continue = 0 then
937 		       l_note_context_type_id := c2_rec.contact_id;
938 		       l_continue := l_continue +1;
939 		    end if;
940 		end loop;
941 
942           OPEN c_task_src(l_task_rec_tbl(i).id);
946           -- create a note context for
943           FETCH c_task_src INTO l_obj_type_code;
944 
945           -- if the source object type of the task is registered for notes usage,
947 	  if ( l_obj_type_code = 'OPPORTUNITY'  ) then
948 		  IF (c_task_src%FOUND) THEN
949 			  if (l_note_context_type_id is not null) then
950 			    jtf_notes_pub.Create_note_context
951 			    ( p_validation_level     => l_valid_level_full,
952 			      p_jtf_note_id          => l_note_id,
953 			      p_last_update_date     => FND_API.G_MISS_DATE,
954 			      p_last_updated_by      => G_USER_ID,
955 			      p_creation_date        => FND_API.G_MISS_DATE,
956 			      p_note_context_type_id => l_note_context_type_id,
957 			      p_note_context_type    => 'PARTY',
958 			      x_return_status        => l_return_status,
959 			      x_note_context_id      => l_context_id
960 			    );
961 
962 
963 			    IF NOT (l_return_status = G_SUCCESS) THEN
964 
965 			      RAISE fail_exception;
966 			    ELSE
967 			      NULL;
968 			    END IF;
969 			  end if;
970 		  end if;-- if lead...
971           END IF; -- if cursor%found
972 
973           IF (c_task_src%ISOPEN) THEN
974             CLOSE c_task_src;
975           END IF;
976         END IF; -- IF (FND_PROFILE.VALUE('AS_NOTES_OPP_CONTACT') = 'Y')
977 
978 	IF (FND_PROFILE.VALUE('AS_NOTES_REL_OBJECT') = 'Y') THEN
979 		l_continue := 0;
980 		select count(a.object_id) into l_continue
981 		from hz_relationships a, hz_parties b
982 		where b.party_type = 'PARTY_RELATIONSHIP'
983 		      and a.party_id in (select source_object_id
984 						from jtf_tasks_b
985 						where task_id = l_task_rec_tbl(i).id)
986 		      and a.party_id = b.party_id
987 		      and a.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
988 		      AND a.OBJECT_TABLE_NAME = 'HZ_PARTIES'
989 		      AND DIRECTIONAL_FLAG = 'F';
990 
991 		if (l_continue > 0) then
992 		 select a.object_id into l_note_context_type_id
993 		 from hz_relationships a, hz_parties b
994 		 where b.party_type = 'PARTY_RELATIONSHIP'
995 		       and a.party_id  in (select source_object_id
996 						from jtf_tasks_b
997 						where task_id = l_task_rec_tbl(i).id)
998 		       and a.party_id = b.party_id
999       		       and a.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
1000 		       AND a.OBJECT_TABLE_NAME = 'HZ_PARTIES'
1001 		       AND DIRECTIONAL_FLAG = 'F';
1002 
1003 		else l_note_context_type_id :=null;
1004 		end if ;
1005 
1006 	        OPEN c_task_src(l_task_rec_tbl(i).id);
1007 		FETCH c_task_src INTO l_obj_type_code;
1008 
1009 		-- if the source object type of the task is registered for notes usage,
1010 		-- create a note context for
1011 		if (l_obj_type_code = 'PARTY'  ) then
1012 			  IF (c_task_src%FOUND) THEN
1013 				  if (l_note_context_type_id is not null) then
1014 				   jtf_notes_pub.Create_note_context
1015 				    ( p_validation_level     => l_valid_level_full,
1016 				      p_jtf_note_id          => l_note_id,
1017 				      p_last_update_date     => FND_API.G_MISS_DATE,
1018 				      p_last_updated_by      => G_USER_ID,
1019 				      p_creation_date        => FND_API.G_MISS_DATE,
1020 				      p_note_context_type_id => l_note_context_type_id,
1021 				      p_note_context_type    => 'PARTY',
1022 				      x_return_status        => l_return_status,
1023 				      x_note_context_id      => l_context_id
1024 				    );
1025 
1026 
1027 				    IF NOT (l_return_status = G_SUCCESS) THEN
1028 				      RAISE fail_exception;
1029 				    ELSE
1030 				      NULL;
1031 				    END IF;
1032 				  end if;
1033 		          end if;-- if lead...
1034                 END IF; -- if cursor%found
1035 
1036 		IF (c_task_src%ISOPEN) THEN
1037 		    CLOSE c_task_src;
1038 		END IF;
1039         END IF; --IF (FND_PROFILE.VALUE('AS_NOTES_REL_OBJECT') = 'Y')
1040 
1041 
1042 	IF (FND_PROFILE.VALUE('AS_NOTES_REL_SUBJECT') = 'Y') THEN
1043 	 l_continue := 0;
1044 	 select count(a.subject_id) into l_continue
1045          from hz_relationships a, hz_parties b
1046          where b.party_type = 'PARTY_RELATIONSHIP'
1047 	            and a.party_id = (select source_object_id
1048 	                        from jtf_tasks_b
1049 				where task_id = l_task_rec_tbl(i).id)
1050 		    and a.party_id = b.party_id
1051 		    and a.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
1052 		    AND a.OBJECT_TABLE_NAME = 'HZ_PARTIES'
1053 		    AND DIRECTIONAL_FLAG = 'F';
1054 
1055          if (l_continue > 0) then
1056            select a.subject_id into l_note_context_type_id
1057            from hz_relationships a, hz_parties b
1058            where b.party_type = 'PARTY_RELATIONSHIP'
1059 	            and a.party_id = (select source_object_id
1060 	                        from jtf_tasks_b
1061 				where task_id = l_task_rec_tbl(i).id)
1062 		    and a.party_id = b.party_id
1063 		    and a.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
1064 		    AND a.OBJECT_TABLE_NAME = 'HZ_PARTIES'
1065 		    AND DIRECTIONAL_FLAG = 'F';
1066 
1067           else l_note_context_type_id := null;
1068           end if;
1069 
1070           OPEN c_task_src(l_task_rec_tbl(i).id);
1071           FETCH c_task_src INTO l_obj_type_code;
1072 
1073           -- if the source object type of the task is registered for notes usage,
1074           -- create a note context for
1075 	  if ( l_obj_type_code = 'PARTY'  ) then
1076 		  IF (c_task_src%FOUND) THEN
1077 			  if (l_note_context_type_id is not null) then
1078 			   jtf_notes_pub.Create_note_context
1079 			    ( p_validation_level     => l_valid_level_full,
1080 			      p_jtf_note_id          => l_note_id,
1081 			      p_last_update_date     => FND_API.G_MISS_DATE,
1082 			      p_last_updated_by      => G_USER_ID,
1083 			      p_creation_date        => FND_API.G_MISS_DATE,
1084 			      p_note_context_type_id => l_note_context_type_id,
1085 			      p_note_context_type    => 'PARTY',
1086 			      x_return_status        => l_return_status,
1087 			      x_note_context_id      => l_context_id
1088 			    );
1089 
1090 
1091 			    IF NOT (l_return_status = G_SUCCESS) THEN
1092 			      RAISE fail_exception;
1093 			    ELSE
1094 			      NULL;
1095 			    END IF;
1096 		          end if;
1097 		  end if;-- if lead...
1098           END IF; -- if cursor%found
1099 
1100           IF (c_task_src%ISOPEN) THEN
1101             CLOSE c_task_src;
1102           END IF;
1103         END IF; -- if FND_PROFILE.VALUE('AS_NOTES_REL_SUBJECT') = 'Y')
1104       END IF; -- if create_note ok
1105     END IF; -- IF (l_note IS NOT NULL)
1106 
1107     -- continue with rest of task items
1108   END LOOP; -- FOR i IN 1..l_count
1109 
1110   -- Set UWQ Actions Data if all is OK
1111   l_uwq_actions_list(1).uwq_action_key := 'UWQ_WORK_DETAILS_REFRESH';
1112   l_uwq_actions_list(1).Action_data := '' ;
1113   l_uwq_actions_list(1).dialog_style := 1 ;
1114   l_uwq_actions_list(1).message := '' ;
1115 
1116   IEU_UWQ_WORK_PANEL_PUB.SET_UWQ_ACTIONS(l_uwq_actions_list,
1117                                          x_uwq_action_list) ;
1118 
1119   x_return_status := G_SUCCESS;
1120 
1121   -- everything went A-OK
1122   commit WORK;
1123 
1124   EXCEPTION
1125 
1126     -- all exceptions are the same for now
1127     WHEN null_fail_exception THEN
1128       x_return_status := G_UNEXP_ERROR;
1129 
1130       fnd_message.set_name ('IEU', 'IEU_STATUS_TYPE_FAIL');
1131       fnd_msg_pub.add;
1132       x_return_status := fnd_api.g_ret_sts_unexp_error;
1133       fnd_msg_pub.count_and_get (
1134         p_count => x_msg_count,
1135         p_data => x_msg_data
1136       );
1137 
1138     WHEN name_fail_exception THEN
1139       x_return_status := G_UNEXP_ERROR;
1140 
1141       fnd_message.set_name ('IEU', 'IEU_TASK_NAME_FAIL');
1142       fnd_msg_pub.add;
1143       x_return_status := fnd_api.g_ret_sts_unexp_error;
1144       fnd_msg_pub.count_and_get (
1145         p_count => x_msg_count,
1146         p_data => x_msg_data
1147       );
1148 
1149     WHEN fail_exception THEN
1150       x_return_status := G_UNEXP_ERROR;
1151       --fnd_message.set_name ('IEU', 'IEU_STATUS_TYPE_FAIL');
1152       if (l_msg_count is null) or (l_msg_count < 1) then
1153       fnd_message.set_name ('IEU', 'IEU_UPDATE_TASK_FAIL');
1154       fnd_msg_pub.add;
1155       x_return_status := fnd_api.g_ret_sts_unexp_error;
1156       fnd_msg_pub.count_and_get (
1157         p_count => x_msg_count,
1158         p_data => x_msg_data
1159       );
1160    end if;
1161     WHEN OTHERS THEN
1162 
1163       -- rollback disabled until this works right, there is a --commit at the end
1164       -- roll back always
1165       ROLLBACK TO update_task_savepoint;
1166 
1167       x_return_status := G_UNEXP_ERROR;
1168 
1169       fnd_message.set_name ('IEU', 'IEU_UPDATE_TASK_FAIL');
1170       fnd_msg_pub.add;
1171 
1172       fnd_msg_pub.count_and_get (
1173         p_count => x_msg_count,
1174         p_data => x_msg_data
1175       );
1176 
1177 END WP_TASK; -- PROCEDURE WP_TASK
1178 
1179 PROCEDURE CLOSE_TASK
1180 ( P_RESOURCE_ID       IN NUMBER,
1181   P_LANGUAGE          IN VARCHAR2,
1182   P_SOURCE_LANG       IN VARCHAR2,
1183   P_ACTION_KEY        IN VARCHAR2,
1184   P_ACTION_INPUT_DATA IN SYSTEM.ACTION_INPUT_DATA_NST,
1185   X_UWQ_ACTION_LIST   OUT NOCOPY SYSTEM.IEU_UWQ_WORK_ACTIONS_NST,
1186   X_MSG_COUNT         OUT NOCOPY NUMBER,
1187   X_MSG_DATA          OUT NOCOPY VARCHAR2,
1188   X_RETURN_STATUS     OUT NOCOPY VARCHAR2
1189 )
1190 IS
1191 BEGIN
1192   IEU_WPACTIONS_PVT.WP_TASK(P_RESOURCE_ID,
1193 			P_LANGUAGE   ,
1194 			P_SOURCE_LANG,
1195 			P_ACTION_KEY ,
1196 			P_ACTION_INPUT_DATA ,
1197 			'CLOSE_TASK',
1198 			X_UWQ_ACTION_LIST  ,
1199 			X_MSG_COUNT        ,
1200 			X_MSG_DATA         ,
1201 			X_RETURN_STATUS);
1202 
1203 END CLOSE_TASK; -- PROCEDURE CLOSE_TASK
1204 
1205 
1206 PROCEDURE UPDATE_TASK
1207 ( P_RESOURCE_ID       IN NUMBER,
1208   P_LANGUAGE          IN VARCHAR2,
1209   P_SOURCE_LANG       IN VARCHAR2,
1210   P_ACTION_KEY        IN VARCHAR2,
1211   P_ACTION_INPUT_DATA IN SYSTEM.ACTION_INPUT_DATA_NST,
1212   X_UWQ_ACTION_LIST   OUT NOCOPY SYSTEM.IEU_UWQ_WORK_ACTIONS_NST,
1213   X_MSG_COUNT         OUT NOCOPY NUMBER,
1214   X_MSG_DATA          OUT NOCOPY VARCHAR2,
1215   X_RETURN_STATUS     OUT NOCOPY VARCHAR2
1216 )
1217 IS
1218 BEGIN
1219   IEU_WPACTIONS_PVT.WP_TASK(P_RESOURCE_ID,
1220 			P_LANGUAGE   ,
1221 			P_SOURCE_LANG,
1222 			P_ACTION_KEY ,
1223 			P_ACTION_INPUT_DATA ,
1224 			'UPDATE_TASK',
1225 			X_UWQ_ACTION_LIST  ,
1226 			X_MSG_COUNT        ,
1227 			X_MSG_DATA         ,
1228 			X_RETURN_STATUS);
1229 
1230 END UPDATE_TASK; -- PROCEDURE UPDATE_TASK
1231 
1232 PROCEDURE REASSIGN_TASK
1233 ( P_RESOURCE_ID       IN NUMBER,
1234   P_LANGUAGE          IN VARCHAR2,
1235   P_SOURCE_LANG       IN VARCHAR2,
1236   P_ACTION_KEY        IN VARCHAR2,
1237   P_ACTION_INPUT_DATA IN SYSTEM.ACTION_INPUT_DATA_NST,
1238   X_UWQ_ACTION_LIST   OUT NOCOPY SYSTEM.IEU_UWQ_WORK_ACTIONS_NST,
1239   X_MSG_COUNT         OUT NOCOPY NUMBER,
1240   X_MSG_DATA          OUT NOCOPY VARCHAR2,
1241   X_RETURN_STATUS     OUT NOCOPY VARCHAR2
1242 )
1243 IS
1244 BEGIN
1245   IEU_WPACTIONS_PVT.WP_TASK(P_RESOURCE_ID,
1246 			P_LANGUAGE   ,
1247 			P_SOURCE_LANG,
1248 			P_ACTION_KEY ,
1249 			P_ACTION_INPUT_DATA ,
1250 			'REASSIGN_TASK',
1251 			X_UWQ_ACTION_LIST  ,
1252 			X_MSG_COUNT        ,
1253 			X_MSG_DATA         ,
1254 			X_RETURN_STATUS);
1255 
1256 END REASSIGN_TASK; -- PROCEDURE REASSIGN_TASK
1257 
1258 PROCEDURE RESCHEDULE_TASK
1259 ( P_RESOURCE_ID       IN NUMBER,
1260   P_LANGUAGE          IN VARCHAR2,
1261   P_SOURCE_LANG       IN VARCHAR2,
1262   P_ACTION_KEY        IN VARCHAR2,
1263   P_ACTION_INPUT_DATA IN SYSTEM.ACTION_INPUT_DATA_NST,
1264   X_UWQ_ACTION_LIST   OUT NOCOPY SYSTEM.IEU_UWQ_WORK_ACTIONS_NST,
1265   X_MSG_COUNT         OUT NOCOPY NUMBER,
1266   X_MSG_DATA          OUT NOCOPY VARCHAR2,
1267   X_RETURN_STATUS     OUT NOCOPY VARCHAR2
1268 )
1269 IS
1270 BEGIN
1271   IEU_WPACTIONS_PVT.WP_TASK(P_RESOURCE_ID,
1272 			P_LANGUAGE   ,
1273 			P_SOURCE_LANG,
1274 			P_ACTION_KEY ,
1275 			P_ACTION_INPUT_DATA ,
1276 			'RESCHEDULE_TASK',
1277 			X_UWQ_ACTION_LIST  ,
1278 			X_MSG_COUNT        ,
1279 			X_MSG_DATA         ,
1280 			X_RETURN_STATUS);
1281 
1282 END RESCHEDULE_TASK; -- PROCEDURE RESCHEDULE_TASK
1283 
1284 PROCEDURE TRANSFER_TASK_OWNER_TASK
1285 ( P_RESOURCE_ID       IN NUMBER,
1286   P_LANGUAGE          IN VARCHAR2,
1287   P_SOURCE_LANG       IN VARCHAR2,
1288   P_ACTION_KEY        IN VARCHAR2,
1289   P_ACTION_INPUT_DATA IN SYSTEM.ACTION_INPUT_DATA_NST,
1290   X_UWQ_ACTION_LIST   OUT NOCOPY SYSTEM.IEU_UWQ_WORK_ACTIONS_NST,
1291   X_MSG_COUNT         OUT NOCOPY NUMBER,
1292   X_MSG_DATA          OUT NOCOPY VARCHAR2,
1293   X_RETURN_STATUS     OUT NOCOPY VARCHAR2
1294 )
1295 IS
1296 BEGIN
1297   IEU_WPACTIONS_PVT.WP_TASK(P_RESOURCE_ID,
1298 			P_LANGUAGE   ,
1299 			P_SOURCE_LANG,
1300 			P_ACTION_KEY ,
1301 			P_ACTION_INPUT_DATA ,
1302 			'TRANSFER_TASK_OWNER_TASK',
1303 			X_UWQ_ACTION_LIST  ,
1304 			X_MSG_COUNT        ,
1305 			X_MSG_DATA         ,
1306 			X_RETURN_STATUS);
1307 
1308 END TRANSFER_TASK_OWNER_TASK; -- PROCEDURE TRANSFER_TASK_OWNER_TASK
1309 
1310 end IEU_WPACTIONS_PVT;