DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_TASK_REPEAT_ASSIGNMENT_PVT

Source


1 PACKAGE BODY jtf_task_repeat_assignment_pvt AS
2 /* $Header: jtfvtkcb.pls 120.1.12000000.2 2007/07/19 08:42:29 lokumar ship $ */
3 /*======================================================================+
4 |  Copyright (c) 1995 Oracle Corporation Redwood Shores, California, USA|
5 |                            All rights reserved.                       |
6 +=======================================================================+
7 | FILENAME                                                              |
8 |   jtftkcb.pls                                                         |
9 |                                                                       |
10 | DESCRIPTION                                                           |
11 |   This package is used to process the repsone of assignee's response  |
12 |    in repeating appointment.                                          |
13 |   The assignee can accept or reject either a specific appointment or  |
14 |        all the appointments among repeating appointments.             |
15 |                                                                       |
16 |   Action     assignment_status_id                                     |
17 |   ========== ======================                                   |
18 |   REJECT ALL          4                                               |
19 |   ACCEPT ALL          3                                               |
20 |                                                                       |
21 |   The possible value for add_option:                                  |
22 |       T: Add a new invitee to all the future appointments             |
23 |       A: Add a new invitee to all appointments                        |
24 |       F: Add a new invitee to the current selected appointment only   |
25 |       N: Skip the new functionality                                   |
26 |                                                                       |
27 |   The possible value for delete_option:                               |
28 |       T: Delete a new invitee from all the future appointments        |
29 |       A: Delete a new invitee from all appointments                   |
30 |       F: Delete a new invitee from the current selected appointment   |
31 |       N: Skip the new functionality                                   |
32 |                                                                       |
33 | NOTES                                                                 |
34 |                                                                       |
35 | Date          Developer        Change                                 |
36 |------         ---------------  ---------------------------------------|
37 | 28-Mar-2002   cjang            Created                                |
38 | 29-Mar-2002   cjang            Added response_invitation_rec          |
39 |                                      add_assignee_rec                 |
40 |                                      delete_assignee_rec              |
41 |                                      add_assignee_rec                 |
42 |                                      add_assignee_rec                 |
43 |                                      add_assignee                     |
44 |                                      delete_assignee                  |
45 |                                Modified response_invitation           |
46 | 02-Apr-2002   cjang            Modified                               |
47 | 03-Apr-2002   cjang            Fixed so as to update last_update_date |
48 | 09-Apr-2002   cjang            Update object_changed_date with SYSDATE|
49 |                                      in jtf_tasks_b                   |
50 | 10-Apr-2002   cjang        A user is NOT allowed to accept one of     |
51 |                              occurrences.                             |
52 |                            He/She can either accept all or reject all.|
53 |                            The "update_all" and "calendar_start_date" |
54 |                              in response_invitation_rec is removed.   |
55 | 28-Apr-2002   cjang        Modified the package name to refer the     |
56 |                            followings:                                |
57 |                              - is_this_first_task                     |
58 |                              - get_new_first_taskid                   |
59 |                              - exist_syncid                           |
60 |                              from jtf_task_utl to jta_sync_task_utl   |
61 *=======================================================================*/
62 
63     PROCEDURE response_invitation(
64         p_api_version             IN     NUMBER,
65         p_init_msg_list           IN     VARCHAR2 DEFAULT fnd_api.g_false,
66         p_commit                  IN     VARCHAR2 DEFAULT fnd_api.g_false,
67         p_object_version_number   IN OUT NOCOPY NUMBER,
68         p_response_invitation_rec IN     response_invitation_rec,
69         x_return_status           OUT NOCOPY    VARCHAR2,
70         x_msg_count               OUT NOCOPY    NUMBER,
71         x_msg_data                OUT NOCOPY    VARCHAR2
72     )
73     IS
74         CURSOR c_assignments (b_recurrence_rule_id NUMBER
75                             , b_task_assignment_id NUMBER)
76         IS
77         SELECT jtb.task_id
78              , jtaa.task_assignment_id
79              , jtaa.object_version_number
80           FROM jtf_task_all_assignments jtaa
81              , jtf_tasks_b jtb
82              , jtf_task_all_assignments rs
83          WHERE jtb.recurrence_rule_id = b_recurrence_rule_id
84            AND rs.task_assignment_id  = b_task_assignment_id
85            AND jtaa.task_id     = jtb.task_id
86            AND jtaa.resource_id = rs.resource_id;
87 
88         l_object_version_number NUMBER := p_object_version_number;
89     BEGIN
90         SAVEPOINT response_invitation_pvt;
91 
92         x_return_status := fnd_api.g_ret_sts_success;
93 
94         IF fnd_api.to_boolean (p_init_msg_list)
95         THEN
96             fnd_msg_pub.initialize;
97         END IF;
98 
99         ----------------------------------------------------
100         FOR rec_assignments IN c_assignments(b_recurrence_rule_id  => p_response_invitation_rec.recurrence_rule_id
101                                            , b_task_assignment_id  => p_response_invitation_rec.task_assignment_id)
102         LOOP
103             l_object_version_number := rec_assignments.object_version_number;
104 
105             jtf_task_assignments_pvt.g_response_flag := jtf_task_utl.g_yes_char;
106 
107             jtf_task_assignments_pvt.update_task_assignment (
108                   p_api_version           => p_api_version,
109                   p_object_version_number => l_object_version_number,
110                   p_init_msg_list         => fnd_api.g_true,
111                   p_commit                => fnd_api.g_false,
112                   p_task_assignment_id    => rec_assignments.task_assignment_id,
113                   p_assignment_status_id  => p_response_invitation_rec.assignment_status_id,
114                   x_return_status         => x_return_status,
115                   x_msg_count             => x_msg_count,
116                   x_msg_data              => x_msg_data,
117                   p_enable_workflow       => 'N',
118                   p_abort_workflow        => 'N'
119             );
120 
121             IF NOT (x_return_status = fnd_api.g_ret_sts_success)
122             THEN
123                 x_return_status := fnd_api.g_ret_sts_unexp_error;
124                 RAISE fnd_api.g_exc_unexpected_error;
125             END IF;
126 
127             IF p_response_invitation_rec.task_id = rec_assignments.task_id
128             THEN
129                 p_object_version_number := l_object_version_number;
130             END IF;
131         END LOOP;
132         ----------------------------------------------------
133 
134         IF fnd_api.to_boolean (p_commit)
135         THEN
136             COMMIT WORK;
137         END IF;
138 
139         fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
140     EXCEPTION
141         WHEN fnd_api.g_exc_unexpected_error
142         THEN
143             ROLLBACK TO response_invitation_pvt;
144             x_return_status := fnd_api.g_ret_sts_unexp_error;
145             fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
146         WHEN OTHERS
147         THEN
148             ROLLBACK TO response_invitation_pvt;
149             fnd_message.set_name ('JTF', 'JTF_TASK_UNKNOWN_ERROR');
150             fnd_message.set_token ('P_TEXT', SQLCODE || SQLERRM);
151             fnd_msg_pub.add;
152             x_return_status := fnd_api.g_ret_sts_unexp_error;
153             fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
154     END response_invitation;
155 
156     PROCEDURE add_assignee(
157             p_api_version          IN  NUMBER,
158             p_init_msg_list        IN  VARCHAR2 DEFAULT fnd_api.g_false,
159             p_commit               IN  VARCHAR2 DEFAULT fnd_api.g_false,
160             p_add_assignee_rec     IN  add_assignee_rec,
161             x_return_status       OUT NOCOPY  VARCHAR2,
162             x_msg_count           OUT NOCOPY  NUMBER,
163             x_msg_data            OUT NOCOPY  VARCHAR2,
164             x_task_assignment_id  OUT NOCOPY  NUMBER
165     )
166     IS
167         CURSOR c_tasks (b_recurrence_rule_id NUMBER
168                        ,b_calendar_start_date DATE
169                        ,b_add_option VARCHAR2)
170         IS
171         SELECT task_id
172              , calendar_start_date
173           FROM jtf_tasks_b
174          WHERE recurrence_rule_id = b_recurrence_rule_id
175            AND ((b_add_option = JTF_TASK_REPEAT_APPT_PVT.G_ALL)   OR
176                 (b_add_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE AND calendar_start_date >= b_calendar_start_date) OR
177                 (b_add_option = JTF_TASK_REPEAT_APPT_PVT.G_ONE    AND calendar_start_date  = b_calendar_start_date));
178 
179         l_task_exclusion_id   NUMBER;
180 
181         CURSOR c_recur (b_recurrence_rule_id NUMBER) IS
182         SELECT *
183           FROM jtf_task_recur_rules
184          WHERE recurrence_rule_id = b_recurrence_rule_id;
185 
186         rec_recur   c_recur%ROWTYPE;
187 
188         l_rowid ROWID;
189         l_new_recurrence_rule_id NUMBER := NULL;
190         l_new_minimum_task_id    NUMBER := NULL;
191         l_first                  BOOLEAN := FALSE;
192         l_exist_new_first_task   BOOLEAN := FALSE;
193         l_sync_id NUMBER;
194 
195         l_add_option VARCHAR2(1) := p_add_assignee_rec.add_option;
196     BEGIN
197         SAVEPOINT add_assignee_pvt;
198 
199         x_return_status := fnd_api.g_ret_sts_success;
200 
201         IF fnd_api.to_boolean (p_init_msg_list)
202         THEN
203             fnd_msg_pub.initialize;
204         END IF;
205 
206         ----------------------------------------------------------
207         -- Check whether the current task_id is the first task_id
208         --              which has been synced
209         ----------------------------------------------------------
210         l_first := jta_sync_task_utl.is_this_first_task(p_task_id => p_add_assignee_rec.task_id);
211 
212         -----------------------------------
213         -- Get new minimum task id
214         -----------------------------------
215         l_new_minimum_task_id := jta_sync_task_utl.get_new_first_taskid(
216                                     p_calendar_start_date => p_add_assignee_rec.calendar_start_date,
217                                     p_recurrence_rule_id  => p_add_assignee_rec.recurrence_rule_id
218                                  );
219         IF l_new_minimum_task_id > 0
220         THEN
221             l_exist_new_first_task := TRUE;
222         END IF;
223 
224         -----------------------------------
225         -- Check if this is the last one
226         -----------------------------------
227         IF (l_first AND NOT l_exist_new_first_task) OR
228            (l_first AND l_add_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE)
229         THEN
230             -- This repeating rule has only one appointment currently OR
231             -- A user selected the first task one and
232             --     chose the option "Add this new invitee into all the future appointments"
233             l_add_option := JTF_TASK_REPEAT_APPT_PVT.G_ALL;
234         END IF;
235 
236         IF l_add_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE
237         THEN
238             -----------------------------------------------------------------
239             -- Create a new repeating rule (use recurrence table handler)
240             -----------------------------------------------------------------
241             OPEN c_recur (p_add_assignee_rec.recurrence_rule_id);
242             FETCH c_recur INTO rec_recur;
243             IF c_recur%NOTFOUND
244             THEN
245                 CLOSE c_recur;
246                 fnd_message.set_name ('JTF', 'JTF_TK_INVALID_RECUR_RULE');
247                 fnd_message.set_token ('P_TASK_RECURRENCE_RULE_ID', p_add_assignee_rec.recurrence_rule_id);
248                 fnd_msg_pub.add;
249 
250                 x_return_status := fnd_api.g_ret_sts_unexp_error;
251                 RAISE fnd_api.g_exc_unexpected_error;
252             END IF;
253             CLOSE c_recur;
254 
255             SELECT jtf_task_recur_rules_s.NEXTVAL
256               INTO l_new_recurrence_rule_id
257               FROM dual;
258 
259             jtf_task_recur_rules_pkg.insert_row (
260                 x_rowid              => l_rowid,
261                 x_recurrence_rule_id => l_new_recurrence_rule_id,
262                 x_occurs_which       => rec_recur.occurs_which,
263                 x_day_of_week        => rec_recur.day_of_week,
264                 x_date_of_month      => rec_recur.date_of_month,
265                 x_occurs_month       => rec_recur.occurs_month,
266                 x_occurs_uom         => rec_recur.occurs_uom,
267                 x_occurs_every       => rec_recur.occurs_every,
268                 x_occurs_number      => rec_recur.occurs_number,
269                 x_start_date_active  => trunc(p_add_assignee_rec.calendar_start_date), -- New start date
270                 x_end_date_active    => rec_recur.end_date_active,
271                 x_attribute1         => rec_recur.attribute1 ,
272                 x_attribute2         => rec_recur.attribute2 ,
273                 x_attribute3         => rec_recur.attribute3 ,
274                 x_attribute4         => rec_recur.attribute4 ,
275                 x_attribute5         => rec_recur.attribute5 ,
276                 x_attribute6         => rec_recur.attribute6 ,
277                 x_attribute7         => rec_recur.attribute7 ,
278                 x_attribute8         => rec_recur.attribute8 ,
279                 x_attribute9         => rec_recur.attribute9 ,
280                 x_attribute10        => rec_recur.attribute10 ,
281                 x_attribute11        => rec_recur.attribute11 ,
282                 x_attribute12        => rec_recur.attribute12 ,
283                 x_attribute13        => rec_recur.attribute13 ,
284                 x_attribute14        => rec_recur.attribute14 ,
285                 x_attribute15        => rec_recur.attribute15,
286                 x_attribute_category => rec_recur.attribute_category ,
287                 x_creation_date      => SYSDATE,
288                 x_created_by         => jtf_task_utl.created_by,
289                 x_last_update_date   => SYSDATE,
290                 x_last_updated_by    => jtf_task_utl.updated_by,
291                 x_last_update_login  => fnd_global.login_id,
292                 x_sunday             => rec_recur.sunday,
293                 x_monday             => rec_recur.monday,
294                 x_tuesday            => rec_recur.tuesday,
295                 x_wednesday          => rec_recur.wednesday,
296                 x_thursday           => rec_recur.thursday,
297                 x_friday             => rec_recur.friday,
298                 x_saturday           => rec_recur.saturday,
299                 x_date_selected      => rec_recur.date_selected
300             );
301         END IF;
302 
303         FOR rec_tasks IN c_tasks (b_recurrence_rule_id => p_add_assignee_rec.recurrence_rule_id
304                                  ,b_calendar_start_date=> p_add_assignee_rec.calendar_start_date
305                                  ,b_add_option         => l_add_option)
306         LOOP
307             IF l_add_option = JTF_TASK_REPEAT_APPT_PVT.G_ONE AND
308                l_first AND
309                l_exist_new_first_task
310             THEN
311                 ---------------------------------------------------
312                 -- Update mapping table with new minimum task id
313                 --    if this is the first one and not the last one
314                 ---------------------------------------------------
315                 IF jta_sync_task_utl.exist_syncid(
316                                 p_task_id     => rec_tasks.task_id,
317                                 x_sync_id     => l_sync_id)
318                 THEN
319                     jta_sync_task_map_pkg.update_row (
320                         p_task_sync_id => l_sync_id,
321                         p_task_id      => l_new_minimum_task_id,
322                         p_resource_id  => p_add_assignee_rec.resource_id
323                     );
324                 END IF;
325             END IF;
326 
327             IF l_add_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE OR
328                l_add_option = JTF_TASK_REPEAT_APPT_PVT.G_ONE
329             THEN
330                 --------------------------------------------
331                 -- Insert this appt into exclusion table
332                 --------------------------------------------
333                 SELECT jta_task_exclusions_s.NEXTVAL
334                   INTO l_task_exclusion_id
335                   FROM DUAL;
336 
337                 jta_task_exclusions_pkg.insert_row (
338                     p_task_exclusion_id   => l_task_exclusion_id,
339                     p_task_id             => rec_tasks.task_id,
340                     p_recurrence_rule_id  => p_add_assignee_rec.recurrence_rule_id,
341                     p_exclusion_date      => rec_tasks.calendar_start_date
342                 );
343 
344                 --------------------------------------------------------
345                 -- l_new_recurrence_rule_id has the following value
346                 --    1) NULL if option = JTF_TASK_REPEAT_APPT_PVT.G_ONE
347                 --    2) new recurrence rule id if option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE
348                 --------------------------------------------------------
349                 UPDATE jtf_tasks_b
350                    SET recurrence_rule_id = l_new_recurrence_rule_id
351                      , object_changed_date = SYSDATE
352                  WHERE task_id = rec_tasks.task_id;
353             END IF;
354 
355             ----------------------
356             -- Add a new invitee
357             ----------------------
358             jtf_task_assignments_pvt.create_task_assignment (
359                 p_api_version           => 1.0,
360                 p_init_msg_list         => fnd_api.g_false,
361                 p_commit                => fnd_api.g_false,
362                 p_task_id               => rec_tasks.task_id,
363                 p_resource_type_code    => p_add_assignee_rec.resource_type_code,
364                 p_resource_id           => p_add_assignee_rec.resource_id,
365 		p_free_busy_type        => p_add_assignee_rec.free_busy_type,
366                 p_assignment_status_id  => p_add_assignee_rec.assignment_status_id,
367                 p_add_option            => NULL,
368                 p_enable_workflow       => 'N',
369                 p_abort_workflow        => 'N',
370                 x_return_status         => x_return_status,
371                 x_msg_count             => x_msg_count,
372                 x_msg_data              => x_msg_data,
373                 x_task_assignment_id    => x_task_assignment_id
374             );
375             IF x_return_status <> fnd_api.g_ret_sts_success THEN
376                 x_return_status := fnd_api.g_ret_sts_unexp_error;
377                 RAISE fnd_api.g_exc_unexpected_error;
378             END IF;
379 
380         END LOOP;
381         ----------------------------------------------------
382 
383         IF fnd_api.to_boolean (p_commit)
384         THEN
385             COMMIT WORK;
386         END IF;
387 
388         fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
389     EXCEPTION
390         WHEN fnd_api.g_exc_unexpected_error
391         THEN
392             ROLLBACK TO add_assignee_pvt;
393             x_return_status := fnd_api.g_ret_sts_unexp_error;
394             fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
395         WHEN OTHERS
396         THEN
397             ROLLBACK TO add_assignee_pvt;
398             fnd_message.set_name ('JTF', 'JTF_TASK_UNKNOWN_ERROR');
399             fnd_message.set_token ('P_TEXT', SQLCODE || SQLERRM);
400             fnd_msg_pub.add;
401             x_return_status := fnd_api.g_ret_sts_unexp_error;
402             fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
403     END add_assignee;
404 
405     PROCEDURE delete_assignee(
406             p_api_version         IN  NUMBER,
407             p_init_msg_list       IN  VARCHAR2 DEFAULT fnd_api.g_false,
408             p_commit              IN  VARCHAR2 DEFAULT fnd_api.g_false,
409             p_delete_assignee_rec IN  delete_assignee_rec,
410             x_return_status       OUT NOCOPY VARCHAR2,
411             x_msg_count           OUT NOCOPY NUMBER,
412             x_msg_data            OUT NOCOPY VARCHAR2
413     )
414     IS
415         CURSOR c_assignments (b_recurrence_rule_id NUMBER
416                              ,b_calendar_start_date DATE
417                              ,b_resource_id NUMBER
418                              ,b_delete_option VARCHAR2)
419         IS
420         SELECT jtaa.task_assignment_id
421              , jtaa.object_version_number
422              , jtaa.task_id
423              , jtb.calendar_start_date
424           FROM jtf_task_all_assignments jtaa
425              , jtf_tasks_b jtb
426          WHERE jtb.recurrence_rule_id = b_recurrence_rule_id
427            AND ((b_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_ALL) OR
428                 (b_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_ONE    AND jtb.calendar_start_date  = b_calendar_start_date) OR
429                 (b_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE AND jtb.calendar_start_date >= b_calendar_start_date))
430            AND jtaa.task_id = jtb.task_id
431            AND jtaa.resource_id = b_resource_id;
432 
433         l_task_exclusion_id NUMBER;
434 
435         CURSOR c_recur (b_recurrence_rule_id NUMBER) IS
436         SELECT *
437           FROM jtf_task_recur_rules
438          WHERE recurrence_rule_id = b_recurrence_rule_id;
439 
440         rec_recur   c_recur%ROWTYPE;
441 
442         l_rowid ROWID;
443         l_new_recurrence_rule_id NUMBER := NULL;
444         l_new_minimum_task_id    NUMBER := NULL;
445         l_first                  BOOLEAN := FALSE;
446         l_exist_new_first_task   BOOLEAN := FALSE;
447         l_sync_id NUMBER;
448 
449         l_delete_option VARCHAR2(1) := p_delete_assignee_rec.delete_option;
450     BEGIN
451         SAVEPOINT delete_assignee_pvt;
452 
453         x_return_status := fnd_api.g_ret_sts_success;
454 
455         IF fnd_api.to_boolean (p_init_msg_list)
456         THEN
457             fnd_msg_pub.initialize;
458         END IF;
459 
460         ----------------------------------------------------
461         ----------------------------------------------------------
462         -- Check whether the current task_id is the first task_id
463         --              which has been synced
464         ----------------------------------------------------------
465         l_first := jta_sync_task_utl.is_this_first_task(
466                         p_task_id     => p_delete_assignee_rec.task_id
467                    );
468 
469         -----------------------------------
470         -- Get new minimum task id
471         -----------------------------------
472         l_new_minimum_task_id := jta_sync_task_utl.get_new_first_taskid(
473                                     p_calendar_start_date => p_delete_assignee_rec.calendar_start_date,
474                                     p_recurrence_rule_id  => p_delete_assignee_rec.recurrence_rule_id
475                                  );
476         IF l_new_minimum_task_id > 0
477         THEN
478             l_exist_new_first_task := TRUE;
479         END IF;
480 
481         -----------------------------------
482         -- Check if this is the last one
483         -----------------------------------
484         IF (l_first AND NOT l_exist_new_first_task) OR
485            (l_first AND l_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE)
486         THEN
487             -- This repeating rule has only one appointment currently OR
488             -- A user selected the first task one and
489             --     chose the option "Delete this invitee from all the future appointments"
490             l_delete_option := JTF_TASK_REPEAT_APPT_PVT.G_ALL;
491         END IF;
492 
493         IF l_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE
494         THEN
495             -----------------------------------------------------------------
496             -- Create a new repeating rule (use recurrence table handler)
497             -----------------------------------------------------------------
498             OPEN c_recur (p_delete_assignee_rec.recurrence_rule_id);
499             FETCH c_recur INTO rec_recur;
500             IF c_recur%NOTFOUND
501             THEN
502                 CLOSE c_recur;
503                 fnd_message.set_name ('JTF', 'JTF_TK_INVALID_RECUR_RULE');
504                 fnd_message.set_token ('P_TASK_RECURRENCE_RULE_ID', p_delete_assignee_rec.recurrence_rule_id);
505                 fnd_msg_pub.add;
506 
507                 x_return_status := fnd_api.g_ret_sts_unexp_error;
508                 RAISE fnd_api.g_exc_unexpected_error;
509             END IF;
510             CLOSE c_recur;
511 
512             SELECT jtf_task_recur_rules_s.NEXTVAL
513               INTO l_new_recurrence_rule_id
514               FROM dual;
515 
516             jtf_task_recur_rules_pkg.insert_row (
517                 x_rowid              => l_rowid,
518                 x_recurrence_rule_id => l_new_recurrence_rule_id,
519                 x_occurs_which       => rec_recur.occurs_which,
520                 x_day_of_week        => rec_recur.day_of_week,
521                 x_date_of_month      => rec_recur.date_of_month,
522                 x_occurs_month       => rec_recur.occurs_month,
523                 x_occurs_uom         => rec_recur.occurs_uom,
524                 x_occurs_every       => rec_recur.occurs_every,
525                 x_occurs_number      => rec_recur.occurs_number,
526                 x_start_date_active  => trunc(p_delete_assignee_rec.calendar_start_date), -- New start date
527                 x_end_date_active    => rec_recur.end_date_active,
528                 x_attribute1         => rec_recur.attribute1 ,
529                 x_attribute2         => rec_recur.attribute2 ,
530                 x_attribute3         => rec_recur.attribute3 ,
531                 x_attribute4         => rec_recur.attribute4 ,
532                 x_attribute5         => rec_recur.attribute5 ,
533                 x_attribute6         => rec_recur.attribute6 ,
534                 x_attribute7         => rec_recur.attribute7 ,
535                 x_attribute8         => rec_recur.attribute8 ,
536                 x_attribute9         => rec_recur.attribute9 ,
537                 x_attribute10        => rec_recur.attribute10 ,
538                 x_attribute11        => rec_recur.attribute11 ,
539                 x_attribute12        => rec_recur.attribute12 ,
540                 x_attribute13        => rec_recur.attribute13 ,
541                 x_attribute14        => rec_recur.attribute14 ,
542                 x_attribute15        => rec_recur.attribute15,
543                 x_attribute_category => rec_recur.attribute_category ,
544                 x_creation_date      => SYSDATE,
545                 x_created_by         => jtf_task_utl.created_by,
546                 x_last_update_date   => SYSDATE,
547                 x_last_updated_by    => jtf_task_utl.updated_by,
548                 x_last_update_login  => fnd_global.login_id,
549                 x_sunday             => rec_recur.sunday,
550                 x_monday             => rec_recur.monday,
551                 x_tuesday            => rec_recur.tuesday,
552                 x_wednesday          => rec_recur.wednesday,
553                 x_thursday           => rec_recur.thursday,
554                 x_friday             => rec_recur.friday,
555                 x_saturday           => rec_recur.saturday,
556                 x_date_selected      => rec_recur.date_selected
557             );
558         END IF;
559 
560         FOR rec_assignments IN c_assignments (b_recurrence_rule_id  => p_delete_assignee_rec.recurrence_rule_id
561                                              ,b_calendar_start_date => p_delete_assignee_rec.calendar_start_date
562                                              ,b_resource_id         => p_delete_assignee_rec.resource_id
563                                              ,b_delete_option       => l_delete_option)
564         LOOP
565             IF l_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_ONE AND
566                l_first AND
567                l_exist_new_first_task
568             THEN
569                 ---------------------------------------------------
570                 -- Update mapping table with new minimum task id
571                 --    if this is the first one and not the last one
572                 ---------------------------------------------------
573                 IF jta_sync_task_utl.exist_syncid(
574                                 p_task_id     => rec_assignments.task_id,
575                                 x_sync_id     => l_sync_id)
576                 THEN
577                     jta_sync_task_map_pkg.update_row (
578                         p_task_sync_id => l_sync_id,
579                         p_task_id      => l_new_minimum_task_id,
580                         p_resource_id  => p_delete_assignee_rec.resource_id
581                     );
582                 END IF;
583             END IF;
584 
585             IF l_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE OR
586                l_delete_option = JTF_TASK_REPEAT_APPT_PVT.G_ONE
587             THEN
588                 --------------------------------------------
589                 -- Insert this appt into exclusion table
590                 --------------------------------------------
591                 SELECT jta_task_exclusions_s.NEXTVAL
592                   INTO l_task_exclusion_id
593                   FROM DUAL;
594 
595                 jta_task_exclusions_pkg.insert_row (
596                     p_task_exclusion_id   => l_task_exclusion_id,
597                     p_task_id             => rec_assignments.task_id,
598                     p_recurrence_rule_id  => p_delete_assignee_rec.recurrence_rule_id,
599                     p_exclusion_date      => rec_assignments.calendar_start_date
600                 );
601 
602                 --------------------------------------------------------
603                 -- l_new_recurrence_rule_id has the following value
604                 --    1) NULL if option = JTF_TASK_REPEAT_APPT_PVT.G_ONE
605                 --    2) new recurrence rule id if option = JTF_TASK_REPEAT_APPT_PVT.G_FUTURE
606                 --------------------------------------------------------
607                 UPDATE jtf_tasks_b
608                    SET recurrence_rule_id = l_new_recurrence_rule_id
609                      , object_changed_date = SYSDATE
610                  WHERE task_id = rec_assignments.task_id;
611             END IF;
612 
613             ----------------------
614             -- Delete this invitee
615             ----------------------
616             jtf_task_assignments_pvt.delete_task_assignment (
617                 p_api_version           => 1.0,
618                 p_init_msg_list         => fnd_api.g_false,
619                 p_commit                => fnd_api.g_false,
620                 p_task_assignment_id    => rec_assignments.task_assignment_id,
621                 p_object_version_number => rec_assignments.object_version_number,
622                 p_delete_option         => NULL,
623                 p_enable_workflow       => 'N',
624                 p_abort_workflow        => 'N',
625                 x_return_status         => x_return_status,
626                 x_msg_count             => x_msg_count,
627                 x_msg_data              => x_msg_data
628             );
629             IF x_return_status <> fnd_api.g_ret_sts_success THEN
630                 x_return_status := fnd_api.g_ret_sts_unexp_error;
631                 RAISE fnd_api.g_exc_unexpected_error;
632             END IF;
633         END LOOP;
634         ----------------------------------------------------
635 
636         IF fnd_api.to_boolean (p_commit)
637         THEN
638             COMMIT WORK;
639         END IF;
640 
641         fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
642     EXCEPTION
643         WHEN fnd_api.g_exc_unexpected_error
644         THEN
645             ROLLBACK TO delete_assignee_pvt;
646             x_return_status := fnd_api.g_ret_sts_unexp_error;
647             fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
648         WHEN OTHERS
649         THEN
650             ROLLBACK TO delete_assignee_pvt;
651             fnd_message.set_name ('JTF', 'JTF_TASK_UNKNOWN_ERROR');
652             fnd_message.set_token ('P_TEXT', SQLCODE || SQLERRM);
653             fnd_msg_pub.add;
654             x_return_status := fnd_api.g_ret_sts_unexp_error;
655             fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
656     END delete_assignee;
657 
658 END jtf_task_repeat_assignment_pvt;