DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_TASKS_PVT

Source


1 PACKAGE BODY jtf_tasks_pvt AS
2   /* $Header: jtfvtktb.pls 120.22 2010/09/13 07:22:47 anangupt ship $ */
3   g_pkg_name       CONSTANT VARCHAR2(30)                                   := 'JTF_TASKS_PVT';
4   g_entity         CONSTANT jtf_tasks_b.entity%TYPE                        := 'TASK';
5   g_free_busy_type CONSTANT jtf_task_all_assignments.free_busy_type%TYPE   := 'FREE';
6   v_select                  VARCHAR2(6000);
7   -- table for query_task
8   v_tbl                     jtf_tasks_pub.task_table_type;
9   -- table for query_task
10   v_n_tbl                   jtf_tasks_pub.task_table_type;
11 
12   -- original version to call the new version which has a workflow enhancement
13   PROCEDURE create_task(
14     p_api_version             IN            NUMBER
15   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
16   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
17   , p_task_id                 IN            NUMBER DEFAULT NULL
18   , p_task_name               IN            VARCHAR2
19   , p_task_type_id            IN            NUMBER DEFAULT NULL
20   , p_description             IN            VARCHAR2 DEFAULT NULL
21   , p_task_status_id          IN            NUMBER DEFAULT NULL
22   , p_task_priority_id        IN            NUMBER DEFAULT NULL
23   , p_owner_type_code         IN            VARCHAR2 DEFAULT NULL
24   , p_owner_id                IN            NUMBER DEFAULT NULL
25   , p_owner_territory_id      IN            NUMBER DEFAULT NULL
26   , p_assigned_by_id          IN            NUMBER DEFAULT NULL
27   , p_customer_id             IN            NUMBER DEFAULT NULL
28   , p_cust_account_id         IN            NUMBER DEFAULT NULL
29   , p_address_id              IN            NUMBER DEFAULT NULL
30   ,   ---- hz_party_sites
31     p_planned_start_date      IN            DATE DEFAULT NULL
32   , p_planned_end_date        IN            DATE DEFAULT NULL
33   , p_scheduled_start_date    IN            DATE DEFAULT NULL
34   , p_scheduled_end_date      IN            DATE DEFAULT NULL
35   , p_actual_start_date       IN            DATE DEFAULT NULL
36   , p_actual_end_date         IN            DATE DEFAULT NULL
37   , p_timezone_id             IN            NUMBER DEFAULT NULL
38   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
39   , p_source_object_id        IN            NUMBER DEFAULT NULL
40   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
41   , p_duration                IN            NUMBER DEFAULT NULL
42   , p_duration_uom            IN            VARCHAR2 DEFAULT NULL
43   , p_planned_effort          IN            NUMBER DEFAULT NULL
44   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT NULL
45   , p_actual_effort           IN            NUMBER DEFAULT NULL
46   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT NULL
47   , p_percentage_complete     IN            NUMBER DEFAULT NULL
48   , p_reason_code             IN            VARCHAR2 DEFAULT NULL
49   , p_private_flag            IN            VARCHAR2 DEFAULT NULL
50   , p_publish_flag            IN            VARCHAR2 DEFAULT NULL
51   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT NULL
52   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT NULL
53   , p_milestone_flag          IN            VARCHAR2 DEFAULT NULL
54   , p_holiday_flag            IN            VARCHAR2 DEFAULT NULL
55   , p_billable_flag           IN            VARCHAR2 DEFAULT NULL
56   , p_bound_mode_code         IN            VARCHAR2 DEFAULT NULL
57   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT NULL
58   , p_workflow_process_id     IN            NUMBER DEFAULT NULL
59   , p_notification_flag       IN            VARCHAR2 DEFAULT NULL
60   , p_notification_period     IN            NUMBER DEFAULT NULL
61   , p_notification_period_uom IN            VARCHAR2 DEFAULT NULL
62   , p_parent_task_id          IN            NUMBER DEFAULT NULL
63   , p_alarm_start             IN            NUMBER DEFAULT NULL
64   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT NULL
65   , p_alarm_on                IN            VARCHAR2 DEFAULT NULL
66   , p_alarm_count             IN            NUMBER DEFAULT NULL
67   , p_alarm_interval          IN            NUMBER DEFAULT NULL
68   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT NULL
69   , p_palm_flag               IN            VARCHAR2 DEFAULT NULL
70   , p_wince_flag              IN            VARCHAR2 DEFAULT NULL
71   , p_laptop_flag             IN            VARCHAR2 DEFAULT NULL
72   , p_device1_flag            IN            VARCHAR2 DEFAULT NULL
73   , p_device2_flag            IN            VARCHAR2 DEFAULT NULL
74   , p_device3_flag            IN            VARCHAR2 DEFAULT NULL
75   , p_costs                   IN            NUMBER DEFAULT NULL
76   , p_currency_code           IN            VARCHAR2 DEFAULT NULL
77   , p_escalation_level        IN            VARCHAR2 DEFAULT NULL
78   , x_return_status           OUT NOCOPY    VARCHAR2
79   , x_msg_count               OUT NOCOPY    NUMBER
80   , x_msg_data                OUT NOCOPY    VARCHAR2
81   , x_task_id                 OUT NOCOPY    NUMBER
82   , p_attribute1              IN            VARCHAR2 DEFAULT NULL
83   , p_attribute2              IN            VARCHAR2 DEFAULT NULL
84   , p_attribute3              IN            VARCHAR2 DEFAULT NULL
85   , p_attribute4              IN            VARCHAR2 DEFAULT NULL
86   , p_attribute5              IN            VARCHAR2 DEFAULT NULL
87   , p_attribute6              IN            VARCHAR2 DEFAULT NULL
88   , p_attribute7              IN            VARCHAR2 DEFAULT NULL
89   , p_attribute8              IN            VARCHAR2 DEFAULT NULL
90   , p_attribute9              IN            VARCHAR2 DEFAULT NULL
91   , p_attribute10             IN            VARCHAR2 DEFAULT NULL
92   , p_attribute11             IN            VARCHAR2 DEFAULT NULL
93   , p_attribute12             IN            VARCHAR2 DEFAULT NULL
94   , p_attribute13             IN            VARCHAR2 DEFAULT NULL
95   , p_attribute14             IN            VARCHAR2 DEFAULT NULL
96   , p_attribute15             IN            VARCHAR2 DEFAULT NULL
97   , p_attribute_category      IN            VARCHAR2 DEFAULT NULL
98   , p_date_selected           IN            VARCHAR2 DEFAULT NULL
99   , p_category_id             IN            NUMBER DEFAULT NULL
100   , p_show_on_calendar        IN            VARCHAR2 DEFAULT NULL
101   , p_owner_status_id         IN            NUMBER DEFAULT NULL
102   , p_template_id             IN            NUMBER DEFAULT NULL
103   , p_template_group_id       IN            NUMBER DEFAULT NULL
104   ) IS
105     l_api_version CONSTANT NUMBER       := 1.0;
106     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK';
107   BEGIN
108     SAVEPOINT create_task_pvt2;
109     x_return_status  := fnd_api.g_ret_sts_success;
110 
111     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
112       RAISE fnd_api.g_exc_unexpected_error;
113     END IF;
114 
115     IF fnd_api.to_boolean(p_init_msg_list) THEN
116       fnd_msg_pub.initialize;
117     END IF;
118 
119     -- call new version, passing defaults for new functionality
120     create_task(
121       p_api_version                => p_api_version
122     , p_init_msg_list              => p_init_msg_list
123     , p_commit                     => fnd_api.g_false
124     , p_task_id                    => p_task_id
125     , p_task_name                  => p_task_name
126     , p_task_type_id               => p_task_type_id
127     , p_description                => p_description
128     , p_task_status_id             => p_task_status_id
129     , p_task_priority_id           => p_task_priority_id
130     , p_owner_type_code            => p_owner_type_code
131     , p_owner_id                   => p_owner_id
132     , p_owner_territory_id         => p_owner_territory_id
133     , p_assigned_by_id             => p_assigned_by_id
134     , p_customer_id                => p_customer_id
135     , p_cust_account_id            => p_cust_account_id
136     , p_address_id                 => p_address_id
137     , p_planned_start_date         => p_planned_start_date
138     , p_planned_end_date           => p_planned_end_date
139     , p_scheduled_start_date       => p_scheduled_start_date
140     , p_scheduled_end_date         => p_scheduled_end_date
141     , p_actual_start_date          => p_actual_start_date
142     , p_actual_end_date            => p_actual_end_date
143     , p_timezone_id                => p_timezone_id
144     , p_source_object_type_code    => p_source_object_type_code
145     , p_source_object_id           => p_source_object_id
146     , p_source_object_name         => p_source_object_name
147     , p_duration                   => p_duration
148     , p_duration_uom               => p_duration_uom
149     , p_planned_effort             => p_planned_effort
150     , p_planned_effort_uom         => p_planned_effort_uom
151     , p_actual_effort              => p_actual_effort
152     , p_actual_effort_uom          => p_actual_effort_uom
153     , p_percentage_complete        => p_percentage_complete
154     , p_reason_code                => p_reason_code
155     , p_private_flag               => p_private_flag
156     , p_publish_flag               => p_publish_flag
157     , p_restrict_closure_flag      => p_restrict_closure_flag
158     , p_multi_booked_flag          => p_multi_booked_flag
159     , p_milestone_flag             => p_milestone_flag
160     , p_holiday_flag               => p_holiday_flag
161     , p_billable_flag              => p_billable_flag
162     , p_bound_mode_code            => p_bound_mode_code
163     , p_soft_bound_flag            => p_soft_bound_flag
164     , p_workflow_process_id        => p_workflow_process_id
165     , p_notification_flag          => p_notification_flag
166     , p_notification_period        => p_notification_period
167     , p_notification_period_uom    => p_notification_period_uom
168     , p_parent_task_id             => p_parent_task_id
169     , p_alarm_start                => p_alarm_start
170     , p_alarm_start_uom            => p_alarm_start_uom
171     , p_alarm_on                   => p_alarm_on
172     , p_alarm_count                => p_alarm_count
173     , p_alarm_interval             => p_alarm_interval
174     , p_alarm_interval_uom         => p_alarm_interval_uom
175     , p_palm_flag                  => p_palm_flag
176     , p_wince_flag                 => p_wince_flag
177     , p_laptop_flag                => p_laptop_flag
178     , p_device1_flag               => p_device1_flag
179     , p_device2_flag               => p_device2_flag
180     , p_device3_flag               => p_device3_flag
181     , p_costs                      => p_costs
182     , p_currency_code              => p_currency_code
183     , p_escalation_level           => p_escalation_level
184     , x_return_status              => x_return_status
185     , x_msg_count                  => x_msg_count
186     , x_msg_data                   => x_msg_data
187     , x_task_id                    => x_task_id
188     , p_attribute1                 => p_attribute1
189     , p_attribute2                 => p_attribute2
190     , p_attribute3                 => p_attribute3
191     , p_attribute4                 => p_attribute4
192     , p_attribute5                 => p_attribute5
193     , p_attribute6                 => p_attribute6
194     , p_attribute7                 => p_attribute7
195     , p_attribute8                 => p_attribute8
196     , p_attribute9                 => p_attribute9
197     , p_attribute10                => p_attribute10
198     , p_attribute11                => p_attribute11
199     , p_attribute12                => p_attribute12
200     , p_attribute13                => p_attribute13
201     , p_attribute14                => p_attribute14
202     , p_attribute15                => p_attribute15
203     , p_attribute_category         => p_attribute_category
204     , p_date_selected              => p_date_selected
205     , p_category_id                => p_category_id
206     , p_show_on_calendar           => p_show_on_calendar
207     , p_owner_status_id            => p_owner_status_id
208     , p_template_id                => p_template_id
209     , p_template_group_id          => p_template_group_id
210     , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
211     , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
212     , p_entity                     => g_entity
213     , p_free_busy_type             => NULL
214     , p_task_confirmation_status   => 'N'
215     , p_task_confirmation_counter  => NULL
216     , p_task_split_flag            => NULL
217     , p_reference_flag             => NULL
218     , p_child_position             => NULL
219     , p_child_sequence_num         => NULL
220     );
221 
222     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
223       x_return_status  := fnd_api.g_ret_sts_unexp_error;
224       RAISE fnd_api.g_exc_unexpected_error;
225     END IF;
226 
227     IF fnd_api.to_boolean(p_commit) THEN
228       COMMIT WORK;
229     END IF;
230 
231     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
232   EXCEPTION
233     WHEN fnd_api.g_exc_unexpected_error THEN
234       ROLLBACK TO create_task_pvt2;
235       x_return_status  := fnd_api.g_ret_sts_unexp_error;
236       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
237     WHEN OTHERS THEN
238       ROLLBACK TO create_task_pvt2;
239       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
240       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
241       fnd_msg_pub.ADD;
242       x_return_status  := fnd_api.g_ret_sts_unexp_error;
243       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
244   END;
245 
246   -- new version which has a workflow enhancement
247   PROCEDURE create_task(
248     p_api_version             IN            NUMBER
249   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
250   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
251   , p_task_id                 IN            NUMBER DEFAULT NULL
252   , p_task_name               IN            VARCHAR2
253   , p_task_type_id            IN            NUMBER DEFAULT NULL
254   , p_description             IN            VARCHAR2 DEFAULT NULL
255   , p_task_status_id          IN            NUMBER DEFAULT NULL
256   , p_task_priority_id        IN            NUMBER DEFAULT NULL
257   , p_owner_type_code         IN            VARCHAR2 DEFAULT NULL
258   , p_owner_id                IN            NUMBER DEFAULT NULL
259   , p_owner_territory_id      IN            NUMBER DEFAULT NULL
260   , p_assigned_by_id          IN            NUMBER DEFAULT NULL
261   , p_customer_id             IN            NUMBER DEFAULT NULL
262   , p_cust_account_id         IN            NUMBER DEFAULT NULL
263   , p_address_id              IN            NUMBER DEFAULT NULL
264   ,   ---- hz_party_sites
265     p_planned_start_date      IN            DATE DEFAULT NULL
266   , p_planned_end_date        IN            DATE DEFAULT NULL
267   , p_scheduled_start_date    IN            DATE DEFAULT NULL
268   , p_scheduled_end_date      IN            DATE DEFAULT NULL
269   , p_actual_start_date       IN            DATE DEFAULT NULL
270   , p_actual_end_date         IN            DATE DEFAULT NULL
271   , p_timezone_id             IN            NUMBER DEFAULT NULL
272   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
273   , p_source_object_id        IN            NUMBER DEFAULT NULL
274   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
275   , p_duration                IN            NUMBER DEFAULT NULL
276   , p_duration_uom            IN            VARCHAR2 DEFAULT NULL
277   , p_planned_effort          IN            NUMBER DEFAULT NULL
278   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT NULL
279   , p_actual_effort           IN            NUMBER DEFAULT NULL
280   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT NULL
281   , p_percentage_complete     IN            NUMBER DEFAULT NULL
282   , p_reason_code             IN            VARCHAR2 DEFAULT NULL
283   , p_private_flag            IN            VARCHAR2 DEFAULT NULL
284   , p_publish_flag            IN            VARCHAR2 DEFAULT NULL
285   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT NULL
286   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT NULL
287   , p_milestone_flag          IN            VARCHAR2 DEFAULT NULL
288   , p_holiday_flag            IN            VARCHAR2 DEFAULT NULL
289   , p_billable_flag           IN            VARCHAR2 DEFAULT NULL
290   , p_bound_mode_code         IN            VARCHAR2 DEFAULT NULL
291   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT NULL
292   , p_workflow_process_id     IN            NUMBER DEFAULT NULL
293   , p_notification_flag       IN            VARCHAR2 DEFAULT NULL
294   , p_notification_period     IN            NUMBER DEFAULT NULL
295   , p_notification_period_uom IN            VARCHAR2 DEFAULT NULL
296   , p_parent_task_id          IN            NUMBER DEFAULT NULL
297   , p_alarm_start             IN            NUMBER DEFAULT NULL
298   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT NULL
299   , p_alarm_on                IN            VARCHAR2 DEFAULT NULL
300   , p_alarm_count             IN            NUMBER DEFAULT NULL
301   , p_alarm_interval          IN            NUMBER DEFAULT NULL
302   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT NULL
303   , p_palm_flag               IN            VARCHAR2 DEFAULT NULL
304   , p_wince_flag              IN            VARCHAR2 DEFAULT NULL
305   , p_laptop_flag             IN            VARCHAR2 DEFAULT NULL
306   , p_device1_flag            IN            VARCHAR2 DEFAULT NULL
307   , p_device2_flag            IN            VARCHAR2 DEFAULT NULL
308   , p_device3_flag            IN            VARCHAR2 DEFAULT NULL
309   , p_costs                   IN            NUMBER DEFAULT NULL
310   , p_currency_code           IN            VARCHAR2 DEFAULT NULL
311   , p_escalation_level        IN            VARCHAR2 DEFAULT NULL
312   , x_return_status           OUT NOCOPY    VARCHAR2
313   , x_msg_count               OUT NOCOPY    NUMBER
314   , x_msg_data                OUT NOCOPY    VARCHAR2
315   , x_task_id                 OUT NOCOPY    NUMBER
316   , p_attribute1              IN            VARCHAR2 DEFAULT NULL
317   , p_attribute2              IN            VARCHAR2 DEFAULT NULL
318   , p_attribute3              IN            VARCHAR2 DEFAULT NULL
319   , p_attribute4              IN            VARCHAR2 DEFAULT NULL
320   , p_attribute5              IN            VARCHAR2 DEFAULT NULL
321   , p_attribute6              IN            VARCHAR2 DEFAULT NULL
322   , p_attribute7              IN            VARCHAR2 DEFAULT NULL
323   , p_attribute8              IN            VARCHAR2 DEFAULT NULL
324   , p_attribute9              IN            VARCHAR2 DEFAULT NULL
325   , p_attribute10             IN            VARCHAR2 DEFAULT NULL
326   , p_attribute11             IN            VARCHAR2 DEFAULT NULL
327   , p_attribute12             IN            VARCHAR2 DEFAULT NULL
328   , p_attribute13             IN            VARCHAR2 DEFAULT NULL
329   , p_attribute14             IN            VARCHAR2 DEFAULT NULL
330   , p_attribute15             IN            VARCHAR2 DEFAULT NULL
331   , p_attribute_category      IN            VARCHAR2 DEFAULT NULL
332   , p_date_selected           IN            VARCHAR2 DEFAULT NULL
333   , p_category_id             IN            NUMBER DEFAULT NULL
334   , p_show_on_calendar        IN            VARCHAR2 DEFAULT NULL
335   , p_owner_status_id         IN            NUMBER DEFAULT NULL
336   , p_template_id             IN            NUMBER DEFAULT NULL
337   , p_template_group_id       IN            NUMBER DEFAULT NULL
338   , p_enable_workflow         IN            VARCHAR2
339   , p_abort_workflow          IN            VARCHAR2
340   ) IS
341     l_api_version CONSTANT NUMBER       := 1.0;
342     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK';
343   BEGIN
344     SAVEPOINT create_task_pvt3;
345     x_return_status  := fnd_api.g_ret_sts_success;
346 
347     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
348       RAISE fnd_api.g_exc_unexpected_error;
349     END IF;
350 
351     IF fnd_api.to_boolean(p_init_msg_list) THEN
352       fnd_msg_pub.initialize;
353     END IF;
354 
355     -- call new version, passing defaults for new functionality
356     create_task(
357       p_api_version                => p_api_version
358     , p_init_msg_list              => p_init_msg_list
359     ,
360       -- passing FALSE so we can commit after processing the table parameters
361       p_commit                     => fnd_api.g_false
362     , p_task_id                    => p_task_id
363     , p_task_name                  => p_task_name
364     , p_task_type_id               => p_task_type_id
365     , p_description                => p_description
366     , p_task_status_id             => p_task_status_id
367     , p_task_priority_id           => p_task_priority_id
368     , p_owner_type_code            => p_owner_type_code
369     , p_owner_id                   => p_owner_id
370     , p_owner_territory_id         => p_owner_territory_id
371     , p_assigned_by_id             => p_assigned_by_id
372     , p_customer_id                => p_customer_id
373     , p_cust_account_id            => p_cust_account_id
374     , p_address_id                 => p_address_id
375     , p_planned_start_date         => p_planned_start_date
376     , p_planned_end_date           => p_planned_end_date
377     , p_scheduled_start_date       => p_scheduled_start_date
378     , p_scheduled_end_date         => p_scheduled_end_date
379     , p_actual_start_date          => p_actual_start_date
380     , p_actual_end_date            => p_actual_end_date
381     , p_timezone_id                => p_timezone_id
382     , p_source_object_type_code    => p_source_object_type_code
383     , p_source_object_id           => p_source_object_id
384     , p_source_object_name         => p_source_object_name
385     , p_duration                   => p_duration
386     , p_duration_uom               => p_duration_uom
387     , p_planned_effort             => p_planned_effort
388     , p_planned_effort_uom         => p_planned_effort_uom
389     , p_actual_effort              => p_actual_effort
390     , p_actual_effort_uom          => p_actual_effort_uom
391     , p_percentage_complete        => p_percentage_complete
392     , p_reason_code                => p_reason_code
393     , p_private_flag               => p_private_flag
394     , p_publish_flag               => p_publish_flag
395     , p_restrict_closure_flag      => p_restrict_closure_flag
396     , p_multi_booked_flag          => p_multi_booked_flag
397     , p_milestone_flag             => p_milestone_flag
398     , p_holiday_flag               => p_holiday_flag
399     , p_billable_flag              => p_billable_flag
400     , p_bound_mode_code            => p_bound_mode_code
401     , p_soft_bound_flag            => p_soft_bound_flag
402     , p_workflow_process_id        => p_workflow_process_id
403     , p_notification_flag          => p_notification_flag
404     , p_notification_period        => p_notification_period
405     , p_notification_period_uom    => p_notification_period_uom
406     , p_parent_task_id             => p_parent_task_id
407     , p_alarm_start                => p_alarm_start
408     , p_alarm_start_uom            => p_alarm_start_uom
409     , p_alarm_on                   => p_alarm_on
410     , p_alarm_count                => p_alarm_count
411     , p_alarm_interval             => p_alarm_interval
412     , p_alarm_interval_uom         => p_alarm_interval_uom
413     , p_palm_flag                  => p_palm_flag
414     , p_wince_flag                 => p_wince_flag
415     , p_laptop_flag                => p_laptop_flag
416     , p_device1_flag               => p_device1_flag
417     , p_device2_flag               => p_device2_flag
418     , p_device3_flag               => p_device3_flag
419     , p_costs                      => p_costs
420     , p_currency_code              => p_currency_code
421     , p_escalation_level           => p_escalation_level
422     , x_return_status              => x_return_status
423     , x_msg_count                  => x_msg_count
424     , x_msg_data                   => x_msg_data
425     , x_task_id                    => x_task_id
426     , p_attribute1                 => p_attribute1
427     , p_attribute2                 => p_attribute2
428     , p_attribute3                 => p_attribute3
429     , p_attribute4                 => p_attribute4
430     , p_attribute5                 => p_attribute5
431     , p_attribute6                 => p_attribute6
432     , p_attribute7                 => p_attribute7
433     , p_attribute8                 => p_attribute8
434     , p_attribute9                 => p_attribute9
435     , p_attribute10                => p_attribute10
436     , p_attribute11                => p_attribute11
437     , p_attribute12                => p_attribute12
438     , p_attribute13                => p_attribute13
439     , p_attribute14                => p_attribute14
440     , p_attribute15                => p_attribute15
441     , p_attribute_category         => p_attribute_category
442     , p_date_selected              => p_date_selected
443     , p_category_id                => p_category_id
444     , p_show_on_calendar           => p_show_on_calendar
445     , p_owner_status_id            => p_owner_status_id
446     , p_template_id                => p_template_id
447     , p_template_group_id          => p_template_group_id
448     , p_enable_workflow            => p_enable_workflow
449     , p_abort_workflow             => p_abort_workflow
450     , p_entity                     => g_entity
451     , p_free_busy_type             => NULL
452     , p_task_confirmation_status   => 'N'
453     , p_task_confirmation_counter  => NULL
454     , p_task_split_flag            => NULL
455     , p_reference_flag             => NULL
456     , p_child_position             => NULL
457     , p_child_sequence_num         => NULL
458     );
459 
460     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
461       x_return_status  := fnd_api.g_ret_sts_unexp_error;
462       RAISE fnd_api.g_exc_unexpected_error;
463     END IF;
464 
465     IF fnd_api.to_boolean(p_commit) THEN
466       COMMIT WORK;
467     END IF;
468 
469     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
470   EXCEPTION
471     WHEN fnd_api.g_exc_unexpected_error THEN
472       ROLLBACK TO create_task_pvt3;
473       x_return_status  := fnd_api.g_ret_sts_unexp_error;
474       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
475     WHEN OTHERS THEN
476       ROLLBACK TO create_task_pvt3;
477       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
478       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
479       fnd_msg_pub.ADD;
480       x_return_status  := fnd_api.g_ret_sts_unexp_error;
481       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
482   END;
483 
484   -- overloaded version to add p_entity and p_free_busy_type..
485   PROCEDURE create_task(
486     p_api_version             IN            NUMBER
487   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
488   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
489   , p_task_id                 IN            NUMBER DEFAULT NULL
490   , p_task_name               IN            VARCHAR2
491   , p_task_type_id            IN            NUMBER DEFAULT NULL
492   , p_description             IN            VARCHAR2 DEFAULT NULL
493   , p_task_status_id          IN            NUMBER DEFAULT NULL
494   , p_task_priority_id        IN            NUMBER DEFAULT NULL
495   , p_owner_type_code         IN            VARCHAR2 DEFAULT NULL
496   , p_owner_id                IN            NUMBER DEFAULT NULL
497   , p_owner_territory_id      IN            NUMBER DEFAULT NULL
498   , p_assigned_by_id          IN            NUMBER DEFAULT NULL
499   , p_customer_id             IN            NUMBER DEFAULT NULL
500   , p_cust_account_id         IN            NUMBER DEFAULT NULL
501   , p_address_id              IN            NUMBER DEFAULT NULL
502   , p_planned_start_date      IN            DATE DEFAULT NULL
503   , p_planned_end_date        IN            DATE DEFAULT NULL
504   , p_scheduled_start_date    IN            DATE DEFAULT NULL
505   , p_scheduled_end_date      IN            DATE DEFAULT NULL
506   , p_actual_start_date       IN            DATE DEFAULT NULL
507   , p_actual_end_date         IN            DATE DEFAULT NULL
508   , p_timezone_id             IN            NUMBER DEFAULT NULL
509   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
510   , p_source_object_id        IN            NUMBER DEFAULT NULL
511   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
512   , p_duration                IN            NUMBER DEFAULT NULL
513   , p_duration_uom            IN            VARCHAR2 DEFAULT NULL
514   , p_planned_effort          IN            NUMBER DEFAULT NULL
515   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT NULL
516   , p_actual_effort           IN            NUMBER DEFAULT NULL
517   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT NULL
518   , p_percentage_complete     IN            NUMBER DEFAULT NULL
519   , p_reason_code             IN            VARCHAR2 DEFAULT NULL
520   , p_private_flag            IN            VARCHAR2 DEFAULT NULL
521   , p_publish_flag            IN            VARCHAR2 DEFAULT NULL
522   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT NULL
523   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT NULL
524   , p_milestone_flag          IN            VARCHAR2 DEFAULT NULL
525   , p_holiday_flag            IN            VARCHAR2 DEFAULT NULL
526   , p_billable_flag           IN            VARCHAR2 DEFAULT NULL
527   , p_bound_mode_code         IN            VARCHAR2 DEFAULT NULL
528   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT NULL
529   , p_workflow_process_id     IN            NUMBER DEFAULT NULL
530   , p_notification_flag       IN            VARCHAR2 DEFAULT NULL
531   , p_notification_period     IN            NUMBER DEFAULT NULL
532   , p_notification_period_uom IN            VARCHAR2 DEFAULT NULL
533   , p_parent_task_id          IN            NUMBER DEFAULT NULL
534   , p_alarm_start             IN            NUMBER DEFAULT NULL
535   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT NULL
536   , p_alarm_on                IN            VARCHAR2 DEFAULT NULL
537   , p_alarm_count             IN            NUMBER DEFAULT NULL
538   , p_alarm_interval          IN            NUMBER DEFAULT NULL
539   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT NULL
540   , p_palm_flag               IN            VARCHAR2 DEFAULT NULL
541   , p_wince_flag              IN            VARCHAR2 DEFAULT NULL
542   , p_laptop_flag             IN            VARCHAR2 DEFAULT NULL
543   , p_device1_flag            IN            VARCHAR2 DEFAULT NULL
544   , p_device2_flag            IN            VARCHAR2 DEFAULT NULL
545   , p_device3_flag            IN            VARCHAR2 DEFAULT NULL
546   , p_costs                   IN            NUMBER DEFAULT NULL
547   , p_currency_code           IN            VARCHAR2 DEFAULT NULL
548   , p_escalation_level        IN            VARCHAR2 DEFAULT NULL
549   , x_return_status           OUT NOCOPY    VARCHAR2
550   , x_msg_count               OUT NOCOPY    NUMBER
551   , x_msg_data                OUT NOCOPY    VARCHAR2
552   , x_task_id                 OUT NOCOPY    NUMBER
553   , p_attribute1              IN            VARCHAR2 DEFAULT NULL
554   , p_attribute2              IN            VARCHAR2 DEFAULT NULL
555   , p_attribute3              IN            VARCHAR2 DEFAULT NULL
556   , p_attribute4              IN            VARCHAR2 DEFAULT NULL
557   , p_attribute5              IN            VARCHAR2 DEFAULT NULL
558   , p_attribute6              IN            VARCHAR2 DEFAULT NULL
559   , p_attribute7              IN            VARCHAR2 DEFAULT NULL
560   , p_attribute8              IN            VARCHAR2 DEFAULT NULL
561   , p_attribute9              IN            VARCHAR2 DEFAULT NULL
562   , p_attribute10             IN            VARCHAR2 DEFAULT NULL
563   , p_attribute11             IN            VARCHAR2 DEFAULT NULL
564   , p_attribute12             IN            VARCHAR2 DEFAULT NULL
565   , p_attribute13             IN            VARCHAR2 DEFAULT NULL
566   , p_attribute14             IN            VARCHAR2 DEFAULT NULL
567   , p_attribute15             IN            VARCHAR2 DEFAULT NULL
568   , p_attribute_category      IN            VARCHAR2 DEFAULT NULL
569   , p_date_selected           IN            VARCHAR2 DEFAULT NULL
570   , p_category_id             IN            NUMBER DEFAULT NULL
571   , p_show_on_calendar        IN            VARCHAR2 DEFAULT NULL
572   , p_owner_status_id         IN            NUMBER DEFAULT NULL
573   , p_template_id             IN            NUMBER DEFAULT NULL
574   , p_template_group_id       IN            NUMBER DEFAULT NULL
575   , p_enable_workflow         IN            VARCHAR2
576   , p_abort_workflow          IN            VARCHAR2
577   , p_entity                  IN            VARCHAR2
578   , p_free_busy_type          IN            VARCHAR2
579   ) IS
580     l_api_version CONSTANT NUMBER       := 1.0;
581     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK';
582   BEGIN
583     SAVEPOINT create_task_pvt1;
584     x_return_status  := fnd_api.g_ret_sts_success;
585 
586     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
587       RAISE fnd_api.g_exc_unexpected_error;
588     END IF;
589 
590     IF fnd_api.to_boolean(p_init_msg_list) THEN
591       fnd_msg_pub.initialize;
592     END IF;
593 
594     -- call new version, passing defaults for new functionality
595     create_task(
596       p_api_version                => p_api_version
597     , p_init_msg_list              => p_init_msg_list
598     , p_commit                     => fnd_api.g_false
599     , p_task_id                    => p_task_id
600     , p_task_name                  => p_task_name
601     , p_task_type_id               => p_task_type_id
602     , p_description                => p_description
603     , p_task_status_id             => p_task_status_id
604     , p_task_priority_id           => p_task_priority_id
605     , p_owner_type_code            => p_owner_type_code
606     , p_owner_id                   => p_owner_id
607     , p_owner_territory_id         => p_owner_territory_id
608     , p_assigned_by_id             => p_assigned_by_id
609     , p_customer_id                => p_customer_id
610     , p_cust_account_id            => p_cust_account_id
611     , p_address_id                 => p_address_id
612     , p_planned_start_date         => p_planned_start_date
613     , p_planned_end_date           => p_planned_end_date
614     , p_scheduled_start_date       => p_scheduled_start_date
615     , p_scheduled_end_date         => p_scheduled_end_date
616     , p_actual_start_date          => p_actual_start_date
617     , p_actual_end_date            => p_actual_end_date
618     , p_timezone_id                => p_timezone_id
619     , p_source_object_type_code    => p_source_object_type_code
620     , p_source_object_id           => p_source_object_id
621     , p_source_object_name         => p_source_object_name
622     , p_duration                   => p_duration
623     , p_duration_uom               => p_duration_uom
624     , p_planned_effort             => p_planned_effort
625     , p_planned_effort_uom         => p_planned_effort_uom
626     , p_actual_effort              => p_actual_effort
627     , p_actual_effort_uom          => p_actual_effort_uom
628     , p_percentage_complete        => p_percentage_complete
629     , p_reason_code                => p_reason_code
630     , p_private_flag               => p_private_flag
631     , p_publish_flag               => p_publish_flag
632     , p_restrict_closure_flag      => p_restrict_closure_flag
633     , p_multi_booked_flag          => p_multi_booked_flag
634     , p_milestone_flag             => p_milestone_flag
635     , p_holiday_flag               => p_holiday_flag
636     , p_billable_flag              => p_billable_flag
637     , p_bound_mode_code            => p_bound_mode_code
638     , p_soft_bound_flag            => p_soft_bound_flag
639     , p_workflow_process_id        => p_workflow_process_id
640     , p_notification_flag          => p_notification_flag
641     , p_notification_period        => p_notification_period
642     , p_notification_period_uom    => p_notification_period_uom
643     , p_parent_task_id             => p_parent_task_id
644     , p_alarm_start                => p_alarm_start
645     , p_alarm_start_uom            => p_alarm_start_uom
646     , p_alarm_on                   => p_alarm_on
647     , p_alarm_count                => p_alarm_count
648     , p_alarm_interval             => p_alarm_interval
649     , p_alarm_interval_uom         => p_alarm_interval_uom
650     , p_palm_flag                  => p_palm_flag
651     , p_wince_flag                 => p_wince_flag
652     , p_laptop_flag                => p_laptop_flag
653     , p_device1_flag               => p_device1_flag
654     , p_device2_flag               => p_device2_flag
655     , p_device3_flag               => p_device3_flag
656     , p_costs                      => p_costs
657     , p_currency_code              => p_currency_code
658     , p_escalation_level           => p_escalation_level
659     , x_return_status              => x_return_status
660     , x_msg_count                  => x_msg_count
661     , x_msg_data                   => x_msg_data
662     , x_task_id                    => x_task_id
663     , p_attribute1                 => p_attribute1
664     , p_attribute2                 => p_attribute2
665     , p_attribute3                 => p_attribute3
666     , p_attribute4                 => p_attribute4
667     , p_attribute5                 => p_attribute5
668     , p_attribute6                 => p_attribute6
669     , p_attribute7                 => p_attribute7
670     , p_attribute8                 => p_attribute8
671     , p_attribute9                 => p_attribute9
672     , p_attribute10                => p_attribute10
673     , p_attribute11                => p_attribute11
674     , p_attribute12                => p_attribute12
675     , p_attribute13                => p_attribute13
676     , p_attribute14                => p_attribute14
677     , p_attribute15                => p_attribute15
678     , p_attribute_category         => p_attribute_category
679     , p_date_selected              => p_date_selected
680     , p_category_id                => p_category_id
681     , p_show_on_calendar           => p_show_on_calendar
682     , p_owner_status_id            => p_owner_status_id
683     , p_template_id                => p_template_id
684     , p_template_group_id          => p_template_group_id
685     , p_enable_workflow            => p_enable_workflow
686     , p_abort_workflow             => p_abort_workflow
687     , p_entity                     => p_entity
688     , p_free_busy_type             => p_free_busy_type
689     , p_task_confirmation_status   => 'N'
690     , p_task_confirmation_counter  => NULL
691     , p_task_split_flag            => NULL
692     , p_reference_flag             => NULL
693     , p_child_position             => NULL
694     , p_child_sequence_num         => NULL
695     );
696 
697     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
698       x_return_status  := fnd_api.g_ret_sts_unexp_error;
699       RAISE fnd_api.g_exc_unexpected_error;
700     END IF;
701 
702     IF fnd_api.to_boolean(p_commit) THEN
703       COMMIT WORK;
704     END IF;
705 
706     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
707   EXCEPTION
708     WHEN fnd_api.g_exc_unexpected_error THEN
709       ROLLBACK TO create_task_pvt1;
710       x_return_status  := fnd_api.g_ret_sts_unexp_error;
711       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
712     WHEN OTHERS THEN
713       ROLLBACK TO create_task_pvt1;
714       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
715       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
716       fnd_msg_pub.ADD;
717       x_return_status  := fnd_api.g_ret_sts_unexp_error;
718       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
719   END;
720 
721   -- Overloaded version for Simplex Changes..
722   PROCEDURE create_task(
723     p_api_version               IN            NUMBER
724   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
725   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
726   , p_task_id                   IN            NUMBER DEFAULT NULL
727   , p_task_name                 IN            VARCHAR2
728   , p_task_type_id              IN            NUMBER DEFAULT NULL
729   , p_description               IN            VARCHAR2 DEFAULT NULL
730   , p_task_status_id            IN            NUMBER DEFAULT NULL
731   , p_task_priority_id          IN            NUMBER DEFAULT NULL
732   , p_owner_type_code           IN            VARCHAR2 DEFAULT NULL
733   , p_owner_id                  IN            NUMBER DEFAULT NULL
734   , p_owner_territory_id        IN            NUMBER DEFAULT NULL
735   , p_assigned_by_id            IN            NUMBER DEFAULT NULL
736   , p_customer_id               IN            NUMBER DEFAULT NULL
737   , p_cust_account_id           IN            NUMBER DEFAULT NULL
738   , p_address_id                IN            NUMBER DEFAULT NULL
739   ,   ---- hz_party_sites
740     p_planned_start_date        IN            DATE DEFAULT NULL
741   , p_planned_end_date          IN            DATE DEFAULT NULL
742   , p_scheduled_start_date      IN            DATE DEFAULT NULL
743   , p_scheduled_end_date        IN            DATE DEFAULT NULL
744   , p_actual_start_date         IN            DATE DEFAULT NULL
745   , p_actual_end_date           IN            DATE DEFAULT NULL
746   , p_timezone_id               IN            NUMBER DEFAULT NULL
747   , p_source_object_type_code   IN            VARCHAR2 DEFAULT NULL
748   , p_source_object_id          IN            NUMBER DEFAULT NULL
749   , p_source_object_name        IN            VARCHAR2 DEFAULT NULL
750   , p_duration                  IN            NUMBER DEFAULT NULL
751   , p_duration_uom              IN            VARCHAR2 DEFAULT NULL
752   , p_planned_effort            IN            NUMBER DEFAULT NULL
753   , p_planned_effort_uom        IN            VARCHAR2 DEFAULT NULL
754   , p_actual_effort             IN            NUMBER DEFAULT NULL
755   , p_actual_effort_uom         IN            VARCHAR2 DEFAULT NULL
756   , p_percentage_complete       IN            NUMBER DEFAULT NULL
757   , p_reason_code               IN            VARCHAR2 DEFAULT NULL
758   , p_private_flag              IN            VARCHAR2 DEFAULT NULL
759   , p_publish_flag              IN            VARCHAR2 DEFAULT NULL
760   , p_restrict_closure_flag     IN            VARCHAR2 DEFAULT NULL
761   , p_multi_booked_flag         IN            VARCHAR2 DEFAULT NULL
762   , p_milestone_flag            IN            VARCHAR2 DEFAULT NULL
763   , p_holiday_flag              IN            VARCHAR2 DEFAULT NULL
764   , p_billable_flag             IN            VARCHAR2 DEFAULT NULL
765   , p_bound_mode_code           IN            VARCHAR2 DEFAULT NULL
766   , p_soft_bound_flag           IN            VARCHAR2 DEFAULT NULL
767   , p_workflow_process_id       IN            NUMBER DEFAULT NULL
768   , p_notification_flag         IN            VARCHAR2 DEFAULT NULL
769   , p_notification_period       IN            NUMBER DEFAULT NULL
770   , p_notification_period_uom   IN            VARCHAR2 DEFAULT NULL
771   , p_parent_task_id            IN            NUMBER DEFAULT NULL
772   , p_alarm_start               IN            NUMBER DEFAULT NULL
773   , p_alarm_start_uom           IN            VARCHAR2 DEFAULT NULL
774   , p_alarm_on                  IN            VARCHAR2 DEFAULT NULL
775   , p_alarm_count               IN            NUMBER DEFAULT NULL
776   , p_alarm_interval            IN            NUMBER DEFAULT NULL
777   , p_alarm_interval_uom        IN            VARCHAR2 DEFAULT NULL
778   , p_palm_flag                 IN            VARCHAR2 DEFAULT NULL
779   , p_wince_flag                IN            VARCHAR2 DEFAULT NULL
780   , p_laptop_flag               IN            VARCHAR2 DEFAULT NULL
781   , p_device1_flag              IN            VARCHAR2 DEFAULT NULL
782   , p_device2_flag              IN            VARCHAR2 DEFAULT NULL
783   , p_device3_flag              IN            VARCHAR2 DEFAULT NULL
784   , p_costs                     IN            NUMBER DEFAULT NULL
785   , p_currency_code             IN            VARCHAR2 DEFAULT NULL
786   , p_escalation_level          IN            VARCHAR2 DEFAULT NULL
787   , x_return_status             OUT NOCOPY    VARCHAR2
788   , x_msg_count                 OUT NOCOPY    NUMBER
789   , x_msg_data                  OUT NOCOPY    VARCHAR2
790   , x_task_id                   OUT NOCOPY    NUMBER
791   , p_attribute1                IN            VARCHAR2 DEFAULT NULL
792   , p_attribute2                IN            VARCHAR2 DEFAULT NULL
793   , p_attribute3                IN            VARCHAR2 DEFAULT NULL
794   , p_attribute4                IN            VARCHAR2 DEFAULT NULL
795   , p_attribute5                IN            VARCHAR2 DEFAULT NULL
796   , p_attribute6                IN            VARCHAR2 DEFAULT NULL
797   , p_attribute7                IN            VARCHAR2 DEFAULT NULL
798   , p_attribute8                IN            VARCHAR2 DEFAULT NULL
799   , p_attribute9                IN            VARCHAR2 DEFAULT NULL
800   , p_attribute10               IN            VARCHAR2 DEFAULT NULL
801   , p_attribute11               IN            VARCHAR2 DEFAULT NULL
802   , p_attribute12               IN            VARCHAR2 DEFAULT NULL
803   , p_attribute13               IN            VARCHAR2 DEFAULT NULL
804   , p_attribute14               IN            VARCHAR2 DEFAULT NULL
805   , p_attribute15               IN            VARCHAR2 DEFAULT NULL
806   , p_attribute_category        IN            VARCHAR2 DEFAULT NULL
807   , p_date_selected             IN            VARCHAR2 DEFAULT NULL
808   , p_category_id               IN            NUMBER DEFAULT NULL
809   , p_show_on_calendar          IN            VARCHAR2 DEFAULT NULL
810   , p_owner_status_id           IN            NUMBER DEFAULT NULL
811   , p_template_id               IN            NUMBER DEFAULT NULL
812   , p_template_group_id         IN            NUMBER DEFAULT NULL
813   , p_enable_workflow           IN            VARCHAR2
814   , p_abort_workflow            IN            VARCHAR2
815   , p_entity                    IN            VARCHAR2
816   , p_free_busy_type            IN            VARCHAR2
817   , p_task_confirmation_status  IN            VARCHAR2
818   , p_task_confirmation_counter IN            NUMBER
819   , p_task_split_flag           IN            VARCHAR2
820   , p_reference_flag            IN            VARCHAR2 DEFAULT NULL
821   , p_child_position            IN            VARCHAR2 DEFAULT NULL
822   , p_child_sequence_num        IN            NUMBER DEFAULT NULL
823   ) IS
824     l_api_version CONSTANT NUMBER       := 1.0;
825     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK';
826   BEGIN
827     SAVEPOINT create_task_pvt4;
828     x_return_status  := fnd_api.g_ret_sts_success;
829 
830     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
831       RAISE fnd_api.g_exc_unexpected_error;
832     END IF;
833 
834     IF fnd_api.to_boolean(p_init_msg_list) THEN
835       fnd_msg_pub.initialize;
836     END IF;
837 
838     -- call new version, passing defaults for new functionality
839     create_task(
840       p_api_version                => p_api_version
841     , p_init_msg_list              => p_init_msg_list
842     , p_commit                     => fnd_api.g_false
843     , p_task_id                    => p_task_id
844     , p_task_name                  => p_task_name
845     , p_task_type_id               => p_task_type_id
846     , p_description                => p_description
847     , p_task_status_id             => p_task_status_id
848     , p_task_priority_id           => p_task_priority_id
849     , p_owner_type_code            => p_owner_type_code
850     , p_owner_id                   => p_owner_id
851     , p_owner_territory_id         => p_owner_territory_id
852     , p_assigned_by_id             => p_assigned_by_id
853     , p_customer_id                => p_customer_id
854     , p_cust_account_id            => p_cust_account_id
855     , p_address_id                 => p_address_id
856     ,   ---- hz_party_sites
857       p_planned_start_date         => p_planned_start_date
858     , p_planned_end_date           => p_planned_end_date
859     , p_scheduled_start_date       => p_scheduled_start_date
860     , p_scheduled_end_date         => p_scheduled_end_date
861     , p_actual_start_date          => p_actual_start_date
862     , p_actual_end_date            => p_actual_end_date
863     , p_timezone_id                => p_timezone_id
864     , p_source_object_type_code    => p_source_object_type_code
865     , p_source_object_id           => p_source_object_id
866     , p_source_object_name         => p_source_object_name
867     , p_duration                   => p_duration
868     , p_duration_uom               => p_duration_uom
869     , p_planned_effort             => p_planned_effort
870     , p_planned_effort_uom         => p_planned_effort_uom
871     , p_actual_effort              => p_actual_effort
872     , p_actual_effort_uom          => p_actual_effort_uom
873     , p_percentage_complete        => p_percentage_complete
874     , p_reason_code                => p_reason_code
875     , p_private_flag               => p_private_flag
876     , p_publish_flag               => p_publish_flag
877     , p_restrict_closure_flag      => p_restrict_closure_flag
878     , p_multi_booked_flag          => p_multi_booked_flag
879     , p_milestone_flag             => p_milestone_flag
880     , p_holiday_flag               => p_holiday_flag
881     , p_billable_flag              => p_billable_flag
882     , p_bound_mode_code            => p_bound_mode_code
883     , p_soft_bound_flag            => p_soft_bound_flag
884     , p_workflow_process_id        => p_workflow_process_id
885     , p_notification_flag          => p_notification_flag
886     , p_notification_period        => p_notification_period
887     , p_notification_period_uom    => p_notification_period_uom
888     , p_parent_task_id             => p_parent_task_id
889     , p_alarm_start                => p_alarm_start
890     , p_alarm_start_uom            => p_alarm_start_uom
891     , p_alarm_on                   => p_alarm_on
892     , p_alarm_count                => p_alarm_count
893     , p_alarm_interval             => p_alarm_interval
894     , p_alarm_interval_uom         => p_alarm_interval_uom
895     , p_palm_flag                  => p_palm_flag
896     , p_wince_flag                 => p_wince_flag
897     , p_laptop_flag                => p_laptop_flag
898     , p_device1_flag               => p_device1_flag
899     , p_device2_flag               => p_device2_flag
900     , p_device3_flag               => p_device3_flag
901     , p_costs                      => p_costs
902     , p_currency_code              => p_currency_code
903     , p_escalation_level           => p_escalation_level
904     , x_return_status              => x_return_status
905     , x_msg_count                  => x_msg_count
906     , x_msg_data                   => x_msg_data
907     , x_task_id                    => x_task_id
908     , p_attribute1                 => p_attribute1
909     , p_attribute2                 => p_attribute2
910     , p_attribute3                 => p_attribute3
911     , p_attribute4                 => p_attribute4
912     , p_attribute5                 => p_attribute5
913     , p_attribute6                 => p_attribute6
914     , p_attribute7                 => p_attribute7
915     , p_attribute8                 => p_attribute8
916     , p_attribute9                 => p_attribute9
917     , p_attribute10                => p_attribute10
918     , p_attribute11                => p_attribute11
919     , p_attribute12                => p_attribute12
920     , p_attribute13                => p_attribute13
921     , p_attribute14                => p_attribute14
922     , p_attribute15                => p_attribute15
923     , p_attribute_category         => p_attribute_category
924     , p_date_selected              => p_date_selected
925     , p_category_id                => p_category_id
926     , p_show_on_calendar           => p_show_on_calendar
927     , p_owner_status_id            => p_owner_status_id
928     , p_template_id                => p_template_id
929     , p_template_group_id          => p_template_group_id
930     , p_enable_workflow            => p_enable_workflow
931     , p_abort_workflow             => p_abort_workflow
932     , p_entity                     => p_entity
933     , p_free_busy_type             => p_free_busy_type
934     , p_task_confirmation_status   => p_task_confirmation_status
935     , p_task_confirmation_counter  => p_task_confirmation_counter
936     , p_task_split_flag            => p_task_split_flag
937     , p_reference_flag             => p_reference_flag
938     , p_child_position             => p_child_position
939     , p_child_sequence_num         => p_child_sequence_num
940     , p_location_id                => NULL
941     );
942 
943     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
944       x_return_status  := fnd_api.g_ret_sts_unexp_error;
945       RAISE fnd_api.g_exc_unexpected_error;
946     END IF;
947 
948     IF fnd_api.to_boolean(p_commit) THEN
949       COMMIT WORK;
950     END IF;
951 
952     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
953   EXCEPTION
954     WHEN fnd_api.g_exc_unexpected_error THEN
955       ROLLBACK TO create_task_pvt4;
956       x_return_status  := fnd_api.g_ret_sts_unexp_error;
957       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
958     WHEN OTHERS THEN
959       ROLLBACK TO create_task_pvt4;
960       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
961       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
962       fnd_msg_pub.ADD;
963       x_return_status  := fnd_api.g_ret_sts_unexp_error;
964       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
965   END;
966 
967   -- Overloaded version for Location Id..
968   PROCEDURE create_task(
969     p_api_version               IN            NUMBER
970   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
971   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
972   , p_task_id                   IN            NUMBER DEFAULT NULL
973   , p_task_name                 IN            VARCHAR2
974   , p_task_type_id              IN            NUMBER DEFAULT NULL
975   , p_description               IN            VARCHAR2 DEFAULT NULL
976   , p_task_status_id            IN            NUMBER DEFAULT NULL
977   , p_task_priority_id          IN            NUMBER DEFAULT NULL
978   , p_owner_type_code           IN            VARCHAR2 DEFAULT NULL
979   , p_owner_id                  IN            NUMBER DEFAULT NULL
980   , p_owner_territory_id        IN            NUMBER DEFAULT NULL
981   , p_assigned_by_id            IN            NUMBER DEFAULT NULL
982   , p_customer_id               IN            NUMBER DEFAULT NULL
983   , p_cust_account_id           IN            NUMBER DEFAULT NULL
984   , p_address_id                IN            NUMBER DEFAULT NULL
985   , p_planned_start_date        IN            DATE DEFAULT NULL
986   , p_planned_end_date          IN            DATE DEFAULT NULL
987   , p_scheduled_start_date      IN            DATE DEFAULT NULL
988   , p_scheduled_end_date        IN            DATE DEFAULT NULL
989   , p_actual_start_date         IN            DATE DEFAULT NULL
990   , p_actual_end_date           IN            DATE DEFAULT NULL
991   , p_timezone_id               IN            NUMBER DEFAULT NULL
992   , p_source_object_type_code   IN            VARCHAR2 DEFAULT NULL
993   , p_source_object_id          IN            NUMBER DEFAULT NULL
994   , p_source_object_name        IN            VARCHAR2 DEFAULT NULL
995   , p_duration                  IN            NUMBER DEFAULT NULL
996   , p_duration_uom              IN            VARCHAR2 DEFAULT NULL
997   , p_planned_effort            IN            NUMBER DEFAULT NULL
998   , p_planned_effort_uom        IN            VARCHAR2 DEFAULT NULL
999   , p_actual_effort             IN            NUMBER DEFAULT NULL
1000   , p_actual_effort_uom         IN            VARCHAR2 DEFAULT NULL
1001   , p_percentage_complete       IN            NUMBER DEFAULT NULL
1002   , p_reason_code               IN            VARCHAR2 DEFAULT NULL
1003   , p_private_flag              IN            VARCHAR2 DEFAULT NULL
1004   , p_publish_flag              IN            VARCHAR2 DEFAULT NULL
1005   , p_restrict_closure_flag     IN            VARCHAR2 DEFAULT NULL
1006   , p_multi_booked_flag         IN            VARCHAR2 DEFAULT NULL
1007   , p_milestone_flag            IN            VARCHAR2 DEFAULT NULL
1008   , p_holiday_flag              IN            VARCHAR2 DEFAULT NULL
1009   , p_billable_flag             IN            VARCHAR2 DEFAULT NULL
1010   , p_bound_mode_code           IN            VARCHAR2 DEFAULT NULL
1011   , p_soft_bound_flag           IN            VARCHAR2 DEFAULT NULL
1012   , p_workflow_process_id       IN            NUMBER DEFAULT NULL
1013   , p_notification_flag         IN            VARCHAR2 DEFAULT NULL
1014   , p_notification_period       IN            NUMBER DEFAULT NULL
1015   , p_notification_period_uom   IN            VARCHAR2 DEFAULT NULL
1016   , p_parent_task_id            IN            NUMBER DEFAULT NULL
1017   , p_alarm_start               IN            NUMBER DEFAULT NULL
1018   , p_alarm_start_uom           IN            VARCHAR2 DEFAULT NULL
1019   , p_alarm_on                  IN            VARCHAR2 DEFAULT NULL
1020   , p_alarm_count               IN            NUMBER DEFAULT NULL
1021   , p_alarm_interval            IN            NUMBER DEFAULT NULL
1022   , p_alarm_interval_uom        IN            VARCHAR2 DEFAULT NULL
1023   , p_palm_flag                 IN            VARCHAR2 DEFAULT NULL
1024   , p_wince_flag                IN            VARCHAR2 DEFAULT NULL
1025   , p_laptop_flag               IN            VARCHAR2 DEFAULT NULL
1026   , p_device1_flag              IN            VARCHAR2 DEFAULT NULL
1027   , p_device2_flag              IN            VARCHAR2 DEFAULT NULL
1028   , p_device3_flag              IN            VARCHAR2 DEFAULT NULL
1029   , p_costs                     IN            NUMBER DEFAULT NULL
1030   , p_currency_code             IN            VARCHAR2 DEFAULT NULL
1031   , p_escalation_level          IN            VARCHAR2 DEFAULT NULL
1032   , x_return_status             OUT NOCOPY    VARCHAR2
1033   , x_msg_count                 OUT NOCOPY    NUMBER
1034   , x_msg_data                  OUT NOCOPY    VARCHAR2
1035   , x_task_id                   OUT NOCOPY    NUMBER
1036   , p_attribute1                IN            VARCHAR2 DEFAULT NULL
1037   , p_attribute2                IN            VARCHAR2 DEFAULT NULL
1038   , p_attribute3                IN            VARCHAR2 DEFAULT NULL
1039   , p_attribute4                IN            VARCHAR2 DEFAULT NULL
1040   , p_attribute5                IN            VARCHAR2 DEFAULT NULL
1041   , p_attribute6                IN            VARCHAR2 DEFAULT NULL
1042   , p_attribute7                IN            VARCHAR2 DEFAULT NULL
1043   , p_attribute8                IN            VARCHAR2 DEFAULT NULL
1044   , p_attribute9                IN            VARCHAR2 DEFAULT NULL
1045   , p_attribute10               IN            VARCHAR2 DEFAULT NULL
1046   , p_attribute11               IN            VARCHAR2 DEFAULT NULL
1047   , p_attribute12               IN            VARCHAR2 DEFAULT NULL
1048   , p_attribute13               IN            VARCHAR2 DEFAULT NULL
1049   , p_attribute14               IN            VARCHAR2 DEFAULT NULL
1050   , p_attribute15               IN            VARCHAR2 DEFAULT NULL
1051   , p_attribute_category        IN            VARCHAR2 DEFAULT NULL
1052   , p_date_selected             IN            VARCHAR2 DEFAULT NULL
1053   , p_category_id               IN            NUMBER DEFAULT NULL
1054   , p_show_on_calendar          IN            VARCHAR2 DEFAULT NULL
1055   , p_owner_status_id           IN            NUMBER DEFAULT NULL
1056   , p_template_id               IN            NUMBER DEFAULT NULL
1057   , p_template_group_id         IN            NUMBER DEFAULT NULL
1058   , p_enable_workflow           IN            VARCHAR2
1059   , p_abort_workflow            IN            VARCHAR2
1060   , p_entity                    IN            VARCHAR2
1061   , p_free_busy_type            IN            VARCHAR2
1062   , p_task_confirmation_status  IN            VARCHAR2
1063   , p_task_confirmation_counter IN            NUMBER
1064   , p_task_split_flag           IN            VARCHAR2
1065   , p_reference_flag            IN            VARCHAR2 DEFAULT NULL
1066   , p_child_position            IN            VARCHAR2 DEFAULT NULL
1067   , p_child_sequence_num        IN            NUMBER DEFAULT NULL
1068   , p_location_id               IN            NUMBER
1069   , p_copied_from_task_id       IN            NUMBER DEFAULT NULL
1070   ) IS
1071     l_api_version     CONSTANT NUMBER                                           := 1.0;
1072     l_api_name        CONSTANT VARCHAR2(30)                                     := 'CREATE_TASK';
1073 
1074     l_return_status            VARCHAR2(1)                                      := fnd_api.g_ret_sts_success;
1075     l_rowid                    ROWID;
1076     l_task_number              jtf_tasks_b.task_number%TYPE;
1077     l_owner_id                 jtf_tasks_b.owner_id%TYPE                        := p_owner_id;
1078     l_owner_type_code          jtf_tasks_b.owner_type_code%TYPE                 := p_owner_type_code;
1079     l_task_type_id             jtf_tasks_b.task_type_id%TYPE                    := p_task_type_id;
1080     l_task_status_id           jtf_tasks_b.task_status_id%TYPE                  := p_task_status_id;
1081     l_task_priority_id         jtf_tasks_b.task_priority_id%TYPE                := p_task_priority_id;
1082     l_source_object_id         jtf_tasks_b.source_object_id%TYPE                := p_source_object_id;
1083     ---
1084     --- to fix bug #2224949
1085     ---
1086     l_source_object_name       jtf_tasks_b.source_object_name%TYPE              := jtf_task_utl.check_truncation(p_object_name => p_source_object_name);
1087     l_source_object_type_code  jtf_tasks_b.source_object_type_code%TYPE         := p_source_object_type_code;
1088     l_duration                 jtf_tasks_b.DURATION%TYPE                        := p_duration;
1089     l_duration_uom             jtf_tasks_b.duration_uom%TYPE                    := p_duration_uom;
1090     l_planned_effort           jtf_tasks_b.planned_effort%TYPE                  := p_planned_effort;
1091     l_planned_effort_uom       jtf_tasks_b.planned_effort_uom%TYPE              := p_planned_effort_uom;
1092     l_actual_effort            jtf_tasks_b.actual_effort%TYPE                   := p_actual_effort;
1093     l_actual_effort_uom        jtf_tasks_b.actual_effort_uom%TYPE               := p_actual_effort_uom;
1094     l_percentage_complete      jtf_tasks_b.percentage_complete%TYPE             := p_percentage_complete;
1095     l_reason_code              jtf_tasks_b.reason_code%TYPE                     := p_reason_code;
1096     l_date_selected            jtf_tasks_b.date_selected%TYPE;
1097     l_calendar_start_date      jtf_tasks_b.calendar_start_date%TYPE;
1098     l_calendar_end_date        jtf_tasks_b.calendar_end_date%TYPE;
1099     l_planned_start_date       jtf_tasks_b.planned_start_date%TYPE              := p_planned_start_date;
1100     l_planned_end_date         jtf_tasks_b.planned_end_date%TYPE                := p_planned_end_date;
1101     l_scheduled_start_date     jtf_tasks_b.scheduled_start_date%TYPE            := p_scheduled_start_date;
1102     l_scheduled_end_date       jtf_tasks_b.scheduled_end_date%TYPE              := p_scheduled_end_date;
1103     l_actual_start_date        jtf_tasks_b.actual_start_date%TYPE               := p_actual_start_date;
1104     l_actual_end_date          jtf_tasks_b.actual_end_date%TYPE                 := p_actual_end_date;
1105     l_task_assignment_id       jtf_task_assignments.task_assignment_id%TYPE;
1106     l_category_id              jtf_task_assignments.category_id%TYPE            := p_category_id;
1107     l_owner_status_id          jtf_task_assignments.assignment_status_id%TYPE;
1108     l_show_on_calendar         jtf_task_assignments.show_on_calendar%TYPE;
1109     l_task_reference_id        jtf_task_references_b.task_reference_id%TYPE;
1110     l_enable_workflow          VARCHAR2(1)                                      := p_enable_workflow;
1111     l_abort_workflow           VARCHAR2(1)                                      := p_abort_workflow;
1112     x_event_return_status      VARCHAR2(100);
1113     -- Booking enhancement
1114     l_entity                   jtf_tasks_b.entity%TYPE                          := p_entity;
1115     l_free_busy_type           jtf_task_all_assignments.free_busy_type%TYPE     := p_free_busy_type;
1116     l_open_flag                VARCHAR2(1);
1117     l_task_confirmation_status jtf_tasks_b.task_confirmation_status%TYPE        := p_task_confirmation_status;
1118     l_res_type                 jtf_task_rsc_reqs.resource_type_code%TYPE;
1119     l_req_units                jtf_task_rsc_reqs.required_units%TYPE;
1120     l_enabled_flag             jtf_task_rsc_reqs.enabled_flag%TYPE;
1121     l_resource_req_id          jtf_task_rsc_reqs.resource_req_id%TYPE;
1122 
1123     CURSOR c_type_reqs IS
1124       SELECT resource_type_code, required_units, enabled_flag
1125         FROM jtf_task_rsc_reqs
1126        WHERE task_type_id = l_task_type_id;
1127 
1128     CURSOR c_jtf_tasks IS
1129       SELECT 'Y'
1130         FROM jtf_tasks_b
1131        WHERE task_id = p_task_id;
1132 
1133     l_task_id_duplicate        VARCHAR2(1);
1134     l_task_rec_type            jtf_tasks_pvt.task_rec_type;
1135   BEGIN
1136     SAVEPOINT create_task_pvt;
1137 
1138     x_return_status := fnd_api.g_ret_sts_success;
1139 
1140     IF fnd_api.to_boolean(p_init_msg_list) THEN
1141       fnd_msg_pub.initialize;
1142     END IF;
1143 
1144     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
1145       RAISE fnd_api.g_exc_unexpected_error;
1146     END IF;
1147 
1148     IF p_task_name IS NULL THEN
1149       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_NAME');
1150       fnd_msg_pub.ADD;
1151       RAISE fnd_api.g_exc_unexpected_error;
1152     END IF;
1153 
1154     IF p_task_split_flag IS NOT NULL THEN
1155       IF NOT p_task_split_flag IN('M', 'D') THEN
1156         fnd_message.set_name('JTF', 'JTF_TASK_CONSTRUCT_ID');
1157         fnd_message.set_token('%P_SHITF_CONSTRUCT_ID', 'task split flag');
1158         fnd_msg_pub.ADD;
1159         RAISE fnd_api.g_exc_unexpected_error;
1160       END IF;
1161     END IF;
1162 
1163     IF NOT p_task_confirmation_status IN('N', 'R', 'C') THEN
1164       fnd_message.set_name('JTF', 'JTF_TASK_CONSTRUCT_ID');
1165       fnd_message.set_token('P_SHITF_CONSTRUCT_ID', 'task confirmation status');
1166       fnd_msg_pub.ADD;
1167       RAISE fnd_api.g_exc_unexpected_error;
1168     END IF;
1169 
1170     IF p_enable_workflow IS NULL OR p_enable_workflow = fnd_api.g_miss_char THEN
1171       l_enable_workflow  := g_enable_workflow;
1172     END IF;
1173 
1174     IF p_abort_workflow IS NULL OR p_abort_workflow = fnd_api.g_miss_char THEN
1175       l_abort_workflow  := g_abort_workflow;
1176     END IF;
1177 
1178     IF p_task_id IS NOT NULL THEN
1179       IF p_task_id > jtf_task_utl_ext.get_last_number('JTF_TASKS_S') AND p_task_id < 1e+12 THEN
1180         fnd_message.set_name('JTF', 'JTF_TASK_OUT_OF_RANGE');
1181         fnd_msg_pub.ADD;
1182         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1183         RAISE fnd_api.g_exc_unexpected_error;
1184       END IF;
1185 
1186       OPEN c_jtf_tasks;
1187       FETCH c_jtf_tasks INTO l_task_id_duplicate;
1188       CLOSE c_jtf_tasks;
1189 
1190       IF l_task_id_duplicate = 'Y' THEN
1191         fnd_message.set_name('JTF', 'JTF_TASK_DUPLICATE_TASK_ID');
1192         fnd_message.set_token('P_TASK_ID', p_task_id);
1193         fnd_msg_pub.ADD;
1194         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1195         RAISE fnd_api.g_exc_unexpected_error;
1196       END IF;
1197 
1198       SELECT jtf_task_number_s.NEXTVAL
1199         INTO l_task_number
1200         FROM DUAL;
1201 
1202       x_task_id := p_task_id;
1203     ELSE
1204       SELECT jtf_tasks_s.NEXTVAL
1205         INTO x_task_id
1206         FROM DUAL;
1207 
1208       SELECT jtf_task_number_s.NEXTVAL
1209         INTO l_task_number
1210         FROM DUAL;
1211     END IF;
1212 
1213     -- ------------------------------------------------------------------------
1214     -- Call jtf_task_utl procedure to set calendar_start_date and
1215     -- calendar_end_date
1216     -- ------------------------------------------------------------------------
1217     jtf_task_utl_ext.set_calendar_dates(
1218       p_show_on_calendar           => p_show_on_calendar
1219     , p_date_selected              => p_date_selected
1220     , p_planned_start_date         => l_planned_start_date
1221     , p_planned_end_date           => l_planned_end_date
1222     , p_scheduled_start_date       => l_scheduled_start_date
1223     , p_scheduled_end_date         => l_scheduled_end_date
1224     , p_actual_start_date          => l_actual_start_date
1225     , p_actual_end_date            => l_actual_end_date
1226     , x_show_on_calendar           => l_show_on_calendar
1227     , x_date_selected              => l_date_selected
1228     , x_calendar_start_date        => l_calendar_start_date
1229     , x_calendar_end_date          => l_calendar_end_date
1230     , x_return_status              => x_return_status
1231     , p_task_status_id             => l_task_status_id-- Enhancement 2683868: new parameter
1232     , p_creation_date              => SYSDATE   -- Enhancement 2683868: new parameter
1233     );
1234 
1235     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1236       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1237       RAISE fnd_api.g_exc_unexpected_error;
1238     END IF;
1239 
1240     -- ------------------------------------------------------------------------
1241     -- If date_selected was not present then set the appropriate dates
1242     -- depending on date_selected returned from set_calendar_dates, to fix
1243     -- bug #1889371
1244     -- ------------------------------------------------------------------------
1245     IF p_date_selected IS NULL OR p_date_selected = fnd_api.g_miss_char THEN
1246       IF l_date_selected = 'P' THEN
1247         l_planned_start_date  := l_calendar_start_date;
1248         l_planned_end_date    := l_calendar_end_date;
1249       ELSIF l_date_selected = 'S' THEN
1250         l_scheduled_start_date  := l_calendar_start_date;
1251         l_scheduled_end_date    := l_calendar_end_date;
1252       ELSIF l_date_selected = 'A' THEN
1253         l_actual_start_date  := l_calendar_start_date;
1254         l_actual_end_date    := l_calendar_end_date;
1255       END IF;
1256     END IF;
1257 
1258     -- ------------------------------------------------------------------------
1259     -- If type is Appointment then set scheduled dates to the value of the
1260     -- planned dates, to fix bug #1889178
1261     -- ------------------------------------------------------------------------
1262     IF p_source_object_type_code = 'APPOINTMENT' THEN
1263       l_scheduled_start_date  := l_planned_start_date;
1264       l_scheduled_end_date    := l_planned_end_date;
1265     END IF;
1266 
1267     -- ------------------------------------------------------------------------
1268     -- If source is Task or Appointment then set source_id to task_id and
1269     -- source_name to task_number
1270     -- ------------------------------------------------------------------------
1271     IF    p_source_object_type_code IN('TASK', 'APPOINTMENT', fnd_api.g_miss_char)
1272        OR p_source_object_type_code IS NULL THEN
1273       l_source_object_id    := x_task_id;
1274       l_source_object_name  := l_task_number;
1275 
1276       IF p_source_object_type_code IS NOT NULL AND p_source_object_type_code <> fnd_api.g_miss_char THEN
1277         l_source_object_type_code  := p_source_object_type_code;
1278       ELSE
1279         l_source_object_type_code  := 'TASK';
1280       END IF;
1281     ELSE
1282       l_source_object_type_code  := p_source_object_type_code;
1283       l_source_object_id         := p_source_object_id;
1284       --- to fix bug #2224949 and 2384479
1285       -- Bug 2602732
1286       l_source_object_name       := jtf_task_utl.check_truncation(jtf_task_utl.get_owner(l_source_object_type_code, l_source_object_id));
1287     --Chanaged For Bug # 2573617
1288     END IF;
1289 
1290     -- Enhancement for booking--
1291     IF (l_task_type_id = 22) THEN
1292       l_entity  := 'ESCALATION';
1293     ELSIF(l_source_object_type_code = 'APPOINTMENT') THEN
1294       l_entity  := 'APPOINTMENT';
1295     END IF;
1296 
1297     --- Validate Priority... Bug 3342819
1298     IF (l_task_priority_id = fnd_api.g_miss_num) OR(l_task_priority_id IS NULL) THEN
1299       l_task_priority_id  := 8;
1300     END IF;
1301 
1302     l_open_flag                                                := jtf_task_utl_ext.get_open_flag(l_task_status_id);
1303     jtf_tasks_pub.p_task_user_hooks.task_id                    := x_task_id;
1304     jtf_tasks_pub.p_task_user_hooks.task_number                := l_task_number;
1305     jtf_tasks_pub.p_task_user_hooks.task_name                  := p_task_name;
1306     jtf_tasks_pub.p_task_user_hooks.task_type_id               := l_task_type_id;
1307     jtf_tasks_pub.p_task_user_hooks.description                := p_description;
1308     jtf_tasks_pub.p_task_user_hooks.task_status_id             := l_task_status_id;
1309     jtf_tasks_pub.p_task_user_hooks.task_priority_id           := l_task_priority_id;
1310     jtf_tasks_pub.p_task_user_hooks.owner_type_code            := l_owner_type_code;
1311     jtf_tasks_pub.p_task_user_hooks.owner_id                   := l_owner_id;
1312     jtf_tasks_pub.p_task_user_hooks.owner_territory_id         := p_owner_territory_id;
1313     jtf_tasks_pub.p_task_user_hooks.assigned_by_id             := p_assigned_by_id;
1314     jtf_tasks_pub.p_task_user_hooks.customer_id                := p_customer_id;
1315     jtf_tasks_pub.p_task_user_hooks.cust_account_id            := p_cust_account_id;
1316     jtf_tasks_pub.p_task_user_hooks.address_id                 := p_address_id;
1317     jtf_tasks_pub.p_task_user_hooks.planned_start_date         := l_planned_start_date;
1318     jtf_tasks_pub.p_task_user_hooks.planned_end_date           := l_planned_end_date;
1319     jtf_tasks_pub.p_task_user_hooks.scheduled_start_date       := l_scheduled_start_date;
1320     jtf_tasks_pub.p_task_user_hooks.scheduled_end_date         := l_scheduled_end_date;
1321     jtf_tasks_pub.p_task_user_hooks.actual_start_date          := l_actual_start_date;
1322     jtf_tasks_pub.p_task_user_hooks.actual_end_date            := l_actual_end_date;
1323     jtf_tasks_pub.p_task_user_hooks.timezone_id                := p_timezone_id;
1324     jtf_tasks_pub.p_task_user_hooks.source_object_type_code    := l_source_object_type_code;
1325     jtf_tasks_pub.p_task_user_hooks.source_object_id           := l_source_object_id;
1326     jtf_tasks_pub.p_task_user_hooks.source_object_name         := l_source_object_name;
1327     jtf_tasks_pub.p_task_user_hooks.DURATION                   := l_duration;
1328     jtf_tasks_pub.p_task_user_hooks.duration_uom               := l_duration_uom;
1329     jtf_tasks_pub.p_task_user_hooks.planned_effort             := l_planned_effort;
1330     jtf_tasks_pub.p_task_user_hooks.planned_effort_uom         := l_planned_effort_uom;
1331     jtf_tasks_pub.p_task_user_hooks.actual_effort              := l_actual_effort;
1332     jtf_tasks_pub.p_task_user_hooks.actual_effort_uom          := l_actual_effort_uom;
1333     jtf_tasks_pub.p_task_user_hooks.percentage_complete        := l_percentage_complete;
1334     jtf_tasks_pub.p_task_user_hooks.reason_code                := l_reason_code;
1335     jtf_tasks_pub.p_task_user_hooks.private_flag               := p_private_flag;
1336     jtf_tasks_pub.p_task_user_hooks.publish_flag               := p_publish_flag;
1337     jtf_tasks_pub.p_task_user_hooks.restrict_closure_flag      := p_restrict_closure_flag;
1338     jtf_tasks_pub.p_task_user_hooks.multi_booked_flag          := p_multi_booked_flag;
1339     jtf_tasks_pub.p_task_user_hooks.milestone_flag             := p_milestone_flag;
1340     jtf_tasks_pub.p_task_user_hooks.holiday_flag               := p_holiday_flag;
1341     jtf_tasks_pub.p_task_user_hooks.billable_flag              := p_billable_flag;
1342     jtf_tasks_pub.p_task_user_hooks.bound_mode_code            := p_bound_mode_code;
1343     jtf_tasks_pub.p_task_user_hooks.soft_bound_flag            := p_soft_bound_flag;
1344     jtf_tasks_pub.p_task_user_hooks.workflow_process_id        := p_workflow_process_id;
1345     jtf_tasks_pub.p_task_user_hooks.notification_flag          := p_notification_flag;
1346     jtf_tasks_pub.p_task_user_hooks.notification_period        := p_notification_period;
1347     jtf_tasks_pub.p_task_user_hooks.notification_period_uom    := p_notification_period_uom;
1348     jtf_tasks_pub.p_task_user_hooks.parent_task_id             := p_parent_task_id;
1349     jtf_tasks_pub.p_task_user_hooks.alarm_start                := p_alarm_start;
1350     jtf_tasks_pub.p_task_user_hooks.alarm_start_uom            := p_alarm_start_uom;
1351     jtf_tasks_pub.p_task_user_hooks.alarm_on                   := p_alarm_on;
1352     jtf_tasks_pub.p_task_user_hooks.alarm_count                := p_alarm_count;
1353     jtf_tasks_pub.p_task_user_hooks.alarm_interval             := p_alarm_interval;
1354     jtf_tasks_pub.p_task_user_hooks.alarm_interval_uom         := p_alarm_interval_uom;
1355     jtf_tasks_pub.p_task_user_hooks.palm_flag                  := p_palm_flag;
1356     jtf_tasks_pub.p_task_user_hooks.wince_flag                 := p_wince_flag;
1357     jtf_tasks_pub.p_task_user_hooks.laptop_flag                := p_laptop_flag;
1358     jtf_tasks_pub.p_task_user_hooks.device1_flag               := p_device1_flag;
1359     jtf_tasks_pub.p_task_user_hooks.device2_flag               := p_device2_flag;
1360     jtf_tasks_pub.p_task_user_hooks.device3_flag               := p_device3_flag;
1361     jtf_tasks_pub.p_task_user_hooks.costs                      := p_costs;
1362     jtf_tasks_pub.p_task_user_hooks.currency_code              := p_currency_code;
1363     jtf_tasks_pub.p_task_user_hooks.escalation_level           := p_escalation_level;
1364     jtf_tasks_pub.p_task_user_hooks.date_selected              := l_date_selected;
1365     jtf_tasks_pub.p_task_user_hooks.template_id                := p_template_id;
1366     jtf_tasks_pub.p_task_user_hooks.template_group_id          := p_template_group_id;
1367     jtf_tasks_pub.p_task_user_hooks.attribute1                 := p_attribute1;
1368     jtf_tasks_pub.p_task_user_hooks.attribute2                 := p_attribute2;
1369     jtf_tasks_pub.p_task_user_hooks.attribute3                 := p_attribute3;
1370     jtf_tasks_pub.p_task_user_hooks.attribute4                 := p_attribute4;
1371     jtf_tasks_pub.p_task_user_hooks.attribute5                 := p_attribute5;
1372     jtf_tasks_pub.p_task_user_hooks.attribute6                 := p_attribute6;
1373     jtf_tasks_pub.p_task_user_hooks.attribute7                 := p_attribute7;
1374     jtf_tasks_pub.p_task_user_hooks.attribute8                 := p_attribute8;
1375     jtf_tasks_pub.p_task_user_hooks.attribute9                 := p_attribute9;
1376     jtf_tasks_pub.p_task_user_hooks.attribute10                := p_attribute10;
1377     jtf_tasks_pub.p_task_user_hooks.attribute11                := p_attribute11;
1378     jtf_tasks_pub.p_task_user_hooks.attribute12                := p_attribute12;
1379     jtf_tasks_pub.p_task_user_hooks.attribute13                := p_attribute13;
1380     jtf_tasks_pub.p_task_user_hooks.attribute14                := p_attribute14;
1381     jtf_tasks_pub.p_task_user_hooks.attribute15                := p_attribute15;
1382     jtf_tasks_pub.p_task_user_hooks.attribute_category         := p_attribute_category;
1383     jtf_tasks_pub.p_task_user_hooks.entity                     := l_entity;
1384     jtf_tasks_pub.p_task_user_hooks.task_confirmation_status   := l_task_confirmation_status;
1385     jtf_tasks_pub.p_task_user_hooks.task_confirmation_counter  := p_task_confirmation_counter;
1386     jtf_tasks_pub.p_task_user_hooks.task_split_flag            := p_task_split_flag;
1387     jtf_tasks_pub.p_task_user_hooks.child_position             := p_child_position;
1388     jtf_tasks_pub.p_task_user_hooks.child_sequence_num         := p_child_sequence_num;
1389     jtf_tasks_pub.p_task_user_hooks.open_flag                  := l_open_flag;
1390     jtf_tasks_pub.p_task_user_hooks.location_id                := p_location_id;
1391     jtf_tasks_pub.p_task_user_hooks.copied_from_task_id        := p_copied_from_task_id;
1392 
1393     jtf_tasks_iuhk.create_task_pre(x_return_status);
1394 
1395     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1396       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1397       RAISE fnd_api.g_exc_unexpected_error;
1398     END IF;
1399 
1400     jtf_tasks_pkg.insert_row(
1401       x_rowid                      => l_rowid
1402     , x_task_id                    => x_task_id
1403     , x_source_object_id           => l_source_object_id
1404     , x_source_object_name         => l_source_object_name
1405     , x_duration                   => l_duration
1406     , x_duration_uom               => l_duration_uom
1407     , x_planned_effort             => l_planned_effort
1408     , x_planned_effort_uom         => l_planned_effort_uom
1409     , x_actual_effort              => l_actual_effort
1410     , x_actual_effort_uom          => l_actual_effort_uom
1411     , x_percentage_complete        => l_percentage_complete
1412     , x_reason_code                => l_reason_code
1413     , x_private_flag               => p_private_flag
1414     , x_publish_flag               => p_publish_flag
1415     , x_restrict_closure_flag      => p_restrict_closure_flag
1416     , x_multi_booked_flag          => p_multi_booked_flag
1417     , x_milestone_flag             => p_milestone_flag
1418     , x_holiday_flag               => p_holiday_flag
1419     , x_billable_flag              => p_billable_flag
1420     , x_bound_mode_code            => p_bound_mode_code
1421     , x_soft_bound_flag            => p_soft_bound_flag
1422     , x_workflow_process_id        => p_workflow_process_id
1423     , x_costs                      => p_costs
1424     , x_currency_code              => p_currency_code
1425     , x_notification_flag          => p_notification_flag
1426     , x_notification_period        => p_notification_period
1427     , x_notification_period_uom    => p_notification_period_uom
1428     , x_parent_task_id             => p_parent_task_id
1429     , x_recurrence_rule_id         => NULL
1430     , x_alarm_start                => p_alarm_start
1431     , x_alarm_start_uom            => p_alarm_start_uom
1432     , x_alarm_on                   => p_alarm_on
1433     , x_alarm_count                => p_alarm_count
1434     , x_alarm_fired_count          => NULL
1435     , x_alarm_interval             => p_alarm_interval
1436     , x_alarm_interval_uom         => p_alarm_interval_uom
1437     , x_deleted_flag               => 'N'
1438     , x_palm_flag                  => p_palm_flag
1439     , x_wince_flag                 => p_wince_flag
1440     , x_laptop_flag                => p_laptop_flag
1441     , x_device1_flag               => p_device1_flag
1442     , x_device2_flag               => p_device2_flag
1443     , x_device3_flag               => p_device3_flag
1444     , x_attribute1                 => p_attribute1
1445     , x_attribute2                 => p_attribute2
1446     , x_attribute3                 => p_attribute3
1447     , x_attribute4                 => p_attribute4
1448     , x_attribute5                 => p_attribute5
1449     , x_attribute6                 => p_attribute6
1450     , x_attribute7                 => p_attribute7
1451     , x_attribute8                 => p_attribute8
1452     , x_attribute9                 => p_attribute9
1453     , x_attribute10                => p_attribute10
1454     , x_attribute11                => p_attribute11
1455     , x_attribute12                => p_attribute12
1456     , x_attribute13                => p_attribute13
1457     , x_attribute14                => p_attribute14
1458     , x_attribute15                => p_attribute15
1459     , x_attribute_category         => p_attribute_category
1460     , x_task_number                => l_task_number
1461     , x_task_type_id               => l_task_type_id
1462     , x_task_status_id             => l_task_status_id
1463     , x_task_priority_id           => l_task_priority_id
1464     , x_owner_id                   => l_owner_id
1465     , x_owner_type_code            => l_owner_type_code
1466     , x_owner_territory_id         => p_owner_territory_id
1467     , x_assigned_by_id             => p_assigned_by_id
1468     , x_cust_account_id            => p_cust_account_id
1469     , x_customer_id                => p_customer_id
1470     , x_address_id                 => p_address_id
1471     , x_planned_start_date         => l_planned_start_date
1472     , x_planned_end_date           => l_planned_end_date
1473     , x_scheduled_start_date       => l_scheduled_start_date
1474     , x_scheduled_end_date         => l_scheduled_end_date
1475     , x_actual_start_date          => l_actual_start_date
1476     , x_actual_end_date            => l_actual_end_date
1477     , x_source_object_type_code    => l_source_object_type_code
1478     , x_timezone_id                => p_timezone_id
1479     , x_task_name                  => p_task_name
1480     , x_description                => p_description
1481     , x_creation_date              => SYSDATE
1482     , x_created_by                 => jtf_task_utl.created_by
1483     , x_last_update_date           => SYSDATE
1484     , x_last_updated_by            => jtf_task_utl.updated_by
1485     , x_last_update_login          => jtf_task_utl.login_id
1486     , x_escalation_level           => p_escalation_level
1487     , x_calendar_start_date        => l_calendar_start_date
1488     , x_calendar_end_date          => l_calendar_end_date
1489     , x_date_selected              => l_date_selected
1490     , x_template_id                => p_template_id
1491     , x_template_group_id          => p_template_group_id
1492     , x_open_flag                  => jtf_task_utl_ext.get_open_flag(l_task_status_id)    -- Enhancement# 2666995
1493     , x_entity                     => l_entity                                            -- enh# 3535354
1494     , x_task_confirmation_status   => l_task_confirmation_status
1495     , x_task_confirmation_counter  => p_task_confirmation_counter
1496     , x_task_split_flag            => p_task_split_flag
1497     , x_child_position             => p_child_position
1498     , x_child_sequence_num         => p_child_sequence_num
1499     , x_location_id                => p_location_id
1500     );
1501 
1502     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1503       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1504       RAISE fnd_api.g_exc_unexpected_error;
1505     END IF;
1506 
1507     -- ------------------------------------------------------------------------
1508     -- Create task assignment for Owner
1509     -- ------------------------------------------------------------------------
1510 
1511     -- ------------------------------------------------------------------------
1512     -- Set owner_status_id from profile if not supplied
1513     -- ------------------------------------------------------------------------
1514     IF p_owner_status_id IS NULL OR p_owner_status_id = fnd_api.g_miss_num THEN
1515       -- Added NVL on 04/08/2006 for bug# 5408967
1516       l_owner_status_id  := NVL(fnd_profile.VALUE(NAME => 'JTF_TASK_DEFAULT_ASSIGNEE_STATUS'), 3);
1517     ELSE
1518       l_owner_status_id  := p_owner_status_id;
1519     END IF;
1520 
1521     jtf_task_assignments_pvt.create_task_assignment(
1522       p_api_version                => l_api_version
1523     , p_init_msg_list              => fnd_api.g_false
1524     , p_commit                     => fnd_api.g_false
1525     , p_task_assignment_id         => l_task_assignment_id
1526     , p_task_id                    => x_task_id
1527     , p_resource_type_code         => l_owner_type_code
1528     , p_resource_id                => l_owner_id
1529     , p_actual_effort              => l_actual_effort
1530     , p_actual_effort_uom          => l_actual_effort_uom
1531     , p_actual_start_date          => p_actual_start_date
1532     , p_actual_end_date            => p_actual_end_date
1533     , p_palm_flag                  => p_palm_flag
1534     , p_wince_flag                 => p_wince_flag
1535     , p_laptop_flag                => p_laptop_flag
1536     , p_device1_flag               => p_device1_flag
1537     , p_device2_flag               => p_device2_flag
1538     , p_device3_flag               => p_device3_flag
1539     , p_resource_territory_id      => p_owner_territory_id
1540     , p_assignment_status_id       => l_owner_status_id
1541     , x_return_status              => x_return_status
1542     , x_msg_count                  => x_msg_count
1543     , x_msg_data                   => x_msg_data
1544     , x_task_assignment_id         => l_task_assignment_id
1545     , p_assignee_role              => 'OWNER'
1546     , p_show_on_calendar           => l_show_on_calendar
1547     , p_category_id                => l_category_id
1548     , p_enable_workflow            => l_enable_workflow
1549     , p_abort_workflow             => l_abort_workflow
1550     , p_add_option                 => jtf_task_repeat_appt_pvt.g_one
1551     , p_free_busy_type             => l_free_busy_type
1552     );
1553 
1554     IF (x_return_status = fnd_api.g_ret_sts_error) THEN
1555       RAISE fnd_api.g_exc_error;
1556     ELSIF(x_return_status = fnd_api.g_ret_sts_unexp_error) THEN
1557       RAISE fnd_api.g_exc_unexpected_error;
1558     END IF;
1559 
1560     IF ((p_reference_flag = 'Y') OR(p_reference_flag IS NULL)) THEN
1561       -- ------------------------------------------------------------------------
1562       -- Create reference to source document
1563       -- ------------------------------------------------------------------------
1564       IF     l_source_object_type_code IS NOT NULL
1565          AND l_source_object_type_code <> fnd_api.g_miss_char
1566          AND l_source_object_type_code NOT IN('TASK', 'APPOINTMENT', 'EXTERNAL APPOINTMENT') THEN
1567         -- 2102281  -- If condition added to invoke jtf_task_utl.create_party_reference only for type 'PARTY'
1568         IF l_source_object_type_code IN('PARTY') THEN
1569           jtf_task_utl.create_party_reference(
1570             p_reference_from             => 'TASK'
1571           , p_task_id                    => x_task_id
1572           , p_party_id                   => l_source_object_id
1573           , x_msg_count                  => x_msg_count
1574           , x_msg_data                   => x_msg_data
1575           , x_return_status              => x_return_status
1576           );
1577         ELSE
1578           jtf_task_utl.g_show_error_for_dup_reference  := FALSE;
1579           jtf_task_references_pvt.create_references(
1580             p_api_version                => l_api_version
1581           , p_init_msg_list              => fnd_api.g_false
1582           , p_commit                     => fnd_api.g_false
1583           , p_task_id                    => x_task_id
1584           , p_object_type_code           => l_source_object_type_code
1585           , p_object_name                => l_source_object_name
1586           , p_object_id                  => l_source_object_id
1587           , x_return_status              => x_return_status
1588           , x_msg_count                  => x_msg_count
1589           , x_msg_data                   => x_msg_data
1590           , x_task_reference_id          => l_task_reference_id
1591           );
1592         END IF;
1593       END IF;
1594 
1595       IF (x_return_status = fnd_api.g_ret_sts_error) THEN
1596         RAISE fnd_api.g_exc_error;
1597       ELSIF(x_return_status = fnd_api.g_ret_sts_unexp_error) THEN
1598         RAISE fnd_api.g_exc_unexpected_error;
1599       END IF;
1600 
1601       -- ------------------------------------------------------------------------
1602       -- Create reference to customer, fix for enh #1845501
1603       -- ------------------------------------------------------------------------
1604       jtf_task_utl.create_party_reference(
1605         p_reference_from             => 'TASK'
1606       , p_task_id                    => x_task_id
1607       , p_party_id                   => p_customer_id
1608       , x_msg_count                  => x_msg_count
1609       , x_msg_data                   => x_msg_data
1610       , x_return_status              => x_return_status
1611       );
1612 
1613       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1614         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1615         RAISE fnd_api.g_exc_unexpected_error;
1616       END IF;
1617     END IF;   -- of if condition on p_reference_flag
1618 
1619     jtf_tasks_iuhk.create_task_post(x_return_status);
1620 
1621     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1622       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1623       RAISE fnd_api.g_exc_unexpected_error;
1624     END IF;
1625 
1626     --BES enh 2391065
1627     IF (l_entity = 'TASK') THEN
1628       l_task_rec_type.task_id                  := x_task_id;
1629       l_task_rec_type.enable_workflow          := l_enable_workflow;
1630       l_task_rec_type.abort_workflow           := l_abort_workflow;
1631       l_task_rec_type.source_object_type_code  := p_source_object_type_code;
1632       l_task_rec_type.source_object_id         := l_source_object_id;
1633       jtf_task_wf_events_pvt.publish_create_task(
1634         p_task_rec      => l_task_rec_type
1635       , x_return_status => x_event_return_status
1636       );
1637 
1638       IF (x_event_return_status = 'WARNING') THEN
1639         fnd_message.set_name('JTF', 'JTF_TASK_EVENT_WARNING');
1640         fnd_message.set_token('P_TASK_ID', x_task_id);
1641         fnd_msg_pub.ADD;
1642       ELSIF(x_event_return_status = 'ERROR') THEN
1643         fnd_message.set_name('JTF', 'JTF_TASK_EVENT_ERROR');
1644         fnd_message.set_token('P_TASK_ID', x_task_id);
1645         fnd_msg_pub.ADD;
1646         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1647         RAISE fnd_api.g_exc_unexpected_error;
1648       END IF;
1649     END IF;
1650 
1651     --BES enh 2391065
1652 
1653     --Create Task Resource Requirements
1654     OPEN c_type_reqs;
1655 
1656     LOOP
1657       FETCH c_type_reqs INTO l_res_type, l_req_units, l_enabled_flag;
1658       EXIT WHEN c_type_reqs%NOTFOUND;
1659       jtf_task_resources_pub.create_task_rsrc_req(
1660         p_api_version                => 1.0
1661       , p_init_msg_list              => fnd_api.g_false
1662       , p_commit                     => fnd_api.g_false
1663       , p_task_id                    => x_task_id
1664       , p_task_template_id           => NULL
1665       , p_resource_type_code         => l_res_type
1666       , p_required_units             => l_req_units
1667       , p_enabled_flag               => l_enabled_flag
1668       , x_return_status              => x_return_status
1669       , x_msg_count                  => x_msg_count
1670       , x_msg_data                   => x_msg_data
1671       , x_resource_req_id            => l_resource_req_id
1672       );
1673 
1674       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1675         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1676         RAISE fnd_api.g_exc_unexpected_error;
1677       END IF;
1678     END LOOP;
1679 
1680     CLOSE c_type_reqs;
1681 
1682     IF fnd_api.to_boolean(p_commit) THEN
1683       COMMIT WORK;
1684     END IF;
1685 
1686     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1687   EXCEPTION
1688     WHEN fnd_api.g_exc_unexpected_error THEN
1689       ROLLBACK TO create_task_pvt;
1690       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1691       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1692     WHEN OTHERS THEN
1693       ROLLBACK TO create_task_pvt;
1694       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
1695       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
1696       fnd_msg_pub.ADD;
1697       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1698       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1699   END;
1700 
1701   -----------------
1702   -----------------
1703       -- old version
1704   PROCEDURE update_task(
1705     p_api_version             IN            NUMBER
1706   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
1707   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
1708   , p_object_version_number   IN OUT NOCOPY NUMBER
1709   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
1710   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1711   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
1712   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1713   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
1714   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
1715   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1716   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
1717   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
1718   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
1719   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
1720   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
1721   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
1722   ,   ---- hz_party_sites
1723     p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
1724   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
1725   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
1726   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
1727   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
1728   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
1729   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
1730   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1731   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
1732   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1733   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
1734   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1735   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
1736   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1737   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
1738   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1739   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
1740   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1741   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1742   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1743   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1744   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1745   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1746   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1747   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1748   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1749   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1750   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
1751   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1752   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
1753   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1754   , p_parent_task_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
1755   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
1756   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1757   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1758   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
1759   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
1760   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
1761   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1762   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1763   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1764   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1765   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1766   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1767   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1768   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
1769   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1770   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1771   , x_return_status           OUT NOCOPY    VARCHAR2
1772   , x_msg_count               OUT NOCOPY    NUMBER
1773   , x_msg_data                OUT NOCOPY    VARCHAR2
1774   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1775   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1776   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1777   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1778   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1779   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1780   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1781   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1782   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1783   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1784   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1785   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1786   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1787   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1788   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1789   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1790   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1791   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
1792   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1793   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
1794   ) IS
1795   BEGIN
1796     SAVEPOINT update_task_pvt1;
1797     x_return_status  := fnd_api.g_ret_sts_success;
1798 
1799     IF fnd_api.to_boolean(p_init_msg_list) THEN
1800       fnd_msg_pub.initialize;
1801     END IF;
1802 
1803     -- Call the new version
1804     update_task(
1805       p_api_version                => p_api_version
1806     , p_init_msg_list              => p_init_msg_list
1807     , p_commit                     => fnd_api.g_false
1808     ,   -- FALSE
1809       p_object_version_number      => p_object_version_number
1810     , p_task_id                    => p_task_id
1811     , p_task_name                  => p_task_name
1812     , p_task_type_id               => p_task_type_id
1813     , p_description                => p_description
1814     , p_task_status_id             => p_task_status_id
1815     , p_task_priority_id           => p_task_priority_id
1816     , p_owner_type_code            => p_owner_type_code
1817     , p_owner_id                   => p_owner_id
1818     , p_owner_territory_id         => p_owner_territory_id
1819     , p_assigned_by_id             => p_assigned_by_id
1820     , p_customer_id                => p_customer_id
1821     , p_cust_account_id            => p_cust_account_id
1822     , p_address_id                 => p_address_id
1823     , p_planned_start_date         => p_planned_start_date
1824     , p_planned_end_date           => p_planned_end_date
1825     , p_scheduled_start_date       => p_scheduled_start_date
1826     , p_scheduled_end_date         => p_scheduled_end_date
1827     , p_actual_start_date          => p_actual_start_date
1828     , p_actual_end_date            => p_actual_end_date
1829     , p_timezone_id                => p_timezone_id
1830     , p_source_object_type_code    => p_source_object_type_code
1831     , p_source_object_id           => p_source_object_id
1832     , p_source_object_name         => p_source_object_name
1833     , p_duration                   => p_duration
1834     , p_duration_uom               => p_duration_uom
1835     , p_planned_effort             => p_planned_effort
1836     , p_planned_effort_uom         => p_planned_effort_uom
1837     , p_actual_effort              => p_actual_effort
1838     , p_actual_effort_uom          => p_actual_effort_uom
1839     , p_percentage_complete        => p_percentage_complete
1840     , p_reason_code                => p_reason_code
1841     , p_private_flag               => p_private_flag
1842     , p_publish_flag               => p_publish_flag
1843     , p_restrict_closure_flag      => p_restrict_closure_flag
1844     , p_multi_booked_flag          => p_multi_booked_flag
1845     , p_milestone_flag             => p_milestone_flag
1846     , p_holiday_flag               => p_holiday_flag
1847     , p_billable_flag              => p_billable_flag
1848     , p_bound_mode_code            => p_bound_mode_code
1849     , p_soft_bound_flag            => p_soft_bound_flag
1850     , p_workflow_process_id        => p_workflow_process_id
1851     , p_notification_flag          => p_notification_flag
1852     , p_notification_period        => p_notification_period
1853     , p_notification_period_uom    => p_notification_period_uom
1854     , p_parent_task_id             => p_parent_task_id
1855     , p_alarm_start                => p_alarm_start
1856     , p_alarm_start_uom            => p_alarm_start_uom
1857     , p_alarm_on                   => p_alarm_on
1858     , p_alarm_count                => p_alarm_count
1859     , p_alarm_fired_count          => p_alarm_fired_count
1860     , p_alarm_interval             => p_alarm_interval
1861     , p_alarm_interval_uom         => p_alarm_interval_uom
1862     , p_palm_flag                  => p_palm_flag
1863     , p_wince_flag                 => p_wince_flag
1864     , p_laptop_flag                => p_laptop_flag
1865     , p_device1_flag               => p_device1_flag
1866     , p_device2_flag               => p_device2_flag
1867     , p_device3_flag               => p_device3_flag
1868     , p_costs                      => p_costs
1869     , p_currency_code              => p_currency_code
1870     , p_escalation_level           => p_escalation_level
1871     , x_return_status              => x_return_status
1872     , x_msg_count                  => x_msg_count
1873     , x_msg_data                   => x_msg_data
1874     , p_attribute1                 => p_attribute1
1875     , p_attribute2                 => p_attribute2
1876     , p_attribute3                 => p_attribute3
1877     , p_attribute4                 => p_attribute4
1878     , p_attribute5                 => p_attribute5
1879     , p_attribute6                 => p_attribute6
1880     , p_attribute7                 => p_attribute7
1881     , p_attribute8                 => p_attribute8
1882     , p_attribute9                 => p_attribute9
1883     , p_attribute10                => p_attribute10
1884     , p_attribute11                => p_attribute11
1885     , p_attribute12                => p_attribute12
1886     , p_attribute13                => p_attribute13
1887     , p_attribute14                => p_attribute14
1888     , p_attribute15                => p_attribute15
1889     , p_attribute_category         => p_attribute_category
1890     , p_date_selected              => p_date_selected
1891     , p_category_id                => p_category_id
1892     , p_show_on_calendar           => p_show_on_calendar
1893     , p_owner_status_id            => p_owner_status_id
1894     , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
1895     , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
1896     , p_change_mode                => jtf_task_repeat_appt_pvt.g_one
1897     , p_free_busy_type             => jtf_task_utl.g_miss_char
1898     );
1899 
1900     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1901       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1902       RAISE fnd_api.g_exc_unexpected_error;
1903     END IF;
1904 
1905     IF fnd_api.to_boolean(p_commit) THEN
1906       COMMIT WORK;
1907     END IF;
1908 
1909     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1910   EXCEPTION
1911     WHEN fnd_api.g_exc_unexpected_error THEN
1912       ROLLBACK TO update_task_pvt1;
1913       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1914       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1915     WHEN OTHERS THEN
1916       ROLLBACK TO update_task_pvt1;
1917       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
1918       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
1919       fnd_msg_pub.ADD;
1920       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1921       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1922   END;
1923 
1924   -- old version
1925   PROCEDURE update_task(
1926     p_api_version             IN            NUMBER
1927   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
1928   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
1929   , p_object_version_number   IN OUT NOCOPY NUMBER
1930   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
1931   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1932   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
1933   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1934   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
1935   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
1936   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1937   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
1938   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
1939   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
1940   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
1941   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
1942   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
1943   ,   ---- hz_party_sites
1944     p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
1945   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
1946   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
1947   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
1948   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
1949   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
1950   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
1951   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1952   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
1953   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1954   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
1955   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1956   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
1957   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1958   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
1959   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1960   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
1961   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1962   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1963   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1964   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1965   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1966   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1967   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1968   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1969   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1970   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1971   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
1972   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1973   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
1974   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1975   , p_parent_task_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
1976   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
1977   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1978   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1979   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
1980   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
1981   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
1982   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1983   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1984   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1985   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1986   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1987   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1988   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1989   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
1990   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1991   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
1992   , x_return_status           OUT NOCOPY    VARCHAR2
1993   , x_msg_count               OUT NOCOPY    NUMBER
1994   , x_msg_data                OUT NOCOPY    VARCHAR2
1995   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1996   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1997   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1998   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
1999   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2000   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2001   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2002   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2003   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2004   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2005   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2006   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2007   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2008   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2009   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2010   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2011   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2012   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2013   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2014   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2015   , p_enable_workflow         IN            VARCHAR2
2016   , p_abort_workflow          IN            VARCHAR2
2017   ) IS
2018   BEGIN
2019     SAVEPOINT update_task_pvt2;
2020     x_return_status  := fnd_api.g_ret_sts_success;
2021 
2022     IF fnd_api.to_boolean(p_init_msg_list) THEN
2023       fnd_msg_pub.initialize;
2024     END IF;
2025 
2026     -- Call the new version
2027     update_task(
2028       p_api_version                => p_api_version
2029     , p_init_msg_list              => p_init_msg_list
2030     , p_commit                     => fnd_api.g_false
2031     ,   -- FALSE
2032       p_object_version_number      => p_object_version_number
2033     , p_task_id                    => p_task_id
2034     , p_task_name                  => p_task_name
2035     , p_task_type_id               => p_task_type_id
2036     , p_description                => p_description
2037     , p_task_status_id             => p_task_status_id
2038     , p_task_priority_id           => p_task_priority_id
2039     , p_owner_type_code            => p_owner_type_code
2040     , p_owner_id                   => p_owner_id
2041     , p_owner_territory_id         => p_owner_territory_id
2042     , p_assigned_by_id             => p_assigned_by_id
2043     , p_customer_id                => p_customer_id
2044     , p_cust_account_id            => p_cust_account_id
2045     , p_address_id                 => p_address_id
2046     , p_planned_start_date         => p_planned_start_date
2047     , p_planned_end_date           => p_planned_end_date
2048     , p_scheduled_start_date       => p_scheduled_start_date
2049     , p_scheduled_end_date         => p_scheduled_end_date
2050     , p_actual_start_date          => p_actual_start_date
2051     , p_actual_end_date            => p_actual_end_date
2052     , p_timezone_id                => p_timezone_id
2053     , p_source_object_type_code    => p_source_object_type_code
2054     , p_source_object_id           => p_source_object_id
2055     , p_source_object_name         => p_source_object_name
2056     , p_duration                   => p_duration
2057     , p_duration_uom               => p_duration_uom
2058     , p_planned_effort             => p_planned_effort
2059     , p_planned_effort_uom         => p_planned_effort_uom
2060     , p_actual_effort              => p_actual_effort
2061     , p_actual_effort_uom          => p_actual_effort_uom
2062     , p_percentage_complete        => p_percentage_complete
2063     , p_reason_code                => p_reason_code
2064     , p_private_flag               => p_private_flag
2065     , p_publish_flag               => p_publish_flag
2066     , p_restrict_closure_flag      => p_restrict_closure_flag
2067     , p_multi_booked_flag          => p_multi_booked_flag
2068     , p_milestone_flag             => p_milestone_flag
2069     , p_holiday_flag               => p_holiday_flag
2070     , p_billable_flag              => p_billable_flag
2071     , p_bound_mode_code            => p_bound_mode_code
2072     , p_soft_bound_flag            => p_soft_bound_flag
2073     , p_workflow_process_id        => p_workflow_process_id
2074     , p_notification_flag          => p_notification_flag
2075     , p_notification_period        => p_notification_period
2076     , p_notification_period_uom    => p_notification_period_uom
2077     , p_parent_task_id             => p_parent_task_id
2078     , p_alarm_start                => p_alarm_start
2079     , p_alarm_start_uom            => p_alarm_start_uom
2080     , p_alarm_on                   => p_alarm_on
2081     , p_alarm_count                => p_alarm_count
2082     , p_alarm_fired_count          => p_alarm_fired_count
2083     , p_alarm_interval             => p_alarm_interval
2084     , p_alarm_interval_uom         => p_alarm_interval_uom
2085     , p_palm_flag                  => p_palm_flag
2086     , p_wince_flag                 => p_wince_flag
2087     , p_laptop_flag                => p_laptop_flag
2088     , p_device1_flag               => p_device1_flag
2089     , p_device2_flag               => p_device2_flag
2090     , p_device3_flag               => p_device3_flag
2091     , p_costs                      => p_costs
2092     , p_currency_code              => p_currency_code
2093     , p_escalation_level           => p_escalation_level
2094     , x_return_status              => x_return_status
2095     , x_msg_count                  => x_msg_count
2096     , x_msg_data                   => x_msg_data
2097     , p_attribute1                 => p_attribute1
2098     , p_attribute2                 => p_attribute2
2099     , p_attribute3                 => p_attribute3
2100     , p_attribute4                 => p_attribute4
2101     , p_attribute5                 => p_attribute5
2102     , p_attribute6                 => p_attribute6
2103     , p_attribute7                 => p_attribute7
2104     , p_attribute8                 => p_attribute8
2105     , p_attribute9                 => p_attribute9
2106     , p_attribute10                => p_attribute10
2107     , p_attribute11                => p_attribute11
2108     , p_attribute12                => p_attribute12
2109     , p_attribute13                => p_attribute13
2110     , p_attribute14                => p_attribute14
2111     , p_attribute15                => p_attribute15
2112     , p_attribute_category         => p_attribute_category
2113     , p_date_selected              => p_date_selected
2114     , p_category_id                => p_category_id
2115     , p_show_on_calendar           => p_show_on_calendar
2116     , p_owner_status_id            => p_owner_status_id
2117     , p_enable_workflow            => p_enable_workflow
2118     , p_abort_workflow             => p_abort_workflow
2119     , p_change_mode                => jtf_task_repeat_appt_pvt.g_one
2120     , p_free_busy_type             => jtf_task_utl.g_miss_char
2121     );
2122 
2123     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2124       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2125       RAISE fnd_api.g_exc_unexpected_error;
2126     END IF;
2127 
2128     IF fnd_api.to_boolean(p_commit) THEN
2129       COMMIT WORK;
2130     END IF;
2131 
2132     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2133   EXCEPTION
2134     WHEN fnd_api.g_exc_unexpected_error THEN
2135       ROLLBACK TO update_task_pvt2;
2136       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2137       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2138     WHEN OTHERS THEN
2139       ROLLBACK TO update_task_pvt2;
2140       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2141       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2142       fnd_msg_pub.ADD;
2143       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2144       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2145   END;
2146 
2147   -- New version which has a workflow enhancement (p_enable_workflow, p_abort_workflow)
2148   PROCEDURE update_task(
2149     p_api_version             IN            NUMBER
2150   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
2151   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
2152   , p_object_version_number   IN OUT NOCOPY NUMBER
2153   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
2154   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2155   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2156   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2157   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2158   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2159   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2160   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2161   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
2162   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2163   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2164   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
2165   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2166   ,   ---- hz_party_sites
2167     p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2168   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2169   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
2170   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
2171   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
2172   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
2173   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2174   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2175   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2176   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2177   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
2178   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2179   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
2180   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2181   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
2182   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2183   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
2184   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2185   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2186   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2187   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2188   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2189   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2190   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2191   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2192   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2193   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2194   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
2195   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2196   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
2197   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2198   , p_parent_task_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2199   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
2200   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2201   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2202   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
2203   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
2204   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
2205   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2206   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2207   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2208   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2209   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2210   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2211   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2212   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2213   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2214   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2215   , x_return_status           OUT NOCOPY    VARCHAR2
2216   , x_msg_count               OUT NOCOPY    NUMBER
2217   , x_msg_data                OUT NOCOPY    VARCHAR2
2218   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2219   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2220   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2221   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2222   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2223   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2224   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2225   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2226   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2227   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2228   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2229   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2230   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2231   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2232   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2233   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2234   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2235   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2236   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2237   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2238   , p_enable_workflow         IN            VARCHAR2
2239   , p_abort_workflow          IN            VARCHAR2
2240   , p_change_mode             IN            VARCHAR2
2241   ) IS
2242   BEGIN
2243     SAVEPOINT update_task_pvt3;
2244     x_return_status  := fnd_api.g_ret_sts_success;
2245 
2246     IF fnd_api.to_boolean(p_init_msg_list) THEN
2247       fnd_msg_pub.initialize;
2248     END IF;
2249 
2250     -- Call the new version
2251     update_task(
2252       p_api_version                => p_api_version
2253     , p_init_msg_list              => p_init_msg_list
2254     , p_commit                     => fnd_api.g_false
2255     ,   -- FALSE
2256       p_object_version_number      => p_object_version_number
2257     , p_task_id                    => p_task_id
2258     , p_task_name                  => p_task_name
2259     , p_task_type_id               => p_task_type_id
2260     , p_description                => p_description
2261     , p_task_status_id             => p_task_status_id
2262     , p_task_priority_id           => p_task_priority_id
2263     , p_owner_type_code            => p_owner_type_code
2264     , p_owner_id                   => p_owner_id
2265     , p_owner_territory_id         => p_owner_territory_id
2266     , p_assigned_by_id             => p_assigned_by_id
2267     , p_customer_id                => p_customer_id
2268     , p_cust_account_id            => p_cust_account_id
2269     , p_address_id                 => p_address_id
2270     , p_planned_start_date         => p_planned_start_date
2271     , p_planned_end_date           => p_planned_end_date
2272     , p_scheduled_start_date       => p_scheduled_start_date
2273     , p_scheduled_end_date         => p_scheduled_end_date
2274     , p_actual_start_date          => p_actual_start_date
2275     , p_actual_end_date            => p_actual_end_date
2276     , p_timezone_id                => p_timezone_id
2277     , p_source_object_type_code    => p_source_object_type_code
2278     , p_source_object_id           => p_source_object_id
2279     , p_source_object_name         => p_source_object_name
2280     , p_duration                   => p_duration
2281     , p_duration_uom               => p_duration_uom
2282     , p_planned_effort             => p_planned_effort
2283     , p_planned_effort_uom         => p_planned_effort_uom
2284     , p_actual_effort              => p_actual_effort
2285     , p_actual_effort_uom          => p_actual_effort_uom
2286     , p_percentage_complete        => p_percentage_complete
2287     , p_reason_code                => p_reason_code
2288     , p_private_flag               => p_private_flag
2289     , p_publish_flag               => p_publish_flag
2290     , p_restrict_closure_flag      => p_restrict_closure_flag
2291     , p_multi_booked_flag          => p_multi_booked_flag
2292     , p_milestone_flag             => p_milestone_flag
2293     , p_holiday_flag               => p_holiday_flag
2294     , p_billable_flag              => p_billable_flag
2295     , p_bound_mode_code            => p_bound_mode_code
2296     , p_soft_bound_flag            => p_soft_bound_flag
2297     , p_workflow_process_id        => p_workflow_process_id
2298     , p_notification_flag          => p_notification_flag
2299     , p_notification_period        => p_notification_period
2300     , p_notification_period_uom    => p_notification_period_uom
2301     , p_parent_task_id             => p_parent_task_id
2302     , p_alarm_start                => p_alarm_start
2303     , p_alarm_start_uom            => p_alarm_start_uom
2304     , p_alarm_on                   => p_alarm_on
2305     , p_alarm_count                => p_alarm_count
2306     , p_alarm_fired_count          => p_alarm_fired_count
2307     , p_alarm_interval             => p_alarm_interval
2308     , p_alarm_interval_uom         => p_alarm_interval_uom
2309     , p_palm_flag                  => p_palm_flag
2310     , p_wince_flag                 => p_wince_flag
2311     , p_laptop_flag                => p_laptop_flag
2312     , p_device1_flag               => p_device1_flag
2313     , p_device2_flag               => p_device2_flag
2314     , p_device3_flag               => p_device3_flag
2315     , p_costs                      => p_costs
2316     , p_currency_code              => p_currency_code
2317     , p_escalation_level           => p_escalation_level
2318     , x_return_status              => x_return_status
2319     , x_msg_count                  => x_msg_count
2320     , x_msg_data                   => x_msg_data
2321     , p_attribute1                 => p_attribute1
2322     , p_attribute2                 => p_attribute2
2323     , p_attribute3                 => p_attribute3
2324     , p_attribute4                 => p_attribute4
2325     , p_attribute5                 => p_attribute5
2326     , p_attribute6                 => p_attribute6
2327     , p_attribute7                 => p_attribute7
2328     , p_attribute8                 => p_attribute8
2329     , p_attribute9                 => p_attribute9
2330     , p_attribute10                => p_attribute10
2331     , p_attribute11                => p_attribute11
2332     , p_attribute12                => p_attribute12
2333     , p_attribute13                => p_attribute13
2334     , p_attribute14                => p_attribute14
2335     , p_attribute15                => p_attribute15
2336     , p_attribute_category         => p_attribute_category
2337     , p_date_selected              => p_date_selected
2338     , p_category_id                => p_category_id
2339     , p_show_on_calendar           => p_show_on_calendar
2340     , p_owner_status_id            => p_owner_status_id
2341     , p_enable_workflow            => p_enable_workflow
2342     , p_abort_workflow             => p_abort_workflow
2343     , p_change_mode                => p_change_mode
2344     , p_free_busy_type             => jtf_task_utl.g_miss_char
2345     );
2346 
2347     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2348       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2349       RAISE fnd_api.g_exc_unexpected_error;
2350     END IF;
2351 
2352     IF fnd_api.to_boolean(p_commit) THEN
2353       COMMIT WORK;
2354     END IF;
2355 
2356     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2357   EXCEPTION
2358     WHEN fnd_api.g_exc_unexpected_error THEN
2359       ROLLBACK TO update_task_pvt3;
2360       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2361       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2362     WHEN OTHERS THEN
2363       ROLLBACK TO update_task_pvt3;
2364       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2365       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2366       fnd_msg_pub.ADD;
2367       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2368       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2369   END;
2370 
2371   -- New version which has a workflow enhancement (p_enable_workflow, p_abort_workflow)
2372   PROCEDURE update_task(
2373     p_api_version             IN            NUMBER
2374   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
2375   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
2376   , p_object_version_number   IN OUT NOCOPY NUMBER
2377   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
2378   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2379   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2380   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2381   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2382   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2383   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2384   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2385   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
2386   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2387   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2388   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
2389   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2390   ,   ---- hz_party_sites
2391     p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2392   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2393   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
2394   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
2395   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
2396   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
2397   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2398   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2399   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2400   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2401   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
2402   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2403   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
2404   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2405   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
2406   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2407   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
2408   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2409   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2410   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2411   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2412   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2413   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2414   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2415   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2416   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2417   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2418   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
2419   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2420   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
2421   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2422   , p_parent_task_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2423   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
2424   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2425   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2426   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
2427   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
2428   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
2429   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2430   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2431   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2432   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2433   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2434   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2435   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2436   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2437   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2438   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2439   , x_return_status           OUT NOCOPY    VARCHAR2
2440   , x_msg_count               OUT NOCOPY    NUMBER
2441   , x_msg_data                OUT NOCOPY    VARCHAR2
2442   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2443   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2444   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2445   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2446   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2447   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2448   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2449   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2450   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2451   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2452   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2453   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2454   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2455   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2456   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2457   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2458   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2459   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2460   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2461   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2462   , p_enable_workflow         IN            VARCHAR2
2463   , p_abort_workflow          IN            VARCHAR2
2464   , p_change_mode             IN            VARCHAR2
2465   , p_free_busy_type          IN            VARCHAR2
2466   ) IS
2467   BEGIN
2468     SAVEPOINT update_task_pvt4;
2469     x_return_status  := fnd_api.g_ret_sts_success;
2470 
2471     IF fnd_api.to_boolean(p_init_msg_list) THEN
2472       fnd_msg_pub.initialize;
2473     END IF;
2474 
2475     -- Call the new version
2476     update_task(
2477       p_api_version                => p_api_version
2478     , p_init_msg_list              => p_init_msg_list
2479     , p_commit                     => fnd_api.g_false
2480     ,   -- FALSE
2481       p_object_version_number      => p_object_version_number
2482     , p_task_id                    => p_task_id
2483     , p_task_name                  => p_task_name
2484     , p_task_type_id               => p_task_type_id
2485     , p_description                => p_description
2486     , p_task_status_id             => p_task_status_id
2487     , p_task_priority_id           => p_task_priority_id
2488     , p_owner_type_code            => p_owner_type_code
2489     , p_owner_id                   => p_owner_id
2490     , p_owner_territory_id         => p_owner_territory_id
2491     , p_assigned_by_id             => p_assigned_by_id
2492     , p_customer_id                => p_customer_id
2493     , p_cust_account_id            => p_cust_account_id
2494     , p_address_id                 => p_address_id
2495     , p_planned_start_date         => p_planned_start_date
2496     , p_planned_end_date           => p_planned_end_date
2497     , p_scheduled_start_date       => p_scheduled_start_date
2498     , p_scheduled_end_date         => p_scheduled_end_date
2499     , p_actual_start_date          => p_actual_start_date
2500     , p_actual_end_date            => p_actual_end_date
2501     , p_timezone_id                => p_timezone_id
2502     , p_source_object_type_code    => p_source_object_type_code
2503     , p_source_object_id           => p_source_object_id
2504     , p_source_object_name         => p_source_object_name
2505     , p_duration                   => p_duration
2506     , p_duration_uom               => p_duration_uom
2507     , p_planned_effort             => p_planned_effort
2508     , p_planned_effort_uom         => p_planned_effort_uom
2509     , p_actual_effort              => p_actual_effort
2510     , p_actual_effort_uom          => p_actual_effort_uom
2511     , p_percentage_complete        => p_percentage_complete
2512     , p_reason_code                => p_reason_code
2513     , p_private_flag               => p_private_flag
2514     , p_publish_flag               => p_publish_flag
2515     , p_restrict_closure_flag      => p_restrict_closure_flag
2516     , p_multi_booked_flag          => p_multi_booked_flag
2517     , p_milestone_flag             => p_milestone_flag
2518     , p_holiday_flag               => p_holiday_flag
2519     , p_billable_flag              => p_billable_flag
2520     , p_bound_mode_code            => p_bound_mode_code
2521     , p_soft_bound_flag            => p_soft_bound_flag
2522     , p_workflow_process_id        => p_workflow_process_id
2523     , p_notification_flag          => p_notification_flag
2524     , p_notification_period        => p_notification_period
2525     , p_notification_period_uom    => p_notification_period_uom
2526     , p_parent_task_id             => p_parent_task_id
2527     , p_alarm_start                => p_alarm_start
2528     , p_alarm_start_uom            => p_alarm_start_uom
2529     , p_alarm_on                   => p_alarm_on
2530     , p_alarm_count                => p_alarm_count
2531     , p_alarm_fired_count          => p_alarm_fired_count
2532     , p_alarm_interval             => p_alarm_interval
2533     , p_alarm_interval_uom         => p_alarm_interval_uom
2534     , p_palm_flag                  => p_palm_flag
2535     , p_wince_flag                 => p_wince_flag
2536     , p_laptop_flag                => p_laptop_flag
2537     , p_device1_flag               => p_device1_flag
2538     , p_device2_flag               => p_device2_flag
2539     , p_device3_flag               => p_device3_flag
2540     , p_costs                      => p_costs
2541     , p_currency_code              => p_currency_code
2542     , p_escalation_level           => p_escalation_level
2543     , x_return_status              => x_return_status
2544     , x_msg_count                  => x_msg_count
2545     , x_msg_data                   => x_msg_data
2546     , p_attribute1                 => p_attribute1
2547     , p_attribute2                 => p_attribute2
2548     , p_attribute3                 => p_attribute3
2549     , p_attribute4                 => p_attribute4
2550     , p_attribute5                 => p_attribute5
2551     , p_attribute6                 => p_attribute6
2552     , p_attribute7                 => p_attribute7
2553     , p_attribute8                 => p_attribute8
2554     , p_attribute9                 => p_attribute9
2555     , p_attribute10                => p_attribute10
2556     , p_attribute11                => p_attribute11
2557     , p_attribute12                => p_attribute12
2558     , p_attribute13                => p_attribute13
2559     , p_attribute14                => p_attribute14
2560     , p_attribute15                => p_attribute15
2561     , p_attribute_category         => p_attribute_category
2562     , p_date_selected              => p_date_selected
2563     , p_category_id                => p_category_id
2564     , p_show_on_calendar           => p_show_on_calendar
2565     , p_owner_status_id            => p_owner_status_id
2566     , p_enable_workflow            => p_enable_workflow
2567     , p_abort_workflow             => p_abort_workflow
2568     , p_change_mode                => p_change_mode
2569     , p_free_busy_type             => p_free_busy_type
2570     ,   --Bug# 3606783.
2571       p_task_confirmation_status   => jtf_task_utl.g_miss_char
2572     , p_task_confirmation_counter  => jtf_task_utl.g_miss_number
2573     , p_task_split_flag            => jtf_task_utl.g_miss_char
2574     , p_child_position             => jtf_task_utl.g_miss_char
2575     , p_child_sequence_num         => jtf_task_utl.g_miss_number
2576     );
2577 
2578     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2579       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2580       RAISE fnd_api.g_exc_unexpected_error;
2581     END IF;
2582 
2583     IF fnd_api.to_boolean(p_commit) THEN
2584       COMMIT WORK;
2585     END IF;
2586 
2587     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2588   EXCEPTION
2589     WHEN fnd_api.g_exc_unexpected_error THEN
2590       ROLLBACK TO update_task_pvt4;
2591       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2592       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2593     WHEN OTHERS THEN
2594       ROLLBACK TO update_task_pvt4;
2595       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2596       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2597       fnd_msg_pub.ADD;
2598       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2599       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2600   END;
2601 
2602   -- Simplex Changes..
2603   PROCEDURE update_task(
2604     p_api_version               IN            NUMBER
2605   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
2606   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
2607   , p_object_version_number     IN OUT NOCOPY NUMBER
2608   , p_task_id                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2609   , p_task_name                 IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2610   , p_task_type_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2611   , p_description               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2612   , p_task_status_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2613   , p_task_priority_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2614   , p_owner_type_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2615   , p_owner_id                  IN            NUMBER DEFAULT fnd_api.g_miss_num
2616   , p_owner_territory_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2617   , p_assigned_by_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2618   , p_customer_id               IN            NUMBER DEFAULT fnd_api.g_miss_num
2619   , p_cust_account_id           IN            NUMBER DEFAULT fnd_api.g_miss_num
2620   , p_address_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2621   ,   ---- hz_party_sites
2622     p_planned_start_date        IN            DATE DEFAULT fnd_api.g_miss_date
2623   , p_planned_end_date          IN            DATE DEFAULT fnd_api.g_miss_date
2624   , p_scheduled_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2625   , p_scheduled_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2626   , p_actual_start_date         IN            DATE DEFAULT fnd_api.g_miss_date
2627   , p_actual_end_date           IN            DATE DEFAULT fnd_api.g_miss_date
2628   , p_timezone_id               IN            NUMBER DEFAULT fnd_api.g_miss_num
2629   , p_source_object_type_code   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2630   , p_source_object_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2631   , p_source_object_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2632   , p_duration                  IN            NUMBER DEFAULT fnd_api.g_miss_num
2633   , p_duration_uom              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2634   , p_planned_effort            IN            NUMBER DEFAULT fnd_api.g_miss_num
2635   , p_planned_effort_uom        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2636   , p_actual_effort             IN            NUMBER DEFAULT fnd_api.g_miss_num
2637   , p_actual_effort_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2638   , p_percentage_complete       IN            NUMBER DEFAULT fnd_api.g_miss_num
2639   , p_reason_code               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2640   , p_private_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2641   , p_publish_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2642   , p_restrict_closure_flag     IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2643   , p_multi_booked_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2644   , p_milestone_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2645   , p_holiday_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2646   , p_billable_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2647   , p_bound_mode_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2648   , p_soft_bound_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2649   , p_workflow_process_id       IN            NUMBER DEFAULT fnd_api.g_miss_num
2650   , p_notification_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2651   , p_notification_period       IN            NUMBER DEFAULT fnd_api.g_miss_num
2652   , p_notification_period_uom   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2653   , p_parent_task_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2654   , p_alarm_start               IN            NUMBER DEFAULT fnd_api.g_miss_num
2655   , p_alarm_start_uom           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2656   , p_alarm_on                  IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2657   , p_alarm_count               IN            NUMBER DEFAULT fnd_api.g_miss_num
2658   , p_alarm_fired_count         IN            NUMBER DEFAULT fnd_api.g_miss_num
2659   , p_alarm_interval            IN            NUMBER DEFAULT fnd_api.g_miss_num
2660   , p_alarm_interval_uom        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2661   , p_palm_flag                 IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2662   , p_wince_flag                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2663   , p_laptop_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2664   , p_device1_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2665   , p_device2_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2666   , p_device3_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2667   , p_costs                     IN            NUMBER DEFAULT fnd_api.g_miss_num
2668   , p_currency_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2669   , p_escalation_level          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2670   , x_return_status             OUT NOCOPY    VARCHAR2
2671   , x_msg_count                 OUT NOCOPY    NUMBER
2672   , x_msg_data                  OUT NOCOPY    VARCHAR2
2673   , p_attribute1                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2674   , p_attribute2                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2675   , p_attribute3                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2676   , p_attribute4                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2677   , p_attribute5                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2678   , p_attribute6                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2679   , p_attribute7                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2680   , p_attribute8                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2681   , p_attribute9                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2682   , p_attribute10               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2683   , p_attribute11               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2684   , p_attribute12               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2685   , p_attribute13               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2686   , p_attribute14               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2687   , p_attribute15               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2688   , p_attribute_category        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2689   , p_date_selected             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2690   , p_category_id               IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2691   , p_show_on_calendar          IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2692   , p_owner_status_id           IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2693   , p_enable_workflow           IN            VARCHAR2
2694   , p_abort_workflow            IN            VARCHAR2
2695   , p_change_mode               IN            VARCHAR2
2696   , p_free_busy_type            IN            VARCHAR2
2697   , p_task_confirmation_status  IN            VARCHAR2
2698   , p_task_confirmation_counter IN            NUMBER
2699   , p_task_split_flag           IN            VARCHAR2
2700   , p_child_position            IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2701   , p_child_sequence_num        IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2702   ) IS
2703   BEGIN
2704     SAVEPOINT update_task_pvt5;
2705     x_return_status  := fnd_api.g_ret_sts_success;
2706 
2707     IF fnd_api.to_boolean(p_init_msg_list) THEN
2708       fnd_msg_pub.initialize;
2709     END IF;
2710 
2711     -- Call the new version
2712     update_task(
2713       p_api_version                => p_api_version
2714     , p_init_msg_list              => p_init_msg_list
2715     , p_commit                     => fnd_api.g_false
2716     , p_object_version_number      => p_object_version_number
2717     , p_task_id                    => p_task_id
2718     , p_task_name                  => p_task_name
2719     , p_task_type_id               => p_task_type_id
2720     , p_description                => p_description
2721     , p_task_status_id             => p_task_status_id
2722     , p_task_priority_id           => p_task_priority_id
2723     , p_owner_type_code            => p_owner_type_code
2724     , p_owner_id                   => p_owner_id
2725     , p_owner_territory_id         => p_owner_territory_id
2726     , p_assigned_by_id             => p_assigned_by_id
2727     , p_customer_id                => p_customer_id
2728     , p_cust_account_id            => p_cust_account_id
2729     , p_address_id                 => p_address_id
2730     ,   ---- hz_party_sites
2731       p_planned_start_date         => p_planned_start_date
2732     , p_planned_end_date           => p_planned_end_date
2733     , p_scheduled_start_date       => p_scheduled_start_date
2734     , p_scheduled_end_date         => p_scheduled_end_date
2735     , p_actual_start_date          => p_actual_start_date
2736     , p_actual_end_date            => p_actual_end_date
2737     , p_timezone_id                => p_timezone_id
2738     , p_source_object_type_code    => p_source_object_type_code
2739     , p_source_object_id           => p_source_object_id
2740     , p_source_object_name         => p_source_object_name
2741     , p_duration                   => p_duration
2742     , p_duration_uom               => p_duration_uom
2743     , p_planned_effort             => p_planned_effort
2744     , p_planned_effort_uom         => p_planned_effort_uom
2745     , p_actual_effort              => p_actual_effort
2746     , p_actual_effort_uom          => p_actual_effort_uom
2747     , p_percentage_complete        => p_percentage_complete
2748     , p_reason_code                => p_reason_code
2749     , p_private_flag               => p_private_flag
2750     , p_publish_flag               => p_publish_flag
2751     , p_restrict_closure_flag      => p_restrict_closure_flag
2752     , p_multi_booked_flag          => p_multi_booked_flag
2753     , p_milestone_flag             => p_milestone_flag
2754     , p_holiday_flag               => p_holiday_flag
2755     , p_billable_flag              => p_billable_flag
2756     , p_bound_mode_code            => p_bound_mode_code
2757     , p_soft_bound_flag            => p_soft_bound_flag
2758     , p_workflow_process_id        => p_workflow_process_id
2759     , p_notification_flag          => p_notification_flag
2760     , p_notification_period        => p_notification_period
2761     , p_notification_period_uom    => p_notification_period_uom
2762     , p_parent_task_id             => p_parent_task_id
2763     , p_alarm_start                => p_alarm_start
2764     , p_alarm_start_uom            => p_alarm_start_uom
2765     , p_alarm_on                   => p_alarm_on
2766     , p_alarm_count                => p_alarm_count
2767     , p_alarm_fired_count          => p_alarm_fired_count
2768     , p_alarm_interval             => p_alarm_interval
2769     , p_alarm_interval_uom         => p_alarm_interval_uom
2770     , p_palm_flag                  => p_palm_flag
2771     , p_wince_flag                 => p_wince_flag
2772     , p_laptop_flag                => p_laptop_flag
2773     , p_device1_flag               => p_device1_flag
2774     , p_device2_flag               => p_device2_flag
2775     , p_device3_flag               => p_device3_flag
2776     , p_costs                      => p_costs
2777     , p_currency_code              => p_currency_code
2778     , p_escalation_level           => p_escalation_level
2779     , x_return_status              => x_return_status
2780     , x_msg_count                  => x_msg_count
2781     , x_msg_data                   => x_msg_data
2782     , p_attribute1                 => p_attribute1
2783     , p_attribute2                 => p_attribute2
2784     , p_attribute3                 => p_attribute3
2785     , p_attribute4                 => p_attribute4
2786     , p_attribute5                 => p_attribute5
2787     , p_attribute6                 => p_attribute6
2788     , p_attribute7                 => p_attribute7
2789     , p_attribute8                 => p_attribute8
2790     , p_attribute9                 => p_attribute9
2791     , p_attribute10                => p_attribute10
2792     , p_attribute11                => p_attribute11
2793     , p_attribute12                => p_attribute12
2794     , p_attribute13                => p_attribute13
2795     , p_attribute14                => p_attribute14
2796     , p_attribute15                => p_attribute15
2797     , p_attribute_category         => p_attribute_category
2798     , p_date_selected              => p_date_selected
2799     , p_category_id                => p_category_id
2800     , p_show_on_calendar           => p_show_on_calendar
2801     , p_owner_status_id            => p_owner_status_id
2802     , p_enable_workflow            => p_enable_workflow
2803     , p_abort_workflow             => p_abort_workflow
2804     , p_change_mode                => p_change_mode
2805     , p_free_busy_type             => p_free_busy_type
2806     , p_task_confirmation_status   => p_task_confirmation_status
2807     , p_task_confirmation_counter  => p_task_confirmation_counter
2808     , p_task_split_flag            => p_task_split_flag
2809     , p_child_position             => p_child_position
2810     , p_child_sequence_num         => p_child_sequence_num
2811     , p_location_id                => NULL
2812     );
2813 
2814     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2815       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2816       RAISE fnd_api.g_exc_unexpected_error;
2817     END IF;
2818 
2819     IF fnd_api.to_boolean(p_commit) THEN
2820       COMMIT WORK;
2821     END IF;
2822 
2823     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2824   EXCEPTION
2825     WHEN fnd_api.g_exc_unexpected_error THEN
2826       ROLLBACK TO update_task_pvt5;
2827       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2828       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2829     WHEN OTHERS THEN
2830       ROLLBACK TO update_task_pvt5;
2831       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2832       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2833       fnd_msg_pub.ADD;
2834       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2835       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2836   END;
2837 
2838   -- Location Id..
2839   PROCEDURE update_task(
2840     p_api_version               IN            NUMBER
2841   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
2842   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
2843   , p_object_version_number     IN OUT NOCOPY NUMBER
2844   , p_task_id                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2845   , p_task_name                 IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2846   , p_task_type_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2847   , p_description               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2848   , p_task_status_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2849   , p_task_priority_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2850   , p_owner_type_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2851   , p_owner_id                  IN            NUMBER DEFAULT fnd_api.g_miss_num
2852   , p_owner_territory_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2853   , p_assigned_by_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2854   , p_customer_id               IN            NUMBER DEFAULT fnd_api.g_miss_num
2855   , p_cust_account_id           IN            NUMBER DEFAULT fnd_api.g_miss_num
2856   , p_address_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2857   , p_planned_start_date        IN            DATE DEFAULT fnd_api.g_miss_date
2858   , p_planned_end_date          IN            DATE DEFAULT fnd_api.g_miss_date
2859   , p_scheduled_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2860   , p_scheduled_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2861   , p_actual_start_date         IN            DATE DEFAULT fnd_api.g_miss_date
2862   , p_actual_end_date           IN            DATE DEFAULT fnd_api.g_miss_date
2863   , p_timezone_id               IN            NUMBER DEFAULT fnd_api.g_miss_num
2864   , p_source_object_type_code   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2865   , p_source_object_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2866   , p_source_object_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2867   , p_duration                  IN            NUMBER DEFAULT fnd_api.g_miss_num
2868   , p_duration_uom              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2869   , p_planned_effort            IN            NUMBER DEFAULT fnd_api.g_miss_num
2870   , p_planned_effort_uom        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2871   , p_actual_effort             IN            NUMBER DEFAULT fnd_api.g_miss_num
2872   , p_actual_effort_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2873   , p_percentage_complete       IN            NUMBER DEFAULT fnd_api.g_miss_num
2874   , p_reason_code               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2875   , p_private_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2876   , p_publish_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2877   , p_restrict_closure_flag     IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2878   , p_multi_booked_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2879   , p_milestone_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2880   , p_holiday_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2881   , p_billable_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2882   , p_bound_mode_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2883   , p_soft_bound_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2884   , p_workflow_process_id       IN            NUMBER DEFAULT fnd_api.g_miss_num
2885   , p_notification_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2886   , p_notification_period       IN            NUMBER DEFAULT fnd_api.g_miss_num
2887   , p_notification_period_uom   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2888   , p_parent_task_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2889   , p_alarm_start               IN            NUMBER DEFAULT fnd_api.g_miss_num
2890   , p_alarm_start_uom           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2891   , p_alarm_on                  IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2892   , p_alarm_count               IN            NUMBER DEFAULT fnd_api.g_miss_num
2893   , p_alarm_fired_count         IN            NUMBER DEFAULT fnd_api.g_miss_num
2894   , p_alarm_interval            IN            NUMBER DEFAULT fnd_api.g_miss_num
2895   , p_alarm_interval_uom        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2896   , p_palm_flag                 IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2897   , p_wince_flag                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2898   , p_laptop_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2899   , p_device1_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2900   , p_device2_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2901   , p_device3_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2902   , p_costs                     IN            NUMBER DEFAULT fnd_api.g_miss_num
2903   , p_currency_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2904   , p_escalation_level          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2905   , x_return_status             OUT NOCOPY    VARCHAR2
2906   , x_msg_count                 OUT NOCOPY    NUMBER
2907   , x_msg_data                  OUT NOCOPY    VARCHAR2
2908   , p_attribute1                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2909   , p_attribute2                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2910   , p_attribute3                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2911   , p_attribute4                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2912   , p_attribute5                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2913   , p_attribute6                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2914   , p_attribute7                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2915   , p_attribute8                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2916   , p_attribute9                IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2917   , p_attribute10               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2918   , p_attribute11               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2919   , p_attribute12               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2920   , p_attribute13               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2921   , p_attribute14               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2922   , p_attribute15               IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2923   , p_attribute_category        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2924   , p_date_selected             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2925   , p_category_id               IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2926   , p_show_on_calendar          IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2927   , p_owner_status_id           IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2928   , p_enable_workflow           IN            VARCHAR2
2929   , p_abort_workflow            IN            VARCHAR2
2930   , p_change_mode               IN            VARCHAR2
2931   , p_free_busy_type            IN            VARCHAR2
2932   , p_task_confirmation_status  IN            VARCHAR2
2933   , p_task_confirmation_counter IN            NUMBER
2934   , p_task_split_flag           IN            VARCHAR2
2935   , p_child_position            IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2936   , p_child_sequence_num        IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2937   , p_location_id               IN            NUMBER
2938   ) IS
2939     l_task_id                      jtf_tasks_b.task_id%TYPE;
2940     l_task_number                  jtf_tasks_b.task_number%TYPE;
2941     l_task_type_id                 jtf_tasks_b.task_type_id%TYPE;
2942     l_task_status_id               jtf_tasks_b.task_status_id%TYPE;
2943     l_task_priority_id             jtf_tasks_b.task_priority_id%TYPE;
2944     l_owner_id                     jtf_tasks_b.owner_id%TYPE;
2945     l_owner_type_code              jtf_tasks_b.owner_type_code%TYPE;
2946     l_assigned_by_id               jtf_tasks_b.assigned_by_id%TYPE;
2947     l_cust_account_id              jtf_tasks_b.cust_account_id%TYPE;
2948     l_customer_id                  jtf_tasks_b.customer_id%TYPE;
2949     l_address_id                   jtf_tasks_b.address_id%TYPE;
2950     l_location_id                  hz_locations.location_id%TYPE;
2951     l_planned_start_date           jtf_tasks_b.planned_start_date%TYPE;
2952     l_planned_end_date             jtf_tasks_b.planned_end_date%TYPE;
2953     l_scheduled_start_date         jtf_tasks_b.scheduled_start_date%TYPE;
2954     l_scheduled_end_date           jtf_tasks_b.scheduled_end_date%TYPE;
2955     l_actual_start_date            jtf_tasks_b.actual_start_date%TYPE;
2956     l_actual_end_date              jtf_tasks_b.actual_end_date%TYPE;
2957     l_source_object_type_code      jtf_tasks_b.source_object_type_code%TYPE;
2958     l_timezone_id                  jtf_tasks_b.timezone_id%TYPE;
2959     l_source_object_id             jtf_tasks_b.source_object_id%TYPE;
2960     l_source_object_name           jtf_tasks_b.source_object_name%TYPE;
2961     l_duration                     jtf_tasks_b.DURATION%TYPE;
2962     l_duration_uom                 jtf_tasks_b.duration_uom%TYPE;
2963     l_planned_effort               jtf_tasks_b.planned_effort%TYPE;
2964     l_planned_effort_uom           jtf_tasks_b.planned_effort_uom%TYPE;
2965     l_actual_effort                jtf_tasks_b.actual_effort%TYPE;
2966     l_actual_effort_uom            jtf_tasks_b.actual_effort_uom%TYPE;
2967     l_percentage_complete          jtf_tasks_b.percentage_complete%TYPE;
2968     l_reason_code                  jtf_tasks_b.reason_code%TYPE;
2969     l_private_flag                 jtf_tasks_b.private_flag%TYPE;
2970     l_publish_flag                 jtf_tasks_b.publish_flag%TYPE;
2971     l_restrict_closure_flag        jtf_tasks_b.restrict_closure_flag%TYPE;
2972     l_multi_booked_flag            jtf_tasks_b.multi_booked_flag%TYPE;
2973     l_milestone_flag               jtf_tasks_b.milestone_flag%TYPE;
2974     l_holiday_flag                 jtf_tasks_b.holiday_flag%TYPE;
2975     l_billable_flag                jtf_tasks_b.billable_flag%TYPE;
2976     l_bound_mode_code              jtf_tasks_b.bound_mode_code%TYPE;
2977     l_soft_bound_flag              jtf_tasks_b.soft_bound_flag%TYPE;
2978     l_workflow_process_id          jtf_tasks_b.workflow_process_id%TYPE;
2979     l_notification_flag            jtf_tasks_b.notification_flag%TYPE;
2980     l_notification_period          jtf_tasks_b.notification_period%TYPE;
2981     l_notification_period_uom      jtf_tasks_b.notification_period_uom%TYPE;
2982     l_parent_task_id               jtf_tasks_b.parent_task_id%TYPE;
2983     l_alarm_start                  jtf_tasks_b.alarm_start%TYPE;
2984     l_alarm_start_uom              jtf_tasks_b.alarm_start_uom%TYPE;
2985     l_alarm_on                     jtf_tasks_b.alarm_on%TYPE;
2986     l_alarm_count                  jtf_tasks_b.alarm_count%TYPE;
2987     l_alarm_fired_count            jtf_tasks_b.alarm_fired_count%TYPE;
2988     l_alarm_interval               jtf_tasks_b.alarm_interval%TYPE;
2989     l_alarm_interval_uom           jtf_tasks_b.alarm_interval_uom%TYPE;
2990     l_palm_flag                    jtf_tasks_b.palm_flag%TYPE;
2991     l_wince_flag                   jtf_tasks_b.wince_flag%TYPE;
2992     l_laptop_flag                  jtf_tasks_b.laptop_flag%TYPE;
2993     l_device1_flag                 jtf_tasks_b.device1_flag%TYPE;
2994     l_device2_flag                 jtf_tasks_b.device2_flag%TYPE;
2995     l_device3_flag                 jtf_tasks_b.device3_flag%TYPE;
2996     l_currency_code                jtf_tasks_b.currency_code%TYPE;
2997     l_costs                        jtf_tasks_b.costs%TYPE;
2998     l_org_id                       jtf_tasks_b.org_id%TYPE;
2999     l_task_name                    jtf_tasks_tl.task_name%TYPE;
3000     l_description                  jtf_tasks_tl.description%TYPE;
3001     l_escalation_level             jtf_tasks_b.escalation_level%TYPE;
3002     l_calendar_start_date          jtf_tasks_b.calendar_start_date%TYPE;
3003     l_calendar_end_date            jtf_tasks_b.calendar_end_date%TYPE;
3004     l_date_selected                jtf_tasks_b.date_selected%TYPE;
3005     l_owner_status_id              jtf_task_assignments.assignment_status_id%TYPE;
3006     l_show_on_calendar             jtf_task_assignments.show_on_calendar%TYPE;
3007     l_free_busy_type               jtf_task_all_assignments.free_busy_type%TYPE;
3008     l_task_confirmation_status     jtf_tasks_b.task_confirmation_status%TYPE;
3009     l_task_confirmation_counter    jtf_tasks_b.task_confirmation_counter%TYPE;
3010     l_task_split_flag              jtf_tasks_b.task_split_flag%TYPE;
3011     l_enable_workflow              VARCHAR2(1)                                 := p_enable_workflow;
3012     l_abort_workflow               VARCHAR2(1)                                  := p_abort_workflow;
3013     l_child_position               jtf_tasks_b.child_position%TYPE;
3014     l_child_sequence_num           jtf_tasks_b.child_sequence_num%TYPE;
3015 
3016     CURSOR c_task IS
3017       SELECT task_number
3018            , recurrence_rule_id
3019            , DECODE(p_task_name, fnd_api.g_miss_char, task_name, p_task_name) task_name
3020            , DECODE(p_task_type_id, fnd_api.g_miss_num, task_type_id, p_task_type_id) task_type_id
3021            , DECODE(p_description, fnd_api.g_miss_char, description, p_description) description
3022            , DECODE(p_task_status_id, fnd_api.g_miss_num, task_status_id, p_task_status_id)
3023                                                                                      task_status_id
3024            , DECODE(p_task_priority_id, fnd_api.g_miss_num, task_priority_id, p_task_priority_id)
3025                                                                                    task_priority_id
3026            , DECODE(p_owner_type_code, fnd_api.g_miss_char, owner_type_code, p_owner_type_code)
3027                                                                                     owner_type_code
3028            , DECODE(p_owner_id, fnd_api.g_miss_num, owner_id, p_owner_id) owner_id
3029            , DECODE(
3030                p_owner_territory_id
3031              , fnd_api.g_miss_num, owner_territory_id
3032              , p_owner_territory_id
3033              ) owner_territory_id
3034            , DECODE(p_assigned_by_id, fnd_api.g_miss_num, assigned_by_id, p_assigned_by_id)
3035                                                                                      assigned_by_id
3036            , DECODE(p_customer_id, fnd_api.g_miss_num, customer_id, p_customer_id) customer_id
3037            , DECODE(p_cust_account_id, fnd_api.g_miss_num, cust_account_id, p_cust_account_id)
3038                                                                                     cust_account_id
3039            , DECODE(p_address_id, fnd_api.g_miss_num, address_id, p_address_id) address_id
3040            , DECODE(
3041                p_planned_start_date
3042              , fnd_api.g_miss_date, planned_start_date
3043              , p_planned_start_date
3044              ) planned_start_date
3045            , DECODE(p_planned_end_date, fnd_api.g_miss_date, planned_end_date, p_planned_end_date)
3046                                                                                    planned_end_date
3047            , DECODE(
3048                p_scheduled_start_date
3049              , fnd_api.g_miss_date, scheduled_start_date
3050              , p_scheduled_start_date
3051              ) scheduled_start_date
3052            , DECODE(
3053                p_scheduled_end_date
3054              , fnd_api.g_miss_date, scheduled_end_date
3055              , p_scheduled_end_date
3056              ) scheduled_end_date
3057            , DECODE(
3058                p_actual_start_date
3059              , fnd_api.g_miss_date, actual_start_date
3060              , p_actual_start_date
3061              ) actual_start_date
3062            , DECODE(p_actual_end_date, fnd_api.g_miss_date, actual_end_date, p_actual_end_date)
3063                                                                                     actual_end_date
3064            , DECODE(p_timezone_id, fnd_api.g_miss_num, timezone_id, p_timezone_id) timezone_id
3065            , DECODE(
3066                p_workflow_process_id
3067              , fnd_api.g_miss_num, workflow_process_id
3068              , p_workflow_process_id
3069              ) workflow_process_id
3070            ,
3071              ---
3072              --- handle NULL like g_miss_value for these three parameters, to fix bug #2002639
3073              ---
3074              DECODE(
3075                p_source_object_type_code
3076              , fnd_api.g_miss_char, source_object_type_code
3077              , NULL, source_object_type_code
3078              , p_source_object_type_code
3079              ) source_object_type_code
3080            , DECODE(
3081                p_source_object_id
3082              , fnd_api.g_miss_num, source_object_id
3083              , NULL, source_object_id
3084              , p_source_object_id
3085              ) source_object_id
3086            ,
3087              ---
3088              --- to fix bug #2224949
3089              ---
3090              DECODE(
3091                p_source_object_name
3092              , fnd_api.g_miss_char, source_object_name
3093              , NULL, source_object_name
3094              , jtf_task_utl.check_truncation(p_source_object_name)
3095              ) source_object_name
3096            , DECODE(p_duration, fnd_api.g_miss_num, DURATION, p_duration) DURATION
3097            , DECODE(p_duration_uom, fnd_api.g_miss_char, duration_uom, p_duration_uom) duration_uom
3098            , DECODE(p_planned_effort, fnd_api.g_miss_num, planned_effort, p_planned_effort)
3099                                                                                      planned_effort
3100            , DECODE(
3101                p_planned_effort_uom
3102              , fnd_api.g_miss_char, planned_effort_uom
3103              , p_planned_effort_uom
3104              ) planned_effort_uom
3105            , DECODE(p_actual_effort, fnd_api.g_miss_num, actual_effort, p_actual_effort)
3106                                                                                       actual_effort
3107            , DECODE(
3108                p_actual_effort_uom
3109              , fnd_api.g_miss_char, actual_effort_uom
3110              , p_actual_effort_uom
3111              ) actual_effort_uom
3112            , DECODE(
3113                p_percentage_complete
3114              , fnd_api.g_miss_num, percentage_complete
3115              , p_percentage_complete
3116              ) percentage_complete
3117            , DECODE(p_reason_code, fnd_api.g_miss_char, reason_code, p_reason_code) reason_code
3118            , DECODE(p_private_flag, fnd_api.g_miss_char, private_flag, p_private_flag) private_flag
3119            , DECODE(p_publish_flag, fnd_api.g_miss_char, publish_flag, p_publish_flag) publish_flag
3120            , DECODE(
3121                p_restrict_closure_flag
3122              , fnd_api.g_miss_char, restrict_closure_flag
3123              , p_restrict_closure_flag
3124              ) restrict_closure_flag
3125            , DECODE(
3126                p_multi_booked_flag
3127              , fnd_api.g_miss_char, multi_booked_flag
3128              , p_multi_booked_flag
3129              ) multi_booked_flag
3130            , DECODE(p_milestone_flag, fnd_api.g_miss_char, milestone_flag, p_milestone_flag)
3131                                                                                      milestone_flag
3132            , DECODE(p_holiday_flag, fnd_api.g_miss_char, holiday_flag, p_holiday_flag) holiday_flag
3133            , DECODE(p_billable_flag, fnd_api.g_miss_char, billable_flag, p_billable_flag)
3134                                                                                       billable_flag
3135            , DECODE(p_bound_mode_code, fnd_api.g_miss_char, bound_mode_code, p_bound_mode_code)
3136                                                                                     bound_mode_code
3137            , DECODE(p_soft_bound_flag, fnd_api.g_miss_char, soft_bound_flag, p_soft_bound_flag)
3138                                                                                     soft_bound_flag
3139            , DECODE(
3140                p_notification_flag
3141              , fnd_api.g_miss_char, notification_flag
3142              , p_notification_flag
3143              ) notification_flag
3144            , DECODE(
3145                p_notification_period
3146              , fnd_api.g_miss_num, notification_period
3147              , p_notification_period
3148              ) notification_period
3149            , DECODE(
3150                p_notification_period_uom
3151              , fnd_api.g_miss_char, notification_period_uom
3152              , p_notification_period_uom
3153              ) notification_period_uom
3154            , DECODE(p_parent_task_id, fnd_api.g_miss_num, parent_task_id, p_parent_task_id)
3155                                                                                      parent_task_id
3156            , DECODE(p_alarm_start, fnd_api.g_miss_num, alarm_start, p_alarm_start) alarm_start
3157            , DECODE(p_alarm_start_uom, fnd_api.g_miss_char, alarm_start_uom, p_alarm_start_uom)
3158                                                                                     alarm_start_uom
3159            , DECODE(p_alarm_on, fnd_api.g_miss_char, alarm_on, p_alarm_on) alarm_on
3160            , DECODE(p_alarm_count, fnd_api.g_miss_num, alarm_count, p_alarm_count) alarm_count
3161            , DECODE(
3162                p_alarm_fired_count
3163              , fnd_api.g_miss_num, alarm_fired_count
3164              , p_alarm_fired_count
3165              ) alarm_fired_count
3166            , DECODE(p_alarm_interval, fnd_api.g_miss_num, alarm_interval, p_alarm_interval)
3167                                                                                      alarm_interval
3168            , DECODE(
3169                p_alarm_interval_uom
3170              , fnd_api.g_miss_char, alarm_interval_uom
3171              , p_alarm_interval_uom
3172              ) alarm_interval_uom
3173            , DECODE(p_palm_flag, fnd_api.g_miss_char, palm_flag, p_palm_flag) palm_flag
3174            , DECODE(p_wince_flag, fnd_api.g_miss_char, wince_flag, p_wince_flag) wince_flag
3175            , DECODE(p_laptop_flag, fnd_api.g_miss_char, laptop_flag, p_laptop_flag) laptop_flag
3176            , DECODE(p_device1_flag, fnd_api.g_miss_char, device1_flag, p_device1_flag) device1_flag
3177            , DECODE(p_device2_flag, fnd_api.g_miss_char, device2_flag, p_device2_flag) device2_flag
3178            , DECODE(p_device3_flag, fnd_api.g_miss_char, device3_flag, p_device3_flag) device3_flag
3179            , DECODE(p_costs, fnd_api.g_miss_num, costs, p_costs) costs
3180            , DECODE(p_currency_code, fnd_api.g_miss_char, currency_code, p_currency_code)
3181                                                                                       currency_code
3182            , DECODE(p_escalation_level, fnd_api.g_miss_char, escalation_level, p_escalation_level)
3183                                                                                    escalation_level
3184            , DECODE(p_attribute1, fnd_api.g_miss_char, attribute1, p_attribute1) attribute1
3185            , DECODE(p_attribute2, fnd_api.g_miss_char, attribute2, p_attribute2) attribute2
3186            , DECODE(p_attribute3, fnd_api.g_miss_char, attribute3, p_attribute3) attribute3
3187            , DECODE(p_attribute4, fnd_api.g_miss_char, attribute4, p_attribute4) attribute4
3188            , DECODE(p_attribute5, fnd_api.g_miss_char, attribute5, p_attribute5) attribute5
3189            , DECODE(p_attribute6, fnd_api.g_miss_char, attribute6, p_attribute6) attribute6
3190            , DECODE(p_attribute7, fnd_api.g_miss_char, attribute7, p_attribute7) attribute7
3191            , DECODE(p_attribute8, fnd_api.g_miss_char, attribute8, p_attribute8) attribute8
3192            , DECODE(p_attribute9, fnd_api.g_miss_char, attribute9, p_attribute9) attribute9
3193            , DECODE(p_attribute10, fnd_api.g_miss_char, attribute10, p_attribute10) attribute10
3194            , DECODE(p_attribute11, fnd_api.g_miss_char, attribute11, p_attribute11) attribute11
3195            , DECODE(p_attribute12, fnd_api.g_miss_char, attribute12, p_attribute12) attribute12
3196            , DECODE(p_attribute13, fnd_api.g_miss_char, attribute13, p_attribute13) attribute13
3197            , DECODE(p_attribute14, fnd_api.g_miss_char, attribute14, p_attribute14) attribute14
3198            , DECODE(p_attribute15, fnd_api.g_miss_char, attribute15, p_attribute15) attribute15
3199            , DECODE(
3200                p_attribute_category
3201              , fnd_api.g_miss_char, attribute_category
3202              , p_attribute_category
3203              ) attribute_category
3204            , calendar_start_date
3205            , calendar_end_date
3206            , DURATION duration_orig
3207            ,   -- XY Story #140
3208              DECODE(p_date_selected, fnd_api.g_miss_char, date_selected, p_date_selected)
3209                                                                                       date_selected
3210            , creation_date
3211            , DECODE(
3212                p_task_confirmation_status
3213              , jtf_task_utl.g_miss_char, task_confirmation_status
3214              , p_task_confirmation_status
3215              ) task_confirmation_status
3216            , DECODE(
3217                p_task_confirmation_counter
3218              , jtf_task_utl.g_miss_number, task_confirmation_counter
3219              , p_task_confirmation_counter
3220              ) task_confirmation_counter
3221            , DECODE(
3222                p_task_split_flag
3223              , jtf_task_utl.g_miss_char, task_split_flag
3224              , p_task_split_flag
3225              ) task_split_flag
3226            , DECODE(p_child_position, jtf_task_utl.g_miss_char, child_position, p_child_position)
3227                                                                                      child_position
3228            , DECODE(
3229                p_child_sequence_num
3230              , jtf_task_utl.g_miss_number, child_sequence_num
3231              , p_child_sequence_num
3232              ) child_sequence_num
3233            , DECODE(p_location_id, fnd_api.g_miss_num, location_id, p_location_id) location_id
3234         FROM jtf_tasks_vl
3235        WHERE task_id = p_task_id;
3236 
3237     tasks                          c_task%ROWTYPE;
3238     x                              NUMBER;
3239 
3240     CURSOR task_ass_u(b_task_id IN NUMBER) IS
3241       SELECT task_id
3242            , task_assignment_id
3243            , object_version_number
3244            , DECODE(p_owner_id, fnd_api.g_miss_num, resource_id, p_owner_id) resource_id
3245            , DECODE(p_owner_type_code, fnd_api.g_miss_char, resource_type_code, p_owner_type_code) resource_type_code
3246            , DECODE(
3247                p_owner_territory_id
3248              , fnd_api.g_miss_num, resource_territory_id
3249              , p_owner_territory_id
3250              ) resource_territory_id
3251            , DECODE(l_owner_status_id, fnd_api.g_miss_num, assignment_status_id, l_owner_status_id) assignment_status_id
3252            , DECODE(l_show_on_calendar, fnd_api.g_miss_char, show_on_calendar, l_show_on_calendar) show_on_calendar
3253            , DECODE(p_category_id, jtf_task_utl.g_miss_number, category_id, p_category_id) category_id
3254            , DECODE(p_free_busy_type, jtf_task_utl.g_miss_char, free_busy_type, p_free_busy_type) free_busy_type
3255         FROM jtf_task_all_assignments
3256        WHERE assignee_role = 'OWNER' AND task_id = b_task_id;
3257 
3258     task_ass_rec                   task_ass_u%ROWTYPE;
3259 
3260     -- Modified on 19/06/2006 for bug# 5210853
3261     CURSOR task_ass_orig(b_task_id IN NUMBER) IS
3262       SELECT   task_id
3263              , assignment_status_id
3264              , show_on_calendar
3265              , category_id
3266              , resource_id
3267              , resource_type_code
3268              , free_busy_type
3269              , booking_start_date
3270              , booking_end_date
3271              , task_assignment_id
3272              , object_version_number
3273              , actual_start_date
3274              , actual_end_date
3275              , actual_effort
3276              , actual_effort_uom
3277              , actual_travel_duration
3278              , actual_travel_duration_uom
3279              , assignee_role
3280           FROM jtf_task_all_assignments
3281          WHERE task_id = b_task_id
3282       ORDER BY assignee_role DESC;
3283 
3284     task_ass_orig_rec              task_ass_orig%ROWTYPE;
3285     -- added for Bug 6031383
3286     l_booking_start_date           jtf_task_all_assignments.booking_start_date%TYPE;
3287     l_booking_end_date             jtf_task_all_assignments.booking_end_date%TYPE;
3288 
3289     CURSOR task_cust_orig(b_task_id IN NUMBER) IS
3290       SELECT customer_id
3291         FROM jtf_tasks_b
3292        WHERE task_id = b_task_id;
3293 
3294     l_orig_cust_id                 jtf_tasks_b.customer_id%TYPE;
3295 
3296     -- 2102281
3297     CURSOR task_source_orig(b_task_id IN NUMBER) IS
3298       SELECT source_object_id
3299            , source_object_type_code
3300            , entity
3301            , open_flag
3302         FROM jtf_tasks_b
3303        WHERE task_id = b_task_id;
3304 
3305     CURSOR c_ref(b_task_id jtf_tasks_b.task_id%TYPE, b_source_id hz_parties.party_id%TYPE) IS
3306       SELECT task_reference_id
3307            , object_version_number
3308         FROM jtf_task_references_b
3309        WHERE task_id = b_task_id AND object_id = b_source_id;
3310 
3311     l_orig_source_id               jtf_tasks_b.source_object_id%TYPE;
3312     l_orig_source_object_type_code jtf_tasks_b.source_object_type_code%TYPE;
3313     l_entity                       jtf_tasks_b.entity%TYPE;
3314     l_orig_open_flag               jtf_tasks_b.open_flag%TYPE;
3315     l_obj_version_number           jtf_task_references_b.object_version_number%TYPE;
3316     l_task_ref_id                  jtf_task_references_b.task_reference_id%TYPE;
3317 
3318     CURSOR c_del_contacts(c_task_id jtf_tasks_b.task_id%TYPE) IS
3319       SELECT task_contact_id
3320            , contact_id
3321            , object_version_number
3322         FROM jtf_task_contacts
3323        WHERE task_id = c_task_id;
3324 
3325     l_updated_field_rec            jtf_task_repeat_appt_pvt.updated_field_rec;
3326     l_assignee_rec                 jtf_task_utl.c_assignee_or_owner%ROWTYPE;
3327     --BES enh 2391065
3328     l_task_rec_type_old            jtf_tasks_pvt.task_rec_type;
3329     l_task_rec_type_new            jtf_tasks_pvt.task_rec_type;
3330     x_task_upd_rec                 jtf_tasks_pkg.task_upd_rec;   --BES enh
3331     x_task_audit_id                jtf_task_audits_b.task_audit_id%TYPE;
3332     x_event_return_status          VARCHAR2(100);
3333     l_availability VARCHAR2(1) := 'F';
3334     l_name VARCHAR2(200);
3335     l_date VARCHAR2(200);
3336   --BES enh 2391065
3337 
3338     /* moved from pub package*/
3339     CURSOR c_owner_status_id(b_owner_status_id jtf_task_all_assignments.assignment_status_id%TYPE) IS
3340       SELECT task_status_id
3341         FROM jtf_task_statuses_b
3342        WHERE task_status_id = b_owner_status_id
3343          --AND assigned_flag = 'Y'
3344          AND assignment_status_flag = 'Y'   -- Fix bug 2500664
3345          AND NVL(end_date_active, SYSDATE) >= SYSDATE
3346          AND NVL(start_date_active, SYSDATE) <= SYSDATE;
3347 
3348   BEGIN
3349     SAVEPOINT update_task_pvt;
3350     x_return_status                                            := fnd_api.g_ret_sts_success;
3351 
3352     IF fnd_api.to_boolean(p_init_msg_list) THEN
3353       fnd_msg_pub.initialize;
3354     END IF;
3355 
3356     IF p_task_name IS NULL THEN
3357       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_NAME');
3358       fnd_msg_pub.ADD;
3359       RAISE fnd_api.g_exc_unexpected_error;
3360     END IF;
3361 
3362     IF p_task_split_flag IS NOT NULL THEN
3363       IF NOT p_task_split_flag IN('M', 'D', fnd_api.g_miss_char) THEN
3364         fnd_message.set_name('JTF', 'JTF_TASK_CONSTRUCT_ID');
3365         fnd_message.set_token('%P_SHITF_CONSTRUCT_ID', 'task split flag');
3366         fnd_msg_pub.ADD;
3367         RAISE fnd_api.g_exc_unexpected_error;
3368       END IF;
3369     END IF;
3370 
3371     IF NOT p_task_confirmation_status IN('N', 'C', 'R', fnd_api.g_miss_char) THEN
3372       fnd_message.set_name('JTF', 'JTF_TASK_CONSTRUCT_ID');
3373       fnd_message.set_token('%P_SHITF_CONSTRUCT_ID', 'task confirmation status');
3374       fnd_msg_pub.ADD;
3375       RAISE fnd_api.g_exc_unexpected_error;
3376     END IF;
3377 
3378     OPEN c_task;
3379     FETCH c_task INTO tasks;
3380     IF c_task%NOTFOUND THEN
3381       CLOSE c_task;
3382       fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_ID');
3383       fnd_message.set_token('P_TASK_ID', p_task_id);
3384       fnd_msg_pub.ADD;
3385       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3386       RAISE fnd_api.g_exc_unexpected_error;
3387     END IF;
3388     CLOSE c_task;
3389 
3390     -- ------------------------------------------------------------------------
3391     -- Check that the user has the correct security privilege
3392     -- ------------------------------------------------------------------------
3393     jtf_task_utl.check_security_privilege(
3394       p_task_id       => p_task_id
3395     , p_session       => 'UPDATE'
3396     , x_return_status => x_return_status
3397     );
3398 
3399     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3400       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3401       RAISE fnd_api.g_exc_unexpected_error;
3402     END IF;
3403 
3404     l_task_id                                                  := p_task_id;
3405     l_task_name                                                := tasks.task_name;
3406     l_task_number                                              := tasks.task_number;
3407     l_task_type_id                                             := tasks.task_type_id;
3408     l_description                                              := tasks.description;
3409     l_task_status_id                                           := tasks.task_status_id;
3410     l_task_priority_id                                         := tasks.task_priority_id;
3411     l_owner_type_code                                          := tasks.owner_type_code;
3412     l_owner_id                                                 := tasks.owner_id;
3413     l_assigned_by_id                                           := tasks.assigned_by_id;
3414     l_customer_id                                              := tasks.customer_id;
3415     l_cust_account_id                                          := tasks.cust_account_id;
3416     l_address_id                                               := tasks.address_id;
3417     l_planned_start_date                                       := tasks.planned_start_date;
3418     l_planned_end_date                                         := tasks.planned_end_date;
3419     l_scheduled_start_date                                     := tasks.scheduled_start_date;
3420     l_scheduled_end_date                                       := tasks.scheduled_end_date;
3421     l_actual_start_date                                        := tasks.actual_start_date;
3422     l_actual_end_date                                          := tasks.actual_end_date;
3423     l_timezone_id                                              := tasks.timezone_id;
3424     l_duration                                                 := tasks.DURATION;
3425     l_duration_uom                                             := tasks.duration_uom;
3426     l_planned_effort                                           := tasks.planned_effort;
3427     l_planned_effort_uom                                       := tasks.planned_effort_uom;
3428     l_actual_effort                                            := tasks.actual_effort;
3429     l_actual_effort_uom                                        := tasks.actual_effort_uom;
3430     l_percentage_complete                                      := tasks.percentage_complete;
3431     l_reason_code                                              := tasks.reason_code;
3432     l_private_flag                                             := tasks.private_flag;
3433     l_publish_flag                                             := tasks.publish_flag;
3434     l_restrict_closure_flag                                    := tasks.restrict_closure_flag;
3435     l_multi_booked_flag                                        := tasks.multi_booked_flag;
3436     l_milestone_flag                                           := tasks.milestone_flag;
3437     l_holiday_flag                                             := tasks.holiday_flag;
3438     l_billable_flag                                            := tasks.billable_flag;
3439     l_bound_mode_code                                          := tasks.bound_mode_code;
3440     l_soft_bound_flag                                          := tasks.soft_bound_flag;
3441     l_notification_flag                                        := tasks.notification_flag;
3442     l_notification_period                                      := tasks.notification_period;
3443     l_notification_period_uom                                  := tasks.notification_period_uom;
3444     l_parent_task_id                                           := tasks.parent_task_id;
3445     l_alarm_start                                              := tasks.alarm_start;
3446     l_alarm_start_uom                                          := tasks.alarm_start_uom;
3447     l_alarm_on                                                 := tasks.alarm_on;
3448     l_alarm_count                                              := tasks.alarm_count;
3449     l_alarm_fired_count                                        := tasks.alarm_fired_count;
3450     l_alarm_interval                                           := tasks.alarm_interval;
3451     l_alarm_interval_uom                                       := tasks.alarm_interval_uom;
3452     l_palm_flag                                                := tasks.palm_flag;
3453     l_wince_flag                                               := tasks.wince_flag;
3454     l_laptop_flag                                              := tasks.laptop_flag;
3455     l_device1_flag                                             := tasks.device1_flag;
3456     l_device2_flag                                             := tasks.device2_flag;
3457     l_device3_flag                                             := tasks.device3_flag;
3458     l_costs                                                    := tasks.costs;
3459     l_currency_code                                            := tasks.currency_code;
3460     l_workflow_process_id                                      := tasks.workflow_process_id;
3461     l_escalation_level                                         := tasks.escalation_level;
3462     l_date_selected                                            := tasks.date_selected;
3463     l_free_busy_type                                           := p_free_busy_type;   --Bug No 4269468
3464     l_task_confirmation_status                                 := tasks.task_confirmation_status;
3465     l_task_confirmation_counter                                := tasks.task_confirmation_counter;
3466     l_task_split_flag                                          := tasks.task_split_flag;
3467     l_child_position                                           := tasks.child_position;
3468     l_child_sequence_num                                       := tasks.child_sequence_num;
3469     l_location_id                                              := tasks.location_id;
3470     -- ------------------------------------------------------------------------
3471     -- Call jtf_task_utl procedure to set calendar_start_date and
3472     -- calendar_end_date
3473     -- ------------------------------------------------------------------------
3474     jtf_task_utl_ext.set_calendar_dates(
3475       p_show_on_calendar           => p_show_on_calendar
3476     , p_date_selected              => tasks.date_selected
3477     , p_planned_start_date         => tasks.planned_start_date
3478     , p_planned_end_date           => tasks.planned_end_date
3479     , p_scheduled_start_date       => tasks.scheduled_start_date
3480     , p_scheduled_end_date         => tasks.scheduled_end_date
3481     , p_actual_start_date          => tasks.actual_start_date
3482     , p_actual_end_date            => tasks.actual_end_date
3483     , x_show_on_calendar           => l_show_on_calendar
3484     , x_date_selected              => l_date_selected
3485     , x_calendar_start_date        => l_calendar_start_date
3486     , x_calendar_end_date          => l_calendar_end_date
3487     , x_return_status              => x_return_status
3488     , p_task_status_id             => l_task_status_id
3489     , p_creation_date              => tasks.creation_date
3490     );
3491 
3492     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3493       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3494       RAISE fnd_api.g_exc_unexpected_error;
3495     END IF;
3496 
3497 
3498     --  Bug 2786689 : Fixing  Cyclic Task Issue
3499     IF (p_parent_task_id IS NOT NULL AND p_parent_task_id <> fnd_api.g_miss_num) THEN
3500       jtf_task_utl.validate_task(
3501         p_task_id                    => l_parent_task_id
3502       , p_task_number                => NULL
3503       , x_task_id                    => l_parent_task_id
3504       , x_return_status              => x_return_status
3505       );
3506 
3507       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3508         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3509         RAISE fnd_api.g_exc_unexpected_error;
3510       END IF;
3511 
3512       jtf_task_utl_ext.validate_cyclic_task(
3513         p_task_id                    => l_task_id
3514       , p_parent_task_id             => l_parent_task_id
3515       , x_return_status              => x_return_status
3516       );
3517 
3518       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3519         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3520         RAISE fnd_api.g_exc_unexpected_error;
3521       END IF;
3522     END IF;
3523 
3524     --- Validate Priority... Bug 3342819
3525     IF (l_task_priority_id = fnd_api.g_miss_num) OR(l_task_priority_id IS NULL) THEN
3526       l_task_priority_id  := 8;
3527     END IF;
3528 
3529     -- If workflow parameters is either NULL or fnd_api.g_miss_char,
3530     -- profile value for workflow will be used instead
3531     IF p_enable_workflow IS NULL OR p_enable_workflow = fnd_api.g_miss_char THEN
3532       l_enable_workflow  := g_enable_workflow;
3533     END IF;
3534 
3535     IF p_abort_workflow IS NULL OR p_abort_workflow = fnd_api.g_miss_char THEN
3536       l_abort_workflow  := g_abort_workflow;
3537     END IF;
3538 
3539     ------------------------------------------------------------
3540     -- Check if this is a repeating appointment
3541     ------------------------------------------------------------
3542     IF     tasks.recurrence_rule_id IS NOT NULL
3543        AND (
3544                tasks.source_object_type_code = 'APPOINTMENT'
3545             OR tasks.source_object_type_code = 'EXTERNAL APPOINTMENT'
3546            )
3547        AND NVL(p_change_mode, jtf_task_repeat_appt_pvt.g_skip) <> jtf_task_repeat_appt_pvt.g_skip THEN
3548       l_updated_field_rec.task_id                  := p_task_id;
3549       l_updated_field_rec.task_name                := p_task_name;
3550       l_updated_field_rec.task_type_id             := p_task_type_id;
3551       l_updated_field_rec.description              := p_description;
3552       l_updated_field_rec.task_status_id           := p_task_status_id;
3553       l_updated_field_rec.task_priority_id         := p_task_priority_id;
3554       l_updated_field_rec.owner_type_code          := p_owner_type_code;
3555       l_updated_field_rec.owner_id                 := p_owner_id;
3556       l_updated_field_rec.owner_territory_id       := p_owner_territory_id;
3557       l_updated_field_rec.assigned_by_id           := p_assigned_by_id;
3558       l_updated_field_rec.customer_id              := p_customer_id;
3559       l_updated_field_rec.cust_account_id          := p_cust_account_id;
3560       l_updated_field_rec.address_id               := p_address_id;
3561       l_updated_field_rec.planned_start_date       := p_planned_start_date;
3562       l_updated_field_rec.planned_end_date         := p_planned_end_date;
3563       l_updated_field_rec.scheduled_start_date     := p_scheduled_start_date;
3564       l_updated_field_rec.scheduled_end_date       := p_scheduled_end_date;
3565       l_updated_field_rec.actual_start_date        := p_actual_start_date;
3566       l_updated_field_rec.actual_end_date          := p_actual_end_date;
3567       l_updated_field_rec.timezone_id              := p_timezone_id;
3568       l_updated_field_rec.source_object_type_code  := p_source_object_type_code;
3569       l_updated_field_rec.source_object_id         := p_source_object_id;
3570       l_updated_field_rec.source_object_name       := p_source_object_name;
3571       l_updated_field_rec.DURATION                 := p_duration;
3572       l_updated_field_rec.duration_uom             := p_duration_uom;
3573       l_updated_field_rec.planned_effort           := p_planned_effort;
3574       l_updated_field_rec.planned_effort_uom       := p_planned_effort_uom;
3575       l_updated_field_rec.actual_effort            := p_actual_effort;
3576       l_updated_field_rec.actual_effort_uom        := p_actual_effort_uom;
3577       l_updated_field_rec.percentage_complete      := p_percentage_complete;
3578       l_updated_field_rec.reason_code              := p_reason_code;
3579       l_updated_field_rec.private_flag             := p_private_flag;
3580       l_updated_field_rec.publish_flag             := p_publish_flag;
3581       l_updated_field_rec.restrict_closure_flag    := p_restrict_closure_flag;
3582       l_updated_field_rec.multi_booked_flag        := p_multi_booked_flag;
3583       l_updated_field_rec.milestone_flag           := p_milestone_flag;
3584       l_updated_field_rec.holiday_flag             := p_holiday_flag;
3585       l_updated_field_rec.billable_flag            := p_billable_flag;
3586       l_updated_field_rec.bound_mode_code          := p_bound_mode_code;
3587       l_updated_field_rec.soft_bound_flag          := p_soft_bound_flag;
3588       l_updated_field_rec.workflow_process_id      := p_workflow_process_id;
3589       l_updated_field_rec.notification_flag        := p_notification_flag;
3590       l_updated_field_rec.notification_period      := p_notification_period;
3591       l_updated_field_rec.notification_period_uom  := p_notification_period_uom;
3592       l_updated_field_rec.parent_task_id           := p_parent_task_id;
3593       l_updated_field_rec.alarm_start              := p_alarm_start;
3594       l_updated_field_rec.alarm_start_uom          := p_alarm_start_uom;
3595       l_updated_field_rec.alarm_on                 := p_alarm_on;
3596       l_updated_field_rec.alarm_count              := p_alarm_count;
3597       l_updated_field_rec.alarm_fired_count        := p_alarm_fired_count;
3598       l_updated_field_rec.alarm_interval           := p_alarm_interval;
3599       l_updated_field_rec.alarm_interval_uom       := p_alarm_interval_uom;
3600       l_updated_field_rec.palm_flag                := p_palm_flag;
3601       l_updated_field_rec.wince_flag               := p_wince_flag;
3602       l_updated_field_rec.laptop_flag              := p_laptop_flag;
3603       l_updated_field_rec.device1_flag             := p_device1_flag;
3604       l_updated_field_rec.device2_flag             := p_device2_flag;
3605       l_updated_field_rec.device3_flag             := p_device3_flag;
3606       l_updated_field_rec.costs                    := p_costs;
3607       l_updated_field_rec.currency_code            := p_currency_code;
3608       l_updated_field_rec.escalation_level         := p_escalation_level;
3609       l_updated_field_rec.attribute1               := p_attribute1;
3610       l_updated_field_rec.attribute2               := p_attribute2;
3611       l_updated_field_rec.attribute3               := p_attribute3;
3612       l_updated_field_rec.attribute4               := p_attribute4;
3613       l_updated_field_rec.attribute5               := p_attribute5;
3614       l_updated_field_rec.attribute6               := p_attribute6;
3615       l_updated_field_rec.attribute7               := p_attribute7;
3616       l_updated_field_rec.attribute8               := p_attribute8;
3617       l_updated_field_rec.attribute9               := p_attribute9;
3618       l_updated_field_rec.attribute10              := p_attribute10;
3619       l_updated_field_rec.attribute11              := p_attribute11;
3620       l_updated_field_rec.attribute12              := p_attribute12;
3621       l_updated_field_rec.attribute13              := p_attribute13;
3622       l_updated_field_rec.attribute14              := p_attribute14;
3623       l_updated_field_rec.attribute15              := p_attribute15;
3624       l_updated_field_rec.attribute_category       := p_attribute_category;
3625       l_updated_field_rec.date_selected            := p_date_selected;
3626       l_updated_field_rec.category_id              := p_category_id;
3627       l_updated_field_rec.show_on_calendar         := p_show_on_calendar;
3628       l_updated_field_rec.owner_status_id          := p_owner_status_id;
3629       l_updated_field_rec.enable_workflow          := l_enable_workflow;
3630       l_updated_field_rec.abort_workflow           := l_abort_workflow;
3631       l_updated_field_rec.change_mode              := p_change_mode;
3632       l_updated_field_rec.recurrence_rule_id       := tasks.recurrence_rule_id;
3633       l_updated_field_rec.old_calendar_start_date  := tasks.calendar_start_date;
3634       l_updated_field_rec.new_calendar_start_date  := l_calendar_start_date;
3635       l_updated_field_rec.new_calendar_end_date    := l_calendar_end_date;
3636       l_updated_field_rec.free_busy_type           := l_free_busy_type;   -- Bug No 4269468
3637       l_updated_field_rec.location_id              := p_location_id;
3638       jtf_task_repeat_appt_pvt.update_repeat_appointment
3639                                                (
3640         p_api_version                => 1.0
3641       , p_init_msg_list              => fnd_api.g_false
3642       , p_commit                     => fnd_api.g_false
3643       , p_object_version_number      => p_object_version_number
3644       , p_updated_field_rec          => l_updated_field_rec
3645       , x_return_status              => x_return_status
3646       , x_msg_count                  => x_msg_count
3647       , x_msg_data                   => x_msg_data
3648       );
3649 
3650       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3651         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3652       --RAISE fnd_api.g_exc_unexpected_error;
3653       END IF;
3654 
3655       RETURN;
3656     END IF;
3657 
3658     -- ------------------------------------------------------------------------
3659     -- If date_selected was not present then set the appropriate dates
3660     -- depending on date_selected returned from set_calendar_dates, to fix
3661     -- bug #1889371
3662     -- ------------------------------------------------------------------------
3663     IF tasks.date_selected IS NULL OR tasks.date_selected = fnd_api.g_miss_char THEN
3664       IF l_date_selected = 'P' THEN
3665         l_planned_start_date  := l_calendar_start_date;
3666         l_planned_end_date    := l_calendar_end_date;
3667       ELSIF l_date_selected = 'S' THEN
3668         l_scheduled_start_date  := l_calendar_start_date;
3669         l_scheduled_end_date    := l_calendar_end_date;
3670       ELSIF l_date_selected = 'A' THEN
3671         l_actual_start_date  := l_calendar_start_date;
3672         l_actual_end_date    := l_calendar_end_date;
3673       END IF;
3674     END IF;
3675 
3676     -- ------------------------------------------------------------------------
3677     -- If type is Appointment then set scheduled dates to the value of the
3678     -- planned dates, to fix bug #1889178
3679     -- ------------------------------------------------------------------------
3680     IF p_source_object_type_code = 'APPOINTMENT' THEN
3681       l_scheduled_start_date  := l_planned_start_date;
3682       l_scheduled_end_date    := l_planned_end_date;
3683     END IF;
3684 
3685     -- ------------------------------------------------------------------------
3686     -- If source is Task or Appointment then set source_id to task_id and
3687     -- source_name to task_number
3688     -- Do not update these values if source_object_type_code is not supplied as
3689     -- a parameter to the update, to fix bug #1935825
3690     -- Also retain original values if source_object_type_code is NULL - this is
3691     -- handled in the DECODE above, so no need to check for it here as
3692     -- tasks.source_object_type_code will always have a value.
3693     -- ------------------------------------------------------------------------
3694     IF tasks.source_object_type_code IN('TASK', 'APPOINTMENT') THEN
3695       l_source_object_id    := l_task_id;
3696       l_source_object_name  := tasks.task_number;
3697     ELSE
3698       l_source_object_id    := tasks.source_object_id;
3699       -- Bug 2602732
3700       l_source_object_name  :=
3701         jtf_task_utl.check_truncation(jtf_task_utl.get_owner(tasks.source_object_type_code
3702           , l_source_object_id));
3703     END IF;
3704 
3705     -- ------------------------------------------------------------------------
3706     -- Get the original customer_id so we can update the reference details if
3707     -- necessary
3708     -- ------------------------------------------------------------------------
3709     OPEN task_cust_orig(l_task_id);
3710     FETCH task_cust_orig INTO l_orig_cust_id;
3711     IF task_cust_orig%NOTFOUND THEN
3712       CLOSE task_cust_orig;
3713       RAISE fnd_api.g_exc_unexpected_error;
3714     END IF;
3715     CLOSE task_cust_orig;
3716 
3717     -- 2102281
3718     OPEN task_source_orig(l_task_id);
3719     FETCH task_source_orig INTO l_orig_source_id, l_orig_source_object_type_code, l_entity, l_orig_open_flag;
3720     IF task_source_orig%NOTFOUND THEN
3721       CLOSE task_source_orig;
3722       RAISE fnd_api.g_exc_unexpected_error;
3723     END IF;
3724     CLOSE task_source_orig;
3725 
3726     jtf_tasks_pub.p_task_user_hooks.task_id                    := l_task_id;
3727     jtf_tasks_pub.p_task_user_hooks.task_number                := l_task_number;
3728     jtf_tasks_pub.p_task_user_hooks.task_name                  := l_task_name;
3729     jtf_tasks_pub.p_task_user_hooks.task_type_id               := l_task_type_id;
3730     jtf_tasks_pub.p_task_user_hooks.description                := l_description;
3731     jtf_tasks_pub.p_task_user_hooks.task_status_id             := l_task_status_id;
3732     jtf_tasks_pub.p_task_user_hooks.task_priority_id           := l_task_priority_id;
3733     jtf_tasks_pub.p_task_user_hooks.owner_type_code            := l_owner_type_code;
3734     jtf_tasks_pub.p_task_user_hooks.owner_id                   := l_owner_id;
3735     jtf_tasks_pub.p_task_user_hooks.owner_territory_id         := tasks.owner_territory_id;
3736     jtf_tasks_pub.p_task_user_hooks.assigned_by_id             := l_assigned_by_id;
3737     jtf_tasks_pub.p_task_user_hooks.customer_id                := l_customer_id;
3738     jtf_tasks_pub.p_task_user_hooks.cust_account_id            := l_cust_account_id;
3739     jtf_tasks_pub.p_task_user_hooks.address_id                 := l_address_id;
3740     jtf_tasks_pub.p_task_user_hooks.planned_start_date         := l_planned_start_date;
3741     jtf_tasks_pub.p_task_user_hooks.planned_end_date           := l_planned_end_date;
3742     jtf_tasks_pub.p_task_user_hooks.scheduled_start_date       := l_scheduled_start_date;
3743     jtf_tasks_pub.p_task_user_hooks.scheduled_end_date         := l_scheduled_end_date;
3744     jtf_tasks_pub.p_task_user_hooks.actual_start_date          := l_actual_start_date;
3745     jtf_tasks_pub.p_task_user_hooks.actual_end_date            := l_actual_end_date;
3746     jtf_tasks_pub.p_task_user_hooks.timezone_id                := l_timezone_id;
3747     jtf_tasks_pub.p_task_user_hooks.source_object_type_code    := tasks.source_object_type_code;
3748     jtf_tasks_pub.p_task_user_hooks.source_object_id           := l_source_object_id;
3749     jtf_tasks_pub.p_task_user_hooks.source_object_name         := l_source_object_name;
3750     jtf_tasks_pub.p_task_user_hooks.DURATION                   := l_duration;
3751     jtf_tasks_pub.p_task_user_hooks.duration_uom               := l_duration_uom;
3752     jtf_tasks_pub.p_task_user_hooks.planned_effort             := l_planned_effort;
3753     jtf_tasks_pub.p_task_user_hooks.planned_effort_uom         := l_planned_effort_uom;
3754     jtf_tasks_pub.p_task_user_hooks.actual_effort              := l_actual_effort;
3755     jtf_tasks_pub.p_task_user_hooks.actual_effort_uom          := l_actual_effort_uom;
3756     jtf_tasks_pub.p_task_user_hooks.percentage_complete        := l_percentage_complete;
3757     jtf_tasks_pub.p_task_user_hooks.reason_code                := l_reason_code;
3758     jtf_tasks_pub.p_task_user_hooks.private_flag               := l_private_flag;
3759     jtf_tasks_pub.p_task_user_hooks.publish_flag               := l_publish_flag;
3760     jtf_tasks_pub.p_task_user_hooks.restrict_closure_flag      := l_restrict_closure_flag;
3761     jtf_tasks_pub.p_task_user_hooks.multi_booked_flag          := l_multi_booked_flag;
3762     jtf_tasks_pub.p_task_user_hooks.milestone_flag             := l_milestone_flag;
3763     jtf_tasks_pub.p_task_user_hooks.holiday_flag               := l_holiday_flag;
3764     jtf_tasks_pub.p_task_user_hooks.billable_flag              := l_billable_flag;
3765     jtf_tasks_pub.p_task_user_hooks.bound_mode_code            := l_bound_mode_code;
3766     jtf_tasks_pub.p_task_user_hooks.soft_bound_flag            := l_soft_bound_flag;
3767     jtf_tasks_pub.p_task_user_hooks.workflow_process_id        := l_workflow_process_id;
3768     jtf_tasks_pub.p_task_user_hooks.notification_flag          := l_notification_flag;
3769     jtf_tasks_pub.p_task_user_hooks.notification_period        := l_notification_period;
3770     jtf_tasks_pub.p_task_user_hooks.notification_period_uom    := l_notification_period_uom;
3771     jtf_tasks_pub.p_task_user_hooks.parent_task_id             := l_parent_task_id;
3772     jtf_tasks_pub.p_task_user_hooks.alarm_start                := l_alarm_start;
3773     jtf_tasks_pub.p_task_user_hooks.alarm_start_uom            := l_alarm_start_uom;
3774     jtf_tasks_pub.p_task_user_hooks.alarm_on                   := l_alarm_on;
3775     jtf_tasks_pub.p_task_user_hooks.alarm_count                := l_alarm_count;
3776     jtf_tasks_pub.p_task_user_hooks.alarm_interval             := l_alarm_interval;
3777     jtf_tasks_pub.p_task_user_hooks.alarm_interval_uom         := l_alarm_interval_uom;
3778     jtf_tasks_pub.p_task_user_hooks.palm_flag                  := l_palm_flag;
3779     jtf_tasks_pub.p_task_user_hooks.wince_flag                 := l_wince_flag;
3780     jtf_tasks_pub.p_task_user_hooks.laptop_flag                := l_laptop_flag;
3781     jtf_tasks_pub.p_task_user_hooks.device1_flag               := l_device1_flag;
3782     jtf_tasks_pub.p_task_user_hooks.device2_flag               := l_device2_flag;
3783     jtf_tasks_pub.p_task_user_hooks.device3_flag               := l_device3_flag;
3784     jtf_tasks_pub.p_task_user_hooks.costs                      := l_costs;
3785     jtf_tasks_pub.p_task_user_hooks.currency_code              := l_currency_code;
3786     jtf_tasks_pub.p_task_user_hooks.escalation_level           := l_escalation_level;
3787     jtf_tasks_pub.p_task_user_hooks.date_selected              := l_date_selected;
3788     jtf_tasks_pub.p_task_user_hooks.attribute1                 := tasks.attribute1;
3789     jtf_tasks_pub.p_task_user_hooks.attribute2                 := tasks.attribute2;
3790     jtf_tasks_pub.p_task_user_hooks.attribute3                 := tasks.attribute3;
3791     jtf_tasks_pub.p_task_user_hooks.attribute4                 := tasks.attribute4;
3792     jtf_tasks_pub.p_task_user_hooks.attribute5                 := tasks.attribute5;
3793     jtf_tasks_pub.p_task_user_hooks.attribute6                 := tasks.attribute6;
3794     jtf_tasks_pub.p_task_user_hooks.attribute7                 := tasks.attribute7;
3795     jtf_tasks_pub.p_task_user_hooks.attribute8                 := tasks.attribute8;
3796     jtf_tasks_pub.p_task_user_hooks.attribute9                 := tasks.attribute9;
3797     jtf_tasks_pub.p_task_user_hooks.attribute10                := tasks.attribute10;
3798     jtf_tasks_pub.p_task_user_hooks.attribute11                := tasks.attribute11;
3799     jtf_tasks_pub.p_task_user_hooks.attribute12                := tasks.attribute12;
3800     jtf_tasks_pub.p_task_user_hooks.attribute13                := tasks.attribute13;
3801     jtf_tasks_pub.p_task_user_hooks.attribute14                := tasks.attribute14;
3802     jtf_tasks_pub.p_task_user_hooks.attribute15                := tasks.attribute15;
3803     jtf_tasks_pub.p_task_user_hooks.attribute_category         := tasks.attribute_category;
3804     jtf_tasks_pub.p_task_user_hooks.entity                     := l_entity;
3805     jtf_tasks_pub.p_task_user_hooks.task_confirmation_status   := l_task_confirmation_status;
3806     jtf_tasks_pub.p_task_user_hooks.task_confirmation_counter  := l_task_confirmation_counter;
3807     jtf_tasks_pub.p_task_user_hooks.task_split_flag            := l_task_split_flag;
3808     jtf_tasks_pub.p_task_user_hooks.child_position             := l_child_position;
3809     jtf_tasks_pub.p_task_user_hooks.child_sequence_num         := l_child_sequence_num;
3810     jtf_tasks_pub.p_task_user_hooks.open_flag                  := l_orig_open_flag;
3811     jtf_tasks_pub.p_task_user_hooks.location_id                := l_location_id;
3812     jtf_tasks_iuhk.update_task_pre(x_return_status);
3813 
3814     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3815       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3816       RAISE fnd_api.g_exc_unexpected_error;
3817     END IF;
3818 
3819     jtf_tasks_pub.lock_task(
3820       p_api_version                => 1.0
3821     , p_init_msg_list              => fnd_api.g_false
3822     , p_commit                     => fnd_api.g_false
3823     , p_task_id                    => l_task_id
3824     , p_object_version_number      => p_object_version_number
3825     , x_return_status              => x_return_status
3826     , x_msg_data                   => x_msg_data
3827     , x_msg_count                  => x_msg_count
3828     );
3829 
3830     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3831       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3832       RAISE fnd_api.g_exc_unexpected_error;
3833     END IF;
3834 
3835           ---------------------------------------------------------
3836           -- When a user update repeating task for all the future
3837           --   appointment, then we create a new recurrence rule.
3838           -- In this case we need to update the recurrence_rule_id
3839           --  for all the future appointment.
3840           ---------------------------------------------------------
3841     --BES changes to call the new jtf_tasks_pkg.update_row
3842     x_task_upd_rec.task_id                                     := l_task_id;
3843     x_task_upd_rec.object_version_number                       := p_object_version_number + 1;
3844     x_task_upd_rec.laptop_flag                                 := l_laptop_flag;
3845     x_task_upd_rec.device1_flag                                := l_device1_flag;
3846     x_task_upd_rec.device2_flag                                := l_device2_flag;
3847     x_task_upd_rec.device3_flag                                := l_device3_flag;
3848     x_task_upd_rec.currency_code                               := l_currency_code;
3849     x_task_upd_rec.costs                                       := l_costs;
3850     x_task_upd_rec.attribute1                                  := tasks.attribute1;
3851     x_task_upd_rec.attribute2                                  := tasks.attribute2;
3852     x_task_upd_rec.attribute3                                  := tasks.attribute3;
3853     x_task_upd_rec.attribute4                                  := tasks.attribute4;
3854     x_task_upd_rec.attribute5                                  := tasks.attribute5;
3855     x_task_upd_rec.attribute6                                  := tasks.attribute6;
3856     x_task_upd_rec.attribute7                                  := tasks.attribute7;
3857     x_task_upd_rec.attribute8                                  := tasks.attribute8;
3858     x_task_upd_rec.attribute9                                  := tasks.attribute9;
3859     x_task_upd_rec.attribute10                                 := tasks.attribute10;
3860     x_task_upd_rec.attribute11                                 := tasks.attribute11;
3861     x_task_upd_rec.attribute12                                 := tasks.attribute12;
3862     x_task_upd_rec.attribute13                                 := tasks.attribute13;
3863     x_task_upd_rec.attribute14                                 := tasks.attribute14;
3864     x_task_upd_rec.attribute15                                 := tasks.attribute15;
3865     x_task_upd_rec.attribute_category                          := tasks.attribute_category;
3866     x_task_upd_rec.task_number                                 := l_task_number;
3867     x_task_upd_rec.task_type_id                                := l_task_type_id;
3868     x_task_upd_rec.task_status_id                              := l_task_status_id;
3869     x_task_upd_rec.task_priority_id                            := l_task_priority_id;
3870     x_task_upd_rec.owner_id                                    := l_owner_id;
3871     x_task_upd_rec.owner_type_code                             := l_owner_type_code;
3872     x_task_upd_rec.owner_territory_id                          := tasks.owner_territory_id;
3873     x_task_upd_rec.assigned_by_id                              := l_assigned_by_id;
3874     x_task_upd_rec.cust_account_id                             := l_cust_account_id;
3875     x_task_upd_rec.customer_id                                 := l_customer_id;
3876     x_task_upd_rec.address_id                                  := l_address_id;
3877     x_task_upd_rec.planned_start_date                          := l_planned_start_date;
3878     x_task_upd_rec.planned_end_date                            := l_planned_end_date;
3879     x_task_upd_rec.scheduled_start_date                        := l_scheduled_start_date;
3880     x_task_upd_rec.scheduled_end_date                          := l_scheduled_end_date;
3881     x_task_upd_rec.actual_start_date                           := l_actual_start_date;
3882     x_task_upd_rec.actual_end_date                             := l_actual_end_date;
3883     x_task_upd_rec.source_object_type_code                     := tasks.source_object_type_code;
3884     x_task_upd_rec.timezone_id                                 := l_timezone_id;
3885     x_task_upd_rec.source_object_id                            := l_source_object_id;
3886     x_task_upd_rec.source_object_name                          := l_source_object_name;
3887     x_task_upd_rec.DURATION                                    := l_duration;
3888     x_task_upd_rec.duration_uom                                := l_duration_uom;
3889     x_task_upd_rec.planned_effort                              := l_planned_effort;
3890     x_task_upd_rec.planned_effort_uom                          := l_planned_effort_uom;
3891     x_task_upd_rec.actual_effort                               := l_actual_effort;
3892     x_task_upd_rec.actual_effort_uom                           := l_actual_effort_uom;
3893     x_task_upd_rec.percentage_complete                         := l_percentage_complete;
3894     x_task_upd_rec.reason_code                                 := l_reason_code;
3895     x_task_upd_rec.private_flag                                := l_private_flag;
3896     x_task_upd_rec.publish_flag                                := l_publish_flag;
3897     x_task_upd_rec.restrict_closure_flag                       := l_restrict_closure_flag;
3898     x_task_upd_rec.multi_booked_flag                           := l_multi_booked_flag;
3899     x_task_upd_rec.milestone_flag                              := l_milestone_flag;
3900     x_task_upd_rec.holiday_flag                                := l_holiday_flag;
3901     x_task_upd_rec.billable_flag                               := l_billable_flag;
3902     x_task_upd_rec.bound_mode_code                             := l_bound_mode_code;
3903     x_task_upd_rec.soft_bound_flag                             := l_soft_bound_flag;
3904     x_task_upd_rec.workflow_process_id                         := l_workflow_process_id;
3905     x_task_upd_rec.notification_flag                           := l_notification_flag;
3906     x_task_upd_rec.notification_period                         := l_notification_period;
3907     x_task_upd_rec.notification_period_uom                     := l_notification_period_uom;
3908     x_task_upd_rec.parent_task_id                              := l_parent_task_id;
3909     x_task_upd_rec.recurrence_rule_id                          := tasks.recurrence_rule_id;
3910     x_task_upd_rec.alarm_start                                 := l_alarm_start;
3911     x_task_upd_rec.alarm_start_uom                             := l_alarm_start_uom;
3912     x_task_upd_rec.alarm_on                                    := l_alarm_on;
3913     x_task_upd_rec.alarm_count                                 := l_alarm_count;
3914     x_task_upd_rec.alarm_fired_count                           := l_alarm_fired_count;
3915     x_task_upd_rec.alarm_interval                              := l_alarm_interval;
3916     x_task_upd_rec.alarm_interval_uom                          := l_alarm_interval_uom;
3917     x_task_upd_rec.deleted_flag                                := 'N';
3918     x_task_upd_rec.palm_flag                                   := l_palm_flag;
3919     x_task_upd_rec.wince_flag                                  := l_wince_flag;
3920     x_task_upd_rec.task_name                                   := l_task_name;
3921     x_task_upd_rec.description                                 := l_description;
3922     x_task_upd_rec.last_update_date                            := SYSDATE;
3923     x_task_upd_rec.last_updated_by                             := jtf_task_utl.updated_by;
3924     x_task_upd_rec.last_update_login                           := jtf_task_utl.login_id;
3925     x_task_upd_rec.escalation_level                            := l_escalation_level;
3926     x_task_upd_rec.calendar_start_date                         := l_calendar_start_date;
3927     x_task_upd_rec.calendar_end_date                           := l_calendar_end_date;
3928     x_task_upd_rec.date_selected                               := l_date_selected;
3929     x_task_upd_rec.open_flag                                   := jtf_task_utl_ext.get_open_flag(l_task_status_id);
3930     x_task_upd_rec.task_confirmation_status                    := l_task_confirmation_status;
3931     x_task_upd_rec.task_confirmation_counter                   := l_task_confirmation_counter;
3932     x_task_upd_rec.task_split_flag                             := l_task_split_flag;
3933     x_task_upd_rec.child_position                              := l_child_position;
3934     x_task_upd_rec.child_sequence_num                          := l_child_sequence_num;
3935     x_task_upd_rec.location_id                                 := l_location_id;
3936     jtf_tasks_pkg.update_row(p_task_upd_rec => x_task_upd_rec, p_task_audit_id => x_task_audit_id);
3937 
3938 
3939     ---------------
3940     ---------------  validate and get value for owner_status_id
3941     ---------------
3942     /* modified validation to default owner assignmetn status based on profile if passed value is not a valid
3943             * assignment status*/
3944     IF p_owner_status_id IS NOT NULL AND p_owner_status_id <> fnd_api.g_miss_num THEN
3945       OPEN c_owner_status_id(p_owner_status_id);
3946 
3947       FETCH c_owner_status_id
3948        INTO l_owner_status_id;
3949 
3950       IF c_owner_status_id%NOTFOUND THEN
3951         CLOSE c_owner_status_id;
3952         /*Modified  for Bug# 8574559 */
3953         l_owner_status_id  := NVL(fnd_profile.VALUE(NAME => 'JTF_TASK_DEFAULT_ASSIGNEE_STATUS'), 3);
3954       ELSE
3955         CLOSE c_owner_status_id;
3956       END IF;
3957     ELSE
3958       -- Added NVL on 08/08/2006 for bug# 5452407
3959       l_owner_status_id  := NVL(fnd_profile.VALUE(NAME => 'JTF_TASK_DEFAULT_ASSIGNEE_STATUS'), 3);
3960     END IF;
3961 
3962     -- ------------------------------------------------------------------------
3963     -- Update task assignment for Owner if changed
3964     -- ------------------------------------------------------------------------
3965     OPEN task_ass_orig(l_task_id);
3966     FETCH task_ass_orig INTO task_ass_orig_rec;
3967     IF ((task_ass_orig%NOTFOUND) OR(task_ass_orig_rec.assignee_role <> 'OWNER')) THEN
3968       CLOSE task_ass_orig;   -- Fix a missing CLOSE on 4/18/2002
3969 
3970       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_OWNER_ASG');
3971       fnd_msg_pub.ADD;
3972       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3973       RAISE fnd_api.g_exc_unexpected_error;
3974     END IF;
3975 
3976     -- CLOSE task_ass_orig; -- Fix a missing CLOSE on 4/18/2002   -- Commented out on 19/06/2006 for bug# 5210853
3977     IF    (
3978                NVL(p_owner_id, 0) <> fnd_api.g_miss_num
3979            AND NVL(p_owner_id, 0) <> task_ass_orig_rec.resource_id
3980           )
3981        OR (
3982                NVL(p_category_id, 0) <> jtf_task_utl.g_miss_number
3983            AND NVL(p_category_id, 0) <> NVL(task_ass_orig_rec.category_id, 0)
3984           )
3985        OR (
3986                NVL(l_show_on_calendar, 'X') <> fnd_api.g_miss_char
3987            AND NVL(l_show_on_calendar, 'X') <> NVL(task_ass_orig_rec.show_on_calendar, 'X')
3988           )
3989        OR (
3990                NVL(x_task_upd_rec.open_flag, 'X') <> fnd_api.g_miss_char
3991            AND NVL(x_task_upd_rec.open_flag, 'X') <> NVL(l_orig_open_flag, 'X')
3992           )
3993        OR (
3994                NVL(l_free_busy_type, 'X') <> jtf_task_utl.g_miss_char
3995            AND NVL(l_free_busy_type, 'X') <> NVL(task_ass_orig_rec.free_busy_type, 'X')
3996           )
3997        OR
3998            -- Commented out this part of the code since it's no more required after fixing bug# 5210853
3999           /* --Added by SBARAT on 26/04/2005 for Bug# 4122322
4000           (nvl(p_scheduled_start_date, sysdate) <> fnd_api.g_miss_date and
4001            nvl(p_scheduled_start_date, sysdate) <> nvl(task_ass_orig_rec.booking_start_date, sysdate)) or
4002           (nvl(p_scheduled_end_date, sysdate) <> fnd_api.g_miss_date and
4003            nvl(p_scheduled_end_date, sysdate) <> nvl(task_ass_orig_rec.booking_end_date, sysdate)) or
4004            --End of addition by SBARAT on 26/04/2005 for Bug# 4122322 */
4005 
4006           -- Start of addition on 19/06/2006 for bug# 5210853
4007           (
4008                (
4009                    (NVL(l_calendar_start_date, SYSDATE) <> NVL(tasks.calendar_start_date, SYSDATE))
4010                 OR (NVL(l_calendar_end_date, SYSDATE) <> NVL(tasks.calendar_end_date, SYSDATE))
4011                )
4012            AND (
4013                    (task_ass_orig_rec.actual_start_date IS NULL)
4014                 OR (task_ass_orig_rec.actual_end_date IS NULL)
4015                )
4016           )
4017        OR (NVL(l_actual_start_date, SYSDATE) <> NVL(task_ass_orig_rec.actual_start_date, SYSDATE))
4018        OR (NVL(l_actual_end_date, SYSDATE) <> NVL(task_ass_orig_rec.actual_end_date, SYSDATE))
4019        OR
4020           -- End of addition on 19/06/2006 for bug# 5210853
4021           (
4022                NVL(l_owner_status_id, 0) <> fnd_api.g_miss_num
4023            AND NVL(l_owner_status_id, 0) <> NVL(task_ass_orig_rec.assignment_status_id, 0)
4024           ) THEN
4025       OPEN task_ass_u(l_task_id);
4026 
4027       FETCH task_ass_u
4028        INTO task_ass_rec;
4029 
4030       IF task_ass_u%NOTFOUND THEN
4031         CLOSE task_ass_orig;
4032 
4033         CLOSE task_ass_u;   -- Fix a missing CLOSE on 4/18/2002
4034 
4035         fnd_message.set_name('JTF', 'JTF_TASK_MISSING_OWNER_ASG');
4036         fnd_msg_pub.ADD;
4037         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4038         RAISE fnd_api.g_exc_unexpected_error;
4039       END IF;
4040 
4041       CLOSE task_ass_u;   -- Fix a missing CLOSE on 4/18/2002
4042 
4043       jtf_task_assignments_pvt.g_response_flag  := jtf_task_utl.g_yes_char;   -- Fix bug# 2375153
4044       jtf_task_assignments_pvt.update_task_assignment(
4045         p_api_version                => p_api_version
4046       , p_object_version_number      => task_ass_rec.object_version_number
4047       , p_init_msg_list              => fnd_api.g_false
4048       , p_commit                     => fnd_api.g_false
4049       , p_task_assignment_id         => task_ass_rec.task_assignment_id
4050       , p_actual_start_date          => l_actual_start_date
4051       , p_actual_end_date            => l_actual_end_date
4052       , p_palm_flag                  => l_palm_flag
4053       , p_wince_flag                 => l_wince_flag
4054       , p_laptop_flag                => l_laptop_flag
4055       , p_device1_flag               => l_device1_flag
4056       , p_device2_flag               => l_device2_flag
4057       , p_device3_flag               => l_device3_flag
4058       , p_resource_id                => task_ass_rec.resource_id
4059       , p_actual_effort              => l_actual_effort
4060       , p_actual_effort_uom          => l_actual_effort_uom
4061       , p_resource_type_code         => task_ass_rec.resource_type_code
4062       , p_resource_territory_id      => task_ass_rec.resource_territory_id
4063       , p_assignment_status_id       => task_ass_rec.assignment_status_id
4064       , x_msg_data                   => x_msg_data
4065       , x_msg_count                  => x_msg_count
4066       , x_return_status              => x_return_status
4067       , p_assignee_role              => 'OWNER'
4068       , p_show_on_calendar           => task_ass_rec.show_on_calendar
4069       , p_category_id                => task_ass_rec.category_id
4070       , p_enable_workflow            => l_enable_workflow
4071       , p_abort_workflow             => l_abort_workflow
4072       , p_free_busy_type             => task_ass_rec.free_busy_type
4073       );
4074       /*************************************************************************
4075         -- Bug 2467222  for assignee category update
4076         OPEN  jtf_task_utl.c_assignee_or_owner (l_task_id,p_category_id);
4077         FETCH jtf_task_utl.c_assignee_or_owner INTO l_assignee_rec;
4078         CLOSE jtf_task_utl.c_assignee_or_owner;
4079 
4080       jtf_task_utl.update_task_category(
4081             p_api_version => p_api_version,
4082             p_object_version_number => l_assignee_rec.object_version_number,
4083             p_task_assignment_id   => l_assignee_rec.task_assignment_id,
4084       p_category_id => p_category_id,
4085             x_msg_data => x_msg_data,
4086       x_msg_count => x_msg_count,
4087       x_return_status => x_return_status);
4088       ***************************************************************************/
4089       jtf_task_assignments_pvt.g_response_flag  := jtf_task_utl.g_no_char;   -- Fix bug# 2375153
4090 
4091       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4092         CLOSE task_ass_orig;
4093 
4094         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4095         RAISE fnd_api.g_exc_unexpected_error;
4096       END IF;
4097     END IF;
4098 
4099     -- Start of addition on 19/06/2006 for bug# 5210853
4100     LOOP
4101       task_ass_orig_rec  := NULL;
4102 
4103       FETCH task_ass_orig INTO task_ass_orig_rec;
4104 
4105       IF task_ass_orig%NOTFOUND THEN
4106         CLOSE task_ass_orig;
4107         EXIT;
4108       END IF;
4109 
4110       IF (
4111               (task_ass_orig_rec.assignee_role = 'ASSIGNEE')
4112           AND (
4113                   (NVL(l_calendar_start_date, SYSDATE) <> NVL(tasks.calendar_start_date, SYSDATE))
4114                OR (NVL(l_calendar_end_date, SYSDATE) <> NVL(tasks.calendar_end_date, SYSDATE))
4115               )
4116           AND (
4117                   (task_ass_orig_rec.actual_start_date IS NULL)
4118                OR (task_ass_orig_rec.actual_end_date IS NULL)
4119               )
4120          ) THEN
4121         -- Added for Bug 6031383 . Directly updating the assignment to avoid
4122         -- object version number change of the assignment.
4123         jtf_task_assignments_pvt.populate_booking_dates
4124                      (
4125           p_calendar_start_date        => l_calendar_start_date
4126         , p_calendar_end_date          => l_calendar_end_date
4127         , p_actual_start_date          => task_ass_orig_rec.actual_start_date
4128         , p_actual_end_date            => task_ass_orig_rec.actual_end_date
4129         , p_actual_travel_duration     => task_ass_orig_rec.actual_travel_duration
4130         , p_actual_travel_duration_uom => task_ass_orig_rec.actual_travel_duration_uom
4131         , p_planned_effort             => l_planned_effort
4132         , p_planned_effort_uom         => l_planned_effort_uom
4133         , p_actual_effort              => task_ass_orig_rec.actual_effort
4134         , p_actual_effort_uom          => task_ass_orig_rec.actual_effort_uom
4135         , x_booking_start_date         => l_booking_start_date
4136         , x_booking_end_date           => l_booking_end_date
4137         );
4138 
4139         UPDATE jtf_task_all_assignments
4140            SET booking_start_date = l_booking_start_date
4141              , booking_end_date = l_booking_end_date
4142          WHERE task_assignment_id = task_ass_orig_rec.task_assignment_id;
4143 
4144          /* Added check to halt creation of double booking appointments while updating appointments*/
4145          if  tasks.source_object_type_code = 'APPOINTMENT'  and task_ass_orig_rec.resource_type_code = 'PN_LOCATION' then
4146 
4147            cac_avlblty_pub.IS_AVAILABLE(
4148                 p_api_version => 1.0,
4149                 p_init_msg_list => 'F',
4150                 p_Object_Type => task_ass_orig_rec.resource_type_code,
4151                 p_Object_ID => task_ass_orig_rec.resource_id,
4152                 p_Start_Date_Time => l_booking_start_date,
4153                 p_End_Date_Time => l_booking_end_date,
4154                 p_Schedule_Category => null ,
4155                 p_Busy_Tentative => null,
4156                 p_task_assignment_id => task_ass_orig_rec.task_assignment_id,
4157                 x_Available => l_availability,
4158                 x_return_status => x_return_status,
4159                 x_msg_count => x_msg_count,
4160                 x_msg_data => x_msg_data);
4161 
4162                 if l_availability = 'F' then
4163 
4164                   l_name := null;
4165                   l_name := JTF_TASK_UTL.get_owner(task_ass_orig_rec.resource_type_code, task_ass_orig_rec.resource_id);
4166                   l_date :=  l_booking_start_date;
4167                   IF(fnd_profile.Value('ENABLE_TIMEZONE_CONVERSIONS') = 'Y') THEN
4168                      l_date := To_Char(CAC_AVLBLTY_PVT.ADJUST_FOR_TIMEZONE(fnd_profile.value('SERVER_TIMEZONE_ID'),
4169                                                                       fnd_profile.value('CLIENT_TIMEZONE_ID'),
4170                                                                       l_booking_start_date),
4171                                                        fnd_profile.Value('ICX_DATE_FORMAT_MASK')||' HH:MI:SS AM');
4172                   END IF;
4173 
4174                   fnd_message.set_name ('JTF', 'JTF_APPT_RES_NOT_AVAILABLE');
4175                   fnd_message.set_token ('RES', l_name );
4176                   fnd_message.set_token ('DATE', l_date);
4177 
4178                   fnd_msg_pub.add;
4179                   x_return_status := fnd_api.g_ret_sts_unexp_error;
4180 
4181                   RAISE fnd_api.g_exc_unexpected_error;
4182 
4183                   end if;
4184          end if;
4185 
4186 
4187       END IF;
4188     END LOOP;
4189 
4190     -- End of addition on 19/06/2006 for bug# 5210853
4191 
4192     -- 2102281
4193     --------------------------------------------------------------
4194       -- ------------------------------------------------------------------------
4195       -- Update reference to source if changed, fix enh # 2102281
4196       -- ------------------------------------------------------------------------
4197     jtf_task_utl_ext.update_object_code(
4198       p_task_id                    => l_task_id
4199     , p_old_object_code            => l_orig_source_object_type_code
4200     , p_new_object_code            => tasks.source_object_type_code
4201     , p_old_object_id              => l_orig_source_id
4202     , p_new_object_id              => l_source_object_id
4203     , p_new_object_name            => l_source_object_name
4204     , x_return_status              => x_return_status
4205     , x_msg_count                  => x_msg_count
4206     , x_msg_data                   => x_msg_data
4207     );
4208 
4209     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4210       RAISE fnd_api.g_exc_unexpected_error;
4211     END IF;
4212 
4213     --------------------------------------------------------------
4214 
4215     -- ------------------------------------------------------------------------
4216     -- Update reference to customer if changed, fix enh #1845501
4217     -- ------------------------------------------------------------------------
4218     IF (
4219         NVL(l_customer_id, 0) <> fnd_api.g_miss_num
4220         AND NVL(l_customer_id, 0) <> NVL(l_orig_cust_id, 0)
4221        ) THEN
4222       -- Added for Bug# 2593974
4223       -------------------------------------------------
4224       ------ delete contacts and related contact points
4225       -------------------------------------------------
4226       FOR c IN c_del_contacts(l_task_id) LOOP
4227         jtf_task_contacts_pub.delete_task_contacts
4228                                                (
4229           p_api_version                => 1.0
4230         , p_init_msg_list              => fnd_api.g_false
4231         , p_commit                     => fnd_api.g_false
4232         , p_object_version_number      => c.object_version_number
4233         , p_task_contact_id            => c.task_contact_id
4234         , x_return_status              => x_return_status
4235         , x_msg_data                   => x_msg_data
4236         , x_msg_count                  => x_msg_count
4237         , p_delete_cascade             => jtf_task_utl.g_yes_char
4238         );
4239 
4240         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4241           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4242           RAISE fnd_api.g_exc_unexpected_error;
4243         END IF;
4244       END LOOP;
4245 
4246       -- End Add
4247 
4248       -- delete the old one
4249       jtf_task_utl.delete_party_reference(
4250         p_reference_from             => 'TASK'
4251       , p_task_id                    => l_task_id
4252       , p_party_id                   => l_orig_cust_id
4253       , x_msg_count                  => x_msg_count
4254       , x_msg_data                   => x_msg_data
4255       , x_return_status              => x_return_status
4256       );
4257 
4258       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4259         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4260         RAISE fnd_api.g_exc_unexpected_error;
4261       END IF;
4262 
4263       -- create a new one
4264       jtf_task_utl.create_party_reference(
4265         p_reference_from             => 'TASK'
4266       , p_task_id                    => l_task_id
4267       , p_party_id                   => l_customer_id
4268       , x_msg_count                  => x_msg_count
4269       , x_msg_data                   => x_msg_data
4270       , x_return_status              => x_return_status
4271       );
4272 
4273       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4274         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4275         RAISE fnd_api.g_exc_unexpected_error;
4276       END IF;
4277     END IF;
4278 
4279     jtf_tasks_iuhk.update_task_post(x_return_status);
4280 
4281     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4282       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4283       RAISE fnd_api.g_exc_unexpected_error;
4284     END IF;
4285 
4286     IF fnd_api.to_boolean(p_commit) THEN
4287       COMMIT WORK;
4288     END IF;
4289 
4290     -- Increment the object version number to be returned
4291     p_object_version_number                                    := p_object_version_number + 1;
4292     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4293 
4294     --BES enh 2391065
4295     IF (l_entity = 'TASK') THEN
4296       l_task_rec_type_old.source_object_type_code  := l_orig_source_object_type_code;
4297       l_task_rec_type_old.source_object_id         := l_orig_source_id;
4298       l_task_rec_type_new.task_id                  := l_task_id;
4299       l_task_rec_type_new.task_audit_id            := x_task_audit_id;
4300       l_task_rec_type_new.source_object_type_code  := tasks.source_object_type_code;
4301       l_task_rec_type_new.source_object_id         := l_source_object_id;
4302       l_task_rec_type_new.enable_workflow          := l_enable_workflow;
4303       l_task_rec_type_new.abort_workflow           := l_abort_workflow;
4304       jtf_task_wf_events_pvt.publish_update_task(
4305         p_task_rec_old               => l_task_rec_type_old
4306       , p_task_rec_new               => l_task_rec_type_new
4307       , x_return_status              => x_event_return_status
4308       );
4309 
4310       IF (x_event_return_status = 'WARNING') THEN
4311         fnd_message.set_name('JTF', 'JTF_TASK_EVENT_WARNING');
4312         fnd_message.set_token('P_TASK_ID', l_task_id);
4313         fnd_msg_pub.ADD;
4314       ELSIF(x_event_return_status = 'ERROR') THEN
4315         fnd_message.set_name('JTF', 'JTF_TASK_EVENT_ERROR');
4316         fnd_message.set_token('P_TASK_ID', l_task_id);
4317         fnd_msg_pub.ADD;
4318         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4319         RAISE fnd_api.g_exc_unexpected_error;
4320       END IF;
4321     END IF;
4322   --BES enh 2391065
4323   EXCEPTION
4324     WHEN fnd_api.g_exc_unexpected_error THEN
4325       ROLLBACK TO update_task_pvt;
4326       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4327       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4328     WHEN OTHERS THEN
4329       ROLLBACK TO update_task_pvt;
4330       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
4331       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
4332       fnd_msg_pub.ADD;
4333       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4334       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4335   END;   ---- End of private Update Task
4336 
4337   -- Old version
4338   PROCEDURE delete_task(
4339     p_api_version               IN            NUMBER
4340   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
4341   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
4342   , p_object_version_number     IN            NUMBER
4343   , p_task_id                   IN            NUMBER
4344   , p_delete_future_recurrences IN            VARCHAR2 DEFAULT fnd_api.g_false
4345   , x_return_status             OUT NOCOPY    VARCHAR2
4346   , x_msg_count                 OUT NOCOPY    NUMBER
4347   , x_msg_data                  OUT NOCOPY    VARCHAR2
4348   ) IS
4349   BEGIN
4350     SAVEPOINT delete_task_pvt2;
4351     x_return_status  := fnd_api.g_ret_sts_success;
4352 
4353     -- Added by lokumar for bug#6598081
4354     IF fnd_api.to_boolean(p_init_msg_list) THEN
4355       fnd_msg_pub.initialize;
4356     END IF;
4357 
4358     -- Call the new version
4359     delete_task(
4360       p_api_version                => p_api_version
4361     , p_init_msg_list              => p_init_msg_list
4362     , p_commit                     => p_commit
4363     , p_object_version_number      => p_object_version_number
4364     , p_task_id                    => p_task_id
4365     , p_delete_future_recurrences  => p_delete_future_recurrences
4366     , x_return_status              => x_return_status
4367     , x_msg_count                  => x_msg_count
4368     , x_msg_data                   => x_msg_data
4369     , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
4370     , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
4371     );
4372 
4373     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4374       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4375       RAISE fnd_api.g_exc_unexpected_error;
4376     END IF;
4377 
4378     IF fnd_api.to_boolean(p_commit) THEN
4379       COMMIT WORK;
4380     END IF;
4381 
4382     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4383   EXCEPTION
4384     WHEN fnd_api.g_exc_unexpected_error THEN
4385       ROLLBACK TO delete_task_pvt2;
4386       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4387       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4388     WHEN OTHERS THEN
4389       ROLLBACK TO delete_task_pvt2;
4390       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
4391       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
4392       fnd_msg_pub.ADD;
4393       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4394       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4395   END;
4396 
4397   -- New version
4398   PROCEDURE delete_task(
4399     p_api_version               IN            NUMBER
4400   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
4401   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
4402   , p_object_version_number     IN            NUMBER
4403   , p_task_id                   IN            NUMBER
4404   , p_delete_future_recurrences IN            VARCHAR2 DEFAULT fnd_api.g_false
4405   , x_return_status             OUT NOCOPY    VARCHAR2
4406   , x_msg_count                 OUT NOCOPY    NUMBER
4407   , x_msg_data                  OUT NOCOPY    VARCHAR2
4408   , p_enable_workflow           IN            VARCHAR2
4409   , p_abort_workflow            IN            VARCHAR2
4410   ) IS
4411     l_task_id                      jtf_tasks_b.task_id%TYPE                       := p_task_id;
4412     l_recur_rule                   jtf_task_recur_rules.recurrence_rule_id%TYPE;
4413     l_date_selected                jtf_task_recur_rules.date_selected%TYPE;
4414     l_planned_date                 jtf_tasks_b.planned_start_date%TYPE;
4415     l_scheduled_date               jtf_tasks_b.scheduled_start_date%TYPE;
4416     l_actual_date                  jtf_tasks_b.actual_start_date%TYPE;
4417     l_obj_version                  jtf_tasks_b.object_version_number%TYPE;
4418     l_source_object_type_code      jtf_tasks_b.source_object_type_code%TYPE;
4419     l_source_object_id             jtf_tasks_b.source_object_id%TYPE;
4420     l_calendar_start_date          DATE;
4421     l_task_exclusion_id            NUMBER;
4422     l_parent_child_count           NUMBER;
4423 
4424     -- ------------------------------------------------------------------------
4425     -- Retrieve recurrence rule id for the selected task, plus the start dates
4426     -- for that task, to fix bug #1975337
4427     -- ------------------------------------------------------------------------
4428     CURSOR c_recur_rule(b_task_id jtf_tasks_b.task_id%TYPE) IS
4429       SELECT recurrence_rule_id
4430            , planned_start_date
4431            , scheduled_start_date
4432            , actual_start_date
4433         FROM jtf_tasks_b
4434        WHERE task_id = b_task_id;
4435 
4436     -- ------------------------------------------------------------------------
4437     -- Retrieve date used in recurrence rule
4438     -- ------------------------------------------------------------------------
4439     CURSOR c_recur_date(b_rule_id jtf_tasks_b.recurrence_rule_id%TYPE) IS
4440       SELECT date_selected
4441         FROM jtf_task_recur_rules
4442        WHERE recurrence_rule_id = b_rule_id;
4443 
4444     -- ------------------------------------------------------------------------
4445     -- Capture all future recurrences if p_delete_future_recurrences is TRUE,
4446     -- or all past and future recurrences if p_delete_future_recurrences is 'A'
4447     -- ------------------------------------------------------------------------
4448     CURSOR c_delete_task(b_date_selected jtf_task_recur_rules.date_selected%TYPE) IS
4449       SELECT task_id
4450            , object_version_number
4451            , source_object_type_code
4452            ,   -- Added for XP Sync Story #58
4453              calendar_start_date   -- Added for XP Sync Story #58
4454         FROM jtf_tasks_b
4455        WHERE task_id = p_task_id
4456       UNION ALL
4457       SELECT task_id
4458            , object_version_number
4459            , source_object_type_code
4460            ,   -- Added for XP Sync Story #58
4461              calendar_start_date   -- Added for XP Sync Story #58
4462         FROM jtf_tasks_b
4463        WHERE recurrence_rule_id = l_recur_rule
4464          AND (
4465                  (
4466                       p_delete_future_recurrences = fnd_api.g_true
4467                   AND (
4468 
4469                           ---------------------------
4470                           ---- 'P' use planned date
4471                           ---- null (existing data)
4472                           ---- also use planned date
4473                           ---------------------------
4474                           (NVL(b_date_selected, 'P') = 'P' AND planned_start_date >= l_planned_date)
4475                        OR
4476                           ---------------------------
4477                           ---- 'S' use scheduled date
4478                           ---------------------------
4479                           (b_date_selected = 'S' AND scheduled_start_date >= l_scheduled_date)
4480                        OR
4481                           ---------------------------
4482                           ---- 'A' use actual date
4483                           ---------------------------
4484                           (b_date_selected = 'A' AND actual_start_date >= l_actual_date)
4485                       )
4486                  )
4487               OR p_delete_future_recurrences = 'A'
4488              )
4489          AND NVL(deleted_flag, 'N') = 'N'
4490          AND task_id <> p_task_id;
4491 
4492     CURSOR c_dependencies IS
4493       SELECT dependency_id
4494            , object_version_number
4495         FROM jtf_task_depends
4496        WHERE task_id = l_task_id OR dependent_on_task_id = l_task_id;
4497 
4498     CURSOR c_references IS
4499       SELECT task_reference_id
4500            , object_version_number
4501         FROM jtf_task_references_vl
4502        WHERE task_id = l_task_id;
4503 
4504     CURSOR c_dates IS
4505       SELECT task_date_id
4506            , object_version_number
4507         FROM jtf_task_dates
4508        WHERE task_id = l_task_id;
4509 
4510     CURSOR c_rsc_reqs IS
4511       SELECT resource_req_id
4512            , object_version_number
4513         FROM jtf_task_rsc_reqs
4514        WHERE task_id = l_task_id;
4515 
4516     CURSOR c_assignments IS
4517       SELECT task_assignment_id
4518            , object_version_number
4519         FROM jtf_task_all_assignments
4520        WHERE task_id = l_task_id;
4521 
4522     -- Added to fix Bug # 2503657
4523     CURSOR c_contacts IS
4524       SELECT task_contact_id
4525            , object_version_number
4526         FROM jtf_task_contacts
4527        WHERE task_id = l_task_id;
4528 
4529     -- Added to fix Bug # 2585935
4530     CURSOR c_contact_points IS
4531       SELECT a.object_version_number
4532            , a.task_phone_id
4533         FROM jtf_task_phones a, jtf_tasks_b c
4534        WHERE a.owner_table_name = 'JTF_TASKS_B'
4535          AND a.task_contact_id = c.task_id
4536          AND c.task_id = l_task_id;
4537 
4538     --BES enh 2391065
4539     l_task_rec_type                jtf_tasks_pvt.task_rec_type;
4540     x_event_return_status          VARCHAR2(100);
4541 
4542     CURSOR task_source_orig(b_task_id IN NUMBER) IS
4543       SELECT source_object_id
4544            , source_object_type_code
4545            , entity
4546         FROM jtf_tasks_b
4547        WHERE task_id = b_task_id;
4548 
4549     CURSOR c_parent_child(b_date_selected jtf_task_recur_rules.date_selected%TYPE) IS
4550       SELECT count(*) FROM
4551       (SELECT task_number
4552           from jtf_tasks_b
4553         where parent_task_id = p_task_id
4554         AND NVL(deleted_flag, 'N') = 'N'
4555       UNION ALL
4556       SELECT task_number
4557         FROM jtf_tasks_b
4558        WHERE recurrence_rule_id = l_recur_rule
4559          AND (
4560                  (
4561                       p_delete_future_recurrences = fnd_api.g_true
4562                   AND (
4563 
4564                           ---------------------------
4565                           ---- 'P' use planned date
4566                           ---- null (existing data)
4567                           ---- also use planned date
4568                           ---------------------------
4569                           (NVL(b_date_selected, 'P') = 'P' AND planned_start_date >= l_planned_date)
4570                        OR
4571                           ---------------------------
4572                           ---- 'S' use scheduled date
4573                           ---------------------------
4574                           (b_date_selected = 'S' AND scheduled_start_date >= l_scheduled_date)
4575                        OR
4576                           ---------------------------
4577                           ---- 'A' use actual date
4578                           ---------------------------
4579                           (b_date_selected = 'A' AND actual_start_date >= l_actual_date)
4580                       )
4581                  )
4582               OR p_delete_future_recurrences = 'A'
4583              )
4584          AND NVL(deleted_flag, 'N') = 'N'
4585          AND task_id <> p_task_id
4586 	 AND exists ( select *
4587                        from jtf_tasks_b
4588                       where parent_task_id = task_id ) );
4589 
4590     l_orig_source_object_id        jtf_tasks_b.source_object_id%TYPE;
4591     l_orig_source_object_type_code jtf_tasks_b.source_object_type_code%TYPE;
4592     l_entity                       jtf_tasks_b.entity%TYPE;
4593   BEGIN
4594     SAVEPOINT delete_task_pvt;
4595     x_return_status                          := fnd_api.g_ret_sts_success;
4596 
4597     -- Added by lokumar for bug#6598081
4598     IF fnd_api.to_boolean(p_init_msg_list) THEN
4599       fnd_msg_pub.initialize;
4600     END IF;
4601 
4602    -- ------------------------------------------------------------------------
4603     -- Check that the user has the correct security privilege
4604     -- ------------------------------------------------------------------------
4605     jtf_task_utl.check_security_privilege(p_task_id => p_task_id, p_session => 'DELETE'
4606     , x_return_status              => x_return_status);
4607 
4608     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4609       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4610       RAISE fnd_api.g_exc_unexpected_error;
4611     END IF;
4612 
4613 
4614         -------------------------------------------------------------------
4615         ---------------------- Workflow Enhancement -----------------------
4616         -------------------------------------------------------------------
4617         -- !!! moved this code to before all the deletes so the data is !!!
4618         -- !!! complete when the WF is sent       !!!
4619         -------------------------------------------------------------------
4620     /* Moved the code to subscription ER# 2797666
4621         IF p_enable_workflow = jtf_task_utl.g_yes
4622         THEN
4623       IF JTF_Task_WF_Util.Do_Notification(l_task_id)
4624       THEN
4625       JTF_Task_WF_Util.Create_Notification(
4626           p_event  => 'DELETE_TASK',
4627           p_task_id      => l_task_id,
4628           p_abort_workflow => p_abort_workflow,
4629           x_return_status  => x_return_status,
4630           x_msg_count      => x_msg_count,
4631           x_msg_data       => x_msg_data
4632       );
4633 
4634       IF NOT (x_return_status = fnd_api.g_ret_sts_success)
4635       THEN
4636          x_return_status := fnd_api.g_ret_sts_unexp_error;
4637          RAISE fnd_api.g_exc_unexpected_error;
4638       END IF;
4639       END IF; -- Check JTF_Task_WF_Util.Do_Notification
4640         END IF; -- Check p_enable_workflow
4641     */
4642         -------------------------------------------------------------------
4643 
4644     ---------------------------
4645     ---- get recurrence rule id
4646     ---------------------------
4647     OPEN c_recur_rule(p_task_id);
4648 
4649     FETCH c_recur_rule
4650      INTO l_recur_rule
4651         , l_planned_date
4652         , l_scheduled_date
4653         , l_actual_date;
4654 
4655     CLOSE c_recur_rule;
4656 
4657     ---------------------------
4658     ---- get date_selected from
4659     ---- the recurrence rule
4660     ---------------------------
4661     IF l_recur_rule IS NOT NULL THEN
4662       OPEN c_recur_date(l_recur_rule);
4663 
4664       FETCH c_recur_date
4665        INTO l_date_selected;
4666 
4667       IF c_recur_date%NOTFOUND THEN
4668         CLOSE c_recur_date;
4669 
4670         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4671         RAISE fnd_api.g_exc_unexpected_error;
4672       END IF;
4673 
4674       CLOSE c_recur_date;
4675     END IF;
4676 
4677     OPEN c_parent_child(l_date_selected);
4678     FETCH c_parent_child into l_parent_child_count;
4679 
4680     IF l_parent_child_count>0 THEN
4681        fnd_message.set_name('JTF', 'JTF_TASK_DELETING_PARENT_CHILD');
4682        fnd_msg_pub.ADD;
4683        x_return_status  := fnd_api.g_ret_sts_unexp_error;
4684        RAISE fnd_api.g_exc_unexpected_error;
4685     END IF;
4686 
4687 
4688 
4689 
4690     jtf_tasks_pub.p_task_user_hooks.task_id  := p_task_id;
4691     jtf_tasks_iuhk.delete_task_pre(x_return_status);
4692 
4693     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4694       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4695       RAISE fnd_api.g_exc_unexpected_error;
4696     END IF;
4697 
4698 
4699     FOR i IN c_delete_task(l_date_selected) LOOP
4700       l_task_id                  := i.task_id;
4701       l_obj_version              := i.object_version_number;
4702       l_source_object_type_code  := i.source_object_type_code;   -- For XP Sync, Story #58
4703       l_calendar_start_date      := i.calendar_start_date;   -- For XP Sync, Story #58
4704 
4705       ---------------------------
4706       ---- delete dependencies
4707       ---------------------------
4708       FOR a IN c_dependencies LOOP
4709         jtf_task_dependency_pub.delete_task_dependency
4710                                                (
4711           p_api_version                => 1.0
4712         , p_init_msg_list              => fnd_api.g_false
4713         , p_commit                     => fnd_api.g_false
4714         , p_object_version_number      => a.object_version_number
4715         , p_dependency_id              => a.dependency_id
4716         , x_return_status              => x_return_status
4717         , x_msg_count                  => x_msg_count
4718         , x_msg_data                   => x_msg_data
4719         );
4720 
4721         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4722           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4723           RAISE fnd_api.g_exc_unexpected_error;
4724         END IF;
4725       END LOOP;
4726 
4727       ---------------------------
4728       ---- delete references. Changed the call from public to private as this
4729       ---- removes the additional overhead of calling private api through public.
4730       ---------------------------
4731       FOR b IN c_references LOOP
4732         jtf_task_references_pvt.delete_references
4733                                                (
4734           p_api_version                => 1.0
4735         , p_init_msg_list              => fnd_api.g_false
4736         , p_commit                     => fnd_api.g_false
4737         , p_object_version_number      => b.object_version_number
4738         , p_task_reference_id          => b.task_reference_id
4739         , x_return_status              => x_return_status
4740         , x_msg_count                  => x_msg_count
4741         , x_msg_data                   => x_msg_data
4742         , p_from_task_api              => 'Y'
4743         );
4744 
4745         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4746           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4747           RAISE fnd_api.g_exc_unexpected_error;
4748         END IF;
4749       END LOOP;
4750 
4751       ---------------------------
4752       ---- delete dates
4753       ---------------------------
4754       FOR c IN c_dates LOOP
4755         jtf_task_dates_pub.delete_task_dates(
4756           p_api_version                => 1.0
4757         , p_init_msg_list              => fnd_api.g_false
4758         , p_commit                     => fnd_api.g_false
4759         , p_object_version_number      => c.object_version_number
4760         , p_task_date_id               => c.task_date_id
4761         , x_return_status              => x_return_status
4762         , x_msg_count                  => x_msg_count
4763         , x_msg_data                   => x_msg_data
4764         );
4765 
4766         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4767           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4768           RAISE fnd_api.g_exc_unexpected_error;
4769         END IF;
4770       END LOOP;
4771 
4772       ---------------------------
4773       ---- delete resource reqs.
4774       ---------------------------
4775       FOR c IN c_rsc_reqs LOOP
4776         jtf_task_resources_pub.delete_task_rsrc_req
4777                                                (
4778           p_api_version                => 1.0
4779         , p_init_msg_list              => fnd_api.g_false
4780         , p_commit                     => fnd_api.g_false
4781         , p_object_version_number      => c.object_version_number
4782         , p_resource_req_id            => c.resource_req_id
4783         , x_return_status              => x_return_status
4784         , x_msg_count                  => x_msg_count
4785         , x_msg_data                   => x_msg_data
4786         );
4787 
4788         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4789           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4790           RAISE fnd_api.g_exc_unexpected_error;
4791         END IF;
4792       END LOOP;
4793 
4794       ---------------------------------------------------------------
4795       -- For XP Sync Story #58
4796       --    When a user updates one of occurrences in Outlook/Palm,
4797       --   This deletes it and insert it into JTA_TASK_EXCLUSIONS
4798       --    When a user deletes one of occurrences in Server,
4799       --   This deletes it and insert it into JTA_TASK_EXCLUSIONS
4800       --    We support this only for Appointment
4801       --        and p_delete_future_recurrences <> 'A'
4802       --    If the deleted task is the first task of the series,
4803       --  then update task_id with the next min of task_id
4804       --   into mapping table
4805       -- Added 'EXTERNAL APPOINTMENT' to fix bug# 5255363 on 09/06/2006
4806       ---------------------------------------------------------------
4807       IF (
4808               (NVL(p_delete_future_recurrences, fnd_api.g_false) <> 'A')
4809           AND (l_recur_rule IS NOT NULL)
4810           AND (l_source_object_type_code IN('APPOINTMENT', 'EXTERNAL APPOINTMENT'))
4811          ) THEN
4812         SELECT jta_task_exclusions_s.NEXTVAL
4813           INTO l_task_exclusion_id
4814           FROM DUAL;
4815 
4816         jta_task_exclusions_pkg.insert_row(
4817           p_task_exclusion_id          => l_task_exclusion_id
4818         , p_task_id                    => l_task_id
4819         , p_recurrence_rule_id         => l_recur_rule
4820         , p_exclusion_date             => l_calendar_start_date
4821         );
4822 
4823         -- Modify task_id in the sync mapping table
4824         IF p_task_id = l_task_id THEN
4825           jta_sync_task_utl.update_mapping(p_task_id => p_task_id);
4826         END IF;
4827       END IF;
4828 
4829       ---------------------------------------------------------------
4830 
4831       ---------------------------
4832       ---- delete assignments
4833       ---------------------------
4834       FOR c IN c_assignments LOOP
4835         jtf_task_assignments_pvt.delete_task_assignment
4836                                (
4837           p_api_version                => 1.0
4838         , p_init_msg_list              => fnd_api.g_false
4839         , p_commit                     => fnd_api.g_false
4840         , p_object_version_number      => c.object_version_number
4841         , p_task_assignment_id         => c.task_assignment_id
4842         , x_return_status              => x_return_status
4843         , x_msg_count                  => x_msg_count
4844         , x_msg_data                   => x_msg_data
4845         , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
4846         , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
4847         , p_delete_option              => jtf_task_repeat_appt_pvt.g_skip
4848         );
4849 
4850         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4851           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4852           RAISE fnd_api.g_exc_unexpected_error;
4853         END IF;
4854       END LOOP;
4855 
4856       jtf_tasks_pub.lock_task(
4857         p_api_version                => 1.0
4858       , p_init_msg_list              => fnd_api.g_false
4859       , p_commit                     => fnd_api.g_false
4860       , p_task_id                    => l_task_id
4861       , p_object_version_number      => l_obj_version
4862       , x_return_status              => x_return_status
4863       , x_msg_data                   => x_msg_data
4864       , x_msg_count                  => x_msg_count
4865       );
4866 
4867       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4868         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4869         RAISE fnd_api.g_exc_unexpected_error;
4870       END IF;
4871 
4872       UPDATE jtf_tasks_b
4873          SET deleted_flag = 'Y'
4874            , last_update_date = SYSDATE
4875            , last_updated_by = fnd_global.user_id
4876            , object_changed_date = SYSDATE
4877        WHERE task_id = l_task_id;
4878 
4879       IF SQL%NOTFOUND THEN
4880         fnd_message.set_name('JTF', 'JTF_TASK_ERROR_DELETING_TASK');
4881         fnd_msg_pub.ADD;
4882         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4883         RAISE fnd_api.g_exc_unexpected_error;
4884       END IF;
4885 
4886       --- Moving the business event code here to fix bug 3363174 ..
4887       --BES enh 2391065
4888       OPEN task_source_orig(l_task_id);
4889 
4890       FETCH task_source_orig
4891        INTO l_orig_source_object_id
4892           , l_orig_source_object_type_code
4893           , l_entity;
4894 
4895       IF task_source_orig%NOTFOUND THEN
4896         CLOSE task_source_orig;
4897 
4898         RAISE fnd_api.g_exc_unexpected_error;
4899       END IF;
4900 
4901       CLOSE task_source_orig;
4902 
4903       IF (l_entity = 'TASK') THEN
4904         l_task_rec_type.task_id                  := l_task_id;
4905         l_task_rec_type.enable_workflow          := p_enable_workflow;
4906         l_task_rec_type.abort_workflow           := p_abort_workflow;
4907         l_task_rec_type.source_object_type_code  := l_orig_source_object_type_code;
4908         l_task_rec_type.source_object_id         := l_orig_source_object_id;
4909         jtf_task_wf_events_pvt.publish_delete_task(p_task_rec => l_task_rec_type
4910         , x_return_status              => x_event_return_status);
4911 
4912         IF (x_event_return_status = 'WARNING') THEN
4913           fnd_message.set_name('JTF', 'JTF_TASK_EVENT_WARNING');
4914           fnd_message.set_token('P_TASK_ID', l_task_id);
4915           fnd_msg_pub.ADD;
4916         ELSIF(x_event_return_status = 'ERROR') THEN
4917           fnd_message.set_name('JTF', 'JTF_TASK_EVENT_ERROR');
4918           fnd_message.set_token('P_TASK_ID', l_task_id);
4919           fnd_msg_pub.ADD;
4920           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4921           RAISE fnd_api.g_exc_unexpected_error;
4922         END IF;
4923       END IF;
4924 
4925       --BES enh 2391065
4926 
4927       -- Added to fix Bug # 2503657
4928           ---------------------------
4929           ---- delete contacts
4930           ---------------------------
4931       FOR cc IN c_contacts LOOP
4932         jtf_task_contacts_pub.delete_task_contacts
4933                                               (
4934           p_api_version                => 1.0
4935         , p_init_msg_list              => fnd_api.g_false
4936         , p_commit                     => fnd_api.g_false
4937         , p_object_version_number      => cc.object_version_number
4938         , p_task_contact_id            => cc.task_contact_id
4939         , x_return_status              => x_return_status
4940         , x_msg_data                   => x_msg_data
4941         , x_msg_count                  => x_msg_count
4942         , p_delete_cascade             => jtf_task_utl.g_yes_char
4943         );
4944 
4945         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4946           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4947           RAISE fnd_api.g_exc_unexpected_error;
4948         END IF;
4949       END LOOP;   -- End of delete contacts
4950 
4951       -- Added to fix Bug # 2585935
4952           ----------------------------
4953           ------ delete contact points
4954           ----------------------------
4955       FOR cp IN c_contact_points LOOP
4956         jtf_task_phones_pub.delete_task_phones
4957                                               (
4958           p_api_version                => 1.0
4959         , p_init_msg_list              => fnd_api.g_false
4960         , p_commit                     => fnd_api.g_false
4961         , p_object_version_number      => cp.object_version_number
4962         , p_task_phone_id              => cp.task_phone_id
4963         , x_return_status              => x_return_status
4964         , x_msg_count                  => x_msg_count
4965         , x_msg_data                   => x_msg_data
4966         );
4967 
4968         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4969           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4970           RAISE fnd_api.g_exc_unexpected_error;
4971         END IF;
4972       END LOOP;   -- End of delete contact points
4973     END LOOP;   --- loop for the task;.
4974 
4975     jtf_tasks_iuhk.delete_task_post(x_return_status);
4976 
4977     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4978       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4979       RAISE fnd_api.g_exc_unexpected_error;
4980     END IF;
4981 
4982     -------------------------------------------------------------------
4983     ---------------------- Workflow Enhancement -----------------------
4984     -------------------------------------------------------------------
4985     -- !!! moved this code to before all the deletes so the data is !!!
4986     -- !!! complete when the WF is sent       !!!
4987     -------------------------------------------------------------------
4988     IF fnd_api.to_boolean(p_commit) THEN
4989       COMMIT WORK;
4990     END IF;
4991 
4992     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4993   EXCEPTION
4994     WHEN fnd_api.g_exc_unexpected_error THEN
4995       ROLLBACK TO delete_task_pvt;
4996       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4997       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4998     WHEN OTHERS THEN
4999       ROLLBACK TO delete_task_pvt;
5000       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
5001       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
5002       fnd_msg_pub.ADD;
5003       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5004       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5005   END;
5006 
5007   PROCEDURE export_file(
5008     p_path          IN            VARCHAR2
5009   , p_file_name     IN            VARCHAR2
5010   , p_task_table    IN            jtf_tasks_pub.task_table_type
5011   , x_return_status OUT NOCOPY    VARCHAR2
5012   , x_msg_count     OUT NOCOPY    NUMBER
5013   , x_msg_data      OUT NOCOPY    VARCHAR2
5014   ) IS
5015     -- variables
5016     l_api_name     VARCHAR2(30)       := 'EXPORT_FILE';
5017     v_file         UTL_FILE.file_type;   -- output file handle
5018     v_start        NUMBER             := p_task_table.FIRST;
5019     v_end          NUMBER             := p_task_table.LAST;
5020     v_cnt          NUMBER;
5021     v_tab CONSTANT VARCHAR2(1)        := fnd_global.local_chr(9);   --tab value 9 in ascii
5022 
5023     PROCEDURE put_f_out(p_str IN VARCHAR2) IS
5024     BEGIN
5025       UTL_FILE.putf(v_file, p_str || v_tab);
5026     END put_f_out;
5027 
5028     PROCEDURE put_f(p_in IN VARCHAR2) IS
5029     BEGIN
5030       put_f_out(p_in);
5031     END put_f;
5032 
5033     PROCEDURE put_f(p_in IN NUMBER) IS
5034     BEGIN
5035       put_f_out(TO_CHAR(p_in));
5036     END put_f;
5037 
5038     PROCEDURE put_f(p_in IN DATE) IS
5039     BEGIN
5040       ---
5041       --- hbucksey 13-Feb-2002
5042       --- Replaced 'dd-mon-rrrr' format mask with 'dd-mm-rrrr' in order to ensure
5043       --- NLS compliance
5044       --- This is to resolve GSCC warning File.Sql.24
5045       ---   2688 - TO_DATE should not use month/day names
5046       ---
5047       put_f_out(TO_DATE(p_in, 'dd-mm-rrrr'));
5048     --  put_f_out (to_date(p_in, 'dd-mon-rrrr'));
5049     END put_f;
5050   BEGIN   -- export file
5051     x_return_status  := fnd_api.g_ret_sts_success;
5052 
5053     -- close file if its open
5054     IF (UTL_FILE.is_open(v_file)) THEN
5055       UTL_FILE.fclose(v_file);
5056     END IF;
5057 
5058     -- open file for write only
5059     v_file           := UTL_FILE.fopen(p_path, p_file_name, 'w');
5060 
5061     FOR v_cnt IN v_start .. v_end LOOP
5062       put_f(p_task_table(v_cnt).task_id);
5063       put_f(p_task_table(v_cnt).task_number);
5064       put_f(p_task_table(v_cnt).task_name);
5065       put_f(p_task_table(v_cnt).task_type);
5066       put_f(p_task_table(v_cnt).task_status);
5067       put_f(p_task_table(v_cnt).task_priority);
5068       put_f(p_task_table(v_cnt).planned_start_date);
5069       put_f(p_task_table(v_cnt).planned_end_date);
5070       put_f(p_task_table(v_cnt).actual_start_date);
5071       put_f(p_task_table(v_cnt).actual_end_date);
5072       put_f(p_task_table(v_cnt).scheduled_start_date);
5073       put_f(p_task_table(v_cnt).scheduled_end_date);
5074       put_f(p_task_table(v_cnt).DURATION);
5075       put_f(p_task_table(v_cnt).duration_uom);
5076       put_f(p_task_table(v_cnt).planned_effort);
5077       put_f(p_task_table(v_cnt).planned_effort_uom);
5078       UTL_FILE.new_line(v_file, 1);
5079     END LOOP;
5080 
5081     -- close file
5082     UTL_FILE.fclose(v_file);
5083   EXCEPTION
5084     WHEN fnd_api.g_exc_error THEN
5085       IF (UTL_FILE.is_open(v_file)) THEN
5086         UTL_FILE.fclose(v_file);
5087       END IF;
5088 
5089       x_return_status  := fnd_api.g_ret_sts_error;
5090       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5091     WHEN fnd_api.g_exc_unexpected_error THEN
5092       IF (UTL_FILE.is_open(v_file)) THEN
5093         UTL_FILE.fclose(v_file);
5094       END IF;
5095 
5096       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5097       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5098     WHEN OTHERS THEN
5099       IF (UTL_FILE.is_open(v_file)) THEN
5100         UTL_FILE.fclose(v_file);
5101       END IF;
5102 
5103       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5104 
5105       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
5106         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
5107       END IF;
5108 
5109       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5110   END export_file;
5111 
5112   PROCEDURE dump_long_line(txt IN VARCHAR2, v_str IN VARCHAR2) IS
5113     LN INTEGER := LENGTH(v_str);
5114     st INTEGER := 1;
5115   BEGIN
5116     LOOP
5117       st  := st + 72;
5118       EXIT WHEN(st >= LN);
5119     END LOOP;
5120   END dump_long_line;
5121 
5122   PROCEDURE query_task(
5123     p_object_version_number IN            NUMBER
5124   , p_task_id               IN            jtf_tasks_v.task_id%TYPE
5125   , p_description           IN            jtf_tasks_v.description%TYPE
5126   , p_task_type_id          IN            jtf_tasks_v.task_type_id%TYPE
5127   , p_task_status_id        IN            jtf_tasks_v.task_status_id%TYPE
5128   , p_task_priority_id      IN            jtf_tasks_v.task_priority_id%TYPE
5129   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE
5130   , p_owner_id              IN            jtf_tasks_v.owner_id%TYPE
5131   , p_assigned_by_id        IN            jtf_tasks_v.assigned_by_id%TYPE
5132   , p_address_id            IN            jtf_tasks_v.address_id%TYPE
5133   , p_owner_territory_id    IN            jtf_tasks_v.owner_territory_id%TYPE DEFAULT NULL
5134   , p_customer_id           IN            jtf_tasks_v.customer_id%TYPE DEFAULT NULL
5135   , p_cust_account_id       IN            jtf_tasks_v.cust_account_id%TYPE DEFAULT NULL
5136   , p_planned_start_date    IN            jtf_tasks_v.planned_start_date%TYPE
5137   , p_planned_end_date      IN            jtf_tasks_v.planned_end_date%TYPE
5138   , p_scheduled_start_date  IN            jtf_tasks_v.scheduled_start_date%TYPE
5139   , p_scheduled_end_date    IN            jtf_tasks_v.scheduled_end_date%TYPE
5140   , p_actual_start_date     IN            jtf_tasks_v.actual_start_date%TYPE
5141   , p_actual_end_date       IN            jtf_tasks_v.actual_end_date%TYPE
5142   , p_object_type_code      IN            jtf_tasks_v.source_object_type_code%TYPE
5143   , p_source_object_id      IN            jtf_tasks_v.source_object_id%TYPE
5144   , p_percentage_complete   IN            jtf_tasks_v.percentage_complete%TYPE
5145   , p_reason_code           IN            jtf_tasks_v.reason_code%TYPE
5146   , p_private_flag          IN            jtf_tasks_v.private_flag%TYPE
5147   , p_restrict_closure_flag IN            jtf_tasks_v.restrict_closure_flag%TYPE
5148   , p_multi_booked_flag     IN            jtf_tasks_v.multi_booked_flag%TYPE
5149   , p_milestone_flag        IN            jtf_tasks_v.milestone_flag%TYPE
5150   , p_holiday_flag          IN            jtf_tasks_v.holiday_flag%TYPE
5151   , p_workflow_process_id   IN            jtf_tasks_v.workflow_process_id%TYPE
5152   , p_notification_flag     IN            jtf_tasks_v.notification_flag%TYPE
5153   , p_parent_task_id        IN            jtf_tasks_v.parent_task_id%TYPE
5154   , p_alarm_on              IN            jtf_tasks_v.alarm_on%TYPE
5155   , p_alarm_count           IN            jtf_tasks_v.alarm_count%TYPE
5156   , p_alarm_fired_count     IN            jtf_tasks_v.alarm_fired_count%TYPE
5157   , p_ref_object_id         IN            NUMBER
5158   , p_ref_object_type_code  IN            VARCHAR2
5159   , p_task_name             IN            jtf_tasks_v.task_name%TYPE
5160   , p_sort_data             IN            jtf_tasks_pub.sort_data
5161   , p_start_pointer         IN            NUMBER
5162   , p_rec_wanted            IN            NUMBER
5163   , p_show_all              IN            VARCHAR2
5164   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
5165   , x_task_table            OUT NOCOPY    jtf_tasks_pub.task_table_type
5166   , x_total_retrieved       OUT NOCOPY    NUMBER
5167   , x_total_returned        OUT NOCOPY    NUMBER
5168   , x_return_status         OUT NOCOPY    VARCHAR2
5169   , x_msg_count             OUT NOCOPY    NUMBER
5170   , x_msg_data              OUT NOCOPY    VARCHAR2
5171   ) IS
5172     -- declare variables
5173     l_api_name VARCHAR2(30) := 'QUERY_TASK';
5174   BEGIN
5175     x_return_status  := fnd_api.g_ret_sts_success;
5176     query_task(
5177       p_object_version_number      => p_object_version_number
5178     , p_task_id                    => p_task_id
5179     , p_description                => p_description
5180     , p_task_type_id               => p_task_type_id
5181     , p_task_status_id             => p_task_status_id
5182     , p_task_priority_id           => p_task_priority_id
5183     , p_owner_type_code            => p_owner_type_code
5184     , p_owner_id                   => p_owner_id
5185     , p_assigned_by_id             => p_assigned_by_id
5186     , p_address_id                 => p_address_id
5187     , p_owner_territory_id         => p_owner_territory_id
5188     , p_customer_id                => p_customer_id
5189     , p_cust_account_id            => p_cust_account_id
5190     , p_planned_start_date         => p_planned_start_date
5191     , p_planned_end_date           => p_planned_end_date
5192     , p_scheduled_start_date       => p_scheduled_start_date
5193     , p_scheduled_end_date         => p_scheduled_end_date
5194     , p_actual_start_date          => p_actual_start_date
5195     , p_actual_end_date            => p_actual_end_date
5196     , p_object_type_code           => p_object_type_code
5197     , p_source_object_id           => p_source_object_id
5198     , p_percentage_complete        => p_percentage_complete
5199     , p_reason_code                => p_reason_code
5200     , p_private_flag               => p_private_flag
5201     , p_restrict_closure_flag      => p_restrict_closure_flag
5202     , p_multi_booked_flag          => p_multi_booked_flag
5203     , p_milestone_flag             => p_milestone_flag
5204     , p_holiday_flag               => p_holiday_flag
5205     , p_workflow_process_id        => p_workflow_process_id
5206     , p_notification_flag          => p_notification_flag
5207     , p_parent_task_id             => p_parent_task_id
5208     , p_alarm_on                   => p_alarm_on
5209     , p_alarm_count                => p_alarm_count
5210     , p_alarm_fired_count          => p_alarm_fired_count
5211     , p_ref_object_id              => p_ref_object_id
5212     , p_ref_object_type_code       => p_ref_object_type_code
5213     , p_task_name                  => p_task_name
5214     , p_sort_data                  => p_sort_data
5215     , p_start_pointer              => p_start_pointer
5216     , p_rec_wanted                 => p_rec_wanted
5217     , p_show_all                   => p_show_all
5218     , p_query_or_next_code         => p_query_or_next_code
5219     , x_task_table                 => x_task_table
5220     , x_total_retrieved            => x_total_retrieved
5221     , x_total_returned             => x_total_returned
5222     , x_return_status              => x_return_status
5223     , x_msg_count                  => x_msg_count
5224     , x_msg_data                   => x_msg_data
5225     , p_location_id                => NULL
5226     );
5227   EXCEPTION
5228     WHEN fnd_api.g_exc_error THEN
5229       x_return_status  := fnd_api.g_ret_sts_error;
5230       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5231     WHEN fnd_api.g_exc_unexpected_error THEN
5232       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5233       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5234     WHEN OTHERS THEN
5235       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5236 
5237       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
5238         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
5239       END IF;
5240 
5241       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5242   END query_task;
5243 
5244   PROCEDURE query_task(
5245     p_object_version_number IN            NUMBER
5246   , p_task_id               IN            jtf_tasks_v.task_id%TYPE
5247   , p_description           IN            jtf_tasks_v.description%TYPE
5248   , p_task_type_id          IN            jtf_tasks_v.task_type_id%TYPE
5249   , p_task_status_id        IN            jtf_tasks_v.task_status_id%TYPE
5250   , p_task_priority_id      IN            jtf_tasks_v.task_priority_id%TYPE
5251   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE
5252   , p_owner_id              IN            jtf_tasks_v.owner_id%TYPE
5253   , p_assigned_by_id        IN            jtf_tasks_v.assigned_by_id%TYPE
5254   , p_address_id            IN            jtf_tasks_v.address_id%TYPE
5255   , p_owner_territory_id    IN            jtf_tasks_v.owner_territory_id%TYPE DEFAULT NULL
5256   , p_customer_id           IN            jtf_tasks_v.customer_id%TYPE DEFAULT NULL
5257   , p_cust_account_id       IN            jtf_tasks_v.cust_account_id%TYPE DEFAULT NULL
5258   , p_planned_start_date    IN            jtf_tasks_v.planned_start_date%TYPE
5259   , p_planned_end_date      IN            jtf_tasks_v.planned_end_date%TYPE
5260   , p_scheduled_start_date  IN            jtf_tasks_v.scheduled_start_date%TYPE
5261   , p_scheduled_end_date    IN            jtf_tasks_v.scheduled_end_date%TYPE
5262   , p_actual_start_date     IN            jtf_tasks_v.actual_start_date%TYPE
5263   , p_actual_end_date       IN            jtf_tasks_v.actual_end_date%TYPE
5264   , p_object_type_code      IN            jtf_tasks_v.source_object_type_code%TYPE
5265   , p_source_object_id      IN            jtf_tasks_v.source_object_id%TYPE
5266   , p_percentage_complete   IN            jtf_tasks_v.percentage_complete%TYPE
5267   , p_reason_code           IN            jtf_tasks_v.reason_code%TYPE
5268   , p_private_flag          IN            jtf_tasks_v.private_flag%TYPE
5269   , p_restrict_closure_flag IN            jtf_tasks_v.restrict_closure_flag%TYPE
5270   , p_multi_booked_flag     IN            jtf_tasks_v.multi_booked_flag%TYPE
5271   , p_milestone_flag        IN            jtf_tasks_v.milestone_flag%TYPE
5272   , p_holiday_flag          IN            jtf_tasks_v.holiday_flag%TYPE
5273   , p_workflow_process_id   IN            jtf_tasks_v.workflow_process_id%TYPE
5274   , p_notification_flag     IN            jtf_tasks_v.notification_flag%TYPE
5275   , p_parent_task_id        IN            jtf_tasks_v.parent_task_id%TYPE
5276   , p_alarm_on              IN            jtf_tasks_v.alarm_on%TYPE
5277   , p_alarm_count           IN            jtf_tasks_v.alarm_count%TYPE
5278   , p_alarm_fired_count     IN            jtf_tasks_v.alarm_fired_count%TYPE
5279   , p_ref_object_id         IN            NUMBER
5280   , p_ref_object_type_code  IN            VARCHAR2
5281   , p_task_name             IN            jtf_tasks_v.task_name%TYPE
5282   , p_sort_data             IN            jtf_tasks_pub.sort_data
5283   , p_start_pointer         IN            NUMBER
5284   , p_rec_wanted            IN            NUMBER
5285   , p_show_all              IN            VARCHAR2
5286   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
5287   , x_task_table            OUT NOCOPY    jtf_tasks_pub.task_table_type
5288   , x_total_retrieved       OUT NOCOPY    NUMBER
5289   , x_total_returned        OUT NOCOPY    NUMBER
5290   , x_return_status         OUT NOCOPY    VARCHAR2
5291   , x_msg_count             OUT NOCOPY    NUMBER
5292   , x_msg_data              OUT NOCOPY    VARCHAR2
5293   , p_location_id           IN            NUMBER
5294   ) IS
5295     -- declare variables
5296     l_api_name  VARCHAR2(30)           := 'QUERY_TASK';
5297     v_cursor_id INTEGER;
5298     v_dummy     INTEGER;
5299     v_cnt       INTEGER;
5300     v_end       INTEGER;
5301     v_start     INTEGER;
5302     v_type      jtf_tasks_pub.task_rec;
5303 
5304     PROCEDURE create_sql_statement IS
5305       v_index INTEGER;
5306       v_first INTEGER;
5307       v_comma VARCHAR2(5);
5308       v_where VARCHAR2(2000);
5309       v_and   CHAR(1)        := 'N';
5310 
5311       PROCEDURE add_to_sql_str(
5312         p_in    VARCHAR2
5313       ,   --value in parameter
5314         p_bind  VARCHAR2
5315       ,   --bind variable to use
5316         p_field VARCHAR2   --field associated with parameter
5317       ) IS
5318         v_str VARCHAR2(10);
5319       BEGIN   -- add_to_sql
5320         IF (p_in IS NOT NULL) THEN
5321           IF (v_and = 'N') THEN
5322             v_str  := ' ';
5323             v_and  := 'Y';
5324           ELSE
5325             v_str  := ' and ';
5326           END IF;
5327 
5328           v_where  := v_where || v_str || p_field || ' = :' || p_bind;
5329         END IF;
5330       END add_to_sql_str;
5331 
5332       PROCEDURE add_to_sql(
5333         p_in    NUMBER
5334       ,   --value in parameter
5335         p_bind  VARCHAR2
5336       ,   --bind variable to use
5337         p_field VARCHAR2   --field associated with parameter
5338       ) IS
5339       BEGIN
5340         add_to_sql_str(TO_CHAR(p_in), p_bind, p_field);
5341       END;
5342 
5343       PROCEDURE add_to_sql(
5344         p_in    DATE
5345       ,   --value in parameter
5346         p_bind  VARCHAR2
5347       ,   --bind variable to use
5348         p_field VARCHAR2   --field associated with parameter
5349       ) IS
5350       BEGIN
5351         add_to_sql_str(TO_CHAR(p_in, 'dd-mon-rrrr'), p_bind, p_field);
5352       END;
5353 
5354       PROCEDURE add_to_sql(
5355         p_in    VARCHAR2
5356       ,   --value in parameter
5357         p_bind  VARCHAR2
5358       ,   --bind variable to use
5359         p_field VARCHAR2   --field associated with parameter
5360       ) IS
5361       BEGIN
5362         add_to_sql_str(p_in, p_bind, p_field);
5363       END;
5364     BEGIN   --create_sql_statement
5365       v_select  :=
5366            'select '
5367         || 'task_id,'
5368         || 'task_number,'
5369         || 'task_name,'
5370         || 'description,'
5371         || 'task_type_id,'
5372         || 'task_type,'
5373         || 'task_status_id,'
5374         || 'task_status,'
5375         || 'task_priority_id,'
5376         || 'task_priority,'
5377         || 'owner_type_code,'
5378         || 'owner_id,'
5379         || 'assigned_by_id,'
5380         || 'assigned_by_name,'
5381         || 'customer_id,'
5382         || 'customer_name,'
5383         || 'customer_number,'
5384         || 'address_id,'
5385         || 'planned_start_date,'
5386         || 'planned_end_date,'
5387         || 'scheduled_start_date,'
5388         || 'scheduled_end_date,'
5389         || 'actual_start_date,'
5390         || 'actual_end_date,'
5391         || 'source_object_type_code,'
5392         || 'source_object_id,'
5393         || 'source_object_name,'
5394         || 'duration,'
5395         || 'duration_uom,'
5396         || 'planned_effort,'
5397         || 'planned_effort_uom,'
5398         || 'actual_effort,'
5399         || 'actual_effort_uom,'
5400         || 'percentage_complete,'
5401         || 'reason_code,'
5402         || 'private_flag,'
5403         || 'publish_flag,'
5404         || 'multi_booked_flag,'
5405         || 'milestone_flag,'
5406         || 'holiday_flag,'
5407         || 'workflow_process_id,'
5408         || 'notification_flag,'
5409         || 'notification_period,'
5410         || 'notification_period_uom,'
5411         || 'parent_task_id,'
5412         || 'alarm_start,'
5413         || 'alarm_start_uom,'
5414         || 'alarm_on,'
5415         || 'alarm_count,'
5416         || 'alarm_fired_count,'
5417         || 'alarm_interval,'
5418         || 'alarm_interval_uom,'
5419         || 'attribute1,'
5420         || 'attribute2,'
5421         || 'attribute3,'
5422         || 'attribute4,'
5423         || 'attribute5,'
5424         || 'attribute6,'
5425         || 'attribute7,'
5426         || 'attribute8,'
5427         || 'attribute9,'
5428         || 'attribute10,'
5429         || 'attribute11,'
5430         || 'attribute12,'
5431         || 'attribute13,'
5432         || 'attribute14,'
5433         || 'attribute15,'
5434         || 'attribute_category,'
5435         || 'owner,'
5436         || 'cust_account_number,'
5437         || 'cust_account_id,'
5438         || 'owner_territory_id,'
5439         || 'creation_date, '
5440         || 'escalation_level, '
5441         || 'object_version_number, '
5442         || 'location_id '
5443         || 'from jtf_tasks_v ';
5444       add_to_sql(p_task_id, 'b1', 'task_id');
5445       add_to_sql(p_description, 'b2', 'description');
5446       add_to_sql(p_task_status_id, 'b3', 'task_status_id');
5447       add_to_sql(p_task_priority_id, 'b4', 'task_priority_id');
5448       add_to_sql(p_owner_type_code, 'b5', 'owner_type_code');
5449       add_to_sql(p_owner_id, 'b6', 'owner_id');
5450       add_to_sql(p_assigned_by_id, 'b7', 'assigned_by_id');
5451       add_to_sql(p_address_id, 'b8', 'address_id');
5452       add_to_sql(p_planned_start_date, 'b9', 'planned_start_date');
5453       add_to_sql(p_planned_end_date, 'b10', 'planned_end_date');
5454       add_to_sql(p_scheduled_start_date, 'b11', 'scheduled_start_date');
5455       add_to_sql(p_scheduled_end_date, 'b12', 'scheduled_end_date');
5456       add_to_sql(p_actual_start_date, 'b13', 'actual_start_date');
5457       add_to_sql(p_actual_end_date, 'b14', 'actual_end_date');
5458       add_to_sql(p_object_type_code, 'b15', 'source_object_type_code');
5459       add_to_sql(p_percentage_complete, 'b16', 'percentage_complete');
5460       add_to_sql(p_reason_code, 'b17', 'reason_code');
5461       add_to_sql(p_private_flag, 'b18', 'private_flag');
5462       add_to_sql(p_restrict_closure_flag, 'b19', 'restrict_closure_flag');
5463       add_to_sql(p_multi_booked_flag, 'b20', 'multi_booked_flag');
5464       add_to_sql(p_milestone_flag, 'b21', 'milestone_flag');
5465       add_to_sql(p_holiday_flag, 'b22', 'holiday_flag');
5466       add_to_sql(p_workflow_process_id, 'b23', 'workflow_process_id');
5467       add_to_sql(p_notification_flag, 'b27', 'notification_flag');
5468       add_to_sql(p_parent_task_id, 'b28', 'parent_task_id');
5469       add_to_sql(p_alarm_on, 'b29', 'alarm_on');
5470       add_to_sql(p_alarm_count, 'b30', 'alarm_count');
5471       add_to_sql(p_alarm_fired_count, 'b31', 'alarm_fired_count');
5472       add_to_sql(p_task_name, 'b32', 'task_name');
5473       add_to_sql(p_owner_territory_id, 'b33', 'owner_territory_id');
5474       add_to_sql(p_customer_id, 'b34', 'customer_id');
5475       add_to_sql(p_cust_account_id, 'b35', 'cust_account_id');
5476       add_to_sql(p_task_type_id, 'b36', 'task_type_id');
5477       add_to_sql(p_source_object_id, 'b37', 'source_object_id');
5478       add_to_sql(p_location_id, 'b38', 'location_id');
5479 
5480       -- jtf_task_references table if object code given
5481       IF (p_ref_object_type_code IS NOT NULL) AND(p_ref_object_id IS NOT NULL) THEN
5482         IF (v_where IS NOT NULL) THEN
5483           v_where  := v_where || ' and';
5484         END IF;
5485 
5486         v_where  :=
5487              v_where
5488           || ' exists '
5489           || '(select * from jtf_task_references_vl r '
5490           || '  where r.task_id = jtf_tasks_v.task_id '
5491           || '	 and r.object_id = :b100 '
5492           || '	 and r.object_type_code = :b101 ) ';
5493       END IF;
5494 
5495       IF (v_where IS NOT NULL) THEN
5496         v_select  := v_select || ' where ' || v_where;
5497       END IF;
5498 
5499       IF (p_sort_data.COUNT > 0) THEN   --there is a sort preference
5500         v_select  := v_select || ' order by ';
5501         v_index   := p_sort_data.FIRST;
5502         v_first   := v_index;
5503 
5504         LOOP
5505           IF (v_first = v_index) THEN
5506             v_comma  := ' ';
5507           ELSE
5508             v_comma  := ', ';
5509           END IF;
5510 
5511           v_select  := v_select || v_comma || p_sort_data(v_index).field_name || ' ';
5512 
5513           -- ascending or descending order
5514           IF (p_sort_data(v_index).asc_dsc_flag = 'A') THEN
5515             v_select  := v_select || 'asc ';
5516           ELSIF(p_sort_data(v_index).asc_dsc_flag = 'D') THEN
5517             v_select  := v_select || 'desc ';
5518           END IF;
5519 
5520           EXIT WHEN v_index = p_sort_data.LAST;
5521           v_index   := p_sort_data.NEXT(v_index);
5522         END LOOP;
5523       END IF;
5524     END create_sql_statement;
5525   BEGIN   -- query task
5526     x_return_status    := fnd_api.g_ret_sts_success;
5527     x_task_table.DELETE;
5528 
5529     IF (p_query_or_next_code = 'Q') THEN
5530       v_tbl.DELETE;
5531       create_sql_statement;
5532       --dump_long_line('v_sel:',v_select);
5533       v_cursor_id  := DBMS_SQL.open_cursor;
5534       DBMS_SQL.parse(v_cursor_id, v_select, DBMS_SQL.v7);
5535 
5536       -- bind variables only if they added to the sql statement
5537       IF (p_task_id IS NOT NULL) THEN
5538         DBMS_SQL.bind_variable(v_cursor_id, ':b1', p_task_id);
5539       END IF;
5540 
5541       IF (p_description IS NOT NULL) THEN
5542         DBMS_SQL.bind_variable(v_cursor_id, ':b2', p_description);
5543       END IF;
5544 
5545       IF (p_task_status_id IS NOT NULL) THEN
5546         DBMS_SQL.bind_variable(v_cursor_id, ':b3', p_task_status_id);
5547       END IF;
5548 
5549       IF (p_task_priority_id IS NOT NULL) THEN
5550         DBMS_SQL.bind_variable(v_cursor_id, ':b4', p_task_priority_id);
5551       END IF;
5552 
5553       IF (p_owner_type_code IS NOT NULL) THEN
5554         DBMS_SQL.bind_variable(v_cursor_id, ':b5', p_owner_type_code);
5555       END IF;
5556 
5557       IF (p_owner_id IS NOT NULL) THEN
5558         DBMS_SQL.bind_variable(v_cursor_id, ':b6', p_owner_id);
5559       END IF;
5560 
5561       IF (p_assigned_by_id IS NOT NULL) THEN
5562         DBMS_SQL.bind_variable(v_cursor_id, ':b7', p_assigned_by_id);
5563       END IF;
5564 
5565       IF (p_address_id IS NOT NULL) THEN
5566         DBMS_SQL.bind_variable(v_cursor_id, ':b8', p_address_id);
5567       END IF;
5568 
5569       IF (p_planned_start_date IS NOT NULL) THEN
5570         DBMS_SQL.bind_variable(v_cursor_id, ':b9', p_planned_start_date);
5571       END IF;
5572 
5573       IF (p_planned_end_date IS NOT NULL) THEN
5574         DBMS_SQL.bind_variable(v_cursor_id, ':b10', p_planned_end_date);
5575       END IF;
5576 
5577       IF (p_scheduled_start_date IS NOT NULL) THEN
5578         DBMS_SQL.bind_variable(v_cursor_id, ':b11', p_scheduled_start_date);
5579       END IF;
5580 
5581       IF (p_scheduled_end_date IS NOT NULL) THEN
5582         DBMS_SQL.bind_variable(v_cursor_id, ':b12', p_scheduled_end_date);
5583       END IF;
5584 
5585       IF (p_actual_start_date IS NOT NULL) THEN
5586         DBMS_SQL.bind_variable(v_cursor_id, ':b13', p_actual_start_date);
5587       END IF;
5588 
5589       IF (p_actual_end_date IS NOT NULL) THEN
5590         DBMS_SQL.bind_variable(v_cursor_id, ':b14', p_actual_end_date);
5591       END IF;
5592 
5593       IF (p_object_type_code IS NOT NULL) THEN
5594         DBMS_SQL.bind_variable(v_cursor_id, ':b15', p_object_type_code);
5595       END IF;
5596 
5597       IF (p_percentage_complete IS NOT NULL) THEN
5598         DBMS_SQL.bind_variable(v_cursor_id, ':b16', p_percentage_complete);
5599       END IF;
5600 
5601       IF (p_reason_code IS NOT NULL) THEN
5602         DBMS_SQL.bind_variable(v_cursor_id, ':b17', p_reason_code);
5603       END IF;
5604 
5605       IF (p_private_flag IS NOT NULL) THEN
5606         DBMS_SQL.bind_variable(v_cursor_id, ':b18', p_private_flag);
5607       END IF;
5608 
5609       IF (p_restrict_closure_flag IS NOT NULL) THEN
5610         DBMS_SQL.bind_variable(v_cursor_id, ':b19', p_restrict_closure_flag);
5611       END IF;
5612 
5613       IF (p_multi_booked_flag IS NOT NULL) THEN
5614         DBMS_SQL.bind_variable(v_cursor_id, ':b20', p_multi_booked_flag);
5615       END IF;
5616 
5617       IF (p_milestone_flag IS NOT NULL) THEN
5618         DBMS_SQL.bind_variable(v_cursor_id, ':b21', p_milestone_flag);
5619       END IF;
5620 
5621       IF (p_holiday_flag IS NOT NULL) THEN
5622         DBMS_SQL.bind_variable(v_cursor_id, ':b22', p_holiday_flag);
5623       END IF;
5624 
5625       IF (p_workflow_process_id IS NOT NULL) THEN
5626         DBMS_SQL.bind_variable(v_cursor_id, ':b23', p_workflow_process_id);
5627       END IF;
5628 
5629       IF (p_notification_flag IS NOT NULL) THEN
5630         DBMS_SQL.bind_variable(v_cursor_id, ':b27', p_notification_flag);
5631       END IF;
5632 
5633       IF (p_parent_task_id IS NOT NULL) THEN
5634         DBMS_SQL.bind_variable(v_cursor_id, ':b28', p_parent_task_id);
5635       END IF;
5636 
5637       IF (p_alarm_on IS NOT NULL) THEN
5638         DBMS_SQL.bind_variable(v_cursor_id, ':b29', p_alarm_on);
5639       END IF;
5640 
5641       IF (p_alarm_count IS NOT NULL) THEN
5642         DBMS_SQL.bind_variable(v_cursor_id, ':b30', p_alarm_count);
5643       END IF;
5644 
5645       IF (p_alarm_fired_count IS NOT NULL) THEN
5646         DBMS_SQL.bind_variable(v_cursor_id, ':b31', p_alarm_fired_count);
5647       END IF;
5648 
5649       IF (p_task_name IS NOT NULL) THEN
5650         DBMS_SQL.bind_variable(v_cursor_id, ':b32', p_task_name);
5651       END IF;
5652 
5653       IF (p_owner_territory_id IS NOT NULL) THEN
5654         DBMS_SQL.bind_variable(v_cursor_id, ':b33', p_owner_territory_id);
5655       END IF;
5656 
5657       IF (p_customer_id IS NOT NULL) THEN
5658         DBMS_SQL.bind_variable(v_cursor_id, ':b34', p_customer_id);
5659       END IF;
5660 
5661       IF (p_cust_account_id IS NOT NULL) THEN
5662         DBMS_SQL.bind_variable(v_cursor_id, ':b35', p_cust_account_id);
5663       END IF;
5664 
5665       IF (p_task_type_id IS NOT NULL) THEN
5666         DBMS_SQL.bind_variable(v_cursor_id, ':b36', p_task_type_id);
5667       END IF;
5668 
5669       IF (p_source_object_id IS NOT NULL) THEN
5670         DBMS_SQL.bind_variable(v_cursor_id, ':b37', p_source_object_id);
5671       END IF;
5672 
5673       IF (p_location_id IS NOT NULL) THEN
5674         DBMS_SQL.bind_variable(v_cursor_id, ':b38', p_location_id);
5675       END IF;
5676 
5677       IF (p_ref_object_type_code IS NOT NULL) AND(p_ref_object_id IS NOT NULL) THEN
5678         DBMS_SQL.bind_variable(v_cursor_id, ':b100', p_ref_object_id);
5679         DBMS_SQL.bind_variable(v_cursor_id, ':b101', p_ref_object_type_code);
5680       END IF;
5681 
5682       -- define the output columns
5683       DBMS_SQL.define_column(v_cursor_id, 1, v_type.task_id);
5684       DBMS_SQL.define_column(v_cursor_id, 2, v_type.task_number, 30);
5685       DBMS_SQL.define_column(v_cursor_id, 3, v_type.task_name, 80);
5686       DBMS_SQL.define_column(v_cursor_id, 4, v_type.description, 4000);
5687       DBMS_SQL.define_column(v_cursor_id, 5, v_type.task_type_id);
5688       DBMS_SQL.define_column(v_cursor_id, 6, v_type.task_type, 30);
5689       DBMS_SQL.define_column(v_cursor_id, 7, v_type.task_status_id);
5690       DBMS_SQL.define_column(v_cursor_id, 8, v_type.task_status, 30);
5691       DBMS_SQL.define_column(v_cursor_id, 9, v_type.task_priority_id);
5692       DBMS_SQL.define_column(v_cursor_id, 10, v_type.task_priority, 30);
5693       DBMS_SQL.define_column(v_cursor_id, 11, v_type.owner_type_code, 20);
5694       DBMS_SQL.define_column(v_cursor_id, 12, v_type.owner_id);
5695       DBMS_SQL.define_column(v_cursor_id, 13, v_type.assigned_by_id);
5696       DBMS_SQL.define_column(v_cursor_id, 14, v_type.assigned_by_name, 100);
5697       DBMS_SQL.define_column(v_cursor_id, 15, v_type.customer_id);
5698       DBMS_SQL.define_column(v_cursor_id, 16, v_type.customer_name, 255);
5699       DBMS_SQL.define_column(v_cursor_id, 17, v_type.customer_number, 30);
5700       DBMS_SQL.define_column(v_cursor_id, 18, v_type.address_id);
5701       DBMS_SQL.define_column(v_cursor_id, 19, v_type.planned_start_date);
5702       DBMS_SQL.define_column(v_cursor_id, 20, v_type.planned_end_date);
5703       DBMS_SQL.define_column(v_cursor_id, 21, v_type.scheduled_start_date);
5704       DBMS_SQL.define_column(v_cursor_id, 22, v_type.scheduled_end_date);
5705       DBMS_SQL.define_column(v_cursor_id, 23, v_type.actual_start_date);
5706       DBMS_SQL.define_column(v_cursor_id, 24, v_type.actual_end_date);
5707       DBMS_SQL.define_column(v_cursor_id, 25, v_type.object_type_code, 30);
5708       DBMS_SQL.define_column(v_cursor_id, 26, v_type.object_id);
5709       DBMS_SQL.define_column(v_cursor_id, 27, v_type.obect_name, 30);
5710       DBMS_SQL.define_column(v_cursor_id, 28, v_type.DURATION);
5711       DBMS_SQL.define_column(v_cursor_id, 29, v_type.duration_uom, 3);
5712       DBMS_SQL.define_column(v_cursor_id, 30, v_type.planned_effort);
5713       DBMS_SQL.define_column(v_cursor_id, 31, v_type.planned_effort_uom, 3);
5714       DBMS_SQL.define_column(v_cursor_id, 32, v_type.actual_effort);
5715       DBMS_SQL.define_column(v_cursor_id, 33, v_type.actual_effort_uom, 3);
5716       DBMS_SQL.define_column(v_cursor_id, 34, v_type.percentage_complete);
5717       DBMS_SQL.define_column(v_cursor_id, 35, v_type.reason_code, 30);
5718       DBMS_SQL.define_column(v_cursor_id, 36, v_type.private_flag, 1);
5719       DBMS_SQL.define_column(v_cursor_id, 37, v_type.publish_flag, 1);
5720       DBMS_SQL.define_column(v_cursor_id, 38, v_type.multi_booked_flag, 1);
5721       DBMS_SQL.define_column(v_cursor_id, 39, v_type.milestone_flag, 1);
5722       DBMS_SQL.define_column(v_cursor_id, 40, v_type.holiday_flag, 1);
5723       DBMS_SQL.define_column(v_cursor_id, 41, v_type.workflow_process_id);
5724       DBMS_SQL.define_column(v_cursor_id, 42, v_type.notification_flag, 1);
5725       DBMS_SQL.define_column(v_cursor_id, 43, v_type.notification_period);
5726       DBMS_SQL.define_column(v_cursor_id, 44, v_type.notification_period_uom, 3);
5727       DBMS_SQL.define_column(v_cursor_id, 45, v_type.parent_task_id);
5728       DBMS_SQL.define_column(v_cursor_id, 46, v_type.alarm_start);
5729       DBMS_SQL.define_column(v_cursor_id, 47, v_type.alarm_start_uom, 3);
5730       DBMS_SQL.define_column(v_cursor_id, 48, v_type.alarm_on, 1);
5731       DBMS_SQL.define_column(v_cursor_id, 49, v_type.alarm_count);
5732       DBMS_SQL.define_column(v_cursor_id, 50, v_type.alarm_fired_count);
5733       DBMS_SQL.define_column(v_cursor_id, 51, v_type.alarm_interval);
5734       DBMS_SQL.define_column(v_cursor_id, 52, v_type.alarm_interval_uom, 3);
5735       DBMS_SQL.define_column(v_cursor_id, 53, v_type.attribute1, 150);
5736       DBMS_SQL.define_column(v_cursor_id, 54, v_type.attribute2, 150);
5737       DBMS_SQL.define_column(v_cursor_id, 55, v_type.attribute3, 150);
5738       DBMS_SQL.define_column(v_cursor_id, 56, v_type.attribute4, 150);
5739       DBMS_SQL.define_column(v_cursor_id, 57, v_type.attribute5, 150);
5740       DBMS_SQL.define_column(v_cursor_id, 58, v_type.attribute6, 150);
5741       DBMS_SQL.define_column(v_cursor_id, 59, v_type.attribute7, 150);
5742       DBMS_SQL.define_column(v_cursor_id, 60, v_type.attribute8, 150);
5743       DBMS_SQL.define_column(v_cursor_id, 61, v_type.attribute9, 150);
5744       DBMS_SQL.define_column(v_cursor_id, 62, v_type.attribute10, 150);
5745       DBMS_SQL.define_column(v_cursor_id, 63, v_type.attribute11, 150);
5746       DBMS_SQL.define_column(v_cursor_id, 64, v_type.attribute12, 150);
5747       DBMS_SQL.define_column(v_cursor_id, 65, v_type.attribute13, 150);
5748       DBMS_SQL.define_column(v_cursor_id, 66, v_type.attribute14, 150);
5749       DBMS_SQL.define_column(v_cursor_id, 67, v_type.attribute15, 150);
5750       DBMS_SQL.define_column(v_cursor_id, 68, v_type.attribute_category, 150);
5751       DBMS_SQL.define_column(v_cursor_id, 69, v_type.owner, 100);
5752       DBMS_SQL.define_column(v_cursor_id, 70, v_type.cust_account_number, 30);
5753       DBMS_SQL.define_column(v_cursor_id, 71, v_type.cust_account_id);
5754       DBMS_SQL.define_column(v_cursor_id, 72, v_type.owner_territory_id);
5755       DBMS_SQL.define_column(v_cursor_id, 73, v_type.creation_date);
5756       DBMS_SQL.define_column(v_cursor_id, 74, v_type.escalation_level, 30);
5757       DBMS_SQL.define_column(v_cursor_id, 75, v_type.object_version_number);
5758       DBMS_SQL.define_column(v_cursor_id, 76, v_type.location_id);
5759       v_dummy      := DBMS_SQL.EXECUTE(v_cursor_id);
5760       v_cnt        := 0;
5761 
5762       LOOP
5763         EXIT WHEN(DBMS_SQL.fetch_rows(v_cursor_id) = 0);
5764         v_cnt         := v_cnt + 1;
5765         -- retrieve the rows from the buffer
5766         DBMS_SQL.column_value(v_cursor_id, 1, v_type.task_id);
5767         DBMS_SQL.column_value(v_cursor_id, 2, v_type.task_number);
5768         DBMS_SQL.column_value(v_cursor_id, 3, v_type.task_name);
5769         DBMS_SQL.column_value(v_cursor_id, 4, v_type.description);
5770         DBMS_SQL.column_value(v_cursor_id, 5, v_type.task_type_id);
5771         DBMS_SQL.column_value(v_cursor_id, 6, v_type.task_type);
5772         DBMS_SQL.column_value(v_cursor_id, 7, v_type.task_status_id);
5773         DBMS_SQL.column_value(v_cursor_id, 8, v_type.task_status);
5774         DBMS_SQL.column_value(v_cursor_id, 9, v_type.task_priority_id);
5775         DBMS_SQL.column_value(v_cursor_id, 10, v_type.task_priority);
5776         DBMS_SQL.column_value(v_cursor_id, 11, v_type.owner_type_code);
5777         DBMS_SQL.column_value(v_cursor_id, 12, v_type.owner_id);
5778         DBMS_SQL.column_value(v_cursor_id, 13, v_type.assigned_by_id);
5779         DBMS_SQL.column_value(v_cursor_id, 14, v_type.assigned_by_name);
5780         DBMS_SQL.column_value(v_cursor_id, 15, v_type.customer_id);
5781         DBMS_SQL.column_value(v_cursor_id, 16, v_type.customer_name);
5782         DBMS_SQL.column_value(v_cursor_id, 17, v_type.customer_number);
5783         DBMS_SQL.column_value(v_cursor_id, 18, v_type.address_id);
5784         DBMS_SQL.column_value(v_cursor_id, 19, v_type.planned_start_date);
5785         DBMS_SQL.column_value(v_cursor_id, 20, v_type.planned_end_date);
5786         DBMS_SQL.column_value(v_cursor_id, 21, v_type.scheduled_start_date);
5787         DBMS_SQL.column_value(v_cursor_id, 22, v_type.scheduled_end_date);
5788         DBMS_SQL.column_value(v_cursor_id, 23, v_type.actual_start_date);
5789         DBMS_SQL.column_value(v_cursor_id, 24, v_type.actual_end_date);
5790         DBMS_SQL.column_value(v_cursor_id, 25, v_type.object_type_code);
5791         DBMS_SQL.column_value(v_cursor_id, 26, v_type.object_id);
5792         DBMS_SQL.column_value(v_cursor_id, 27, v_type.obect_name);
5793         DBMS_SQL.column_value(v_cursor_id, 28, v_type.DURATION);
5794         DBMS_SQL.column_value(v_cursor_id, 29, v_type.duration_uom);
5795         DBMS_SQL.column_value(v_cursor_id, 30, v_type.planned_effort);
5796         DBMS_SQL.column_value(v_cursor_id, 31, v_type.planned_effort_uom);
5797         DBMS_SQL.column_value(v_cursor_id, 32, v_type.actual_effort);
5798         DBMS_SQL.column_value(v_cursor_id, 33, v_type.actual_effort_uom);
5799         DBMS_SQL.column_value(v_cursor_id, 34, v_type.percentage_complete);
5800         DBMS_SQL.column_value(v_cursor_id, 35, v_type.reason_code);
5801         DBMS_SQL.column_value(v_cursor_id, 36, v_type.private_flag);
5802         DBMS_SQL.column_value(v_cursor_id, 37, v_type.publish_flag);
5803         DBMS_SQL.column_value(v_cursor_id, 38, v_type.multi_booked_flag);
5804         DBMS_SQL.column_value(v_cursor_id, 39, v_type.milestone_flag);
5805         DBMS_SQL.column_value(v_cursor_id, 40, v_type.holiday_flag);
5806         DBMS_SQL.column_value(v_cursor_id, 41, v_type.workflow_process_id);
5807         DBMS_SQL.column_value(v_cursor_id, 42, v_type.notification_flag);
5808         DBMS_SQL.column_value(v_cursor_id, 43, v_type.notification_period);
5809         DBMS_SQL.column_value(v_cursor_id, 44, v_type.notification_period_uom);
5810         DBMS_SQL.column_value(v_cursor_id, 45, v_type.parent_task_id);
5811         DBMS_SQL.column_value(v_cursor_id, 46, v_type.alarm_start);
5812         DBMS_SQL.column_value(v_cursor_id, 47, v_type.alarm_start_uom);
5813         DBMS_SQL.column_value(v_cursor_id, 48, v_type.alarm_on);
5814         DBMS_SQL.column_value(v_cursor_id, 49, v_type.alarm_count);
5815         DBMS_SQL.column_value(v_cursor_id, 50, v_type.alarm_fired_count);
5816         DBMS_SQL.column_value(v_cursor_id, 51, v_type.alarm_interval);
5817         DBMS_SQL.column_value(v_cursor_id, 52, v_type.alarm_interval_uom);
5818         DBMS_SQL.column_value(v_cursor_id, 53, v_type.attribute1);
5819         DBMS_SQL.column_value(v_cursor_id, 54, v_type.attribute2);
5820         DBMS_SQL.column_value(v_cursor_id, 55, v_type.attribute3);
5821         DBMS_SQL.column_value(v_cursor_id, 56, v_type.attribute4);
5822         DBMS_SQL.column_value(v_cursor_id, 57, v_type.attribute5);
5823         DBMS_SQL.column_value(v_cursor_id, 58, v_type.attribute6);
5824         DBMS_SQL.column_value(v_cursor_id, 59, v_type.attribute7);
5825         DBMS_SQL.column_value(v_cursor_id, 60, v_type.attribute8);
5826         DBMS_SQL.column_value(v_cursor_id, 61, v_type.attribute9);
5827         DBMS_SQL.column_value(v_cursor_id, 62, v_type.attribute10);
5828         DBMS_SQL.column_value(v_cursor_id, 63, v_type.attribute11);
5829         DBMS_SQL.column_value(v_cursor_id, 64, v_type.attribute12);
5830         DBMS_SQL.column_value(v_cursor_id, 65, v_type.attribute13);
5831         DBMS_SQL.column_value(v_cursor_id, 66, v_type.attribute14);
5832         DBMS_SQL.column_value(v_cursor_id, 67, v_type.attribute15);
5833         DBMS_SQL.column_value(v_cursor_id, 68, v_type.attribute_category);
5834         DBMS_SQL.column_value(v_cursor_id, 69, v_type.owner);
5835         DBMS_SQL.column_value(v_cursor_id, 70, v_type.cust_account_number);
5836         DBMS_SQL.column_value(v_cursor_id, 71, v_type.cust_account_id);
5837         DBMS_SQL.column_value(v_cursor_id, 72, v_type.owner_territory_id);
5838         DBMS_SQL.column_value(v_cursor_id, 73, v_type.creation_date);
5839         DBMS_SQL.column_value(v_cursor_id, 74, v_type.escalation_level);
5840         DBMS_SQL.column_value(v_cursor_id, 75, v_type.object_version_number);
5841         DBMS_SQL.column_value(v_cursor_id, 76, v_type.location_id);
5842         --      'v_type.task_id:'||
5843         --       to_char(v_type.task_id));
5844         v_tbl(v_cnt)  := v_type;
5845       END LOOP;
5846 
5847       DBMS_SQL.close_cursor(v_cursor_id);
5848     END IF;   --p_query_or_next_code;
5849 
5850     -- copy records to be returned back
5851     x_total_retrieved  := v_tbl.COUNT;
5852 
5853     -- if table is empty do nothing
5854     IF (x_total_retrieved > 0) THEN
5855       IF (p_show_all = 'Y') THEN   -- return all the rows
5856         v_start  := v_tbl.FIRST;
5857         v_end    := v_tbl.LAST;
5858       ELSE
5859         v_start  := p_start_pointer;
5860         v_end    := p_start_pointer + p_rec_wanted - 1;
5861 
5862         IF (v_end > v_tbl.LAST) THEN
5863           v_end  := v_tbl.LAST;
5864         END IF;
5865       END IF;
5866 
5867       FOR v_cnt IN v_start .. v_end LOOP
5868         x_task_table(v_cnt)  := v_tbl(v_cnt);
5869       END LOOP;
5870     END IF;
5871 
5872     x_total_returned   := x_task_table.COUNT;
5873   EXCEPTION
5874     WHEN fnd_api.g_exc_error THEN
5875       x_return_status  := fnd_api.g_ret_sts_error;
5876       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5877     WHEN fnd_api.g_exc_unexpected_error THEN
5878       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5879       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5880     WHEN OTHERS THEN
5881       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5882 
5883       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
5884         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
5885       END IF;
5886 
5887       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5888   END query_task;
5889 
5890   PROCEDURE query_next_task(
5891     p_object_version_number IN            NUMBER
5892   , p_task_id               IN            jtf_tasks_v.task_id%TYPE
5893   ,   -- current task id
5894     p_query_type            IN            VARCHAR2 DEFAULT 'Dependency'
5895   ,   -- values Dependency or Date
5896     p_date_type             IN            VARCHAR2 DEFAULT NULL
5897   , p_date_start_or_end     IN            VARCHAR2 DEFAULT NULL
5898   ,   -- start or end
5899     p_owner_id              IN            jtf_tasks_v.owner_id%TYPE DEFAULT NULL
5900   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE DEFAULT NULL
5901   , p_assigned_by           IN            jtf_tasks_v.assigned_by_id%TYPE DEFAULT NULL
5902   , p_sort_data             IN            jtf_tasks_pub.sort_data
5903   , p_start_pointer         IN            NUMBER
5904   , p_rec_wanted            IN            NUMBER
5905   , p_show_all              IN            VARCHAR2 DEFAULT 'Y'
5906   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
5907   , x_task_table            OUT NOCOPY    jtf_tasks_pub.task_table_type
5908   , x_total_retrieved       OUT NOCOPY    NUMBER
5909   , x_total_returned        OUT NOCOPY    NUMBER
5910   , x_return_status         OUT NOCOPY    VARCHAR2
5911   , x_msg_count             OUT NOCOPY    NUMBER
5912   , x_msg_data              OUT NOCOPY    VARCHAR2
5913   ) IS
5914     -- declare variables
5915     l_api_name  VARCHAR2(30)           := 'QUERY_NEXT_TASK';
5916     v_cursor_id INTEGER;
5917     v_dummy     INTEGER;
5918     v_cnt       INTEGER;
5919     v_end       INTEGER;
5920     v_start     INTEGER;
5921     v_key_date  DATE;   -- stores date for query string
5922     v_find_date DATE;
5923     v_type      jtf_tasks_pub.task_rec;
5924 
5925     PROCEDURE create_sql_statement IS
5926       v_index       INTEGER;
5927       v_first       INTEGER;
5928       v_comma       VARCHAR2(5);
5929       v_where       VARCHAR2(2000);
5930       v_and         CHAR(1)        := 'N';
5931       v_date_sql    VARCHAR2(500);
5932       -- build the date field we are going to key on
5933       v_select_date VARCHAR2(50)   := UPPER(p_date_type || '_' || p_date_start_or_end || '_date');
5934       -- build the date field for the sub-query, always a 'start'
5935       v_start_date  VARCHAR2(50)   := UPPER(p_date_type || '_start_date');
5936 
5937       PROCEDURE add_to_sql_str(
5938         p_in    VARCHAR2
5939       ,   --value in parameter
5940         p_bind  VARCHAR2
5941       ,   --bind variable to use
5942         p_field VARCHAR2   --field associated with parameter
5943       ) IS
5944         v_str VARCHAR2(10);
5945       BEGIN   -- add_to_sql
5946         IF (p_in IS NOT NULL) THEN
5947           IF (v_and = 'N') THEN
5948             v_str  := ' ';
5949             v_and  := 'Y';
5950           ELSE
5951             v_str  := ' and ';
5952           END IF;
5953 
5954           v_where  := v_where || v_str || p_field || ' = :' || p_bind;
5955         END IF;
5956       END add_to_sql_str;
5957 
5958       PROCEDURE add_to_sql(
5959         p_in    NUMBER
5960       ,   --value in parameter
5961         p_bind  VARCHAR2
5962       ,   --bind variable to use
5963         p_field VARCHAR2   --field associated with parameter
5964       ) IS
5965       BEGIN
5966         add_to_sql_str(TO_CHAR(p_in), p_bind, p_field);
5967       END;
5968 
5969       PROCEDURE add_to_sql(
5970         p_in    DATE
5971       ,   --value in parameter
5972         p_bind  VARCHAR2
5973       ,   --bind variable to use
5974         p_field VARCHAR2   --field associated with parameter
5975       ) IS
5976       BEGIN
5977         add_to_sql_str(TO_CHAR(p_in, 'dd-mon-rrrr'), p_bind, p_field);
5978       END;
5979 
5980       PROCEDURE add_to_sql(
5981         p_in    VARCHAR2
5982       ,   --value in parameter
5983         p_bind  VARCHAR2
5984       ,   --bind variable to use
5985         p_field VARCHAR2   --field associated with parameter
5986       ) IS
5987       BEGIN
5988         add_to_sql_str(p_in, p_bind, p_field);
5989       END;
5990 
5991       FUNCTION get_date(p_date_field IN VARCHAR2, p_task_id IN NUMBER)
5992         RETURN DATE IS
5993           -- Commented out by SBARAT on 30/05/2006 for perf bug# 5213367
5994           /*cursor c_get_date is
5995             select decode (p_date_field,
5996              'PLANNED_START_DATE', planned_start_date,
5997              'PLANNED_END_DATE', planned_end_date,
5998              'SCHEDULED_START_DATE', scheduled_start_date,
5999              'SCHEDULED_END_DATE', scheduled_end_date,
6000              'ACTUAL_START_DATE', actual_start_date,
6001              'ACTUAL_END_DATE', actual_end_date, null)
6002         from jtf_tasks_v
6003         where task_id = p_task_id;*/
6004 
6005         -- Added by SBARAT on 30/05/2006 for perf bug# 5213367
6006         -- This query takea less sharable memory compared to previous one.
6007         CURSOR c_get_date IS
6008           SELECT DECODE(
6009                    p_date_field
6010                  , 'PLANNED_START_DATE', planned_start_date
6011                  , 'PLANNED_END_DATE', planned_end_date
6012                  , 'SCHEDULED_START_DATE', scheduled_start_date
6013                  , 'SCHEDULED_END_DATE', scheduled_end_date
6014                  , 'ACTUAL_START_DATE', actual_start_date
6015                  , 'ACTUAL_END_DATE', actual_end_date
6016                  , NULL
6017                  )
6018             FROM jtf_tasks_vl jta
6019                , jtf_task_types_tl jttt
6020                , jtf_task_types_b jttb
6021                , jtf_task_statuses_tl jtst
6022                , jtf_task_statuses_b jtsb
6023                , jtf_task_priorities_tl jtpt
6024                , jtf_objects_tl jtot
6025                , jtf_objects_b jtob
6026                , jtf_objects_tl jto2
6027            WHERE jta.task_id = p_task_id
6028              AND jta.task_type_id = jttb.task_type_id
6029              AND jta.task_status_id = jtsb.task_status_id
6030              AND (jta.deleted_flag <> 'Y' OR jta.deleted_flag IS NULL)
6031              AND jta.task_priority_id = jtpt.task_priority_id(+)
6032              AND jta.source_object_type_code = jtob.object_code
6033              AND jta.owner_type_code = jto2.object_code
6034              AND jttb.task_type_id <> 22
6035              AND NVL(jtpt.LANGUAGE, USERENV('lang')) = USERENV('lang')
6036              AND jttt.LANGUAGE = USERENV('lang')
6037              AND jttt.task_type_id = jta.task_type_id
6038              AND jtst.LANGUAGE = USERENV('lang')
6039              AND jtst.task_status_id = jta.task_status_id
6040              AND jtot.LANGUAGE = USERENV('lang')
6041              AND jtot.object_code = jtob.object_code
6042              AND jto2.LANGUAGE = USERENV('lang');
6043 
6044         v_return_date DATE;
6045       BEGIN
6046         OPEN c_get_date;
6047 
6048         FETCH c_get_date
6049          INTO v_return_date;
6050 
6051         IF (c_get_date%NOTFOUND) THEN
6052           CLOSE c_get_date;
6053 
6054           fnd_message.set_name('JTF', 'JTF_TK_NO_DATE');
6055           fnd_msg_pub.ADD;
6056           RAISE fnd_api.g_exc_error;
6057         ELSE
6058           CLOSE c_get_date;
6059         END IF;
6060 
6061         RETURN(v_return_date);
6062       END get_date;
6063     BEGIN   --create_sql_statement
6064       v_select  :=
6065            'select '
6066         || 'v.task_id,'
6067         || 'v.task_number,'
6068         || 'v.task_name,'
6069         || 'v.description,'
6070         || 'v.task_type_id,'
6071         || 'v.task_type,'
6072         || 'v.task_status_id,'
6073         || 'v.task_status,'
6074         || 'v.task_priority_id,'
6075         || 'v.task_priority,'
6076         || 'v.owner_type_code,'
6077         || 'v.owner_id,'
6078         || 'v.assigned_by_id,'
6079         || 'v.assigned_by_name,'
6080         || 'v.customer_id,'
6081         || 'v.customer_name,'
6082         || 'v.customer_number,'
6083         || 'v.address_id,'
6084         || 'v.planned_start_date,'
6085         || 'v.planned_end_date,'
6086         || 'v.scheduled_start_date,'
6087         || 'v.scheduled_end_date,'
6088         || 'v.actual_start_date,'
6089         || 'v.actual_end_date,'
6090         || 'v.source_object_type_code,'
6091         || 'v.source_object_id,'
6092         || 'v.source_object_name,'
6093         || 'v.duration,'
6094         || 'v.duration_uom,'
6095         || 'v.planned_effort,'
6096         || 'v.planned_effort_uom,'
6097         || 'v.actual_effort,'
6098         || 'v.actual_effort_uom,'
6099         || 'v.percentage_complete,'
6100         || 'v.reason_code,'
6101         || 'v.private_flag,'
6102         || 'v.publish_flag,'
6103         || 'v.multi_booked_flag,'
6104         || 'v.milestone_flag,'
6105         || 'v.holiday_flag,'
6106         || 'v.workflow_process_id,'
6107         || 'v.notification_flag,'
6108         || 'v.notification_period,'
6109         || 'v.notification_period_uom,'
6110         || 'v.parent_task_id,'
6111         || 'v.alarm_start,'
6112         || 'v.alarm_start_uom,'
6113         || 'v.alarm_on,'
6114         || 'v.alarm_count,'
6115         || 'v.alarm_fired_count,'
6116         || 'v.alarm_interval,'
6117         || 'v.alarm_interval_uom,'
6118         || 'v.attribute1,'
6119         || 'v.attribute2,'
6120         || 'v.attribute3,'
6121         || 'v.attribute4,'
6122         || 'v.attribute5,'
6123         || 'v.attribute6,'
6124         || 'v.attribute7,'
6125         || 'v.attribute8,'
6126         || 'v.attribute9,'
6127         || 'v.attribute10,'
6128         || 'v.attribute11,'
6129         || 'v.attribute12,'
6130         || 'v.attribute13,'
6131         || 'v.attribute14,'
6132         || 'v.attribute15,'
6133         || 'v.attribute_category '
6134         || 'from jtf_tasks_v v ';
6135 
6136       IF (p_query_type = 'DEPENDENCY') THEN
6137         v_select  := v_select || ', jtf_task_depends d ';
6138         add_to_sql(p_task_id, 'b1', 'd.dependent_on_task_id');
6139 
6140         IF (v_where IS NOT NULL) THEN
6141           v_select  := v_select || ' where v.task_id = d.task_id and ' || v_where;
6142         END IF;
6143       ELSE   -- must be assigned or owner
6144         v_key_date  := get_date(v_select_date, p_task_id);
6145 
6146         IF (p_query_type = 'ASSIGNED') THEN
6147           v_date_sql  :=
6148                'select min('
6149             || v_start_date
6150             || ') from jtf_tasks_v where assigned_by_id = '
6151             || TO_CHAR(p_assigned_by)
6152             || ' and '
6153             || v_start_date
6154             || ' > :1 ';
6155 
6156           EXECUTE IMMEDIATE v_date_sql
6157                        INTO v_find_date
6158                       USING v_key_date;
6159 
6160           add_to_sql(p_assigned_by, 'b10', 'assigned_by_id');
6161           v_where     := v_where || ' and ' || v_start_date || ' = :b11 ';
6162         ELSIF(p_query_type = 'OWNER') THEN
6163           v_date_sql  :=
6164                'select min('
6165             || v_start_date
6166             || ') from jtf_tasks_v where owner_type_code = '''
6167             || p_owner_type_code
6168             || ''' and '
6169             || 'owner_id = '
6170             || TO_CHAR(p_owner_id)
6171             || ' and '
6172             || v_start_date
6173             || ' > :1 ';
6174 
6175           EXECUTE IMMEDIATE v_date_sql
6176                        INTO v_find_date
6177                       USING v_key_date;
6178 
6179           add_to_sql(p_owner_type_code, 'b100', 'owner_type_code');
6180           add_to_sql(p_owner_id, 'b101', 'owner_id');
6181           v_where     := v_where || ' and ' || v_start_date || ' = :b102 ';
6182         END IF;
6183 
6184         IF (v_where IS NOT NULL) THEN
6185           v_select  := v_select || ' where ' || v_where;
6186         END IF;
6187       END IF;
6188 
6189       IF (p_sort_data.COUNT > 0) THEN   --there is a sort preference
6190         v_select  := v_select || ' order by ';
6191         v_index   := p_sort_data.FIRST;
6192         v_first   := v_index;
6193 
6194         LOOP
6195           IF (v_first = v_index) THEN
6196             v_comma  := ' ';
6197           ELSE
6198             v_comma  := ', ';
6199           END IF;
6200 
6201           v_select  := v_select || v_comma || p_sort_data(v_index).field_name || ' ';
6202 
6203           -- ascending or descending order
6204           IF (p_sort_data(v_index).asc_dsc_flag = 'A') THEN
6205             v_select  := v_select || 'asc ';
6206           ELSIF(p_sort_data(v_index).asc_dsc_flag = 'D') THEN
6207             v_select  := v_select || 'desc ';
6208           END IF;
6209 
6210           EXIT WHEN v_index = p_sort_data.LAST;
6211           v_index   := p_sort_data.NEXT(v_index);
6212         END LOOP;
6213       END IF;
6214     END create_sql_statement;
6215   BEGIN   -- query task
6216     x_return_status    := fnd_api.g_ret_sts_success;
6217     x_task_table.DELETE;
6218 
6219     IF (p_query_or_next_code = 'Q') THEN
6220       v_n_tbl.DELETE;
6221       create_sql_statement;
6222       --dump_long_line('v_sel:',v_select);
6223       v_cursor_id  := DBMS_SQL.open_cursor;
6224       DBMS_SQL.parse(v_cursor_id, v_select, DBMS_SQL.v7);
6225 
6226       -- bind variables only if they added to the sql statement
6227       IF (p_query_type = 'DEPENDENCY') THEN
6228         IF (p_task_id IS NOT NULL) THEN
6229           DBMS_SQL.bind_variable(v_cursor_id, ':b1', p_task_id);
6230         END IF;
6231       ELSIF(p_query_type = 'ASSIGNED') THEN
6232         DBMS_SQL.bind_variable(v_cursor_id, ':b10', p_assigned_by);
6233         DBMS_SQL.bind_variable(v_cursor_id, ':b11', v_find_date);
6234       ELSIF(p_query_type = 'OWNER') THEN
6235         DBMS_SQL.bind_variable(v_cursor_id, ':b100', p_owner_type_code);
6236         DBMS_SQL.bind_variable(v_cursor_id, ':b101', p_owner_id);
6237         DBMS_SQL.bind_variable(v_cursor_id, ':b102', v_find_date);
6238       END IF;
6239 
6240       -- define the output columns
6241       DBMS_SQL.define_column(v_cursor_id, 1, v_type.task_id);
6242       DBMS_SQL.define_column(v_cursor_id, 2, v_type.task_number, 30);
6243       DBMS_SQL.define_column(v_cursor_id, 3, v_type.task_name, 80);
6244       DBMS_SQL.define_column(v_cursor_id, 4, v_type.description, 4000);
6245       DBMS_SQL.define_column(v_cursor_id, 5, v_type.task_type_id);
6246       DBMS_SQL.define_column(v_cursor_id, 6, v_type.task_type, 30);
6247       DBMS_SQL.define_column(v_cursor_id, 7, v_type.task_status_id);
6248       DBMS_SQL.define_column(v_cursor_id, 8, v_type.task_status, 30);
6249       DBMS_SQL.define_column(v_cursor_id, 9, v_type.task_priority_id);
6250       DBMS_SQL.define_column(v_cursor_id, 10, v_type.task_priority, 30);
6251       DBMS_SQL.define_column(v_cursor_id, 11, v_type.owner_type_code, 10);
6252       DBMS_SQL.define_column(v_cursor_id, 12, v_type.owner_id);
6253       DBMS_SQL.define_column(v_cursor_id, 13, v_type.assigned_by_id);
6254       DBMS_SQL.define_column(v_cursor_id, 14, v_type.assigned_by_name, 100);
6255       DBMS_SQL.define_column(v_cursor_id, 15, v_type.customer_id);
6256       DBMS_SQL.define_column(v_cursor_id, 16, v_type.customer_name, 255);
6257       DBMS_SQL.define_column(v_cursor_id, 17, v_type.customer_number, 30);
6258       DBMS_SQL.define_column(v_cursor_id, 18, v_type.address_id);
6259       DBMS_SQL.define_column(v_cursor_id, 19, v_type.planned_start_date);
6260       DBMS_SQL.define_column(v_cursor_id, 20, v_type.planned_end_date);
6261       DBMS_SQL.define_column(v_cursor_id, 21, v_type.scheduled_start_date);
6262       DBMS_SQL.define_column(v_cursor_id, 22, v_type.scheduled_end_date);
6263       DBMS_SQL.define_column(v_cursor_id, 23, v_type.actual_start_date);
6264       DBMS_SQL.define_column(v_cursor_id, 24, v_type.actual_end_date);
6265       DBMS_SQL.define_column(v_cursor_id, 25, v_type.object_type_code, 30);
6266       DBMS_SQL.define_column(v_cursor_id, 26, v_type.object_id);
6267       DBMS_SQL.define_column(v_cursor_id, 27, v_type.obect_name, 30);
6268       DBMS_SQL.define_column(v_cursor_id, 28, v_type.DURATION);
6269       DBMS_SQL.define_column(v_cursor_id, 29, v_type.duration_uom, 3);
6270       DBMS_SQL.define_column(v_cursor_id, 30, v_type.planned_effort);
6271       DBMS_SQL.define_column(v_cursor_id, 31, v_type.planned_effort_uom, 3);
6272       DBMS_SQL.define_column(v_cursor_id, 32, v_type.actual_effort);
6273       DBMS_SQL.define_column(v_cursor_id, 33, v_type.actual_effort_uom, 3);
6274       DBMS_SQL.define_column(v_cursor_id, 34, v_type.percentage_complete);
6275       DBMS_SQL.define_column(v_cursor_id, 35, v_type.reason_code, 30);
6276       DBMS_SQL.define_column(v_cursor_id, 36, v_type.private_flag, 1);
6277       DBMS_SQL.define_column(v_cursor_id, 37, v_type.publish_flag, 1);
6278       DBMS_SQL.define_column(v_cursor_id, 38, v_type.multi_booked_flag, 1);
6279       DBMS_SQL.define_column(v_cursor_id, 39, v_type.milestone_flag, 1);
6280       DBMS_SQL.define_column(v_cursor_id, 40, v_type.holiday_flag, 1);
6281       DBMS_SQL.define_column(v_cursor_id, 41, v_type.workflow_process_id);
6282       DBMS_SQL.define_column(v_cursor_id, 46, v_type.notification_flag, 1);
6283       DBMS_SQL.define_column(v_cursor_id, 47, v_type.notification_period);
6284       DBMS_SQL.define_column(v_cursor_id, 48, v_type.notification_period_uom, 3);
6285       DBMS_SQL.define_column(v_cursor_id, 49, v_type.parent_task_id);
6286       DBMS_SQL.define_column(v_cursor_id, 50, v_type.alarm_start);
6287       DBMS_SQL.define_column(v_cursor_id, 51, v_type.alarm_start_uom, 3);
6288       DBMS_SQL.define_column(v_cursor_id, 52, v_type.alarm_on, 1);
6289       DBMS_SQL.define_column(v_cursor_id, 53, v_type.alarm_count);
6290       DBMS_SQL.define_column(v_cursor_id, 54, v_type.alarm_fired_count);
6291       DBMS_SQL.define_column(v_cursor_id, 55, v_type.alarm_interval);
6292       DBMS_SQL.define_column(v_cursor_id, 56, v_type.alarm_interval_uom, 3);
6293       DBMS_SQL.define_column(v_cursor_id, 57, v_type.attribute1, 150);
6294       DBMS_SQL.define_column(v_cursor_id, 58, v_type.attribute2, 150);
6295       DBMS_SQL.define_column(v_cursor_id, 59, v_type.attribute3, 150);
6296       DBMS_SQL.define_column(v_cursor_id, 60, v_type.attribute4, 150);
6297       DBMS_SQL.define_column(v_cursor_id, 61, v_type.attribute5, 150);
6298       DBMS_SQL.define_column(v_cursor_id, 62, v_type.attribute6, 150);
6299       DBMS_SQL.define_column(v_cursor_id, 63, v_type.attribute7, 150);
6300       DBMS_SQL.define_column(v_cursor_id, 64, v_type.attribute8, 150);
6301       DBMS_SQL.define_column(v_cursor_id, 65, v_type.attribute9, 150);
6302       DBMS_SQL.define_column(v_cursor_id, 66, v_type.attribute10, 150);
6303       DBMS_SQL.define_column(v_cursor_id, 67, v_type.attribute11, 150);
6304       DBMS_SQL.define_column(v_cursor_id, 68, v_type.attribute12, 150);
6305       DBMS_SQL.define_column(v_cursor_id, 69, v_type.attribute13, 150);
6306       DBMS_SQL.define_column(v_cursor_id, 70, v_type.attribute14, 150);
6307       DBMS_SQL.define_column(v_cursor_id, 71, v_type.attribute15, 150);
6308       DBMS_SQL.define_column(v_cursor_id, 72, v_type.attribute_category, 150);
6309       v_dummy      := DBMS_SQL.EXECUTE(v_cursor_id);
6310       v_cnt        := 0;
6311 
6312       LOOP
6313         EXIT WHEN(DBMS_SQL.fetch_rows(v_cursor_id) = 0);
6314         v_cnt           := v_cnt + 1;
6315         -- retrieve the rows from the buffer
6316         DBMS_SQL.column_value(v_cursor_id, 1, v_type.task_id);
6317         DBMS_SQL.column_value(v_cursor_id, 2, v_type.task_number);
6318         DBMS_SQL.column_value(v_cursor_id, 3, v_type.task_name);
6319         DBMS_SQL.column_value(v_cursor_id, 4, v_type.description);
6320         DBMS_SQL.column_value(v_cursor_id, 5, v_type.task_type_id);
6321         DBMS_SQL.column_value(v_cursor_id, 6, v_type.task_type);
6322         DBMS_SQL.column_value(v_cursor_id, 7, v_type.task_status_id);
6323         DBMS_SQL.column_value(v_cursor_id, 8, v_type.task_status);
6324         DBMS_SQL.column_value(v_cursor_id, 9, v_type.task_priority_id);
6325         DBMS_SQL.column_value(v_cursor_id, 10, v_type.task_priority);
6326         DBMS_SQL.column_value(v_cursor_id, 11, v_type.owner_type_code);
6327         DBMS_SQL.column_value(v_cursor_id, 12, v_type.owner_id);
6328         DBMS_SQL.column_value(v_cursor_id, 13, v_type.assigned_by_id);
6329         DBMS_SQL.column_value(v_cursor_id, 14, v_type.assigned_by_name);
6330         DBMS_SQL.column_value(v_cursor_id, 15, v_type.customer_id);
6331         DBMS_SQL.column_value(v_cursor_id, 16, v_type.customer_name);
6332         DBMS_SQL.column_value(v_cursor_id, 17, v_type.customer_number);
6333         DBMS_SQL.column_value(v_cursor_id, 18, v_type.address_id);
6334         DBMS_SQL.column_value(v_cursor_id, 19, v_type.planned_start_date);
6335         DBMS_SQL.column_value(v_cursor_id, 20, v_type.planned_end_date);
6336         DBMS_SQL.column_value(v_cursor_id, 21, v_type.scheduled_start_date);
6337         DBMS_SQL.column_value(v_cursor_id, 22, v_type.scheduled_end_date);
6338         DBMS_SQL.column_value(v_cursor_id, 23, v_type.actual_start_date);
6339         DBMS_SQL.column_value(v_cursor_id, 24, v_type.actual_end_date);
6340         DBMS_SQL.column_value(v_cursor_id, 25, v_type.object_type_code);
6341         DBMS_SQL.column_value(v_cursor_id, 26, v_type.object_id);
6342         DBMS_SQL.column_value(v_cursor_id, 27, v_type.obect_name);
6343         DBMS_SQL.column_value(v_cursor_id, 28, v_type.DURATION);
6344         DBMS_SQL.column_value(v_cursor_id, 29, v_type.duration_uom);
6345         DBMS_SQL.column_value(v_cursor_id, 30, v_type.planned_effort);
6346         DBMS_SQL.column_value(v_cursor_id, 31, v_type.planned_effort_uom);
6347         DBMS_SQL.column_value(v_cursor_id, 32, v_type.actual_effort);
6348         DBMS_SQL.column_value(v_cursor_id, 33, v_type.actual_effort_uom);
6349         DBMS_SQL.column_value(v_cursor_id, 34, v_type.percentage_complete);
6350         DBMS_SQL.column_value(v_cursor_id, 35, v_type.reason_code);
6351         DBMS_SQL.column_value(v_cursor_id, 36, v_type.private_flag);
6352         DBMS_SQL.column_value(v_cursor_id, 37, v_type.publish_flag);
6353         DBMS_SQL.column_value(v_cursor_id, 38, v_type.multi_booked_flag);
6354         DBMS_SQL.column_value(v_cursor_id, 39, v_type.milestone_flag);
6355         DBMS_SQL.column_value(v_cursor_id, 40, v_type.holiday_flag);
6356         DBMS_SQL.column_value(v_cursor_id, 41, v_type.workflow_process_id);
6357         DBMS_SQL.column_value(v_cursor_id, 46, v_type.notification_flag);
6358         DBMS_SQL.column_value(v_cursor_id, 47, v_type.notification_period);
6359         DBMS_SQL.column_value(v_cursor_id, 48, v_type.notification_period_uom);
6360         DBMS_SQL.column_value(v_cursor_id, 49, v_type.parent_task_id);
6361         DBMS_SQL.column_value(v_cursor_id, 50, v_type.alarm_start);
6362         DBMS_SQL.column_value(v_cursor_id, 51, v_type.alarm_start_uom);
6363         DBMS_SQL.column_value(v_cursor_id, 52, v_type.alarm_on);
6364         DBMS_SQL.column_value(v_cursor_id, 53, v_type.alarm_count);
6365         DBMS_SQL.column_value(v_cursor_id, 54, v_type.alarm_fired_count);
6366         DBMS_SQL.column_value(v_cursor_id, 55, v_type.alarm_interval);
6367         DBMS_SQL.column_value(v_cursor_id, 56, v_type.alarm_interval_uom);
6368         DBMS_SQL.column_value(v_cursor_id, 57, v_type.attribute1);
6369         DBMS_SQL.column_value(v_cursor_id, 58, v_type.attribute2);
6370         DBMS_SQL.column_value(v_cursor_id, 59, v_type.attribute3);
6371         DBMS_SQL.column_value(v_cursor_id, 60, v_type.attribute4);
6372         DBMS_SQL.column_value(v_cursor_id, 61, v_type.attribute5);
6373         DBMS_SQL.column_value(v_cursor_id, 62, v_type.attribute6);
6374         DBMS_SQL.column_value(v_cursor_id, 63, v_type.attribute7);
6375         DBMS_SQL.column_value(v_cursor_id, 64, v_type.attribute8);
6376         DBMS_SQL.column_value(v_cursor_id, 65, v_type.attribute9);
6377         DBMS_SQL.column_value(v_cursor_id, 66, v_type.attribute10);
6378         DBMS_SQL.column_value(v_cursor_id, 67, v_type.attribute11);
6379         DBMS_SQL.column_value(v_cursor_id, 68, v_type.attribute12);
6380         DBMS_SQL.column_value(v_cursor_id, 69, v_type.attribute13);
6381         DBMS_SQL.column_value(v_cursor_id, 70, v_type.attribute14);
6382         DBMS_SQL.column_value(v_cursor_id, 71, v_type.attribute15);
6383         DBMS_SQL.column_value(v_cursor_id, 72, v_type.attribute_category);
6384         --       'v_type.task_id:'||
6385         --       to_char(v_type.task_id));
6386         v_n_tbl(v_cnt)  := v_type;
6387       END LOOP;
6388     --dbms_sql.close_cursor(v_cursor_id);
6389     END IF;   --p_query_or_next_code;
6390 
6391     -- copy records to be returned back
6392     x_total_retrieved  := v_n_tbl.COUNT;
6393 
6394     -- if table is empty do nothing
6395     IF (x_total_retrieved > 0) THEN
6396       IF (p_show_all = 'Y') THEN   -- return all the rows
6397         v_start  := v_n_tbl.FIRST;
6398         v_end    := v_n_tbl.LAST;
6399       ELSE
6400         v_start  := p_start_pointer;
6401         v_end    := p_start_pointer + p_rec_wanted - 1;
6402 
6403         IF (v_end > v_n_tbl.LAST) THEN
6404           v_end  := v_n_tbl.LAST;
6405         END IF;
6406       END IF;
6407 
6408       FOR v_cnt IN v_start .. v_end LOOP
6409         x_task_table(v_cnt)  := v_n_tbl(v_cnt);
6410       END LOOP;
6411     END IF;
6412 
6413     x_total_returned   := x_task_table.COUNT;
6414   EXCEPTION
6415     WHEN fnd_api.g_exc_error THEN
6416       x_return_status  := fnd_api.g_ret_sts_error;
6417       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6418     WHEN fnd_api.g_exc_unexpected_error THEN
6419       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6420       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6421     WHEN OTHERS THEN
6422       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6423 
6424       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
6425         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
6426       END IF;
6427 
6428       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6429   END query_next_task;
6430 END;