DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_TASKS_PUB

Source


1 PACKAGE BODY jtf_tasks_pub AS
2   /* $Header: jtfptktb.pls 120.17 2009/09/07 13:15:43 anangupt ship $ */
3   g_entity         CONSTANT jtf_tasks_b.entity%TYPE                        := 'TASK';
4   g_free_busy_type CONSTANT jtf_task_all_assignments.free_busy_type%TYPE   := 'FREE';
5 
6   -- new version without table type parameters
7   -- Remove the fix of Bug 2152549
8   PROCEDURE create_task(
9     p_api_version             IN            NUMBER
10   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
11   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
12   , p_task_id                 IN            NUMBER DEFAULT NULL
13   , p_task_name               IN            VARCHAR2
14   , p_task_type_name          IN            VARCHAR2 DEFAULT NULL
15   , p_task_type_id            IN            NUMBER DEFAULT NULL
16   , p_description             IN            VARCHAR2 DEFAULT NULL
17   , p_task_status_name        IN            VARCHAR2 DEFAULT NULL
18   , p_task_status_id          IN            NUMBER DEFAULT NULL
19   , p_task_priority_name      IN            VARCHAR2 DEFAULT NULL
20   , p_task_priority_id        IN            NUMBER DEFAULT NULL
21   , p_owner_type_name         IN            VARCHAR2 DEFAULT NULL
22   , p_owner_type_code         IN            VARCHAR2 DEFAULT NULL
23   , p_owner_id                IN            NUMBER DEFAULT NULL
24   , p_owner_territory_id      IN            NUMBER DEFAULT NULL
25   , p_assigned_by_name        IN            VARCHAR2 DEFAULT NULL
26   , p_assigned_by_id          IN            NUMBER DEFAULT NULL
27   , p_customer_number         IN            VARCHAR2 DEFAULT NULL
28   , p_customer_id             IN            NUMBER DEFAULT NULL
29   , p_cust_account_number     IN            VARCHAR2 DEFAULT NULL
30   , p_cust_account_id         IN            NUMBER DEFAULT NULL
31   , p_address_id              IN            NUMBER DEFAULT NULL
32   , p_address_number          IN            VARCHAR2 DEFAULT NULL
33   , p_planned_start_date      IN            DATE DEFAULT NULL
34   , p_planned_end_date        IN            DATE DEFAULT NULL
35   , p_scheduled_start_date    IN            DATE DEFAULT NULL
36   , p_scheduled_end_date      IN            DATE DEFAULT NULL
37   , p_actual_start_date       IN            DATE DEFAULT NULL
38   , p_actual_end_date         IN            DATE DEFAULT NULL
39   , p_timezone_id             IN            NUMBER DEFAULT NULL
40   , p_timezone_name           IN            VARCHAR2 DEFAULT NULL
41   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
42   , p_source_object_id        IN            NUMBER DEFAULT NULL
43   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
44   , p_duration                IN            NUMBER DEFAULT NULL
45   , p_duration_uom            IN            VARCHAR2 DEFAULT NULL
46   , p_planned_effort          IN            NUMBER DEFAULT NULL
47   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT NULL
48   , p_actual_effort           IN            NUMBER DEFAULT NULL
49   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT NULL
50   , p_percentage_complete     IN            NUMBER DEFAULT NULL
51   , p_reason_code             IN            VARCHAR2 DEFAULT NULL
52   , p_private_flag            IN            VARCHAR2 DEFAULT NULL
53   , p_publish_flag            IN            VARCHAR2 DEFAULT NULL
54   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT NULL
55   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT NULL
56   , p_milestone_flag          IN            VARCHAR2 DEFAULT NULL
57   , p_holiday_flag            IN            VARCHAR2 DEFAULT NULL
58   , p_billable_flag           IN            VARCHAR2 DEFAULT NULL
59   , p_bound_mode_code         IN            VARCHAR2 DEFAULT NULL
60   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT NULL
61   , p_workflow_process_id     IN            NUMBER DEFAULT NULL
62   , p_notification_flag       IN            VARCHAR2 DEFAULT NULL
63   , p_notification_period     IN            NUMBER DEFAULT NULL
64   , p_notification_period_uom IN            VARCHAR2 DEFAULT NULL
65   , p_parent_task_number      IN            VARCHAR2 DEFAULT NULL
66   , p_parent_task_id          IN            NUMBER DEFAULT NULL
67   , p_alarm_start             IN            NUMBER DEFAULT NULL
68   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT NULL
69   , p_alarm_on                IN            VARCHAR2 DEFAULT NULL
70   , p_alarm_count             IN            NUMBER DEFAULT NULL
71   , p_alarm_interval          IN            NUMBER DEFAULT NULL
72   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT NULL
73   , p_palm_flag               IN            VARCHAR2 DEFAULT NULL
74   , p_wince_flag              IN            VARCHAR2 DEFAULT NULL
75   , p_laptop_flag             IN            VARCHAR2 DEFAULT NULL
76   , p_device1_flag            IN            VARCHAR2 DEFAULT NULL
77   , p_device2_flag            IN            VARCHAR2 DEFAULT NULL
78   , p_device3_flag            IN            VARCHAR2 DEFAULT NULL
79   , p_costs                   IN            NUMBER DEFAULT NULL
80   , p_currency_code           IN            VARCHAR2 DEFAULT NULL
81   , p_escalation_level        IN            VARCHAR2 DEFAULT NULL
82   , x_return_status           OUT NOCOPY    VARCHAR2
83   , x_msg_count               OUT NOCOPY    NUMBER
84   , x_msg_data                OUT NOCOPY    VARCHAR2
85   , x_task_id                 OUT NOCOPY    NUMBER
86   , p_attribute1              IN            VARCHAR2 DEFAULT NULL
87   , p_attribute2              IN            VARCHAR2 DEFAULT NULL
88   , p_attribute3              IN            VARCHAR2 DEFAULT NULL
89   , p_attribute4              IN            VARCHAR2 DEFAULT NULL
90   , p_attribute5              IN            VARCHAR2 DEFAULT NULL
91   , p_attribute6              IN            VARCHAR2 DEFAULT NULL
92   , p_attribute7              IN            VARCHAR2 DEFAULT NULL
93   , p_attribute8              IN            VARCHAR2 DEFAULT NULL
94   , p_attribute9              IN            VARCHAR2 DEFAULT NULL
95   , p_attribute10             IN            VARCHAR2 DEFAULT NULL
96   , p_attribute11             IN            VARCHAR2 DEFAULT NULL
97   , p_attribute12             IN            VARCHAR2 DEFAULT NULL
98   , p_attribute13             IN            VARCHAR2 DEFAULT NULL
99   , p_attribute14             IN            VARCHAR2 DEFAULT NULL
100   , p_attribute15             IN            VARCHAR2 DEFAULT NULL
101   , p_attribute_category      IN            VARCHAR2 DEFAULT NULL
102   , p_date_selected           IN            VARCHAR2 DEFAULT NULL
103   , p_category_id             IN            NUMBER DEFAULT NULL
104   , p_show_on_calendar        IN            VARCHAR2 DEFAULT NULL
105   , p_owner_status_id         IN            NUMBER DEFAULT NULL
106   , p_template_id             IN            NUMBER DEFAULT NULL
107   , p_template_group_id       IN            NUMBER DEFAULT NULL
108   , p_enable_workflow         IN            VARCHAR2
109   , p_abort_workflow          IN            VARCHAR2
110   ) IS
111     l_api_version CONSTANT NUMBER       := 1.0;
112     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK';
113   BEGIN
114     SAVEPOINT create_task_pub2;
115     x_return_status  := fnd_api.g_ret_sts_success;
116 
117     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
118       RAISE fnd_api.g_exc_unexpected_error;
119     END IF;
120 
121     IF fnd_api.to_boolean(p_init_msg_list) THEN
122       fnd_msg_pub.initialize;
123     END IF;
124 
125     -- call new version, passing defaults for new functionality
126     -- Remove the fix of Bug 2152549: call create_task_b which is non-overloading procedure
127     create_task(
128       p_api_version                => p_api_version
129     , p_init_msg_list              => p_init_msg_list
130     , p_commit                     => fnd_api.g_false
131     , p_task_id                    => p_task_id
132     , p_task_name                  => p_task_name
133     , p_task_type_name             => p_task_type_name
134     , p_task_type_id               => p_task_type_id
135     , p_description                => p_description
136     , p_task_status_name           => p_task_status_name
137     , p_task_status_id             => p_task_status_id
138     , p_task_priority_name         => p_task_priority_name
139     , p_task_priority_id           => p_task_priority_id
140     , p_owner_type_name            => p_owner_type_name
141     , p_owner_type_code            => p_owner_type_code
142     , p_owner_id                   => p_owner_id
143     , p_owner_territory_id         => p_owner_territory_id
144     , p_assigned_by_name           => p_assigned_by_name
145     , p_assigned_by_id             => p_assigned_by_id
146     , p_customer_number            => p_customer_number
147     , p_customer_id                => p_customer_id
148     , p_cust_account_number        => p_cust_account_number
149     , p_cust_account_id            => p_cust_account_id
150     , p_address_id                 => p_address_id
151     , p_address_number             => p_address_number
152     , p_planned_start_date         => p_planned_start_date
153     , p_planned_end_date           => p_planned_end_date
154     , p_scheduled_start_date       => p_scheduled_start_date
155     , p_scheduled_end_date         => p_scheduled_end_date
156     , p_actual_start_date          => p_actual_start_date
157     , p_actual_end_date            => p_actual_end_date
158     , p_timezone_id                => p_timezone_id
159     , p_timezone_name              => p_timezone_name
160     , p_source_object_type_code    => p_source_object_type_code
161     , p_source_object_id           => p_source_object_id
162     , p_source_object_name         => p_source_object_name
163     , p_duration                   => p_duration
164     , p_duration_uom               => p_duration_uom
165     , p_planned_effort             => p_planned_effort
166     , p_planned_effort_uom         => p_planned_effort_uom
167     , p_actual_effort              => p_actual_effort
168     , p_actual_effort_uom          => p_actual_effort_uom
169     , p_percentage_complete        => p_percentage_complete
170     , p_reason_code                => p_reason_code
171     , p_private_flag               => p_private_flag
172     , p_publish_flag               => p_publish_flag
173     , p_restrict_closure_flag      => p_restrict_closure_flag
174     , p_multi_booked_flag          => p_multi_booked_flag
175     , p_milestone_flag             => p_milestone_flag
176     , p_holiday_flag               => p_holiday_flag
177     , p_billable_flag              => p_billable_flag
178     , p_bound_mode_code            => p_bound_mode_code
179     , p_soft_bound_flag            => p_soft_bound_flag
180     , p_workflow_process_id        => p_workflow_process_id
181     , p_notification_flag          => p_notification_flag
182     , p_notification_period        => p_notification_period
183     , p_notification_period_uom    => p_notification_period_uom
184     , p_parent_task_number         => p_parent_task_number
185     , p_parent_task_id             => p_parent_task_id
186     , p_alarm_start                => p_alarm_start
187     , p_alarm_start_uom            => p_alarm_start_uom
188     , p_alarm_on                   => p_alarm_on
189     , p_alarm_count                => p_alarm_count
190     , p_alarm_interval             => p_alarm_interval
191     , p_alarm_interval_uom         => p_alarm_interval_uom
192     , p_palm_flag                  => p_palm_flag
193     , p_wince_flag                 => p_wince_flag
194     , p_laptop_flag                => p_laptop_flag
195     , p_device1_flag               => p_device1_flag
196     , p_device2_flag               => p_device2_flag
197     , p_device3_flag               => p_device3_flag
198     , p_costs                      => p_costs
199     , p_currency_code              => p_currency_code
200     , p_escalation_level           => p_escalation_level
201     , x_return_status              => x_return_status
202     , x_msg_count                  => x_msg_count
203     , x_msg_data                   => x_msg_data
204     , x_task_id                    => x_task_id
205     , p_attribute1                 => p_attribute1
206     , p_attribute2                 => p_attribute2
207     , p_attribute3                 => p_attribute3
208     , p_attribute4                 => p_attribute4
209     , p_attribute5                 => p_attribute5
210     , p_attribute6                 => p_attribute6
211     , p_attribute7                 => p_attribute7
212     , p_attribute8                 => p_attribute8
213     , p_attribute9                 => p_attribute9
214     , p_attribute10                => p_attribute10
215     , p_attribute11                => p_attribute11
216     , p_attribute12                => p_attribute12
217     , p_attribute13                => p_attribute13
218     , p_attribute14                => p_attribute14
219     , p_attribute15                => p_attribute15
220     , p_attribute_category         => p_attribute_category
221     , p_date_selected              => p_date_selected
222     , p_category_id                => p_category_id
223     , p_show_on_calendar           => p_show_on_calendar
224     , p_owner_status_id            => p_owner_status_id
225     , p_template_id                => p_template_id
226     , p_template_group_id          => p_template_group_id
227     , p_enable_workflow            => p_enable_workflow
228     , p_abort_workflow             => p_abort_workflow
229     , p_task_split_flag            => NULL
230     , p_child_position             => NULL
231     , p_child_sequence_num         => NULL
232     );
233 
234     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
235       x_return_status  := fnd_api.g_ret_sts_unexp_error;
236       RAISE fnd_api.g_exc_unexpected_error;
237     END IF;
238 
239     IF fnd_api.to_boolean(p_commit) THEN
240       COMMIT WORK;
241     END IF;
242 
243     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
244   EXCEPTION
245     WHEN fnd_api.g_exc_unexpected_error THEN
246       ROLLBACK TO create_task_pub2;
247       x_return_status  := fnd_api.g_ret_sts_unexp_error;
248       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
249     WHEN OTHERS THEN
250       ROLLBACK TO create_task_pub2;
251       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
252       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
253       fnd_msg_pub.ADD;
254       x_return_status  := fnd_api.g_ret_sts_unexp_error;
255       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
256   END;
257 
258   -- Overloaded Version for the Simplex Fix.
259   -- new version without table type parameters
260   -- Remove the fix of Bug 2152549
261   PROCEDURE create_task(
262     p_api_version             IN            NUMBER
263   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
264   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
265   , p_task_id                 IN            NUMBER DEFAULT NULL
266   , p_task_name               IN            VARCHAR2
267   , p_task_type_name          IN            VARCHAR2 DEFAULT NULL
268   , p_task_type_id            IN            NUMBER DEFAULT NULL
269   , p_description             IN            VARCHAR2 DEFAULT NULL
270   , p_task_status_name        IN            VARCHAR2 DEFAULT NULL
271   , p_task_status_id          IN            NUMBER DEFAULT NULL
272   , p_task_priority_name      IN            VARCHAR2 DEFAULT NULL
273   , p_task_priority_id        IN            NUMBER DEFAULT NULL
274   , p_owner_type_name         IN            VARCHAR2 DEFAULT NULL
275   , p_owner_type_code         IN            VARCHAR2 DEFAULT NULL
276   , p_owner_id                IN            NUMBER DEFAULT NULL
277   , p_owner_territory_id      IN            NUMBER DEFAULT NULL
278   , p_assigned_by_name        IN            VARCHAR2 DEFAULT NULL
279   , p_assigned_by_id          IN            NUMBER DEFAULT NULL
280   , p_customer_number         IN            VARCHAR2 DEFAULT NULL
281   , p_customer_id             IN            NUMBER DEFAULT NULL
282   , p_cust_account_number     IN            VARCHAR2 DEFAULT NULL
283   , p_cust_account_id         IN            NUMBER DEFAULT NULL
284   , p_address_id              IN            NUMBER DEFAULT NULL
285   , p_address_number          IN            VARCHAR2 DEFAULT NULL
286   , p_planned_start_date      IN            DATE DEFAULT NULL
287   , p_planned_end_date        IN            DATE DEFAULT NULL
288   , p_scheduled_start_date    IN            DATE DEFAULT NULL
289   , p_scheduled_end_date      IN            DATE DEFAULT NULL
290   , p_actual_start_date       IN            DATE DEFAULT NULL
291   , p_actual_end_date         IN            DATE DEFAULT NULL
292   , p_timezone_id             IN            NUMBER DEFAULT NULL
293   , p_timezone_name           IN            VARCHAR2 DEFAULT NULL
294   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
295   , p_source_object_id        IN            NUMBER DEFAULT NULL
296   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
297   , p_duration                IN            NUMBER DEFAULT NULL
298   , p_duration_uom            IN            VARCHAR2 DEFAULT NULL
299   , p_planned_effort          IN            NUMBER DEFAULT NULL
300   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT NULL
301   , p_actual_effort           IN            NUMBER DEFAULT NULL
302   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT NULL
303   , p_percentage_complete     IN            NUMBER DEFAULT NULL
304   , p_reason_code             IN            VARCHAR2 DEFAULT NULL
305   , p_private_flag            IN            VARCHAR2 DEFAULT NULL
306   , p_publish_flag            IN            VARCHAR2 DEFAULT NULL
307   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT NULL
308   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT NULL
309   , p_milestone_flag          IN            VARCHAR2 DEFAULT NULL
310   , p_holiday_flag            IN            VARCHAR2 DEFAULT NULL
311   , p_billable_flag           IN            VARCHAR2 DEFAULT NULL
312   , p_bound_mode_code         IN            VARCHAR2 DEFAULT NULL
313   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT NULL
314   , p_workflow_process_id     IN            NUMBER DEFAULT NULL
315   , p_notification_flag       IN            VARCHAR2 DEFAULT NULL
316   , p_notification_period     IN            NUMBER DEFAULT NULL
317   , p_notification_period_uom IN            VARCHAR2 DEFAULT NULL
318   , p_parent_task_number      IN            VARCHAR2 DEFAULT NULL
319   , p_parent_task_id          IN            NUMBER DEFAULT NULL
320   , p_alarm_start             IN            NUMBER DEFAULT NULL
321   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT NULL
322   , p_alarm_on                IN            VARCHAR2 DEFAULT NULL
323   , p_alarm_count             IN            NUMBER DEFAULT NULL
324   , p_alarm_interval          IN            NUMBER DEFAULT NULL
325   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT NULL
326   , p_palm_flag               IN            VARCHAR2 DEFAULT NULL
327   , p_wince_flag              IN            VARCHAR2 DEFAULT NULL
328   , p_laptop_flag             IN            VARCHAR2 DEFAULT NULL
329   , p_device1_flag            IN            VARCHAR2 DEFAULT NULL
330   , p_device2_flag            IN            VARCHAR2 DEFAULT NULL
331   , p_device3_flag            IN            VARCHAR2 DEFAULT NULL
332   , p_costs                   IN            NUMBER DEFAULT NULL
333   , p_currency_code           IN            VARCHAR2 DEFAULT NULL
334   , p_escalation_level        IN            VARCHAR2 DEFAULT NULL
335   , x_return_status           OUT NOCOPY    VARCHAR2
336   , x_msg_count               OUT NOCOPY    NUMBER
337   , x_msg_data                OUT NOCOPY    VARCHAR2
338   , x_task_id                 OUT NOCOPY    NUMBER
339   , p_attribute1              IN            VARCHAR2 DEFAULT NULL
340   , p_attribute2              IN            VARCHAR2 DEFAULT NULL
341   , p_attribute3              IN            VARCHAR2 DEFAULT NULL
342   , p_attribute4              IN            VARCHAR2 DEFAULT NULL
343   , p_attribute5              IN            VARCHAR2 DEFAULT NULL
344   , p_attribute6              IN            VARCHAR2 DEFAULT NULL
345   , p_attribute7              IN            VARCHAR2 DEFAULT NULL
346   , p_attribute8              IN            VARCHAR2 DEFAULT NULL
347   , p_attribute9              IN            VARCHAR2 DEFAULT NULL
348   , p_attribute10             IN            VARCHAR2 DEFAULT NULL
349   , p_attribute11             IN            VARCHAR2 DEFAULT NULL
350   , p_attribute12             IN            VARCHAR2 DEFAULT NULL
351   , p_attribute13             IN            VARCHAR2 DEFAULT NULL
352   , p_attribute14             IN            VARCHAR2 DEFAULT NULL
353   , p_attribute15             IN            VARCHAR2 DEFAULT NULL
354   , p_attribute_category      IN            VARCHAR2 DEFAULT NULL
355   , p_date_selected           IN            VARCHAR2 DEFAULT NULL
356   , p_category_id             IN            NUMBER DEFAULT NULL
357   , p_show_on_calendar        IN            VARCHAR2 DEFAULT NULL
358   , p_owner_status_id         IN            NUMBER DEFAULT NULL
359   , p_template_id             IN            NUMBER DEFAULT NULL
360   , p_template_group_id       IN            NUMBER DEFAULT NULL
361   , p_enable_workflow         IN            VARCHAR2
362   , p_abort_workflow          IN            VARCHAR2
363   , p_task_split_flag         IN            VARCHAR2
364   , p_reference_flag          IN            VARCHAR2 DEFAULT NULL
365   , p_child_position          IN            VARCHAR2 DEFAULT NULL
366   , p_child_sequence_num      IN            NUMBER DEFAULT NULL
367   ) IS
368     l_api_version CONSTANT NUMBER       := 1.0;
369     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK';
370   BEGIN
371     SAVEPOINT create_task_pub1;
372     x_return_status  := fnd_api.g_ret_sts_success;
373 
374     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
375       RAISE fnd_api.g_exc_unexpected_error;
376     END IF;
377 
378     IF fnd_api.to_boolean(p_init_msg_list) THEN
379       fnd_msg_pub.initialize;
380     END IF;
381 
382     -- call new version, passing defaults for new functionality
383     create_task(
384       p_api_version                => p_api_version
385     , p_init_msg_list              => p_init_msg_list
386     , p_commit                     => fnd_api.g_false
387     , p_task_id                    => p_task_id
388     , p_task_name                  => p_task_name
389     , p_task_type_name             => p_task_type_name
390     , p_task_type_id               => p_task_type_id
391     , p_description                => p_description
392     , p_task_status_name           => p_task_status_name
393     , p_task_status_id             => p_task_status_id
394     , p_task_priority_name         => p_task_priority_name
395     , p_task_priority_id           => p_task_priority_id
396     , p_owner_type_name            => p_owner_type_name
397     , p_owner_type_code            => p_owner_type_code
398     , p_owner_id                   => p_owner_id
399     , p_owner_territory_id         => p_owner_territory_id
400     , p_assigned_by_name           => p_assigned_by_name
401     , p_assigned_by_id             => p_assigned_by_id
402     , p_customer_number            => p_customer_number
403     , p_customer_id                => p_customer_id
404     , p_cust_account_number        => p_cust_account_number
405     , p_cust_account_id            => p_cust_account_id
406     , p_address_id                 => p_address_id
407     , p_address_number             => p_address_number
408     , p_planned_start_date         => p_planned_start_date
409     , p_planned_end_date           => p_planned_end_date
410     , p_scheduled_start_date       => p_scheduled_start_date
411     , p_scheduled_end_date         => p_scheduled_end_date
412     , p_actual_start_date          => p_actual_start_date
413     , p_actual_end_date            => p_actual_end_date
414     , p_timezone_id                => p_timezone_id
415     , p_timezone_name              => p_timezone_name
416     , p_source_object_type_code    => p_source_object_type_code
417     , p_source_object_id           => p_source_object_id
418     , p_source_object_name         => p_source_object_name
419     , p_duration                   => p_duration
420     , p_duration_uom               => p_duration_uom
421     , p_planned_effort             => p_planned_effort
422     , p_planned_effort_uom         => p_planned_effort_uom
423     , p_actual_effort              => p_actual_effort
424     , p_actual_effort_uom          => p_actual_effort_uom
425     , p_percentage_complete        => p_percentage_complete
426     , p_reason_code                => p_reason_code
427     , p_private_flag               => p_private_flag
428     , p_publish_flag               => p_publish_flag
429     , p_restrict_closure_flag      => p_restrict_closure_flag
430     , p_multi_booked_flag          => p_multi_booked_flag
431     , p_milestone_flag             => p_milestone_flag
432     , p_holiday_flag               => p_holiday_flag
433     , p_billable_flag              => p_billable_flag
434     , p_bound_mode_code            => p_bound_mode_code
435     , p_soft_bound_flag            => p_soft_bound_flag
436     , p_workflow_process_id        => p_workflow_process_id
437     , p_notification_flag          => p_notification_flag
438     , p_notification_period        => p_notification_period
439     , p_notification_period_uom    => p_notification_period_uom
440     , p_parent_task_number         => p_parent_task_number
441     , p_parent_task_id             => p_parent_task_id
442     , p_alarm_start                => p_alarm_start
443     , p_alarm_start_uom            => p_alarm_start_uom
444     , p_alarm_on                   => p_alarm_on
445     , p_alarm_count                => p_alarm_count
446     , p_alarm_interval             => p_alarm_interval
447     , p_alarm_interval_uom         => p_alarm_interval_uom
448     , p_palm_flag                  => p_palm_flag
449     , p_wince_flag                 => p_wince_flag
450     , p_laptop_flag                => p_laptop_flag
451     , p_device1_flag               => p_device1_flag
452     , p_device2_flag               => p_device2_flag
453     , p_device3_flag               => p_device3_flag
454     , p_costs                      => p_costs
455     , p_currency_code              => p_currency_code
456     , p_escalation_level           => p_escalation_level
457     , p_task_assign_tbl            => g_miss_task_assign_tbl
458     , p_task_depends_tbl           => g_miss_task_depends_tbl
459     , p_task_rsrc_req_tbl          => g_miss_task_rsrc_req_tbl
460     , p_task_refer_tbl             => g_miss_task_refer_tbl
461     , p_task_dates_tbl             => g_miss_task_dates_tbl
462     , p_task_notes_tbl             => g_miss_task_notes_tbl
463     , p_task_recur_rec             => g_miss_task_recur_rec
464     , p_task_contacts_tbl          => g_miss_task_contacts_tbl
465     , x_return_status              => x_return_status
466     , x_msg_count                  => x_msg_count
467     , x_msg_data                   => x_msg_data
468     , x_task_id                    => x_task_id
469     , p_attribute1                 => p_attribute1
470     , p_attribute2                 => p_attribute2
471     , p_attribute3                 => p_attribute3
472     , p_attribute4                 => p_attribute4
473     , p_attribute5                 => p_attribute5
474     , p_attribute6                 => p_attribute6
475     , p_attribute7                 => p_attribute7
476     , p_attribute8                 => p_attribute8
477     , p_attribute9                 => p_attribute9
478     , p_attribute10                => p_attribute10
479     , p_attribute11                => p_attribute11
480     , p_attribute12                => p_attribute12
481     , p_attribute13                => p_attribute13
482     , p_attribute14                => p_attribute14
483     , p_attribute15                => p_attribute15
484     , p_attribute_category         => p_attribute_category
485     , p_date_selected              => p_date_selected
486     , p_category_id                => p_category_id
487     , p_show_on_calendar           => p_show_on_calendar
488     , p_owner_status_id            => p_owner_status_id
489     , p_template_id                => p_template_id
490     , p_template_group_id          => p_template_group_id
491     , p_enable_workflow            => p_enable_workflow
492     , p_abort_workflow             => p_abort_workflow
493     , p_task_split_flag            => p_task_split_flag
494     , p_reference_flag             => p_reference_flag
495     , p_child_position             => p_child_position
496     , p_child_sequence_num         => p_child_sequence_num
497     , p_location_id                => NULL
498     );
499 
500     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
501       x_return_status  := fnd_api.g_ret_sts_unexp_error;
502       RAISE fnd_api.g_exc_unexpected_error;
503     END IF;
504 
505     IF fnd_api.to_boolean(p_commit) THEN
506       COMMIT WORK;
507     END IF;
508 
509     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
510   EXCEPTION
511     WHEN fnd_api.g_exc_unexpected_error THEN
512       ROLLBACK TO create_task_pub1;
513       x_return_status  := fnd_api.g_ret_sts_unexp_error;
514       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
515     WHEN OTHERS THEN
516       ROLLBACK TO create_task_pub1;
517       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
518       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
519       fnd_msg_pub.ADD;
520       x_return_status  := fnd_api.g_ret_sts_unexp_error;
521       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
522   END;
523 
524   -- Overloaded Version for Location Id Enh# 3691788.
525   PROCEDURE create_task(
526     p_api_version             IN            NUMBER
527   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
528   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
529   , p_task_id                 IN            NUMBER DEFAULT NULL
530   , p_task_name               IN            VARCHAR2
531   , p_task_type_name          IN            VARCHAR2 DEFAULT NULL
532   , p_task_type_id            IN            NUMBER DEFAULT NULL
533   , p_description             IN            VARCHAR2 DEFAULT NULL
534   , p_task_status_name        IN            VARCHAR2 DEFAULT NULL
535   , p_task_status_id          IN            NUMBER DEFAULT NULL
536   , p_task_priority_name      IN            VARCHAR2 DEFAULT NULL
537   , p_task_priority_id        IN            NUMBER DEFAULT NULL
538   , p_owner_type_name         IN            VARCHAR2 DEFAULT NULL
539   , p_owner_type_code         IN            VARCHAR2 DEFAULT NULL
540   , p_owner_id                IN            NUMBER DEFAULT NULL
541   , p_owner_territory_id      IN            NUMBER DEFAULT NULL
542   , p_assigned_by_name        IN            VARCHAR2 DEFAULT NULL
543   , p_assigned_by_id          IN            NUMBER DEFAULT NULL
544   , p_customer_number         IN            VARCHAR2 DEFAULT NULL
545   , p_customer_id             IN            NUMBER DEFAULT NULL
546   , p_cust_account_number     IN            VARCHAR2 DEFAULT NULL
547   , p_cust_account_id         IN            NUMBER DEFAULT NULL
548   , p_address_id              IN            NUMBER DEFAULT NULL
549   , p_address_number          IN            VARCHAR2 DEFAULT NULL
550   , p_planned_start_date      IN            DATE DEFAULT NULL
551   , p_planned_end_date        IN            DATE DEFAULT NULL
552   , p_scheduled_start_date    IN            DATE DEFAULT NULL
553   , p_scheduled_end_date      IN            DATE DEFAULT NULL
554   , p_actual_start_date       IN            DATE DEFAULT NULL
555   , p_actual_end_date         IN            DATE DEFAULT NULL
556   , p_timezone_id             IN            NUMBER DEFAULT NULL
557   , p_timezone_name           IN            VARCHAR2 DEFAULT NULL
558   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
559   , p_source_object_id        IN            NUMBER DEFAULT NULL
560   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
561   , p_duration                IN            NUMBER DEFAULT NULL
562   , p_duration_uom            IN            VARCHAR2 DEFAULT NULL
563   , p_planned_effort          IN            NUMBER DEFAULT NULL
564   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT NULL
565   , p_actual_effort           IN            NUMBER DEFAULT NULL
566   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT NULL
567   , p_percentage_complete     IN            NUMBER DEFAULT NULL
568   , p_reason_code             IN            VARCHAR2 DEFAULT NULL
569   , p_private_flag            IN            VARCHAR2 DEFAULT NULL
570   , p_publish_flag            IN            VARCHAR2 DEFAULT NULL
571   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT NULL
572   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT NULL
573   , p_milestone_flag          IN            VARCHAR2 DEFAULT NULL
574   , p_holiday_flag            IN            VARCHAR2 DEFAULT NULL
575   , p_billable_flag           IN            VARCHAR2 DEFAULT NULL
576   , p_bound_mode_code         IN            VARCHAR2 DEFAULT NULL
577   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT NULL
578   , p_workflow_process_id     IN            NUMBER DEFAULT NULL
579   , p_notification_flag       IN            VARCHAR2 DEFAULT NULL
580   , p_notification_period     IN            NUMBER DEFAULT NULL
581   , p_notification_period_uom IN            VARCHAR2 DEFAULT NULL
582   , p_parent_task_number      IN            VARCHAR2 DEFAULT NULL
583   , p_parent_task_id          IN            NUMBER DEFAULT NULL
584   , p_alarm_start             IN            NUMBER DEFAULT NULL
585   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT NULL
586   , p_alarm_on                IN            VARCHAR2 DEFAULT NULL
587   , p_alarm_count             IN            NUMBER DEFAULT NULL
588   , p_alarm_interval          IN            NUMBER DEFAULT NULL
589   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT NULL
590   , p_palm_flag               IN            VARCHAR2 DEFAULT NULL
591   , p_wince_flag              IN            VARCHAR2 DEFAULT NULL
592   , p_laptop_flag             IN            VARCHAR2 DEFAULT NULL
593   , p_device1_flag            IN            VARCHAR2 DEFAULT NULL
594   , p_device2_flag            IN            VARCHAR2 DEFAULT NULL
595   , p_device3_flag            IN            VARCHAR2 DEFAULT NULL
596   , p_costs                   IN            NUMBER DEFAULT NULL
597   , p_currency_code           IN            VARCHAR2 DEFAULT NULL
598   , p_escalation_level        IN            VARCHAR2 DEFAULT NULL
599   , p_task_assign_tbl         IN            task_assign_tbl DEFAULT g_miss_task_assign_tbl
600   , p_task_depends_tbl        IN            task_depends_tbl DEFAULT g_miss_task_depends_tbl
601   , p_task_rsrc_req_tbl       IN            task_rsrc_req_tbl DEFAULT g_miss_task_rsrc_req_tbl
602   , p_task_refer_tbl          IN            task_refer_tbl DEFAULT g_miss_task_refer_tbl
603   , p_task_dates_tbl          IN            task_dates_tbl DEFAULT g_miss_task_dates_tbl
604   , p_task_notes_tbl          IN            task_notes_tbl DEFAULT g_miss_task_notes_tbl
605   , p_task_recur_rec          IN            task_recur_rec DEFAULT g_miss_task_recur_rec
606   , p_task_contacts_tbl       IN            task_contacts_tbl DEFAULT g_miss_task_contacts_tbl
607   , x_return_status           OUT NOCOPY    VARCHAR2
608   , x_msg_count               OUT NOCOPY    NUMBER
609   , x_msg_data                OUT NOCOPY    VARCHAR2
610   , x_task_id                 OUT NOCOPY    NUMBER
611   , p_attribute1              IN            VARCHAR2 DEFAULT NULL
612   , p_attribute2              IN            VARCHAR2 DEFAULT NULL
613   , p_attribute3              IN            VARCHAR2 DEFAULT NULL
614   , p_attribute4              IN            VARCHAR2 DEFAULT NULL
615   , p_attribute5              IN            VARCHAR2 DEFAULT NULL
616   , p_attribute6              IN            VARCHAR2 DEFAULT NULL
617   , p_attribute7              IN            VARCHAR2 DEFAULT NULL
618   , p_attribute8              IN            VARCHAR2 DEFAULT NULL
619   , p_attribute9              IN            VARCHAR2 DEFAULT NULL
620   , p_attribute10             IN            VARCHAR2 DEFAULT NULL
621   , p_attribute11             IN            VARCHAR2 DEFAULT NULL
622   , p_attribute12             IN            VARCHAR2 DEFAULT NULL
623   , p_attribute13             IN            VARCHAR2 DEFAULT NULL
624   , p_attribute14             IN            VARCHAR2 DEFAULT NULL
625   , p_attribute15             IN            VARCHAR2 DEFAULT NULL
626   , p_attribute_category      IN            VARCHAR2 DEFAULT NULL
627   , p_date_selected           IN            VARCHAR2 DEFAULT NULL
628   , p_category_id             IN            NUMBER DEFAULT NULL
629   , p_show_on_calendar        IN            VARCHAR2 DEFAULT NULL
630   , p_owner_status_id         IN            NUMBER DEFAULT NULL
631   , p_template_id             IN            NUMBER DEFAULT NULL
632   , p_template_group_id       IN            NUMBER DEFAULT NULL
633   , p_enable_workflow         IN            VARCHAR2 DEFAULT fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
634   , p_abort_workflow          IN            VARCHAR2 DEFAULT fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
635   , p_task_split_flag         IN            VARCHAR2 DEFAULT NULL
636   , p_reference_flag          IN            VARCHAR2 DEFAULT NULL
637   , p_child_position          IN            VARCHAR2 DEFAULT NULL
638   , p_child_sequence_num      IN            NUMBER DEFAULT NULL
639   , p_location_id             IN            NUMBER
640   ) IS
641     l_api_version    CONSTANT NUMBER                                               := 1.0;
642     l_api_name       CONSTANT VARCHAR2(30)                                       := 'VALIDATE_TASK';
643     l_task_number             jtf_tasks_b.task_number%TYPE;
644     /* Modified by TSINGHAL dt 8/10/2003 for bug fix 3182170 start */
645     l_task_name               jtf_tasks_tl.task_name%TYPE;
646     /* Modified by TSINGHAL dt 8/10/2003 for bug fix 3182170 End */
647     l_task_type_id            jtf_tasks_b.task_type_id%TYPE                       := p_task_type_id;
648     l_task_priority_id        jtf_tasks_b.task_priority_id%TYPE               := p_task_priority_id;
649     l_task_status_id          jtf_tasks_b.task_status_id%TYPE                   := p_task_status_id;
650     l_owner_type_name         jtf_objects_tl.NAME%TYPE                         := p_owner_type_name;
651     l_owner_type_code         jtf_objects_b.object_code%TYPE                   := p_owner_type_code;
652     l_owner_id                jtf_tasks_b.owner_id%TYPE                            := p_owner_id;
653     l_timezone_id             hz_timezones.timezone_id%TYPE                        := p_timezone_id;
654     l_timezone_name           hz_timezones.global_timezone_name%TYPE             := p_timezone_name;
655     l_planned_start_date      DATE                                          := p_planned_start_date;
656     l_planned_end_date        DATE                                            := p_planned_end_date;
657     l_actual_start_date       DATE                                           := p_actual_start_date;
658     l_actual_end_date         DATE                                             := p_actual_end_date;
659     l_scheduled_start_date    DATE                                        := p_scheduled_start_date;
660     l_scheduled_end_date      DATE                                          := p_scheduled_end_date;
661     l_assigned_by_name        fnd_user.user_name%TYPE                         := p_assigned_by_name;
662     l_assigned_by_id          NUMBER                                            := p_assigned_by_id;
663     l_cust_account_number     hz_cust_accounts.account_number%TYPE         := p_cust_account_number;
664     l_cust_account_id         hz_cust_accounts.cust_account_id%TYPE            := p_cust_account_id;
665     l_customer_id             hz_parties.party_id%TYPE                             := p_customer_id;
666     l_customer_number         hz_parties.party_number%TYPE                     := p_customer_number;
667     l_address_id              hz_party_sites.party_site_id%TYPE                    := p_address_id;
668     l_location_id             hz_locations.location_id%TYPE                        := p_location_id;
669     l_address_number          hz_party_sites.party_site_number%TYPE             := p_address_number;
670     l_parent_task_id          jtf_tasks_b.task_id%TYPE                          := p_parent_task_id;
671     l_parent_task_number      jtf_tasks_b.task_number%TYPE                  := p_parent_task_number;
672     l_source_object_type_code jtf_tasks_b.source_object_type_code%TYPE := p_source_object_type_code;
673     l_source_object_id        jtf_tasks_b.source_object_id%TYPE               := p_source_object_id;
674     l_source_object_name      jtf_tasks_b.source_object_name%TYPE
675                             := jtf_task_utl.check_truncation(p_object_name => p_source_object_name);
676     x                         CHAR;
677     l_costs                   jtf_tasks_b.costs%TYPE                               := p_costs;
678     l_currency_code           jtf_tasks_b.currency_code%TYPE                     := p_currency_code;
679     y                         BOOLEAN;
680     l_date_selected           jtf_tasks_b.date_selected%TYPE;
681     l_owner_status_id         jtf_task_all_assignments.assignment_status_id%TYPE;
682     l_type                    VARCHAR2(10);
683     l_msg_data                VARCHAR2(2000);   -- debug
684     l_task_id                 jtf_tasks_b.task_id%TYPE;
685     l_notes_id                NUMBER;
686     l_dependency_id           jtf_task_depends.dependency_id%TYPE;
687     l_recurrence_rule_id      jtf_task_recur_rules.recurrence_rule_id%TYPE;
688     l_resource_req_id         jtf_task_rsc_reqs.resource_req_id%TYPE;
689     l_task_rec                jtf_task_recurrences_pub.task_details_rec;
690     l_reccurence_generated    NUMBER;
691     /*** Start: Added a local variable to fix bug 2107464 ***/
692     l_task_contact_id         jtf_task_contacts.task_contact_id%TYPE;
693     /*** End: Added a local variable to fix bug 2107464 ***/
694     l_task_date_id            jtf_task_dates.task_date_id%TYPE;
695     l_task_assignment_id      jtf_task_all_assignments.task_assignment_id%TYPE;
696     l_task_reference_id       jtf_task_references_b.task_reference_id%TYPE;
697     current_record            INTEGER;
698 
699     CURSOR c_owner_status_id(b_owner_status_id jtf_task_all_assignments.assignment_status_id%TYPE) IS
700       SELECT task_status_id
701         FROM jtf_task_statuses_b
702        WHERE task_status_id = b_owner_status_id
703          --AND assigned_flag = 'Y'
704          AND assignment_status_flag = 'Y'   -- Fix bug 2500664
705          AND NVL(end_date_active, SYSDATE) >= SYSDATE
706          AND NVL(start_date_active, SYSDATE) <= SYSDATE;
707   BEGIN
708     SAVEPOINT create_task_pub;
709     x_return_status  := fnd_api.g_ret_sts_success;
710 
711     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
712       RAISE fnd_api.g_exc_unexpected_error;
713     END IF;
714 
715     IF fnd_api.to_boolean(p_init_msg_list) THEN
716       fnd_msg_pub.initialize;
717     END IF;
718 
719     /* Modified by TSINGHAL bug fix Validate task name length 3182170 Start*/
720     l_task_name      := check_param_length(p_task_name, 'JTF_TASK_NAME_INVALID_LENGTH', 80);
721     /* Modified by TSINGHAL bug fix 3182170 End*/
722 
723     -------
724     ------- Validate Task Type
725     -------
726     jtf_task_utl.validate_task_type(
727       p_task_type_id               => l_task_type_id
728     , p_task_type_name             => p_task_type_name
729     , x_return_status              => x_return_status
730     , x_task_type_id               => l_task_type_id
731     );
732 
733     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
734       x_return_status  := fnd_api.g_ret_sts_unexp_error;
735       RAISE fnd_api.g_exc_unexpected_error;
736     END IF;
737 
738     IF l_task_type_id IS NULL THEN
739       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_TASK_TYPE');
740       fnd_msg_pub.ADD;
741       RAISE fnd_api.g_exc_unexpected_error;
742     END IF;
743 
744     -------
745     ------- Validate Task Status
746     -------
747     IF l_task_type_id = '22' THEN
748       l_type  := 'ESCALATION';
749     ELSE
750       l_type  := 'TASK';
751     END IF;
752 
753     jtf_task_utl.validate_task_status(
754       p_task_status_id             => l_task_status_id
755     , p_task_status_name           => p_task_status_name
756     , p_validation_type            => l_type
757     , x_return_status              => x_return_status
758     , x_task_status_id             => l_task_status_id
759     );
760 
761     IF l_task_status_id IS NULL THEN
762       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_TASK_STATUS');
763       fnd_msg_pub.ADD;
764       RAISE fnd_api.g_exc_unexpected_error;
765     END IF;
766 
767     -------
768     ------- Validate Task Priority
769     -------
770     jtf_task_utl.validate_task_priority(
771       p_task_priority_id           => l_task_priority_id
772     , p_task_priority_name         => p_task_priority_name
773     , x_return_status              => x_return_status
774     , x_task_priority_id           => l_task_priority_id
775     );
776     -------
777     ------- Validate Location Id
778     -------
779     jtf_task_utl.validate_location_id(
780       p_location_id                => l_location_id
781     , p_address_id                 => l_address_id
782     , p_task_id                    => NULL
783     , x_return_status              => x_return_status
784     );
785 
786     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
787       x_return_status  := fnd_api.g_ret_sts_unexp_error;
788       RAISE fnd_api.g_exc_unexpected_error;
789     END IF;
790 
791     -------
792     ------- Validate Duration
793     -------
794     jtf_task_utl.validate_effort
795                   (
796       p_tag                        => jtf_task_utl.get_translated_lookup
797                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
798                                       , 'DURATION')
799     , p_tag_uom                    => jtf_task_utl.get_translated_lookup
800                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
801                                       , 'DURATION_UOM')
802     , x_return_status              => x_return_status
803     , p_effort                     => p_duration
804     , p_effort_uom                 => p_duration_uom
805     );
806 
807     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
808       x_return_status  := fnd_api.g_ret_sts_unexp_error;
809       RAISE fnd_api.g_exc_unexpected_error;
810     END IF;
811 
812     -------
813     ------- Validate Planned Effort
814     -------
815     jtf_task_utl.validate_effort(
816       p_tag            => jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'PLANNED_EFFORT')
817     , p_tag_uom        => jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'PLANNED_EFFORT_UOM')
818     , x_return_status  => x_return_status
819     , p_effort         => p_planned_effort
820     , p_effort_uom     => p_planned_effort_uom
821     );
822 
823     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
824       x_return_status  := fnd_api.g_ret_sts_unexp_error;
825       RAISE fnd_api.g_exc_unexpected_error;
826     END IF;
827 
828     -------
829     ------- Validate Actual Effort
830     -------
831     jtf_task_utl.validate_effort(
832       p_tag             => jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'ACTUAL_EFFORT')
833     , p_tag_uom         => jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'ACTUAL_EFFORT_UOM')
834     , x_return_status   => x_return_status
835     , p_effort          => p_actual_effort
836     , p_effort_uom      => p_actual_effort_uom
837     );
838 
839     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
840       x_return_status  := fnd_api.g_ret_sts_unexp_error;
841       RAISE fnd_api.g_exc_unexpected_error;
842     END IF;
843 
844     -------
845     ------- Validate Owner and Owner Sub Type
846     -------
847     jtf_task_utl.validate_task_owner(
848       p_owner_type_code            => l_owner_type_code
849     , p_owner_type_name            => NULL
850     , p_owner_id                   => l_owner_id
851     , x_return_status              => x_return_status
852     , x_owner_id                   => l_owner_id
853     , x_owner_type_code            => l_owner_type_code
854     );
855 
856     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
857       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_OWNER');
858       fnd_msg_pub.ADD;
859       x_return_status  := fnd_api.g_ret_sts_unexp_error;
860       RAISE fnd_api.g_exc_unexpected_error;
861     END IF;
862 
863     IF l_owner_id IS NULL THEN
864       fnd_message.set_name('JTF', 'JTF_TASK_OWNER');
865       fnd_msg_pub.ADD;
866       RAISE fnd_api.g_exc_unexpected_error;
867     END IF;
868 
869     IF l_owner_type_code IS NULL THEN
870       fnd_message.set_name('JTF', 'JTF_TASK_OWNER_TYPE_CODE');
871       fnd_msg_pub.ADD;
872       RAISE fnd_api.g_exc_unexpected_error;
873     END IF;
874 
875     -------
876     ------- Validate Planned Dates
877     -------
878     jtf_task_utl.validate_dates(
879       p_date_tag                   => jtf_task_utl.get_translated_lookup
880                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
881                                       , 'PLANNED')
882     , p_start_date                 => l_planned_start_date
883     , p_end_date                   => l_planned_end_date
884     , x_return_status              => x_return_status
885     );
886 
887     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
888       x_return_status  := fnd_api.g_ret_sts_unexp_error;
889       RAISE fnd_api.g_exc_unexpected_error;
890     END IF;
891 
892     -------
893     ------- Validate Actual Dates
894     -------
895     jtf_task_utl.validate_dates
896                  (
897       p_date_tag                   => jtf_task_utl.get_translated_lookup
898                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
899                                       , 'ACTUAL')
900     , p_start_date                 => l_actual_start_date
901     , p_end_date                   => l_actual_end_date
902     , x_return_status              => x_return_status
903     );
904 
905     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
906       x_return_status  := fnd_api.g_ret_sts_unexp_error;
907       RAISE fnd_api.g_exc_unexpected_error;
908     END IF;
909 
910     -------
911     ------- Validate Scheduled Dates
912     -------
913     jtf_task_utl.validate_dates
914                  (
915       p_date_tag                   => jtf_task_utl.get_translated_lookup
916                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
917                                       , 'SCHEDULED')
918     , p_start_date                 => l_scheduled_start_date
919     , p_end_date                   => l_scheduled_end_date
920     , x_return_status              => x_return_status
921     );
922 
923     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
924       x_return_status  := fnd_api.g_ret_sts_unexp_error;
925       RAISE fnd_api.g_exc_unexpected_error;
926     END IF;
927 
928     -------
929     ------- Validate Timezones
930     -------
931     jtf_task_utl.validate_timezones(
932       p_timezone_id                => l_timezone_id
933     , p_timezone_name              => l_timezone_name
934     , x_return_status              => x_return_status
935     , x_timezone_id                => l_timezone_id
936     );
937 
938     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
939       x_return_status  := fnd_api.g_ret_sts_unexp_error;
940       RAISE fnd_api.g_exc_unexpected_error;
941     END IF;
942 
943     -------
944     ------- Validate source object details
945     -------
946     --- only if object is not TASK, fix for bug #2058164
947     IF l_source_object_type_code <> 'TASK' THEN
948       jtf_task_utl.validate_source_object(
949         p_object_code                => l_source_object_type_code
950       , p_object_id                  => l_source_object_id
951       , p_object_name                => l_source_object_name
952       , x_return_status              => x_return_status
953       );
954 
955       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
956         x_return_status  := fnd_api.g_ret_sts_unexp_error;
957         RAISE fnd_api.g_exc_unexpected_error;
958       END IF;
959     END IF;
960 
961     -------
962     ------- Call the private flag
963     -------
964     jtf_task_utl.validate_flag
965                 (
966       x_return_status              => x_return_status
967     , p_flag_name                  => jtf_task_utl.get_translated_lookup
968                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
969                                       , 'PRIVATE_FLAG')
970     , p_flag_value                 => p_private_flag
971     );
972 
973     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
974       x_return_status  := fnd_api.g_ret_sts_unexp_error;
975       RAISE fnd_api.g_exc_unexpected_error;
976     END IF;
977 
978     -------
979     ------- Call the publish flag
980     -------
981     jtf_task_utl.validate_flag
982                 (
983       x_return_status              => x_return_status
984     , p_flag_name                  => jtf_task_utl.get_translated_lookup
985                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
986                                       , 'PUBLISH_FLAG')
987     , p_flag_value                 => p_publish_flag
988     );
989 
990     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
991       x_return_status  := fnd_api.g_ret_sts_unexp_error;
992       RAISE fnd_api.g_exc_unexpected_error;
993     END IF;
994 
995     -------
996     ------- Call the Restrict closure  flag
997     -------
998     jtf_task_utl.validate_flag
999                 (
1000       p_api_name                   => l_api_name
1001     , p_init_msg_list              => fnd_api.g_false
1002     , x_return_status              => x_return_status
1003     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1004                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1005                                       , 'RESTRICT_CLOSURE_FLAG')
1006     , p_flag_value                 => p_restrict_closure_flag
1007     );
1008 
1009     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1010       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1011       RAISE fnd_api.g_exc_unexpected_error;
1012     END IF;
1013 
1014     -------
1015     ------- Call the Multi Booked flag
1016     -------
1017     jtf_task_utl.validate_flag
1018                 (
1019       p_api_name                   => l_api_name
1020     , p_init_msg_list              => fnd_api.g_false
1021     , x_return_status              => x_return_status
1022     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1023                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1024                                       , 'MULTIBOOKED_FLAG')
1025     , p_flag_value                 => p_multi_booked_flag
1026     );
1027 
1028     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1029       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1030       RAISE fnd_api.g_exc_unexpected_error;
1031     END IF;
1032 
1033     -------
1034     ------- Call the milestone flag
1035     -------
1036     jtf_task_utl.validate_flag
1037                 (
1038       p_api_name                   => l_api_name
1039     , p_init_msg_list              => fnd_api.g_false
1040     , x_return_status              => x_return_status
1041     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1042                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1043                                       , 'MILESTONE_FLAG')
1044     , p_flag_value                 => p_milestone_flag
1045     );
1046 
1047     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1048       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1049       RAISE fnd_api.g_exc_unexpected_error;
1050     END IF;
1051 
1052     -------
1053     ------- Call the Holiday Flag
1054     -------
1055     jtf_task_utl.validate_flag
1056                 (
1057       p_api_name                   => l_api_name
1058     , p_init_msg_list              => fnd_api.g_false
1059     , x_return_status              => x_return_status
1060     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1061                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1062                                       , 'HOLIDAY_FLAG')
1063     , p_flag_value                 => p_holiday_flag
1064     );
1065 
1066     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1067       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1068       RAISE fnd_api.g_exc_unexpected_error;
1069     END IF;
1070 
1071     -------
1072     ------- Call the Billable Flag
1073     -------
1074     jtf_task_utl.validate_flag
1075                 (
1076       x_return_status              => x_return_status
1077     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1078                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1079                                       , 'BILLABLE_FLAG')
1080     , p_flag_value                 => p_billable_flag
1081     );
1082 
1083     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1084       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1085       RAISE fnd_api.g_exc_unexpected_error;
1086     END IF;
1087 
1088     -------
1089     ------- Call the Validate Notification Parameters
1090     -------
1091     jtf_task_utl.validate_notification(
1092       p_notification_flag          => p_notification_flag
1093     , p_notification_period        => p_notification_period
1094     , p_notification_period_uom    => p_notification_period_uom
1095     , x_return_status              => x_return_status
1096     );
1097 
1098     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1099       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1100       RAISE fnd_api.g_exc_unexpected_error;
1101     END IF;
1102 
1103     -------
1104     ------- Call the soft bound Flag
1105     -------
1106     jtf_task_utl.validate_flag
1107                 (
1108       p_api_name                   => l_api_name
1109     , p_init_msg_list              => fnd_api.g_false
1110     , x_return_status              => x_return_status
1111     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1112                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1113                                       , 'SOFTBOUND_FLAG')
1114     , p_flag_value                 => p_soft_bound_flag
1115     );
1116 
1117     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1118       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1119       RAISE fnd_api.g_exc_unexpected_error;
1120     END IF;
1121 
1122     -------
1123     ------- Call the Palm Flag
1124     -------
1125     jtf_task_utl.validate_flag
1126                 (
1127       p_api_name                   => l_api_name
1128     , p_init_msg_list              => fnd_api.g_false
1129     , x_return_status              => x_return_status
1130     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1131                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1132                                       , 'PALM_FLAG')
1133     , p_flag_value                 => p_palm_flag
1134     );
1135 
1136     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1137       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1138       RAISE fnd_api.g_exc_unexpected_error;
1139     END IF;
1140 
1141     -------
1142     ------- Call the Wince Flag
1143     -------
1144     jtf_task_utl.validate_flag
1145                 (
1146       p_api_name                   => l_api_name
1147     , p_init_msg_list              => fnd_api.g_false
1148     , x_return_status              => x_return_status
1149     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1150                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1151                                       , 'WINCE_FLAG')
1152     , p_flag_value                 => p_wince_flag
1153     );
1154 
1155     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1156       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1157       RAISE fnd_api.g_exc_unexpected_error;
1158     END IF;
1159 
1160     -------
1161     ------- Call the Laptop Flag
1162     -------
1163     jtf_task_utl.validate_flag
1164                 (
1165       p_api_name                   => l_api_name
1166     , p_init_msg_list              => fnd_api.g_false
1167     , x_return_status              => x_return_status
1168     , p_flag_name                  => jtf_task_utl.get_translated_lookup
1169                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
1170                                       , 'LAPTOP_FLAG')
1171     , p_flag_value                 => p_laptop_flag
1172     );
1173 
1174     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1175       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1176       RAISE fnd_api.g_exc_unexpected_error;
1177     END IF;
1178 
1179     -------
1180     ------- Validating the alarm details
1181     -------
1182     jtf_task_utl.validate_alarm(
1183       p_alarm_start                => p_alarm_start
1184     , p_alarm_start_uom            => p_alarm_start_uom
1185     , p_alarm_on                   => p_alarm_on
1186     , p_alarm_count                => p_alarm_count
1187     , p_alarm_interval             => p_alarm_interval
1188     , p_alarm_interval_uom         => p_alarm_interval_uom
1189     , x_return_status              => x_return_status
1190     );
1191 
1192     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1193       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1194       RAISE fnd_api.g_exc_unexpected_error;
1195     END IF;
1196 
1197     -------
1198     ------- Validating the assigned_by_id
1199     -------
1200     jtf_task_utl.validate_assigned_by(
1201       p_assigned_by_id             => l_assigned_by_id
1202     , p_assigned_by_name           => l_assigned_by_name
1203     , x_return_status              => x_return_status
1204     , x_assigned_by_id             => l_assigned_by_id
1205     );   -------
1206     ------- Validating the parent task id
1207     -------
1208     -- Fix Bug 2119074 : Must validate p_parent_task_number when p_parent_task_id is null
1209     --IF p_parent_task_id IS NOT NULL
1210     --THEN
1211     jtf_task_utl.validate_task(
1212       p_task_id                    => l_parent_task_id
1213     , p_task_number                => l_parent_task_number
1214     , x_task_id                    => l_parent_task_id
1215     , x_return_status              => x_return_status
1216     );
1217 
1218     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1219       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1220       RAISE fnd_api.g_exc_unexpected_error;
1221     END IF;
1222 
1223     --END IF;
1224 
1225     -------
1226     ------- Call the Customer Info
1227     -------
1228     jtf_task_utl.validate_customer_info(
1229       p_cust_account_number        => l_cust_account_number
1230     , p_cust_account_id            => l_cust_account_id
1231     , p_customer_number            => l_customer_number
1232     , p_customer_id                => l_customer_id
1233     , p_address_id                 => l_address_id
1234     , p_address_number             => l_address_number
1235     , x_return_status              => x_return_status
1236     , x_cust_account_id            => l_cust_account_id
1237     , x_customer_id                => l_customer_id
1238     , x_address_id                 => l_address_id
1239     );
1240 
1241     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1242       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1243       RAISE fnd_api.g_exc_unexpected_error;
1244     END IF;
1245 
1246     -------
1247     ------- Validate Percentage Complete
1248     -------
1249     IF p_percentage_complete IS NOT NULL THEN
1250       IF p_percentage_complete < 0 OR p_percentage_complete > 100 THEN
1251         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_PCT_COMPLETE');
1252         fnd_msg_pub.ADD;
1253         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1254         RAISE fnd_api.g_exc_unexpected_error;
1255       END IF;
1256     END IF;
1257 
1258     -------
1259     ------- Bound mode code.
1260     -------
1261     IF p_bound_mode_code IS NOT NULL THEN
1262       y  := jtf_task_utl.validate_lookup('JTF_TASK_BOUND_MODE_CODE', p_bound_mode_code, NULL);
1263 
1264       IF y = FALSE THEN
1265         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1266         RAISE fnd_api.g_exc_unexpected_error;
1267       END IF;
1268     END IF;
1269 
1270     -------
1271     ------- Validating costs
1272     -------
1273     jtf_task_utl.validate_costs(p_costs => l_costs, p_currency_code => l_currency_code
1274     , x_return_status              => x_return_status);
1275 
1276     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1277       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1278       RAISE fnd_api.g_exc_unexpected_error;
1279     END IF;
1280 
1281     ---------------
1282     ---------------  Validate date_selected
1283     ---------------
1284     IF l_date_selected IS NOT NULL AND l_date_selected <> fnd_api.g_miss_char THEN
1285       IF l_date_selected NOT IN('P', 'S', 'A', 'D') THEN
1286         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1287         RAISE fnd_api.g_exc_unexpected_error;
1288       END IF;
1289     END IF;
1290 
1291     ---------------
1292     ---------------  Validate owner_status_id
1293     ---------------
1294     IF p_owner_status_id IS NOT NULL AND p_owner_status_id <> fnd_api.g_miss_num THEN
1295       OPEN c_owner_status_id(p_owner_status_id);
1296 
1297       FETCH c_owner_status_id
1298        INTO l_owner_status_id;
1299 
1300       IF c_owner_status_id%NOTFOUND THEN
1301         CLOSE c_owner_status_id;
1302 
1303         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1304         RAISE fnd_api.g_exc_unexpected_error;
1305       ELSE
1306         CLOSE c_owner_status_id;
1307       END IF;
1308     END IF;
1309 
1310     -------
1311     ------- Call the private api.
1312     -------
1313     jtf_tasks_pvt.create_task(
1314       p_api_version                => 1.0
1315     , p_init_msg_list              => fnd_api.g_false
1316     , p_commit                     => fnd_api.g_false
1317     , p_task_id                    => p_task_id
1318     , p_task_type_id               => l_task_type_id
1319     , p_task_name                  => l_task_name
1320     , x_return_status              => x_return_status
1321     , x_msg_count                  => x_msg_count
1322     , x_msg_data                   => x_msg_data
1323     , x_task_id                    => x_task_id
1324     , p_task_status_id             => l_task_status_id
1325     , p_task_priority_id           => l_task_priority_id
1326     , p_owner_id                   => l_owner_id
1327     , p_owner_type_code            => l_owner_type_code
1328     , p_owner_territory_id         => p_owner_territory_id
1329     , p_source_object_id           => l_source_object_id
1330     , p_source_object_name         => l_source_object_name
1331     , p_duration                   => p_duration
1332     , p_duration_uom               => p_duration_uom
1333     , p_planned_effort             => p_planned_effort
1334     , p_planned_effort_uom         => p_planned_effort_uom
1335     , p_actual_effort              => p_actual_effort
1336     , p_actual_effort_uom          => p_actual_effort_uom
1337     , p_percentage_complete        => p_percentage_complete
1338     , p_reason_code                => p_reason_code
1339     , p_private_flag               => p_private_flag
1340     , p_publish_flag               => p_publish_flag
1341     , p_restrict_closure_flag      => p_restrict_closure_flag
1342     , p_multi_booked_flag          => p_multi_booked_flag
1343     , p_milestone_flag             => p_milestone_flag
1344     , p_holiday_flag               => p_holiday_flag
1345     , p_billable_flag              => p_billable_flag
1346     , p_bound_mode_code            => p_bound_mode_code
1347     , p_soft_bound_flag            => p_soft_bound_flag
1348     , p_workflow_process_id        => p_workflow_process_id
1349     , p_notification_flag          => p_notification_flag
1350     , p_notification_period        => p_notification_period
1351     , p_notification_period_uom    => p_notification_period_uom
1352     , p_parent_task_id             => l_parent_task_id
1353     , p_alarm_start                => p_alarm_start
1354     , p_alarm_start_uom            => p_alarm_start_uom
1355     , p_alarm_on                   => p_alarm_on
1356     , p_alarm_count                => p_alarm_count
1357     , p_alarm_interval             => p_alarm_interval
1358     , p_alarm_interval_uom         => p_alarm_interval_uom
1359     , p_palm_flag                  => p_palm_flag
1360     , p_wince_flag                 => p_wince_flag
1361     , p_laptop_flag                => p_laptop_flag
1362     , p_device1_flag               => p_device1_flag
1363     , p_device2_flag               => p_device2_flag
1364     , p_device3_flag               => p_device3_flag
1365     , p_assigned_by_id             => l_assigned_by_id
1366     , p_cust_account_id            => p_cust_account_id
1367     , p_customer_id                => p_customer_id
1368     , p_address_id                 => p_address_id
1369     , p_planned_start_date         => p_planned_start_date
1370     , p_planned_end_date           => p_planned_end_date
1371     , p_scheduled_start_date       => p_scheduled_start_date
1372     , p_scheduled_end_date         => p_scheduled_end_date
1373     , p_actual_start_date          => p_actual_start_date
1374     , p_actual_end_date            => p_actual_end_date
1375     , p_source_object_type_code    => l_source_object_type_code
1376     , p_timezone_id                => l_timezone_id
1377     , p_description                => p_description
1378     , p_costs                      => p_costs
1379     , p_currency_code              => p_currency_code
1380     , p_escalation_level           => p_escalation_level
1381     , p_attribute1                 => p_attribute1
1382     , p_attribute2                 => p_attribute2
1383     , p_attribute3                 => p_attribute3
1384     , p_attribute4                 => p_attribute4
1385     , p_attribute5                 => p_attribute5
1386     , p_attribute6                 => p_attribute6
1387     , p_attribute7                 => p_attribute7
1388     , p_attribute8                 => p_attribute8
1389     , p_attribute9                 => p_attribute9
1390     , p_attribute10                => p_attribute10
1391     , p_attribute11                => p_attribute11
1392     , p_attribute12                => p_attribute12
1393     , p_attribute13                => p_attribute13
1394     , p_attribute14                => p_attribute14
1395     , p_attribute15                => p_attribute15
1396     , p_attribute_category         => p_attribute_category
1397     , p_date_selected              => p_date_selected
1398     , p_category_id                => p_category_id
1399     , p_show_on_calendar           => p_show_on_calendar
1400     , p_owner_status_id            => l_owner_status_id
1401     , p_template_id                => p_template_id
1402     , p_template_group_id          => p_template_group_id
1403     , p_enable_workflow            => p_enable_workflow
1404     , p_abort_workflow             => p_abort_workflow
1405     , p_entity                     => g_entity
1406     , p_free_busy_type             => g_free_busy_type
1407     , p_task_confirmation_status   => 'N'
1408     , p_task_confirmation_counter  => 0
1409     , p_task_split_flag            => p_task_split_flag
1410     , p_reference_flag             => p_reference_flag
1411     , p_child_position             => p_child_position
1412     , p_child_sequence_num         => p_child_sequence_num
1413     , p_location_id                => l_location_id
1414     );
1415 
1416     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1417       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1418       RAISE fnd_api.g_exc_unexpected_error;
1419     END IF;
1420 
1421     l_task_id        := x_task_id;
1422 
1423     -------
1424     -------
1425     ------- Create the dependencies
1426     -------
1427     -------
1428     IF p_task_depends_tbl.COUNT > 0 THEN
1429       current_record  := p_task_depends_tbl.FIRST;
1430 
1431       FOR i IN 1 .. p_task_depends_tbl.COUNT LOOP
1432         jtf_task_dependency_pub.create_task_dependency
1433           (
1434           p_api_version                => 1.0
1435         , p_init_msg_list              => fnd_api.g_false
1436         , p_commit                     => fnd_api.g_false
1437         , p_validation_level           => fnd_api.g_valid_level_full
1438         , p_task_id                    => l_task_id
1439         , p_dependent_on_task_id       => p_task_depends_tbl(current_record).dependent_on_task_id
1440         , p_dependent_on_task_number   => p_task_depends_tbl(current_record).dependent_on_task_number
1441         , p_dependency_type_code       => p_task_depends_tbl(current_record).dependency_type_code
1442         , p_template_flag              => jtf_task_utl.g_no
1443         , p_adjustment_time            => p_task_depends_tbl(current_record).adjustment_time
1444         , p_adjustment_time_uom        => p_task_depends_tbl(current_record).adjustment_time_uom
1445         , p_validated_flag             => p_task_depends_tbl(current_record).validated_flag
1446         , x_dependency_id              => l_dependency_id
1447         , x_return_status              => x_return_status
1448         , x_msg_count                  => x_msg_count
1449         , x_msg_data                   => x_msg_data
1450         );
1451 
1452         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1453           x_return_status  := fnd_api.g_ret_sts_unexp_error;
1454           RAISE fnd_api.g_exc_unexpected_error;
1455         END IF;
1456 
1457         current_record  := p_task_depends_tbl.NEXT(current_record);
1458       END LOOP;
1459     END IF;
1460 
1461     -------
1462     ------- Create References
1463     -------
1464     IF p_task_refer_tbl.COUNT > 0 THEN
1465       current_record  := p_task_refer_tbl.FIRST;
1466 
1467       FOR i IN 1 .. p_task_refer_tbl.COUNT LOOP
1468         jtf_task_references_pub.create_references
1469                           (
1470           p_api_version                => 1.0
1471         , p_init_msg_list              => fnd_api.g_false
1472         , p_commit                     => fnd_api.g_false
1473         , p_task_id                    => l_task_id
1474         , p_object_type_code           => p_task_refer_tbl(current_record).object_type_code
1475         ,
1476           --          p_object_type_name => p_task_refer_tbl (current_record).object_type_name,
1477           p_object_name                => p_task_refer_tbl(current_record).object_name
1478         , p_object_id                  => p_task_refer_tbl(current_record).object_id
1479         , p_object_details             => p_task_refer_tbl(current_record).object_details
1480         , p_reference_code             => p_task_refer_tbl(current_record).reference_code
1481         , p_usage                      => p_task_refer_tbl(current_record).USAGE
1482         , x_return_status              => x_return_status
1483         , x_msg_count                  => x_msg_count
1484         , x_msg_data                   => x_msg_data
1485         , x_task_reference_id          => l_task_reference_id
1486         );
1487 
1488         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1489           x_return_status  := fnd_api.g_ret_sts_unexp_error;
1490           RAISE fnd_api.g_exc_unexpected_error;
1491         END IF;
1492 
1493         current_record  := p_task_refer_tbl.NEXT(current_record);
1494       END LOOP;
1495     END IF;
1496 
1497     -------
1498     ------- Create Resource Requirements
1499     -------
1500     IF p_task_rsrc_req_tbl.COUNT > 0 THEN
1501       current_record  := p_task_rsrc_req_tbl.FIRST;
1502 
1503       FOR i IN 1 .. p_task_rsrc_req_tbl.COUNT LOOP
1504         jtf_task_resources_pub.create_task_rsrc_req
1505                                  (
1506           p_api_version                => 1.0
1507         , p_init_msg_list              => fnd_api.g_false
1508         , p_commit                     => fnd_api.g_false
1509         , p_task_id                    => l_task_id
1510         , p_resource_type_code         => p_task_rsrc_req_tbl(i).resource_type_code
1511         , p_required_units             => p_task_rsrc_req_tbl(i).required_units
1512         , p_enabled_flag               => p_task_rsrc_req_tbl(i).enabled_flag
1513         , x_return_status              => x_return_status
1514         , x_msg_count                  => x_msg_count
1515         , x_msg_data                   => x_msg_data
1516         , x_resource_req_id            => l_resource_req_id
1517         );
1518 
1519         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1520           x_return_status  := fnd_api.g_ret_sts_unexp_error;
1521           RAISE fnd_api.g_exc_unexpected_error;
1522         END IF;
1523 
1524         current_record  := p_task_rsrc_req_tbl.NEXT(current_record);
1525       END LOOP;
1526     END IF;
1527 
1528     -------
1529     ------- Create Assignments
1530     -------
1531     IF p_task_assign_tbl.COUNT > 0 THEN
1532       current_record  := p_task_assign_tbl.FIRST;
1533 
1534       FOR i IN 1 .. p_task_assign_tbl.COUNT LOOP
1535         jtf_task_assignments_pub.create_task_assignment
1536                    (
1537           p_api_version                => 1.0
1538         , p_init_msg_list              => fnd_api.g_false
1539         , p_commit                     => fnd_api.g_false
1540         , p_task_id                    => l_task_id
1541         , p_resource_type_code         => p_task_assign_tbl(i).resource_type_code
1542         , p_resource_id                => p_task_assign_tbl(i).resource_id
1543         , p_actual_effort              => p_task_assign_tbl(i).actual_effort
1544         , p_actual_effort_uom          => p_task_assign_tbl(i).actual_effort_uom
1545         , p_schedule_flag              => p_task_assign_tbl(i).schedule_flag
1546         , p_alarm_type_code            => p_task_assign_tbl(i).alarm_type_code
1547         , p_alarm_contact              => p_task_assign_tbl(i).alarm_contact
1548         , p_sched_travel_distance      => p_task_assign_tbl(i).sched_travel_duration
1549         , p_sched_travel_duration      => p_task_assign_tbl(i).sched_travel_duration
1550         , p_sched_travel_duration_uom  => p_task_assign_tbl(i).sched_travel_duration_uom
1551         , p_actual_travel_distance     => p_task_assign_tbl(i).actual_travel_distance
1552         , p_actual_travel_duration     => p_task_assign_tbl(i).actual_travel_duration
1553         , p_actual_travel_duration_uom => p_task_assign_tbl(i).actual_travel_duration_uom
1554         , p_actual_start_date          => p_task_assign_tbl(i).actual_start_date
1555         , p_actual_end_date            => p_task_assign_tbl(i).actual_end_date
1556         , p_palm_flag                  => p_task_assign_tbl(i).palm_flag
1557         , p_wince_flag                 => p_task_assign_tbl(i).wince_flag
1558         , p_laptop_flag                => p_task_assign_tbl(i).laptop_flag
1559         , p_device1_flag               => p_task_assign_tbl(i).device1_flag
1560         , p_device2_flag               => p_task_assign_tbl(i).device2_flag
1561         , p_device3_flag               => p_task_assign_tbl(i).device3_flag
1562         , p_resource_territory_id      => p_task_assign_tbl(i).resource_territory_id
1563         , p_assignment_status_id       => p_task_assign_tbl(i).assignment_status_id
1564         , p_shift_construct_id         => p_task_assign_tbl(i).shift_construct_id
1565         , p_show_on_calendar           => p_task_assign_tbl(i).show_on_calendar
1566         , p_category_id                => p_task_assign_tbl(i).category_id
1567         , x_return_status              => x_return_status
1568         , x_msg_count                  => x_msg_count
1569         , x_msg_data                   => x_msg_data
1570         , x_task_assignment_id         => l_task_assignment_id
1571         );
1572 
1573         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1574           x_return_status  := fnd_api.g_ret_sts_unexp_error;
1575           RAISE fnd_api.g_exc_unexpected_error;
1576         END IF;
1577 
1578         current_record  := p_task_rsrc_req_tbl.NEXT(current_record);
1579       END LOOP;
1580     END IF;
1581 
1582     -------
1583     ------- Create Dates
1584     -------
1585     IF p_task_dates_tbl.COUNT > 0 THEN
1586       current_record  := p_task_dates_tbl.FIRST;
1587 
1588       FOR i IN 1 .. p_task_dates_tbl.COUNT LOOP
1589         jtf_task_dates_pub.create_task_dates
1590                               (
1591           p_api_version                => 1.0
1592         , p_init_msg_list              => fnd_api.g_false
1593         , p_commit                     => fnd_api.g_false
1594         , p_task_id                    => l_task_id
1595         , p_date_type_id               => p_task_dates_tbl(current_record).date_type_id
1596         , p_date_type_name             => p_task_dates_tbl(current_record).date_type_name
1597         , p_date_value                 => p_task_dates_tbl(current_record).date_value
1598         , x_return_status              => x_return_status
1599         , x_msg_count                  => x_msg_count
1600         , x_msg_data                   => x_msg_data
1601         , x_task_date_id               => l_task_date_id
1602         );
1603 
1604         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1605           x_return_status  := fnd_api.g_ret_sts_unexp_error;
1606           RAISE fnd_api.g_exc_unexpected_error;
1607         END IF;
1608 
1609         current_record  := p_task_dates_tbl.NEXT(current_record);
1610       END LOOP;
1611     END IF;
1612 
1613     -------
1614     ------- Create Notes
1615     -------
1616     IF p_task_notes_tbl.COUNT > 0 THEN
1617       current_record  := p_task_notes_tbl.FIRST;
1618 
1619       FOR i IN 1 .. p_task_notes_tbl.COUNT LOOP
1620         jtf_notes_pub.create_note(
1621           p_api_version                => 1.0
1622         , p_init_msg_list              => fnd_api.g_false
1623         , p_commit                     => fnd_api.g_false
1624         , p_validation_level           => fnd_api.g_valid_level_full
1625         , p_parent_note_id             => p_task_notes_tbl(i).parent_note_id
1626         , x_return_status              => x_return_status
1627         , x_msg_count                  => x_msg_count
1628         , x_msg_data                   => x_msg_count
1629         , p_org_id                     => p_task_notes_tbl(i).org_id
1630         , p_source_object_id           => l_task_id
1631         , p_source_object_code         => 'TASK'
1632         , p_notes                      => p_task_notes_tbl(i).notes
1633         , p_notes_detail               => p_task_notes_tbl(i).notes_detail
1634         , p_note_status                => p_task_notes_tbl(i).note_status
1635         , p_entered_by                 => p_task_notes_tbl(i).entered_by
1636         , p_entered_date               => p_task_notes_tbl(i).entered_date
1637         , x_jtf_note_id                => l_notes_id
1638         , p_note_type                  => p_task_notes_tbl(i).note_type
1639         , p_jtf_note_contexts_tab      => jtf_notes_pub.jtf_note_contexts_tab
1640         , p_creation_date              => SYSDATE
1641         , p_last_update_date           => SYSDATE
1642         , p_last_updated_by            => fnd_global.login_id
1643         , p_attribute1                 => p_task_notes_tbl(i).attribute1
1644         , p_attribute2                 => p_task_notes_tbl(i).attribute2
1645         , p_attribute3                 => p_task_notes_tbl(i).attribute3
1646         , p_attribute4                 => p_task_notes_tbl(i).attribute4
1647         , p_attribute5                 => p_task_notes_tbl(i).attribute5
1648         , p_attribute6                 => p_task_notes_tbl(i).attribute6
1649         , p_attribute7                 => p_task_notes_tbl(i).attribute7
1650         , p_attribute8                 => p_task_notes_tbl(i).attribute8
1651         , p_attribute9                 => p_task_notes_tbl(i).attribute9
1652         , p_attribute10                => p_task_notes_tbl(i).attribute10
1653         , p_attribute11                => p_task_notes_tbl(i).attribute11
1654         , p_attribute12                => p_task_notes_tbl(i).attribute12
1655         , p_attribute13                => p_task_notes_tbl(i).attribute13
1656         , p_attribute14                => p_task_notes_tbl(i).attribute14
1657         , p_attribute15                => p_task_notes_tbl(i).attribute15
1658         , p_context                    => p_task_notes_tbl(i).CONTEXT
1659         );
1660 
1661         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1662           x_return_status  := fnd_api.g_ret_sts_unexp_error;
1663           RAISE fnd_api.g_exc_unexpected_error;
1664         END IF;
1665 
1666         current_record  := p_task_dates_tbl.NEXT(current_record);
1667       END LOOP;
1668     END IF;
1669 
1670     -------
1671     -------
1672     ------- Create recurrences
1673     -------
1674     -------
1675     IF (
1676            p_task_recur_rec.occurs_which IS NOT NULL
1677         OR p_task_recur_rec.day_of_week IS NOT NULL
1678         OR p_task_recur_rec.date_of_month IS NOT NULL
1679         OR p_task_recur_rec.occurs_month IS NOT NULL
1680         OR p_task_recur_rec.occurs_uom IS NOT NULL
1681         OR p_task_recur_rec.occurs_every IS NOT NULL
1682         OR p_task_recur_rec.occurs_number IS NOT NULL
1683         OR p_task_recur_rec.start_date_active IS NOT NULL
1684         OR p_task_recur_rec.end_date_active IS NOT NULL
1685        ) THEN
1686       jtf_task_recurrences_pub.create_task_recurrence
1687                                         (
1688         p_api_version                => 1.0
1689       , p_init_msg_list              => fnd_api.g_false
1690       , p_commit                     => fnd_api.g_false
1691       , p_task_id                    => l_task_id
1692       , p_occurs_which               => p_task_recur_rec.occurs_which
1693       , p_template_flag              => jtf_task_utl.g_no
1694       , p_day_of_week                => p_task_recur_rec.day_of_week
1695       , p_date_of_month              => p_task_recur_rec.date_of_month
1696       , p_occurs_month               => p_task_recur_rec.occurs_month
1697       , p_occurs_uom                 => p_task_recur_rec.occurs_uom
1698       , p_occurs_every               => p_task_recur_rec.occurs_every
1699       , p_occurs_number              => p_task_recur_rec.occurs_number
1700       , p_start_date_active          => p_task_recur_rec.start_date_active
1701       , p_end_date_active            => p_task_recur_rec.end_date_active
1702       , x_return_status              => x_return_status
1703       , x_msg_count                  => x_msg_count
1704       , x_msg_data                   => x_msg_data
1705       , x_recurrence_rule_id         => l_recurrence_rule_id
1706       , x_task_rec                   => l_task_rec
1707       , x_reccurences_generated      => l_reccurence_generated
1708       );
1709 
1710       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1711         x_return_status  := fnd_api.g_ret_sts_unexp_error;
1712         RAISE fnd_api.g_exc_unexpected_error;
1713       END IF;
1714     END IF;
1715 
1716     /***** Start: Fix bug 2107464 ***************/
1717     -------
1718     ------- Create Contacts
1719     -------
1720     IF p_task_contacts_tbl.COUNT > 0 THEN
1721       --current_record := p_task_contacts_tbl.FIRST;
1722       FOR i IN p_task_contacts_tbl.FIRST .. p_task_contacts_tbl.COUNT LOOP
1723         jtf_task_contacts_pub.create_task_contacts
1724                    (
1725           p_api_version                => 1.0
1726         , p_init_msg_list              => fnd_api.g_false
1727         , p_commit                     => fnd_api.g_false
1728         , p_task_id                    => l_task_id
1729         , p_contact_id                 => p_task_contacts_tbl(i).contact_id
1730         , p_contact_type_code          => p_task_contacts_tbl(i).contact_type_code
1731         , p_escalation_notify_flag     => p_task_contacts_tbl(i).escalation_notify_flag
1732         , p_escalation_requester_flag  => p_task_contacts_tbl(i).escalation_requester_flag
1733         , x_task_contact_id            => l_task_contact_id
1734         , x_return_status              => x_return_status
1735         , x_msg_count                  => x_msg_count
1736         , x_msg_data                   => x_msg_data
1737         );
1738 
1739         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
1740           x_return_status  := fnd_api.g_ret_sts_unexp_error;
1741           RAISE fnd_api.g_exc_unexpected_error;
1742         END IF;
1743       --current_record := p_task_dates_tbl.NEXT (current_record);
1744       END LOOP;
1745     END IF;
1746 
1747     /***** End: Fix bug 2107464 ***************/
1748 
1749     -------
1750     -------
1751     -------
1752     IF fnd_api.to_boolean(p_commit) THEN
1753       COMMIT WORK;
1754     END IF;
1755 
1756     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1757   EXCEPTION
1758     WHEN fnd_api.g_exc_unexpected_error THEN
1759       ROLLBACK TO create_task_pub;
1760       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1761       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1762     WHEN OTHERS THEN
1763       ROLLBACK TO create_task_pub;
1764       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
1765       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
1766       fnd_msg_pub.ADD;
1767       x_return_status  := fnd_api.g_ret_sts_unexp_error;
1768       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
1769   END;
1770 
1771   -- original version including table type parameters
1772   -- Remove the fix of Bug 2152549
1773   PROCEDURE create_task(
1774     p_api_version             IN            NUMBER
1775   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
1776   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
1777   , p_task_id                 IN            NUMBER DEFAULT NULL
1778   , p_task_name               IN            VARCHAR2
1779   , p_task_type_name          IN            VARCHAR2 DEFAULT NULL
1780   , p_task_type_id            IN            NUMBER DEFAULT NULL
1781   , p_description             IN            VARCHAR2 DEFAULT NULL
1782   , p_task_status_name        IN            VARCHAR2 DEFAULT NULL
1783   , p_task_status_id          IN            NUMBER DEFAULT NULL
1784   , p_task_priority_name      IN            VARCHAR2 DEFAULT NULL
1785   , p_task_priority_id        IN            NUMBER DEFAULT NULL
1786   , p_owner_type_name         IN            VARCHAR2 DEFAULT NULL
1787   , p_owner_type_code         IN            VARCHAR2 DEFAULT NULL
1788   , p_owner_id                IN            NUMBER DEFAULT NULL
1789   , p_owner_territory_id      IN            NUMBER DEFAULT NULL
1790   , p_assigned_by_name        IN            VARCHAR2 DEFAULT NULL
1791   , p_assigned_by_id          IN            NUMBER DEFAULT NULL
1792   , p_customer_number         IN            VARCHAR2 DEFAULT NULL
1793   ,   -- from hz_parties
1794     p_customer_id             IN            NUMBER DEFAULT NULL
1795   , p_cust_account_number     IN            VARCHAR2 DEFAULT NULL
1796   , p_cust_account_id         IN            NUMBER DEFAULT NULL
1797   , p_address_id              IN            NUMBER DEFAULT NULL
1798   ,   ---- hz_party_sites
1799     p_address_number          IN            VARCHAR2 DEFAULT NULL
1800   , p_planned_start_date      IN            DATE DEFAULT NULL
1801   , p_planned_end_date        IN            DATE DEFAULT NULL
1802   , p_scheduled_start_date    IN            DATE DEFAULT NULL
1803   , p_scheduled_end_date      IN            DATE DEFAULT NULL
1804   , p_actual_start_date       IN            DATE DEFAULT NULL
1805   , p_actual_end_date         IN            DATE DEFAULT NULL
1806   , p_timezone_id             IN            NUMBER DEFAULT NULL
1807   , p_timezone_name           IN            VARCHAR2 DEFAULT NULL
1808   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
1809   , p_source_object_id        IN            NUMBER DEFAULT NULL
1810   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
1811   , p_duration                IN            NUMBER DEFAULT NULL
1812   , p_duration_uom            IN            VARCHAR2 DEFAULT NULL
1813   , p_planned_effort          IN            NUMBER DEFAULT NULL
1814   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT NULL
1815   , p_actual_effort           IN            NUMBER DEFAULT NULL
1816   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT NULL
1817   , p_percentage_complete     IN            NUMBER DEFAULT NULL
1818   , p_reason_code             IN            VARCHAR2 DEFAULT NULL
1819   , p_private_flag            IN            VARCHAR2 DEFAULT NULL
1820   , p_publish_flag            IN            VARCHAR2 DEFAULT NULL
1821   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT NULL
1822   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT NULL
1823   , p_milestone_flag          IN            VARCHAR2 DEFAULT NULL
1824   , p_holiday_flag            IN            VARCHAR2 DEFAULT NULL
1825   , p_billable_flag           IN            VARCHAR2 DEFAULT NULL
1826   , p_bound_mode_code         IN            VARCHAR2 DEFAULT NULL
1827   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT NULL
1828   , p_workflow_process_id     IN            NUMBER DEFAULT NULL
1829   , p_notification_flag       IN            VARCHAR2 DEFAULT NULL
1830   , p_notification_period     IN            NUMBER DEFAULT NULL
1831   , p_notification_period_uom IN            VARCHAR2 DEFAULT NULL
1832   , p_parent_task_number      IN            VARCHAR2 DEFAULT NULL
1833   , p_parent_task_id          IN            NUMBER DEFAULT NULL
1834   , p_alarm_start             IN            NUMBER DEFAULT NULL
1835   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT NULL
1836   , p_alarm_on                IN            VARCHAR2 DEFAULT NULL
1837   , p_alarm_count             IN            NUMBER DEFAULT NULL
1838   , p_alarm_interval          IN            NUMBER DEFAULT NULL
1839   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT NULL
1840   , p_palm_flag               IN            VARCHAR2 DEFAULT NULL
1841   , p_wince_flag              IN            VARCHAR2 DEFAULT NULL
1842   , p_laptop_flag             IN            VARCHAR2 DEFAULT NULL
1843   , p_device1_flag            IN            VARCHAR2 DEFAULT NULL
1844   , p_device2_flag            IN            VARCHAR2 DEFAULT NULL
1845   , p_device3_flag            IN            VARCHAR2 DEFAULT NULL
1846   , p_costs                   IN            NUMBER DEFAULT NULL
1847   , p_currency_code           IN            VARCHAR2 DEFAULT NULL
1848   , p_escalation_level        IN            VARCHAR2 DEFAULT NULL
1849   , p_task_assign_tbl         IN            task_assign_tbl DEFAULT g_miss_task_assign_tbl
1850   , p_task_depends_tbl        IN            task_depends_tbl DEFAULT g_miss_task_depends_tbl
1851   , p_task_rsrc_req_tbl       IN            task_rsrc_req_tbl DEFAULT g_miss_task_rsrc_req_tbl
1852   , p_task_refer_tbl          IN            task_refer_tbl DEFAULT g_miss_task_refer_tbl
1853   , p_task_dates_tbl          IN            task_dates_tbl DEFAULT g_miss_task_dates_tbl
1854   , p_task_notes_tbl          IN            task_notes_tbl DEFAULT g_miss_task_notes_tbl
1855   , p_task_recur_rec          IN            task_recur_rec DEFAULT g_miss_task_recur_rec
1856   , p_task_contacts_tbl       IN            task_contacts_tbl DEFAULT g_miss_task_contacts_tbl
1857   , x_return_status           OUT NOCOPY    VARCHAR2
1858   , x_msg_count               OUT NOCOPY    NUMBER
1859   , x_msg_data                OUT NOCOPY    VARCHAR2
1860   , x_task_id                 OUT NOCOPY    NUMBER
1861   , p_attribute1              IN            VARCHAR2 DEFAULT NULL
1862   , p_attribute2              IN            VARCHAR2 DEFAULT NULL
1863   , p_attribute3              IN            VARCHAR2 DEFAULT NULL
1864   , p_attribute4              IN            VARCHAR2 DEFAULT NULL
1865   , p_attribute5              IN            VARCHAR2 DEFAULT NULL
1866   , p_attribute6              IN            VARCHAR2 DEFAULT NULL
1867   , p_attribute7              IN            VARCHAR2 DEFAULT NULL
1868   , p_attribute8              IN            VARCHAR2 DEFAULT NULL
1869   , p_attribute9              IN            VARCHAR2 DEFAULT NULL
1870   , p_attribute10             IN            VARCHAR2 DEFAULT NULL
1871   , p_attribute11             IN            VARCHAR2 DEFAULT NULL
1872   , p_attribute12             IN            VARCHAR2 DEFAULT NULL
1873   , p_attribute13             IN            VARCHAR2 DEFAULT NULL
1874   , p_attribute14             IN            VARCHAR2 DEFAULT NULL
1875   , p_attribute15             IN            VARCHAR2 DEFAULT NULL
1876   , p_attribute_category      IN            VARCHAR2 DEFAULT NULL
1877   , p_date_selected           IN            VARCHAR2 DEFAULT NULL
1878   , p_category_id             IN            NUMBER DEFAULT NULL
1879   , p_show_on_calendar        IN            VARCHAR2 DEFAULT NULL
1880   , p_owner_status_id         IN            NUMBER DEFAULT NULL
1881   , p_template_id             IN            NUMBER DEFAULT NULL
1882   , p_template_group_id       IN            NUMBER DEFAULT NULL
1883   ) IS
1884     l_api_version CONSTANT NUMBER       := 1.0;
1885     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK';
1886   BEGIN
1887     SAVEPOINT create_task_pub2;
1888     x_return_status  := fnd_api.g_ret_sts_success;
1889 
1890     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
1891       RAISE fnd_api.g_exc_unexpected_error;
1892     END IF;
1893 
1894     IF fnd_api.to_boolean(p_init_msg_list) THEN
1895       fnd_msg_pub.initialize;
1896     END IF;
1897 
1898     -- call new version, passing defaults for new functionality
1899           -- Remove the fix of Bug 2152549: call create_task_b which is non-overloading procedure
1900     create_task(
1901       p_api_version                => p_api_version
1902     , p_init_msg_list              => p_init_msg_list
1903     ,
1904       -- passing FALSE so we can commit after processing the table parameters
1905       p_commit                     => fnd_api.g_false
1906     , p_task_id                    => p_task_id
1907     , p_task_name                  => p_task_name
1908     , p_task_type_name             => p_task_type_name
1909     , p_task_type_id               => p_task_type_id
1910     , p_description                => p_description
1911     , p_task_status_name           => p_task_status_name
1912     , p_task_status_id             => p_task_status_id
1913     , p_task_priority_name         => p_task_priority_name
1914     , p_task_priority_id           => p_task_priority_id
1915     , p_owner_type_name            => p_owner_type_name
1916     , p_owner_type_code            => p_owner_type_code
1917     , p_owner_id                   => p_owner_id
1918     , p_owner_territory_id         => p_owner_territory_id
1919     , p_assigned_by_name           => p_assigned_by_name
1920     , p_assigned_by_id             => p_assigned_by_id
1921     , p_customer_number            => p_customer_number
1922     , p_customer_id                => p_customer_id
1923     , p_cust_account_number        => p_cust_account_number
1924     , p_cust_account_id            => p_cust_account_id
1925     , p_address_id                 => p_address_id
1926     , p_address_number             => p_address_number
1927     , p_planned_start_date         => p_planned_start_date
1928     , p_planned_end_date           => p_planned_end_date
1929     , p_scheduled_start_date       => p_scheduled_start_date
1930     , p_scheduled_end_date         => p_scheduled_end_date
1931     , p_actual_start_date          => p_actual_start_date
1932     , p_actual_end_date            => p_actual_end_date
1933     , p_timezone_id                => p_timezone_id
1934     , p_timezone_name              => p_timezone_name
1935     , p_source_object_type_code    => p_source_object_type_code
1936     , p_source_object_id           => p_source_object_id
1937     , p_source_object_name         => p_source_object_name
1938     , p_duration                   => p_duration
1939     , p_duration_uom               => p_duration_uom
1940     , p_planned_effort             => p_planned_effort
1941     , p_planned_effort_uom         => p_planned_effort_uom
1942     , p_actual_effort              => p_actual_effort
1943     , p_actual_effort_uom          => p_actual_effort_uom
1944     , p_percentage_complete        => p_percentage_complete
1945     , p_reason_code                => p_reason_code
1946     , p_private_flag               => p_private_flag
1947     , p_publish_flag               => p_publish_flag
1948     , p_restrict_closure_flag      => p_restrict_closure_flag
1949     , p_multi_booked_flag          => p_multi_booked_flag
1950     , p_milestone_flag             => p_milestone_flag
1951     , p_holiday_flag               => p_holiday_flag
1952     , p_billable_flag              => p_billable_flag
1953     , p_bound_mode_code            => p_bound_mode_code
1954     , p_soft_bound_flag            => p_soft_bound_flag
1955     , p_workflow_process_id        => p_workflow_process_id
1956     , p_notification_flag          => p_notification_flag
1957     , p_notification_period        => p_notification_period
1958     , p_notification_period_uom    => p_notification_period_uom
1959     , p_parent_task_number         => p_parent_task_number
1960     , p_parent_task_id             => p_parent_task_id
1961     , p_alarm_start                => p_alarm_start
1962     , p_alarm_start_uom            => p_alarm_start_uom
1963     , p_alarm_on                   => p_alarm_on
1964     , p_alarm_count                => p_alarm_count
1965     , p_alarm_interval             => p_alarm_interval
1966     , p_alarm_interval_uom         => p_alarm_interval_uom
1967     , p_palm_flag                  => p_palm_flag
1968     , p_wince_flag                 => p_wince_flag
1969     , p_laptop_flag                => p_laptop_flag
1970     , p_device1_flag               => p_device1_flag
1971     , p_device2_flag               => p_device2_flag
1972     , p_device3_flag               => p_device3_flag
1973     , p_costs                      => p_costs
1974     , p_currency_code              => p_currency_code
1975     , p_escalation_level           => p_escalation_level
1976     , p_task_assign_tbl            => p_task_assign_tbl
1977     , p_task_depends_tbl           => p_task_depends_tbl
1978     , p_task_rsrc_req_tbl          => p_task_rsrc_req_tbl
1979     , p_task_refer_tbl             => p_task_refer_tbl
1980     , p_task_dates_tbl             => p_task_dates_tbl
1981     , p_task_notes_tbl             => p_task_notes_tbl
1982     , p_task_recur_rec             => p_task_recur_rec
1983     , p_task_contacts_tbl          => p_task_contacts_tbl
1984     , x_return_status              => x_return_status
1985     , x_msg_count                  => x_msg_count
1986     , x_msg_data                   => x_msg_data
1987     , x_task_id                    => x_task_id
1988     , p_attribute1                 => p_attribute1
1989     , p_attribute2                 => p_attribute2
1990     , p_attribute3                 => p_attribute3
1991     , p_attribute4                 => p_attribute4
1992     , p_attribute5                 => p_attribute5
1993     , p_attribute6                 => p_attribute6
1994     , p_attribute7                 => p_attribute7
1995     , p_attribute8                 => p_attribute8
1996     , p_attribute9                 => p_attribute9
1997     , p_attribute10                => p_attribute10
1998     , p_attribute11                => p_attribute11
1999     , p_attribute12                => p_attribute12
2000     , p_attribute13                => p_attribute13
2001     , p_attribute14                => p_attribute14
2002     , p_attribute15                => p_attribute15
2003     , p_attribute_category         => p_attribute_category
2004     , p_date_selected              => p_date_selected
2005     , p_category_id                => p_category_id
2006     , p_show_on_calendar           => p_show_on_calendar
2007     , p_owner_status_id            => p_owner_status_id
2008     , p_template_id                => p_template_id
2009     , p_template_group_id          => p_template_group_id
2010     , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
2011     , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
2012     , p_task_split_flag            => NULL
2013     , p_reference_flag             => NULL
2014     , p_child_position             => NULL
2015     , p_child_sequence_num         => NULL
2016     , p_location_id                => NULL
2017     );
2018 
2019     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2020       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2021       RAISE fnd_api.g_exc_unexpected_error;
2022     END IF;
2023 
2024     IF fnd_api.to_boolean(p_commit) THEN
2025       COMMIT WORK;
2026     END IF;
2027 
2028     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2029   EXCEPTION
2030     WHEN fnd_api.g_exc_unexpected_error THEN
2031       ROLLBACK TO create_task_pub2;
2032       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2033       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2034     WHEN OTHERS THEN
2035       ROLLBACK TO create_task_pub2;
2036       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2037       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2038       fnd_msg_pub.ADD;
2039       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2040       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2041   END;
2042 
2043   -- Old Version
2044   PROCEDURE update_task(
2045     p_api_version             IN            NUMBER
2046   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
2047   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
2048   , p_object_version_number   IN OUT NOCOPY NUMBER
2049   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
2050   , p_task_number             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2051   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2052   , p_task_type_name          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2053   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2054   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2055   , p_task_status_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2056   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2057   , p_task_priority_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2058   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2059   , p_owner_type_name         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2060   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2061   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2062   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
2063   , p_assigned_by_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2064   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2065   , p_customer_number         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2066   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2067   , p_cust_account_number     IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2068   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
2069   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2070   , p_address_number          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2071   , p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2072   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2073   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
2074   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
2075   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
2076   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
2077   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2078   , p_timezone_name           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2079   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2080   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2081   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2082   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
2083   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2084   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
2085   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2086   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
2087   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2088   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
2089   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2090   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2091   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2092   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2093   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2094   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2095   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2096   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2097   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2098   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2099   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
2100   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2101   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
2102   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2103   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
2104   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2105   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2106   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
2107   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
2108   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
2109   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2110   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2111   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2112   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2113   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2114   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2115   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2116   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2117   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2118   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2119   , x_return_status           OUT NOCOPY    VARCHAR2
2120   , x_msg_count               OUT NOCOPY    NUMBER
2121   , x_msg_data                OUT NOCOPY    VARCHAR2
2122   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2123   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2124   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2125   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2126   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2127   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2128   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2129   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2130   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2131   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2132   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2133   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2134   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2135   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2136   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2137   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2138   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2139   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2140   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2141   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2142   , p_parent_task_id          IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2143   , p_parent_task_number      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2144   ) IS
2145     l_api_version CONSTANT NUMBER       := 1.0;
2146     l_api_name    CONSTANT VARCHAR2(30) := 'UPDATE_TASK';
2147   BEGIN
2148     SAVEPOINT update_task_pub1;
2149 
2150     -----------
2151     -----------
2152     -----------
2153     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
2154       RAISE fnd_api.g_exc_unexpected_error;
2155     END IF;
2156 
2157     IF fnd_api.to_boolean(p_init_msg_list) THEN
2158       fnd_msg_pub.initialize;
2159     END IF;
2160 
2161     update_task
2162              (
2163       p_api_version                => 1.0
2164     , p_init_msg_list              => fnd_api.g_false
2165     ,   --commented out as it cleared stack fnd_api.g_true,
2166       p_commit                     => fnd_api.g_false
2167     , p_object_version_number      => p_object_version_number
2168     , p_task_id                    => p_task_id
2169     , p_task_number                => p_task_number
2170     , p_task_name                  => p_task_name
2171     , p_task_type_name             => p_task_type_name
2172     , p_task_type_id               => p_task_type_id
2173     , p_description                => p_description
2174     , p_task_status_name           => p_task_status_name
2175     , p_task_status_id             => p_task_status_id
2176     , p_task_priority_name         => p_task_priority_name
2177     , p_task_priority_id           => p_task_priority_id
2178     , p_owner_type_name            => p_owner_type_name
2179     , p_owner_type_code            => p_owner_type_code
2180     , p_owner_id                   => p_owner_id
2181     , p_owner_territory_id         => p_owner_territory_id
2182     , p_assigned_by_name           => p_assigned_by_name
2183     , p_assigned_by_id             => p_assigned_by_id
2184     , p_customer_number            => p_customer_number
2185     , p_customer_id                => p_customer_id
2186     , p_cust_account_number        => p_cust_account_number
2187     , p_cust_account_id            => p_cust_account_id
2188     , p_address_id                 => p_address_id
2189     , p_address_number             => p_address_number
2190     , p_planned_start_date         => p_planned_start_date
2191     , p_planned_end_date           => p_planned_end_date
2192     , p_scheduled_start_date       => p_scheduled_start_date
2193     , p_scheduled_end_date         => p_scheduled_end_date
2194     , p_actual_start_date          => p_actual_start_date
2195     , p_actual_end_date            => p_actual_end_date
2196     , p_timezone_id                => p_timezone_id
2197     , p_timezone_name              => p_timezone_name
2198     , p_source_object_type_code    => p_source_object_type_code
2199     , p_source_object_id           => p_source_object_id
2200     , p_source_object_name         => p_source_object_name
2201     , p_duration                   => p_duration
2202     , p_duration_uom               => p_duration_uom
2203     , p_planned_effort             => p_planned_effort
2204     , p_planned_effort_uom         => p_planned_effort_uom
2205     , p_actual_effort              => p_actual_effort
2206     , p_actual_effort_uom          => p_actual_effort_uom
2207     , p_percentage_complete        => p_percentage_complete
2208     , p_reason_code                => p_reason_code
2209     , p_private_flag               => p_private_flag
2210     , p_publish_flag               => p_publish_flag
2211     , p_restrict_closure_flag      => p_restrict_closure_flag
2212     , p_multi_booked_flag          => p_multi_booked_flag
2213     , p_milestone_flag             => p_milestone_flag
2214     , p_holiday_flag               => p_holiday_flag
2215     , p_billable_flag              => p_billable_flag
2216     , p_bound_mode_code            => p_bound_mode_code
2217     , p_soft_bound_flag            => p_soft_bound_flag
2218     , p_workflow_process_id        => p_workflow_process_id
2219     , p_notification_flag          => p_notification_flag
2220     , p_notification_period        => p_notification_period
2221     , p_notification_period_uom    => p_notification_period_uom
2222     , p_alarm_start                => p_alarm_start
2223     , p_alarm_start_uom            => p_alarm_start_uom
2224     , p_alarm_on                   => p_alarm_on
2225     , p_alarm_count                => p_alarm_count
2226     , p_alarm_fired_count          => p_alarm_fired_count
2227     , p_alarm_interval             => p_alarm_interval
2228     , p_alarm_interval_uom         => p_alarm_interval_uom
2229     , p_palm_flag                  => p_palm_flag
2230     , p_wince_flag                 => p_wince_flag
2231     , p_laptop_flag                => p_laptop_flag
2232     , p_device1_flag               => p_device1_flag
2233     , p_device2_flag               => p_device2_flag
2234     , p_device3_flag               => p_device3_flag
2235     , p_costs                      => p_costs
2236     , p_currency_code              => p_currency_code
2237     , p_escalation_level           => p_escalation_level
2238     , x_return_status              => x_return_status
2239     , x_msg_count                  => x_msg_count
2240     , x_msg_data                   => x_msg_data
2241     , p_attribute1                 => p_attribute1
2242     , p_attribute2                 => p_attribute2
2243     , p_attribute3                 => p_attribute3
2244     , p_attribute4                 => p_attribute4
2245     , p_attribute5                 => p_attribute5
2246     , p_attribute6                 => p_attribute6
2247     , p_attribute7                 => p_attribute7
2248     , p_attribute8                 => p_attribute8
2249     , p_attribute9                 => p_attribute9
2250     , p_attribute10                => p_attribute10
2251     , p_attribute11                => p_attribute11
2252     , p_attribute12                => p_attribute12
2253     , p_attribute13                => p_attribute13
2254     , p_attribute14                => p_attribute14
2255     , p_attribute15                => p_attribute15
2256     , p_attribute_category         => p_attribute_category
2257     , p_date_selected              => p_date_selected
2258     , p_category_id                => p_category_id
2259     , p_show_on_calendar           => p_show_on_calendar
2260     , p_owner_status_id            => p_owner_status_id
2261     , p_parent_task_id             => p_parent_task_id
2262     , p_parent_task_number         => p_parent_task_number
2263     , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
2264     , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
2265     );
2266 
2267     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2268       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2269       RAISE fnd_api.g_exc_unexpected_error;
2270     END IF;
2271 
2272     -------
2273     -------
2274     -------
2275     IF fnd_api.to_boolean(p_commit) THEN
2276       COMMIT WORK;
2277     END IF;
2278 
2279     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2280   EXCEPTION
2281     WHEN fnd_api.g_exc_unexpected_error THEN
2282       ROLLBACK TO update_task_pub1;
2283       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2284       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2285     WHEN OTHERS THEN
2286       ROLLBACK TO update_task_pub1;
2287       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2288       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2289       fnd_msg_pub.ADD;
2290       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2291       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2292   END;
2293 
2294   -- Old Version
2295   PROCEDURE update_task(
2296     p_api_version             IN            NUMBER
2297   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
2298   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
2299   , p_object_version_number   IN OUT NOCOPY NUMBER
2300   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
2301   , p_task_number             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2302   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2303   , p_task_type_name          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2304   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2305   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2306   , p_task_status_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2307   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2308   , p_task_priority_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2309   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2310   , p_owner_type_name         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2311   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2312   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2313   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
2314   , p_assigned_by_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2315   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2316   , p_customer_number         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2317   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2318   , p_cust_account_number     IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2319   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
2320   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2321   , p_address_number          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2322   , p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2323   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2324   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
2325   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
2326   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
2327   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
2328   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2329   , p_timezone_name           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2330   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2331   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2332   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2333   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
2334   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2335   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
2336   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2337   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
2338   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2339   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
2340   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2341   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2342   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2343   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2344   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2345   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2346   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2347   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2348   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2349   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2350   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
2351   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2352   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
2353   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2354   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
2355   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2356   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2357   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
2358   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
2359   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
2360   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2361   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2362   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2363   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2364   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2365   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2366   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2367   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2368   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2369   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2370   , x_return_status           OUT NOCOPY    VARCHAR2
2371   , x_msg_count               OUT NOCOPY    NUMBER
2372   , x_msg_data                OUT NOCOPY    VARCHAR2
2373   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2374   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2375   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2376   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2377   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2378   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2379   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2380   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2381   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2382   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2383   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2384   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2385   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2386   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2387   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2388   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2389   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2390   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2391   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2392   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2393   , p_parent_task_id          IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2394   , p_parent_task_number      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2395   , p_enable_workflow         IN            VARCHAR2
2396   , p_abort_workflow          IN            VARCHAR2
2397   ) IS
2398     l_api_version CONSTANT NUMBER       := 1.0;
2399     l_api_name    CONSTANT VARCHAR2(30) := 'UPDATE_TASK';
2400   BEGIN
2401     SAVEPOINT update_task_pub2;
2402 
2403     -----------
2404     -----------
2405     -----------
2406     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
2407       RAISE fnd_api.g_exc_unexpected_error;
2408     END IF;
2409 
2410     IF fnd_api.to_boolean(p_init_msg_list) THEN
2411       fnd_msg_pub.initialize;
2412     END IF;
2413 
2414     update_task
2415              (
2416       p_api_version                => 1.0
2417     , p_init_msg_list              => fnd_api.g_false
2418     ,   --commented out as it cleared stack fnd_api.g_true,
2419       p_commit                     => fnd_api.g_false
2420     , p_object_version_number      => p_object_version_number
2421     , p_task_id                    => p_task_id
2422     , p_task_number                => p_task_number
2423     , p_task_name                  => p_task_name
2424     , p_task_type_name             => p_task_type_name
2425     , p_task_type_id               => p_task_type_id
2426     , p_description                => p_description
2427     , p_task_status_name           => p_task_status_name
2428     , p_task_status_id             => p_task_status_id
2429     , p_task_priority_name         => p_task_priority_name
2430     , p_task_priority_id           => p_task_priority_id
2431     , p_owner_type_name            => p_owner_type_name
2432     , p_owner_type_code            => p_owner_type_code
2433     , p_owner_id                   => p_owner_id
2434     , p_owner_territory_id         => p_owner_territory_id
2435     , p_assigned_by_name           => p_assigned_by_name
2436     , p_assigned_by_id             => p_assigned_by_id
2437     , p_customer_number            => p_customer_number
2438     , p_customer_id                => p_customer_id
2439     , p_cust_account_number        => p_cust_account_number
2440     , p_cust_account_id            => p_cust_account_id
2441     , p_address_id                 => p_address_id
2442     , p_address_number             => p_address_number
2443     , p_planned_start_date         => p_planned_start_date
2444     , p_planned_end_date           => p_planned_end_date
2445     , p_scheduled_start_date       => p_scheduled_start_date
2446     , p_scheduled_end_date         => p_scheduled_end_date
2447     , p_actual_start_date          => p_actual_start_date
2448     , p_actual_end_date            => p_actual_end_date
2449     , p_timezone_id                => p_timezone_id
2450     , p_timezone_name              => p_timezone_name
2451     , p_source_object_type_code    => p_source_object_type_code
2452     , p_source_object_id           => p_source_object_id
2453     , p_source_object_name         => p_source_object_name
2454     , p_duration                   => p_duration
2455     , p_duration_uom               => p_duration_uom
2456     , p_planned_effort             => p_planned_effort
2457     , p_planned_effort_uom         => p_planned_effort_uom
2458     , p_actual_effort              => p_actual_effort
2459     , p_actual_effort_uom          => p_actual_effort_uom
2460     , p_percentage_complete        => p_percentage_complete
2461     , p_reason_code                => p_reason_code
2462     , p_private_flag               => p_private_flag
2463     , p_publish_flag               => p_publish_flag
2464     , p_restrict_closure_flag      => p_restrict_closure_flag
2465     , p_multi_booked_flag          => p_multi_booked_flag
2466     , p_milestone_flag             => p_milestone_flag
2467     , p_holiday_flag               => p_holiday_flag
2468     , p_billable_flag              => p_billable_flag
2469     , p_bound_mode_code            => p_bound_mode_code
2470     , p_soft_bound_flag            => p_soft_bound_flag
2471     , p_workflow_process_id        => p_workflow_process_id
2472     , p_notification_flag          => p_notification_flag
2473     , p_notification_period        => p_notification_period
2474     , p_notification_period_uom    => p_notification_period_uom
2475     , p_alarm_start                => p_alarm_start
2476     , p_alarm_start_uom            => p_alarm_start_uom
2477     , p_alarm_on                   => p_alarm_on
2478     , p_alarm_count                => p_alarm_count
2479     , p_alarm_fired_count          => p_alarm_fired_count
2480     , p_alarm_interval             => p_alarm_interval
2481     , p_alarm_interval_uom         => p_alarm_interval_uom
2482     , p_palm_flag                  => p_palm_flag
2483     , p_wince_flag                 => p_wince_flag
2484     , p_laptop_flag                => p_laptop_flag
2485     , p_device1_flag               => p_device1_flag
2486     , p_device2_flag               => p_device2_flag
2487     , p_device3_flag               => p_device3_flag
2488     , p_costs                      => p_costs
2489     , p_currency_code              => p_currency_code
2490     , p_escalation_level           => p_escalation_level
2491     , x_return_status              => x_return_status
2492     , x_msg_count                  => x_msg_count
2493     , x_msg_data                   => x_msg_data
2494     , p_attribute1                 => p_attribute1
2495     , p_attribute2                 => p_attribute2
2496     , p_attribute3                 => p_attribute3
2497     , p_attribute4                 => p_attribute4
2498     , p_attribute5                 => p_attribute5
2499     , p_attribute6                 => p_attribute6
2500     , p_attribute7                 => p_attribute7
2501     , p_attribute8                 => p_attribute8
2502     , p_attribute9                 => p_attribute9
2503     , p_attribute10                => p_attribute10
2504     , p_attribute11                => p_attribute11
2505     , p_attribute12                => p_attribute12
2506     , p_attribute13                => p_attribute13
2507     , p_attribute14                => p_attribute14
2508     , p_attribute15                => p_attribute15
2509     , p_attribute_category         => p_attribute_category
2510     , p_date_selected              => p_date_selected
2511     , p_category_id                => p_category_id
2512     , p_show_on_calendar           => p_show_on_calendar
2513     , p_owner_status_id            => p_owner_status_id
2514     , p_parent_task_id             => p_parent_task_id
2515     , p_parent_task_number         => p_parent_task_number
2516     , p_enable_workflow            => p_enable_workflow
2517     , p_abort_workflow             => p_abort_workflow
2518     , p_task_split_flag            => fnd_api.g_miss_char
2519     , p_child_position             => fnd_api.g_miss_char
2520     , p_child_sequence_num         => fnd_api.g_miss_num
2521     );
2522 
2523     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2524       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2525       RAISE fnd_api.g_exc_unexpected_error;
2526     END IF;
2527 
2528     -------
2529     -------
2530     -------
2531     IF fnd_api.to_boolean(p_commit) THEN
2532       COMMIT WORK;
2533     END IF;
2534 
2535     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2536   EXCEPTION
2537     WHEN fnd_api.g_exc_unexpected_error THEN
2538       ROLLBACK TO update_task_pub2;
2539       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2540       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2541     WHEN OTHERS THEN
2542       ROLLBACK TO update_task_pub2;
2543       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2544       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2545       fnd_msg_pub.ADD;
2546       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2547       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2548   END;
2549 
2550   -- Old version
2551   PROCEDURE update_task(
2552     p_api_version             IN            NUMBER
2553   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
2554   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
2555   , p_object_version_number   IN OUT NOCOPY NUMBER
2556   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
2557   , p_task_number             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2558   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2559   , p_task_type_name          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2560   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2561   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2562   , p_task_status_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2563   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2564   , p_task_priority_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2565   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2566   , p_owner_type_name         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2567   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2568   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2569   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
2570   , p_assigned_by_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2571   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2572   , p_customer_number         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2573   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2574   , p_cust_account_number     IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2575   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
2576   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2577   , p_address_number          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2578   , p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2579   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2580   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
2581   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
2582   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
2583   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
2584   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2585   , p_timezone_name           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2586   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2587   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2588   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2589   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
2590   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2591   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
2592   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2593   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
2594   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2595   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
2596   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2597   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2598   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2599   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2600   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2601   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2602   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2603   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2604   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2605   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2606   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
2607   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2608   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
2609   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2610   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
2611   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2612   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2613   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
2614   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
2615   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
2616   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2617   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2618   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2619   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2620   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2621   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2622   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2623   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2624   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2625   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2626   , x_return_status           OUT NOCOPY    VARCHAR2
2627   , x_msg_count               OUT NOCOPY    NUMBER
2628   , x_msg_data                OUT NOCOPY    VARCHAR2
2629   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2630   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2631   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2632   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2633   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2634   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2635   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2636   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2637   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2638   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2639   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2640   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2641   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2642   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2643   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2644   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2645   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2646   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2647   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2648   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2649   , p_parent_task_id          IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2650   , p_parent_task_number      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2651   , p_enable_workflow         IN            VARCHAR2
2652   , p_abort_workflow          IN            VARCHAR2
2653   , p_task_split_flag         IN            VARCHAR2
2654   , p_child_position          IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2655   , p_child_sequence_num      IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2656   ) IS
2657     l_api_version CONSTANT NUMBER       := 1.0;
2658     l_api_name    CONSTANT VARCHAR2(30) := 'UPDATE_TASK';
2659   BEGIN
2660     SAVEPOINT update_task_pub3;
2661 
2662     -----------
2663     -----------
2664     -----------
2665     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
2666       RAISE fnd_api.g_exc_unexpected_error;
2667     END IF;
2668 
2669     IF fnd_api.to_boolean(p_init_msg_list) THEN
2670       fnd_msg_pub.initialize;
2671     END IF;
2672 
2673     update_task
2674              (
2675       p_api_version                => 1.0
2676     , p_init_msg_list              => fnd_api.g_false
2677     ,   --commented out as it cleared stack fnd_api.g_true,
2678       p_commit                     => fnd_api.g_false
2679     , p_object_version_number      => p_object_version_number
2680     , p_task_id                    => p_task_id
2681     , p_task_number                => p_task_number
2682     , p_task_name                  => p_task_name
2683     , p_task_type_name             => p_task_type_name
2684     , p_task_type_id               => p_task_type_id
2685     , p_description                => p_description
2686     , p_task_status_name           => p_task_status_name
2687     , p_task_status_id             => p_task_status_id
2688     , p_task_priority_name         => p_task_priority_name
2689     , p_task_priority_id           => p_task_priority_id
2690     , p_owner_type_name            => p_owner_type_name
2691     , p_owner_type_code            => p_owner_type_code
2692     , p_owner_id                   => p_owner_id
2693     , p_owner_territory_id         => p_owner_territory_id
2694     , p_assigned_by_name           => p_assigned_by_name
2695     , p_assigned_by_id             => p_assigned_by_id
2696     , p_customer_number            => p_customer_number
2697     , p_customer_id                => p_customer_id
2698     , p_cust_account_number        => p_cust_account_number
2699     , p_cust_account_id            => p_cust_account_id
2700     , p_address_id                 => p_address_id
2701     , p_address_number             => p_address_number
2702     , p_planned_start_date         => p_planned_start_date
2703     , p_planned_end_date           => p_planned_end_date
2704     , p_scheduled_start_date       => p_scheduled_start_date
2705     , p_scheduled_end_date         => p_scheduled_end_date
2706     , p_actual_start_date          => p_actual_start_date
2707     , p_actual_end_date            => p_actual_end_date
2708     , p_timezone_id                => p_timezone_id
2709     , p_timezone_name              => p_timezone_name
2710     , p_source_object_type_code    => p_source_object_type_code
2711     , p_source_object_id           => p_source_object_id
2712     , p_source_object_name         => p_source_object_name
2713     , p_duration                   => p_duration
2714     , p_duration_uom               => p_duration_uom
2715     , p_planned_effort             => p_planned_effort
2716     , p_planned_effort_uom         => p_planned_effort_uom
2717     , p_actual_effort              => p_actual_effort
2718     , p_actual_effort_uom          => p_actual_effort_uom
2719     , p_percentage_complete        => p_percentage_complete
2720     , p_reason_code                => p_reason_code
2721     , p_private_flag               => p_private_flag
2722     , p_publish_flag               => p_publish_flag
2723     , p_restrict_closure_flag      => p_restrict_closure_flag
2724     , p_multi_booked_flag          => p_multi_booked_flag
2725     , p_milestone_flag             => p_milestone_flag
2726     , p_holiday_flag               => p_holiday_flag
2727     , p_billable_flag              => p_billable_flag
2728     , p_bound_mode_code            => p_bound_mode_code
2729     , p_soft_bound_flag            => p_soft_bound_flag
2730     , p_workflow_process_id        => p_workflow_process_id
2731     , p_notification_flag          => p_notification_flag
2732     , p_notification_period        => p_notification_period
2733     , p_notification_period_uom    => p_notification_period_uom
2734     , p_alarm_start                => p_alarm_start
2735     , p_alarm_start_uom            => p_alarm_start_uom
2736     , p_alarm_on                   => p_alarm_on
2737     , p_alarm_count                => p_alarm_count
2738     , p_alarm_fired_count          => p_alarm_fired_count
2739     , p_alarm_interval             => p_alarm_interval
2740     , p_alarm_interval_uom         => p_alarm_interval_uom
2741     , p_palm_flag                  => p_palm_flag
2742     , p_wince_flag                 => p_wince_flag
2743     , p_laptop_flag                => p_laptop_flag
2744     , p_device1_flag               => p_device1_flag
2745     , p_device2_flag               => p_device2_flag
2746     , p_device3_flag               => p_device3_flag
2747     , p_costs                      => p_costs
2748     , p_currency_code              => p_currency_code
2749     , p_escalation_level           => p_escalation_level
2750     , x_return_status              => x_return_status
2751     , x_msg_count                  => x_msg_count
2752     , x_msg_data                   => x_msg_data
2753     , p_attribute1                 => p_attribute1
2754     , p_attribute2                 => p_attribute2
2755     , p_attribute3                 => p_attribute3
2756     , p_attribute4                 => p_attribute4
2757     , p_attribute5                 => p_attribute5
2758     , p_attribute6                 => p_attribute6
2759     , p_attribute7                 => p_attribute7
2760     , p_attribute8                 => p_attribute8
2761     , p_attribute9                 => p_attribute9
2762     , p_attribute10                => p_attribute10
2763     , p_attribute11                => p_attribute11
2764     , p_attribute12                => p_attribute12
2765     , p_attribute13                => p_attribute13
2766     , p_attribute14                => p_attribute14
2767     , p_attribute15                => p_attribute15
2768     , p_attribute_category         => p_attribute_category
2769     , p_date_selected              => p_date_selected
2770     , p_category_id                => p_category_id
2771     , p_show_on_calendar           => p_show_on_calendar
2772     , p_owner_status_id            => p_owner_status_id
2773     , p_parent_task_id             => p_parent_task_id
2774     , p_parent_task_number         => p_parent_task_number
2775     , p_enable_workflow            => p_enable_workflow
2776     , p_abort_workflow             => p_abort_workflow
2777     , p_task_split_flag            => p_task_split_flag
2778     , p_child_position             => p_child_position
2779     , p_child_sequence_num         => p_child_sequence_num
2780     , p_location_id                => fnd_api.g_miss_num
2781     );
2782 
2783     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
2784       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2785       RAISE fnd_api.g_exc_unexpected_error;
2786     END IF;
2787 
2788     -------
2789     -------
2790     -------
2791     IF fnd_api.to_boolean(p_commit) THEN
2792       COMMIT WORK;
2793     END IF;
2794 
2795     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2796   EXCEPTION
2797     WHEN fnd_api.g_exc_unexpected_error THEN
2798       ROLLBACK TO update_task_pub3;
2799       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2800       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2801     WHEN OTHERS THEN
2802       ROLLBACK TO update_task_pub3;
2803       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
2804       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
2805       fnd_msg_pub.ADD;
2806       x_return_status  := fnd_api.g_ret_sts_unexp_error;
2807       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
2808   END;
2809 
2810   PROCEDURE update_task(
2811     p_api_version             IN            NUMBER
2812   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
2813   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
2814   , p_object_version_number   IN OUT NOCOPY NUMBER
2815   , p_task_id                 IN            NUMBER DEFAULT fnd_api.g_miss_num
2816   , p_task_number             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2817   , p_task_name               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2818   , p_task_type_name          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2819   , p_task_type_id            IN            NUMBER DEFAULT fnd_api.g_miss_num
2820   , p_description             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2821   , p_task_status_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2822   , p_task_status_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2823   , p_task_priority_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2824   , p_task_priority_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2825   , p_owner_type_name         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2826   , p_owner_type_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2827   , p_owner_id                IN            NUMBER DEFAULT fnd_api.g_miss_num
2828   , p_owner_territory_id      IN            NUMBER DEFAULT fnd_api.g_miss_num
2829   , p_assigned_by_name        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2830   , p_assigned_by_id          IN            NUMBER DEFAULT fnd_api.g_miss_num
2831   , p_customer_number         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2832   , p_customer_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2833   , p_cust_account_number     IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2834   , p_cust_account_id         IN            NUMBER DEFAULT fnd_api.g_miss_num
2835   , p_address_id              IN            NUMBER DEFAULT fnd_api.g_miss_num
2836   , p_address_number          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2837   , p_planned_start_date      IN            DATE DEFAULT fnd_api.g_miss_date
2838   , p_planned_end_date        IN            DATE DEFAULT fnd_api.g_miss_date
2839   , p_scheduled_start_date    IN            DATE DEFAULT fnd_api.g_miss_date
2840   , p_scheduled_end_date      IN            DATE DEFAULT fnd_api.g_miss_date
2841   , p_actual_start_date       IN            DATE DEFAULT fnd_api.g_miss_date
2842   , p_actual_end_date         IN            DATE DEFAULT fnd_api.g_miss_date
2843   , p_timezone_id             IN            NUMBER DEFAULT fnd_api.g_miss_num
2844   , p_timezone_name           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2845   , p_source_object_type_code IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2846   , p_source_object_id        IN            NUMBER DEFAULT fnd_api.g_miss_num
2847   , p_source_object_name      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2848   , p_duration                IN            NUMBER DEFAULT fnd_api.g_miss_num
2849   , p_duration_uom            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2850   , p_planned_effort          IN            NUMBER DEFAULT fnd_api.g_miss_num
2851   , p_planned_effort_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2852   , p_actual_effort           IN            NUMBER DEFAULT fnd_api.g_miss_num
2853   , p_actual_effort_uom       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2854   , p_percentage_complete     IN            NUMBER DEFAULT fnd_api.g_miss_num
2855   , p_reason_code             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2856   , p_private_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2857   , p_publish_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2858   , p_restrict_closure_flag   IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2859   , p_multi_booked_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2860   , p_milestone_flag          IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2861   , p_holiday_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2862   , p_billable_flag           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2863   , p_bound_mode_code         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2864   , p_soft_bound_flag         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2865   , p_workflow_process_id     IN            NUMBER DEFAULT fnd_api.g_miss_num
2866   , p_notification_flag       IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2867   , p_notification_period     IN            NUMBER DEFAULT fnd_api.g_miss_num
2868   , p_notification_period_uom IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2869   , p_alarm_start             IN            NUMBER DEFAULT fnd_api.g_miss_num
2870   , p_alarm_start_uom         IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2871   , p_alarm_on                IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2872   , p_alarm_count             IN            NUMBER DEFAULT fnd_api.g_miss_num
2873   , p_alarm_fired_count       IN            NUMBER DEFAULT fnd_api.g_miss_num
2874   , p_alarm_interval          IN            NUMBER DEFAULT fnd_api.g_miss_num
2875   , p_alarm_interval_uom      IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2876   , p_palm_flag               IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2877   , p_wince_flag              IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2878   , p_laptop_flag             IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2879   , p_device1_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2880   , p_device2_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2881   , p_device3_flag            IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2882   , p_costs                   IN            NUMBER DEFAULT fnd_api.g_miss_num
2883   , p_currency_code           IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2884   , p_escalation_level        IN            VARCHAR2 DEFAULT fnd_api.g_miss_char
2885   , x_return_status           OUT NOCOPY    VARCHAR2
2886   , x_msg_count               OUT NOCOPY    NUMBER
2887   , x_msg_data                OUT NOCOPY    VARCHAR2
2888   , p_attribute1              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2889   , p_attribute2              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2890   , p_attribute3              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2891   , p_attribute4              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2892   , p_attribute5              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2893   , p_attribute6              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2894   , p_attribute7              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2895   , p_attribute8              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2896   , p_attribute9              IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2897   , p_attribute10             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2898   , p_attribute11             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2899   , p_attribute12             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2900   , p_attribute13             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2901   , p_attribute14             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2902   , p_attribute15             IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2903   , p_attribute_category      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2904   , p_date_selected           IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2905   , p_category_id             IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2906   , p_show_on_calendar        IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2907   , p_owner_status_id         IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2908   , p_parent_task_id          IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2909   , p_parent_task_number      IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2910   , p_enable_workflow         IN            VARCHAR2
2911   , p_abort_workflow          IN            VARCHAR2
2912   , p_task_split_flag         IN            VARCHAR2
2913   , p_child_position          IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
2914   , p_child_sequence_num      IN            NUMBER DEFAULT jtf_task_utl.g_miss_number
2915   , p_location_id             IN            NUMBER
2916   ) IS
2917     l_api_version    CONSTANT NUMBER                                               := 1.0;
2918     l_api_name       CONSTANT VARCHAR2(30)                                         := 'UPDATE_TASK';
2919     l_task_id                 jtf_tasks_b.task_id%TYPE                             := p_task_id;
2920     l_task_number             jtf_tasks_b.task_number%TYPE                         := p_task_number;
2921     /* Modified by TSINGHAL dt 8/10/2003 for bug fix 3182170 start */
2922     l_task_name               jtf_tasks_tl.task_name%TYPE;
2923     /* Modified by TSINGHAL dt 8/10/2003 for bug fix 3182170 End */
2924     l_task_type_name          jtf_task_types_tl.NAME%TYPE                       := p_task_type_name;
2925     l_task_type_id            jtf_task_types_b.task_type_id%TYPE                  := p_task_type_id;
2926     l_task_status_name        jtf_task_statuses_tl.NAME%TYPE                  := p_task_status_name;
2927     l_task_status_id          jtf_task_statuses_b.task_status_id%TYPE           := p_task_status_id;
2928     l_task_priority_name      jtf_task_priorities_tl.NAME%TYPE              := p_task_priority_name;
2929     l_task_priority_id        jtf_task_priorities_b.task_priority_id%TYPE     := p_task_priority_id;
2930     l_assigned_by_name        fnd_user.user_name%TYPE                         := p_assigned_by_name;
2931     l_assigned_by_id          NUMBER                                            := p_assigned_by_id;
2932     l_customer_id             hz_parties.party_id%TYPE;
2933     l_customer_number         hz_parties.party_number%TYPE;
2934     l_cust_account_id         hz_cust_accounts.cust_account_id%TYPE;
2935     l_cust_account_number     hz_cust_accounts.account_number%TYPE;
2936     l_address_id              hz_party_sites.party_site_id%TYPE;
2937     l_location_id             hz_locations.location_id%TYPE;
2938     l_address_number          hz_party_sites.party_site_number%TYPE;
2939     l_planned_start_date      DATE;
2940     l_planned_end_date        DATE;
2941     l_scheduled_start_date    DATE;
2942     l_scheduled_end_date      DATE;
2943     l_actual_start_date       DATE;
2944     l_actual_end_date         DATE;
2945     l_source_object_type_code jtf_tasks_b.source_object_type_code%TYPE;
2946     l_source_object_id        jtf_tasks_b.source_object_id%TYPE;
2947     l_source_object_name      jtf_tasks_b.source_object_name%TYPE;
2948     l_timezone_id             jtf_tasks_b.timezone_id%TYPE                         := p_timezone_id;
2949     l_timezone_name           hz_timezones.global_timezone_name%TYPE             := p_timezone_name;
2950     l_duration                jtf_tasks_b.DURATION%TYPE;
2951     l_duration_uom            jtf_tasks_b.duration_uom%TYPE;
2952     l_owner_type_code         jtf_tasks_b.owner_type_code%TYPE;
2953     l_owner_id                jtf_tasks_b.owner_id%TYPE;
2954     l_percentage_complete     jtf_tasks_b.percentage_complete%TYPE;
2955     l_reason_code             jtf_tasks_b.reason_code%TYPE;
2956     l_private_flag            jtf_tasks_b.private_flag%TYPE;
2957     l_publish_flag            jtf_tasks_b.publish_flag%TYPE;
2958     l_restrict_closure_flag   jtf_tasks_b.restrict_closure_flag%TYPE;
2959     l_multi_booked_flag       jtf_tasks_b.multi_booked_flag%TYPE;
2960     l_palm_flag               jtf_tasks_b.palm_flag%TYPE;
2961     l_wince_flag              jtf_tasks_b.wince_flag%TYPE;
2962     l_laptop_flag             jtf_tasks_b.laptop_flag%TYPE;
2963     l_device1_flag            jtf_tasks_b.device1_flag%TYPE;
2964     l_device2_flag            jtf_tasks_b.device2_flag%TYPE;
2965     l_device3_flag            jtf_tasks_b.device3_flag%TYPE;
2966     l_description             jtf_tasks_tl.description%TYPE;
2967     l_planned_effort          jtf_tasks_b.planned_effort%TYPE;
2968     l_planned_effort_uom      jtf_tasks_b.planned_effort_uom%TYPE;
2969     l_actual_effort           jtf_tasks_b.actual_effort%TYPE;
2970     l_actual_effort_uom       jtf_tasks_b.actual_effort_uom%TYPE;
2971     l_milestone_flag          jtf_tasks_b.milestone_flag%TYPE;
2972     l_holiday_flag            jtf_tasks_b.holiday_flag%TYPE;
2973     l_currency_code           jtf_tasks_b.currency_code%TYPE;
2974     l_costs                   jtf_tasks_b.costs%TYPE;
2975     l_notification_flag       jtf_tasks_b.notification_flag%TYPE;
2976     l_notification_period     jtf_tasks_b.notification_period%TYPE;
2977     l_notification_period_uom jtf_tasks_b.notification_period_uom%TYPE;
2978     l_billable_flag           jtf_tasks_b.billable_flag%TYPE;
2979     l_bound_mode_code         jtf_tasks_b.bound_mode_code%TYPE;
2980     l_soft_bound_flag         jtf_tasks_b.soft_bound_flag%TYPE;
2981     l_workflow_process_id     jtf_tasks_b.workflow_process_id%TYPE;
2982     l_parent_task_id          jtf_tasks_b.parent_task_id%TYPE;
2983     l_parent_task_number      jtf_tasks_b.task_number%TYPE;
2984     l_alarm_start             jtf_tasks_b.alarm_start%TYPE;
2985     l_alarm_start_uom         jtf_tasks_b.alarm_start_uom%TYPE;
2986     l_alarm_on                jtf_tasks_b.alarm_on%TYPE;
2987     l_alarm_count             jtf_tasks_b.alarm_count%TYPE;
2988     l_alarm_fired_count       jtf_tasks_b.alarm_fired_count%TYPE;
2989     l_alarm_interval          jtf_tasks_b.alarm_interval%TYPE;
2990     l_alarm_interval_uom      jtf_tasks_b.alarm_interval_uom%TYPE;
2991     l_owner_type_name         jtf_objects_tl.NAME%TYPE;
2992     l_date_selected           jtf_tasks_b.date_selected%TYPE;
2993     l_type                    VARCHAR2(10);
2994     y                         BOOLEAN;
2995     l_task_split_flag         jtf_tasks_b.task_split_flag%TYPE;
2996 
2997     CURSOR c_task_update(l_task_id IN NUMBER) IS
2998       SELECT DECODE(p_task_id, fnd_api.g_miss_num, task_id, p_task_id) task_id
2999            , DECODE(p_task_number, fnd_api.g_miss_char, task_number, p_task_number) task_number
3000            , DECODE(p_task_name, fnd_api.g_miss_char, task_name, p_task_name) task_name
3001            , DECODE(p_task_type_id, fnd_api.g_miss_num, task_type_id, p_task_type_id) task_type_id
3002            , DECODE(p_description, fnd_api.g_miss_char, description, p_description) description
3003            , DECODE(p_task_status_id, fnd_api.g_miss_num, task_status_id, p_task_status_id)
3004                                                                                      task_status_id
3005            , DECODE(p_task_priority_id, fnd_api.g_miss_num, task_priority_id, p_task_priority_id)
3006                                                                                    task_priority_id
3007            , DECODE(p_owner_type_code, fnd_api.g_miss_char, owner_type_code, p_owner_type_code)
3008                                                                                     owner_type_code
3009            , DECODE(p_owner_id, fnd_api.g_miss_num, owner_id, p_owner_id) owner_id
3010            , DECODE(
3011                p_owner_territory_id
3012              , fnd_api.g_miss_num, owner_territory_id
3013              , p_owner_territory_id
3014              ) owner_territory_id
3015            , DECODE(p_assigned_by_id, fnd_api.g_miss_num, assigned_by_id, p_assigned_by_id)
3016                                                                                      assigned_by_id
3017            , DECODE(p_customer_id, fnd_api.g_miss_num, customer_id, p_customer_id) customer_id
3018            , DECODE(p_cust_account_id, fnd_api.g_miss_num, cust_account_id, p_cust_account_id)
3019                                                                                     cust_account_id
3020            , DECODE(p_address_id, fnd_api.g_miss_num, address_id, p_address_id) address_id
3021            , DECODE(p_location_id, fnd_api.g_miss_num, location_id, p_location_id) location_id
3022            , DECODE(
3023                p_planned_start_date
3024              , fnd_api.g_miss_date, planned_start_date
3025              , p_planned_start_date
3026              ) planned_start_date
3027            , DECODE(p_planned_end_date, fnd_api.g_miss_date, planned_end_date, p_planned_end_date)
3028                                                                                    planned_end_date
3029            , DECODE(
3030                p_scheduled_start_date
3031              , fnd_api.g_miss_date, scheduled_start_date
3032              , p_scheduled_start_date
3033              ) scheduled_start_date
3034            , DECODE(
3035                p_scheduled_end_date
3036              , fnd_api.g_miss_date, scheduled_end_date
3037              , p_scheduled_end_date
3038              ) scheduled_end_date
3039            , DECODE(
3040                p_actual_start_date
3041              , fnd_api.g_miss_date, actual_start_date
3042              , p_actual_start_date
3043              ) actual_start_date
3044            , DECODE(p_actual_end_date, fnd_api.g_miss_date, actual_end_date, p_actual_end_date)
3045                                                                                     actual_end_date
3046            , DECODE(p_timezone_id, fnd_api.g_miss_num, timezone_id, p_timezone_id) timezone_id
3047            , DECODE(
3048                p_source_object_type_code
3049              , fnd_api.g_miss_char, source_object_type_code
3050              , p_source_object_type_code
3051              ) source_object_type_code
3052            , DECODE(p_source_object_id, fnd_api.g_miss_num, source_object_id, p_source_object_id)
3053                                                                                    source_object_id
3054            , DECODE(
3055                p_source_object_name
3056              , fnd_api.g_miss_char, source_object_name
3057              , jtf_task_utl.check_truncation(p_source_object_name)
3058              ) source_object_name
3059            , DECODE(p_duration, fnd_api.g_miss_num, DURATION, p_duration) DURATION
3060            , DECODE(p_duration_uom, fnd_api.g_miss_char, duration_uom, p_duration_uom) duration_uom
3061            , DECODE(p_planned_effort, fnd_api.g_miss_num, planned_effort, p_planned_effort)
3062                                                                                      planned_effort
3063            , DECODE(
3064                p_planned_effort_uom
3065              , fnd_api.g_miss_char, planned_effort_uom
3066              , p_planned_effort_uom
3067              ) planned_effort_uom
3068            , DECODE(p_actual_effort, fnd_api.g_miss_num, actual_effort, p_actual_effort)
3069                                                                                       actual_effort
3070            , DECODE(
3071                p_actual_effort_uom
3072              , fnd_api.g_miss_char, actual_effort_uom
3073              , p_actual_effort_uom
3074              ) actual_effort_uom
3075            , DECODE(
3076                p_percentage_complete
3077              , fnd_api.g_miss_num, percentage_complete
3078              , p_percentage_complete
3079              ) percentage_complete
3080            , DECODE(p_reason_code, fnd_api.g_miss_char, reason_code, p_reason_code) reason_code
3081            , DECODE(p_private_flag, fnd_api.g_miss_char, private_flag, p_private_flag) private_flag
3082            , DECODE(p_publish_flag, fnd_api.g_miss_char, publish_flag, p_publish_flag) publish_flag
3083            , DECODE(
3084                p_restrict_closure_flag
3085              , fnd_api.g_miss_char, restrict_closure_flag
3086              , p_restrict_closure_flag
3087              ) restrict_closure_flag
3088            , DECODE(
3089                p_multi_booked_flag
3090              , fnd_api.g_miss_char, multi_booked_flag
3091              , p_multi_booked_flag
3092              ) multi_booked_flag
3093            , DECODE(p_milestone_flag, fnd_api.g_miss_char, milestone_flag, p_milestone_flag)
3094                                                                                      milestone_flag
3095            , DECODE(p_holiday_flag, fnd_api.g_miss_char, holiday_flag, p_holiday_flag) holiday_flag
3096            , DECODE(p_billable_flag, fnd_api.g_miss_char, billable_flag, p_billable_flag)
3097                                                                                       billable_flag
3098            , DECODE(p_bound_mode_code, fnd_api.g_miss_char, bound_mode_code, p_bound_mode_code)
3099                                                                                     bound_mode_code
3100            , DECODE(p_soft_bound_flag, fnd_api.g_miss_char, soft_bound_flag, p_soft_bound_flag)
3101                                                                                     soft_bound_flag
3102            , DECODE(
3103                p_workflow_process_id
3104              , fnd_api.g_miss_num, workflow_process_id
3105              , p_workflow_process_id
3106              ) workflow_process_id
3107            , DECODE(
3108                p_notification_flag
3109              , fnd_api.g_miss_char, notification_flag
3110              , p_notification_flag
3111              ) notification_flag
3112            , DECODE(
3113                p_notification_period
3114              , fnd_api.g_miss_num, notification_period
3115              , p_notification_period
3116              ) notification_period
3117            , DECODE(
3118                p_notification_period_uom
3119              , fnd_api.g_miss_char, notification_period_uom
3120              , p_notification_period_uom
3121              ) notification_period_uom
3122            , DECODE(p_alarm_start, fnd_api.g_miss_num, alarm_start, p_alarm_start) alarm_start
3123            , DECODE(p_alarm_start_uom, fnd_api.g_miss_char, alarm_start_uom, p_alarm_start_uom)
3124                                                                                     alarm_start_uom
3125            , DECODE(p_alarm_on, fnd_api.g_miss_char, alarm_on, p_alarm_on) alarm_on
3126            , DECODE(p_alarm_count, fnd_api.g_miss_num, alarm_count, p_alarm_count) alarm_count
3127            , DECODE(
3128                p_alarm_fired_count
3129              , fnd_api.g_miss_num, alarm_fired_count
3130              , p_alarm_fired_count
3131              ) alarm_fired_count
3132            , DECODE(p_alarm_interval, fnd_api.g_miss_num, alarm_interval, p_alarm_interval)
3133                                                                                      alarm_interval
3134            , DECODE(
3135                p_alarm_interval_uom
3136              , fnd_api.g_miss_char, alarm_interval_uom
3137              , p_alarm_interval_uom
3138              ) alarm_interval_uom
3139            , DECODE(p_palm_flag, fnd_api.g_miss_char, palm_flag, p_palm_flag) palm_flag
3140            , DECODE(p_wince_flag, fnd_api.g_miss_char, wince_flag, p_wince_flag) wince_flag
3141            , DECODE(p_laptop_flag, fnd_api.g_miss_char, laptop_flag, p_laptop_flag) laptop_flag
3142            , DECODE(p_device1_flag, fnd_api.g_miss_char, device1_flag, p_device1_flag) device1_flag
3143            , DECODE(p_device2_flag, fnd_api.g_miss_char, device2_flag, p_device2_flag) device2_flag
3144            , DECODE(p_device3_flag, fnd_api.g_miss_char, device3_flag, p_device3_flag) device3_flag
3145            , DECODE(p_costs, fnd_api.g_miss_num, costs, p_costs) costs
3146            , DECODE(p_currency_code, fnd_api.g_miss_char, currency_code, p_currency_code)
3147                                                                                       currency_code
3148            , DECODE(p_escalation_level, fnd_api.g_miss_char, escalation_level, p_escalation_level)
3149                                                                                    escalation_level
3150            , DECODE(p_attribute1, fnd_api.g_miss_char, attribute1, p_attribute1) attribute1
3151            , DECODE(p_attribute2, fnd_api.g_miss_char, attribute2, p_attribute2) attribute2
3152            , DECODE(p_attribute3, fnd_api.g_miss_char, attribute3, p_attribute3) attribute3
3153            , DECODE(p_attribute4, fnd_api.g_miss_char, attribute4, p_attribute4) attribute4
3154            , DECODE(p_attribute5, fnd_api.g_miss_char, attribute5, p_attribute5) attribute5
3155            , DECODE(p_attribute6, fnd_api.g_miss_char, attribute6, p_attribute6) attribute6
3156            , DECODE(p_attribute7, fnd_api.g_miss_char, attribute7, p_attribute7) attribute7
3157            , DECODE(p_attribute8, fnd_api.g_miss_char, attribute8, p_attribute8) attribute8
3158            , DECODE(p_attribute9, fnd_api.g_miss_char, attribute9, p_attribute9) attribute9
3159            , DECODE(p_attribute10, fnd_api.g_miss_char, attribute10, p_attribute10) attribute10
3160            , DECODE(p_attribute11, fnd_api.g_miss_char, attribute11, p_attribute11) attribute11
3161            , DECODE(p_attribute12, fnd_api.g_miss_char, attribute12, p_attribute12) attribute12
3162            , DECODE(p_attribute13, fnd_api.g_miss_char, attribute13, p_attribute13) attribute13
3163            , DECODE(p_attribute14, fnd_api.g_miss_char, attribute14, p_attribute14) attribute14
3164            , DECODE(p_attribute15, fnd_api.g_miss_char, attribute15, p_attribute15) attribute15
3165            , DECODE(
3166                p_attribute_category
3167              , fnd_api.g_miss_char, attribute_category
3168              , p_attribute_category
3169              ) attribute_category
3170            , DECODE(p_date_selected, fnd_api.g_miss_char, date_selected, p_date_selected)
3171                                                                                       date_selected
3172            , DECODE(p_parent_task_id, fnd_api.g_miss_num, parent_task_id, p_parent_task_id)
3173                                                                                      parent_task_id
3174            , DECODE(p_task_split_flag, fnd_api.g_miss_char, task_split_flag, p_task_split_flag)
3175                                                                                     task_split_flag
3176            , DECODE(p_child_position, fnd_api.g_miss_char, child_position, p_child_position)
3177                                                                                      child_position
3178            , DECODE(
3179                p_child_sequence_num
3180              , fnd_api.g_miss_num, child_sequence_num
3181              , p_child_sequence_num
3182              ) child_sequence_num
3183         FROM jtf_tasks_vl
3184        WHERE task_id = l_task_id;
3185 
3186     task_rec                  c_task_update%ROWTYPE;
3187 
3188 
3189   BEGIN
3190     SAVEPOINT update_task_pub;
3191 
3192     -----------
3193     -----------
3194     -----------
3195     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
3196       RAISE fnd_api.g_exc_unexpected_error;
3197     END IF;
3198 
3199     IF fnd_api.to_boolean(p_init_msg_list) THEN
3200       fnd_msg_pub.initialize;
3201     END IF;
3202 
3203     /* Modified by TSINGHAL bug fix Validate task name length 3182170 Start*/
3204     l_task_name                :=
3205                                  check_param_length(p_task_name, 'JTF_TASK_NAME_INVALID_LENGTH', 80);
3206     /* Modified by TSINGHAL bug fix 3182170 End*/
3207 
3208     /*  --------
3209           -------- Call the Internal User Hook
3210           --------
3211           p_task_user_hooks.task_id := p_task_id;
3212           p_task_user_hooks.task_name := p_task_name;
3213           p_task_user_hooks.task_type_name := p_task_type_name;
3214           p_task_user_hooks.task_type_id := p_task_type_id;
3215           p_task_user_hooks.description := p_description;
3216           p_task_user_hooks.task_status_name := p_task_status_name;
3217           p_task_user_hooks.task_status_id := p_task_status_id;
3218           p_task_user_hooks.task_priority_name := p_task_priority_name;
3219           p_task_user_hooks.task_priority_id := p_task_priority_id;
3220           p_task_user_hooks.owner_type_name := p_owner_type_name;
3221           p_task_user_hooks.owner_type_code := p_owner_type_code;
3222           p_task_user_hooks.owner_id := p_owner_id;
3223           p_task_user_hooks.owner_territory_id := p_owner_territory_id;
3224           p_task_user_hooks.assigned_by_name := p_assigned_by_name;
3225           p_task_user_hooks.assigned_by_id := p_assigned_by_id;
3226           p_task_user_hooks.customer_number := p_customer_number;
3227           p_task_user_hooks.customer_id := p_customer_id;
3228           p_task_user_hooks.cust_account_number := p_cust_account_number;
3229           p_task_user_hooks.cust_account_id := p_cust_account_id;
3230           p_task_user_hooks.address_id := p_address_id;
3231           p_task_user_hooks.location_id := p_location_id;
3232           p_task_user_hooks.address_number := p_address_number;
3233           p_task_user_hooks.planned_start_date := p_planned_start_date;
3234           p_task_user_hooks.planned_end_date := p_planned_end_date;
3235           p_task_user_hooks.scheduled_start_date := p_scheduled_start_date;
3236           p_task_user_hooks.scheduled_end_date := p_scheduled_end_date;
3237           p_task_user_hooks.actual_start_date := p_actual_start_date;
3238           p_task_user_hooks.actual_end_date := p_actual_end_date;
3239           p_task_user_hooks.timezone_id := p_timezone_id;
3240           p_task_user_hooks.timezone_name := p_timezone_name;
3241           p_task_user_hooks.source_object_type_code := p_source_object_type_code;
3242           p_task_user_hooks.source_object_id := p_source_object_id;
3243           p_task_user_hooks.source_object_name := p_source_object_name;
3244           p_task_user_hooks.duration := p_duration;
3245           p_task_user_hooks.duration_uom := p_duration_uom;
3246           p_task_user_hooks.planned_effort := p_planned_effort;
3247           p_task_user_hooks.planned_effort_uom := p_planned_effort_uom;
3248           p_task_user_hooks.actual_effort := p_actual_effort;
3249           p_task_user_hooks.actual_effort_uom := p_actual_effort_uom;
3250           p_task_user_hooks.percentage_complete := p_percentage_complete;
3251           p_task_user_hooks.reason_code := p_reason_code;
3252           p_task_user_hooks.private_flag := p_private_flag;
3253           p_task_user_hooks.publish_flag := p_publish_flag;
3254           p_task_user_hooks.restrict_closure_flag := p_restrict_closure_flag;
3255           p_task_user_hooks.multi_booked_flag := p_multi_booked_flag;
3256           p_task_user_hooks.milestone_flag := p_milestone_flag;
3257           p_task_user_hooks.holiday_flag := p_holiday_flag;
3258           p_task_user_hooks.billable_flag := p_billable_flag;
3259           p_task_user_hooks.bound_mode_code := p_bound_mode_code;
3260           p_task_user_hooks.soft_bound_flag := p_soft_bound_flag;
3261           p_task_user_hooks.workflow_process_id := p_workflow_process_id;
3262           p_task_user_hooks.notification_flag := p_notification_flag;
3263           p_task_user_hooks.notification_period := p_notification_period;
3264           p_task_user_hooks.notification_period_uom := p_notification_period_uom;
3265           p_task_user_hooks.alarm_start := p_alarm_start;
3266           p_task_user_hooks.alarm_start_uom := p_alarm_start_uom;
3267           p_task_user_hooks.alarm_on := p_alarm_on;
3268           p_task_user_hooks.alarm_count := p_alarm_count;
3269           p_task_user_hooks.alarm_interval := p_alarm_interval;
3270           p_task_user_hooks.alarm_interval_uom := p_alarm_interval_uom;
3271           p_task_user_hooks.palm_flag := p_palm_flag;
3272           p_task_user_hooks.wince_flag := p_wince_flag;
3273           p_task_user_hooks.laptop_flag := p_laptop_flag;
3274           p_task_user_hooks.device1_flag := p_device1_flag;
3275           p_task_user_hooks.device2_flag := p_device2_flag;
3276           p_task_user_hooks.device3_flag := p_device3_flag;
3277           p_task_user_hooks.costs := p_costs;
3278           p_task_user_hooks.currency_code := p_currency_code;
3279           p_task_user_hooks.escalation_level := p_escalation_level;
3280 
3281           jtf_tasks_iuhk.update_task_pre (x_return_status);
3282 
3283           IF NOT (x_return_status = fnd_api.g_ret_sts_success)
3284           THEN
3285        x_return_status := fnd_api.g_ret_sts_unexp_error;
3286        RAISE fnd_api.g_exc_unexpected_error;
3287           END IF;
3288 
3289     */
3290     x_return_status            := fnd_api.g_ret_sts_success;
3291 
3292     -----
3293     -----   Validate Tasks
3294     -----
3295     IF (l_task_id = fnd_api.g_miss_num AND l_task_number = fnd_api.g_miss_char) THEN
3296       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_TASK');
3297       fnd_msg_pub.ADD;
3298       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3299       RAISE fnd_api.g_exc_unexpected_error;
3300     ELSE
3301       SELECT DECODE(l_task_id, fnd_api.g_miss_num, NULL, l_task_id)
3302         INTO l_task_id
3303         FROM DUAL;
3304 
3305       SELECT DECODE(l_task_number, fnd_api.g_miss_char, NULL, l_task_number)
3306         INTO l_task_number
3307         FROM DUAL;
3308 
3309       jtf_task_utl.validate_task(
3310         p_task_id                    => l_task_id
3311       , p_task_number                => l_task_number
3312       , x_task_id                    => l_task_id
3313       , x_return_status              => x_return_status
3314       );
3315 
3316       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3317         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3318         RAISE fnd_api.g_exc_unexpected_error;
3319       END IF;
3320 
3321       IF l_task_id IS NULL THEN
3322         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_NUMBER');
3323         fnd_message.set_token('P_TASK_NUMBER', l_task_number);
3324         fnd_msg_pub.ADD;
3325         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3326         RAISE fnd_api.g_exc_unexpected_error;
3327       END IF;
3328     END IF;
3329 
3330     -----
3331     ----- Task Name
3332     -----
3333     IF l_task_name IS NULL THEN
3334       fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_NAME');
3335       fnd_msg_pub.ADD;
3336       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3337       RAISE fnd_api.g_exc_unexpected_error;
3338     END IF;
3339 
3340     -----
3341     ----- Task Description
3342     -----
3343     l_description              := task_rec.description;
3344 
3345     OPEN c_task_update(l_task_id);
3346 
3347     FETCH c_task_update
3348      INTO task_rec;
3349 
3350     IF c_task_update%NOTFOUND THEN
3351       fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_ID');
3352       fnd_message.set_token('P_TASK_ID', l_task_id);
3353       fnd_msg_pub.ADD;
3354       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3355       RAISE fnd_api.g_exc_unexpected_error;
3356     END IF;
3357 
3358     -----
3359     ----- Task Type
3360     -----
3361     IF (l_task_type_name = fnd_api.g_miss_char AND l_task_type_id = fnd_api.g_miss_num) THEN
3362       l_task_type_id  := task_rec.task_type_id;
3363     ELSIF(l_task_type_name = fnd_api.g_miss_char AND l_task_type_id <> fnd_api.g_miss_num) THEN
3364       jtf_task_utl.validate_task_type(
3365         p_task_type_id               => l_task_type_id
3366       , p_task_type_name             => NULL
3367       , x_return_status              => x_return_status
3368       , x_task_type_id               => l_task_type_id
3369       );
3370     ELSIF(l_task_type_name <> fnd_api.g_miss_char AND l_task_type_id = fnd_api.g_miss_num) THEN
3371       jtf_task_utl.validate_task_type(
3372         p_task_type_id               => NULL
3373       , p_task_type_name             => l_task_type_name
3374       , x_return_status              => x_return_status
3375       , x_task_type_id               => l_task_type_id
3376       );
3377     ELSE
3378       jtf_task_utl.validate_task_type(
3379         p_task_type_id               => l_task_type_id
3380       , p_task_type_name             => l_task_type_name
3381       , x_return_status              => x_return_status
3382       , x_task_type_id               => l_task_type_id
3383       );
3384     END IF;
3385 
3386     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3387       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3388       RAISE fnd_api.g_exc_unexpected_error;
3389     END IF;
3390 
3391     IF l_task_type_id IS NULL THEN
3392       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_TYPE');
3393       fnd_msg_pub.ADD;
3394       RAISE fnd_api.g_exc_unexpected_error;
3395     END IF;
3396 
3397     -------
3398     ------- Validate Location Id
3399     -------
3400     jtf_task_utl.validate_location_id(
3401       p_location_id                => p_location_id
3402     , p_address_id                 => p_address_id
3403     , p_task_id                    => l_task_id
3404     , x_return_status              => x_return_status
3405     );
3406 
3407     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3408       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3409       RAISE fnd_api.g_exc_unexpected_error;
3410     END IF;
3411 
3412     -----
3413     -----   Task Status
3414     -----
3415     IF l_task_type_id = '22' THEN
3416       l_type  := 'ESCALATION';
3417     ELSE
3418       l_type  := 'TASK';
3419     END IF;
3420 
3421     IF (l_task_status_name = fnd_api.g_miss_char AND l_task_status_id = fnd_api.g_miss_num) THEN
3422       l_task_status_id  := task_rec.task_status_id;
3423     ELSIF(l_task_status_name = fnd_api.g_miss_char AND l_task_status_id <> fnd_api.g_miss_num) THEN
3424       jtf_task_utl.validate_task_status(
3425         p_task_status_id             => l_task_status_id
3426       , p_task_status_name           => NULL
3427       , p_validation_type            => l_type
3428       , x_return_status              => x_return_status
3429       , x_task_status_id             => l_task_status_id
3430       );
3431     ELSIF(l_task_status_name <> fnd_api.g_miss_char AND l_task_status_id = fnd_api.g_miss_num) THEN
3432       jtf_task_utl.validate_task_status(
3433         p_task_status_id             => NULL
3434       , p_task_status_name           => l_task_status_name
3435       , p_validation_type            => l_type
3436       , x_return_status              => x_return_status
3437       , x_task_status_id             => l_task_status_id
3438       );
3439     ELSE
3440       jtf_task_utl.validate_task_status(
3441         p_task_status_id             => l_task_status_id
3442       , p_task_status_name           => l_task_status_name
3443       , p_validation_type            => l_type
3444       , x_return_status              => x_return_status
3445       , x_task_status_id             => l_task_status_id
3446       );
3447     END IF;
3448 
3449     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3450       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3451       RAISE fnd_api.g_exc_unexpected_error;
3452     END IF;
3453 
3454     IF l_task_status_id IS NULL THEN
3455       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_status');
3456       fnd_msg_pub.ADD;
3457       RAISE fnd_api.g_exc_unexpected_error;
3458     END IF;
3459 
3460     --------
3461     --------  Task Priority
3462     --------
3463     IF (l_task_priority_name = fnd_api.g_miss_char AND l_task_priority_id = fnd_api.g_miss_num) THEN
3464       l_task_priority_id  := task_rec.task_priority_id;
3465     ELSIF(l_task_priority_name = fnd_api.g_miss_char AND l_task_priority_id <> fnd_api.g_miss_num) THEN
3466       jtf_task_utl.validate_task_priority(
3467         p_task_priority_id           => l_task_priority_id
3468       , p_task_priority_name         => NULL
3469       , x_return_status              => x_return_status
3470       , x_task_priority_id           => l_task_priority_id
3471       );
3472     ELSIF(l_task_priority_name <> fnd_api.g_miss_char AND l_task_priority_id = fnd_api.g_miss_num) THEN
3473       jtf_task_utl.validate_task_priority(
3474         p_task_priority_id           => NULL
3475       , p_task_priority_name         => l_task_priority_name
3476       , x_return_status              => x_return_status
3477       , x_task_priority_id           => l_task_priority_id
3478       );
3479     ELSE
3480       jtf_task_utl.validate_task_priority(
3481         p_task_priority_id           => l_task_priority_id
3482       , p_task_priority_name         => l_task_priority_name
3483       , x_return_status              => x_return_status
3484       , x_task_priority_id           => l_task_priority_id
3485       );
3486     END IF;
3487 
3488     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3489       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3490       RAISE fnd_api.g_exc_unexpected_error;
3491     END IF;
3492 
3493     --------
3494     --------  Asssigned By Name
3495     --------
3496     IF (l_assigned_by_name = fnd_api.g_miss_char AND l_assigned_by_id = fnd_api.g_miss_num) THEN
3497       l_assigned_by_id  := task_rec.assigned_by_id;
3498     ELSIF     (l_assigned_by_name = fnd_api.g_miss_char)
3499           AND (l_assigned_by_id <> fnd_api.g_miss_num OR l_assigned_by_id IS NULL) THEN
3500       jtf_task_utl.validate_assigned_by(
3501         p_assigned_by_id             => l_assigned_by_id
3502       , p_assigned_by_name           => NULL
3503       , x_return_status              => x_return_status
3504       , x_assigned_by_id             => l_assigned_by_id
3505       );
3506     ELSIF     (l_assigned_by_name <> fnd_api.g_miss_char OR l_assigned_by_name IS NULL)
3507           AND (l_assigned_by_id = fnd_api.g_miss_num) THEN
3508       jtf_task_utl.validate_assigned_by(
3509         p_assigned_by_id             => NULL
3510       , p_assigned_by_name           => l_assigned_by_name
3511       , x_return_status              => x_return_status
3512       , x_assigned_by_id             => l_assigned_by_id
3513       );
3514     ELSE
3515       jtf_task_utl.validate_assigned_by(
3516         p_assigned_by_id             => l_assigned_by_id
3517       , p_assigned_by_name           => l_assigned_by_name
3518       , x_return_status              => x_return_status
3519       , x_assigned_by_id             => l_assigned_by_id
3520       );
3521     END IF;
3522 
3523     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3524       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3525       RAISE fnd_api.g_exc_unexpected_error;
3526     END IF;
3527 
3528     -----------
3529     -----------  Customer Id
3530     -----------
3531     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3532       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3533       RAISE fnd_api.g_exc_unexpected_error;
3534     END IF;
3535 
3536     IF (
3537            p_customer_id <> fnd_api.g_miss_num
3538         OR p_customer_id IS NULL
3539         OR p_customer_number <> fnd_api.g_miss_char
3540         OR p_customer_number IS NULL
3541        ) THEN
3542       SELECT DECODE(p_customer_id, fnd_api.g_miss_num, NULL, p_customer_id)
3543         INTO l_customer_id
3544         FROM DUAL;
3545 
3546       SELECT DECODE(p_customer_number, fnd_api.g_miss_char, NULL, p_customer_number)
3547         INTO l_customer_number
3548         FROM DUAL;
3549 
3550       jtf_task_utl.validate_party(
3551         p_party_id                   => l_customer_id
3552       , p_party_number               => l_customer_number
3553       , x_party_id                   => l_customer_id
3554       , x_return_status              => x_return_status
3555       );
3556     ELSE
3557       l_customer_id  := task_rec.customer_id;
3558     END IF;
3559 
3560     -----------
3561     -----------  Address Id.
3562     -----------
3563     IF (p_address_id <> fnd_api.g_miss_num OR p_address_number <> fnd_api.g_miss_char) THEN
3564       SELECT DECODE(p_address_id, fnd_api.g_miss_num, NULL, p_address_id)
3565         INTO l_address_id
3566         FROM DUAL;
3567 
3568       SELECT DECODE(p_address_number, fnd_api.g_miss_char, NULL, p_address_number)
3569         INTO l_address_number
3570         FROM DUAL;
3571 
3572       jtf_task_utl.validate_party_site(
3573         p_party_site_id              => l_address_id
3574       , p_party_site_number          => l_address_number
3575       , x_party_site_id              => l_address_id
3576       , x_return_status              => x_return_status
3577       );
3578     ELSE
3579       l_address_id  := task_rec.address_id;
3580     END IF;
3581 
3582     -----------
3583     -----------  Customer Account Info.
3584     -----------
3585     IF (p_cust_account_id <> fnd_api.g_miss_num OR p_cust_account_number <> fnd_api.g_miss_char) THEN
3586       SELECT DECODE(p_cust_account_id, fnd_api.g_miss_num, NULL, p_cust_account_id)
3587         INTO l_cust_account_id
3588         FROM DUAL;
3589 
3590       SELECT DECODE(p_cust_account_number, fnd_api.g_miss_char, NULL, p_cust_account_number)
3591         INTO l_cust_account_number
3592         FROM DUAL;
3593 
3594       jtf_task_utl.validate_cust_account(
3595         p_cust_account_id            => l_cust_account_id
3596       , p_cust_account_number        => l_cust_account_number
3597       , x_cust_account_id            => l_cust_account_id
3598       , x_return_status              => x_return_status
3599       );
3600     ELSE
3601       l_cust_account_id  := task_rec.cust_account_id;
3602     END IF;
3603 
3604     /*  removing fix for bug #1628560
3605           ----
3606           ----  Cross-validate customer/address/account
3607           ----
3608           jtf_task_utl.validate_party_site_acct (
3609        p_party_id => l_customer_id,
3610        p_party_site_id => l_address_id,
3611        p_cust_account_id => l_cust_account_id,
3612        x_return_status => x_return_status
3613           );
3614 
3615           IF NOT (x_return_status = fnd_api.g_ret_sts_success)
3616           THEN
3617        x_return_status := fnd_api.g_ret_sts_unexp_error;
3618        RAISE fnd_api.g_exc_unexpected_error;
3619           END IF;
3620 
3621     */    ----
3622           ----  Planned Dates
3623           ----
3624     l_planned_start_date       := task_rec.planned_start_date;
3625     l_planned_end_date         := task_rec.planned_end_date;
3626     jtf_task_utl.validate_dates
3627                  (
3628       p_date_tag                   => jtf_task_utl.get_translated_lookup
3629                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3630                                       , 'PLANNED')
3631     , p_start_date                 => l_planned_start_date
3632     , p_end_date                   => l_planned_end_date
3633     , x_return_status              => x_return_status
3634     );
3635 
3636     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3637       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3638       RAISE fnd_api.g_exc_unexpected_error;
3639     END IF;
3640 
3641     ----
3642     ----  scheduled Dates
3643     ----
3644     l_scheduled_start_date     := task_rec.scheduled_start_date;
3645     l_scheduled_end_date       := task_rec.scheduled_end_date;
3646     jtf_task_utl.validate_dates
3647                  (
3648       p_date_tag                   => jtf_task_utl.get_translated_lookup
3649                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3650                                       , 'SCHEDULED')
3651     , p_start_date                 => l_scheduled_start_date
3652     , p_end_date                   => l_scheduled_end_date
3653     , x_return_status              => x_return_status
3654     );
3655 
3656     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3657       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3658       RAISE fnd_api.g_exc_unexpected_error;
3659     END IF;
3660 
3661     ----
3662     ----  Actual Dates
3663     ----
3664     l_actual_start_date        := task_rec.actual_start_date;
3665     l_actual_end_date          := task_rec.actual_end_date;
3666     jtf_task_utl.validate_dates
3667                  (
3668       p_date_tag                   => jtf_task_utl.get_translated_lookup
3669                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3670                                       , 'ACTUAL')
3671     , p_start_date                 => l_actual_start_date
3672     , p_end_date                   => l_actual_end_date
3673     , x_return_status              => x_return_status
3674     );
3675 
3676     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3677       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3678       RAISE fnd_api.g_exc_unexpected_error;
3679     END IF;
3680 
3681     --------
3682     --------  Validate source object details
3683     --------
3684     l_source_object_type_code  := task_rec.source_object_type_code;
3685     l_source_object_id         := task_rec.source_object_id;
3686     l_source_object_name       := task_rec.source_object_name;
3687 
3688     --- Added the if condition. It will validate only if the field is being updated, else it will be ignored.
3689     IF p_source_object_type_code = fnd_api.g_miss_char AND p_source_object_id = fnd_api.g_miss_num THEN
3690        --Commented out for minipatch 401
3691       --ELSE
3692       jtf_task_utl.validate_source_object(
3693         p_object_code                => l_source_object_type_code
3694       , p_object_id                  => l_source_object_id
3695       , p_object_name                => l_source_object_name
3696       , x_return_status              => x_return_status
3697       );
3698     END IF;
3699 
3700     ---- Also, since we are denormalizing the source_object_name,
3701     ---- on every update, the source_object_name is updated to the
3702     ---- proper source_object_name.
3703     l_source_object_name       :=
3704       jtf_task_utl.check_truncation
3705                          (
3706         p_object_name                => jtf_task_utl.get_owner(
3707                                           task_rec.source_object_type_code
3708                                         , task_rec.source_object_id
3709                                         )
3710       );
3711 
3712     ---- Commented out by lokumar as part of bug#5741482
3713     ---- source_object_name is ultimately updated at PKG level
3714     /*
3715      update jtf_tasks_b
3716      set source_object_name = l_source_object_name
3717      where task_id =  l_task_id ;
3718      */
3719     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3720       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3721       RAISE fnd_api.g_exc_unexpected_error;
3722     END IF;
3723 
3724     ----------
3725     ----------  Validate duration
3726     ----------
3727     l_duration                 := task_rec.DURATION;
3728     l_duration_uom             := task_rec.duration_uom;
3729 
3730     ----------
3731     ----------  Do not validate if either duration or duration_uom
3732     ----------  is missing, to fix bug #1893801
3733     ----------
3734     IF (
3735             l_duration <> fnd_api.g_miss_num
3736         AND l_duration IS NOT NULL
3737         AND l_duration_uom <> fnd_api.g_miss_char
3738         AND l_duration_uom IS NOT NULL
3739        ) THEN
3740       jtf_task_utl.validate_effort
3741                  (
3742         p_tag                        => jtf_task_utl.get_translated_lookup
3743                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3744                                         , 'DURATION')
3745       , p_tag_uom                    => jtf_task_utl.get_translated_lookup
3746                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3747                                         , 'DURATION_UOM')
3748       , p_effort                     => l_duration
3749       , p_effort_uom                 => l_duration_uom
3750       , x_return_status              => x_return_status
3751       );
3752 
3753       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3754         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3755         RAISE fnd_api.g_exc_unexpected_error;
3756       END IF;
3757     END IF;
3758 
3759     ----------
3760     ----------  Validate actual_effort
3761     ----------
3762     l_actual_effort            := task_rec.actual_effort;
3763     l_actual_effort_uom        := task_rec.actual_effort_uom;
3764     jtf_task_utl.validate_effort
3765                   (
3766       p_tag                        => jtf_task_utl.get_translated_lookup
3767                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3768                                       , 'ACTUAL_EFFORT')
3769     , p_tag_uom                    => jtf_task_utl.get_translated_lookup
3770                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3771                                       , 'ACTUAL_EFFORT_UOM')
3772     , p_effort                     => l_actual_effort
3773     , p_effort_uom                 => l_actual_effort_uom
3774     , x_return_status              => x_return_status
3775     );
3776 
3777     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3778       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3779       RAISE fnd_api.g_exc_unexpected_error;
3780     END IF;
3781 
3782     ----------
3783     ----------  Validate planned_effort
3784     ----------
3785     l_planned_effort           := task_rec.planned_effort;
3786     l_planned_effort_uom       := task_rec.planned_effort_uom;
3787     jtf_task_utl.validate_effort
3788                   (
3789       p_tag                        => jtf_task_utl.get_translated_lookup
3790                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3791                                       , 'PLANNED_EFFORT')
3792     , p_tag_uom                    => jtf_task_utl.get_translated_lookup
3793                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3794                                       , 'PLANNED_EFFORT_UOM')
3795     , p_effort                     => l_planned_effort
3796     , p_effort_uom                 => l_planned_effort_uom
3797     , x_return_status              => x_return_status
3798     );
3799 
3800     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3801       x_return_status  := fnd_api.g_ret_sts_unexp_error;
3802       RAISE fnd_api.g_exc_unexpected_error;
3803     END IF;
3804 
3805     -------
3806     ------- Validate percentage complete
3807     -------
3808     IF (p_percentage_complete <> fnd_api.g_miss_num OR p_percentage_complete IS NULL) THEN
3809       IF p_percentage_complete < 0 OR p_percentage_complete > 100 THEN
3810         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_PCT_COMPLETE');
3811         fnd_msg_pub.ADD;
3812         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3813         RAISE fnd_api.g_exc_unexpected_error;
3814       END IF;
3815     END IF;
3816 
3817     l_percentage_complete      := task_rec.percentage_complete;
3818 
3819     -------
3820     ------- Validate private flag
3821     -------
3822     IF p_private_flag <> fnd_api.g_miss_char THEN
3823       jtf_task_utl.validate_flag
3824                (
3825         p_flag_name                  => jtf_task_utl.get_translated_lookup
3826                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3827                                         , 'PRIVATE_FLAG')
3828       , p_flag_value                 => p_private_flag
3829       , x_return_status              => x_return_status
3830       );
3831 
3832       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3833         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3834         RAISE fnd_api.g_exc_unexpected_error;
3835       END IF;
3836 
3837       l_private_flag  := p_private_flag;
3838     ELSE
3839       l_private_flag  := task_rec.private_flag;
3840     END IF;
3841 
3842     -------
3843     ------- Validate publish flag
3844     -------
3845     IF p_publish_flag <> fnd_api.g_miss_char OR p_publish_flag IS NULL THEN
3846       jtf_task_utl.validate_flag
3847                (
3848         p_flag_name                  => jtf_task_utl.get_translated_lookup
3849                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3850                                         , 'PUBLISH_FLAG')
3851       , p_flag_value                 => p_publish_flag
3852       , x_return_status              => x_return_status
3853       );
3854 
3855       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3856         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3857         RAISE fnd_api.g_exc_unexpected_error;
3858       END IF;
3859 
3860       l_publish_flag  := p_publish_flag;
3861     ELSE
3862       l_publish_flag  := task_rec.publish_flag;
3863     END IF;
3864 
3865     -------
3866     ------- Validate restrict closure flag
3867     -------
3868     IF p_restrict_closure_flag <> fnd_api.g_miss_char OR p_restrict_closure_flag IS NULL THEN
3869       jtf_task_utl.validate_flag
3870                (
3871         p_flag_name                  => jtf_task_utl.get_translated_lookup
3872                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3873                                         , 'RESTRICT_CLOSURE_FLAG')
3874       , p_flag_value                 => p_restrict_closure_flag
3875       , x_return_status              => x_return_status
3876       );
3877 
3878       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3879         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3880         RAISE fnd_api.g_exc_unexpected_error;
3881       END IF;
3882 
3883       l_restrict_closure_flag  := p_restrict_closure_flag;
3884     ELSE
3885       l_restrict_closure_flag  := task_rec.restrict_closure_flag;
3886     END IF;
3887 
3888     -------
3889     ------- Validate multibooked flag
3890     -------
3891     IF p_multi_booked_flag <> fnd_api.g_miss_char OR p_multi_booked_flag IS NULL THEN
3892       jtf_task_utl.validate_flag
3893                (
3894         p_flag_name                  => jtf_task_utl.get_translated_lookup
3895                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3896                                         , 'MULTIBOOKED_FLAG')
3897       , p_flag_value                 => p_multi_booked_flag
3898       , x_return_status              => x_return_status
3899       );
3900 
3901       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3902         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3903         RAISE fnd_api.g_exc_unexpected_error;
3904       END IF;
3905 
3906       l_multi_booked_flag  := p_multi_booked_flag;
3907     ELSE
3908       l_multi_booked_flag  := task_rec.multi_booked_flag;
3909     END IF;
3910 
3911     -------
3912     ------- Validate milestone flag
3913     -------
3914     IF p_milestone_flag <> fnd_api.g_miss_char OR p_milestone_flag IS NULL THEN
3915       jtf_task_utl.validate_flag
3916                (
3917         p_flag_name                  => jtf_task_utl.get_translated_lookup
3918                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3919                                         , 'MILESTONE_FLAG')
3920       , p_flag_value                 => p_milestone_flag
3921       , x_return_status              => x_return_status
3922       );
3923 
3924       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3925         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3926         RAISE fnd_api.g_exc_unexpected_error;
3927       END IF;
3928 
3929       l_milestone_flag  := p_milestone_flag;
3930     ELSE
3931       l_milestone_flag  := task_rec.milestone_flag;
3932     END IF;
3933 
3934     -------
3935     ------- Validate holiday flag
3936     -------
3937     IF p_holiday_flag <> fnd_api.g_miss_char OR p_holiday_flag IS NULL THEN
3938       jtf_task_utl.validate_flag
3939                (
3940         p_flag_name                  => jtf_task_utl.get_translated_lookup
3941                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3942                                         , 'HOILDAY_FLAG')
3943       , p_flag_value                 => p_holiday_flag
3944       , x_return_status              => x_return_status
3945       );
3946 
3947       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3948         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3949         RAISE fnd_api.g_exc_unexpected_error;
3950       END IF;
3951 
3952       l_holiday_flag  := p_holiday_flag;
3953     ELSE
3954       l_holiday_flag  := task_rec.holiday_flag;
3955     END IF;
3956 
3957     -------
3958     ------- Validate palm flag
3959     -------
3960     IF p_palm_flag <> fnd_api.g_miss_char THEN
3961       jtf_task_utl.validate_flag
3962                (
3963         p_flag_name                  => jtf_task_utl.get_translated_lookup
3964                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3965                                         , 'PALM_FLAG')
3966       , p_flag_value                 => p_palm_flag
3967       , x_return_status              => x_return_status
3968       );
3969 
3970       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3971         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3972         RAISE fnd_api.g_exc_unexpected_error;
3973       END IF;
3974 
3975       l_palm_flag  := p_palm_flag;
3976     ELSE
3977       l_palm_flag  := task_rec.palm_flag;
3978     END IF;
3979 
3980     -------
3981     ------- Validate wince flag
3982     -------
3983     IF p_wince_flag <> fnd_api.g_miss_char OR p_wince_flag IS NULL THEN
3984       jtf_task_utl.validate_flag
3985                (
3986         p_flag_name                  => jtf_task_utl.get_translated_lookup
3987                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
3988                                         , 'WINCE_FLAG')
3989       , p_flag_value                 => p_wince_flag
3990       , x_return_status              => x_return_status
3991       );
3992 
3993       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
3994         x_return_status  := fnd_api.g_ret_sts_unexp_error;
3995         RAISE fnd_api.g_exc_unexpected_error;
3996       END IF;
3997 
3998       l_wince_flag  := p_wince_flag;
3999     ELSE
4000       l_wince_flag  := task_rec.wince_flag;
4001     END IF;
4002 
4003     -------
4004     ------- Validate laptop flag
4005     -------
4006     IF p_laptop_flag <> fnd_api.g_miss_char OR p_laptop_flag IS NULL THEN
4007       jtf_task_utl.validate_flag
4008                (
4009         p_flag_name                  => jtf_task_utl.get_translated_lookup
4010                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
4011                                         , 'LAPTOP_FLAG')
4012       , p_flag_value                 => p_laptop_flag
4013       , x_return_status              => x_return_status
4014       );
4015 
4016       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4017         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4018         RAISE fnd_api.g_exc_unexpected_error;
4019       END IF;
4020 
4021       l_laptop_flag  := p_laptop_flag;
4022     ELSE
4023       l_laptop_flag  := task_rec.laptop_flag;
4024     END IF;
4025 
4026     -------
4027     ------- Validate billable flag
4028     -------
4029     IF p_billable_flag <> fnd_api.g_miss_char THEN
4030       jtf_task_utl.validate_flag
4031                (
4032         p_flag_name                  => jtf_task_utl.get_translated_lookup
4033                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
4034                                         , 'BILLABLE_FLAG')
4035       , p_flag_value                 => p_billable_flag
4036       , x_return_status              => x_return_status
4037       );
4038 
4039       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4040         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4041         RAISE fnd_api.g_exc_unexpected_error;
4042       END IF;
4043 
4044       l_billable_flag  := p_billable_flag;
4045     ELSE
4046       l_billable_flag  := task_rec.billable_flag;
4047     END IF;
4048 
4049     --------
4050     --------  Task Timezone
4051     --------
4052     IF (p_timezone_name = fnd_api.g_miss_char AND p_timezone_id = fnd_api.g_miss_num) THEN
4053       l_timezone_id  := task_rec.timezone_id;
4054     ELSIF     p_timezone_name = fnd_api.g_miss_char
4055           AND (p_timezone_id <> fnd_api.g_miss_num OR p_timezone_id IS NULL) THEN
4056       jtf_task_utl.validate_timezones(
4057         p_timezone_id                => p_timezone_id
4058       , p_timezone_name              => NULL
4059       , x_return_status              => x_return_status
4060       , x_timezone_id                => l_timezone_id
4061       );
4062     ELSIF     (p_timezone_name <> fnd_api.g_miss_char OR p_timezone_name IS NULL)
4063           AND p_timezone_id = fnd_api.g_miss_num THEN
4064       jtf_task_utl.validate_timezones(
4065         p_timezone_id                => NULL
4066       , p_timezone_name              => p_timezone_name
4067       , x_return_status              => x_return_status
4068       , x_timezone_id                => l_timezone_id
4069       );
4070     ELSE
4071       jtf_task_utl.validate_timezones(
4072         p_timezone_id                => p_timezone_id
4073       , p_timezone_name              => p_timezone_name
4074       , x_return_status              => x_return_status
4075       , x_timezone_id                => l_timezone_id
4076       );
4077     END IF;
4078 
4079     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4080       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4081       RAISE fnd_api.g_exc_unexpected_error;
4082     END IF;
4083 
4084     -------
4085     ------- Validate soft bound flag
4086     -------
4087     IF p_soft_bound_flag <> fnd_api.g_miss_char OR p_soft_bound_flag IS NULL THEN
4088       jtf_task_utl.validate_flag
4089                (
4090         p_flag_name                  => jtf_task_utl.get_translated_lookup
4091                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
4092                                         , 'SOFTBOUND_FLAG')
4093       , p_flag_value                 => p_soft_bound_flag
4094       , x_return_status              => x_return_status
4095       );
4096 
4097       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4098         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4099         RAISE fnd_api.g_exc_unexpected_error;
4100       END IF;
4101 
4102       l_soft_bound_flag  := p_soft_bound_flag;
4103     ELSE
4104       l_soft_bound_flag  := task_rec.soft_bound_flag;
4105     END IF;
4106 
4107     -------
4108     ------- Validate device1 flag
4109     -------
4110     IF p_device1_flag <> fnd_api.g_miss_char OR p_device1_flag IS NULL THEN
4111       jtf_task_utl.validate_flag
4112                (
4113         p_flag_name                  => jtf_task_utl.get_translated_lookup
4114                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
4115                                         , 'DEVICE1_FLAG')
4116       , p_flag_value                 => p_device1_flag
4117       , x_return_status              => x_return_status
4118       );
4119 
4120       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4121         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4122         RAISE fnd_api.g_exc_unexpected_error;
4123       END IF;
4124 
4125       l_device1_flag  := p_device1_flag;
4126     ELSE
4127       l_device1_flag  := task_rec.device1_flag;
4128     END IF;
4129 
4130     -------
4131     ------- Validate device2 flag
4132     -------
4133     IF p_device2_flag <> fnd_api.g_miss_char OR p_device2_flag IS NULL THEN
4134       jtf_task_utl.validate_flag
4135                (
4136         p_flag_name                  => jtf_task_utl.get_translated_lookup
4137                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
4138                                         , 'DEVICE2_FLAG')
4139       , p_flag_value                 => p_device2_flag
4140       , x_return_status              => x_return_status
4141       );
4142 
4143       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4144         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4145         RAISE fnd_api.g_exc_unexpected_error;
4146       END IF;
4147 
4148       l_device2_flag  := p_device2_flag;
4149     ELSE
4150       l_device2_flag  := task_rec.device2_flag;
4151     END IF;
4152 
4153     -------
4154     ------- Validate device3 flag
4155     -------
4156     IF p_device3_flag <> fnd_api.g_miss_char OR p_device3_flag IS NULL THEN
4157       jtf_task_utl.validate_flag
4158                (
4159         p_flag_name                  => jtf_task_utl.get_translated_lookup
4160                                                                     ('JTF_TASK_TRANSLATED_MESSAGES'
4161                                         , 'DEVICE3_FLAG')
4162       , p_flag_value                 => p_device3_flag
4163       , x_return_status              => x_return_status
4164       );
4165 
4166       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4167         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4168         RAISE fnd_api.g_exc_unexpected_error;
4169       END IF;
4170 
4171       l_device3_flag  := p_device3_flag;
4172     ELSE
4173       l_device3_flag  := task_rec.device3_flag;
4174     END IF;
4175 
4176     -------
4177     ------- Validate Notification
4178     -------
4179     IF (
4180            p_notification_period <> fnd_api.g_miss_num
4181         OR p_notification_period IS NULL
4182         OR p_notification_period_uom <> fnd_api.g_miss_char
4183         OR p_notification_period_uom IS NULL
4184         OR p_notification_flag <> fnd_api.g_miss_char
4185         OR p_notification_flag IS NULL
4186        ) THEN
4187       /*        IF (  p_notification_period <> fnd_api.g_miss_num
4188                OR p_notification_period IS NULL)
4189             THEN
4190           l_notification_period := p_notification_period;
4191             ELSE
4192           l_notification_period := task_rec.notification_period;
4193             END IF;
4194 
4195             IF (  p_notification_period_uom <> fnd_api.g_miss_char
4196                OR p_notification_period_uom IS NULL)
4197             THEN
4198           l_notification_period_uom := p_notification_period_uom;
4199             ELSE
4200           l_notification_period_uom := task_rec.notification_period_uom;
4201             END IF;
4202 
4203             IF (  p_notification_flag <> fnd_api.g_miss_char
4204                OR p_notification_flag IS NULL)
4205             THEN
4206           l_notification_flag := p_notification_flag;
4207             ELSE
4208           l_notification_flag := task_rec.notification_flag;
4209             END IF;
4210       */
4211       l_notification_flag        := task_rec.notification_flag;
4212       l_notification_period      := task_rec.notification_period;
4213       l_notification_period_uom  := task_rec.notification_period_uom;
4214       jtf_task_utl.validate_notification(
4215         p_notification_flag          => l_notification_flag
4216       , p_notification_period        => l_notification_period
4217       , p_notification_period_uom    => l_notification_period_uom
4218       , x_return_status              => x_return_status
4219       );
4220 
4221       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4222         fnd_message.set_name('JTF', 'INVALID_NOTIFICATION');
4223         fnd_msg_pub.ADD;
4224         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4225         RAISE fnd_api.g_exc_unexpected_error;
4226       END IF;
4227     ELSE
4228       l_notification_flag        := task_rec.notification_flag;
4229       l_notification_period      := task_rec.notification_period;
4230       l_notification_period_uom  := task_rec.notification_period_uom;
4231     END IF;
4232 
4233     -----------
4234     -----------   Validate alarm
4235     -----------
4236     IF (
4237            p_alarm_start <> fnd_api.g_miss_num
4238         OR p_alarm_start_uom <> fnd_api.g_miss_char
4239         OR p_alarm_on <> fnd_api.g_miss_char
4240         OR p_alarm_count <> fnd_api.g_miss_num
4241         OR p_alarm_fired_count <> fnd_api.g_miss_num
4242         OR p_alarm_interval <> fnd_api.g_miss_num
4243         OR p_alarm_interval_uom <> fnd_api.g_miss_char
4244         OR p_alarm_start IS NULL
4245         OR p_alarm_start_uom IS NULL
4246         OR p_alarm_on IS NULL
4247         OR p_alarm_count IS NULL
4248         OR p_alarm_fired_count IS NULL
4249         OR p_alarm_interval IS NULL
4250         OR p_alarm_interval_uom IS NULL
4251        ) THEN
4252       l_alarm_start         := task_rec.alarm_start;
4253       l_alarm_start_uom     := task_rec.alarm_start_uom;
4254       l_alarm_on            := task_rec.alarm_on;
4255       l_alarm_interval      := task_rec.alarm_interval;
4256       l_alarm_interval_uom  := task_rec.alarm_interval_uom;
4257       l_alarm_count         := task_rec.alarm_count;
4258       l_alarm_fired_count   := task_rec.alarm_fired_count;
4259       jtf_task_utl.validate_alarm(
4260         p_alarm_start                => l_alarm_start
4261       , p_alarm_start_uom            => l_alarm_start_uom
4262       , p_alarm_on                   => l_alarm_on
4263       , p_alarm_count                => l_alarm_count
4264       , p_alarm_interval             => l_alarm_interval
4265       , p_alarm_interval_uom         => l_alarm_interval_uom
4266       , x_return_status              => x_return_status
4267       );
4268 
4269       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4270         fnd_message.set_name('JTF', 'INVALID_ALARM_PARAM');
4271         fnd_msg_pub.ADD;
4272         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4273         RAISE fnd_api.g_exc_unexpected_error;
4274       END IF;
4275 
4276       IF l_alarm_fired_count IS NOT NULL THEN
4277         IF l_alarm_fired_count > l_alarm_count THEN
4278           fnd_message.set_name('JTF', 'INVALID_ALARM_PARAM');
4279           fnd_msg_pub.ADD;
4280           x_return_status  := fnd_api.g_ret_sts_unexp_error;
4281           RAISE fnd_api.g_exc_unexpected_error;
4282         END IF;
4283       END IF;
4284     ELSE
4285       l_alarm_start         := task_rec.alarm_start;
4286       l_alarm_start_uom     := task_rec.alarm_start_uom;
4287       l_alarm_on            := task_rec.alarm_on;
4288       l_alarm_interval      := task_rec.alarm_interval;
4289       l_alarm_interval_uom  := task_rec.alarm_interval_uom;
4290       l_alarm_count         := task_rec.alarm_count;
4291       l_alarm_fired_count   := task_rec.alarm_fired_count;
4292     END IF;
4293 
4294     l_owner_id                 := task_rec.owner_id;
4295     l_owner_type_code          := task_rec.owner_type_code;
4296 
4297     -----
4298     -----  Validate Owner
4299     -----
4300     IF (
4301            p_owner_type_code <> fnd_api.g_miss_char
4302         OR p_owner_type_code IS NULL
4303         OR p_owner_id IS NULL
4304         OR p_owner_id <> fnd_api.g_miss_num
4305         OR p_owner_type_name IS NULL
4306         OR p_owner_type_name <> fnd_api.g_miss_char
4307        ) THEN
4308       l_owner_type_name  := p_owner_type_name;
4309       jtf_task_utl.validate_task_owner(
4310         p_owner_type_name            => l_owner_type_name
4311       , p_owner_type_code            => l_owner_type_code
4312       , p_owner_id                   => l_owner_id
4313       , x_return_status              => x_return_status
4314       , x_owner_id                   => l_owner_id
4315       , x_owner_type_code            => l_owner_type_code
4316       );
4317     END IF;
4318 
4319     ----------
4320     ----------   Validate costs
4321     ----------
4322     l_costs                    := task_rec.costs;
4323     l_currency_code            := task_rec.currency_code;
4324 
4325     IF (
4326            p_costs <> fnd_api.g_miss_num
4327         OR p_costs IS NULL
4328         OR p_currency_code IS NULL
4329         OR p_currency_code <> fnd_api.g_miss_char
4330        ) THEN
4331       l_costs          := task_rec.costs;
4332       l_currency_code  := task_rec.currency_code;
4333       jtf_task_utl.validate_costs(p_costs => l_costs, p_currency_code => l_currency_code
4334       , x_return_status              => x_return_status);
4335 
4336       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4337         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4338         RAISE fnd_api.g_exc_unexpected_error;
4339       END IF;
4340     END IF;
4341 
4342     ---------------
4343     ---------------  Bound mode code.
4344     ---------------
4345     l_bound_mode_code          := task_rec.bound_mode_code;
4346 
4347     IF l_bound_mode_code IS NOT NULL AND l_bound_mode_code <> fnd_api.g_miss_char THEN
4348       y  := jtf_task_utl.validate_lookup('JTF_TASK_BOUND_MODE_CODE', l_bound_mode_code, NULL);
4349 
4350       IF y = FALSE THEN
4351         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4352         RAISE fnd_api.g_exc_unexpected_error;
4353       END IF;
4354     END IF;
4355 
4356     ---------------
4357     ---------------  Validate date_selected
4358     ---------------
4359     l_date_selected            := task_rec.date_selected;
4360 
4361     IF l_date_selected IS NOT NULL AND l_date_selected <> fnd_api.g_miss_char THEN
4362       IF l_date_selected NOT IN('P', 'S', 'A', 'D') THEN
4363         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4364         RAISE fnd_api.g_exc_unexpected_error;
4365       END IF;
4366     END IF;
4367 
4368     ---------------
4369     ---------------  Validate owner_status_id
4370     ---------------
4371    /* moved  code to pvt package for bug # 8574559 */
4372 
4373     ------- Validating the parent task id
4374     -------
4375     IF    (p_parent_task_id IS NOT NULL AND p_parent_task_id <> fnd_api.g_miss_num)
4376        OR (p_parent_task_number IS NOT NULL AND p_parent_task_number <> fnd_api.g_miss_char) THEN
4377       SELECT DECODE(p_parent_task_id, fnd_api.g_miss_num, NULL, p_parent_task_id)
4378         INTO l_parent_task_id
4379         FROM DUAL;
4380 
4381       SELECT DECODE(p_parent_task_number, fnd_api.g_miss_char, NULL, p_parent_task_number)
4382         INTO l_parent_task_number
4383         FROM DUAL;
4384 
4385       jtf_task_utl.validate_task(
4386         p_task_id                    => l_parent_task_id
4387       , p_task_number                => l_parent_task_number
4388       , x_task_id                    => l_parent_task_id
4389       , x_return_status              => x_return_status
4390       );
4391 
4392       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4393         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4394         RAISE fnd_api.g_exc_unexpected_error;
4395       END IF;
4396     --  Bug 2786689 : Fixing  Cyclic Task Issue : Removed code to
4397     --  PVT api.
4398     ELSE
4399       l_parent_task_id  := p_parent_task_id;
4400     END IF;
4401 
4402     l_reason_code              := task_rec.reason_code;
4403     jtf_tasks_pvt.update_task(
4404       p_api_version                => 1.0
4405     , p_init_msg_list              => fnd_api.g_false
4406     , p_commit                     => fnd_api.g_false
4407     , p_object_version_number      => p_object_version_number
4408     , p_task_id                    => l_task_id
4409     , p_task_name                  => l_task_name
4410     , p_task_type_id               => l_task_type_id
4411     , p_description                => task_rec.description
4412     , p_task_status_id             => l_task_status_id
4413     , p_task_priority_id           => l_task_priority_id
4414     , p_owner_type_code            => l_owner_type_code
4415     , p_owner_id                   => l_owner_id
4416     , p_owner_territory_id         => p_owner_territory_id
4417     , p_assigned_by_id             => l_assigned_by_id
4418     , p_customer_id                => l_customer_id
4419     , p_cust_account_id            => l_cust_account_id
4420     , p_address_id                 => l_address_id
4421     , p_planned_start_date         => l_planned_start_date
4422     , p_planned_end_date           => l_planned_end_date
4423     , p_scheduled_start_date       => l_scheduled_start_date
4424     , p_scheduled_end_date         => l_scheduled_end_date
4425     , p_actual_start_date          => l_actual_start_date
4426     , p_actual_end_date            => l_actual_end_date
4427     , p_timezone_id                => l_timezone_id
4428     , p_source_object_type_code    => l_source_object_type_code
4429     , p_source_object_id           => l_source_object_id
4430     , p_source_object_name         => l_source_object_name
4431     , p_duration                   => l_duration
4432     , p_duration_uom               => l_duration_uom
4433     , p_planned_effort             => l_planned_effort
4434     , p_planned_effort_uom         => l_planned_effort_uom
4435     , p_actual_effort              => l_actual_effort
4436     , p_actual_effort_uom          => l_actual_effort_uom
4437     , p_percentage_complete        => l_percentage_complete
4438     , p_reason_code                => l_reason_code
4439     , p_private_flag               => l_private_flag
4440     , p_publish_flag               => l_publish_flag
4441     , p_restrict_closure_flag      => l_restrict_closure_flag
4442     , p_multi_booked_flag          => l_multi_booked_flag
4443     , p_milestone_flag             => l_milestone_flag
4444     , p_holiday_flag               => l_holiday_flag
4445     , p_billable_flag              => l_billable_flag
4446     , p_bound_mode_code            => l_bound_mode_code
4447     , p_soft_bound_flag            => l_soft_bound_flag
4448     , p_workflow_process_id        => task_rec.workflow_process_id
4449     , p_notification_flag          => l_notification_flag
4450     , p_notification_period        => l_notification_period
4451     , p_notification_period_uom    => l_notification_period_uom
4452     , p_parent_task_id             => l_parent_task_id
4453     , p_alarm_start                => l_alarm_start
4454     , p_alarm_start_uom            => l_alarm_start_uom
4455     , p_alarm_on                   => l_alarm_on
4456     , p_alarm_count                => l_alarm_count
4457     , p_alarm_fired_count          => l_alarm_fired_count
4458     , p_alarm_interval             => l_alarm_interval
4459     , p_alarm_interval_uom         => l_alarm_interval_uom
4460     , p_palm_flag                  => l_palm_flag
4461     , p_wince_flag                 => l_wince_flag
4462     , p_laptop_flag                => l_laptop_flag
4463     , p_device1_flag               => l_device1_flag
4464     , p_device2_flag               => l_device2_flag
4465     , p_device3_flag               => l_device3_flag
4466     , p_costs                      => l_costs
4467     , p_currency_code              => l_currency_code
4468     , p_escalation_level           => p_escalation_level
4469     , x_return_status              => x_return_status
4470     , x_msg_count                  => x_msg_count
4471     , x_msg_data                   => x_msg_data
4472     , p_attribute1                 => task_rec.attribute1
4473     , p_attribute2                 => task_rec.attribute2
4474     , p_attribute3                 => task_rec.attribute3
4475     , p_attribute4                 => task_rec.attribute4
4476     , p_attribute5                 => task_rec.attribute5
4477     , p_attribute6                 => task_rec.attribute6
4478     , p_attribute7                 => task_rec.attribute7
4479     , p_attribute8                 => task_rec.attribute8
4480     , p_attribute9                 => task_rec.attribute9
4481     , p_attribute10                => task_rec.attribute10
4482     , p_attribute11                => task_rec.attribute11
4483     , p_attribute12                => task_rec.attribute12
4484     , p_attribute13                => task_rec.attribute13
4485     , p_attribute14                => task_rec.attribute14
4486     , p_attribute15                => task_rec.attribute15
4487     , p_attribute_category         => task_rec.attribute_category
4488     , p_date_selected              => task_rec.date_selected
4489     , p_category_id                => p_category_id
4490     , p_show_on_calendar           => p_show_on_calendar
4491     , p_owner_status_id            => p_owner_status_id
4492     , p_enable_workflow            => p_enable_workflow
4493     , p_abort_workflow             => p_abort_workflow
4494     ,
4495       --         p_task_confirmation_status => 'N',  -- confirmation status should be changed in jtf_tasks_confirmations apis
4496       p_task_confirmation_status   => fnd_api.g_miss_char
4497     , p_task_confirmation_counter  => fnd_api.g_miss_num
4498     , p_task_split_flag            => task_rec.task_split_flag
4499     , p_change_mode                => jtf_task_repeat_appt_pvt.g_one
4500     , p_free_busy_type             => g_free_busy_type
4501     , p_child_position             => task_rec.child_position
4502     , p_child_sequence_num         => task_rec.child_sequence_num
4503     , p_location_id                => task_rec.location_id
4504     );
4505 
4506     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4507       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4508       RAISE fnd_api.g_exc_unexpected_error;
4509     END IF;
4510 
4511           -----------
4512           ----------- Call Internal API hooks.
4513           -----------
4514     /*  jtf_tasks_iuhk.update_task_post (x_return_status);
4515 
4516 
4517           IF NOT (x_return_status = fnd_api.g_ret_sts_success)
4518           THEN
4519        x_return_status := fnd_api.g_ret_sts_unexp_error;
4520        RAISE fnd_api.g_exc_unexpected_error;
4521           END IF;
4522 
4523     */  -----------
4524           -----------
4525           -----------
4526 
4527     -- Added by SBARAT on 21/10/2005 for bug# 4670385
4528     IF fnd_api.to_boolean(p_commit) THEN
4529       COMMIT WORK;
4530     END IF;
4531 
4532     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4533   EXCEPTION
4534     WHEN fnd_api.g_exc_unexpected_error THEN
4535       ROLLBACK TO update_task_pub;
4536       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4537       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4538     WHEN NO_DATA_FOUND THEN
4539       ROLLBACK TO update_task_pub;
4540       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4541       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4542     WHEN OTHERS THEN
4543       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
4544       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
4545       fnd_msg_pub.ADD;
4546       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4547       ROLLBACK TO update_task_pub;
4548       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4549   END;
4550 
4551   -- Old Version
4552   PROCEDURE delete_task(
4553     p_api_version               IN            NUMBER
4554   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
4555   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
4556   , p_object_version_number     IN            NUMBER
4557   , p_task_id                   IN            NUMBER DEFAULT NULL
4558   , p_task_number               IN            VARCHAR2 DEFAULT NULL
4559   , p_delete_future_recurrences IN            VARCHAR2 DEFAULT fnd_api.g_false
4560   , x_return_status             OUT NOCOPY    VARCHAR2
4561   , x_msg_count                 OUT NOCOPY    NUMBER
4562   , x_msg_data                  OUT NOCOPY    VARCHAR2
4563   ) IS
4564     l_api_version CONSTANT NUMBER       := 1.0;
4565     l_api_name    CONSTANT VARCHAR2(30) := 'DELETE_TASK';
4566   BEGIN
4567     SAVEPOINT delete_task_pub2;
4568     x_return_status  := fnd_api.g_ret_sts_success;
4569 
4570     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
4571       RAISE fnd_api.g_exc_unexpected_error;
4572     END IF;
4573 
4574     IF fnd_api.to_boolean(p_init_msg_list) THEN
4575       fnd_msg_pub.initialize;
4576     END IF;
4577 
4578     delete_task(
4579       p_api_version                => 1.0
4580     , p_init_msg_list              => fnd_api.g_true
4581     , p_commit                     => fnd_api.g_false
4582     , p_object_version_number      => p_object_version_number
4583     , p_task_id                    => p_task_id
4584     , p_task_number                => p_task_number
4585     , p_delete_future_recurrences  => p_delete_future_recurrences
4586     , x_return_status              => x_return_status
4587     , x_msg_count                  => x_msg_count
4588     , x_msg_data                   => x_msg_data
4589     , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
4590     , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
4591     );
4592 
4593     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4594       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4595       RAISE fnd_api.g_exc_unexpected_error;
4596     END IF;
4597 
4598     IF fnd_api.to_boolean(p_commit) THEN
4599       COMMIT WORK;
4600     END IF;
4601 
4602     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4603   EXCEPTION
4604     WHEN fnd_api.g_exc_unexpected_error THEN
4605       ROLLBACK TO delete_task_pub2;
4606       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4607       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4608     WHEN OTHERS THEN
4609       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
4610       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
4611       fnd_msg_pub.ADD;
4612       ROLLBACK TO delete_task_pub2;
4613       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4614       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4615   END;
4616 
4617   -- New Version
4618   PROCEDURE delete_task(
4619     p_api_version               IN            NUMBER
4620   , p_init_msg_list             IN            VARCHAR2 DEFAULT fnd_api.g_false
4621   , p_commit                    IN            VARCHAR2 DEFAULT fnd_api.g_false
4622   , p_object_version_number     IN            NUMBER
4623   , p_task_id                   IN            NUMBER DEFAULT NULL
4624   , p_task_number               IN            VARCHAR2 DEFAULT NULL
4625   , p_delete_future_recurrences IN            VARCHAR2 DEFAULT fnd_api.g_false
4626   , x_return_status             OUT NOCOPY    VARCHAR2
4627   , x_msg_count                 OUT NOCOPY    NUMBER
4628   , x_msg_data                  OUT NOCOPY    VARCHAR2
4629   , p_enable_workflow           IN            VARCHAR2
4630   , p_abort_workflow            IN            VARCHAR2
4631   ) IS
4632     l_api_version CONSTANT NUMBER                         := 1.0;
4633     l_api_name    CONSTANT VARCHAR2(30)                   := 'DELETE_TASK';
4634     l_task_id              jtf_tasks_b.task_id%TYPE       := p_task_id;
4635     l_task_number          jtf_tasks_b.task_number%TYPE   := p_task_number;
4636   BEGIN
4637     SAVEPOINT delete_task_pub;
4638     x_return_status  := fnd_api.g_ret_sts_success;
4639 
4640     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
4641       RAISE fnd_api.g_exc_unexpected_error;
4642     END IF;
4643 
4644     IF fnd_api.to_boolean(p_init_msg_list) THEN
4645       fnd_msg_pub.initialize;
4646     END IF;
4647 
4648     IF (l_task_id IS NULL AND l_task_number IS NULL) THEN
4649       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_TASK');
4650       fnd_msg_pub.ADD;
4651       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4652       RAISE fnd_api.g_exc_unexpected_error;
4653     ELSE
4654       jtf_task_utl.validate_task(
4655         p_task_id                    => l_task_id
4656       , p_task_number                => l_task_number
4657       , x_task_id                    => l_task_id
4658       , x_return_status              => x_return_status
4659       );
4660 
4661       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4662         x_return_status  := fnd_api.g_ret_sts_unexp_error;
4663         RAISE fnd_api.g_exc_unexpected_error;
4664       END IF;
4665     END IF;
4666 
4667     jtf_tasks_pvt.delete_task(
4668       p_api_version                => 1.0
4669     , p_init_msg_list              => fnd_api.g_false
4670     , p_commit                     => fnd_api.g_false
4671     , p_object_version_number      => p_object_version_number
4672     , p_task_id                    => l_task_id
4673     , p_delete_future_recurrences  => p_delete_future_recurrences
4674     , x_return_status              => x_return_status
4675     , x_msg_count                  => x_msg_count
4676     , x_msg_data                   => x_msg_data
4677     , p_enable_workflow            => p_enable_workflow
4678     , p_abort_workflow             => p_abort_workflow
4679     );
4680 
4681     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
4682       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4683       RAISE fnd_api.g_exc_unexpected_error;
4684     END IF;
4685 
4686     IF fnd_api.to_boolean(p_commit) THEN
4687       COMMIT WORK;
4688     END IF;
4689 
4690     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4691   EXCEPTION
4692     WHEN fnd_api.g_exc_unexpected_error THEN
4693       ROLLBACK TO delete_task_pub;
4694       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4695       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4696     WHEN OTHERS THEN
4697       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
4698       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
4699       fnd_msg_pub.ADD;
4700       ROLLBACK TO delete_task_pub;
4701       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4702       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4703   END;
4704 
4705   PROCEDURE export_query_task   --  INPUT VARIABLES
4706 
4707                              --    p_file_name           - file name for output of export file, always
4708                              --          placed in /sqlcom/out directory
4709                              --
4710                              --    possible query variables which are named after fields in jtf_tasks_v
4711                              --    p_task_number         - query by task number
4712                              --    p_task_id
4713                              --    p_task_name
4714                              --    p_description
4715                              --    p_task_status_name
4716                              --    p_task_status_id
4717                              --    p_task_priority_name
4718                              --    p_task_priority_id
4719                              --    p_owner_type_code
4720                              --    p_owner_id
4721                              --    p_assigned_name
4722                              --    p_assigned_by_id
4723                              --    p_address_id
4724                              --    p_planned_start_date
4725                              --    p_planned_end_date
4726                              --    p_scheduled_start_date
4727                              --    p_scheduled_end_date
4728                              --    p_actual_start_date
4729                              --    p_actual_end_date
4730                              --    p_object_type_code
4731                              --    p_object_name
4732                              --    p_percentage_complete
4733                              --    p_reason_code
4734                              --    p_private_flag
4735                              --    p_restrict_closure_flag
4736                              --    p_multi_booked_flag
4737                              --    p_milestone_flag
4738                              --    p_holiday_flag
4739                              --    p_workflow_process_id
4740                              --    p_notification_flag
4741                              --    p_parent_task_id
4742                              --    p_alarm_on
4743                              --    p_alarm_count
4744                              --    p_alarm_fired_count
4745                              --
4746                              --    p_ref_object_id         -- referenced object id
4747                              --    p_ref_object_type_code      -- referenced object type code
4748                              --
4749                              --    p_sort_data           -- sort data structucture based on sort date
4750                              --    p_start_pointer         -- return records starting at this number
4751                              --    p_rec_wanted          -- return the next 'n' records from start_pointer
4752                              --    p_show_all          -- return all the records (value Y or N), overrides start_pointer, rec_wanted
4753                              --    p_query_or_next_code        -- run query or retrieve records from previous query (value Q/N)
4754                              --
4755                              --    OUTPUT values
4756                              --    x_task_table          -- pl/sql table of records
4757                              --    x_total_retrieved         -- total number of records selected by query
4758                              --    x_total_returned        -- number of records returned in pl/sql table
4759   (
4760     p_api_version           IN            NUMBER
4761   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
4762   , p_validate_level        IN            VARCHAR2 DEFAULT fnd_api.g_valid_level_full
4763   , p_file_name             IN            VARCHAR2
4764   , p_task_number           IN            jtf_tasks_v.task_number%TYPE DEFAULT NULL
4765   , p_task_id               IN            jtf_tasks_v.task_id%TYPE DEFAULT NULL
4766   , p_task_name             IN            jtf_tasks_v.task_name%TYPE DEFAULT NULL
4767   , p_description           IN            jtf_tasks_v.description%TYPE DEFAULT NULL
4768   , p_task_type_name        IN            jtf_tasks_v.task_type%TYPE DEFAULT NULL
4769   , p_task_type_id          IN            jtf_tasks_v.task_type_id%TYPE DEFAULT NULL
4770   , p_task_status_name      IN            jtf_tasks_v.task_status%TYPE DEFAULT NULL
4771   , p_task_status_id        IN            jtf_tasks_v.task_status_id%TYPE DEFAULT NULL
4772   , p_task_priority_name    IN            jtf_tasks_v.task_priority%TYPE DEFAULT NULL
4773   , p_task_priority_id      IN            jtf_tasks_v.task_priority_id%TYPE DEFAULT NULL
4774   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE DEFAULT NULL
4775   , p_owner_id              IN            jtf_tasks_v.owner_id%TYPE DEFAULT NULL
4776   , p_assigned_name         IN            jtf_tasks_v.assigned_by_name%TYPE DEFAULT NULL
4777   , p_assigned_by_id        IN            jtf_tasks_v.assigned_by_id%TYPE DEFAULT NULL
4778   , p_address_id            IN            jtf_tasks_v.address_id%TYPE DEFAULT NULL
4779   , p_owner_territory_id    IN            jtf_tasks_v.owner_territory_id%TYPE DEFAULT NULL
4780   , p_customer_id           IN            jtf_tasks_v.customer_id%TYPE DEFAULT NULL
4781   , p_customer_name         IN            jtf_tasks_v.customer_name%TYPE DEFAULT NULL
4782   , p_customer_number       IN            jtf_tasks_v.customer_number%TYPE DEFAULT NULL
4783   , p_cust_account_number   IN            jtf_tasks_v.cust_account_number%TYPE DEFAULT NULL
4784   , p_cust_account_id       IN            jtf_tasks_v.cust_account_id%TYPE DEFAULT NULL
4785   , p_planned_start_date    IN            jtf_tasks_v.planned_start_date%TYPE DEFAULT NULL
4786   , p_planned_end_date      IN            jtf_tasks_v.planned_end_date%TYPE DEFAULT NULL
4787   , p_scheduled_start_date  IN            jtf_tasks_v.scheduled_start_date%TYPE DEFAULT NULL
4788   , p_scheduled_end_date    IN            jtf_tasks_v.scheduled_end_date%TYPE DEFAULT NULL
4789   , p_actual_start_date     IN            jtf_tasks_v.actual_start_date%TYPE DEFAULT NULL
4790   , p_actual_end_date       IN            jtf_tasks_v.actual_end_date%TYPE DEFAULT NULL
4791   , p_object_type_code      IN            jtf_tasks_v.source_object_type_code%TYPE DEFAULT NULL
4792   , p_object_name           IN            jtf_tasks_v.source_object_name%TYPE DEFAULT NULL
4793   , p_source_object_id      IN            jtf_tasks_v.source_object_id%TYPE DEFAULT NULL
4794   , p_percentage_complete   IN            jtf_tasks_v.percentage_complete%TYPE DEFAULT NULL
4795   , p_reason_code           IN            jtf_tasks_v.reason_code%TYPE DEFAULT NULL
4796   , p_private_flag          IN            jtf_tasks_v.private_flag%TYPE DEFAULT NULL
4797   , p_restrict_closure_flag IN            jtf_tasks_v.restrict_closure_flag%TYPE DEFAULT NULL
4798   , p_multi_booked_flag     IN            jtf_tasks_v.multi_booked_flag%TYPE DEFAULT NULL
4799   , p_milestone_flag        IN            jtf_tasks_v.milestone_flag%TYPE DEFAULT NULL
4800   , p_holiday_flag          IN            jtf_tasks_v.holiday_flag%TYPE DEFAULT NULL
4801   , p_workflow_process_id   IN            jtf_tasks_v.workflow_process_id%TYPE DEFAULT NULL
4802   , p_notification_flag     IN            jtf_tasks_v.notification_flag%TYPE DEFAULT NULL
4803   , p_parent_task_id        IN            jtf_tasks_v.parent_task_id%TYPE DEFAULT NULL
4804   , p_alarm_on              IN            jtf_tasks_v.alarm_on%TYPE DEFAULT NULL
4805   , p_alarm_count           IN            jtf_tasks_v.alarm_count%TYPE DEFAULT NULL
4806   , p_alarm_fired_count     IN            jtf_tasks_v.alarm_fired_count%TYPE DEFAULT NULL
4807   , p_ref_object_id         IN            NUMBER DEFAULT NULL
4808   , p_ref_object_type_code  IN            VARCHAR2 DEFAULT NULL
4809   , p_sort_data             IN            sort_data
4810   , p_start_pointer         IN            NUMBER
4811   , p_rec_wanted            IN            NUMBER
4812   , p_show_all              IN            VARCHAR2
4813   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
4814   , x_task_table            OUT NOCOPY    task_table_type
4815   , x_total_retrieved       OUT NOCOPY    NUMBER
4816   , x_total_returned        OUT NOCOPY    NUMBER
4817   , x_return_status         OUT NOCOPY    VARCHAR2
4818   , x_msg_count             OUT NOCOPY    NUMBER
4819   , x_msg_data              OUT NOCOPY    VARCHAR2
4820   , x_object_version_number IN OUT NOCOPY NUMBER
4821   ) IS
4822     l_api_version CONSTANT NUMBER         := 1.0;
4823     l_api_name    CONSTANT VARCHAR2(30)   := 'EXPORT_QUERY_TASK';
4824     l_return_status        VARCHAR2(1)    := fnd_api.g_ret_sts_success;
4825     l_msg_data             VARCHAR2(2000);
4826     l_msg_count            NUMBER;
4827   BEGIN
4828     x_return_status  := fnd_api.g_ret_sts_success;
4829 
4830     -- standard call to check for call compatibility
4831     IF (NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name)) THEN
4832       RAISE fnd_api.g_exc_unexpected_error;
4833     END IF;
4834 
4835     -- initialize message list i p_init_msg_list is set to true
4836     IF (fnd_api.to_boolean(p_init_msg_list)) THEN
4837       fnd_msg_pub.initialize;
4838     END IF;
4839 
4840     export_query_task(
4841       p_api_version                => p_api_version
4842     , p_init_msg_list              => p_init_msg_list
4843     , p_validate_level             => p_validate_level
4844     , p_file_name                  => p_file_name
4845     , p_task_number                => p_task_number
4846     , p_task_id                    => p_task_id
4847     , p_task_name                  => p_task_name
4848     , p_description                => p_description
4849     , p_task_type_name             => p_task_type_name
4850     , p_task_type_id               => p_task_type_id
4851     , p_task_status_name           => p_task_status_name
4852     , p_task_status_id             => p_task_status_id
4853     , p_task_priority_name         => p_task_priority_name
4854     , p_task_priority_id           => p_task_priority_id
4855     , p_owner_type_code            => p_owner_type_code
4856     , p_owner_id                   => p_owner_id
4857     , p_assigned_name              => p_assigned_name
4858     , p_assigned_by_id             => p_assigned_by_id
4859     , p_address_id                 => p_address_id
4860     , p_owner_territory_id         => p_owner_territory_id
4861     , p_customer_id                => p_customer_id
4862     , p_customer_name              => p_customer_name
4863     , p_customer_number            => p_customer_number
4864     , p_cust_account_number        => p_cust_account_number
4865     , p_cust_account_id            => p_cust_account_id
4866     , p_planned_start_date         => p_planned_start_date
4867     , p_planned_end_date           => p_planned_end_date
4868     , p_scheduled_start_date       => p_scheduled_start_date
4869     , p_scheduled_end_date         => p_scheduled_end_date
4870     , p_actual_start_date          => p_actual_start_date
4871     , p_actual_end_date            => p_actual_end_date
4872     , p_object_type_code           => p_object_type_code
4873     , p_object_name                => p_object_name
4874     , p_source_object_id           => p_source_object_id
4875     , p_percentage_complete        => p_percentage_complete
4876     , p_reason_code                => p_reason_code
4877     , p_private_flag               => p_private_flag
4878     , p_restrict_closure_flag      => p_restrict_closure_flag
4879     , p_multi_booked_flag          => p_multi_booked_flag
4880     , p_milestone_flag             => p_milestone_flag
4881     , p_holiday_flag               => p_holiday_flag
4882     , p_workflow_process_id        => p_workflow_process_id
4883     , p_notification_flag          => p_notification_flag
4884     , p_parent_task_id             => p_parent_task_id
4885     , p_alarm_on                   => p_alarm_on
4886     , p_alarm_count                => p_alarm_count
4887     , p_alarm_fired_count          => p_alarm_fired_count
4888     , p_ref_object_id              => p_ref_object_id
4889     , p_ref_object_type_code       => p_ref_object_type_code
4890     , p_sort_data                  => p_sort_data
4891     , p_start_pointer              => p_start_pointer
4892     , p_rec_wanted                 => p_rec_wanted
4893     , p_show_all                   => p_show_all
4894     , p_query_or_next_code         => p_query_or_next_code
4895     , x_task_table                 => x_task_table
4896     , x_total_retrieved            => x_total_retrieved
4897     , x_total_returned             => x_total_returned
4898     , x_return_status              => x_return_status
4899     , x_msg_count                  => x_msg_count
4900     , x_msg_data                   => x_msg_data
4901     , x_object_version_number      => x_object_version_number
4902     , p_location_id                => NULL
4903     );
4904   EXCEPTION
4905     WHEN fnd_api.g_exc_error THEN
4906       x_return_status  := fnd_api.g_ret_sts_error;
4907       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4908     WHEN fnd_api.g_exc_unexpected_error THEN
4909       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4910       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4911     WHEN OTHERS THEN
4912       x_return_status  := fnd_api.g_ret_sts_unexp_error;
4913 
4914       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
4915         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
4916       END IF;
4917 
4918       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
4919   END export_query_task;
4920 
4921   PROCEDURE export_query_task   --  INPUT VARIABLES
4922 
4923                              --    p_file_name           - file name for output of export file, always
4924                              --          placed in /sqlcom/out directory
4925                              --
4926                              --    possible query variables which are named after fields in jtf_tasks_v
4927                              --    p_task_number         - query by task number
4928                              --    p_task_id
4929                              --    p_task_name
4930                              --    p_description
4931                              --    p_task_status_name
4932                              --    p_task_status_id
4933                              --    p_task_priority_name
4934                              --    p_task_priority_id
4935                              --    p_owner_type_code
4936                              --    p_owner_id
4937                              --    p_assigned_name
4938                              --    p_assigned_by_id
4939                              --    p_address_id
4940                              --    p_planned_start_date
4941                              --    p_planned_end_date
4942                              --    p_scheduled_start_date
4943                              --    p_scheduled_end_date
4944                              --    p_actual_start_date
4945                              --    p_actual_end_date
4946                              --    p_object_type_code
4947                              --    p_object_name
4948                              --    p_percentage_complete
4949                              --    p_reason_code
4950                              --    p_private_flag
4951                              --    p_restrict_closure_flag
4952                              --    p_multi_booked_flag
4953                              --    p_milestone_flag
4954                              --    p_holiday_flag
4955                              --    p_workflow_process_id
4956                              --    p_notification_flag
4957                              --    p_parent_task_id
4958                              --    p_alarm_on
4959                              --    p_alarm_count
4960                              --    p_alarm_fired_count
4961                              --
4962                              --    p_ref_object_id         -- referenced object id
4963                              --    p_ref_object_type_code      -- referenced object type code
4964                              --
4965                              --    p_sort_data           -- sort data structucture based on sort date
4966                              --    p_start_pointer         -- return records starting at this number
4967                              --    p_rec_wanted          -- return the next 'n' records from start_pointer
4968                              --    p_show_all          -- return all the records (value Y or N), overrides start_pointer, rec_wanted
4969                              --    p_query_or_next_code        -- run query or retrieve records from previous query (value Q/N)
4970                              --
4971                              --    OUTPUT values
4972                              --    x_task_table          -- pl/sql table of records
4973                              --    x_total_retrieved         -- total number of records selected by query
4974                              --    x_total_returned        -- number of records returned in pl/sql table
4975   (
4976     p_api_version           IN            NUMBER
4977   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
4978   , p_validate_level        IN            VARCHAR2 DEFAULT fnd_api.g_valid_level_full
4979   , p_file_name             IN            VARCHAR2
4980   , p_task_number           IN            jtf_tasks_v.task_number%TYPE DEFAULT NULL
4981   , p_task_id               IN            jtf_tasks_v.task_id%TYPE DEFAULT NULL
4982   , p_task_name             IN            jtf_tasks_v.task_name%TYPE DEFAULT NULL
4983   , p_description           IN            jtf_tasks_v.description%TYPE DEFAULT NULL
4984   , p_task_type_name        IN            jtf_tasks_v.task_type%TYPE DEFAULT NULL
4985   , p_task_type_id          IN            jtf_tasks_v.task_type_id%TYPE DEFAULT NULL
4986   , p_task_status_name      IN            jtf_tasks_v.task_status%TYPE DEFAULT NULL
4987   , p_task_status_id        IN            jtf_tasks_v.task_status_id%TYPE DEFAULT NULL
4988   , p_task_priority_name    IN            jtf_tasks_v.task_priority%TYPE DEFAULT NULL
4989   , p_task_priority_id      IN            jtf_tasks_v.task_priority_id%TYPE DEFAULT NULL
4990   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE DEFAULT NULL
4991   , p_owner_id              IN            jtf_tasks_v.owner_id%TYPE DEFAULT NULL
4992   , p_assigned_name         IN            jtf_tasks_v.assigned_by_name%TYPE DEFAULT NULL
4993   , p_assigned_by_id        IN            jtf_tasks_v.assigned_by_id%TYPE DEFAULT NULL
4994   , p_address_id            IN            jtf_tasks_v.address_id%TYPE DEFAULT NULL
4995   , p_owner_territory_id    IN            jtf_tasks_v.owner_territory_id%TYPE DEFAULT NULL
4996   , p_customer_id           IN            jtf_tasks_v.customer_id%TYPE DEFAULT NULL
4997   , p_customer_name         IN            jtf_tasks_v.customer_name%TYPE DEFAULT NULL
4998   , p_customer_number       IN            jtf_tasks_v.customer_number%TYPE DEFAULT NULL
4999   , p_cust_account_number   IN            jtf_tasks_v.cust_account_number%TYPE DEFAULT NULL
5000   , p_cust_account_id       IN            jtf_tasks_v.cust_account_id%TYPE DEFAULT NULL
5001   , p_planned_start_date    IN            jtf_tasks_v.planned_start_date%TYPE DEFAULT NULL
5002   , p_planned_end_date      IN            jtf_tasks_v.planned_end_date%TYPE DEFAULT NULL
5003   , p_scheduled_start_date  IN            jtf_tasks_v.scheduled_start_date%TYPE DEFAULT NULL
5004   , p_scheduled_end_date    IN            jtf_tasks_v.scheduled_end_date%TYPE DEFAULT NULL
5005   , p_actual_start_date     IN            jtf_tasks_v.actual_start_date%TYPE DEFAULT NULL
5006   , p_actual_end_date       IN            jtf_tasks_v.actual_end_date%TYPE DEFAULT NULL
5007   , p_object_type_code      IN            jtf_tasks_v.source_object_type_code%TYPE DEFAULT NULL
5008   , p_object_name           IN            jtf_tasks_v.source_object_name%TYPE DEFAULT NULL
5009   , p_source_object_id      IN            jtf_tasks_v.source_object_id%TYPE DEFAULT NULL
5010   , p_percentage_complete   IN            jtf_tasks_v.percentage_complete%TYPE DEFAULT NULL
5011   , p_reason_code           IN            jtf_tasks_v.reason_code%TYPE DEFAULT NULL
5012   , p_private_flag          IN            jtf_tasks_v.private_flag%TYPE DEFAULT NULL
5013   , p_restrict_closure_flag IN            jtf_tasks_v.restrict_closure_flag%TYPE DEFAULT NULL
5014   , p_multi_booked_flag     IN            jtf_tasks_v.multi_booked_flag%TYPE DEFAULT NULL
5015   , p_milestone_flag        IN            jtf_tasks_v.milestone_flag%TYPE DEFAULT NULL
5016   , p_holiday_flag          IN            jtf_tasks_v.holiday_flag%TYPE DEFAULT NULL
5017   , p_workflow_process_id   IN            jtf_tasks_v.workflow_process_id%TYPE DEFAULT NULL
5018   , p_notification_flag     IN            jtf_tasks_v.notification_flag%TYPE DEFAULT NULL
5019   , p_parent_task_id        IN            jtf_tasks_v.parent_task_id%TYPE DEFAULT NULL
5020   , p_alarm_on              IN            jtf_tasks_v.alarm_on%TYPE DEFAULT NULL
5021   , p_alarm_count           IN            jtf_tasks_v.alarm_count%TYPE DEFAULT NULL
5022   , p_alarm_fired_count     IN            jtf_tasks_v.alarm_fired_count%TYPE DEFAULT NULL
5023   , p_ref_object_id         IN            NUMBER DEFAULT NULL
5024   , p_ref_object_type_code  IN            VARCHAR2 DEFAULT NULL
5025   , p_sort_data             IN            sort_data
5026   , p_start_pointer         IN            NUMBER
5027   , p_rec_wanted            IN            NUMBER
5028   , p_show_all              IN            VARCHAR2
5029   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
5030   , x_task_table            OUT NOCOPY    task_table_type
5031   , x_total_retrieved       OUT NOCOPY    NUMBER
5032   , x_total_returned        OUT NOCOPY    NUMBER
5033   , x_return_status         OUT NOCOPY    VARCHAR2
5034   , x_msg_count             OUT NOCOPY    NUMBER
5035   , x_msg_data              OUT NOCOPY    VARCHAR2
5036   , x_object_version_number IN OUT NOCOPY NUMBER
5037   , p_location_id           IN            NUMBER
5038   ) IS
5039     l_api_version CONSTANT NUMBER                        := 1.0;
5040     l_api_name    CONSTANT VARCHAR2(30)                  := 'EXPORT_QUERY_TASK';
5041     l_return_status        VARCHAR2(1)                   := fnd_api.g_ret_sts_success;
5042     l_msg_data             VARCHAR2(2000);
5043     l_msg_count            NUMBER;
5044     v_task_table           jtf_tasks_pub.task_table_type;
5045   BEGIN
5046     x_return_status  := fnd_api.g_ret_sts_success;
5047 
5048     -- standard call to check for call compatibility
5049     IF (NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name)) THEN
5050       RAISE fnd_api.g_exc_unexpected_error;
5051     END IF;
5052 
5053     -- initialize message list i p_init_msg_list is set to true
5054     IF (fnd_api.to_boolean(p_init_msg_list)) THEN
5055       fnd_msg_pub.initialize;
5056     END IF;
5057 
5058     query_task(
5059       p_api_version
5060     , p_init_msg_list
5061     , p_validate_level
5062     , p_task_number
5063     , p_task_id
5064     , p_task_name
5065     , p_description
5066     , p_task_type_name
5067     , p_task_type_id
5068     , p_task_status_name
5069     , p_task_status_id
5070     , p_task_priority_name
5071     , p_task_priority_id
5072     , p_owner_type_code
5073     , p_owner_id
5074     , p_assigned_name
5075     , p_assigned_by_id
5076     , p_address_id
5077     , p_owner_territory_id
5078     , p_customer_id
5079     , p_customer_name
5080     , p_customer_number
5081     , p_cust_account_number
5082     , p_cust_account_id
5083     , p_planned_start_date
5084     , p_planned_end_date
5085     , p_scheduled_start_date
5086     , p_scheduled_end_date
5087     , p_actual_start_date
5088     , p_actual_end_date
5089     , p_object_type_code
5090     , p_object_name
5091     , p_source_object_id
5092     , p_percentage_complete
5093     , p_reason_code
5094     , p_private_flag
5095     , p_restrict_closure_flag
5096     , p_multi_booked_flag
5097     , p_milestone_flag
5098     , p_holiday_flag
5099     , p_workflow_process_id
5100     , p_notification_flag
5101     , p_parent_task_id
5102     , p_alarm_on
5103     , p_alarm_count
5104     , p_alarm_fired_count
5105     , p_ref_object_id
5106     , p_ref_object_type_code
5107     , p_sort_data
5108     , p_start_pointer
5109     , p_rec_wanted
5110     , p_show_all
5111     , p_query_or_next_code
5112     , v_task_table
5113     , x_total_retrieved
5114     , x_total_returned
5115     , x_return_status
5116     , x_msg_count
5117     , x_msg_data
5118     , x_object_version_number
5119     , p_location_id
5120     );
5121     export_file(
5122       p_api_version
5123     , p_init_msg_list
5124     , p_validate_level
5125     , p_file_name
5126     , v_task_table
5127     , x_return_status
5128     , x_msg_count
5129     , x_msg_data
5130     , x_object_version_number
5131     );
5132   EXCEPTION
5133     WHEN fnd_api.g_exc_error THEN
5134       x_return_status  := fnd_api.g_ret_sts_error;
5135       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5136     WHEN fnd_api.g_exc_unexpected_error THEN
5137       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5138       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5139     WHEN OTHERS THEN
5140       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5141 
5142       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
5143         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
5144       END IF;
5145 
5146       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5147   END export_query_task;
5148 
5149   PROCEDURE export_file(
5150     p_api_version           IN            NUMBER
5151   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
5152   , p_validate_level        IN            VARCHAR2 DEFAULT fnd_api.g_valid_level_full
5153   , p_file_name             IN            VARCHAR2
5154   , p_task_table            IN            jtf_tasks_pub.task_table_type
5155   , x_return_status         OUT NOCOPY    VARCHAR2
5156   , x_msg_count             OUT NOCOPY    NUMBER
5157   , x_msg_data              OUT NOCOPY    VARCHAR2
5158   , x_object_version_number IN OUT NOCOPY NUMBER
5159   ) IS
5160     l_path        CONSTANT VARCHAR2(30)   := '/sqlcom/out';   -- directory for file output
5161     l_api_version CONSTANT NUMBER         := 1.0;
5162     l_api_name    CONSTANT VARCHAR2(30)   := 'EXPORT_FILE';
5163     l_return_status        VARCHAR2(1)    := fnd_api.g_ret_sts_success;
5164     l_msg_data             VARCHAR2(2000);
5165     l_msg_count            NUMBER;
5166     l_tbl_count            NUMBER         := p_task_table.COUNT;
5167   BEGIN   -- export_file
5168     x_return_status  := fnd_api.g_ret_sts_success;
5169 
5170     -- standard call to check for call compatibility
5171     IF (NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name)) THEN
5172       RAISE fnd_api.g_exc_unexpected_error;
5173     END IF;
5174 
5175     -- initialize message list i p_init_msg_list is set to true
5176     IF (fnd_api.to_boolean(p_init_msg_list)) THEN
5177       fnd_msg_pub.initialize;
5178     END IF;
5179 
5180     -- required parameters to control records returned
5181 
5182     -- p_file_name must not be null
5183     IF (p_file_name IS NULL) THEN
5184       fnd_message.set_name('JTF', 'JTF_TK_EXP_FILE_NAME_NULL');
5185       RAISE fnd_api.g_exc_error;
5186     END IF;
5187 
5188     -- l_table_count must be > 0, or no records are in the table
5189     IF (l_tbl_count = 0) THEN
5190       fnd_message.set_name('JTF', 'JTF_TK_EXP_TABLE_EMPTY');
5191       RAISE fnd_api.g_exc_error;
5192     END IF;
5193 
5194     jtf_tasks_pvt.export_file(l_path, p_file_name, p_task_table, x_return_status, x_msg_count
5195     , x_msg_data);
5196   EXCEPTION
5197     WHEN fnd_api.g_exc_error THEN
5198       ROLLBACK TO query_next_task;
5199       x_return_status  := fnd_api.g_ret_sts_error;
5200       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5201     WHEN fnd_api.g_exc_unexpected_error THEN
5202       ROLLBACK TO query_next_task;
5203       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5204       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5205     WHEN OTHERS THEN
5206       ROLLBACK TO query_next_task;
5207       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5208 
5209       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
5210         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
5211       END IF;
5212 
5213       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5214   END export_file;
5215 
5216   PROCEDURE val_task(
5217     v_task_id     IN OUT NOCOPY jtf_tasks_v.task_id%TYPE
5218   , p_task_number IN            jtf_tasks_v.task_number%TYPE
5219   , p_task_name   IN            jtf_tasks_v.task_name%TYPE
5220   ) IS
5221     CURSOR c_task_number IS
5222       SELECT task_id
5223         FROM jtf_tasks_b
5224        WHERE task_number = p_task_number;
5225 
5226     CURSOR c_task_name IS
5227       -- Fix for Bug # 2516412 - changed the view jtf_tasks_v to jtf_tasks_vl
5228       SELECT NULL
5229         FROM jtf_tasks_vl
5230        WHERE task_name = p_task_name AND NVL(deleted_flag, 'N') = 'N';
5231 
5232     v_dummy VARCHAR2(1);
5233   BEGIN
5234     IF (p_task_number IS NOT NULL) THEN
5235       OPEN c_task_number;
5236 
5237       FETCH c_task_number
5238        INTO v_task_id;
5239 
5240       IF c_task_number%NOTFOUND THEN
5241         CLOSE c_task_number;
5242 
5243         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_NUMBER');
5244         fnd_message.set_token('P_TASK_NUMBER', p_task_number);
5245         fnd_msg_pub.ADD;
5246         RAISE fnd_api.g_exc_error;
5247       ELSE
5248         CLOSE c_task_number;
5249       END IF;
5250     ELSIF(p_task_name IS NOT NULL) THEN
5251       OPEN c_task_name;
5252 
5253       FETCH c_task_name
5254        INTO v_dummy;
5255 
5256       IF c_task_name%NOTFOUND THEN
5257         CLOSE c_task_name;
5258 
5259         fnd_message.set_name('JTF', 'JTF_TASK_INV_TK_NAME');
5260         fnd_msg_pub.ADD;
5261         RAISE fnd_api.g_exc_error;
5262       ELSE
5263         CLOSE c_task_name;
5264       END IF;
5265     END IF;
5266   END;
5267 
5268   PROCEDURE val_task_id(p_task_id IN jtf_tasks_v.task_id%TYPE) IS
5269     CURSOR c_task_id IS
5270       SELECT NULL
5271         FROM jtf_tasks_b
5272        WHERE task_id = p_task_id;
5273 
5274     v_dummy VARCHAR2(1);
5275   BEGIN
5276     IF (p_task_id IS NOT NULL) THEN
5277       OPEN c_task_id;
5278 
5279       FETCH c_task_id
5280        INTO v_dummy;
5281 
5282       IF c_task_id%NOTFOUND THEN
5283         CLOSE c_task_id;
5284 
5285         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_ID');
5286         fnd_message.set_token('P_TASK_ID', p_task_id);
5287         fnd_msg_pub.ADD;
5288         RAISE fnd_api.g_exc_error;
5289       ELSE
5290         CLOSE c_task_id;
5291       END IF;
5292     END IF;
5293   END val_task_id;
5294 
5295   PROCEDURE val_dates(p_start IN DATE, p_end IN DATE) IS
5296   BEGIN
5297     IF (p_start IS NOT NULL) AND(p_end IS NOT NULL) THEN
5298       IF (p_end < p_start) THEN
5299         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_DATES');
5300         fnd_message.set_token('P_DATE_TAG', p_start);
5301         fnd_msg_pub.ADD;
5302         RAISE fnd_api.g_exc_error;
5303       END IF;
5304     END IF;
5305   END val_dates;
5306 
5307   PROCEDURE val_assigned(
5308     v_assigned_by_id IN OUT NOCOPY jtf_tasks_v.assigned_by_id%TYPE
5309   , p_assigned_name  IN            jtf_tasks_v.assigned_by_name%TYPE
5310   ) IS
5311     CURSOR c_assigned_by_name IS
5312       SELECT user_id assigned_by_id
5313         FROM fnd_user
5314        WHERE user_name = p_assigned_name
5315          AND NVL(end_date, SYSDATE) >= SYSDATE
5316          AND NVL(start_date, SYSDATE) <= SYSDATE;
5317   BEGIN
5318     IF (p_assigned_name IS NOT NULL) THEN
5319       OPEN c_assigned_by_name;
5320 
5321       FETCH c_assigned_by_name
5322        INTO v_assigned_by_id;
5323 
5324       IF c_assigned_by_name%NOTFOUND THEN
5325         CLOSE c_assigned_by_name;
5326 
5327         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_ASSIGNED_NAME');
5328         fnd_msg_pub.ADD;
5329         RAISE fnd_api.g_exc_error;
5330       ELSE
5331         CLOSE c_assigned_by_name;
5332       END IF;
5333     END IF;
5334   END;
5335 
5336   PROCEDURE val_object_type(
5337     v_object_type_code IN OUT NOCOPY jtf_tasks_v.source_object_type_code%TYPE
5338   , p_object_name      IN            jtf_tasks_v.source_object_name%TYPE
5339   ) IS
5340     CURSOR c_object_type_name IS
5341       SELECT object_code
5342         FROM jtf_objects_vl
5343        WHERE NAME = p_object_name
5344          AND NVL(end_date_active, SYSDATE) >= SYSDATE
5345          AND NVL(start_date_active, SYSDATE) <= SYSDATE;
5346   BEGIN
5347     IF (p_object_name IS NOT NULL) THEN
5348       OPEN c_object_type_name;
5349 
5350       FETCH c_object_type_name
5351        INTO v_object_type_code;
5352 
5353       IF c_object_type_name%NOTFOUND THEN
5354         CLOSE c_object_type_name;
5355 
5356         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_OBJECT_CODE');
5357         fnd_message.set_token('P_object_type_code', p_object_name);
5358         fnd_msg_pub.ADD;
5359         RAISE fnd_api.g_exc_error;
5360       ELSE
5361         CLOSE c_object_type_name;
5362       END IF;
5363     END IF;
5364   END;
5365 
5366   PROCEDURE val_customer(
5367     p_customer_id     IN OUT NOCOPY jtf_tasks_v.customer_id%TYPE
5368   , p_customer_name   IN            jtf_tasks_v.customer_name%TYPE
5369   , p_customer_number IN            jtf_tasks_v.customer_number%TYPE
5370   ) IS
5371     CURSOR c1 IS
5372       SELECT party_id
5373         FROM hz_parties
5374        WHERE party_name = p_customer_name;
5375 
5376     CURSOR c2 IS
5377       SELECT party_id
5378         FROM hz_parties
5379        WHERE party_number = p_customer_number;
5380   BEGIN
5381     IF (p_customer_number IS NOT NULL) THEN
5382       OPEN c2;
5383 
5384       FETCH c2
5385        INTO p_customer_id;
5386 
5387       IF c2%NOTFOUND THEN
5388         CLOSE c2;
5389 
5390         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_CUST_NUMBER');
5391         fnd_message.set_token('P_customer_number', p_customer_number);
5392         fnd_msg_pub.ADD;
5393         RAISE fnd_api.g_exc_error;
5394       ELSE
5395         CLOSE c2;
5396       END IF;
5397     ELSIF(p_customer_name IS NOT NULL) THEN
5398       OPEN c1;
5399 
5400       FETCH c1
5401        INTO p_customer_id;
5402 
5403       IF c1%NOTFOUND THEN
5404         CLOSE c1;
5405 
5406         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_CUST_NAME');
5407         fnd_message.set_token('P_customer_name', p_customer_name);
5408         fnd_msg_pub.ADD;
5409         RAISE fnd_api.g_exc_error;
5410       ELSE
5411         CLOSE c1;
5412       END IF;
5413     END IF;
5414   END val_customer;
5415 
5416   PROCEDURE val_cust_account(
5417     p_cust_account_id     IN OUT NOCOPY jtf_tasks_v.cust_account_id%TYPE
5418   , p_cust_account_number IN            jtf_tasks_v.cust_account_number%TYPE
5419   ) IS
5420     CURSOR c1 IS
5421       SELECT cust_account_id
5422         FROM hz_cust_accounts
5423        WHERE account_number = p_cust_account_number;
5424   BEGIN
5425     IF (p_cust_account_number IS NOT NULL) THEN
5426       OPEN c1;
5427 
5428       FETCH c1
5429        INTO p_cust_account_id;
5430 
5431       IF c1%NOTFOUND THEN
5432         CLOSE c1;
5433 
5434         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_CUST_ACCT_NUM');
5435         fnd_message.set_token('P_CUST_ACCOUNT_NUMBER', p_cust_account_number);
5436         fnd_msg_pub.ADD;
5437         RAISE fnd_api.g_exc_error;
5438       ELSE
5439         CLOSE c1;
5440       END IF;
5441     END IF;
5442   END val_cust_account;
5443 
5444   PROCEDURE val_priority(
5445     v_task_priority_id   IN OUT NOCOPY jtf_tasks_v.task_priority_id%TYPE
5446   , p_task_priority_name IN            jtf_tasks_v.task_priority%TYPE
5447   ) IS
5448     CURSOR c_task_priority_name IS
5449       SELECT task_priority_id
5450         FROM jtf_task_priorities_vl
5451        WHERE NAME = p_task_priority_name
5452          AND NVL(end_date_active, SYSDATE) >= SYSDATE
5453          AND NVL(start_date_active, SYSDATE) <= SYSDATE;
5454   BEGIN
5455     IF (p_task_priority_name IS NOT NULL) THEN
5456       OPEN c_task_priority_name;
5457 
5458       FETCH c_task_priority_name
5459        INTO v_task_priority_id;
5460 
5461       IF c_task_priority_name%NOTFOUND THEN
5462         CLOSE c_task_priority_name;
5463 
5464         fnd_message.set_name('JTF', 'JTF_TASK_INVALID_PRIORITY_NAME');
5465         fnd_message.set_token('P_TASK_PRIORITY_NAME', p_task_priority_name);
5466         fnd_msg_pub.ADD;
5467         RAISE fnd_api.g_exc_error;
5468       ELSE
5469         CLOSE c_task_priority_name;
5470       END IF;
5471     END IF;
5472   END val_priority;
5473 
5474   PROCEDURE query_task   --  possible query variables which are named after fields in jtf_tasks_v
5475 
5476                       --    p_task_number     - query by task number
5477                       --    p_task_id
5478                       --    p_task_name
5479                       --    p_description
5480                       --    p_task_status_name
5481                       --    p_task_status_id
5482                       --    p_task_priority_name
5483                       --    p_task_priority_id
5484                       --    p_owner_type_code
5485                       --    p_owner_id
5486                       --    p_assigned_name
5487                       --    p_assigned_by_id
5488                       --    p_address_id
5489                       --    p_planned_start_date
5490                       --    p_planned_end_date
5491                       --    p_scheduled_start_date
5492                       --    p_scheduled_end_date
5493                       --    p_actual_start_date
5494                       --    p_actual_end_date
5495                       --    p_object_type_code
5496                       --    p_object_name
5497                       --    p_percentage_complete
5498                       --    p_reason_code
5499                       --    p_private_flag
5500                       --    p_restrict_closure_flag
5501                       --    p_multi_booked_flag
5502                       --    p_milestone_flag
5503                       --    p_holiday_flag
5504                       --    p_workflow_process_id
5505                       --    p_notification_flag
5506                       --    p_parent_task_id
5507                       --    p_alarm_on
5508                       --    p_alarm_count
5509                       --    p_alarm_fired_count
5510                       --
5511                       --    p_ref_object_id     -- referenced object id
5512                       --    p_ref_object_type_code    -- referenced object type code
5513                       --
5514                       --    p_sort_data     -- sort data structucture based on sort date
5515 
5516   --    p_query_or_next_code    -- run query or retrieve records from previous query (value Q/N)
5517                       --
5518                       --    OUTPUT values
5519                       --    x_task_table      -- pl/sql table of records
5520                       --    x_total_retrieved     -- total number of records selected by query
5521                       --    x_total_returned      -- number of records returned in pl/sql table
5522   (
5523     p_api_version           IN            NUMBER
5524   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
5525   , p_validate_level        IN            VARCHAR2 DEFAULT fnd_api.g_valid_level_full
5526   , p_task_number           IN            jtf_tasks_v.task_number%TYPE DEFAULT NULL
5527   , p_task_id               IN            jtf_tasks_v.task_id%TYPE DEFAULT NULL
5528   , p_task_name             IN            jtf_tasks_v.task_name%TYPE DEFAULT NULL
5529   , p_description           IN            jtf_tasks_v.description%TYPE DEFAULT NULL
5530   , p_task_type_name        IN            jtf_tasks_v.task_type%TYPE DEFAULT NULL
5531   , p_task_type_id          IN            jtf_tasks_v.task_type_id%TYPE DEFAULT NULL
5532   , p_task_status_name      IN            jtf_tasks_v.task_status%TYPE DEFAULT NULL
5533   , p_task_status_id        IN            jtf_tasks_v.task_status_id%TYPE DEFAULT NULL
5534   , p_task_priority_name    IN            jtf_tasks_v.task_priority%TYPE DEFAULT NULL
5535   , p_task_priority_id      IN            jtf_tasks_v.task_priority_id%TYPE DEFAULT NULL
5536   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE DEFAULT NULL
5537   , p_owner_id              IN            jtf_tasks_v.owner_id%TYPE DEFAULT NULL
5538   , p_assigned_name         IN            jtf_tasks_v.assigned_by_name%TYPE DEFAULT NULL
5539   , p_assigned_by_id        IN            jtf_tasks_v.assigned_by_id%TYPE DEFAULT NULL
5540   , p_address_id            IN            jtf_tasks_v.address_id%TYPE DEFAULT NULL
5541   , p_owner_territory_id    IN            jtf_tasks_v.owner_territory_id%TYPE DEFAULT NULL
5542   , p_customer_id           IN            jtf_tasks_v.customer_id%TYPE DEFAULT NULL
5543   , p_customer_name         IN            jtf_tasks_v.customer_name%TYPE DEFAULT NULL
5544   , p_customer_number       IN            jtf_tasks_v.customer_number%TYPE DEFAULT NULL
5545   , p_cust_account_number   IN            jtf_tasks_v.cust_account_number%TYPE DEFAULT NULL
5546   , p_cust_account_id       IN            jtf_tasks_v.cust_account_id%TYPE DEFAULT NULL
5547   , p_planned_start_date    IN            jtf_tasks_v.planned_start_date%TYPE DEFAULT NULL
5548   , p_planned_end_date      IN            jtf_tasks_v.planned_end_date%TYPE DEFAULT NULL
5549   , p_scheduled_start_date  IN            jtf_tasks_v.scheduled_start_date%TYPE DEFAULT NULL
5550   , p_scheduled_end_date    IN            jtf_tasks_v.scheduled_end_date%TYPE DEFAULT NULL
5551   , p_actual_start_date     IN            jtf_tasks_v.actual_start_date%TYPE DEFAULT NULL
5552   , p_actual_end_date       IN            jtf_tasks_v.actual_end_date%TYPE DEFAULT NULL
5553   , p_object_type_code      IN            jtf_tasks_v.source_object_type_code%TYPE DEFAULT NULL
5554   , p_object_name           IN            jtf_tasks_v.source_object_name%TYPE DEFAULT NULL
5555   , p_source_object_id      IN            jtf_tasks_v.source_object_id%TYPE DEFAULT NULL
5556   , p_percentage_complete   IN            jtf_tasks_v.percentage_complete%TYPE DEFAULT NULL
5557   , p_reason_code           IN            jtf_tasks_v.reason_code%TYPE DEFAULT NULL
5558   , p_private_flag          IN            jtf_tasks_v.private_flag%TYPE DEFAULT NULL
5559   , p_restrict_closure_flag IN            jtf_tasks_v.restrict_closure_flag%TYPE DEFAULT NULL
5560   , p_multi_booked_flag     IN            jtf_tasks_v.multi_booked_flag%TYPE DEFAULT NULL
5561   , p_milestone_flag        IN            jtf_tasks_v.milestone_flag%TYPE DEFAULT NULL
5562   , p_holiday_flag          IN            jtf_tasks_v.holiday_flag%TYPE DEFAULT NULL
5563   , p_workflow_process_id   IN            jtf_tasks_v.workflow_process_id%TYPE DEFAULT NULL
5564   , p_notification_flag     IN            jtf_tasks_v.notification_flag%TYPE DEFAULT NULL
5565   , p_parent_task_id        IN            jtf_tasks_v.parent_task_id%TYPE DEFAULT NULL
5566   , p_alarm_on              IN            jtf_tasks_v.alarm_on%TYPE DEFAULT NULL
5567   , p_alarm_count           IN            jtf_tasks_v.alarm_count%TYPE DEFAULT NULL
5568   , p_alarm_fired_count     IN            jtf_tasks_v.alarm_fired_count%TYPE DEFAULT NULL
5569   , p_ref_object_id         IN            NUMBER DEFAULT NULL
5570   , p_ref_object_type_code  IN            VARCHAR2 DEFAULT NULL
5571   , p_sort_data             IN            sort_data
5572   , p_start_pointer         IN            NUMBER
5573   , p_rec_wanted            IN            NUMBER
5574   , p_show_all              IN            VARCHAR2
5575   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
5576   , x_task_table            OUT NOCOPY    task_table_type
5577   , x_total_retrieved       OUT NOCOPY    NUMBER
5578   , x_total_returned        OUT NOCOPY    NUMBER
5579   , x_return_status         OUT NOCOPY    VARCHAR2
5580   , x_msg_count             OUT NOCOPY    NUMBER
5581   , x_msg_data              OUT NOCOPY    VARCHAR2
5582   , x_object_version_number IN OUT NOCOPY NUMBER
5583   ) IS
5584     l_api_version CONSTANT NUMBER         := 1.0;
5585     l_api_name    CONSTANT VARCHAR2(30)   := 'QUERY_TASK';
5586     l_return_status        VARCHAR2(1)    := fnd_api.g_ret_sts_success;
5587     l_msg_data             VARCHAR2(2000);
5588     l_msg_count            NUMBER;
5589   BEGIN
5590     SAVEPOINT query_task_pub1;
5591     x_return_status  := fnd_api.g_ret_sts_success;
5592 
5593     -- standard call to check for call compatibility
5594     IF (NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name)) THEN
5595       RAISE fnd_api.g_exc_unexpected_error;
5596     END IF;
5597 
5598     -- initialize message list i p_init_msg_list is set to true
5599     IF (fnd_api.to_boolean(p_init_msg_list)) THEN
5600       fnd_msg_pub.initialize;
5601     END IF;
5602 
5603     query_task(
5604       p_api_version                => p_api_version
5605     , p_init_msg_list              => p_init_msg_list
5606     , p_validate_level             => p_validate_level
5607     , p_task_number                => p_task_number
5608     , p_task_id                    => p_task_id
5609     , p_task_name                  => p_task_name
5610     , p_description                => p_description
5611     , p_task_type_name             => p_task_type_name
5612     , p_task_type_id               => p_task_type_id
5613     , p_task_status_name           => p_task_status_name
5614     , p_task_status_id             => p_task_status_id
5615     , p_task_priority_name         => p_task_priority_name
5616     , p_task_priority_id           => p_task_priority_id
5617     , p_owner_type_code            => p_owner_type_code
5618     , p_owner_id                   => p_owner_id
5619     , p_assigned_name              => p_assigned_name
5620     , p_assigned_by_id             => p_assigned_by_id
5621     , p_address_id                 => p_address_id
5622     , p_owner_territory_id         => p_owner_territory_id
5623     , p_customer_id                => p_customer_id
5624     , p_customer_name              => p_customer_name
5625     , p_customer_number            => p_customer_number
5626     , p_cust_account_number        => p_cust_account_number
5627     , p_cust_account_id            => p_cust_account_id
5628     , p_planned_start_date         => p_planned_start_date
5629     , p_planned_end_date           => p_planned_end_date
5630     , p_scheduled_start_date       => p_scheduled_start_date
5631     , p_scheduled_end_date         => p_scheduled_end_date
5632     , p_actual_start_date          => p_actual_start_date
5633     , p_actual_end_date            => p_actual_end_date
5634     , p_object_type_code           => p_object_type_code
5635     , p_object_name                => p_object_name
5636     , p_source_object_id           => p_source_object_id
5637     , p_percentage_complete        => p_percentage_complete
5638     , p_reason_code                => p_reason_code
5639     , p_private_flag               => p_private_flag
5640     , p_restrict_closure_flag      => p_restrict_closure_flag
5641     , p_multi_booked_flag          => p_multi_booked_flag
5642     , p_milestone_flag             => p_milestone_flag
5643     , p_holiday_flag               => p_holiday_flag
5644     , p_workflow_process_id        => p_workflow_process_id
5645     , p_notification_flag          => p_notification_flag
5646     , p_parent_task_id             => p_parent_task_id
5647     , p_alarm_on                   => p_alarm_on
5648     , p_alarm_count                => p_alarm_count
5649     , p_alarm_fired_count          => p_alarm_fired_count
5650     , p_ref_object_id              => p_ref_object_id
5651     , p_ref_object_type_code       => p_ref_object_type_code
5652     , p_sort_data                  => p_sort_data
5653     , p_start_pointer              => p_start_pointer
5654     , p_rec_wanted                 => p_rec_wanted
5655     , p_show_all                   => p_show_all
5656     , p_query_or_next_code         => p_query_or_next_code
5657     , x_task_table                 => x_task_table
5658     , x_total_retrieved            => x_total_retrieved
5659     , x_total_returned             => x_total_returned
5660     , x_return_status              => x_return_status
5661     , x_msg_count                  => x_msg_count
5662     , x_msg_data                   => x_msg_data
5663     , x_object_version_number      => x_object_version_number
5664     , p_location_id                => NULL
5665     );
5666   EXCEPTION
5667     WHEN fnd_api.g_exc_error THEN
5668       ROLLBACK TO query_task_pub1;
5669       x_return_status  := fnd_api.g_ret_sts_error;
5670       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5671     WHEN fnd_api.g_exc_unexpected_error THEN
5672       ROLLBACK TO query_task_pub1;
5673       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5674       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5675     WHEN OTHERS THEN
5676       ROLLBACK TO query_task_pub1;
5677       x_return_status  := fnd_api.g_ret_sts_unexp_error;
5678 
5679       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
5680         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
5681       END IF;
5682 
5683       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
5684   END query_task;
5685 
5686   PROCEDURE query_task   --  possible query variables which are named after fields in jtf_tasks_v
5687 
5688                       --    p_task_number     - query by task number
5689                       --    p_task_id
5690                       --    p_task_name
5691                       --    p_description
5692                       --    p_task_status_name
5693                       --    p_task_status_id
5694                       --    p_task_priority_name
5695                       --    p_task_priority_id
5696                       --    p_owner_type_code
5697                       --    p_owner_id
5698                       --    p_assigned_name
5699                       --    p_assigned_by_id
5700                       --    p_address_id
5701                       --    p_planned_start_date
5702                       --    p_planned_end_date
5703                       --    p_scheduled_start_date
5704                       --    p_scheduled_end_date
5705                       --    p_actual_start_date
5706                       --    p_actual_end_date
5707                       --    p_object_type_code
5708                       --    p_object_name
5709                       --    p_percentage_complete
5710                       --    p_reason_code
5711                       --    p_private_flag
5712                       --    p_restrict_closure_flag
5713                       --    p_multi_booked_flag
5714                       --    p_milestone_flag
5715                       --    p_holiday_flag
5716                       --    p_workflow_process_id
5717                       --    p_notification_flag
5718                       --    p_parent_task_id
5719                       --    p_alarm_on
5720                       --    p_alarm_count
5721                       --    p_alarm_fired_count
5722                       --
5723                       --    p_ref_object_id     -- referenced object id
5724                       --    p_ref_object_type_code    -- referenced object type code
5725                       --
5726                       --    p_sort_data     -- sort data structucture based on sort date
5727 
5728   --    p_query_or_next_code    -- run query or retrieve records from previous query (value Q/N)
5729                       --
5730                       --    OUTPUT values
5731                       --    x_task_table      -- pl/sql table of records
5732                       --    x_total_retrieved     -- total number of records selected by query
5733                       --    x_total_returned      -- number of records returned in pl/sql table
5734   (
5735     p_api_version           IN            NUMBER
5736   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
5737   , p_validate_level        IN            VARCHAR2 DEFAULT fnd_api.g_valid_level_full
5738   , p_task_number           IN            jtf_tasks_v.task_number%TYPE DEFAULT NULL
5739   , p_task_id               IN            jtf_tasks_v.task_id%TYPE DEFAULT NULL
5740   , p_task_name             IN            jtf_tasks_v.task_name%TYPE DEFAULT NULL
5741   , p_description           IN            jtf_tasks_v.description%TYPE DEFAULT NULL
5742   , p_task_type_name        IN            jtf_tasks_v.task_type%TYPE DEFAULT NULL
5743   , p_task_type_id          IN            jtf_tasks_v.task_type_id%TYPE DEFAULT NULL
5744   , p_task_status_name      IN            jtf_tasks_v.task_status%TYPE DEFAULT NULL
5745   , p_task_status_id        IN            jtf_tasks_v.task_status_id%TYPE DEFAULT NULL
5746   , p_task_priority_name    IN            jtf_tasks_v.task_priority%TYPE DEFAULT NULL
5747   , p_task_priority_id      IN            jtf_tasks_v.task_priority_id%TYPE DEFAULT NULL
5748   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE DEFAULT NULL
5749   , p_owner_id              IN            jtf_tasks_v.owner_id%TYPE DEFAULT NULL
5750   , p_assigned_name         IN            jtf_tasks_v.assigned_by_name%TYPE DEFAULT NULL
5751   , p_assigned_by_id        IN            jtf_tasks_v.assigned_by_id%TYPE DEFAULT NULL
5752   , p_address_id            IN            jtf_tasks_v.address_id%TYPE DEFAULT NULL
5753   , p_owner_territory_id    IN            jtf_tasks_v.owner_territory_id%TYPE DEFAULT NULL
5754   , p_customer_id           IN            jtf_tasks_v.customer_id%TYPE DEFAULT NULL
5755   , p_customer_name         IN            jtf_tasks_v.customer_name%TYPE DEFAULT NULL
5756   , p_customer_number       IN            jtf_tasks_v.customer_number%TYPE DEFAULT NULL
5757   , p_cust_account_number   IN            jtf_tasks_v.cust_account_number%TYPE DEFAULT NULL
5758   , p_cust_account_id       IN            jtf_tasks_v.cust_account_id%TYPE DEFAULT NULL
5759   , p_planned_start_date    IN            jtf_tasks_v.planned_start_date%TYPE DEFAULT NULL
5760   , p_planned_end_date      IN            jtf_tasks_v.planned_end_date%TYPE DEFAULT NULL
5761   , p_scheduled_start_date  IN            jtf_tasks_v.scheduled_start_date%TYPE DEFAULT NULL
5762   , p_scheduled_end_date    IN            jtf_tasks_v.scheduled_end_date%TYPE DEFAULT NULL
5763   , p_actual_start_date     IN            jtf_tasks_v.actual_start_date%TYPE DEFAULT NULL
5764   , p_actual_end_date       IN            jtf_tasks_v.actual_end_date%TYPE DEFAULT NULL
5765   , p_object_type_code      IN            jtf_tasks_v.source_object_type_code%TYPE DEFAULT NULL
5766   , p_object_name           IN            jtf_tasks_v.source_object_name%TYPE DEFAULT NULL
5767   , p_source_object_id      IN            jtf_tasks_v.source_object_id%TYPE DEFAULT NULL
5768   , p_percentage_complete   IN            jtf_tasks_v.percentage_complete%TYPE DEFAULT NULL
5769   , p_reason_code           IN            jtf_tasks_v.reason_code%TYPE DEFAULT NULL
5770   , p_private_flag          IN            jtf_tasks_v.private_flag%TYPE DEFAULT NULL
5771   , p_restrict_closure_flag IN            jtf_tasks_v.restrict_closure_flag%TYPE DEFAULT NULL
5772   , p_multi_booked_flag     IN            jtf_tasks_v.multi_booked_flag%TYPE DEFAULT NULL
5773   , p_milestone_flag        IN            jtf_tasks_v.milestone_flag%TYPE DEFAULT NULL
5774   , p_holiday_flag          IN            jtf_tasks_v.holiday_flag%TYPE DEFAULT NULL
5775   , p_workflow_process_id   IN            jtf_tasks_v.workflow_process_id%TYPE DEFAULT NULL
5776   , p_notification_flag     IN            jtf_tasks_v.notification_flag%TYPE DEFAULT NULL
5777   , p_parent_task_id        IN            jtf_tasks_v.parent_task_id%TYPE DEFAULT NULL
5778   , p_alarm_on              IN            jtf_tasks_v.alarm_on%TYPE DEFAULT NULL
5779   , p_alarm_count           IN            jtf_tasks_v.alarm_count%TYPE DEFAULT NULL
5780   , p_alarm_fired_count     IN            jtf_tasks_v.alarm_fired_count%TYPE DEFAULT NULL
5781   , p_ref_object_id         IN            NUMBER DEFAULT NULL
5782   , p_ref_object_type_code  IN            VARCHAR2 DEFAULT NULL
5783   , p_sort_data             IN            sort_data
5784   , p_start_pointer         IN            NUMBER
5785   , p_rec_wanted            IN            NUMBER
5786   , p_show_all              IN            VARCHAR2
5787   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
5788   , x_task_table            OUT NOCOPY    task_table_type
5789   , x_total_retrieved       OUT NOCOPY    NUMBER
5790   , x_total_returned        OUT NOCOPY    NUMBER
5791   , x_return_status         OUT NOCOPY    VARCHAR2
5792   , x_msg_count             OUT NOCOPY    NUMBER
5793   , x_msg_data              OUT NOCOPY    VARCHAR2
5794   , x_object_version_number IN OUT NOCOPY NUMBER
5795   , p_location_id           IN            NUMBER
5796   ) IS
5797     l_api_version CONSTANT NUMBER                                     := 1.0;
5798     l_api_name    CONSTANT VARCHAR2(30)                               := 'QUERY_TASK';
5799     l_return_status        VARCHAR2(1)                                := fnd_api.g_ret_sts_success;
5800     l_msg_data             VARCHAR2(2000);
5801     l_msg_count            NUMBER;
5802     v_task_id              jtf_tasks_v.task_id%TYPE                   := p_task_id;
5803     v_task_type_id         jtf_tasks_v.task_type_id%TYPE              := p_task_type_id;
5804     v_task_status_id       jtf_tasks_v.task_status_id%TYPE            := p_task_status_id;
5805     v_object_type_code     jtf_tasks_v.source_object_type_code%TYPE   := p_object_type_code;
5806     v_task_priority_id     jtf_tasks_v.task_priority_id%TYPE          := p_task_priority_id;
5807     v_customer_id          jtf_tasks_v.customer_id%TYPE               := p_customer_id;
5808     v_cust_account_id      jtf_tasks_v.cust_account_id%TYPE           := p_cust_account_id;
5809     v_assigned_by_id       jtf_tasks_v.assigned_by_id%TYPE;
5810     l_type                 VARCHAR2(10);
5811   BEGIN
5812     SAVEPOINT query_task_pub2;
5813     x_return_status   := fnd_api.g_ret_sts_success;
5814 
5815     -- standard call to check for call compatibility
5816     IF (NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name)) THEN
5817       RAISE fnd_api.g_exc_unexpected_error;
5818     END IF;
5819 
5820     -- initialize message list i p_init_msg_list is set to true
5821     IF (fnd_api.to_boolean(p_init_msg_list)) THEN
5822       fnd_msg_pub.initialize;
5823     END IF;
5824 
5825     -- required parameters to control records returned
5826 
5827     -- p_ref_object_type_code or p_ref object_id is not null then both must exist
5828     IF (p_ref_object_type_code IS NOT NULL) OR(p_ref_object_id IS NOT NULL) THEN
5829       IF (p_ref_object_type_code IS NULL) OR(p_ref_object_id IS NULL) THEN
5830         fnd_message.set_name('JTF', 'JTF_TK_OBJECT_TYPE_ID_RQD');
5831         fnd_msg_pub.ADD;
5832         RAISE fnd_api.g_exc_error;
5833       END IF;
5834     END IF;
5835 
5836     -- p_query_or_next_code should be Q or N
5837     IF (p_query_or_next_code NOT IN('Q', 'N')) OR(p_query_or_next_code IS NULL) THEN
5838       fnd_message.set_name('JTF', 'JTF_TK_INV_QRY_NXT');
5839       fnd_msg_pub.ADD;
5840       RAISE fnd_api.g_exc_error;
5841     END IF;
5842 
5843     -- p_show_all should be Y or N
5844     IF (p_show_all NOT IN('Y', 'N')) OR(p_show_all IS NULL) THEN
5845       fnd_message.set_name('JTF', 'JTF_TK_INV_SHOW_ALL');
5846       fnd_msg_pub.ADD;
5847       RAISE fnd_api.g_exc_error;
5848     END IF;
5849 
5850     IF (p_show_all = 'N') THEN
5851       IF (p_start_pointer IS NULL) THEN
5852         fnd_message.set_name('JTF', 'JTF_TK_NULL_STRT_PTR');
5853         fnd_msg_pub.ADD;
5854         RAISE fnd_api.g_exc_error;
5855       END IF;
5856 
5857       IF (p_rec_wanted IS NULL) THEN
5858         fnd_message.set_name('JTF', 'JTF_TK_NULL_REC_WANT');
5859         fnd_msg_pub.ADD;
5860         RAISE fnd_api.g_exc_error;
5861       END IF;
5862     END IF;
5863 
5864     -- validate query parameters
5865     IF (v_task_id IS NULL) THEN
5866       val_task(v_task_id, p_task_number, p_task_name);
5867     END IF;
5868 
5869     IF (v_object_type_code IS NULL) THEN
5870       val_object_type(v_object_type_code, p_object_name);
5871     END IF;
5872 
5873     IF (v_task_type_id IS NULL AND p_task_type_name IS NOT NULL) THEN
5874       jtf_task_utl.validate_task_type(p_task_type_id, p_task_type_name, l_return_status
5875       , v_task_type_id);
5876 
5877       IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5878         RAISE fnd_api.g_exc_unexpected_error;
5879       END IF;
5880     END IF;
5881 
5882     IF (p_task_status_id IS NULL AND p_task_status_name IS NOT NULL) THEN
5883       IF v_task_type_id = '22' THEN
5884         l_type  := 'ESCALATION';
5885       ELSE
5886         l_type  := 'TASK';
5887       END IF;
5888 
5889       jtf_task_utl.validate_task_status(p_task_status_id, p_task_status_name, l_type
5890       , l_return_status, v_task_status_id);
5891 
5892       IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5893         RAISE fnd_api.g_exc_unexpected_error;
5894       END IF;
5895     END IF;
5896 
5897     IF (v_task_priority_id IS NULL) THEN
5898       val_priority(v_task_priority_id, p_task_priority_name);
5899     END IF;
5900 
5901     v_assigned_by_id  := p_assigned_by_id;
5902 
5903     IF (v_assigned_by_id IS NOT NULL) THEN
5904       val_assigned(v_assigned_by_id, p_assigned_name);
5905     END IF;
5906 
5907     IF (p_customer_id IS NULL) AND(p_customer_name IS NOT NULL OR p_customer_number IS NOT NULL) THEN
5908       val_customer(v_customer_id, p_customer_name, p_customer_number);
5909     END IF;
5910 
5911     IF (p_cust_account_id IS NULL) AND(p_cust_account_number IS NOT NULL) THEN
5912       val_cust_account(v_cust_account_id, p_cust_account_number);
5913     END IF;
5914 
5915     val_dates(p_planned_start_date, p_planned_end_date);
5916     val_dates(p_scheduled_start_date, p_scheduled_end_date);
5917     val_dates(p_actual_start_date, p_actual_end_date);
5918     -- private flag
5919     jtf_task_utl.validate_flag(
5920       l_api_name
5921     , p_init_msg_list
5922     , l_return_status
5923     , jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'PRIVATE_FLAG')
5924     , p_private_flag
5925     );
5926 
5927     IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5928       RAISE fnd_api.g_exc_unexpected_error;
5929     END IF;
5930 
5931     -- restrict closure
5932     jtf_task_utl.validate_flag(
5933       l_api_name
5934     , p_init_msg_list
5935     , l_return_status
5936     , jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'RESTRICT_CLOSURE_FLAG')
5937     , p_restrict_closure_flag
5938     );
5939 
5940     IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5941       RAISE fnd_api.g_exc_unexpected_error;
5942     END IF;
5943 
5944     -- multi_booked_flag
5945     jtf_task_utl.validate_flag(
5946       l_api_name
5947     , p_init_msg_list
5948     , l_return_status
5949     , jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'MULTIBOOKED_FLAG')
5950     , p_multi_booked_flag
5951     );
5952 
5953     IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5954       RAISE fnd_api.g_exc_unexpected_error;
5955     END IF;
5956 
5957     -- milestone_flag
5958     jtf_task_utl.validate_flag(
5959       l_api_name
5960     , p_init_msg_list
5961     , l_return_status
5962     , jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'MILESTONE_FLAG')
5963     , p_milestone_flag
5964     );
5965 
5966     IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5967       RAISE fnd_api.g_exc_unexpected_error;
5968     END IF;
5969 
5970     -- holiday_flag
5971     jtf_task_utl.validate_flag(
5972       l_api_name
5973     , p_init_msg_list
5974     , l_return_status
5975     , jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'HOLIDAY_FLAG')
5976     , p_holiday_flag
5977     );
5978 
5979     IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5980       RAISE fnd_api.g_exc_unexpected_error;
5981     END IF;
5982 
5983     -- notification_flag
5984     jtf_task_utl.validate_flag(
5985       l_api_name
5986     , p_init_msg_list
5987     , l_return_status
5988     , jtf_task_utl.get_translated_lookup('JTF_TASK_TRANSLATED_MESSAGES', 'NOTIFICATION_FLAG')
5989     , p_notification_flag
5990     );
5991 
5992     IF (l_return_status = fnd_api.g_ret_sts_unexp_error) THEN
5993       RAISE fnd_api.g_exc_unexpected_error;
5994     END IF;
5995 
5996     --call private api to execute the fetch
5997     jtf_tasks_pvt.query_task(
5998       0
5999     , v_task_id
6000     , p_description
6001     , v_task_type_id
6002     , v_task_status_id
6003     , p_task_priority_id
6004     , p_owner_type_code
6005     , p_owner_id
6006     , p_assigned_by_id
6007     , p_address_id
6008     , p_owner_territory_id
6009     , p_customer_id
6010     , p_cust_account_id
6011     , p_planned_start_date
6012     , p_planned_end_date
6013     , p_scheduled_start_date
6014     , p_scheduled_end_date
6015     , p_actual_start_date
6016     , p_actual_end_date
6017     , v_object_type_code
6018     , p_source_object_id
6019     , p_percentage_complete
6020     , p_reason_code
6021     , p_private_flag
6022     , p_restrict_closure_flag
6023     , p_multi_booked_flag
6024     , p_milestone_flag
6025     , p_holiday_flag
6026     , p_workflow_process_id
6027     , p_notification_flag
6028     , p_parent_task_id
6029     , p_alarm_on
6030     , p_alarm_count
6031     , p_alarm_fired_count
6032     , p_ref_object_id
6033     , p_ref_object_type_code
6034     , p_task_name
6035     , p_sort_data
6036     , p_start_pointer
6037     , p_rec_wanted
6038     , p_show_all
6039     , p_query_or_next_code
6040     , x_task_table
6041     , x_total_retrieved
6042     , x_total_returned
6043     , x_return_status
6044     , x_msg_count
6045     , x_msg_data
6046     , p_location_id
6047     );
6048   EXCEPTION
6049     WHEN fnd_api.g_exc_error THEN
6050       ROLLBACK TO query_task_pub2;
6051       x_return_status  := fnd_api.g_ret_sts_error;
6052       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6053     WHEN fnd_api.g_exc_unexpected_error THEN
6054       ROLLBACK TO query_task_pub2;
6055       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6056       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6057     WHEN OTHERS THEN
6058       ROLLBACK TO query_task_pub2;
6059       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6060 
6061       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
6062         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
6063       END IF;
6064 
6065       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6066   END query_task;
6067 
6068   PROCEDURE query_next_task   --  INPUT VARIABLES
6069 
6070                            --  p_file_name         - file name for output of export file, always
6071                            --              placed in /sqlcom/out directory
6072                            --
6073                            --  p_task_id        -- current task id
6074                            --  p_query_type       -- values Dependency or Date for type of query
6075 
6076   --The following parameters only used if p_query_type is date
6077                            --  p_date_type        -- date type, values scheduled, planned, actual
6078                            --  p_date_start_or_end      -- use start or end date of current task values start/end
6079                            --  p_owner_id       -- query owner_id from jtf_tasks_v
6080                            --  p_owner_type_code      -- query owner_type_code from jtf_tasks_v
6081                            --  p_assigned_by        -- assigned_by
6082 
6083   --  p_sort_data         -- sort data structucture based on sort date
6084                            --  p_start_pointer       -- return records starting at this number
6085                            --  p_rec_wanted        -- return the next 'n' records from start_pointer
6086                            --  p_show_all        -- return all the records (value Y or N), overrides start_pointer, rec_wanted
6087                            --  p_query_or_next_code      -- run query or retrieve records from previous query (value Q/N)
6088                            --
6089                            --  OUTPUT values
6090                            --  x_task_table        -- pl/sql table of records
6091                            --  x_total_retrieved       -- total number of records selected by query
6092                            --  x_total_returned      -- number of records returned in pl/sql table
6093   (
6094     p_api_version           IN            NUMBER
6095   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
6096   , p_validate_level        IN            VARCHAR2 DEFAULT fnd_api.g_valid_level_full
6097   , p_task_id               IN            jtf_tasks_v.task_id%TYPE
6098   ,   -- current task id
6099     p_query_type            IN            VARCHAR2 DEFAULT 'Dependency'
6100   ,   -- values Dependency or Date
6101     p_date_type             IN            VARCHAR2 DEFAULT NULL
6102   , p_date_start_or_end     IN            VARCHAR2 DEFAULT NULL
6103   , p_owner_id              IN            jtf_tasks_v.owner_id%TYPE DEFAULT NULL
6104   , p_owner_type_code       IN            jtf_tasks_v.owner_type_code%TYPE DEFAULT NULL
6105   , p_assigned_by           IN            jtf_tasks_v.assigned_by_id%TYPE DEFAULT NULL
6106   , p_sort_data             IN            sort_data
6107   , p_start_pointer         IN            NUMBER
6108   , p_rec_wanted            IN            NUMBER
6109   , p_show_all              IN            VARCHAR2 DEFAULT 'Y'
6110   , p_query_or_next_code    IN            VARCHAR2 DEFAULT 'Q'
6111   , x_task_table            OUT NOCOPY    task_table_type
6112   , x_total_retrieved       OUT NOCOPY    NUMBER
6113   , x_total_returned        OUT NOCOPY    NUMBER
6114   , x_return_status         OUT NOCOPY    VARCHAR2
6115   , x_msg_count             OUT NOCOPY    NUMBER
6116   , x_msg_data              OUT NOCOPY    VARCHAR2
6117   , x_object_version_number IN OUT NOCOPY NUMBER
6118   ) IS
6119     l_api_version CONSTANT NUMBER         := 1.0;
6120     l_api_name    CONSTANT VARCHAR2(30)   := 'QUERY_NEXT_TASK';
6121     l_return_status        VARCHAR2(1)    := fnd_api.g_ret_sts_success;
6122     l_msg_data             VARCHAR2(2000);
6123     l_msg_count            NUMBER;
6124     l_query_type           VARCHAR2(20)   := UPPER(p_query_type);
6125     l_date_type            VARCHAR2(20)   := UPPER(p_date_type);
6126     l_date_start_or_end    VARCHAR2(6)    := UPPER(p_date_start_or_end);
6127   BEGIN
6128     SAVEPOINT query_next_task;
6129     x_return_status  := fnd_api.g_ret_sts_success;
6130 
6131     -- standard call to check for call compatibility
6132     IF (NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name)) THEN
6133       RAISE fnd_api.g_exc_unexpected_error;
6134     END IF;
6135 
6136     -- initialize message list i p_init_msg_list is set to true
6137     IF (fnd_api.to_boolean(p_init_msg_list)) THEN
6138       fnd_msg_pub.initialize;
6139     END IF;
6140 
6141     -- required parameters to control records returned
6142 
6143     -- p_query_or_next_code should be Q or N
6144     IF (p_query_or_next_code NOT IN('Q', 'N')) OR(p_query_or_next_code IS NULL) THEN
6145       fnd_message.set_name('JTF', 'JTF_TK_INV_QRY_NXT');
6146       fnd_msg_pub.ADD;
6147       RAISE fnd_api.g_exc_error;
6148     END IF;
6149 
6150     -- p_show_all should be Y or N
6151     IF (p_show_all NOT IN('Y', 'N')) OR(p_show_all IS NULL) THEN
6152       fnd_message.set_name('JTF', 'JTF_TK_INV_SHOW_ALL');
6153       fnd_msg_pub.ADD;
6154       RAISE fnd_api.g_exc_error;
6155     END IF;
6156 
6157     IF (p_show_all = 'N') THEN
6158       IF (p_start_pointer IS NULL) THEN
6159         fnd_message.set_name('JTF', 'JTF_TK_NULL_STRT_PTR');
6160         fnd_msg_pub.ADD;
6161         RAISE fnd_api.g_exc_error;
6162       END IF;
6163 
6164       IF (p_rec_wanted IS NULL) THEN
6165         fnd_message.set_name('JTF', 'JTF_TK_NULL_REC_WANT');
6166         fnd_msg_pub.ADD;
6167         RAISE fnd_api.g_exc_error;
6168       END IF;
6169     END IF;
6170 
6171     -- parameters to control querying
6172     IF (l_query_type NOT IN('DEPENDENCY', 'ASSIGNED', 'OWNER')) THEN
6173       fnd_message.set_name('JTF', 'JTF_TK_QRY_NXT_INV_QRY_TYP');
6174       fnd_msg_pub.ADD;
6175       RAISE fnd_api.g_exc_error;
6176     ELSE
6177       -- check date_type and date_start_or_end
6178       IF (l_date_type NOT IN('SCHEDULED', 'PLANNED', 'ACTUAL')) THEN
6179         fnd_message.set_name('JTF', 'JTF_TK_QRY_NXT_INV_DT_TYPE');
6180         fnd_msg_pub.ADD;
6181         RAISE fnd_api.g_exc_error;
6182       END IF;
6183 
6184       IF (l_date_start_or_end NOT IN('END', 'START')) THEN
6185         fnd_message.set_name('JTF', 'JTF_TK_QRY_NXT_INV_STRT_END_DT');
6186         fnd_msg_pub.ADD;
6187         RAISE fnd_api.g_exc_error;
6188       END IF;
6189 
6190       IF (l_query_type = 'ASSIGNED') THEN
6191         IF (p_assigned_by IS NULL) THEN
6192           fnd_message.set_name('JTF', 'JTF_TK_QRY_NXT_NUL_ASGND_BY');
6193           fnd_msg_pub.ADD;
6194           RAISE fnd_api.g_exc_error;
6195         END IF;
6196       ELSIF(l_query_type = 'OWNER') THEN
6197         IF (p_owner_type_code IS NULL OR p_owner_id IS NULL) THEN
6198           fnd_message.set_name('JTF', 'JTF_TK_QRY_NXT_NUL_OWNER');
6199           fnd_msg_pub.ADD;
6200           RAISE fnd_api.g_exc_error;
6201         END IF;
6202       END IF;
6203     END IF;
6204 
6205     -- validate query parameters
6206 
6207     -- task id should not be null
6208     IF (p_task_id IS NULL) THEN
6209       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_TASK');
6210       fnd_msg_pub.ADD;
6211       RAISE fnd_api.g_exc_error;
6212     END IF;
6213 
6214     -- check for valid task_id
6215     val_task_id(p_task_id);
6216     --call private api to execute the fetch
6217     jtf_tasks_pvt.query_next_task(
6218       0
6219     , p_task_id
6220     , UPPER(p_query_type)
6221     , UPPER(p_date_type)
6222     , UPPER(p_date_start_or_end)
6223     , p_owner_id
6224     , p_owner_type_code
6225     , p_assigned_by
6226     , p_sort_data
6227     , p_start_pointer
6228     , p_rec_wanted
6229     , p_show_all
6230     , p_query_or_next_code
6231     , x_task_table
6232     , x_total_retrieved
6233     , x_total_returned
6234     , x_return_status
6235     , x_msg_count
6236     , x_msg_data
6237     );
6238   EXCEPTION
6239     WHEN fnd_api.g_exc_error THEN
6240       ROLLBACK TO query_next_task;
6241       x_return_status  := fnd_api.g_ret_sts_error;
6242       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6243     WHEN fnd_api.g_exc_unexpected_error THEN
6244       ROLLBACK TO query_next_task;
6245       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6246       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6247     WHEN OTHERS THEN
6248       ROLLBACK TO query_next_task;
6249       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6250 
6251       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
6252         fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
6253       END IF;
6254 
6255       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
6256   END query_next_task;
6257 
6258   -----------
6259   -----------   Copy Task
6260   -----------
6261   -----------
6262   PROCEDURE copy_task(
6263     p_api_version              IN            NUMBER
6264   , p_init_msg_list            IN            VARCHAR2 DEFAULT fnd_api.g_false
6265   , p_commit                   IN            VARCHAR2 DEFAULT fnd_api.g_false
6266   , p_source_task_id           IN            NUMBER DEFAULT NULL
6267   , p_source_task_number       IN            VARCHAR2 DEFAULT NULL
6268   , p_target_task_id           IN            NUMBER DEFAULT NULL
6269   , p_copy_task_assignments    IN            VARCHAR2 DEFAULT fnd_api.g_false
6270   , p_copy_task_rsc_reqs       IN            VARCHAR2 DEFAULT fnd_api.g_false
6271   , p_copy_task_depends        IN            VARCHAR2 DEFAULT fnd_api.g_false
6272   , p_create_recurrences       IN            VARCHAR2 DEFAULT fnd_api.g_false
6273   , p_copy_task_references     IN            VARCHAR2 DEFAULT fnd_api.g_false
6274   , p_copy_task_dates          IN            VARCHAR2 DEFAULT fnd_api.g_false
6275   , x_return_status            OUT NOCOPY    VARCHAR2
6276   , p_copy_notes               IN            VARCHAR2 DEFAULT fnd_api.g_false
6277   , p_resource_id              IN            NUMBER DEFAULT NULL
6278   , p_resource_type            IN            VARCHAR2 DEFAULT NULL
6279   , x_msg_count                OUT NOCOPY    NUMBER
6280   , x_msg_data                 OUT NOCOPY    VARCHAR2
6281   , x_task_id                  OUT NOCOPY    NUMBER
6282   , p_copy_task_contacts       IN            VARCHAR2 DEFAULT jtf_task_utl.g_false_char
6283   , p_copy_task_contact_points IN            VARCHAR2 DEFAULT jtf_task_utl.g_false_char
6284   ) IS
6285     l_api_version     CONSTANT NUMBER                                             := 1.0;
6286     l_api_name        CONSTANT VARCHAR2(30)                                       := 'COPY_TASK';
6287     l_source_task_id           jtf_tasks_b.task_id%TYPE                         := p_source_task_id;
6288     l_target_task_id           jtf_tasks_b.task_id%TYPE                         := p_target_task_id;
6289     l_task_number              jtf_tasks_b.task_id%TYPE                     := p_source_task_number;
6290     l_dependency_id            jtf_task_depends.dependency_id%TYPE;
6291     l_task_assignment_id       jtf_task_all_assignments.task_assignment_id%TYPE;
6292     l_resource_req_id          jtf_task_rsc_reqs.resource_req_id%TYPE;
6293     l_task_reference_id        jtf_task_references_b.task_reference_id%TYPE;
6294     l_task_date_id             jtf_task_dates.task_date_id%TYPE;
6295     l_recurrence_rule_id       jtf_task_recur_rules.recurrence_rule_id%TYPE;
6296     l_task_rec                 jtf_task_recurrences_pub.task_details_rec;
6297     l_output_dates_counter     NUMBER;
6298 
6299     CURSOR c_task IS
6300       SELECT tk.laptop_flag
6301            , tk.device1_flag
6302            , tk.device2_flag
6303            , tk.device3_flag
6304            , tk.template_id
6305            , tk.template_group_id
6306            , tk.currency_code
6307            , tk.costs
6308            , tk.task_type_id
6309            , tk.task_status_id
6310            , tk.task_priority_id
6311            , tk.owner_id
6312            , tk.owner_type_code
6313            , tk.assigned_by_id
6314            , tk.cust_account_id
6315            , tk.customer_id
6316            , tk.address_id
6317            , tk.location_id
6318            , tk.planned_start_date
6319            , tk.planned_end_date
6320            , tk.scheduled_start_date
6321            , tk.scheduled_end_date
6322            , tk.actual_start_date
6323            , tk.actual_end_date
6324            , tk.source_object_type_code
6325            , tk.timezone_id
6326            , tk.source_object_id
6327            , tk.source_object_name
6328            , tk.DURATION
6329            , tk.duration_uom
6330            , tk.planned_effort
6331            , tk.planned_effort_uom
6332            , tk.actual_effort
6333            , tk.actual_effort_uom
6334            , tk.percentage_complete
6335            , tk.reason_code
6336            , tk.private_flag
6337            , tk.publish_flag
6338            , tk.restrict_closure_flag
6339            , tk.multi_booked_flag
6340            , tk.milestone_flag
6341            , tk.holiday_flag
6342            , tk.billable_flag
6343            , tk.bound_mode_code
6344            , tk.soft_bound_flag
6345            , tk.workflow_process_id
6346            , tk.notification_flag
6347            , tk.notification_period
6348            , tk.notification_period_uom
6349            , tk.parent_task_id
6350            , tk.recurrence_rule_id
6351            , tk.alarm_start
6352            , tk.alarm_start_uom
6353            , tk.alarm_on
6354            , tk.alarm_count
6355            , tk.alarm_fired_count
6356            , tk.alarm_interval
6357            , tk.alarm_interval_uom
6358            , tk.deleted_flag
6359            , tk.palm_flag
6360            , tk.wince_flag
6361            , tk.task_name
6362            , tk.description
6363            , tk.date_selected
6364            , tk.attribute1
6365            , tk.attribute2
6366            , tk.attribute3
6367            , tk.attribute4
6368            , tk.attribute5
6369            , tk.attribute6
6370            , tk.attribute7
6371            , tk.attribute8
6372            , tk.attribute9
6373            , tk.attribute10
6374            , tk.attribute11
6375            , tk.attribute12
6376            , tk.attribute13
6377            , tk.attribute14
6378            , tk.attribute15
6379            , tk.attribute_category
6380            , NVL(tka.category_id, NULL) category_id
6381            , NVL(tka.show_on_calendar, NULL) show_on_calendar
6382            , NVL(tka.assignment_status_id, NULL) assignment_status_id
6383            , tka.free_busy_type free_busy_type
6384            , tk.entity
6385         FROM jtf_tasks_vl tk, jtf_task_all_assignments tka
6386        WHERE tk.task_id = l_source_task_id AND tk.task_id = tka.task_id(+) AND 'OWNER' = tka.assignee_role(+);
6387 
6388     -- Fetch also assignment details for OWNER, if present, as this is
6389     -- created by the task_create API
6390     CURSOR c_depends IS
6391       SELECT dependent_on_task_id
6392            , dependency_type_code
6393            , template_flag
6394            , adjustment_time
6395            , adjustment_time_uom
6396            , validated_flag
6397         FROM jtf_task_depends
6398        WHERE task_id = l_source_task_id;
6399 
6400     CURSOR c_references IS
6401       SELECT object_type_code
6402            , object_name
6403            , object_id
6404            , object_details
6405            , reference_code
6406            , USAGE
6407         FROM jtf_task_references_vl
6408        WHERE task_id = l_source_task_id;
6409 
6410     CURSOR c_dates IS
6411       SELECT date_type_id
6412            , date_value
6413         FROM jtf_task_dates
6414        WHERE task_id = l_source_task_id;
6415 
6416     CURSOR c_recurs IS
6417       SELECT occurs_which
6418            , day_of_week
6419            , date_of_month
6420            , occurs_month
6421            , occurs_uom
6422            , occurs_every
6423            , occurs_number
6424            , start_date_active
6425            , end_date_active
6426         FROM jtf_task_recur_rules
6427        WHERE recurrence_rule_id = l_recurrence_rule_id;
6428 
6429     CURSOR c_rsc_reqs IS
6430       SELECT task_id
6431            , resource_type_code
6432            , required_units
6433            , enabled_flag
6434         FROM jtf_task_rsc_reqs
6435        WHERE task_id = l_source_task_id;
6436 
6437     CURSOR c_assignments IS
6438       SELECT resource_type_code
6439            , resource_id
6440            , actual_effort
6441            , actual_effort_uom
6442            , schedule_flag
6443            , alarm_type_code
6444            , alarm_contact
6445            , sched_travel_distance
6446            , sched_travel_duration
6447            , sched_travel_duration_uom
6448            , actual_travel_distance
6449            , actual_travel_duration
6450            , actual_travel_duration_uom
6451            , actual_start_date
6452            , actual_end_date
6453            , palm_flag
6454            , wince_flag
6455            , laptop_flag
6456            , device1_flag
6457            , device2_flag
6458            , device3_flag
6459            , resource_territory_id
6460            , assignment_status_id
6461            , assignee_role
6462            , show_on_calendar
6463            , category_id
6464            , free_busy_type
6465         FROM jtf_task_all_assignments
6466        WHERE task_id = l_source_task_id AND assignee_role = 'ASSIGNEE';
6467 
6468     -- Assignment record for OWNER is created by the task_create API
6469     CURSOR c1_assignments IS
6470       SELECT resource_type_code
6471            , resource_id
6472            , actual_effort
6473            , actual_effort_uom
6474            , schedule_flag
6475            , alarm_type_code
6476            , alarm_contact
6477            , sched_travel_distance
6478            , sched_travel_duration
6479            , sched_travel_duration_uom
6480            , actual_travel_distance
6481            , actual_travel_duration
6482            , actual_travel_duration_uom
6483            , actual_start_date
6484            , actual_end_date
6485            , palm_flag
6486            , wince_flag
6487            , laptop_flag
6488            , device1_flag
6489            , device2_flag
6490            , device3_flag
6491            , resource_territory_id
6492            , assignment_status_id
6493            , assignee_role
6494            , show_on_calendar
6495            , category_id
6496            , free_busy_type
6497         FROM jtf_task_all_assignments
6498        WHERE task_id = l_source_task_id AND assignee_role = 'ASSIGNEE';
6499 
6500     CURSOR c_notes(p_source_object_code IN VARCHAR2) IS
6501       SELECT jtf_note_id
6502            , parent_note_id
6503            , source_object_id
6504            , source_object_code
6505            , source_number
6506            , last_update_date
6507            , last_updated_by
6508            , creation_date
6509            , created_by
6510            , last_update_login
6511            , notes
6512            , notes_detail
6513            , note_status
6514            , entered_by
6515            , entered_by_name
6516            , entered_date
6517            , source_object_meaning
6518            , note_type
6519            , note_type_meaning
6520            , attribute1
6521            , attribute2
6522            , attribute3
6523            , attribute4
6524            , attribute5
6525            , attribute6
6526            , attribute7
6527            , attribute8
6528            , attribute9
6529            , attribute10
6530            , attribute11
6531            , attribute12
6532            , attribute13
6533            , attribute14
6534            , attribute15
6535            , CONTEXT
6536            , note_status_meaning
6537         FROM jtf_notes_vl
6538        WHERE source_object_id = l_source_task_id AND source_object_code = p_source_object_code;
6539 
6540     CURSOR c_contacts IS
6541       SELECT task_contact_id
6542            , contact_id
6543            , contact_type_code
6544            , escalation_notify_flag
6545            , escalation_requester_flag
6546            , primary_flag
6547         FROM jtf_task_contacts
6548        WHERE task_id = l_source_task_id;
6549 
6550     CURSOR c_contact_points(b_contact_id jtf_task_phones.task_contact_id%TYPE) IS
6551       SELECT phone_id
6552            , task_phone_id
6553            , primary_flag
6554         FROM jtf_task_phones
6555        WHERE task_contact_id = b_contact_id;
6556 
6557     tasks                      c_task%ROWTYPE;
6558     depends                    c_depends%ROWTYPE;
6559     REFERENCE                  c_references%ROWTYPE;
6560     dates                      c_dates%ROWTYPE;
6561     recurs                     c_recurs%ROWTYPE;
6562     rsc_reqs                   c_rsc_reqs%ROWTYPE;
6563     assignments                c_assignments%ROWTYPE;
6564     notes                      c_notes%ROWTYPE;
6565     contacts                   c_contacts%ROWTYPE;
6566     contact_points             c_contact_points%ROWTYPE;
6567     l_jtf_note_id              NUMBER;
6568     l_rowid                    VARCHAR2(20);
6569     l_note_id                  NUMBER;
6570     l_source_object_id         NUMBER;
6571     l_notes_detail             VARCHAR2(32767);
6572     l_task_contact_id          NUMBER;
6573     l_task_phone_id            NUMBER;
6574     l_notes_source_object_code VARCHAR2(50);   -- Added on 31/05/2006 for bug# 5211606
6575   BEGIN
6576     SAVEPOINT copy_task;
6577     x_return_status  := fnd_api.g_ret_sts_success;
6578 
6579     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
6580       RAISE fnd_api.g_exc_unexpected_error;
6581     END IF;
6582 
6583     IF fnd_api.to_boolean(p_init_msg_list) THEN
6584       fnd_msg_pub.initialize;
6585     END IF;
6586 
6587     IF l_source_task_id IS NULL THEN
6588       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6589       fnd_message.set_name('JTF', 'JTF_TASK_MISSING_TASK_ID');
6590       fnd_msg_pub.ADD;
6591       RAISE fnd_api.g_exc_unexpected_error;
6592     END IF;
6593 
6594     jtf_task_utl.validate_task(
6595       x_return_status              => x_return_status
6596     , p_task_id                    => p_source_task_id
6597     , p_task_number                => p_source_task_number
6598     , x_task_id                    => l_source_task_id
6599     );
6600 
6601     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
6602       RAISE fnd_api.g_exc_unexpected_error;
6603     END IF;
6604 
6605     --- copy the main task.
6606     OPEN c_task;
6607     FETCH c_task INTO tasks;
6608     IF c_task%NOTFOUND THEN
6609       x_return_status  := fnd_api.g_ret_sts_unexp_error;
6610       fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_ID');
6611       fnd_message.set_token('P_TASK_ID', l_source_task_id);
6612       fnd_msg_pub.ADD;
6613       RAISE fnd_api.g_exc_unexpected_error;
6614       CLOSE c_task;
6615     END IF;
6616 
6617     ----------------------------------------------------------------------------------------------------------------------------------
6618     IF (p_resource_id IS NOT NULL AND p_resource_type IS NOT NULL) THEN
6619       -- Copy task for all the members in a group or a team.
6620       jtf_tasks_pvt.create_task(
6621         p_api_version                => 1.0
6622       , p_init_msg_list              => fnd_api.g_false
6623       , p_commit                     => fnd_api.g_false
6624       , p_task_id                    => p_target_task_id
6625       , p_task_name                  => tasks.task_name
6626       , p_task_type_id               => tasks.task_type_id
6627       , p_description                => tasks.description
6628       , p_task_status_id             => tasks.task_status_id
6629       , p_task_priority_id           => tasks.task_priority_id
6630       , p_owner_type_code            => p_resource_type
6631       , p_owner_id                   => p_resource_id
6632       , p_assigned_by_id             => tasks.assigned_by_id
6633       , p_customer_id                => tasks.customer_id
6634       , p_cust_account_id            => tasks.cust_account_id
6635       , p_address_id                 => tasks.address_id
6636       , p_planned_start_date         => tasks.planned_start_date
6637       , p_planned_end_date           => tasks.planned_end_date
6638       , p_scheduled_start_date       => tasks.scheduled_start_date
6639       , p_scheduled_end_date         => tasks.scheduled_end_date
6640       , p_actual_start_date          => tasks.actual_start_date
6641       , p_actual_end_date            => tasks.actual_end_date
6642       , p_timezone_id                => tasks.timezone_id
6643       , p_source_object_type_code    => tasks.source_object_type_code
6644       , p_source_object_id           => tasks.source_object_id
6645       , p_source_object_name         => tasks.source_object_name
6646       , p_duration                   => tasks.DURATION
6647       , p_duration_uom               => tasks.duration_uom
6648       , p_planned_effort             => tasks.planned_effort
6649       , p_planned_effort_uom         => tasks.planned_effort_uom
6650       , p_actual_effort              => tasks.actual_effort
6651       , p_actual_effort_uom          => tasks.actual_effort_uom
6652       , p_percentage_complete        => tasks.percentage_complete
6653       , p_reason_code                => tasks.reason_code
6654       , p_private_flag               => tasks.private_flag
6655       , p_publish_flag               => tasks.publish_flag
6656       , p_restrict_closure_flag      => tasks.restrict_closure_flag
6657       , p_multi_booked_flag          => tasks.multi_booked_flag
6658       , p_milestone_flag             => tasks.milestone_flag
6659       , p_holiday_flag               => tasks.holiday_flag
6660       , p_billable_flag              => tasks.billable_flag
6661       , p_bound_mode_code            => tasks.bound_mode_code
6662       , p_soft_bound_flag            => tasks.soft_bound_flag
6663       , p_notification_flag          => tasks.notification_flag
6664       , p_notification_period        => tasks.notification_period
6665       , p_notification_period_uom    => tasks.notification_period_uom
6666       , p_parent_task_id             => tasks.parent_task_id
6667       , p_alarm_start                => tasks.alarm_start
6668       , p_alarm_start_uom            => tasks.alarm_start_uom
6669       , p_alarm_on                   => tasks.alarm_on
6670       , p_alarm_count                => tasks.alarm_count
6671       , p_alarm_interval             => tasks.alarm_interval
6672       , p_alarm_interval_uom         => tasks.alarm_interval_uom
6673       , p_palm_flag                  => tasks.palm_flag
6674       , p_wince_flag                 => tasks.wince_flag
6675       , p_laptop_flag                => tasks.laptop_flag
6676       , p_device1_flag               => tasks.device1_flag
6677       , p_device2_flag               => tasks.device2_flag
6678       , p_device3_flag               => tasks.device3_flag
6679       , p_costs                      => tasks.costs
6680       , p_currency_code              => tasks.currency_code
6681       , x_return_status              => x_return_status
6682       , x_msg_count                  => x_msg_count
6683       , x_msg_data                   => x_msg_data
6684       , x_task_id                    => l_target_task_id
6685       , p_date_selected              => tasks.date_selected
6686       , p_category_id                => tasks.category_id
6687       , p_show_on_calendar           => tasks.show_on_calendar
6688       , p_owner_status_id            => tasks.assignment_status_id
6689       , p_attribute1                 => tasks.attribute1
6690       , p_attribute2                 => tasks.attribute2
6691       , p_attribute3                 => tasks.attribute3
6692       , p_attribute4                 => tasks.attribute4
6693       , p_attribute5                 => tasks.attribute5
6694       , p_attribute6                 => tasks.attribute6
6695       , p_attribute7                 => tasks.attribute7
6696       , p_attribute8                 => tasks.attribute8
6697       , p_attribute9                 => tasks.attribute9
6698       , p_attribute10                => tasks.attribute10
6699       , p_attribute11                => tasks.attribute11
6700       , p_attribute12                => tasks.attribute12
6701       , p_attribute13                => tasks.attribute13
6702       , p_attribute14                => tasks.attribute14
6703       , p_attribute15                => tasks.attribute15
6704       , p_attribute_category         => tasks.attribute_category
6705       , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
6706       , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
6707       , p_entity                     => tasks.entity
6708       , p_free_busy_type             => tasks.free_busy_type
6709       , p_task_confirmation_status   => 'N'
6710       , p_task_confirmation_counter  => NULL
6711       , p_task_split_flag            => NULL
6712       , p_reference_flag             => NULL
6713       , p_child_position             => NULL
6714       , p_child_sequence_num         => NULL
6715       , p_location_id                => tasks.location_id
6716       , p_template_id                => tasks.template_id
6717       , p_template_group_id          => tasks.template_group_id
6718       , p_copied_from_task_id        => l_source_task_id
6719       );
6720 
6721       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
6722         x_return_status  := fnd_api.g_ret_sts_unexp_error;
6723         RAISE fnd_api.g_exc_unexpected_error;
6724       END IF;
6725 
6726       --Create notes
6727       IF fnd_api.to_boolean(p_copy_notes) THEN
6728         -- Added on 31/05/2006 for bug# 5211606
6729         IF ((tasks.entity IS NOT NULL) AND(tasks.entity = 'ESCALATION')) THEN
6730           l_notes_source_object_code  := 'ESC';
6731         ELSE
6732           l_notes_source_object_code  := tasks.entity;
6733         END IF;
6734 
6735         -- Modified on 31/05/2006 for bug# 5211606
6736         FOR notes_rec IN c_notes(l_notes_source_object_code) LOOP
6737           jtf_notes_pub.writelobtodata(notes_rec.jtf_note_id, l_notes_detail);
6738 
6739           SELECT jtf_notes_s.NEXTVAL
6740             INTO l_note_id
6741             FROM DUAL;
6742 
6743           jtf_notes_pkg.insert_row(
6744             x_rowid                      => l_rowid
6745           , x_jtf_note_id                => l_note_id
6746           , x_source_object_code         => notes_rec.source_object_code
6747           , x_note_status                => notes_rec.note_status
6748           , x_entered_by                 => notes_rec.entered_by
6749           , x_entered_date               => notes_rec.entered_date
6750           , x_note_type                  => notes_rec.note_type
6751           , x_attribute1                 => notes_rec.attribute1
6752           , x_attribute2                 => notes_rec.attribute2
6753           , x_attribute3                 => notes_rec.attribute3
6754           , x_attribute4                 => notes_rec.attribute4
6755           , x_attribute5                 => notes_rec.attribute5
6756           , x_attribute6                 => notes_rec.attribute6
6757           , x_attribute7                 => notes_rec.attribute7
6758           , x_attribute8                 => notes_rec.attribute8
6759           , x_attribute9                 => notes_rec.attribute9
6760           , x_attribute10                => notes_rec.attribute10
6761           , x_attribute11                => notes_rec.attribute11
6762           , x_attribute12                => notes_rec.attribute12
6763           , x_attribute13                => notes_rec.attribute13
6764           , x_attribute14                => notes_rec.attribute14
6765           , x_attribute15                => notes_rec.attribute15
6766           , x_context                    => notes_rec.CONTEXT
6767           , x_parent_note_id             => notes_rec.parent_note_id
6768           , x_source_object_id           => l_target_task_id
6769           , x_notes                      => notes_rec.notes
6770           , x_notes_detail               => l_notes_detail
6771           , x_creation_date              => notes_rec.creation_date
6772           , x_created_by                 => notes_rec.created_by
6773           , x_last_update_date           => notes_rec.last_update_date
6774           , x_last_updated_by            => notes_rec.last_updated_by
6775           , x_last_update_login          => notes_rec.last_update_login
6776           );
6777 
6778           IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
6779             x_return_status  := fnd_api.g_ret_sts_unexp_error;
6780             RAISE fnd_api.g_exc_unexpected_error;
6781           END IF;
6782         END LOOP;
6783       END IF;
6784     ELSE
6785       jtf_tasks_pvt.create_task(
6786         p_api_version                => 1.0
6787       , p_init_msg_list              => fnd_api.g_false
6788       , p_commit                     => fnd_api.g_false
6789       , p_task_id                    => p_target_task_id
6790       , p_task_name                  => tasks.task_name
6791       , p_task_type_id               => tasks.task_type_id
6792       , p_description                => tasks.description
6793       , p_task_status_id             => tasks.task_status_id
6794       , p_task_priority_id           => tasks.task_priority_id
6795       , p_owner_type_code            => tasks.owner_type_code
6796       , p_owner_id                   => tasks.owner_id
6797       , p_assigned_by_id             => tasks.assigned_by_id
6798       , p_customer_id                => tasks.customer_id
6799       , p_cust_account_id            => tasks.cust_account_id
6800       , p_address_id                 => tasks.address_id
6801       , p_planned_start_date         => tasks.planned_start_date
6802       , p_planned_end_date           => tasks.planned_end_date
6803       , p_scheduled_start_date       => tasks.scheduled_start_date
6804       , p_scheduled_end_date         => tasks.scheduled_end_date
6805       , p_actual_start_date          => tasks.actual_start_date
6806       , p_actual_end_date            => tasks.actual_end_date
6807       , p_timezone_id                => tasks.timezone_id
6808       , p_source_object_type_code    => tasks.source_object_type_code
6809       , p_source_object_id           => tasks.source_object_id
6810       , p_source_object_name         => tasks.source_object_name
6811       , p_duration                   => tasks.DURATION
6812       , p_duration_uom               => tasks.duration_uom
6813       , p_planned_effort             => tasks.planned_effort
6814       , p_planned_effort_uom         => tasks.planned_effort_uom
6815       , p_actual_effort              => tasks.actual_effort
6816       , p_actual_effort_uom          => tasks.actual_effort_uom
6817       , p_percentage_complete        => tasks.percentage_complete
6818       , p_reason_code                => tasks.reason_code
6819       , p_private_flag               => tasks.private_flag
6820       , p_publish_flag               => tasks.publish_flag
6821       , p_restrict_closure_flag      => tasks.restrict_closure_flag
6822       , p_multi_booked_flag          => tasks.multi_booked_flag
6823       , p_milestone_flag             => tasks.milestone_flag
6824       , p_holiday_flag               => tasks.holiday_flag
6825       , p_billable_flag              => tasks.billable_flag
6826       , p_bound_mode_code            => tasks.bound_mode_code
6827       , p_soft_bound_flag            => tasks.soft_bound_flag
6828       , p_notification_flag          => tasks.notification_flag
6829       , p_notification_period        => tasks.notification_period
6830       , p_notification_period_uom    => tasks.notification_period_uom
6831       , p_parent_task_id             => tasks.parent_task_id
6832       , p_alarm_start                => tasks.alarm_start
6833       , p_alarm_start_uom            => tasks.alarm_start_uom
6834       , p_alarm_on                   => tasks.alarm_on
6835       , p_alarm_count                => tasks.alarm_count
6836       , p_alarm_interval             => tasks.alarm_interval
6837       , p_alarm_interval_uom         => tasks.alarm_interval_uom
6838       , p_palm_flag                  => tasks.palm_flag
6839       , p_wince_flag                 => tasks.wince_flag
6840       , p_laptop_flag                => tasks.laptop_flag
6841       , p_device1_flag               => tasks.device1_flag
6842       , p_device2_flag               => tasks.device2_flag
6843       , p_device3_flag               => tasks.device3_flag
6844       , p_costs                      => tasks.costs
6845       , p_currency_code              => tasks.currency_code
6846       , x_return_status              => x_return_status
6847       , x_msg_count                  => x_msg_count
6848       , x_msg_data                   => x_msg_data
6849       , x_task_id                    => l_target_task_id
6850       , p_date_selected              => tasks.date_selected
6851       , p_category_id                => tasks.category_id
6852       , p_show_on_calendar           => tasks.show_on_calendar
6853       , p_owner_status_id            => tasks.assignment_status_id
6854       , p_attribute1                 => tasks.attribute1
6855       , p_attribute2                 => tasks.attribute2
6856       , p_attribute3                 => tasks.attribute3
6857       , p_attribute4                 => tasks.attribute4
6858       , p_attribute5                 => tasks.attribute5
6859       , p_attribute6                 => tasks.attribute6
6860       , p_attribute7                 => tasks.attribute7
6861       , p_attribute8                 => tasks.attribute8
6862       , p_attribute9                 => tasks.attribute9
6863       , p_attribute10                => tasks.attribute10
6864       , p_attribute11                => tasks.attribute11
6865       , p_attribute12                => tasks.attribute12
6866       , p_attribute13                => tasks.attribute13
6867       , p_attribute14                => tasks.attribute14
6868       , p_attribute15                => tasks.attribute15
6869       , p_attribute_category         => tasks.attribute_category
6870       , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
6871       , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
6872       , p_entity                     => tasks.entity
6873       , p_free_busy_type             => tasks.free_busy_type
6874       , p_task_confirmation_status   => 'N'
6875       , p_task_confirmation_counter  => NULL
6876       , p_task_split_flag            => NULL
6877       , p_reference_flag             => NULL
6878       , p_child_position             => NULL
6879       , p_child_sequence_num         => NULL
6880       , p_location_id                => tasks.location_id
6881       , p_template_id                => tasks.template_id
6882       , p_template_group_id          => tasks.template_group_id
6883       , p_copied_from_task_id        => l_source_task_id
6884       );
6885       x_task_id  := l_target_task_id;
6886 
6887       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
6888         x_return_status  := fnd_api.g_ret_sts_unexp_error;
6889         RAISE fnd_api.g_exc_unexpected_error;
6890       END IF;
6891     END IF;
6892 
6893     IF c_task%ISOPEN THEN
6894       CLOSE c_task;
6895     END IF;
6896 
6897     ------
6898     ------ Create contact point for the customer
6899     ------ (where task_contact_id = task_id)
6900     ------
6901     FOR contact_points IN c_contact_points(l_source_task_id) LOOP
6902       jtf_task_phones_pub.create_task_phones(
6903         p_api_version                => 1.0
6904       , p_init_msg_list              => fnd_api.g_false
6905       , p_commit                     => fnd_api.g_false
6906       , p_task_contact_id            => l_target_task_id
6907       , p_phone_id                   => contact_points.phone_id
6908       , p_primary_flag               => contact_points.primary_flag
6909       , p_owner_table_name           => 'JTF_TASKS_B'
6910       , x_return_status              => x_return_status
6911       , x_msg_count                  => x_msg_count
6912       , x_msg_data                   => x_msg_data
6913       , x_task_phone_id              => l_task_phone_id
6914       );
6915 
6916       IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
6917         x_return_status  := fnd_api.g_ret_sts_unexp_error;
6918         RAISE fnd_api.g_exc_unexpected_error;
6919       END IF;
6920     END LOOP;
6921 
6922     -------------------------------------------------------------------------------------------------------------------------
6923     ------
6924     ------ Create dependencies
6925     ------
6926     IF fnd_api.to_boolean(p_copy_task_depends) THEN
6927       FOR depends IN c_depends LOOP
6928         jtf_task_dependency_pvt.create_task_dependency(
6929           p_api_version                => 1.0
6930         , p_init_msg_list              => fnd_api.g_false
6931         , p_commit                     => fnd_api.g_false
6932         , p_task_id                    => l_target_task_id
6933         , p_dependent_on_task_id       => depends.dependent_on_task_id
6934         , p_dependency_type_code       => depends.dependency_type_code
6935         , p_template_flag              => depends.template_flag
6936         , p_adjustment_time            => depends.adjustment_time
6937         , p_adjustment_time_uom        => depends.adjustment_time_uom
6938         , p_validated_flag             => depends.validated_flag
6939         , x_dependency_id              => l_dependency_id
6940         , x_return_status              => x_return_status
6941         , x_msg_count                  => x_msg_count
6942         , x_msg_data                   => x_msg_data
6943         );
6944 
6945         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
6946           x_return_status  := fnd_api.g_ret_sts_unexp_error;
6947           RAISE fnd_api.g_exc_unexpected_error;
6948         END IF;
6949       END LOOP;
6950     END IF;
6951 
6952     ------
6953     ------ Create Resource Requirements
6954     ------
6955     IF fnd_api.to_boolean(p_copy_task_rsc_reqs) THEN
6956       FOR rsc_reqs IN c_rsc_reqs LOOP
6957         jtf_task_resources_pub.create_task_rsrc_req(
6958           p_api_version                => 1.0
6959         , p_init_msg_list              => fnd_api.g_false
6960         , p_commit                     => fnd_api.g_false
6961         , p_task_id                    => l_target_task_id
6962         , p_resource_type_code         => rsc_reqs.resource_type_code
6963         , p_required_units             => rsc_reqs.required_units
6964         , p_enabled_flag               => rsc_reqs.enabled_flag
6965         , x_return_status              => x_return_status
6966         , x_msg_count                  => x_msg_count
6967         , x_msg_data                   => x_msg_data
6968         , x_resource_req_id            => l_resource_req_id
6969         );
6970 
6971         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
6972           x_return_status  := fnd_api.g_ret_sts_unexp_error;
6973           RAISE fnd_api.g_exc_unexpected_error;
6974         END IF;
6975       END LOOP;
6976     END IF;
6977 
6978     -----------------------------------------------------------------------------------------------------
6979     ---Code added for mass task creation
6980 
6981     ------
6982     ------ Create Task Assignments
6983     ------
6984     IF fnd_api.to_boolean(p_copy_task_assignments) THEN
6985       jtf_task_utl.g_validate_category  := FALSE;
6986 
6987       IF (p_resource_id IS NOT NULL AND p_resource_type IS NOT NULL) THEN
6988         FOR assignments IN c1_assignments LOOP
6989           jtf_task_assignments_pub.create_task_assignment(
6990             p_api_version                => 1.0
6991           , p_init_msg_list              => fnd_api.g_false
6992           , p_commit                     => fnd_api.g_false
6993           , p_task_id                    => l_target_task_id
6994           , p_resource_type_code         => p_resource_type
6995           , p_resource_id                => p_resource_id
6996           , p_resource_territory_id      => assignments.resource_territory_id
6997           , p_assignment_status_id       => assignments.assignment_status_id
6998           , p_actual_effort              => assignments.actual_effort
6999           , p_actual_effort_uom          => assignments.actual_effort_uom
7000           , p_schedule_flag              => assignments.schedule_flag
7001           , p_alarm_type_code            => assignments.alarm_type_code
7002           , p_alarm_contact              => assignments.alarm_contact
7003           , p_sched_travel_distance      => assignments.sched_travel_duration
7004           , p_sched_travel_duration      => assignments.sched_travel_duration
7005           , p_sched_travel_duration_uom  => assignments.sched_travel_duration_uom
7006           , p_actual_travel_distance     => assignments.actual_travel_distance
7007           , p_actual_travel_duration     => assignments.actual_travel_duration
7008           , p_actual_travel_duration_uom => assignments.actual_travel_duration_uom
7009           , p_actual_start_date          => assignments.actual_start_date
7010           , p_actual_end_date            => assignments.actual_end_date
7011           , p_palm_flag                  => assignments.palm_flag
7012           , p_wince_flag                 => assignments.wince_flag
7013           , p_laptop_flag                => assignments.laptop_flag
7014           , p_device1_flag               => assignments.device1_flag
7015           , p_device2_flag               => assignments.device2_flag
7016           , p_device3_flag               => assignments.device3_flag
7017           , x_return_status              => x_return_status
7018           , x_msg_count                  => x_msg_count
7019           , x_msg_data                   => x_msg_data
7020           , x_task_assignment_id         => l_task_assignment_id
7021           , p_show_on_calendar           => assignments.show_on_calendar
7022           , p_category_id                => assignments.category_id
7023           , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
7024           , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
7025           , p_object_capacity_id         => NULL
7026           , p_free_busy_type             => assignments.free_busy_type
7027           );
7028 
7029           IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7030             x_return_status  := fnd_api.g_ret_sts_unexp_error;
7031             RAISE fnd_api.g_exc_unexpected_error;
7032           END IF;
7033         END LOOP;
7034       ELSE
7035         FOR assignments IN c_assignments LOOP
7036           jtf_task_assignments_pub.create_task_assignment(
7037             p_api_version                => 1.0
7038           , p_init_msg_list              => fnd_api.g_false
7039           , p_commit                     => fnd_api.g_false
7040           , p_task_id                    => l_target_task_id
7041           , p_resource_type_code         => assignments.resource_type_code
7042           , p_resource_id                => assignments.resource_id
7043           , p_resource_territory_id      => assignments.resource_territory_id
7044           , p_assignment_status_id       => assignments.assignment_status_id
7045           , p_actual_effort              => assignments.actual_effort
7046           , p_actual_effort_uom          => assignments.actual_effort_uom
7047           , p_schedule_flag              => assignments.schedule_flag
7048           , p_alarm_type_code            => assignments.alarm_type_code
7049           , p_alarm_contact              => assignments.alarm_contact
7050           , p_sched_travel_distance      => assignments.sched_travel_duration
7051           , p_sched_travel_duration      => assignments.sched_travel_duration
7052           , p_sched_travel_duration_uom  => assignments.sched_travel_duration_uom
7053           , p_actual_travel_distance     => assignments.actual_travel_distance
7054           , p_actual_travel_duration     => assignments.actual_travel_duration
7055           , p_actual_travel_duration_uom => assignments.actual_travel_duration_uom
7056           , p_actual_start_date          => assignments.actual_start_date
7057           , p_actual_end_date            => assignments.actual_end_date
7058           , p_palm_flag                  => assignments.palm_flag
7059           , p_wince_flag                 => assignments.wince_flag
7060           , p_laptop_flag                => assignments.laptop_flag
7061           , p_device1_flag               => assignments.device1_flag
7062           , p_device2_flag               => assignments.device2_flag
7063           , p_device3_flag               => assignments.device3_flag
7064           , x_return_status              => x_return_status
7065           , x_msg_count                  => x_msg_count
7066           , x_msg_data                   => x_msg_data
7067           , x_task_assignment_id         => l_task_assignment_id
7068           , p_show_on_calendar           => assignments.show_on_calendar
7069           , p_category_id                => assignments.category_id
7070           , p_enable_workflow            => fnd_profile.VALUE('JTF_TASK_ENABLE_WORKFLOW')
7071           , p_abort_workflow             => fnd_profile.VALUE('JTF_TASK_ABORT_PREV_WF')
7072           , p_object_capacity_id         => NULL
7073           , p_free_busy_type             => assignments.free_busy_type
7074           );
7075 
7076           IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7077             x_return_status  := fnd_api.g_ret_sts_unexp_error;
7078             RAISE fnd_api.g_exc_unexpected_error;
7079           END IF;
7080         END LOOP;
7081       END IF;
7082     END IF;
7083 
7084     ------
7085     ------ Create references
7086     ------
7087     IF fnd_api.to_boolean(p_copy_task_references) THEN
7088       FOR REFERENCE IN c_references LOOP
7089         jtf_task_utl.g_show_error_for_dup_reference  := FALSE;
7090         jtf_task_references_pvt.create_references(
7091           p_api_version                => 1.0
7092         , p_init_msg_list              => fnd_api.g_false
7093         , p_commit                     => fnd_api.g_false
7094         , p_task_id                    => l_target_task_id
7095         , p_object_type_code           => REFERENCE.object_type_code
7096         , p_object_name                => REFERENCE.object_name
7097         , p_object_id                  => REFERENCE.object_id
7098         , p_object_details             => REFERENCE.object_details
7099         , p_reference_code             => REFERENCE.reference_code
7100         , p_usage                      => REFERENCE.USAGE
7101         , x_return_status              => x_return_status
7102         , x_msg_data                   => x_msg_data
7103         , x_msg_count                  => x_msg_count
7104         , x_task_reference_id          => l_task_reference_id
7105         );
7106 
7107         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7108           x_return_status  := fnd_api.g_ret_sts_unexp_error;
7109           RAISE fnd_api.g_exc_unexpected_error;
7110         END IF;
7111       END LOOP;
7112     END IF;
7113 
7114     ------
7115     ------ Create dates
7116     ------
7117     IF fnd_api.to_boolean(p_copy_task_dates) THEN
7118       FOR dates IN c_dates LOOP
7119         jtf_task_dates_pvt.create_task_dates(
7120           p_api_version                => 1.0
7121         , p_init_msg_list              => fnd_api.g_false
7122         , p_commit                     => fnd_api.g_false
7123         , p_task_id                    => l_target_task_id
7124         , p_date_type_id               => dates.date_type_id
7125         , p_date_value                 => dates.date_value
7126         , x_return_status              => x_return_status
7127         , x_msg_count                  => x_msg_count
7128         , x_msg_data                   => x_msg_data
7129         , x_task_date_id               => l_task_date_id
7130         );
7131 
7132         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7133           x_return_status  := fnd_api.g_ret_sts_unexp_error;
7134           RAISE fnd_api.g_exc_unexpected_error;
7135         END IF;
7136       END LOOP;
7137     END IF;
7138 
7139     ---- if the user wants to create the recurrences, then check if the source task has a valid recurrence_id
7140     ---- if yes, then get the recurrence rule and pass it to the task while creating the task.
7141     ---- if no, then error out.
7142 
7143     ---- For recurrences
7144     IF fnd_api.to_boolean(p_create_recurrences) THEN
7145       IF fnd_api.to_boolean(p_create_recurrences) THEN
7146         ---- get the recurrence rule id for the source task
7147         BEGIN
7148           SELECT recurrence_rule_id
7149             INTO l_recurrence_rule_id
7150             FROM jtf_tasks_b
7151            WHERE task_id = l_source_task_id;
7152         EXCEPTION
7153           WHEN NO_DATA_FOUND THEN
7154             x_return_status  := fnd_api.g_ret_sts_unexp_error;
7155             fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_ID');
7156             fnd_message.set_token('P_TASK_ID', l_source_task_id);
7157             fnd_msg_pub.ADD;
7158             RAISE fnd_api.g_exc_unexpected_error;
7159           WHEN OTHERS THEN
7160             fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
7161             fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
7162             x_return_status  := fnd_api.g_ret_sts_unexp_error;
7163             fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7164             RAISE fnd_api.g_exc_unexpected_error;
7165         END;
7166 
7167         IF l_recurrence_rule_id IS NOT NULL THEN
7168           x_return_status  := fnd_api.g_ret_sts_unexp_error;
7169 
7170           FOR recurs IN c_recurs LOOP
7171             jtf_task_recurrences_pvt.create_task_recurrence(
7172               p_api_version                => 1.0
7173             , p_init_msg_list              => fnd_api.g_false
7174             , p_commit                     => fnd_api.g_false
7175             , p_task_id                    => l_target_task_id
7176             , p_occurs_which               => recurs.occurs_which
7177             , p_day_of_week                => recurs.day_of_week
7178             , p_date_of_month              => recurs.date_of_month
7179             , p_occurs_month               => recurs.occurs_month
7180             , p_occurs_uom                 => recurs.occurs_uom
7181             , p_occurs_every               => recurs.occurs_every
7182             , p_occurs_number              => recurs.occurs_number
7183             , p_start_date_active          => recurs.start_date_active
7184             , p_end_date_active            => recurs.end_date_active
7185             , p_template_flag              => jtf_task_utl.g_no
7186             , x_return_status              => x_return_status
7187             , x_msg_count                  => x_msg_count
7188             , x_msg_data                   => x_msg_data
7189             , x_recurrence_rule_id         => l_recurrence_rule_id
7190             , x_task_rec                   => l_task_rec
7191             , x_output_dates_counter       => l_output_dates_counter
7192             );
7193 
7194             IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7195               x_return_status  := fnd_api.g_ret_sts_unexp_error;
7196               RAISE fnd_api.g_exc_unexpected_error;
7197             END IF;
7198           END LOOP;
7199         END IF;
7200       END IF;
7201     END IF;
7202 
7203     ------
7204     ------ Create contacts
7205     ------
7206     IF fnd_api.to_boolean(p_copy_task_contacts) THEN
7207       FOR contacts IN c_contacts LOOP
7208         jtf_task_contacts_pub.create_task_contacts(
7209           p_api_version                => 1.0
7210         , p_init_msg_list              => fnd_api.g_false
7211         , p_commit                     => fnd_api.g_false
7212         , p_task_id                    => l_target_task_id
7213         , p_contact_id                 => contacts.contact_id
7214         , p_contact_type_code          => contacts.contact_type_code
7215         , p_escalation_notify_flag     => contacts.escalation_notify_flag
7216         , p_escalation_requester_flag  => contacts.escalation_requester_flag
7217         , p_primary_flag               => contacts.primary_flag
7218         , x_return_status              => x_return_status
7219         , x_msg_count                  => x_msg_count
7220         , x_msg_data                   => x_msg_data
7221         , x_task_contact_id            => l_task_contact_id
7222         );
7223 
7224         IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7225           x_return_status  := fnd_api.g_ret_sts_unexp_error;
7226           RAISE fnd_api.g_exc_unexpected_error;
7227         END IF;
7228 
7229         ------
7230         ------ Create contact points for each contact
7231         ------
7232         IF fnd_api.to_boolean(p_copy_task_contact_points) THEN
7233           FOR contact_points IN c_contact_points(contacts.task_contact_id) LOOP
7234             jtf_task_phones_pub.create_task_phones(
7235               p_api_version                => 1.0
7236             , p_init_msg_list              => fnd_api.g_false
7237             , p_commit                     => fnd_api.g_false
7238             , p_task_contact_id            => l_task_contact_id
7239             , p_phone_id                   => contact_points.phone_id
7240             , p_primary_flag               => contact_points.primary_flag
7241             , x_return_status              => x_return_status
7242             , x_msg_count                  => x_msg_count
7243             , x_msg_data                   => x_msg_data
7244             , x_task_phone_id              => l_task_phone_id
7245             );
7246 
7247             IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7248               x_return_status  := fnd_api.g_ret_sts_unexp_error;
7249               RAISE fnd_api.g_exc_unexpected_error;
7250             END IF;
7251           END LOOP;
7252         END IF;
7253       END LOOP;
7254     END IF;
7255 
7256     --Added by RDESPOTO, updated by TWAN for fixing bug 3756747
7257     cac_view_util_pvt.create_repeat_collab_details(p_source_task_id, x_task_id);
7258 
7259     IF c_task%ISOPEN THEN
7260       CLOSE c_task;
7261     END IF;
7262 
7263     IF c_depends%ISOPEN THEN
7264       CLOSE c_depends;
7265     END IF;
7266 
7267     IF c_references%ISOPEN THEN
7268       CLOSE c_references;
7269     END IF;
7270 
7271     IF c_dates%ISOPEN THEN
7272       CLOSE c_dates;
7273     END IF;
7274 
7275     IF c_recurs%ISOPEN THEN
7276       CLOSE c_recurs;
7277     END IF;
7278 
7279     IF c_rsc_reqs%ISOPEN THEN
7280       CLOSE c_rsc_reqs;
7281     END IF;
7282 
7283     IF c_assignments%ISOPEN THEN
7284       CLOSE c_assignments;
7285     END IF;
7286 
7287     IF c1_assignments%ISOPEN THEN
7288       CLOSE c1_assignments;
7289     END IF;
7290 
7291     IF c_contacts%ISOPEN THEN
7292       CLOSE c_contacts;
7293     END IF;
7294 
7295     IF c_notes%ISOPEN THEN
7296       CLOSE c_notes;
7297     END IF;
7298 
7299     IF fnd_api.to_boolean(p_commit) THEN
7300       COMMIT WORK;
7301     END IF;
7302 
7303     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7304   EXCEPTION
7305     WHEN fnd_api.g_exc_unexpected_error THEN
7306       ROLLBACK TO copy_task;
7307       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7308       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7309 
7310       IF c_task%ISOPEN THEN
7311         CLOSE c_task;
7312       END IF;
7313 
7314       IF c_depends%ISOPEN THEN
7315         CLOSE c_depends;
7316       END IF;
7317 
7318       IF c_references%ISOPEN THEN
7319         CLOSE c_references;
7320       END IF;
7321 
7322       IF c_dates%ISOPEN THEN
7323         CLOSE c_dates;
7324       END IF;
7325 
7326       IF c_recurs%ISOPEN THEN
7327         CLOSE c_recurs;
7328       END IF;
7329 
7330       IF c_rsc_reqs%ISOPEN THEN
7331         CLOSE c_rsc_reqs;
7332       END IF;
7333 
7334       IF c_assignments%ISOPEN THEN
7335         CLOSE c_assignments;
7336       END IF;
7337 
7338       IF c1_assignments%ISOPEN THEN
7339         CLOSE c1_assignments;
7340       END IF;
7341 
7342       IF c_contacts%ISOPEN THEN
7343         CLOSE c_contacts;
7344       END IF;
7345 
7346       IF c_notes%ISOPEN THEN
7347         CLOSE c_notes;
7348       END IF;
7349     WHEN OTHERS THEN
7350       ROLLBACK TO copy_task;
7351       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
7352       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
7353       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7354       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7355 
7356       IF c_task%ISOPEN THEN
7357         CLOSE c_task;
7358       END IF;
7359 
7360       IF c_depends%ISOPEN THEN
7361         CLOSE c_depends;
7362       END IF;
7363 
7364       IF c_references%ISOPEN THEN
7365         CLOSE c_references;
7366       END IF;
7367 
7368       IF c_dates%ISOPEN THEN
7369         CLOSE c_dates;
7370       END IF;
7371 
7372       IF c_recurs%ISOPEN THEN
7373         CLOSE c_recurs;
7374       END IF;
7375 
7376       IF c_rsc_reqs%ISOPEN THEN
7377         CLOSE c_rsc_reqs;
7378       END IF;
7379 
7380       IF c_assignments%ISOPEN THEN
7381         CLOSE c_assignments;
7382       END IF;
7383 
7384       IF c1_assignments%ISOPEN THEN
7385         CLOSE c1_assignments;
7386       END IF;
7387 
7388       IF c_contacts%ISOPEN THEN
7389         CLOSE c_contacts;
7390       END IF;
7391 
7392       IF c_notes%ISOPEN THEN
7393         CLOSE c_notes;
7394       END IF;
7395   END copy_task;
7396 
7397   -- Temp Enh. Refactoring Template Code in create_task_from_template proc....
7398   PROCEDURE create_task_from_template(
7399     p_api_version              IN            NUMBER
7400   , p_init_msg_list            IN            VARCHAR2 DEFAULT fnd_api.g_false
7401   , p_commit                   IN            VARCHAR2 DEFAULT fnd_api.g_false
7402   , p_task_template_group_id   IN            NUMBER DEFAULT NULL
7403   , p_task_template_group_name IN            VARCHAR2 DEFAULT NULL
7404   , p_owner_type_code          IN            VARCHAR2 DEFAULT NULL
7405   , p_owner_id                 IN            NUMBER DEFAULT NULL
7406   , p_source_object_id         IN            NUMBER DEFAULT NULL
7407   , p_source_object_name       IN            VARCHAR2 DEFAULT NULL
7408   , x_return_status            OUT NOCOPY    VARCHAR2
7409   , x_msg_count                OUT NOCOPY    NUMBER
7410   , x_msg_data                 OUT NOCOPY    VARCHAR2
7411   , x_task_details_tbl         OUT NOCOPY    task_details_tbl
7412   , p_assigned_by_id           IN            NUMBER DEFAULT NULL
7413   , p_cust_account_id          IN            NUMBER DEFAULT NULL
7414   , p_customer_id              IN            NUMBER DEFAULT NULL
7415   , p_address_id               IN            NUMBER DEFAULT NULL
7416   , p_actual_start_date        IN            DATE DEFAULT NULL
7417   , p_actual_end_date          IN            DATE DEFAULT NULL
7418   , p_planned_start_date       IN            DATE DEFAULT NULL
7419   , p_planned_end_date         IN            DATE DEFAULT NULL
7420   , p_scheduled_start_date     IN            DATE DEFAULT NULL
7421   , p_scheduled_end_date       IN            DATE DEFAULT NULL
7422   , p_palm_flag                IN            VARCHAR2 DEFAULT NULL
7423   , p_wince_flag               IN            VARCHAR2 DEFAULT NULL
7424   , p_laptop_flag              IN            VARCHAR2 DEFAULT NULL
7425   , p_device1_flag             IN            VARCHAR2 DEFAULT NULL
7426   , p_device2_flag             IN            VARCHAR2 DEFAULT NULL
7427   , p_device3_flag             IN            VARCHAR2 DEFAULT NULL
7428   , p_parent_task_id           IN            NUMBER DEFAULT NULL
7429   , p_percentage_complete      IN            NUMBER DEFAULT NULL
7430   , p_timezone_id              IN            NUMBER DEFAULT NULL
7431   , p_actual_effort            IN            NUMBER DEFAULT NULL
7432   , p_actual_effort_uom        IN            VARCHAR2 DEFAULT NULL
7433   , p_reason_code              IN            VARCHAR2 DEFAULT NULL
7434   , p_bound_mode_code          IN            VARCHAR2 DEFAULT NULL
7435   , p_soft_bound_flag          IN            VARCHAR2 DEFAULT NULL
7436   , p_workflow_process_id      IN            NUMBER DEFAULT NULL
7437   , p_owner_territory_id       IN            NUMBER DEFAULT NULL
7438   , p_costs                    IN            NUMBER DEFAULT NULL
7439   , p_currency_code            IN            VARCHAR2 DEFAULT NULL
7440   , p_attribute1               IN            VARCHAR2 DEFAULT NULL
7441   , p_attribute2               IN            VARCHAR2 DEFAULT NULL
7442   , p_attribute3               IN            VARCHAR2 DEFAULT NULL
7443   , p_attribute4               IN            VARCHAR2 DEFAULT NULL
7444   , p_attribute5               IN            VARCHAR2 DEFAULT NULL
7445   , p_attribute6               IN            VARCHAR2 DEFAULT NULL
7446   , p_attribute7               IN            VARCHAR2 DEFAULT NULL
7447   , p_attribute8               IN            VARCHAR2 DEFAULT NULL
7448   , p_attribute9               IN            VARCHAR2 DEFAULT NULL
7449   , p_attribute10              IN            VARCHAR2 DEFAULT NULL
7450   , p_attribute11              IN            VARCHAR2 DEFAULT NULL
7451   , p_attribute12              IN            VARCHAR2 DEFAULT NULL
7452   , p_attribute13              IN            VARCHAR2 DEFAULT NULL
7453   , p_attribute14              IN            VARCHAR2 DEFAULT NULL
7454   , p_attribute15              IN            VARCHAR2 DEFAULT NULL
7455   , p_attribute_category       IN            VARCHAR2 DEFAULT NULL
7456   , p_date_selected            IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
7457   ) IS
7458     l_api_version CONSTANT NUMBER       := 1.0;
7459     l_api_name    CONSTANT VARCHAR2(30) := 'CREATE_TASK_FROM_TEMPLATE';
7460   BEGIN
7461     SAVEPOINT create_task_from_template_pub1;
7462     x_return_status  := fnd_api.g_ret_sts_success;
7463 
7464     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
7465       RAISE fnd_api.g_exc_unexpected_error;
7466     END IF;
7467 
7468     IF fnd_api.to_boolean(p_init_msg_list) THEN
7469       fnd_msg_pub.initialize;
7470     END IF;
7471 
7472     -- call new version, passing defaults for new functionality
7473     create_task_from_template(
7474       p_api_version                => p_api_version
7475     , p_init_msg_list              => p_init_msg_list
7476     , p_commit                     => fnd_api.g_false
7477     , p_task_template_group_id     => p_task_template_group_id
7478     , p_task_template_group_name   => p_task_template_group_name
7479     , p_owner_type_code            => p_owner_type_code
7480     , p_owner_id                   => p_owner_id
7481     , p_source_object_id           => p_source_object_id
7482     , p_source_object_name         => p_source_object_name
7483     , x_return_status              => x_return_status
7484     , x_msg_count                  => x_msg_count
7485     , x_msg_data                   => x_msg_data
7486     , x_task_details_tbl           => x_task_details_tbl
7487     , p_assigned_by_id             => p_assigned_by_id
7488     , p_cust_account_id            => p_cust_account_id
7489     , p_customer_id                => p_customer_id
7490     , p_address_id                 => p_address_id
7491     , p_actual_start_date          => p_actual_start_date
7492     , p_actual_end_date            => p_actual_end_date
7493     , p_planned_start_date         => p_planned_start_date
7494     , p_planned_end_date           => p_planned_end_date
7495     , p_scheduled_start_date       => p_scheduled_start_date
7496     , p_scheduled_end_date         => p_scheduled_end_date
7497     , p_palm_flag                  => p_palm_flag
7498     , p_wince_flag                 => p_wince_flag
7499     , p_laptop_flag                => p_laptop_flag
7500     , p_device1_flag               => p_device1_flag
7501     , p_device2_flag               => p_device2_flag
7502     , p_device3_flag               => p_device3_flag
7503     , p_parent_task_id             => p_parent_task_id
7504     , p_percentage_complete        => p_percentage_complete
7505     , p_timezone_id                => p_timezone_id
7506     , p_actual_effort              => p_actual_effort
7507     , p_actual_effort_uom          => p_actual_effort_uom
7508     , p_reason_code                => p_reason_code
7509     , p_bound_mode_code            => p_bound_mode_code
7510     , p_soft_bound_flag            => p_soft_bound_flag
7511     , p_workflow_process_id        => p_workflow_process_id
7512     , p_owner_territory_id         => p_owner_territory_id
7513     , p_costs                      => p_costs
7514     , p_currency_code              => p_currency_code
7515     , p_attribute1                 => p_attribute1
7516     , p_attribute2                 => p_attribute2
7517     , p_attribute3                 => p_attribute3
7518     , p_attribute4                 => p_attribute4
7519     , p_attribute5                 => p_attribute5
7520     , p_attribute6                 => p_attribute6
7521     , p_attribute7                 => p_attribute7
7522     , p_attribute8                 => p_attribute8
7523     , p_attribute9                 => p_attribute9
7524     , p_attribute10                => p_attribute10
7525     , p_attribute11                => p_attribute11
7526     , p_attribute12                => p_attribute12
7527     , p_attribute13                => p_attribute13
7528     , p_attribute14                => p_attribute14
7529     , p_attribute15                => p_attribute15
7530     , p_attribute_category         => p_attribute_category
7531     , p_date_selected              => p_date_selected
7532     , p_location_id                => NULL
7533     );
7534 
7535     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7536       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7537       RAISE fnd_api.g_exc_unexpected_error;
7538     END IF;
7539 
7540     IF fnd_api.to_boolean(p_commit) THEN
7541       COMMIT WORK;
7542     END IF;
7543 
7544     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7545   EXCEPTION
7546     WHEN fnd_api.g_exc_unexpected_error THEN
7547       ROLLBACK TO create_task_from_template_pub1;
7548       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7549       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7550     WHEN OTHERS THEN
7551       ROLLBACK TO create_task_from_template_pub1;
7552       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
7553       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
7554       fnd_msg_pub.ADD;
7555       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7556       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7557   END;
7558 
7559   -- New Version...
7560   PROCEDURE create_task_from_template(
7561     p_api_version              IN            NUMBER
7562   , p_init_msg_list            IN            VARCHAR2 DEFAULT fnd_api.g_false
7563   , p_commit                   IN            VARCHAR2 DEFAULT fnd_api.g_false
7564   , p_task_template_group_id   IN            NUMBER DEFAULT NULL
7565   , p_task_template_group_name IN            VARCHAR2 DEFAULT NULL
7566   , p_owner_type_code          IN            VARCHAR2 DEFAULT NULL
7567   , p_owner_id                 IN            NUMBER DEFAULT NULL
7568   , p_source_object_id         IN            NUMBER DEFAULT NULL
7569   , p_source_object_name       IN            VARCHAR2 DEFAULT NULL
7570   , x_return_status            OUT NOCOPY    VARCHAR2
7571   , x_msg_count                OUT NOCOPY    NUMBER
7572   , x_msg_data                 OUT NOCOPY    VARCHAR2
7573   , x_task_details_tbl         OUT NOCOPY    task_details_tbl
7574   , p_assigned_by_id           IN            NUMBER DEFAULT NULL
7575   , p_cust_account_id          IN            NUMBER DEFAULT NULL
7576   , p_customer_id              IN            NUMBER DEFAULT NULL
7577   , p_address_id               IN            NUMBER DEFAULT NULL
7578   , p_actual_start_date        IN            DATE DEFAULT NULL
7579   , p_actual_end_date          IN            DATE DEFAULT NULL
7580   , p_planned_start_date       IN            DATE DEFAULT NULL
7581   , p_planned_end_date         IN            DATE DEFAULT NULL
7582   , p_scheduled_start_date     IN            DATE DEFAULT NULL
7583   , p_scheduled_end_date       IN            DATE DEFAULT NULL
7584   , p_palm_flag                IN            VARCHAR2 DEFAULT NULL
7585   , p_wince_flag               IN            VARCHAR2 DEFAULT NULL
7586   , p_laptop_flag              IN            VARCHAR2 DEFAULT NULL
7587   , p_device1_flag             IN            VARCHAR2 DEFAULT NULL
7588   , p_device2_flag             IN            VARCHAR2 DEFAULT NULL
7589   , p_device3_flag             IN            VARCHAR2 DEFAULT NULL
7590   , p_parent_task_id           IN            NUMBER DEFAULT NULL
7591   , p_percentage_complete      IN            NUMBER DEFAULT NULL
7592   , p_timezone_id              IN            NUMBER DEFAULT NULL
7593   , p_actual_effort            IN            NUMBER DEFAULT NULL
7594   , p_actual_effort_uom        IN            VARCHAR2 DEFAULT NULL
7595   , p_reason_code              IN            VARCHAR2 DEFAULT NULL
7596   , p_bound_mode_code          IN            VARCHAR2 DEFAULT NULL
7597   , p_soft_bound_flag          IN            VARCHAR2 DEFAULT NULL
7598   , p_workflow_process_id      IN            NUMBER DEFAULT NULL
7599   , p_owner_territory_id       IN            NUMBER DEFAULT NULL
7600   , p_costs                    IN            NUMBER DEFAULT NULL
7601   , p_currency_code            IN            VARCHAR2 DEFAULT NULL
7602   , p_attribute1               IN            VARCHAR2 DEFAULT NULL
7603   , p_attribute2               IN            VARCHAR2 DEFAULT NULL
7604   , p_attribute3               IN            VARCHAR2 DEFAULT NULL
7605   , p_attribute4               IN            VARCHAR2 DEFAULT NULL
7606   , p_attribute5               IN            VARCHAR2 DEFAULT NULL
7607   , p_attribute6               IN            VARCHAR2 DEFAULT NULL
7608   , p_attribute7               IN            VARCHAR2 DEFAULT NULL
7609   , p_attribute8               IN            VARCHAR2 DEFAULT NULL
7610   , p_attribute9               IN            VARCHAR2 DEFAULT NULL
7611   , p_attribute10              IN            VARCHAR2 DEFAULT NULL
7612   , p_attribute11              IN            VARCHAR2 DEFAULT NULL
7613   , p_attribute12              IN            VARCHAR2 DEFAULT NULL
7614   , p_attribute13              IN            VARCHAR2 DEFAULT NULL
7615   , p_attribute14              IN            VARCHAR2 DEFAULT NULL
7616   , p_attribute15              IN            VARCHAR2 DEFAULT NULL
7617   , p_attribute_category       IN            VARCHAR2 DEFAULT NULL
7618   , p_date_selected            IN            VARCHAR2 DEFAULT jtf_task_utl.g_miss_char
7619   , p_location_id              IN            NUMBER
7620   ) IS
7621     l_api_version     CONSTANT NUMBER                                               := 1.0;
7622     l_api_name        CONSTANT VARCHAR2(30)                          := 'CREATE_TASK_FROM_TEMPLATE';
7623     l_task_template_group_info jtf_task_inst_templates_pub.task_template_group_info;
7624     l_task_template_info_tbl   jtf_task_inst_templates_pub.task_template_info_tbl;
7625     l_task_contact_points_tbl  jtf_task_inst_templates_pub.task_contact_points_tbl;
7626     g_task_details_tbl         jtf_task_inst_templates_pub.task_details_tbl;
7627   BEGIN
7628     SAVEPOINT create_task_from_template_pub;   -- Fix Bug 2896377
7629     x_return_status                                    := fnd_api.g_ret_sts_success;
7630 
7631     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
7632       RAISE fnd_api.g_exc_unexpected_error;
7633     END IF;
7634 
7635     IF fnd_api.to_boolean(p_init_msg_list) THEN
7636       fnd_msg_pub.initialize;
7637     END IF;
7638 
7639     l_task_template_group_info.task_template_group_id  := p_task_template_group_id;
7640     l_task_template_group_info.owner_type_code         := p_owner_type_code;
7641     l_task_template_group_info.owner_id                := p_owner_id;
7642     l_task_template_group_info.source_object_id        := p_source_object_id;
7643     l_task_template_group_info.source_object_name      := p_source_object_name;
7644     l_task_template_group_info.assigned_by_id          := p_assigned_by_id;
7645     l_task_template_group_info.cust_account_id         := p_cust_account_id;
7646     l_task_template_group_info.customer_id             := p_customer_id;
7647     l_task_template_group_info.address_id              := p_address_id;
7648     l_task_template_group_info.location_id             := p_location_id;
7649     l_task_template_group_info.actual_start_date       := p_actual_start_date;
7650     l_task_template_group_info.actual_end_date         := p_actual_end_date;
7651     l_task_template_group_info.planned_start_date      := p_planned_start_date;
7652     l_task_template_group_info.planned_end_date        := p_planned_end_date;
7653     l_task_template_group_info.scheduled_start_date    := p_scheduled_start_date;
7654     l_task_template_group_info.scheduled_end_date      := p_scheduled_end_date;
7655     l_task_template_group_info.palm_flag               := p_palm_flag;
7656     l_task_template_group_info.wince_flag              := p_wince_flag;
7657     l_task_template_group_info.laptop_flag             := p_laptop_flag;
7658     l_task_template_group_info.device1_flag            := p_device1_flag;
7659     l_task_template_group_info.device2_flag            := p_device2_flag;
7660     l_task_template_group_info.device3_flag            := p_device3_flag;
7661     l_task_template_group_info.parent_task_id          := p_parent_task_id;
7662     l_task_template_group_info.percentage_complete     := p_percentage_complete;
7663     l_task_template_group_info.timezone_id             := p_timezone_id;
7664     l_task_template_group_info.actual_effort           := p_actual_effort;
7665     l_task_template_group_info.actual_effort_uom       := p_actual_effort_uom;
7666     l_task_template_group_info.reason_code             := p_reason_code;
7667     l_task_template_group_info.bound_mode_code         := p_bound_mode_code;
7668     l_task_template_group_info.soft_bound_flag         := p_soft_bound_flag;
7669     l_task_template_group_info.workflow_process_id     := p_workflow_process_id;
7670     l_task_template_group_info.owner_territory_id      := p_owner_territory_id;
7671     l_task_template_group_info.costs                   := p_costs;
7672     l_task_template_group_info.currency_code           := p_currency_code;
7673     l_task_template_group_info.attribute1              := p_attribute1;
7674     l_task_template_group_info.attribute2              := p_attribute2;
7675     l_task_template_group_info.attribute3              := p_attribute3;
7676     l_task_template_group_info.attribute4              := p_attribute4;
7677     l_task_template_group_info.attribute5              := p_attribute5;
7678     l_task_template_group_info.attribute6              := p_attribute6;
7679     l_task_template_group_info.attribute7              := p_attribute7;
7680     l_task_template_group_info.attribute8              := p_attribute8;
7681     l_task_template_group_info.attribute9              := p_attribute9;
7682     l_task_template_group_info.attribute10             := p_attribute10;
7683     l_task_template_group_info.attribute11             := p_attribute11;
7684     l_task_template_group_info.attribute12             := p_attribute12;
7685     l_task_template_group_info.attribute13             := p_attribute13;
7686     l_task_template_group_info.attribute14             := p_attribute14;
7687     l_task_template_group_info.attribute15             := p_attribute15;
7688     l_task_template_group_info.attribute_category      := p_attribute_category;
7689     l_task_template_group_info.date_selected           := p_date_selected;
7690     jtf_task_inst_templates_pub.create_task_from_template
7691                                           (
7692       p_api_version                => p_api_version
7693     , p_init_msg_list              => p_init_msg_list
7694     , p_commit                     => p_commit
7695     , p_task_template_group_info   => l_task_template_group_info
7696     , p_task_templates_tbl         => l_task_template_info_tbl
7697     , p_task_contact_points_tbl    => l_task_contact_points_tbl
7698     , x_return_status              => x_return_status
7699     , x_msg_count                  => x_msg_count
7700     , x_msg_data                   => x_msg_data
7701     , x_task_details_tbl           => g_task_details_tbl
7702     );
7703 
7704     FOR i IN 1 .. g_task_details_tbl.COUNT LOOP
7705       x_task_details_tbl(i).task_id           := g_task_details_tbl(i).task_id;
7706       x_task_details_tbl(i).task_template_id  := g_task_details_tbl(i).task_template_id;
7707       NULL;
7708     END LOOP;
7709 
7710     IF fnd_api.to_boolean(p_commit) THEN
7711       COMMIT WORK;
7712     END IF;
7713 
7714     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7715   EXCEPTION
7716     WHEN fnd_api.g_exc_unexpected_error THEN
7717       ROLLBACK TO create_task_from_template_pub;   -- Fix Bug 2896377
7718       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7719       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7720     WHEN OTHERS THEN
7721       ROLLBACK TO create_task_from_template_pub;   -- Fix Bug 2896377
7722       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
7723       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
7724       fnd_msg_pub.ADD;
7725       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7726       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7727   END;
7728 
7729   PROCEDURE lock_task(
7730     p_api_version           IN            NUMBER
7731   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
7732   , p_commit                IN            VARCHAR2 DEFAULT fnd_api.g_false
7733   , p_task_id               IN            NUMBER
7734   , p_object_version_number IN            NUMBER
7735   , x_return_status         OUT NOCOPY    VARCHAR2
7736   , x_msg_data              OUT NOCOPY    VARCHAR2
7737   , x_msg_count             OUT NOCOPY    NUMBER
7738   ) IS
7739     l_api_version CONSTANT NUMBER       := 1.0;
7740     l_api_name    CONSTANT VARCHAR2(30) := 'LOCK_TASK';
7741     resource_locked        EXCEPTION;
7742     PRAGMA EXCEPTION_INIT(resource_locked, -54);
7743   BEGIN
7744     SAVEPOINT lock_tasks_pub;
7745     x_return_status  := fnd_api.g_ret_sts_success;
7746 
7747     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
7748       RAISE fnd_api.g_exc_unexpected_error;
7749     END IF;
7750 
7751     IF fnd_api.to_boolean(p_init_msg_list) THEN
7752       fnd_msg_pub.initialize;
7753     END IF;
7754 
7755     x_return_status  := fnd_api.g_ret_sts_success;
7756     jtf_tasks_pkg.lock_row(x_task_id => p_task_id
7757     , x_object_version_number      => p_object_version_number);
7758     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7759   EXCEPTION
7760     WHEN resource_locked THEN
7761       ROLLBACK TO lock_tasks_pub;
7762       fnd_message.set_name('JTF', 'JTF_TASK_RESOURCE_LOCKED');
7763       fnd_message.set_token('P_LOCKED_RESOURCE', 'Task');
7764       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7765       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7766     WHEN fnd_api.g_exc_unexpected_error THEN
7767       ROLLBACK TO lock_tasks_pub;
7768       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7769       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7770     WHEN OTHERS THEN
7771       ROLLBACK TO lock_tasks_pub;
7772       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
7773       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
7774       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7775       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7776   END;
7777 
7778   ------
7779   ------ This procedure updates the Task record with the source object
7780   ------ details.  In the update_task API the source object details are
7781   ------ not allowed to be udpated.
7782   ------
7783   PROCEDURE update_task_source(
7784     p_api_version             IN            NUMBER
7785   , p_init_msg_list           IN            VARCHAR2 DEFAULT fnd_api.g_false
7786   , p_commit                  IN            VARCHAR2 DEFAULT fnd_api.g_false
7787   , p_object_version_number   IN OUT NOCOPY NUMBER
7788   , p_task_id                 IN            NUMBER
7789   , p_source_object_type_code IN            VARCHAR2 DEFAULT NULL
7790   , p_source_object_id        IN            NUMBER DEFAULT NULL
7791   , p_source_object_name      IN            VARCHAR2 DEFAULT NULL
7792   , x_return_status           OUT NOCOPY    VARCHAR2
7793   , x_msg_count               OUT NOCOPY    NUMBER
7794   , x_msg_data                OUT NOCOPY    VARCHAR2
7795   ) IS
7796     l_api_version CONSTANT NUMBER                                := 1.0;
7797     l_api_name    CONSTANT VARCHAR2(30)                          := 'UPDATE_TASK_SOURCE';
7798     l_task_id              NUMBER;
7799     l_source_object_name   jtf_tasks_b.source_object_name%TYPE;
7800   BEGIN
7801     SAVEPOINT update_task_source;
7802     x_return_status          := fnd_api.g_ret_sts_success;
7803 
7804     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
7805       RAISE fnd_api.g_exc_unexpected_error;
7806     END IF;
7807 
7808     IF fnd_api.to_boolean(p_init_msg_list) THEN
7809       fnd_msg_pub.initialize;
7810     END IF;
7811 
7812     -------
7813     ------- Check for truncation of source object name
7814     -------
7815     l_source_object_name     := jtf_task_utl.check_truncation(p_object_name => p_source_object_name);
7816     -------
7817     ------- Validate source object details
7818     -------
7819     jtf_task_utl.validate_source_object(
7820       p_object_code                => p_source_object_type_code
7821     , p_object_id                  => p_source_object_id
7822     , p_object_name                => l_source_object_name
7823     , x_return_status              => x_return_status
7824     );
7825 
7826     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7827       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7828       RAISE fnd_api.g_exc_unexpected_error;
7829     END IF;
7830 
7831     ------
7832     ------ Update the Task record with the source object details
7833     ------
7834     jtf_tasks_pub.lock_task(
7835       p_api_version                => 1.0
7836     , p_init_msg_list              => fnd_api.g_false
7837     , p_commit                     => fnd_api.g_false
7838     , p_task_id                    => p_task_id
7839     , p_object_version_number      => p_object_version_number
7840     , x_return_status              => x_return_status
7841     , x_msg_data                   => x_msg_data
7842     , x_msg_count                  => x_msg_count
7843     );
7844 
7845     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7846       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7847       RAISE fnd_api.g_exc_unexpected_error;
7848     END IF;
7849 
7850     p_object_version_number  := p_object_version_number + 1;
7851 
7852     /*    jtf_tasks_pkg.update_row (
7853           x_task_id => p_task_id,
7854           x_object_version_number => p_object_version_number,
7855           x_source_object_type_code => l_source_object_type_code,
7856           x_source_object_id => l_source_object_id,
7857           x_source_object_name => l_source_object_name,
7858           x_last_update_date => SYSDATE,
7859           x_last_updated_by => jtf_task_utl.updated_by,
7860           x_last_update_login => jtf_task_utl.login_id,
7861       );
7862     */
7863     IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
7864       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7865       RAISE fnd_api.g_exc_unexpected_error;
7866     END IF;
7867 
7868     IF fnd_api.to_boolean(p_commit) THEN
7869       COMMIT WORK;
7870     END IF;
7871 
7872     fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7873   EXCEPTION
7874     WHEN fnd_api.g_exc_unexpected_error THEN
7875       ROLLBACK TO update_task_source;
7876       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7877       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7878     WHEN OTHERS THEN
7879       ROLLBACK TO update_task_source;
7880       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
7881       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
7882       x_return_status  := fnd_api.g_ret_sts_unexp_error;
7883       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
7884   END;
7885 
7886   -- Function to check parameter length and throw error if length not in allowed limit bug # 3182170 Start
7887   FUNCTION check_param_length(
7888     p_task_name    IN VARCHAR2
7889   , p_message_name IN VARCHAR2 DEFAULT NULL
7890   , p_length       IN NUMBER DEFAULT 80
7891   )
7892     RETURN VARCHAR2 IS
7893   BEGIN
7894     IF LENGTH(p_task_name) > p_length THEN
7895       fnd_message.set_name('JTF', p_message_name);
7896       fnd_msg_pub.ADD;
7897       RAISE fnd_api.g_exc_unexpected_error;
7898     ELSE
7899       RETURN p_task_name;
7900     END IF;
7901   END;
7902 
7903   -- Function to check parameter length and throw error if length not in allowed limit bug # 3182170 End
7904   PROCEDURE delete_split_tasks(
7905     p_api_version           IN            NUMBER
7906   , p_init_msg_list         IN            VARCHAR2 DEFAULT fnd_api.g_false
7907   , p_commit                IN            VARCHAR2 DEFAULT fnd_api.g_false
7908   , p_object_version_number IN            NUMBER
7909   , p_task_id               IN            NUMBER DEFAULT NULL
7910   , p_task_split_flag       IN            VARCHAR2 DEFAULT NULL
7911   , p_try_to_reconnect_flag IN            VARCHAR2 DEFAULT 'N'
7912   , p_template_flag         IN            VARCHAR2 DEFAULT 'N'
7913   , x_return_status         OUT NOCOPY    VARCHAR2
7914   , x_msg_count             OUT NOCOPY    NUMBER
7915   , x_msg_data              OUT NOCOPY    VARCHAR2
7916   ) IS
7917     CURSOR c_task_info(i_task_id jtf_tasks_b.task_id%TYPE) IS
7918       SELECT a.task_id
7919            , b.object_version_number
7920         FROM jtf_task_depends a, jtf_tasks_b b
7921        WHERE a.task_id = i_task_id AND a.task_id = b.task_id
7922              AND b.task_split_flag = p_task_split_flag;
7923 
7924     -- Cursor for finding all the tasks depend on the master task
7925     CURSOR c_mass_tasks_info IS
7926       SELECT     task_id
7927                , dependent_on_task_id
7928             FROM jtf_task_depends
7929       START WITH dependent_on_task_id = p_task_id
7930       CONNECT BY PRIOR task_id = dependent_on_task_id;
7931 
7932     -- changed the parameter name by SBARAT on 19/01/2006 for bug# 4888496
7933     CURSOR c_task_validate(p_task_id jtf_tasks_b.task_id%TYPE) IS
7934       SELECT object_version_number
7935            , task_split_flag
7936         FROM jtf_tasks_b
7937        WHERE task_id = p_task_id;
7938 
7939     l_api_version      CONSTANT NUMBER                      := 1.0;
7940     l_api_name         CONSTANT VARCHAR2(30)                := 'DELETE_SPLIT_TASKS';
7941     p_delete_future_recurrences VARCHAR2(1)                 := 'S';
7942     l_return_status             VARCHAR2(1)                 := fnd_api.g_ret_sts_success;
7943     l_msg_data                  VARCHAR2(2000);
7944     l_msg_count                 NUMBER;
7945     l_ovn                       NUMBER;
7946     l_task_info                 c_task_info%ROWTYPE;
7947     l_mass_tasks_info           c_mass_tasks_info%ROWTYPE;
7948     l_task_id                   jtf_tasks_b.task_id%TYPE;
7949     task_val                    c_task_validate%ROWTYPE;
7950   BEGIN
7951     SAVEPOINT delete_split_tasks_pub;
7952     x_return_status  := fnd_api.g_ret_sts_success;
7953 
7954     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
7955       RAISE fnd_api.g_exc_unexpected_error;
7956     END IF;
7957 
7958     IF fnd_api.to_boolean(p_init_msg_list) THEN
7959       fnd_msg_pub.initialize;
7960     END IF;
7961 
7962     OPEN c_task_validate(p_task_id);
7963 
7964     FETCH c_task_validate
7965      INTO task_val;
7966 
7967     IF c_task_validate%NOTFOUND THEN
7968       fnd_message.set_name('JTF', 'JTF_TASK_INVALID_TASK_ID');
7969       fnd_message.set_token('P_TASK_ID', p_task_id);
7970       fnd_msg_pub.ADD;
7971       RAISE fnd_api.g_exc_unexpected_error;
7972     END IF;
7973 
7974     CLOSE c_task_validate;
7975 
7976     IF (p_task_split_flag IS NULL) THEN
7977       fnd_message.set_name('JTF', 'JTF_TASK_SPLIT_FLAG_NULL');
7978       fnd_msg_pub.ADD;
7979       RAISE fnd_api.g_exc_unexpected_error;
7980     END IF;
7981 
7982     IF (task_val.task_split_flag IS NULL) THEN
7983       fnd_message.set_name('JTF', 'JTF_TASK_SPLIT_FLAG_NOT_EXIST');
7984       fnd_msg_pub.ADD;
7985       RAISE fnd_api.g_exc_unexpected_error;
7986     END IF;
7987 
7988     IF (task_val.task_split_flag <> 'D' OR task_val.task_split_flag <> 'M') THEN
7989       fnd_message.set_name('JTF', 'JTF_TASK_SPLIT_FLAG_NOT_VALID');
7990       fnd_message.set_token('P_TASK_ID', p_task_id);
7991       fnd_message.set_token('P_TASK_SPLIT_FLAG', task_val.task_split_flag);
7992       fnd_msg_pub.ADD;
7993       RAISE fnd_api.g_exc_unexpected_error;
7994     END IF;
7995 
7996     IF (task_val.task_split_flag <> p_task_split_flag) THEN
7997       fnd_message.set_name('JTF', 'JTF_TASK_INVALID_SPLIT_FLAG');
7998       fnd_message.set_token('P_TASK_SPLIT_FLAG', p_task_split_flag);
7999       fnd_message.set_token('P_TASK_ID', p_task_id);
8000       fnd_msg_pub.ADD;
8001       RAISE fnd_api.g_exc_unexpected_error;
8002     END IF;
8003 
8004     IF (p_task_split_flag = 'D') THEN
8005       -- find all the tasks depend on the specific task
8006       OPEN c_task_info(p_task_id);
8007 
8008       FETCH c_task_info
8009        INTO l_task_info;
8010 
8011       IF c_task_info%NOTFOUND THEN
8012         RETURN;
8013       END IF;
8014 
8015       CLOSE c_task_info;
8016 
8017       -- if try_to_reconnect_flag is 'Y', reconnect dependencies then delete task.
8018       -- if try_to_reconnect_flag is 'N', just delete task.
8019       IF (p_try_to_reconnect_flag = 'Y') THEN
8020         jtf_task_dependency_pvt.reconnect_dependency(
8021           p_api_version                => 1.0
8022         , p_init_msg_list              => fnd_api.g_false
8023         , p_commit                     => fnd_api.g_false
8024         , p_task_id                    => l_task_info.task_id
8025         , p_template_flag              => p_template_flag
8026         , x_return_status              => x_return_status
8027         , x_msg_data                   => x_msg_data
8028         , x_msg_count                  => x_msg_count
8029         );
8030       END IF;
8031 
8032       jtf_tasks_pvt.delete_task(
8033         p_api_version                => 1.0
8034       , p_init_msg_list              => fnd_api.g_false
8035       , p_commit                     => fnd_api.g_false
8036       , p_object_version_number      => l_task_info.object_version_number
8037       , p_task_id                    => l_task_info.task_id
8038       , p_delete_future_recurrences  => p_delete_future_recurrences
8039       , x_return_status              => x_return_status
8040       , x_msg_count                  => x_msg_count
8041       , x_msg_data                   => x_msg_data
8042       );
8043     -- if task_split_flag is 'M'
8044     ELSIF(p_task_split_flag = 'M') THEN
8045       FOR l_mass_tasks_info IN c_mass_tasks_info LOOP
8046         OPEN c_task_validate(l_mass_tasks_info.dependent_on_task_id);
8047 
8048         FETCH c_task_validate
8049          INTO task_val;
8050 
8051         CLOSE c_task_validate;
8052 
8053         IF (task_val.object_version_number IS NOT NULL) THEN
8054           jtf_tasks_pvt.delete_task(
8055             p_api_version                => 1.0
8056           , p_init_msg_list              => fnd_api.g_false
8057           , p_commit                     => fnd_api.g_false
8058           , p_object_version_number      => task_val.object_version_number
8059           , p_task_id                    => l_mass_tasks_info.dependent_on_task_id
8060           , x_return_status              => x_return_status
8061           , x_msg_count                  => x_msg_count
8062           , x_msg_data                   => x_msg_data
8063           );
8064 
8065           IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
8066             x_return_status  := fnd_api.g_ret_sts_unexp_error;
8067             RAISE fnd_api.g_exc_unexpected_error;
8068           END IF;
8069         END IF;
8070 
8071         OPEN c_task_validate(l_mass_tasks_info.task_id);
8072 
8073         FETCH c_task_validate
8074          INTO task_val;
8075 
8076         CLOSE c_task_validate;
8077 
8078         IF (task_val.object_version_number IS NOT NULL) THEN
8079           jtf_tasks_pvt.delete_task(
8080             p_api_version                => 1.0
8081           , p_init_msg_list              => fnd_api.g_false
8082           , p_commit                     => fnd_api.g_false
8083           , p_object_version_number      => task_val.object_version_number
8084           , p_task_id                    => l_mass_tasks_info.task_id
8085           , x_return_status              => x_return_status
8086           , x_msg_count                  => x_msg_count
8087           , x_msg_data                   => x_msg_data
8088           );
8089 
8090           IF NOT(x_return_status = fnd_api.g_ret_sts_success) THEN
8091             x_return_status  := fnd_api.g_ret_sts_unexp_error;
8092             RAISE fnd_api.g_exc_unexpected_error;
8093           END IF;
8094         END IF;
8095       END LOOP;
8096 
8097       IF fnd_api.to_boolean(p_commit) THEN
8098         COMMIT WORK;
8099       END IF;
8100 
8101       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
8102     END IF;
8103   EXCEPTION
8104     WHEN fnd_api.g_exc_unexpected_error THEN
8105       ROLLBACK TO delete_split_tasks_pub;
8106       x_return_status  := fnd_api.g_ret_sts_unexp_error;
8107       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
8108     WHEN OTHERS THEN
8109       fnd_message.set_name('JTF', 'JTF_TASK_UNKNOWN_ERROR');
8110       fnd_message.set_token('P_TEXT', SQLCODE || SQLERRM);
8111       fnd_msg_pub.ADD;
8112       ROLLBACK TO delete_split_tasks_pub;
8113       x_return_status  := fnd_api.g_ret_sts_unexp_error;
8114       fnd_msg_pub.count_and_get(p_count => x_msg_count, p_data => x_msg_data);
8115   END;
8116 
8117   PROCEDURE MASS_TASK_UPDATE  (
8118        P_API_VERSION                   IN     NUMBER
8119       ,P_INIT_MSG_LIST                 IN     VARCHAR2
8120       ,P_COMMIT                        IN     VARCHAR2
8121       ,P_TASK_ID_LIST                  IN     JTF_NUMBER_TABLE
8122       ,P_NEW_TASK_STATUS_ID            IN     NUMBER
8123       ,P_NEW_SOURCE_TYPE_CODE          IN     VARCHAR2
8124       ,P_NEW_SOURCE_VALUE              IN     VARCHAR2
8125       ,P_NEW_SOURCE_ID                 IN     VARCHAR2
8126       ,P_NEW_TASK_OWNER_TYPE_CODE      IN     VARCHAR2
8127       ,P_NEW_TASK_OWNER_ID             IN     NUMBER
8128       ,P_NEW_PLANNED_START_DATE        IN     DATE
8129       ,P_NEW_PLANNED_END_DATE          IN     DATE
8130       ,P_NEW_ACTUAL_START_DATE         IN     DATE
8131       ,P_NEW_ACTUAL_END_DATE           IN     DATE
8132       ,P_NEW_SCHEDULED_START_DATE      IN     DATE
8133       ,P_NEW_SCHEDULED_END_DATE        IN     DATE
8134       ,P_NEW_CALENDAR_START_DATE       IN     DATE
8135       ,P_NEW_CALENDAR_END_DATE         IN     DATE
8136       ,P_NOTE_TYPE                     IN     VARCHAR2
8137       ,P_NOTE_STATUS                   IN     VARCHAR2
8138       ,P_NOTE                          IN     VARCHAR2
8139       ,P_REMOVE_ASSIGNMENT_FLAG        IN     VARCHAR2
8140       ,X_RETURN_STATUS                 OUT    NOCOPY VARCHAR2
8141       ,X_MSG_COUNT                     OUT    NOCOPY NUMBER
8142       ,X_MSG_DATA                      OUT    NOCOPY VARCHAR2
8143       ,X_SUCC_TASK_ID_LIST             OUT    NOCOPY JTF_NUMBER_TABLE
8144       ,X_FAILED_TASK_ID_LIST           OUT    NOCOPY JTF_NUMBER_TABLE
8145       ,X_FAILED_REASON_LIST            OUT    NOCOPY JTF_VARCHAR2_TABLE_2000
8146   ) IS
8147     l_task_att_modified_flag number :=1;
8148     l_task_updated number;
8149     l_failed_index number :=1;
8150     l_completed_index number :=1;
8151     l_last_task number:=0;
8152     L_TASK_UPDATE_COMPLTED JTF_NUMBER_TABLE;
8153     l_succ_task_id_list JTF_NUMBER_TABLE := JTF_NUMBER_TABLE();
8154     l_failed_task_id_list JTF_NUMBER_TABLE := JTF_NUMBER_TABLE();
8155     l_failed_reason_list JTF_VARCHAR2_TABLE_2000 := JTF_VARCHAR2_TABLE_2000();
8156     l_return_status VARCHAR2(100);
8157     l_msg_count NUMBER;
8158     l_msg_data VARCHAR2(2000);
8159     l_note_return_status VARCHAR2(100);
8160     l_note_msg_count NUMBER;
8161     l_note_msg_data VARCHAR2(2000);
8162     l_note_id NUMBER;
8163     l_object_version_number number;
8164     l_miss_char VARCHAR2(1) :='';
8165     l_new_task_owner_type_code VARCHAR2(30) :=P_NEW_TASK_OWNER_TYPE_CODE;
8166     l_new_task_owner_id NUMBER :=P_NEW_TASK_OWNER_ID;
8167     l_new_task_status_id NUMBER :=P_NEW_TASK_STATUS_ID;
8168     l_note VARCHAR2(2000) := P_NOTE;
8169     l_update_status NUMBER := 0;
8170     l_date_selected jtf_tasks_b.date_selected%TYPE :='S';
8171     l_planned_start_date DATE :=P_NEW_PLANNED_START_DATE;
8172     l_planned_end_date DATE :=P_NEW_PLANNED_END_DATE;
8173     l_actual_start_date DATE := P_NEW_ACTUAL_START_DATE;
8174     l_actual_end_date DATE := P_NEW_ACTUAL_END_DATE;
8175     l_scheduled_start_date DATE := P_NEW_SCHEDULED_START_DATE;
8176     l_scheduled_end_date DATE :=P_NEW_SCHEDULED_END_DATE;
8177     l_new_planned_start_date DATE ;
8178     l_new_planned_end_date DATE ;
8179     l_new_actual_start_date DATE;
8180     l_new_actual_end_date DATE ;
8181     l_new_scheduled_start_date DATE ;
8182     l_new_scheduled_end_date DATE;
8183     l_task_update_required NUMBER :=1;
8184 
8185     cursor c_task_details(l_task_id IN NUMBER) is
8186       SELECT object_version_number
8187             , task_number
8188             , scheduled_start_date
8189             , scheduled_end_date
8190             , planned_start_date
8191             , planned_end_date
8192             , actual_start_date
8193             , actual_end_date
8194         FROM jtf_tasks_b
8195        WHERE task_id=l_task_id;
8196 
8197     cursor c_Assignment_details(l_task_id IN NUMBER) is
8198       SELECT object_version_number,task_assignment_id
8199         FROM jtf_task_assignments
8200        WHERE task_id=l_task_id;
8201 
8202     task_rec  c_task_details%ROWTYPE;
8203 
8204 
8205   BEGIN
8206       IF l_new_task_owner_id is null THEN
8207         l_new_task_owner_id:=FND_API.G_MISS_NUM;
8208       END IF;
8209 
8210       IF l_new_task_status_id is null THEN
8211         l_new_task_status_id:=FND_API.G_MISS_NUM;
8212       END IF;
8213 
8214       IF l_new_task_owner_type_code IS NULL THEN
8215         l_new_task_owner_type_code:=FND_API.G_MISS_CHAR;
8216       END IF;
8217 
8218       IF l_note IS NULL THEN
8219         l_note:=FND_API.G_MISS_CHAR;
8220       END IF;
8221 
8222 
8223 
8224       l_date_selected:=SUBSTR(fnd_profile.value('JTF_TASK_DEFAULT_DATE_SELECTED'),1,1);
8225       IF (P_NEW_CALENDAR_END_DATE is not null AND P_NEW_CALENDAR_END_DATE <> FND_API.G_MISS_DATE) THEN
8226         if l_date_selected='P' then
8227           l_planned_end_date:=P_NEW_CALENDAR_END_DATE;
8228         elsif l_date_selected='A' then
8229           l_actual_end_date:=P_NEW_CALENDAR_END_DATE;
8230         else
8231           l_scheduled_end_date:=P_NEW_CALENDAR_END_DATE;
8232         end if;
8233       END IF;
8234 
8235       IF (P_NEW_CALENDAR_START_DATE is not null AND P_NEW_CALENDAR_START_DATE <> FND_API.G_MISS_DATE) THEN
8236         if l_date_selected='P' then
8237           l_planned_start_date:=P_NEW_CALENDAR_START_DATE;
8238         elsif l_date_selected='A' then
8239           l_actual_start_date:=P_NEW_CALENDAR_START_DATE;
8240         else
8241           l_scheduled_start_date:=P_NEW_CALENDAR_START_DATE;
8242         end if;
8243       END IF;
8244 
8245       --CHECK IF TASK IS MODIFIED
8246       IF (l_new_task_status_id IS NULL OR l_new_task_status_id = FND_API.G_MISS_NUM)
8247          AND  (l_new_task_owner_id IS NULL OR l_new_task_owner_id = FND_API.G_MISS_NUM )
8248          AND  (l_new_task_owner_type_code IS NULL OR l_new_task_owner_type_code = FND_API.G_MISS_CHAR)
8249          AND  (P_NEW_PLANNED_START_DATE IS NULL OR P_NEW_PLANNED_START_DATE = FND_API.G_MISS_DATE)
8250          AND  (P_NEW_PLANNED_END_DATE IS NULL OR P_NEW_PLANNED_END_DATE = FND_API.G_MISS_DATE)
8251          AND  (P_NEW_ACTUAL_START_DATE IS NULL OR P_NEW_ACTUAL_START_DATE = FND_API.G_MISS_DATE)
8252          AND  (P_NEW_ACTUAL_END_DATE IS NULL OR P_NEW_ACTUAL_END_DATE = FND_API.G_MISS_DATE)
8253          AND  (P_NEW_SCHEDULED_START_DATE IS NULL OR P_NEW_SCHEDULED_START_DATE = FND_API.G_MISS_DATE)
8254          AND  (P_NEW_SCHEDULED_END_DATE IS NULL OR P_NEW_SCHEDULED_END_DATE = FND_API.G_MISS_DATE)
8255          AND  (P_NEW_CALENDAR_START_DATE IS NULL OR P_NEW_CALENDAR_START_DATE = FND_API.G_MISS_DATE)
8256          AND  (P_NEW_CALENDAR_END_DATE IS NULL OR P_NEW_CALENDAR_END_DATE = FND_API.G_MISS_DATE)
8257       THEN
8258         l_task_update_required:=0;
8259       END IF;
8260 
8261       IF( l_task_update_required=1 or P_REMOVE_ASSIGNMENT_FLAG = 'T') THEN
8262           -- task attribute are modifed
8263           -- so we have to call udpate task details
8264           -- otherwise we dont have to update anything just return back from here
8265           --OPEN TASK LOOP
8266           FOR i in 1..P_TASK_ID_LIST.count
8267           LOOP
8268             savepoint mass_task_update;
8269             --update task
8270             l_update_status:=0;
8271             l_return_status:= fnd_api.g_ret_sts_success;
8272             if(l_task_update_required=1) then
8273               l_return_status:= fnd_api.g_ret_sts_unexp_error;
8274               open c_task_details(P_TASK_ID_LIST(i));
8275               fetch c_task_details into task_rec;
8276 
8277               close c_task_details;
8278 
8279               l_new_scheduled_start_date:=l_scheduled_start_date;
8280               l_new_scheduled_end_date:=l_scheduled_end_date;
8281               l_new_actual_start_date:=l_actual_start_date;
8282               l_new_actual_end_date:=l_actual_end_date;
8283               l_new_planned_start_date:=l_planned_start_date;
8284               l_new_planned_end_date:=l_planned_end_date;
8285 
8286               IF (l_new_scheduled_start_date is null OR l_new_scheduled_start_date =FND_API.G_MISS_DATE) THEN
8287                 l_new_scheduled_start_date:=task_rec.scheduled_start_date;
8288               END IF;
8289 
8290               IF (l_new_actual_start_date is null OR l_new_actual_start_date =FND_API.G_MISS_DATE) THEN
8291                 l_new_actual_start_date:=task_rec.actual_start_date;
8292               END IF;
8293 
8294               IF (l_new_planned_start_date is null OR l_new_planned_start_date =FND_API.G_MISS_DATE) THEN
8295                 l_new_planned_start_date:=task_rec.planned_start_date;
8296               END IF;
8297 
8298               IF (l_new_scheduled_end_date is null OR l_new_scheduled_end_date =FND_API.G_MISS_DATE) THEN
8299                 l_new_scheduled_end_date:=task_rec.scheduled_end_date;
8300               END IF;
8301 
8302               IF (l_new_actual_end_date is null OR l_new_actual_end_date =FND_API.G_MISS_DATE) THEN
8303                 l_new_actual_end_date:=task_rec.actual_end_date;
8304               END IF;
8305 
8306               IF (l_new_planned_end_date is null OR l_new_planned_end_date =FND_API.G_MISS_DATE) THEN
8307                 l_new_planned_end_date:=task_rec.planned_end_date;
8308               END IF;
8309 
8310               jtf_tasks_pub.update_task(
8311                 p_api_version => 1.0,
8312                 p_init_msg_list => FND_API.G_TRUE,
8313                 p_commit => FND_API.G_FALSE,
8314                 p_object_version_number =>task_rec.object_version_number,
8315                 p_task_id => P_TASK_ID_LIST(i),
8316                 p_task_status_id => l_new_task_status_id,
8317                 p_owner_type_code => l_new_task_owner_type_code,
8318                 p_owner_id => l_new_task_owner_id,
8319                 p_planned_start_date => l_new_planned_start_date,
8320                 p_planned_end_date	=> l_new_planned_end_date,
8321                 p_scheduled_start_date	=> l_new_scheduled_start_date,
8322                 p_scheduled_end_date	=> l_new_scheduled_end_date,
8323                 p_actual_start_date => l_new_actual_start_date,
8324                 p_actual_end_date => l_new_actual_end_date,
8325                 p_date_selected => l_date_selected,
8326                 p_source_object_type_code => P_NEW_SOURCE_TYPE_CODE,
8327                 p_source_object_id	=> P_NEW_SOURCE_VALUE,
8328                 p_source_object_name => P_NEW_SOURCE_ID,
8329                 x_return_status => l_return_status,
8330                 x_msg_count => l_msg_count,
8331                 x_msg_data	=> l_msg_data
8332                 );
8333             end if; --end if(l_task_update_required=1)
8334             IF (l_return_status = fnd_api.g_ret_sts_success) THEN
8335               IF(P_REMOVE_ASSIGNMENT_FLAG = 'T') THEN
8336                 FOR asg_rec in c_Assignment_details(P_TASK_ID_LIST(i))
8337                 LOOP
8338                   jtf_task_assignments_pub.delete_task_assignment(
8339                   p_api_version => 1.0,
8340                   p_object_version_number => asg_rec.object_version_number,
8341                   p_task_assignment_id => asg_rec.task_assignment_id,
8342                   p_commit => FND_API.G_FALSE,
8343                   x_return_status => l_return_status,
8344                   x_msg_count => l_msg_count,
8345                   x_msg_data	=> l_msg_data);
8346                   IF (l_return_status <> fnd_api.g_ret_sts_success)
8347                   THEN
8348                       l_update_status := 1;
8349                   END IF;
8350                   EXIT when l_update_status = 1;
8351                 END LOOP;
8352                 IF c_Assignment_details%ISOPEN
8353                 THEN
8354                    close c_Assignment_details;
8355                 END IF;
8356               END IF; --end IF(P_REMOVE_ASSIGNMENT_FLAG = 'T')
8357               IF (l_update_status = 0) THEN
8358                 IF ( P_NOTE_TYPE is not null and P_NOTE_TYPE <> FND_API.G_MISS_CHAR)
8359                    OR ( P_NOTE_STATUS is not null and P_NOTE_STATUS <> FND_API.G_MISS_CHAR)
8360                    OR ( P_NOTE is not null and P_NOTE <> FND_API.G_MISS_CHAR)
8361                 THEN
8362                   jtf_notes_pub.create_note(
8363                      p_api_version  =>1.0
8364                    , p_init_msg_list =>'F'
8365                    , p_commit =>'T'
8366                    , x_return_status =>l_note_return_status
8367                    , x_msg_count =>l_note_msg_count
8368                    , x_msg_data => l_note_msg_data
8369                    , p_source_object_id  => p_TASK_ID_LIST(i)
8370                    , p_source_object_code  => 'TASK'
8371                    , p_notes  => l_note
8372                    , p_note_status => p_note_status
8373                    , p_note_type  => p_note_type
8374                    , p_entered_by => FND_GLOBAL.USER_ID
8375                    , p_entered_date => sysdate
8376                    , x_jtf_note_id   => l_note_id
8377                    , p_last_update_date => sysdate
8378                    , p_last_updated_by => FND_GLOBAL.USER_ID
8379                    , p_creation_date => sysdate
8380                    , p_created_by => FND_GLOBAL.USER_ID
8381                    , p_last_update_login => FND_GLOBAL.LOGIN_ID
8382                    );
8383                 END IF; --end note variable check
8384                 IF fnd_api.to_boolean(p_commit) THEN
8385                   COMMIT WORK;
8386                 END IF;
8387                 l_SUCC_TASK_ID_LIST.extend;
8388                 l_SUCC_TASK_ID_LIST(l_completed_index):=P_TASK_ID_LIST(i);
8389                 l_completed_index:=l_completed_index+1;
8390               ELSE
8391                 rollback to mass_task_update;
8392                 l_failed_reason_list.extend;
8393                 l_failed_task_id_list.extend;
8394                 l_failed_reason_list(l_failed_index):=
8395                   fnd_msg_pub.get_Detail(p_msg_index => fnd_msg_pub.G_FIRST,
8396                               p_encoded =>'F' );
8397                 l_failed_task_id_list(l_failed_index):=P_TASK_ID_LIST(i);
8398                 l_failed_index:=l_failed_index+1;
8399               END IF; -- end IF (l_update_status = 0)
8400             ELSE
8401               rollback to mass_task_update;
8402               l_failed_reason_list.extend;
8403               l_failed_task_id_list.extend;
8404               l_failed_reason_list(l_failed_index):=fnd_msg_pub.get_Detail(p_msg_index => fnd_msg_pub.G_FIRST,
8405                               p_encoded =>'F');
8406               l_failed_task_id_list(l_failed_index):=P_TASK_ID_LIST(i);
8407               l_failed_index:=l_failed_index+1;
8408             END IF;  -- end IF (l_return_status = fnd_api.g_ret_sts_success)
8409           END LOOP;
8410       END IF; -- end IF( l_task_update_required=1 or P_REMOVE_ASSIGNMENT_FLAG = 'T')
8411       x_failed_reason_list:=l_failed_reason_list;
8412       x_failed_task_id_list:=l_failed_task_id_list;
8413       x_SUCC_TASK_ID_LIST:=l_SUCC_TASK_ID_LIST;
8414   END;
8415 END;