DBA Data[Home] [Help]

PACKAGE BODY: APPS.HZ_CONTACT_POINT_V2PUB

Source


1 PACKAGE BODY hz_contact_point_v2pub AS
2 /*$Header: ARH2CPSB.pls 120.37 2008/02/01 06:58:51 nshinde ship $ */
3 
4   --------------------------------------
5   -- declaration of private global varibles
6   --------------------------------------
7 
8   g_debug_count                        NUMBER := 0;
9   --g_debug                              BOOLEAN := FALSE;
10 
11   -- Bug 2197181: added for mix-n-match project.
12 
13   g_cpt_mixnmatch_enabled              VARCHAR2(1);
14   g_cpt_selected_datasources           VARCHAR2(255);
15   g_cpt_is_datasource_selected         VARCHAR2(1) := 'N';
16   g_cpt_entity_attr_id                 NUMBER;
17 
18   --------------------------------------
19   -- declaration of private procedures and functions
20   --------------------------------------
21 
22   /*PROCEDURE enable_debug;
23 
24   PROCEDURE disable_debug;
25   */
26 
27 
28   PROCEDURE do_create_contact_point (
29     p_contact_point_rec                IN OUT NOCOPY contact_point_rec_type,
30     p_edi_rec                          IN OUT NOCOPY edi_rec_type,
31     p_eft_rec                          IN OUT NOCOPY eft_rec_type,
32     p_email_rec                        IN OUT NOCOPY email_rec_type,
33     p_phone_rec                        IN OUT NOCOPY phone_rec_type,
34     p_telex_rec                        IN OUT NOCOPY telex_rec_type,
35     p_web_rec                          IN OUT NOCOPY web_rec_type,
36     x_contact_point_id                 OUT NOCOPY    NUMBER,
37     x_return_status                    IN OUT NOCOPY VARCHAR2
38   );
39 
40   PROCEDURE do_update_contact_point (
41     p_contact_point_rec                IN OUT NOCOPY contact_point_rec_type,
42     p_edi_rec                          IN OUT NOCOPY edi_rec_type,
43     p_eft_rec                          IN OUT NOCOPY eft_rec_type,
44     p_email_rec                        IN OUT NOCOPY email_rec_type,
45     p_phone_rec                        IN OUT NOCOPY phone_rec_type,
46     p_telex_rec                        IN OUT NOCOPY telex_rec_type,
47     p_web_rec                          IN OUT NOCOPY web_rec_type,
48     p_object_version_number            IN OUT NOCOPY NUMBER,
49     x_return_status                    IN OUT NOCOPY VARCHAR2
50   );
51 
52 
53   PROCEDURE do_denormalize_contact_point (
54     p_party_id                         IN     NUMBER,
55     p_contact_point_type               IN     VARCHAR2,
56     p_url                              IN     VARCHAR2,
57     p_email_address                    IN     VARCHAR2,
58     p_phone_contact_pt_id              IN     NUMBER,
59     p_phone_purpose                    IN     VARCHAR2,
60     p_phone_line_type                  IN     VARCHAR2,
61     p_phone_country_code               IN     VARCHAR2,
62     p_phone_area_code                  IN     VARCHAR2,
63     p_phone_number                     IN     VARCHAR2,
64     p_phone_extension                  IN     VARCHAR2
65   );
66 
67   PROCEDURE do_unset_prim_contact_point (
68     p_owner_table_name                 IN     VARCHAR2,
69     p_owner_table_id                   IN     NUMBER,
70     p_contact_point_type               IN     VARCHAR2,
71     p_contact_point_id                 IN     NUMBER,
72     p_mode                             IN     VARCHAR2 := NULL
73   );
74 
75   PROCEDURE do_unset_primary_by_purpose (
76     p_owner_table_name                 IN     VARCHAR2,
77     p_owner_table_id                   IN     NUMBER,
78     p_contact_point_type               IN     VARCHAR2,
79     p_contact_point_purpose            IN     VARCHAR2,
80     p_contact_point_id                 IN     NUMBER
81   );
82 
83   FUNCTION filter_phone_number (
84     p_phone_number                     IN     VARCHAR2,
85     p_isformat                         IN     NUMBER := 0
86   ) RETURN VARCHAR2;
87 
88   PROCEDURE get_phone_format (
89     p_raw_phone_number                 IN     VARCHAR2 := fnd_api.g_miss_char,
90     p_territory_code                   IN     VARCHAR2 := fnd_api.g_miss_char,
91     p_area_code                        IN     VARCHAR2,
92     x_phone_country_code               OUT NOCOPY    VARCHAR2,
93     x_phone_format_style               OUT NOCOPY    VARCHAR2,
94     x_area_code_size                   OUT NOCOPY    VARCHAR2,
95     x_include_country_code             OUT NOCOPY    BOOLEAN,
96     x_msg                              OUT NOCOPY    VARCHAR2
97   );
98 
99   PROCEDURE translate_raw_phone_number (
100     p_raw_phone_number                 IN     VARCHAR2 := fnd_api.g_miss_char,
101     p_phone_format_style               IN     VARCHAR2 := fnd_api.g_miss_char,
102     p_area_code_size                   IN     NUMBER := 0,
103     x_formatted_phone_number           OUT NOCOPY    VARCHAR2,
104     x_phone_area_code                  OUT NOCOPY    VARCHAR2,
105     x_phone_number                     OUT NOCOPY    VARCHAR2
106   );
107 
108   PROCEDURE update_contact_point_search(
109        p_cp_rec        IN HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE,
110        p_old_phone_rec IN HZ_CONTACT_POINT_V2PUB.phone_rec_type,
111        p_new_phone_rec IN HZ_CONTACT_POINT_V2PUB.phone_rec_type,
112        p_old_email_rec IN HZ_CONTACT_POINT_V2PUB.email_rec_type,
113        p_new_email_rec IN HZ_CONTACT_POINT_V2PUB.email_rec_type
114    );
115   FUNCTION isModified(p_old_value IN VARCHAR2,
116                       p_new_value IN VARCHAR2
117                       ) RETURN BOOLEAN;
118 
119   FUNCTION get_protocol_prefixed_url (p_web_rec IN HZ_CONTACT_POINT_V2PUB.web_rec_type)
120            RETURN HZ_CONTACT_POINT_V2PUB.web_rec_type;
121 
122   --------------------------------------
123   -- private procedures and functions
124   --------------------------------------
125 
126   --
127   -- PRIVATE PROCEDURE enable_debug
128   --
129   -- DESCRIPTION
130   --     Turn on debug mode.
131   --
132   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
133   --     HZ_UTILITY_V2PUB.enable_debug
134   --
135   -- MODIFICATION HISTORY
136   --
137   --   07-23-2001    Jianying Huang      o Created.
138   --
139   --
140 
141   /*PROCEDURE enable_debug IS
142   BEGIN
143     g_debug_count := g_debug_count + 1;
144 
145     IF g_debug_count = 1 THEN
146       IF fnd_profile.value('HZ_API_FILE_DEBUG_ON') = 'Y' OR
147          fnd_profile.value('HZ_API_DBMS_DEBUG_ON') = 'Y'
148       THEN
149         hz_utility_v2pub.enable_debug;
150         g_debug := TRUE;
151       END IF;
152     END IF;
153   END enable_debug;
154   */
155 
156   --
157   -- PRIVATE PROCEDURE disable_debug
158   --
159   -- DESCRIPTION
160   --     Turn off debug mode.
161   --
162   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
163   --     HZ_UTILITY_V2PUB.disable_debug
164   --
165   -- MODIFICATION HISTORY
166   --
167   --   07-23-2001    Jianying Huang      o Created.
168   --
169   --
170 
171   /*PROCEDURE disable_debug IS
172   BEGIN
173     IF g_debug THEN
174       g_debug_count := g_debug_count - 1;
175 
176       IF g_debug_count = 0 THEN
177         hz_utility_v2pub.disable_debug;
178         g_debug := FALSE;
179       END IF;
180     END IF;
181   END disable_debug;
182   */
183 
184   --
185   -- PRIVATE FUNCTION get_protocol_prefixed_url
186   --
187   -- DESCRIPTION
188   --     To append 'http://' if it is not present in URL for web type (protocol)
189   --     HTTP. Otherwise it will simply return back passed in URL.
190   --     This can be extended in future for ther protocols also.
191   --
192   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
193   --     None
194   --
195   -- MODIFICATION HISTORY
196   --
197   --   02-MAY-2006    Nishant Singhai  o Created for Bug 4960793 (for HTTP)
198   --
199   --
200 
201   FUNCTION get_protocol_prefixed_url (p_web_rec IN HZ_CONTACT_POINT_V2PUB.web_rec_type)
202   RETURN HZ_CONTACT_POINT_V2PUB.web_rec_type IS
203     l_web_type      VARCHAR2(60);
204     l_url           VARCHAR2(2000);
205     l_http_position NUMBER;
206     l_web_rec       HZ_CONTACT_POINT_V2PUB.web_rec_type;
207   BEGIN
208     l_web_type := p_web_rec.web_type;
209     l_url      := LTRIM(RTRIM(p_web_rec.url));
210 
211     -- If webtype is HTTP, prefix 'http://' if not present in the beginning
212     IF (l_web_type = 'HTTP') THEN
213       IF (l_url IS NOT NULL) THEN
214         l_http_position := INSTR(l_url,'http://');
215         IF (l_http_position = 0) THEN
216           -- append http:// in front of URL
217           l_url := 'http://'||l_url;
218         ELSIF (l_http_position > 1) THEN
219           -- remove from other location and append it in front
220           l_url := 'http://'||REPLACE(l_url,'http://','');
221         END IF;
222       END IF;
223     END IF;
224 
225     l_web_rec.web_type := l_web_type;
226     l_web_rec.url      := l_url;
227     RETURN l_web_rec;
228   END get_protocol_prefixed_url;
229 
230   --
231   -- PRIVATE PROCEDURE do_create_contact_point
232   --
233   -- DESCRIPTION
234   --     Private procedure to create contact point.
235   --
236   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
237   --     hz_registry_validate_v2pub.validate_contact_point
238   --     hz_registry_validate_v2pub.validate_edi_contact_point
239   --     hz_registry_validate_v2pub.validate_eft_contact_point
240   --     hz_registry_validate_v2pub.validate_web_contact_point
241   --     hz_registry_validate_v2pub.validate_phone_contact_point
242   --     hz_registry_validate_v2pub.validate_telex_contact_point
243   --     hz_registry_validate_v2pub.validate_email_contact_point
244   --     hz_contact_points_pkg.insert_row
245   --     hz_phone_number_pkg.transpose
246   --
247   -- ARGUMENTS
248   --   IN/OUT:
249   --     p_contact_point_rec  Contact point record.
250   --     p_edi_rec            EDI record.
251   --     p_email_rec          Email record.
252   --     p_phone_rec          Phone record.
253   --     p_telex_rec          Telex record.
254   --     p_web_rec            Web record.
255   --     x_return_status      Return status after the call. The status can
256   --                          be FND_API.G_RET_STS_SUCCESS (success),
257   --                          FND_API.G_RET_STS_ERROR (error),
258   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
259   --   OUT:
260   --     x_contact_point_id   Contact point ID.
261   --
262   -- NOTES
263   --
264   -- MODIFICATION HISTORY
265   --
266   --   07-23-2001    Jianying Huang      o Created.
267   --   15-NOV-2001   Joe del Callar      Bug 2116225: Modified for consolidated
268   --                                     bank support (EFT record support).
269   --   05-DEC-2001   Joe del Callar      Bug 2136283: Modified to use new
270   --                                     validation procedures.
271   --   06-JUL-2004   Rajib Ranjan Borah  Bug 3520843.raw_phone_number will not be
272   --                                     re-created if passed initially.
273   --   01-03-2005    Rajib Ranjan Borah  SSM SST Integration and Extension.
274   --                                     For non-profile entities, the concept of
275   --                                     select/de-select data-sources is obsoleted.
276 
277   PROCEDURE do_create_contact_point (
278     p_contact_point_rec         IN OUT NOCOPY contact_point_rec_type,
279     p_edi_rec                   IN OUT NOCOPY edi_rec_type,
280     p_eft_rec                   IN OUT NOCOPY eft_rec_type,
281     p_email_rec                 IN OUT NOCOPY email_rec_type,
282     p_phone_rec                 IN OUT NOCOPY phone_rec_type,
283     p_telex_rec                 IN OUT NOCOPY telex_rec_type,
284     p_web_rec                   IN OUT NOCOPY web_rec_type,
285     x_contact_point_id          OUT NOCOPY    NUMBER,
286     x_return_status             IN OUT NOCOPY VARCHAR2
287   ) IS
288     l_debug_prefix              VARCHAR2(30) := ''; -- do_create_contact_point
289 
290     l_dummy                     VARCHAR2(1);
291     l_return_status             VARCHAR2(1);
292     l_message_count             NUMBER;
293     l_msg_count                 NUMBER;
294     l_msg_data                  VARCHAR2(2000);
295 
296     l_formatted_phone_number    VARCHAR2(100);
297     l_country_code              hz_locations.country%TYPE;
298     l_transposed_phone_number   hz_contact_points.transposed_phone_number%TYPE;
299 
300     l_edi_rec                   edi_rec_type;
301     l_email_rec                 email_rec_type;
302     l_phone_rec                 phone_rec_type;
303     l_telex_rec                 telex_rec_type;
304     l_web_rec                   web_rec_type;
305     l_eft_rec                   eft_rec_type;
306     l_orig_sys_reference_rec  HZ_ORIG_SYSTEM_REF_PUB.ORIG_SYS_REFERENCE_REC_TYPE;
307 
308     l_phone_line_type           VARCHAR2(30);
309     l_phone_country_code        VARCHAR2(10);
310     l_phone_area_code           VARCHAR2(10);
311     l_phone_number              VARCHAR2(40);
312     l_phone_extension           VARCHAR2(20);
313     l_contact_point_purpose     VARCHAR2(30);
314 
315     -- Bug 2117973: added following cursors for retrofit to conform to
316     -- Applications PL/SQL standards.
317 
318     CURSOR c_country (p_site_id IN NUMBER) IS
319       SELECT country
320       FROM   hz_locations
321       WHERE  location_id = (SELECT location_id
322                             FROM   hz_party_sites
323                             WHERE  party_site_id = p_site_id);
324 
325     -- Bug 2197181: added for mix-n-match project: the contact point
326     -- must be visible.
327 
328     -- SSM SST Integration and Extension
329     -- For non-profile entities, the concept of select/de-select data-sources is obsoleted.
330     -- There is no need to check if the data-source is selected.
331 
332     CURSOR c_cp (p_owner_table_name   IN VARCHAR2,
333                  p_owner_table_id     IN NUMBER,
334                  p_contact_point_type IN VARCHAR2) IS
335       SELECT 'Y'
336       FROM   hz_contact_points
337       WHERE  owner_table_name = p_owner_table_name
338       AND owner_table_id = p_owner_table_id
339       AND contact_point_type = p_contact_point_type
340 /*      AND HZ_MIXNM_UTILITY.isDataSourceSelected (
341             g_cpt_selected_datasources, actual_content_source ) = 'Y'*/
342       AND status = 'A'
343       AND rownum = 1;
344 
345   BEGIN
346     -- Debug info.
347     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
348         hz_utility_v2pub.debug(p_message=>'do_create_contact_point (+)',
349                                p_prefix=>l_debug_prefix,
350                                p_msg_level=>fnd_log.level_procedure);
351     END IF;
352 
353     IF p_contact_point_rec.contact_point_type = 'EDI' THEN
354       l_edi_rec := p_edi_rec;
355 
356       -- Validate the contact point record
357       hz_registry_validate_v2pub.validate_edi_contact_point (
358         p_create_update_flag    => 'C',
359         p_contact_point_rec     => p_contact_point_rec,
360         p_edi_rec               => l_edi_rec,
361         p_rowid                 => NULL,
362         x_return_status         => x_return_status);
363     ELSIF p_contact_point_rec.contact_point_type = 'EFT' THEN
364       l_eft_rec := p_eft_rec;
365 
366       -- Validate the contact point record
367       hz_registry_validate_v2pub.validate_eft_contact_point (
368         p_create_update_flag    => 'C',
369         p_contact_point_rec     => p_contact_point_rec,
370         p_eft_rec               => l_eft_rec,
371         p_rowid                 => NULL,
372         x_return_status         => x_return_status);
373     ELSIF p_contact_point_rec.contact_point_type = 'EMAIL' THEN
374       l_email_rec := p_email_rec;
375 
376       -- Validate the contact point record
377       hz_registry_validate_v2pub.validate_email_contact_point (
378         p_create_update_flag    => 'C',
379         p_contact_point_rec     => p_contact_point_rec,
380         p_email_rec             => l_email_rec,
381         p_rowid                 => NULL,
382         x_return_status         => x_return_status);
383     ELSIF p_contact_point_rec.contact_point_type = 'PHONE' THEN
384       l_phone_rec := p_phone_rec;
385 
386       -- Validate the contact point record
387       hz_registry_validate_v2pub.validate_phone_contact_point (
388         p_create_update_flag    => 'C',
389         p_contact_point_rec     => p_contact_point_rec,
390         p_phone_rec             => l_phone_rec,
391         p_rowid                 => NULL,
392         x_return_status         => x_return_status);
393     ELSIF p_contact_point_rec.contact_point_type = 'TLX' THEN
394       l_telex_rec := p_telex_rec;
395 
396       -- Validate the contact point record
397       hz_registry_validate_v2pub.validate_telex_contact_point (
398         p_create_update_flag    => 'C',
399         p_contact_point_rec     => p_contact_point_rec,
400         p_telex_rec             => l_telex_rec,
401         p_rowid                 => NULL,
402         x_return_status         => x_return_status);
403     ELSIF p_contact_point_rec.contact_point_type = 'WEB' THEN
404       --l_web_rec := p_web_rec;
405 
406       -- modify URL to prefix protocol (Bug 4960793 Nishant 02-May-2006)
407       l_web_rec := get_protocol_prefixed_url(p_web_rec);
408 
409       -- Validate the contact point record
410       hz_registry_validate_v2pub.validate_web_contact_point (
411         p_create_update_flag    => 'C',
412         p_contact_point_rec     => p_contact_point_rec,
413         p_web_rec               => l_web_rec,
414         p_rowid                 => NULL,
415         x_return_status         => x_return_status);
416     ELSE
417       l_edi_rec := p_edi_rec;
418       l_email_rec := p_email_rec;
419       l_phone_rec := p_phone_rec;
420       l_telex_rec := p_telex_rec;
421       l_web_rec := p_web_rec;
422       l_eft_rec := p_eft_rec;
423 
424       -- Validate the contact point record - call the old routine and the
425       -- EFT validation routine.
426       hz_registry_validate_v2pub.validate_contact_point (
427         p_create_update_flag    => 'C',
428         p_contact_point_rec     => p_contact_point_rec,
429         p_edi_rec               => l_edi_rec,
430         p_email_rec             => l_email_rec,
431         p_phone_rec             => l_phone_rec,
432         p_telex_rec             => l_telex_rec,
433         p_web_rec               => l_web_rec,
434         p_rowid                 => NULL,
435         x_return_status         => x_return_status);
436 
437       IF x_return_status <> fnd_api.g_ret_sts_success THEN
438         RAISE fnd_api.g_exc_error;
439       END IF;
440 
441       hz_registry_validate_v2pub.validate_eft_contact_point (
442         p_create_update_flag    => 'C',
443         p_contact_point_rec     => p_contact_point_rec,
444         p_eft_rec               => l_eft_rec,
445         p_rowid                 => NULL,
446         x_return_status         => x_return_status);
447     END IF;
448 
449     -- Raise an error if any of the validations failed.
450     IF x_return_status <> fnd_api.g_ret_sts_success THEN
451       RAISE fnd_api.g_exc_error;
452     END IF;
453 
454     -- If raw_phone_number is passed in, call procedure phone_format.
455     -- either raw_phone_number or phone_number should be passed in
456     -- but can not be both. If raw_phone_number does not have a value,
457     -- it will be set by phone_number and phone_area_code.
458 
459     -- Debug info.
460     IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
461            hz_utility_v2pub.debug(p_message=>'contact_point_type = ' || p_contact_point_rec.contact_point_type,
462                                   p_prefix =>l_debug_prefix,
463                                   p_msg_level=>fnd_log.level_statement);
464     END IF;
465 
466     --To get territory code to pass to phone_format, first check if country code
467     --was passed in else get it from hz_locations for owner_table_name HZ_PARTY_SITES
468 
469     IF p_contact_point_rec.contact_point_type = 'PHONE' THEN
470       IF l_phone_rec.raw_phone_number IS NOT NULL AND
471          l_phone_rec.raw_phone_number <> fnd_api.g_miss_char
472       THEN
473          IF l_phone_rec.phone_country_code is not null AND
474             l_phone_rec.phone_country_code <> fnd_api.g_miss_char
475          THEN
476             BEGIN
477               select territory_code into l_country_code
478               from hz_phone_country_codes
479               where phone_country_code = l_phone_rec.phone_country_code
480               and rownum = 1;
481             EXCEPTION
482               WHEN NO_DATA_FOUND THEN
483                NULL;
484             END;
485          ELSIF p_contact_point_rec.owner_table_name = 'HZ_PARTY_SITES' AND
486            (l_phone_rec.phone_country_code IS NULL OR
487             l_phone_rec.phone_country_code = fnd_api.g_miss_char)
488          THEN
489            -- Bug 2117973: modified to conform to Applications PL/SQL standards.
490            OPEN c_country(p_contact_point_rec.owner_table_id);
491            FETCH c_country INTO l_country_code;
492            IF c_country%NOTFOUND THEN
493              CLOSE c_country;
494              RAISE NO_DATA_FOUND;
495            END IF;
496            CLOSE c_country;
497          ELSE
498            l_country_code := NULL;
499          END IF;
500 
501          l_message_count := fnd_msg_pub.count_msg();
502 
503          -- Since phone_format cannot format raw_phone_number and phone_number
504          -- at same time, the input value of phone_number and phone_area_code
505          -- should be NULL or G_MISS before the call.
506 
507          phone_format (
508            p_raw_phone_number                => l_phone_rec.raw_phone_number,
509            p_territory_code                  => l_country_code,
510            x_formatted_phone_number          => l_formatted_phone_number,
511            x_phone_country_code              => l_phone_rec.phone_country_code,
512            x_phone_area_code                 => l_phone_rec.phone_area_code,
513            x_phone_number                    => l_phone_rec.phone_number,
514            x_return_status                   => x_return_status,
515            x_msg_count                       => l_msg_count,
516            x_msg_data                        => l_msg_data);
517 
518          -- Raise exception only if content_source_type = G_MISS_CONTENT_SOURCE_TYPE.
519          -- For other sources, we do not want to error out, but simply store the
520          -- Raw Phone Number.
521 
522          -- Bug 2197181 : content_source_type is obsolete and replaced by
523          -- actual_content_source
524 
525          IF x_return_status <> fnd_api.g_ret_sts_success THEN
526            IF p_contact_point_rec.actual_content_source = g_miss_content_source_type
527            THEN
528              IF x_return_status = fnd_api.g_ret_sts_error THEN
529                RAISE fnd_api.g_exc_error;
530              ELSE
531                RAISE fnd_api.g_exc_unexpected_error;
532              END IF;
533            ELSE
534              FOR i IN 1..(l_msg_count - l_message_count) LOOP
535                fnd_msg_pub.delete_msg(l_msg_count - l_message_count + 1 - i);
536              END LOOP;
537              x_return_status := fnd_api.g_ret_sts_success;
538            END IF;
539          END IF;
540 
541     --  END IF; Bug 3520843
542        ELSE
543           -- raw_phone_number must always have value.
544           IF l_phone_rec.phone_area_code IS NULL OR
545              l_phone_rec.phone_area_code = fnd_api.g_miss_char
546           THEN
547              l_phone_rec.raw_phone_number := l_phone_rec.phone_number;
548           ELSE
549              l_phone_rec.raw_phone_number := l_phone_rec.phone_area_code || '-' ||
550                                         l_phone_rec.phone_number;
551           END IF;
552        END IF;
553 
554       -- Debug info.
555       IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
556            hz_utility_v2pub.debug(p_message=>'phone_number = ' || l_phone_rec.phone_number || ' ' ||
557           'raw_phone_number = ' || l_phone_rec.raw_phone_number,
558                                   p_prefix =>l_debug_prefix,
559                                   p_msg_level=>fnd_log.level_statement);
560      END IF;
561 
562       -- Populate transposed_phone_number
563       IF l_phone_rec.phone_country_code IS NOT NULL AND
564          l_phone_rec.phone_country_code <> fnd_api.g_miss_char
565       THEN
566         l_transposed_phone_number := l_phone_rec.phone_country_code;
567       END IF;
568 
569       IF l_phone_rec.phone_area_code IS NOT NULL AND
570          l_phone_rec.phone_area_code <> fnd_api.g_miss_char
571       THEN
572         l_transposed_phone_number := l_transposed_phone_number ||
573                                      l_phone_rec.phone_area_code;
574       END IF;
575 
576       -- phone_number is mandatory
577       l_transposed_phone_number := hz_phone_number_pkg.transpose(
578         l_transposed_phone_number || l_phone_rec.phone_number);
579 
580       -- Debug info.
581       IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
582            hz_utility_v2pub.debug(p_message=>'transposed_phone_number = ' || l_transposed_phone_number,
583                                   p_prefix =>l_debug_prefix,
584                                   p_msg_level=>fnd_log.level_statement);
585       END IF;
586     END IF;
587 
588     -- If this is the first active contact point for the combination of
589     -- owner_table_name, owner_table_id, contact_point_type, we need to
590     -- mark it as primary no matter the value of primary_flag,
591     -- If primary_flag = 'Y', we need to unmark the previous primary.
592     -- Please note, if status is NULL or MISSING, we treat it as 'A'
593     -- and in validation part, we already checked that primary_flag = 'Y'
594     -- and status = 'I' can not both be set.
595 
596     -- Bug 2197181: added for mix-n-match project: the primary flag
597     -- can be set to 'Y' only if the contact point will be visible. If
598     -- it is not visible, the flag must be reset to 'N'.
599 
600     -- SSM SST Integration and Extension
601     -- For non-profile entities, the concept of select/de-select data sources is obsoleted.
602     -- There is no need to check if the data-source is selected.
603 
604     IF p_contact_point_rec.status IS NULL OR
605        p_contact_point_rec.status = fnd_api.g_miss_char OR
606        p_contact_point_rec.status = 'A'
607     THEN
608       IF p_contact_point_rec.primary_flag = 'Y' THEN
609         -- Bug 2197181: added for mix-n-match project
610      -- IF g_cpt_is_datasource_selected = 'Y' THEN
611           -- Unmark previous primary contact point.
612           do_unset_prim_contact_point (p_contact_point_rec.owner_table_name,
613                                        p_contact_point_rec.owner_table_id,
614                                        p_contact_point_rec.contact_point_type,
615                                        p_contact_point_rec.contact_point_id, 'I');
616      -- ELSE
617      --   p_contact_point_rec.primary_flag := 'N';
618      -- END IF;
619       ELSE
620         -- Bug 2117973: modified to conform to Applications PL/SQL standards.
621         OPEN c_cp (p_contact_point_rec.owner_table_name,
622                     p_contact_point_rec.owner_table_id,
623                     p_contact_point_rec.contact_point_type);
624         FETCH c_cp INTO l_dummy;
625 
626         -- SSM SST Integration and Extension
627 	-- For non-profile entities, the concept of select/de-select data-sources is obsoleted.
628 	-- There is no need to check if the data-source is selected.
629 
630         IF c_cp%NOTFOUND /*AND
631            -- Bug 2197181: added for mix-n-match project
632            g_cpt_is_datasource_selected = 'Y'*/
633         THEN
634           -- First active and visible contact point per type for this entity
635           p_contact_point_rec.primary_flag := 'Y';
636         ELSE
637           p_contact_point_rec.primary_flag := 'N';
638         END IF;
639         CLOSE c_cp;
640       END IF;
641 
642 
643     END IF;
644 
645     -- There is only one primary per purpose contact point exist for
646     -- the combination of owner_table_name, owner_table_id, contact_point_type
647     -- and contact_point_purpose. If primary_by_purpose is set to 'Y',
648     -- we need to unset the previous primary per purpose contact point to
649     -- non-primary. Since setting primary_by_purpose is only making
650     -- sense when contact_point_purpose has some value, we ignore
651     -- the primary_by_purpose (setting it to 'N') if contact_point_purpose
652     -- is NULL.
653 
654     -- Bug 2197181: added for mix-n-match project: the primary by purpose
655     -- flag can be set to 'Y' only if the contact point will be visible.
656     -- If it is not visible, the flag must be reset to 'N'.
657 
658     -- SSM SST Integration and Extension
659     -- For non-profile entities, the concept of select/de-select data sources is obsoleted.
660     -- There is no need to check if the data-source is selected.
661 
662     IF p_contact_point_rec.contact_point_purpose IS NOT NULL AND
663        p_contact_point_rec.contact_point_purpose <> fnd_api.g_miss_char
664     THEN
665       IF p_contact_point_rec.primary_by_purpose = 'Y' THEN
666         -- Bug 2197181: added for mix-n-match project
667      -- IF g_cpt_is_datasource_selected = 'Y' THEN
668           do_unset_primary_by_purpose (p_contact_point_rec.owner_table_name,
669                                        p_contact_point_rec.owner_table_id,
670                                        p_contact_point_rec.contact_point_type,
671                                        p_contact_point_rec.contact_point_purpose,
672                                        p_contact_point_rec.contact_point_id);
673      -- ELSE
674      --     p_contact_point_rec.primary_by_purpose := 'N';
675      -- END IF;
676       END IF;
677     ELSE
678       p_contact_point_rec.primary_by_purpose := 'N';
679     END IF;
680 
681     if l_phone_rec.timezone_id is null or
682            l_phone_rec.timezone_id = fnd_api.g_miss_num
683     then
684 
685         if l_phone_rec.phone_country_code IS NOT NULL AND
686         l_phone_rec.phone_country_code <> fnd_api.g_miss_char
687         then
688                 l_message_count := fnd_msg_pub.count_msg();
689                 hz_timezone_pub.get_phone_timezone_id(
690                         p_api_version => 1.0,
691                         p_init_msg_list => FND_API.G_FALSE,
692                         p_phone_country_code => l_phone_rec.phone_country_code,
693                         p_area_code => l_phone_rec.phone_area_code,
694                         p_phone_prefix => null,
695                         p_country_code => null,-- don't need to pass in this
696                         x_timezone_id => l_phone_rec.timezone_id,
697                         x_return_status => l_return_status ,
698                         x_msg_count =>l_msg_count ,
699                         x_msg_data => l_msg_data);
700                         if l_return_status <> fnd_api.g_ret_sts_success
701                         then  -- we don't raise error
702                                 l_phone_rec.timezone_id := null;
703                                 FOR i IN 1..(l_msg_count - l_message_count) LOOP
704                                     fnd_msg_pub.delete_msg(l_msg_count - l_message_count + 1 - i);
705                                 END LOOP;
706                                 l_return_status := FND_API.G_RET_STS_SUCCESS;
707                         end if;
708         end if;
709     end if;
710 
711 
712     -- Debug info.
713     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
714         hz_utility_v2pub.debug(p_message=>'HZ_CONTACT_POINTS_PKG.Insert_Row (+)',
715                                p_prefix=>l_debug_prefix,
716                                p_msg_level=>fnd_log.level_procedure);
717     END IF;
718 
719     -- Call table-handler.
720     hz_contact_points_pkg.insert_row (
721       x_contact_point_id                => p_contact_point_rec.contact_point_id,
722       x_contact_point_type              => p_contact_point_rec.contact_point_type,
723       x_status                          => p_contact_point_rec.status,
724       x_owner_table_name                => p_contact_point_rec.owner_table_name,
725       x_owner_table_id                  => p_contact_point_rec.owner_table_id,
726       x_primary_flag                    => p_contact_point_rec.primary_flag,
727       x_orig_system_reference           => p_contact_point_rec.orig_system_reference,
728       x_attribute_category              => p_contact_point_rec.attribute_category,
729       x_attribute1                      => p_contact_point_rec.attribute1,
730       x_attribute2                      => p_contact_point_rec.attribute2,
731       x_attribute3                      => p_contact_point_rec.attribute3,
732       x_attribute4                      => p_contact_point_rec.attribute4,
733       x_attribute5                      => p_contact_point_rec.attribute5,
734       x_attribute6                      => p_contact_point_rec.attribute6,
735       x_attribute7                      => p_contact_point_rec.attribute7,
736       x_attribute8                      => p_contact_point_rec.attribute8,
737       x_attribute9                      => p_contact_point_rec.attribute9,
738       x_attribute10                     => p_contact_point_rec.attribute10,
739       x_attribute11                     => p_contact_point_rec.attribute11,
740       x_attribute12                     => p_contact_point_rec.attribute12,
741       x_attribute13                     => p_contact_point_rec.attribute13,
742       x_attribute14                     => p_contact_point_rec.attribute14,
743       x_attribute15                     => p_contact_point_rec.attribute15,
744       x_attribute16                     => p_contact_point_rec.attribute16,
745       x_attribute17                     => p_contact_point_rec.attribute17,
746       x_attribute18                     => p_contact_point_rec.attribute18,
747       x_attribute19                     => p_contact_point_rec.attribute19,
748       x_attribute20                     => p_contact_point_rec.attribute20,
749       x_edi_transaction_handling        => l_edi_rec.edi_transaction_handling,
750       x_edi_id_number                   => l_edi_rec.edi_id_number,
751       x_edi_payment_method              => l_edi_rec.edi_payment_method,
752       x_edi_payment_format              => l_edi_rec.edi_payment_format,
753       x_edi_remittance_method           => l_edi_rec.edi_remittance_method,
754       x_edi_remittance_instruction      => l_edi_rec.edi_remittance_instruction,
755       x_edi_tp_header_id                => l_edi_rec.edi_tp_header_id,
756       x_edi_ece_tp_location_code        => l_edi_rec.edi_ece_tp_location_code,
757       x_eft_transmission_program_id     => l_eft_rec.eft_transmission_program_id,
758       x_eft_printing_program_id         => l_eft_rec.eft_printing_program_id,
759       x_eft_user_number                 => l_eft_rec.eft_user_number,
760       x_eft_swift_code                  => l_eft_rec.eft_swift_code,
761       x_email_format                    => l_email_rec.email_format,
762       x_email_address                   => l_email_rec.email_address,
763       x_phone_calling_calendar          => l_phone_rec.phone_calling_calendar,
764       x_last_contact_dt_time            => l_phone_rec.last_contact_dt_time,
765       x_timezone_id                     => l_phone_rec.timezone_id,
766       x_phone_area_code                 => l_phone_rec.phone_area_code,
767       x_phone_country_code              => l_phone_rec.phone_country_code,
768       x_phone_number                    => l_phone_rec.phone_number,
769       x_phone_extension                 => l_phone_rec.phone_extension,
770       x_phone_line_type                 => l_phone_rec.phone_line_type,
771       x_telex_number                    => l_telex_rec.telex_number,
772       x_web_type                        => l_web_rec.web_type,
773       x_url                             => l_web_rec.url,
774       x_content_source_type             => p_contact_point_rec.content_source_type,
775       x_raw_phone_number                => l_phone_rec.raw_phone_number,
776       x_object_version_number           => 1,
777       x_contact_point_purpose           => p_contact_point_rec.contact_point_purpose,
778       x_primary_by_purpose              => p_contact_point_rec.primary_by_purpose,
779       x_created_by_module               => p_contact_point_rec.created_by_module,
780       x_application_id                  => p_contact_point_rec.application_id,
781       x_transposed_phone_number         => l_transposed_phone_number,
782       x_actual_content_source           => p_contact_point_rec.actual_content_source
783    );
784 
785     x_contact_point_id := p_contact_point_rec.contact_point_id;
786 
787 ---Bug No: 3131865
788      -- De-normalize primary contact point to HZ_PARTIES.
789       -- url is mandatory if contact_point_type = 'WEB'.
790       -- email_address is mandatory if contact_point_type = 'EMAIL'.
791 
792       -- Debug info.
793       IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
794            hz_utility_v2pub.debug(p_message=>'primary_flag = ' || p_contact_point_rec.primary_flag || ' ' ||
795                                           'owner_table_name = '||p_contact_point_rec.owner_table_name||' '||
796                                           'contact_point_type = '||p_contact_point_rec.contact_point_type||' '||
797                                           'actual_content_source = ' || p_contact_point_rec.actual_content_source,
798                                   p_prefix =>l_debug_prefix,
799                                   p_msg_level=>fnd_log.level_statement);
800       END IF;
801 
802       -- Bug 2197181: commented out NOCOPY the data source checking. We will denormalize
803       -- to hz_parties as long as it's a primary contact point regardless of data
804       -- source.
805     IF p_contact_point_rec.status IS NULL OR
806        p_contact_point_rec.status = fnd_api.g_miss_char OR
807        p_contact_point_rec.status = 'A'
808     THEN
809       IF p_contact_point_rec.primary_flag = 'Y' AND
810          p_contact_point_rec.owner_table_name = 'HZ_PARTIES' AND
811          (p_contact_point_rec.contact_point_type IN ('WEB','EMAIL','PHONE'))
812          /* AND
813          (p_contact_point_rec.content_source_type IS NULL OR
814            p_contact_point_rec.content_source_type = fnd_api.g_miss_char OR
815            p_contact_point_rec.content_source_type =
816              hz_party_v2pub.g_miss_content_source_type)
817          */
818       THEN
819         IF l_phone_rec.phone_line_type = fnd_api.g_miss_char then
820            l_phone_line_type := NULL;
821         ELSE
822            l_phone_line_type := l_phone_rec.phone_line_type;
823         END IF;
824         IF l_phone_rec.phone_country_code = fnd_api.g_miss_char then
825            l_phone_country_code := NULL;
826         ELSE
827            l_phone_country_code := l_phone_rec.phone_country_code;
828         END IF;
829         IF l_phone_rec.phone_area_code = fnd_api.g_miss_char then
830            l_phone_area_code := NULL;
831         ELSE
832            l_phone_area_code := l_phone_rec.phone_area_code;
833         END IF;
834         IF l_phone_rec.phone_number = fnd_api.g_miss_char then
835            l_phone_number := NULL;
836         ELSE
837            l_phone_number := l_phone_rec.phone_number;
838         END IF;
839         IF l_phone_rec.phone_extension = fnd_api.g_miss_char then
840            l_phone_extension := NULL;
841         ELSE
842            l_phone_extension := l_phone_rec.phone_extension;
843         END IF;
844         IF p_contact_point_rec.contact_point_purpose = fnd_api.g_miss_char then
845            l_contact_point_purpose := NULL;
846         ELSE
847            l_contact_point_purpose := p_contact_point_rec.contact_point_purpose;
848         END IF;
849 
850 
851         do_denormalize_contact_point (p_contact_point_rec.owner_table_id,
852                                       p_contact_point_rec.contact_point_type,
853                                       l_web_rec.url,
854                                       l_email_rec.email_address,
855                                       p_contact_point_rec.contact_point_id,
856                                       l_contact_point_purpose,
857                                       l_phone_line_type,
858                                       l_phone_country_code,
859                                       l_phone_area_code,
860                                       l_phone_number,
861                                       l_phone_extension
862                                       );
863       END IF;
864     END IF;
865 --End of Bug No: 3131865.
866 
867     -- Debug info.
868     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
869         hz_utility_v2pub.debug(p_message=>'HZ_CONTACT_POINTS_PKG.Insert_Row (-) ' ||
870         'x_contact_point_id = ' ||p_contact_point_rec.contact_point_id,
871                                p_prefix=>l_debug_prefix,
872                                p_msg_level=>fnd_log.level_procedure);
873     END IF;
874 
875      if p_contact_point_rec.orig_system is not null
876          and p_contact_point_rec.orig_system <>fnd_api.g_miss_char
877       then
878                 l_orig_sys_reference_rec.orig_system := p_contact_point_rec.orig_system;
879                 l_orig_sys_reference_rec.orig_system_reference := p_contact_point_rec.orig_system_reference;
880                 l_orig_sys_reference_rec.owner_table_name := 'HZ_CONTACT_POINTS';
881                 l_orig_sys_reference_rec.owner_table_id := p_contact_point_rec.contact_point_id;
882                 l_orig_sys_reference_rec.created_by_module := p_contact_point_rec.created_by_module;
883 
884                 hz_orig_system_ref_pub.create_orig_system_reference(
885                         FND_API.G_FALSE,
886                         l_orig_sys_reference_rec,
887                         x_return_status,
888                         l_msg_count,
889                         l_msg_data);
890                  IF x_return_status <> fnd_api.g_ret_sts_success THEN
891                         RAISE FND_API.G_EXC_ERROR;
892                 END IF;
893       end if;
894 
895 
896     -- Debug info.
897     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
898         hz_utility_v2pub.debug(p_message=>'do_create_contact_point (-)',
899                                p_prefix=>l_debug_prefix,
900                                p_msg_level=>fnd_log.level_procedure);
901     END IF;
902 
903   END do_create_contact_point;
904 
905   --
906   -- PRIVATE PROCEDURE do_update_contact_point
907   --
908   -- DESCRIPTION
909   --     Private procedure to update contact point.
910   --
911   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
912   --     hz_registry_validate_v2pub.validate_contact_point
913   --     hz_registry_validate_v2pub.validate_edi_contact_point
914   --     hz_registry_validate_v2pub.validate_eft_contact_point
915   --     hz_registry_validate_v2pub.validate_web_contact_point
916   --     hz_registry_validate_v2pub.validate_phone_contact_point
917   --     hz_registry_validate_v2pub.validate_telex_contact_point
918   --     hz_registry_validate_v2pub.validate_email_contact_point
919   --     hz_contact_points_pkg.update_row
920   --     hz_phone_number_pkg.transpose
921   --
922   -- ARGUMENTS
923   --   IN/OUT:
924   --     p_contact_point_rec      Contact point record.
925   --     p_edi_rec                EDI record.
926   --     p_eft_rec                Electronic File Transfer record.
927   --     p_email_rec              Email record.
928   --     p_phone_rec              Phone record.
929   --     p_telex_rec              Telex record.
930   --     p_web_rec                Web record.
931   --     p_object_version_number  Used for locking the being updated record.
932   --     x_return_status          Return status after the call. The status can
933   --                              be fnd_api.g_ret_sts_success (success),
934   --                              fnd_api.g_ret_sts_error (error),
935   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
936   --
937   -- NOTES
938   --
939   -- MODIFICATION HISTORY
940   --
941   --   07-23-2001    Jianying Huang      o Created.
942   --   15-NOV-2001   Joe del Callar      Bug 2116225: Modified for consolidated
943   --                                     bank support (EFT record support).
944   --   05-DEC-2001   Joe del Callar      Bug 2136283: Modified to use new
945   --                                     validation procedures.
946   --   06-JUL-2004   Rajib Ranjan Borah  Bug 3711740. If phone_format returns
947   --                                     NULL for phone_area_code,phone_country_code
948   --                                     and/or phone_number, then set these to
949   --                                     FND_API.G_MISS_CHAR as otherwise, the old
950   --                                     value will be retained.
951   --  01-03-2005  Rajib Ranjan Borah   o SSM SST Integration and Extension.
952   --                                     For non-profile entities, the concept of
953   --                                     select/de-select data-sources is obsoleted.
954   --   01-FEB-2008   Neeraj Shinde       Bug 6755308: Modified the condition to call the
955   --                                     do_unset_primary_by_purpose procedure
956 
957 
958   PROCEDURE do_update_contact_point (
959     p_contact_point_rec                   IN OUT NOCOPY contact_point_rec_type,
960     p_edi_rec                             IN OUT NOCOPY edi_rec_type,
961     p_eft_rec                             IN OUT NOCOPY eft_rec_type,
962     p_email_rec                           IN OUT NOCOPY email_rec_type,
963     p_phone_rec                           IN OUT NOCOPY phone_rec_type,
964     p_telex_rec                           IN OUT NOCOPY telex_rec_type,
965     p_web_rec                             IN OUT NOCOPY web_rec_type,
966     p_object_version_number               IN OUT NOCOPY NUMBER,
967     x_return_status                       IN OUT NOCOPY VARCHAR2
968   ) IS
969 
970     l_debug_prefix              VARCHAR2(30) := ''; -- do_update_contact_point
971 
972     l_rowid                     ROWID := NULL;
973     l_contact_point_rowid       ROWID := NULL;
974     l_dummy                     VARCHAR2(1);
975     l_object_version_number     NUMBER;
976     l_message_count             NUMBER;
977     l_msg_count                 NUMBER;
978     l_msg_data                  VARCHAR2(2000);
979 
980     l_formatted_phone_number    VARCHAR2(100);
981     l_country_code              hz_locations.country%TYPE;
982     l_owner_table_name          hz_contact_points.owner_table_name%TYPE;
983     l_owner_table_id            NUMBER;
984     l_contact_point_type        hz_contact_points.contact_point_type%TYPE :=
985                                   p_contact_point_rec.contact_point_type;
986     l_primary_flag              hz_contact_points.primary_flag%TYPE;
987     l_status                    hz_contact_points.status%TYPE;
988     l_phone_area_code           hz_contact_points.phone_area_code%TYPE;
989     l_phone_number              hz_contact_points.phone_number%TYPE;
990     l_phone_country_code        hz_contact_points.phone_country_code%TYPE;
991     l_url                       hz_contact_points.url%TYPE;
992     l_email_address             hz_contact_points.email_address%TYPE;
993     l_contact_point_purpose     hz_contact_points.contact_point_purpose%TYPE;
994     l_primary_by_purpose        hz_contact_points.primary_by_purpose%TYPE;
995     l_transposed_phone_number   hz_contact_points.transposed_phone_number%TYPE;
996 
997     --BugNo:1695595.Added local variables to hold denormalized column values----
998     l_contact_point_id          hz_contact_points.contact_point_id%TYPE;
999     l_phone_line_type           hz_contact_points.phone_line_type%TYPE;
1000     l_phone_extension           hz_contact_points.phone_extension%TYPE;
1001     -----------------------------------------------------------------
1002     l_edi_rec                   edi_rec_type;
1003     l_eft_rec                   eft_rec_type;
1004     l_email_rec                 email_rec_type;
1005     l_phone_rec                 phone_rec_type;
1006     l_telex_rec                 telex_rec_type;
1007     l_web_rec                   web_rec_type;
1008 
1009     -- Bug 2197181: added for mix-n-match project.
1010     db_actual_content_source    hz_contact_points.actual_content_source%TYPE;
1011 --  Bug 4693719 : Added for local assignment
1012     l_acs    hz_contact_points.actual_content_source%TYPE;
1013 
1014     -- Bug 2117973: defined the following cursors for PL/SQL coding standards
1015     -- compliance.
1016     CURSOR c_country (p_owner_table_id IN NUMBER) IS
1017       SELECT country
1018       FROM   hz_locations
1019       WHERE  location_id = (SELECT location_id
1020                             FROM   hz_party_sites
1021                             WHERE  party_site_id = p_owner_table_id);
1022 
1023     -- Bug 2197181: added for mix-n-match project: the contact point
1024     -- must be visible.
1025 
1026     -- SSM SST Integration and Extension
1027     -- Modified the cursors c_setpf and c_chkdenorm
1028     -- For non-profile entities, the concept of select/de-select data-sources is obsoleted.
1029     -- There is no need to check if the data-source is selected.
1030 
1031 
1032     CURSOR c_setpf (
1033       p_owner_table_name   IN VARCHAR2,
1034       p_owner_table_id     IN NUMBER,
1035       p_contact_point_type IN VARCHAR2
1036     ) IS
1037       SELECT 'Y'
1038       FROM   hz_contact_points
1039       WHERE  owner_table_name = p_owner_table_name
1040       AND owner_table_id = p_owner_table_id
1041       AND contact_point_type = p_contact_point_type
1042       AND contact_point_id <> p_contact_point_rec.contact_point_id
1043    /*   AND HZ_MIXNM_UTILITY.isDataSourceSelected (
1044             g_cpt_selected_datasources, actual_content_source ) = 'Y'*/
1045       AND status = 'A'
1046       AND rownum = 1;
1047 
1048     -- Bug 2197181: added for mix-n-match project: the contact point
1049     -- must be visible.
1050 
1051     CURSOR c_chkdenorm (
1052       p_owner_table_name   IN VARCHAR2,
1053       p_owner_table_id     IN NUMBER,
1054       p_contact_point_type IN VARCHAR2,
1055       p_contact_point_id   IN NUMBER
1056     ) IS
1057       SELECT rowid, url, email_address,contact_point_id,contact_point_purpose,
1058              phone_line_type,phone_area_code,phone_country_code,phone_number,phone_extension
1059       FROM   hz_contact_points
1060       WHERE  contact_point_id = (
1061                SELECT MIN(contact_point_id)
1062                FROM   hz_contact_points
1063                WHERE  owner_table_name = p_owner_table_name
1064                       AND owner_table_id = p_owner_table_id
1065                       AND contact_point_type = p_contact_point_type
1066                     /*  AND HZ_MIXNM_UTILITY.isDataSourceSelected (
1067                             g_cpt_selected_datasources, actual_content_source ) = 'Y'*/
1068                       AND status = 'A'
1069                       AND contact_point_id <> p_contact_point_id);
1070 
1071   BEGIN
1072     -- Debug info.
1073     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
1074         hz_utility_v2pub.debug(p_message=>'do_update_contact_point (+)',
1075                                p_prefix=>l_debug_prefix,
1076                                p_msg_level=>fnd_log.level_procedure);
1077     END IF;
1078 
1079 
1080     -- Lock record.
1081 
1082     -- Bug 2197181: selecting actual_content_source for  mix-n-match project.
1083 
1084     BEGIN
1085     --Bug 1695595 added phone_line_type,phone_extension columns to the select caluse.
1086 
1087 
1088       SELECT rowid, object_version_number,
1089              owner_table_name, owner_table_id,
1090              contact_point_type, phone_line_type,phone_country_code, phone_area_code,
1091              phone_number,phone_extension,primary_flag, status, contact_point_purpose,
1092              url, email_address, primary_by_purpose, actual_content_source
1093       INTO   l_rowid, l_object_version_number,
1094              l_owner_table_name, l_owner_table_id,
1095              l_contact_point_type,l_phone_line_type,
1096              l_phone_country_code, l_phone_area_code, l_phone_number,l_phone_extension,
1097              l_primary_flag, l_status, l_contact_point_purpose,
1098              l_url, l_email_address, l_primary_by_purpose, db_actual_content_source
1099       FROM   hz_contact_points
1100       WHERE  contact_point_id = p_contact_point_rec.contact_point_id
1101       FOR UPDATE NOWAIT;
1102 
1103       IF NOT ((p_object_version_number IS NULL AND
1104                 l_object_version_number IS NULL) OR
1105               (p_object_version_number IS NOT NULL AND
1106                 l_object_version_number IS NOT NULL AND
1107                 p_object_version_number = l_object_version_number))
1108       THEN
1109         fnd_message.set_name('AR', 'HZ_API_RECORD_CHANGED');
1110         fnd_message.set_token('TABLE', 'hz_contact_points');
1111         fnd_msg_pub.add;
1112         RAISE fnd_api.g_exc_error;
1113       END IF;
1114 
1115       p_object_version_number := NVL(l_object_version_number, 1) + 1;
1116 
1117     EXCEPTION
1118       WHEN NO_DATA_FOUND THEN
1119         fnd_message.set_name('AR', 'HZ_API_NO_RECORD');
1120         fnd_message.set_token('RECORD', 'contact point');
1121         fnd_message.set_token('VALUE',
1122           NVL(TO_CHAR(p_contact_point_rec.contact_point_id), 'null'));
1123         fnd_msg_pub.add;
1124         RAISE fnd_api.g_exc_error;
1125     END;
1126 
1127     -- Debug info.
1128     IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
1129            hz_utility_v2pub.debug(p_message=>'l_contact_point_type = ' || l_contact_point_type,
1130                                   p_prefix =>l_debug_prefix,
1131                                   p_msg_level=>fnd_log.level_statement);
1132     END IF;
1133 
1134 
1135     IF l_contact_point_type = 'EDI' THEN
1136       l_edi_rec := p_edi_rec;
1137 
1138       -- Validate the contact point record
1139       hz_registry_validate_v2pub.validate_edi_contact_point (
1140         p_create_update_flag    => 'U',
1141         p_contact_point_rec     => p_contact_point_rec,
1142         p_edi_rec               => l_edi_rec,
1143         p_rowid                 => l_rowid,
1144         x_return_status         => x_return_status);
1145     ELSIF l_contact_point_type = 'EFT' THEN
1146       l_eft_rec := p_eft_rec;
1147 
1148       -- Validate the contact point record
1149       hz_registry_validate_v2pub.validate_eft_contact_point (
1150         p_create_update_flag    => 'U',
1151         p_contact_point_rec     => p_contact_point_rec,
1152         p_eft_rec               => l_eft_rec,
1153         p_rowid                 => l_rowid,
1154         x_return_status         => x_return_status);
1155     ELSIF l_contact_point_type = 'EMAIL' THEN
1156       l_email_rec := p_email_rec;
1157 
1158       -- Validate the contact point record
1159       hz_registry_validate_v2pub.validate_email_contact_point (
1160         p_create_update_flag    => 'U',
1161         p_contact_point_rec     => p_contact_point_rec,
1162         p_email_rec             => l_email_rec,
1163         p_rowid                 => l_rowid,
1164         x_return_status         => x_return_status);
1165     ELSIF l_contact_point_type = 'PHONE' THEN
1166       l_phone_rec := p_phone_rec;
1167 
1168       -- Validate the contact point record
1169       hz_registry_validate_v2pub.validate_phone_contact_point (
1170         p_create_update_flag    => 'U',
1171         p_contact_point_rec     => p_contact_point_rec,
1172         p_phone_rec             => l_phone_rec,
1173         p_rowid                 => l_rowid,
1174         x_return_status         => x_return_status);
1175     ELSIF l_contact_point_type = 'TLX' THEN
1176       l_telex_rec := p_telex_rec;
1177 
1178       -- Validate the contact point record
1179       hz_registry_validate_v2pub.validate_telex_contact_point (
1180         p_create_update_flag    => 'U',
1181         p_contact_point_rec     => p_contact_point_rec,
1182         p_telex_rec             => l_telex_rec,
1183         p_rowid                 => l_rowid,
1184         x_return_status         => x_return_status);
1185     ELSIF l_contact_point_type = 'WEB' THEN
1186       -- l_web_rec := p_web_rec;
1187       -- modify URL to prefix protocol (Bug 4960793 Nishant 02-May-2006)
1188       l_web_rec := get_protocol_prefixed_url(p_web_rec);
1189 
1190       -- Validate the contact point record
1191       hz_registry_validate_v2pub.validate_web_contact_point (
1192         p_create_update_flag    => 'U',
1193         p_contact_point_rec     => p_contact_point_rec,
1194         p_web_rec               => l_web_rec,
1195         p_rowid                 => l_rowid,
1196         x_return_status         => x_return_status);
1197     ELSE
1198       l_edi_rec := p_edi_rec;
1199       l_email_rec := p_email_rec;
1200       l_phone_rec := p_phone_rec;
1201       l_telex_rec := p_telex_rec;
1202       l_web_rec := p_web_rec;
1203 
1204       -- Validate the contact point record - call the old routine and the
1205       -- EFT validation routine.
1206       hz_registry_validate_v2pub.validate_contact_point (
1207         p_create_update_flag    => 'U',
1208         p_contact_point_rec     => p_contact_point_rec,
1209         p_edi_rec               => l_edi_rec,
1210         p_email_rec             => l_email_rec,
1211         p_phone_rec             => l_phone_rec,
1212         p_telex_rec             => l_telex_rec,
1213         p_web_rec               => l_web_rec,
1214         p_rowid                 => l_rowid,
1215         x_return_status         => x_return_status);
1216 
1217       IF x_return_status <> fnd_api.g_ret_sts_success THEN
1218         RAISE fnd_api.g_exc_error;
1219       END IF;
1220 
1221       hz_registry_validate_v2pub.validate_eft_contact_point (
1222         p_create_update_flag    => 'U',
1223         p_contact_point_rec     => p_contact_point_rec,
1224         p_eft_rec               => l_eft_rec,
1225         p_rowid                 => l_rowid,
1226         x_return_status         => x_return_status);
1227     END IF;
1228 
1229     IF x_return_status <> fnd_api.g_ret_sts_success THEN
1230       RAISE fnd_api.g_exc_error;
1231     END IF;
1232 
1233     -- If raw_phone_number is passed in, call procedure phone_format.
1234     -- either raw_phone_number or phone_number should be passed in
1235     -- but can not be both. If raw_phone_number does not have a value,
1236     -- it will be set by phone_number and phone_area_code.
1237     -- We cannot re-format raw_phone_number if only phone_country_code
1238     -- is changed because raw_phone_number might not have been formatted
1239     -- and created by concat phone_area_code and phone_number.
1240 
1241     -- contact_point_type, owner_table_name, owner_table_id,
1242     -- actual_content_source are non-updateable columns.
1243 
1244     IF l_contact_point_type = 'PHONE' THEN
1245       IF l_phone_rec.phone_country_code IS NOT NULL THEN
1246         IF l_phone_rec.phone_country_code = fnd_api.g_miss_char THEN
1247           l_phone_country_code := NULL;
1248         ELSE
1249           l_phone_country_code := l_phone_rec.phone_country_code;
1250         END IF;
1251       END IF;
1252 
1253       IF l_phone_rec.phone_area_code IS NOT NULL THEN
1254         IF l_phone_rec.phone_area_code = fnd_api.g_miss_char THEN
1255           l_phone_area_code := NULL;
1256         ELSE
1257           l_phone_area_code := l_phone_rec.phone_area_code;
1258         END IF;
1259       END IF;
1260 
1261       IF l_phone_rec.phone_number IS NOT NULL THEN
1262         IF l_phone_rec.phone_number = fnd_api.g_miss_char THEN
1263           l_phone_number := NULL;
1264         ELSE
1265           l_phone_number := l_phone_rec.phone_number;
1266         END IF;
1267       END IF;
1268 
1269       IF l_phone_rec.raw_phone_number IS NOT NULL AND
1270          l_phone_rec.raw_phone_number <> fnd_api.g_miss_char THEN
1271 
1272          IF l_phone_rec.phone_country_code is not null AND
1273             l_phone_rec.phone_country_code <> fnd_api.g_miss_char
1274          THEN
1275             BEGIN
1276               select territory_code into l_country_code
1277               from hz_phone_country_codes
1278               where phone_country_code = l_phone_rec.phone_country_code
1279               and rownum = 1;
1280             EXCEPTION
1281               WHEN NO_DATA_FOUND THEN
1282                NULL;
1283             END;
1284          ELSIF l_owner_table_name = 'HZ_PARTY_SITES' AND
1285                l_phone_country_code IS NULL THEN
1286                OPEN c_country (l_owner_table_id);
1287                FETCH c_country INTO l_country_code;
1288 
1289                IF c_country%NOTFOUND THEN
1290                  CLOSE c_country;
1291                  RAISE NO_DATA_FOUND;
1292                ELSE
1293                  CLOSE c_country;
1294                END IF;
1295          ELSE
1296            l_country_code := NULL;
1297          END IF;
1298 
1299          -- Since phone_format cannot format raw_phone_number and phone_number
1300          -- at same time, the input value of phone_number and phone_area_code
1301          -- shoule be NULL or G_MISS before the call.
1302 
1303          l_message_count := fnd_msg_pub.count_msg();
1304 
1305          phone_format (
1306            p_raw_phone_number                  => l_phone_rec.raw_phone_number,
1307            p_territory_code                    => l_country_code,
1308            x_formatted_phone_number            => l_formatted_phone_number,
1309            x_phone_country_code                => l_phone_country_code,
1310            x_phone_area_code                   => l_phone_rec.phone_area_code,
1311            x_phone_number                      => l_phone_rec.phone_number,
1312            x_return_status                     => x_return_status,
1313            x_msg_count                         => l_msg_count,
1314            x_msg_data                          => l_msg_data);
1315 
1316          -- Raise exception only if content_source_type = G_MISS_CONTENT_SOURCE_TYPE.
1317          -- For other sources, we do not want to error out, but simply store the
1318          -- Raw Phone Number.
1319 
1320          /* Bug 3711740 */
1321          IF l_phone_rec.phone_area_code IS NULL THEN
1322              l_phone_rec.phone_area_code := fnd_api.g_miss_char;
1323          END IF;
1324 
1325          IF l_phone_rec.phone_number IS NULL THEN
1326              l_phone_rec.phone_number := fnd_api.g_miss_char;
1327          END IF;
1328 
1329          -- Bug 2197181 : content_source_type is obsolete and replaced by
1330          -- actual_content_source
1331 
1332          IF x_return_status <> fnd_api.g_ret_sts_success THEN
1333            IF db_actual_content_source = g_miss_content_source_type
1334            THEN
1335              IF x_return_status = fnd_api.g_ret_sts_error THEN
1336                RAISE fnd_api.g_exc_error;
1337              ELSE
1338                RAISE fnd_api.g_exc_unexpected_error;
1339              END IF;
1340            ELSE
1341              FOR i IN 1..(l_msg_count - l_message_count) LOOP
1342                fnd_msg_pub.delete_msg(l_msg_count - l_message_count + 1 - i);
1343              END LOOP;
1344              x_return_status := fnd_api.g_ret_sts_success;
1345            END IF;
1346          ELSE
1347            l_phone_number := l_phone_rec.phone_number;
1348            l_phone_area_code := l_phone_rec.phone_area_code;
1349 
1350            IF l_phone_country_code IS NOT NULL THEN
1351              l_phone_rec.phone_country_code := l_phone_country_code;
1352            ELSE
1353              l_phone_rec.phone_country_code := FND_API.G_MISS_CHAR; /*Bug 3711740*/
1354            END IF;
1355          END IF;
1356       ELSE
1357         -- raw_phone_number must always have value.
1358 
1359         IF l_phone_area_code IS NULL THEN
1360           l_phone_rec.raw_phone_number := l_phone_number;
1361         ELSE
1362           l_phone_rec.raw_phone_number :=
1363             l_phone_area_code || '-' || l_phone_number;
1364         END IF;
1365       END IF;
1366 
1367       -- Debug info.
1368       IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
1369            hz_utility_v2pub.debug(p_message=>'phone_number = ' || l_phone_rec.phone_number || ' ' ||
1370           'raw_phone_number = ' || l_phone_rec.raw_phone_number,
1371                                   p_prefix =>l_debug_prefix,
1372                                   p_msg_level=>fnd_log.level_statement);
1373       END IF;
1374 
1375 
1376       -- Populate transposed_phone_number
1377       IF l_phone_country_code IS NOT NULL THEN
1378         l_transposed_phone_number := l_phone_country_code;
1379       END IF;
1380 
1381       IF l_phone_area_code IS NOT NULL THEN
1382         l_transposed_phone_number := l_transposed_phone_number ||
1383                                      l_phone_area_code;
1384       END IF;
1385 
1386       IF l_phone_number IS NOT NULL THEN
1387         l_transposed_phone_number := l_transposed_phone_number ||
1388                                      l_phone_number;
1389       END IF;
1390 
1391       IF l_transposed_phone_number IS NOT NULL THEN
1392         l_transposed_phone_number :=
1393           hz_phone_number_pkg.transpose(l_transposed_phone_number);
1394       END IF;
1395 
1396       -- Debug info.
1397       IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
1398            hz_utility_v2pub.debug(p_message=>'transposed_phone_number = ' || l_transposed_phone_number,
1399                                   p_prefix =>l_debug_prefix,
1400                                   p_msg_level=>fnd_log.level_statement);
1401     END IF;
1402 
1403     END IF;
1404 
1405     -- Cannot set an inactive contact point as primary. This validation
1406     -- has been checked in validate_contact_point procedure.
1407 
1408     -- Ignore the value of primary contact flag if the flag has been set
1409     -- to 'N' or fnd_api.g_miss_char by setting primary flag to NULL.
1410     -- User can not unset primary flag by passing value. To unset a
1411     -- primary contact, he/she needs to select another contact as priamry
1412     -- or set the current one to Inactive.
1413 
1414     IF p_contact_point_rec.primary_flag = 'N' OR
1415        p_contact_point_rec.primary_flag = fnd_api.g_miss_char
1416     THEN
1417       p_contact_point_rec.primary_flag := NULL;
1418     END IF;
1419 
1420     -- Bug 2197181: added for mix-n-match project: the primary flag
1421     -- can be set to 'Y' only if the contact point will be visible. If
1422     -- it is not visible, the flag must be reset to 'N'.
1423 
1424     -- Set the first, visible, active contact point as primary.
1425 
1426     -- SSM SST Integration and Extension
1427     -- For non-profile entities, the concept of select/de-select data-sources is obsoleted.
1428     -- There is no need to check if the data-source is selected.
1429 
1430     IF (p_contact_point_rec.status IS NULL AND
1431         l_status = 'A') OR
1432         p_contact_point_rec.status = 'A'
1433     THEN
1434       IF p_contact_point_rec.primary_flag = 'Y' AND
1435          l_primary_flag <> 'Y'
1436       THEN
1437         -- Bug 2197181: added for mix-n-match project
1438      -- IF g_cpt_is_datasource_selected = 'Y' THEN
1439           -- Unmark previous primary contact point.
1440           do_unset_prim_contact_point (
1441             l_owner_table_name,
1442             l_owner_table_id,
1443             l_contact_point_type,
1444             p_contact_point_rec.contact_point_id, 'U');
1445      -- ELSE
1446      --   p_contact_point_rec.primary_flag := 'N';
1447      -- END IF;
1448       ELSIF l_primary_flag <> 'Y' THEN
1449         -- Bug 2117973: changed to use a cursor instead of select...into.
1450         OPEN c_setpf(l_owner_table_name,
1451                      l_owner_table_id,
1452                      l_contact_point_type);
1453         FETCH c_setpf INTO l_dummy;
1454 
1455         -- SSM SST Integration and Extension
1456 	-- For non-profile entities, the concept of select/de-select data-sources is obsoleted.
1457 	-- There is no need to check if the data-source is selected.
1458 
1459         IF c_setpf%NOTFOUND /*AND
1460            -- Bug 2197181: added for mix-n-match project
1461            g_cpt_is_datasource_selected = 'Y'*/
1462         THEN
1463           -- First visible, active contact point per type for this entity
1464           p_contact_point_rec.primary_flag := 'Y';
1465         ELSE
1466           p_contact_point_rec.primary_flag := 'N';
1467         END IF;
1468 
1469         CLOSE c_setpf;
1470       END IF;
1471 
1472       -- De-normalize primary contact point to HZ_PARTIES.
1473       -- url is mandatory if contact_point_type = 'WEB'.
1474       -- email_address is mandatory if contact_point_type = 'EMAIL'.
1475 
1476       -- Bug 2197181: commented out NOCOPY the data source checking. We will
1477       -- denormalize to hz_parties as long as it's a primary contact
1478       -- point regardless of data source.
1479 
1480       IF (p_contact_point_rec.primary_flag = 'Y' OR
1481           l_primary_flag = 'Y') AND
1482          l_owner_table_name = 'HZ_PARTIES' AND
1483          (l_contact_point_type IN ('WEB','EMAIL','PHONE'))
1484          /*  AND
1485          l_content_source_type = hz_party_v2pub.g_miss_content_source_type
1486          */
1487       THEN
1488         IF l_web_rec.url IS NOT NULL THEN
1489           l_url := l_web_rec.url;
1490         END IF;
1491 
1492         IF l_email_rec.email_address IS NOT NULL THEN
1493           l_email_address := l_email_rec.email_address;
1494         END IF;
1495 
1496         --BugNo:1695595.Initialized the local variables with the passed values after validations--
1497 
1498         l_contact_point_id:=p_contact_point_rec.contact_point_id;
1499 
1500         IF p_contact_point_rec.contact_point_purpose=FND_API.G_MISS_CHAR THEN
1501           l_contact_point_purpose := NULL;
1502         ELSIF p_contact_point_rec.contact_point_purpose IS NOT NULL THEN
1503           l_contact_point_purpose := p_contact_point_rec.contact_point_purpose;
1504         END IF;
1505 
1506         IF l_phone_rec.phone_line_type=FND_API.G_MISS_CHAR THEN
1507           l_phone_line_type :=NULL;
1508         ELSIF l_phone_rec.phone_line_type IS NOT NULL THEN
1509           l_phone_line_type := l_phone_rec.phone_line_type;
1510         END IF;
1511 
1512         IF l_phone_rec.phone_country_code=FND_API.G_MISS_CHAR THEN
1513           l_phone_country_code :=NULL;
1514         ELSIF l_phone_rec.phone_country_code IS NOT NULL THEN
1515           l_phone_country_code := l_phone_rec.phone_country_code;
1516         END IF;
1517 
1518         IF l_phone_rec.phone_area_code=FND_API.G_MISS_CHAR THEN
1519           l_phone_area_code :=NULL;
1520         ELSIF l_phone_rec.phone_area_code IS NOT NULL THEN
1521           l_phone_area_code := l_phone_rec.phone_area_code;
1522         END IF;
1523 
1524         IF l_phone_rec.phone_number=FND_API.G_MISS_CHAR THEN
1525           l_phone_number := NULL;
1526         ELSIF l_phone_rec.phone_number IS NOT NULL THEN
1527           l_phone_number := l_phone_rec.phone_number;
1528         END IF;
1529 
1530         IF l_phone_rec.phone_extension=FND_API.G_MISS_CHAR THEN
1531           l_phone_extension :=NULL;
1532         ELSIF l_phone_rec.phone_extension IS NOT NULL THEN
1533           l_phone_extension := l_phone_rec.phone_extension;
1534         END IF;
1535 
1536         ----------------------------------------------------------
1537         do_denormalize_contact_point(l_owner_table_id,
1538                                      l_contact_point_type,
1539                                      l_url,
1540                                      l_email_address,
1541                                      l_contact_point_id,
1542                                      l_contact_point_purpose,
1543                                      l_phone_line_type,
1544                                      l_phone_country_code,
1545                                      l_phone_area_code,
1546                                      l_phone_number,
1547                                      l_phone_extension
1548                                     );
1549       END IF;
1550     ELSE
1551       -- If a primary contact is being marked as inactive then
1552       -- set the current one as non-primary and mark the next
1553       -- active contact as primary
1554 
1555       IF l_status = 'A' AND
1556          p_contact_point_rec.status = 'I' AND
1557          l_primary_flag = 'Y'
1558       THEN
1559 
1560         -- set the current one as non-primary
1561         p_contact_point_rec.primary_flag := 'N';
1562 
1563         -- Bug 2117973: changed to use cursor instead of select...into.
1564         OPEN c_chkdenorm(l_owner_table_name,
1565                          l_owner_table_id,
1566                          l_contact_point_type,
1567                          p_contact_point_rec.contact_point_id);
1568         FETCH c_chkdenorm INTO l_contact_point_rowid, l_url, l_email_address,l_contact_point_id,
1569                                l_contact_point_purpose,l_phone_line_type,l_phone_area_code,
1570                                l_phone_country_code,l_phone_number,l_phone_extension;
1571 
1572         IF c_chkdenorm%NOTFOUND THEN
1573           -- no active contact point of this type left.
1574           -- clear denormalized field in hz_parties.
1575 
1576           IF l_owner_table_name = 'HZ_PARTIES' AND
1577              (l_contact_point_type IN('WEB','EMAIL','PHONE'))
1578              /*AND
1579              l_content_source_type = hz_party_v2pub.g_miss_content_source_type */
1580           THEN
1581             l_url                   :=NULL;
1582             l_email_address         :=NULL;
1583             --Bugno:1695595. Updated the denormalized columns to NULL.
1584             l_contact_point_id      :=NULL;
1585             l_contact_point_purpose :=NULL;
1586             l_phone_line_type       :=NULL;
1587             l_phone_country_code    :=NULL;
1588             l_phone_area_code       :=NULL;
1589             l_phone_number          :=NULL;
1590             l_phone_extension       :=NULL;
1591 
1592 
1593             do_denormalize_contact_point(l_owner_table_id,
1594                                          l_contact_point_type,
1595                                          l_url,
1596                                          l_email_address,
1597                                          l_contact_point_id,
1598                                          l_contact_point_purpose,
1599                                          l_phone_line_type,
1600                                          l_phone_country_code,
1601                                          l_phone_area_code,
1602                                          l_phone_number,
1603                                          l_phone_extension
1604                                         );
1605           END IF;
1606         ELSE
1607           UPDATE hz_contact_points
1608           SET    primary_flag = 'Y'
1609           WHERE  rowid = l_contact_point_rowid;
1610 
1611           -- De-normalize primary contact point to HZ_PARTIES.
1612 
1613           IF l_owner_table_name = 'HZ_PARTIES' AND
1614              (l_contact_point_type IN ('WEB','EMAIL','PHONE'))
1615              /*
1616              l_content_source_type = hz_party_v2pub.g_miss_content_source_type */
1617           THEN
1618             do_denormalize_contact_point(l_owner_table_id,
1619                                          l_contact_point_type,
1620                                          l_url,
1621                                          l_email_address,
1622                                          l_contact_point_id,
1623                                          l_contact_point_purpose,
1624                                          l_phone_line_type,
1625                                          l_phone_country_code,
1626                                          l_phone_area_code,
1627                                          l_phone_number,
1628                                          l_phone_extension
1629                                         );
1630           END IF;
1631         END IF;
1632         CLOSE c_chkdenorm;
1633       END IF;
1634     END IF;
1635 
1636     -- There is only one primary per purpose contact point exist for
1637     -- the combination of owner_table_name, owner_table_id, contact_point_type
1638     -- and contact_point_purpose. If primary_by_purpose is set to 'Y',
1639     -- we need to unset the previous primary per purpose contact point to
1640     -- non-primary. Since setting primary_by_purpose is only making
1641     -- sense when contact_point_purpose has some value, we ignore
1642     -- the primary_by_purpose (setting it to 'N') if contact_point_purpose
1643     -- is NULL.
1644 
1645     -- Bug 2197181: added for mix-n-match project: the primary by purpose
1646     -- flag can be set to 'Y' only if the contact point will be visible.
1647     -- If it is not visible, the flag must be reset to 'N'.
1648 
1649     -- SSM SST Integration and Extension
1650     -- For non-profile entities, the concept of select/de-select data-sources is obsoleted.
1651     -- There is no need to check if the data-source is selected.
1652 
1653     IF (p_contact_point_rec.contact_point_purpose IS NOT NULL AND
1654          p_contact_point_rec.contact_point_purpose <> fnd_api.g_miss_char) OR
1655        (p_contact_point_rec.contact_point_purpose IS NULL AND
1656          l_contact_point_purpose IS NOT NULL)
1657     THEN
1658       IF p_contact_point_rec.contact_point_purpose IS NOT NULL AND
1659          p_contact_point_rec.contact_point_purpose <> fnd_api.g_miss_char
1660       THEN
1661          l_contact_point_purpose := p_contact_point_rec.contact_point_purpose;
1662       END IF;
1663 
1664       --Bug 6755308 Change Start
1665       IF (p_contact_point_rec.primary_by_purpose = 'Y')
1666           /*AND
1667           NVL(l_primary_by_purpose,'N') = 'N') AND
1668           -- Bug 2197181: added for mix-n-match project
1669           g_cpt_is_datasource_selected = 'Y') *//*OR
1670          (p_contact_point_rec.primary_by_purpose IS NULL AND
1671           l_primary_by_purpose = 'Y')*/
1672       --Bug 6755308 Change End
1673       THEN
1674         do_unset_primary_by_purpose(l_owner_table_name,
1675                                      l_owner_table_id,
1676                                      l_contact_point_type,
1677                                      l_contact_point_purpose,
1678                                      p_contact_point_rec.contact_point_id);
1679       ELSIF NVL(l_primary_by_purpose,'N') = 'N' THEN
1680         p_contact_point_rec.primary_by_purpose := 'N';
1681       ELSE
1682         p_contact_point_rec.primary_by_purpose := NULL;
1683       END IF;
1684     ELSE
1685       p_contact_point_rec.primary_by_purpose := 'N';
1686     END IF;
1687 
1688      if (p_contact_point_rec.orig_system is not null
1689          and p_contact_point_rec.orig_system <>fnd_api.g_miss_char)
1690         and (p_contact_point_rec.orig_system_reference is not null
1691          and p_contact_point_rec.orig_system_reference <>fnd_api.g_miss_char)
1692       then
1693                 p_contact_point_rec.orig_system_reference := null;
1694                 -- In mosr, we have bypassed osr nonupdateable validation
1695                 -- but we should not update existing osr, set it to null
1696       end if;
1697 
1698     -- Debug info.
1699     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
1700         hz_utility_v2pub.debug(p_message=>'hz_contact_points_pkg.update_row (+) ',
1701                                p_prefix=>l_debug_prefix,
1702                                p_msg_level=>fnd_log.level_procedure);
1703     END IF;
1704 
1705 --  Bug 4693719 : pass NULL if the secure data is not updated
1706     IF HZ_UTILITY_V2PUB.G_UPDATE_ACS = 'Y' THEN
1707        l_acs := nvl(p_contact_point_rec.actual_content_source, 'USER_ENTERED');
1708     ELSE
1709        l_acs := NULL;
1710     END IF;
1711     -- Call table-handler.
1712     hz_contact_points_pkg.update_row (
1713       x_rowid                           => l_rowid,
1714       x_contact_point_id                => p_contact_point_rec.contact_point_id,
1715       x_contact_point_type              => p_contact_point_rec.contact_point_type,
1716       x_status                          => p_contact_point_rec.status,
1717       x_owner_table_name                => p_contact_point_rec.owner_table_name,
1718       x_owner_table_id                  => p_contact_point_rec.owner_table_id,
1719       x_primary_flag                    => p_contact_point_rec.primary_flag,
1720       x_orig_system_reference           => p_contact_point_rec.orig_system_reference,
1721       x_attribute_category              => p_contact_point_rec.attribute_category,
1722       x_attribute1                      => p_contact_point_rec.attribute1,
1723       x_attribute2                      => p_contact_point_rec.attribute2,
1724       x_attribute3                      => p_contact_point_rec.attribute3,
1725       x_attribute4                      => p_contact_point_rec.attribute4,
1726       x_attribute5                      => p_contact_point_rec.attribute5,
1727       x_attribute6                      => p_contact_point_rec.attribute6,
1728       x_attribute7                      => p_contact_point_rec.attribute7,
1729       x_attribute8                      => p_contact_point_rec.attribute8,
1730       x_attribute9                      => p_contact_point_rec.attribute9,
1731       x_attribute10                     => p_contact_point_rec.attribute10,
1732       x_attribute11                     => p_contact_point_rec.attribute11,
1733       x_attribute12                     => p_contact_point_rec.attribute12,
1734       x_attribute13                     => p_contact_point_rec.attribute13,
1735       x_attribute14                     => p_contact_point_rec.attribute14,
1736       x_attribute15                     => p_contact_point_rec.attribute15,
1737       x_attribute16                     => p_contact_point_rec.attribute16,
1738       x_attribute17                     => p_contact_point_rec.attribute17,
1739       x_attribute18                     => p_contact_point_rec.attribute18,
1740       x_attribute19                     => p_contact_point_rec.attribute19,
1741       x_attribute20                     => p_contact_point_rec.attribute20,
1742       x_edi_transaction_handling        => l_edi_rec.edi_transaction_handling,
1743       x_edi_id_number                   => l_edi_rec.edi_id_number,
1744       x_edi_payment_method              => l_edi_rec.edi_payment_method,
1745       x_edi_payment_format              => l_edi_rec.edi_payment_format,
1746       x_edi_remittance_method           => l_edi_rec.edi_remittance_method,
1747       x_edi_remittance_instruction      => l_edi_rec.edi_remittance_instruction,
1748       x_edi_tp_header_id                => l_edi_rec.edi_tp_header_id,
1749       x_edi_ece_tp_location_code        => l_edi_rec.edi_ece_tp_location_code,
1750       x_eft_transmission_program_id     => l_eft_rec.eft_transmission_program_id,
1751       x_eft_printing_program_id         => l_eft_rec.eft_printing_program_id,
1752       x_eft_user_number                 => l_eft_rec.eft_user_number,
1753       x_eft_swift_code                  => l_eft_rec.eft_swift_code,
1754       x_email_format                    => l_email_rec.email_format,
1755       x_email_address                   => l_email_rec.email_address,
1756       x_phone_calling_calendar          => l_phone_rec.phone_calling_calendar,
1757       x_last_contact_dt_time            => l_phone_rec.last_contact_dt_time,
1758       x_timezone_id                     => l_phone_rec.timezone_id,
1759       x_phone_area_code                 => l_phone_rec.phone_area_code,
1760       x_phone_country_code              => l_phone_rec.phone_country_code,
1761       x_phone_number                    => l_phone_rec.phone_number,
1762       x_phone_extension                 => l_phone_rec.phone_extension,
1763       x_phone_line_type                 => l_phone_rec.phone_line_type,
1764       x_telex_number                    => l_telex_rec.telex_number,
1765       x_web_type                        => l_web_rec.web_type,
1766       x_url                             => l_web_rec.url,
1767       -- Bug 2197181 : content_source_type is obsolete and it is non-updateable.
1768       x_content_source_type             => NULL,
1769       x_raw_phone_number                => l_phone_rec.raw_phone_number,
1770       x_object_version_number           => p_object_version_number,
1771       x_contact_point_purpose           => p_contact_point_rec.contact_point_purpose,
1772       x_primary_by_purpose              => p_contact_point_rec.primary_by_purpose,
1773       x_created_by_module               => p_contact_point_rec.created_by_module,
1774       x_application_id                  => p_contact_point_rec.application_id,
1775       x_transposed_phone_number         => l_transposed_phone_number,
1776    --  Bug 4693719 : Pass correct value for ACS
1777       x_actual_content_source           => l_acs
1778     );
1779 
1780     -- Debug info.
1781     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
1782         hz_utility_v2pub.debug(p_message=>'hz_contact_points_PKG.Update_Row (-) ',
1783                                p_prefix=>l_debug_prefix,
1784                                p_msg_level=>fnd_log.level_procedure);
1785         hz_utility_v2pub.debug(p_message=>'do_update_contact_point (-)',
1786                                p_prefix=>l_debug_prefix,
1787                                p_msg_level=>fnd_log.level_procedure);
1788     END IF;
1789 
1790   END do_update_contact_point;
1791 
1792   --
1793   -- PRIVATE PROCEDURE do_unset_prim_contact_point
1794   --
1795   -- DESCRIPTION
1796   --     Private procedure to unset previous primary flag.
1797   --
1798   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
1799   --
1800   -- ARGUMENTS
1801   --   IN:
1802   --     p_owner_table_name             Owner table name.
1803   --     p_owner_table_id               Owner table ID.
1804   --     p_contact_point_type           Contact point type.
1805   --     p_contact_point_id             Contact point id.
1806   --     p_mode                         Mode of Operation.
1807   --
1808   -- NOTES
1809   --
1810   -- MODIFICATION HISTORY
1811   --
1812   --   07-23-2001    Jianying Huang      o Created.
1813   --   09-30-2003    Rajib Ranjan Borah  o Bug 2914238.Updated the who columns
1814   --                                       while updating the HZ_CONTACT_POINT record.
1815   --  28-OCT-2003   Ramesh Ch           Bug#2914238.Removed  created_by and creation_date
1816   --                                    columns during update.
1817   --  11-JUL-2006   avjha               Bug 5203798: Populate BOT incase of direct update.
1818   PROCEDURE do_unset_prim_contact_point (
1819     p_owner_table_name                      IN     VARCHAR2,
1820     p_owner_table_id                        IN     NUMBER,
1821     p_contact_point_type                    IN     VARCHAR2,
1822     p_contact_point_id                      IN     NUMBER,
1823     p_mode			                    IN     VARCHAR2
1824   ) IS
1825 
1826 --bug #5203798
1827     CURSOR c_contact_point IS
1828       SELECT contact_point_id
1829       FROM   hz_contact_points CP
1830       WHERE CP.owner_table_name = p_owner_table_name
1831 	AND	CP.owner_table_id = p_owner_table_id
1832 	AND 	CP.contact_point_type = p_contact_point_type
1833 	AND 	CP.contact_point_id <> p_contact_point_id
1834       AND   CP.primary_flag = 'Y'
1835       AND   ROWNUM = 1
1836       FOR UPDATE NOWAIT;
1837 
1838     l_contact_point_id                      NUMBER;
1839     l_debug_prefix                         VARCHAR2(30) := '';
1840     l_unset_prim_contact_point_id           NUMBER;
1841 
1842   BEGIN
1843 
1844     -- Debug info.
1845     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
1846         hz_utility_v2pub.debug(p_message=>'do_unset_prim_contact_point (+)',
1847                                p_prefix=>l_debug_prefix,
1848                                p_msg_level=>fnd_log.level_procedure);
1849     END IF;
1850 
1851     BEGIN
1852       OPEN c_contact_point;
1853       FETCH c_contact_point INTO l_unset_prim_contact_point_id;
1854       CLOSE c_contact_point;
1855     END;
1856 
1857     -- Check during insert.
1858     IF p_contact_point_id IS NULL THEN
1859       l_contact_point_id := fnd_api.g_miss_num;
1860     ELSE
1861       l_contact_point_id := p_contact_point_id;
1862     END IF;
1863 
1864     UPDATE hz_contact_points
1865     SET    primary_flag         = 'N',
1866       --Bug number 2914238 .Updated the who columns.
1867            last_update_date     = hz_utility_v2pub.last_update_date,
1868            last_updated_by      = hz_utility_v2pub.last_updated_by,
1869            last_update_login    = hz_utility_v2pub.last_update_login,
1870            request_id           = hz_utility_v2pub.request_id,
1871            program_id           = hz_utility_v2pub.program_id,
1872            program_application_id = hz_utility_v2pub.program_application_id,
1873            program_update_date  = hz_utility_v2pub.program_update_date
1874     WHERE  owner_table_name = p_owner_table_name
1875     AND owner_table_id = p_owner_table_id
1876     AND contact_point_type = p_contact_point_type
1877     AND contact_point_id <> l_contact_point_id
1878     -- AND content_source_type = hz_party_v2pub.g_miss_content_source_type
1879     AND primary_flag = 'Y';
1880 
1881 --bug #5203798
1882       IF(HZ_UTILITY_V2PUB.G_EXECUTE_API_CALLOUTS in ('EVENTS_ENABLED', 'BO_EVENTS_ENABLED')) THEN
1883         -- populate function for integration service
1884         HZ_POPULATE_BOT_PKG.pop_hz_contact_points(
1885           p_operation     => p_mode,
1886           p_contact_point_id => l_unset_prim_contact_point_id);
1887       END IF;
1888 
1889     -- Debug info.
1890     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
1891         hz_utility_v2pub.debug(p_message=>'do_unset_prim_contact_point (-)',
1892                                p_prefix=>l_debug_prefix,
1893                                p_msg_level=>fnd_log.level_procedure);
1894     END IF;
1895 
1896   END do_unset_prim_contact_point;
1897 
1898   --
1899   -- PRIVATE PROCEDURE do_denormalize_contact_point
1900   --
1901   -- DESCRIPTION
1902   --   Private procedure to denormalize some type of contact point to hz_parties.
1903   --
1904   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
1905   --
1906   -- ARGUMENTS
1907   --   IN:
1908   --     p_party_id                     Party ID.
1909   --     p_contact_point_type           Contact point type.
1910   --     p_url                          URL.
1911   --     p_email_address                Email address.
1912   --   BugNo:1695595
1913   --     p_phone_contact_pt_id          Contact point id.
1914   --     p_phone_purpose                Contact Point Purpose.
1915   --     p_phone_line_type              Phone line type.
1916   --     p_phone_country_code           Phone country code.
1917   --     p_phone_area_code              Phone area code.
1918   --     p_phone_number                 Phone Number.
1919   --     p_phone_extension              Phone extension.
1920   -- NOTES
1921   --
1922   -- MODIFICATION HISTORY
1923   --
1924   --   07-23-2001    Jianying Huang      o Created.
1925   --   08-19-2003    Ramesh.Ch           o Modified the
1926   --                                       Signature and logic.
1927   --   05-05-2006    Praveen Kasturi     o Bug No 4355133 :  Truncated the value in p_email_address
1928   --					   before updating the table to support RFC standards.
1929 
1930   PROCEDURE do_denormalize_contact_point (
1931     p_party_id                              IN     NUMBER,
1932     p_contact_point_type                    IN     VARCHAR2,
1933     p_url                                   IN     VARCHAR2,
1934     p_email_address                         IN     VARCHAR2,
1935     p_phone_contact_pt_id                   IN     NUMBER,
1936     p_phone_purpose                         IN     VARCHAR2,
1937     p_phone_line_type                       IN     VARCHAR2,
1938     p_phone_country_code                    IN     VARCHAR2,
1939     p_phone_area_code                       IN     VARCHAR2,
1940     p_phone_number                          IN     VARCHAR2,
1941     p_phone_extension                       IN     VARCHAR2
1942   ) IS
1943   l_debug_prefix                       VARCHAR2(30) := '';
1944   BEGIN
1945     -- Debug info.
1946     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
1947         hz_utility_v2pub.debug(p_message=>'do_denormalize_contact_point (+)',
1948                                p_prefix=>l_debug_prefix,
1949                                p_msg_level=>fnd_log.level_procedure);
1950     END IF;
1951     IF fnd_log.level_statement>=fnd_log.g_current_runtime_level THEN
1952            hz_utility_v2pub.debug(p_message=>'party_id = ' || p_party_id || ' ' ||
1953                                         'contact_point_type = ' || p_contact_point_type || ' ' ||
1954                                         'url = ' || p_url || ' ' ||
1955                                         'email_address = ' || p_email_address||
1956                                         'primary_phone_contact_pt_id = ' || p_phone_contact_pt_id || ' ' ||
1957                                         'primary_phone_purpose = ' || p_phone_purpose || ' ' ||
1958                                         'primary_phone_line_type = ' || p_phone_line_type || ' ' ||
1959                                         'primary_phone_country_code = ' || p_phone_country_code || ' ' ||
1960                                         'primary_phone_area_code = ' || p_phone_area_code || ' ' ||
1961                                         'primary_phone_number = ' || p_phone_number || ' ' ||
1962                                         'primary_phone_extension = ' || p_phone_extension  ,
1963                                   p_prefix =>l_debug_prefix,
1964                                   p_msg_level=>fnd_log.level_statement);
1965     END IF;
1966 
1967 
1968     IF p_contact_point_type = 'WEB' THEN
1969       UPDATE hz_parties
1970       SET    url                       = p_url,
1971              last_update_date          = hz_utility_v2pub.last_update_date,
1972              last_updated_by           = hz_utility_v2pub.last_updated_by,
1973              last_update_login         = hz_utility_v2pub.last_update_login,
1974              request_id                = hz_utility_v2pub.request_id,
1975              program_application_id    = hz_utility_v2pub.program_application_id,
1976              program_id                = hz_utility_v2pub.program_id,
1977              program_update_date       = sysdate
1978       WHERE  party_id = p_party_id;
1979     ELSIF p_contact_point_type = 'EMAIL' THEN
1980       UPDATE hz_parties
1981 					/* Bug No : 4355133*/
1982       SET    email_address             = SUBSTRB(p_email_address,1,320),
1983              last_update_date          = hz_utility_v2pub.last_update_date,
1984              last_updated_by           = hz_utility_v2pub.last_updated_by,
1985              last_update_login         = hz_utility_v2pub.last_update_login,
1986              request_id                = hz_utility_v2pub.request_id,
1987              program_application_id    = hz_utility_v2pub.program_application_id,
1988              program_id                = hz_utility_v2pub.program_id,
1989              program_update_date       = sysdate
1990       WHERE  party_id = p_party_id;
1991     ELSIF p_contact_point_type = 'PHONE' THEN
1992       UPDATE hz_parties
1993       SET    primary_phone_contact_pt_id       = p_phone_contact_pt_id,
1994              primary_phone_purpose             = p_phone_purpose,
1995              primary_phone_line_type           = p_phone_line_type,
1996              primary_phone_country_code        = p_phone_country_code,
1997              primary_phone_area_code           = p_phone_area_code,
1998              primary_phone_number              = p_phone_number,
1999              primary_phone_extension           = p_phone_extension,
2000              last_update_date          = hz_utility_v2pub.last_update_date,
2001              last_updated_by           = hz_utility_v2pub.last_updated_by,
2002              last_update_login         = hz_utility_v2pub.last_update_login,
2003              request_id                = hz_utility_v2pub.request_id,
2004              program_application_id    = hz_utility_v2pub.program_application_id,
2005              program_id                = hz_utility_v2pub.program_id,
2006              program_update_date       = sysdate
2007       WHERE  party_id = p_party_id;
2008     END IF;
2009 
2010     -- Debug info.
2011     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2012         hz_utility_v2pub.debug(p_message=>'do_denormalize_contact_point (-)',
2013                                p_prefix=>l_debug_prefix,
2014                                p_msg_level=>fnd_log.level_procedure);
2015     END IF;
2016 
2017   END do_denormalize_contact_point;
2018 
2019   --
2020   -- PRIVATE PROCEDURE do_unset_primary_by_purpose
2021   --
2022   -- DESCRIPTION
2023   --     Private procedure to unset previous primary by purpose flag.
2024   --
2025   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2026   --
2027   -- ARGUMENTS
2028   --   IN:
2029   --     p_owner_table_name             Owner table name.
2030   --     p_owner_table_id               Owner table ID.
2031   --     p_contact_point_type           Contact point type.
2032   --     p_contact_point_purpose        Contact point purpose.
2033   --     p_contact_point_id             Contact point id.
2034   --
2035   -- NOTES
2036   --
2037   -- MODIFICATION HISTORY
2038   --
2039   --   07-23-2001    Jianying Huang      o Created.
2040   --   28-OCT-2003   Ramesh Ch           Bug#2914238. Updated the who columns in
2041   --                                     do_unset_primary_by_purpose
2042   --
2043   --
2044 
2045   PROCEDURE do_unset_primary_by_purpose (
2046     p_owner_table_name                      IN     VARCHAR2,
2047     p_owner_table_id                        IN     NUMBER,
2048     p_contact_point_type                    IN     VARCHAR2,
2049     p_contact_point_purpose                 IN     VARCHAR2,
2050     p_contact_point_id                      IN     NUMBER
2051   ) IS
2052 
2053     l_contact_point_id                      NUMBER;
2054     l_debug_prefix                     VARCHAR2(30) := '';
2055   BEGIN
2056 
2057     -- Debug info.
2058     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2059         hz_utility_v2pub.debug(p_message=>'do_unset_primary_by_purpose (+)',
2060                                p_prefix=>l_debug_prefix,
2061                                p_msg_level=>fnd_log.level_procedure);
2062     END IF;
2063 
2064     -- Check during insert.
2065     IF p_contact_point_id IS NULL THEN
2066       l_contact_point_id := FND_API.G_MISS_NUM;
2067     ELSE
2068       l_contact_point_id := p_contact_point_id;
2069     END IF;
2070 
2071     UPDATE hz_contact_points
2072     SET   primary_by_purpose = 'N',
2073           last_update_date     = hz_utility_v2pub.last_update_date,
2074           last_updated_by      = hz_utility_v2pub.last_updated_by,
2075           last_update_login    = hz_utility_v2pub.last_update_login,
2076           request_id           = hz_utility_v2pub.request_id,
2077           program_id           = hz_utility_v2pub.program_id,
2078           program_application_id = hz_utility_v2pub.program_application_id,
2079           program_update_date  = hz_utility_v2pub.program_update_date
2080     WHERE  owner_table_name = p_owner_table_name
2081     AND owner_table_id = p_owner_table_id
2082     AND contact_point_type = p_contact_point_type
2083     AND contact_point_purpose = p_contact_point_purpose
2084     AND contact_point_id <> l_contact_point_id
2085     -- AND content_source_type = hz_party_v2pub.g_miss_content_source_type
2086     AND primary_by_purpose = 'Y';
2087 
2088     -- Debug info.
2089     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2090         hz_utility_v2pub.debug(p_message=>'do_unset_primary_by_purpose (-)',
2091                                p_prefix=>l_debug_prefix,
2092                                p_msg_level=>fnd_log.level_procedure);
2093     END IF;
2094 
2095   END do_unset_primary_by_purpose;
2096 
2097   --
2098   -- PRIVATE FUNCTION filter_phone_number
2099   --
2100   -- DESCRIPTION
2101   --     Private funcation to filter phone number. It returns filtered phone number
2102   --     based on some translation rule.
2103   --
2104   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2105   --
2106   -- ARGUMENTS
2107   --   IN:
2108   --     p_phone_number                 Phone number.
2109   --     p_isformat                     Use different translation rule.
2110   --
2111   -- NOTES
2112   --
2113   -- MODIFICATION HISTORY
2114   --
2115   --   07-23-2001    Jianying Huang      o Created.
2116   --
2117   --
2118 
2119   FUNCTION filter_phone_number (
2120     p_phone_number                          IN     VARCHAR2,
2121     p_isformat                              IN     NUMBER := 0
2122   ) RETURN VARCHAR2 IS
2123 
2124     l_filtered_number                       VARCHAR2(100);
2125     l_debug_prefix                         VARCHAR2(30) := '';
2126 
2127   BEGIN
2128 
2129     -- Debug info.
2130     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2131         hz_utility_v2pub.debug(p_message=>'filter_phone_number (+)',
2132                                p_prefix=>l_debug_prefix,
2133                                p_msg_level=>fnd_log.level_procedure);
2134     END IF;
2135 
2136     IF p_isformat = 0 THEN
2137       l_filtered_number := TRANSLATE (
2138         p_phone_number,
2139         '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ()- .+''~`\/@#$%^&*_,|}{[]?<>=";:',
2140         '0123456789');
2141     ELSE
2142       l_filtered_number := TRANSLATE (
2143         p_phone_number,
2144         '9012345678ABCDEFGHIJKLMNOPQRSTUVWXYZ()- .+''~`\/@#$%^&*_,|}{[]?<>=";:',
2145         '9');
2146     END IF;
2147 
2148     -- Debug info.
2149     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2150         hz_utility_v2pub.debug(p_message=>'filter_phone_number (-)',
2151                                p_prefix=>l_debug_prefix,
2152                                p_msg_level=>fnd_log.level_procedure);
2153     END IF;
2154 
2155     RETURN l_filtered_number;
2156 
2157   END filter_phone_number;
2158 
2159   --
2160   -- PRIVATE PROCEDURE get_phone_format
2161   --
2162   -- DESCRIPTION
2163   --     Private procedure to get phone format.
2164   --
2165   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2166   --
2167   -- ARGUMENTS
2168   --   IN:
2169   --     p_phone_number                 Phone number.
2170   --     p_isformat                     Use different translation rule.
2171   --
2172   -- NOTES
2173   --
2174   -- MODIFICATION HISTORY
2175   --
2176   --   07-23-2001    Jianying Huang      o Created.
2177   --
2178   --
2179 
2180   PROCEDURE get_phone_format (
2181     p_raw_phone_number          IN     VARCHAR2 := fnd_api.g_miss_char,
2182     p_territory_code            IN     VARCHAR2 := fnd_api.g_miss_char,
2183     p_area_code                 IN     VARCHAR2,
2184     x_phone_country_code        OUT NOCOPY    VARCHAR2,
2185     x_phone_format_style        OUT NOCOPY    VARCHAR2,
2186     x_area_code_size            OUT NOCOPY    VARCHAR2,
2187     x_include_country_code      OUT NOCOPY    BOOLEAN,
2188     x_msg                       OUT NOCOPY    VARCHAR2
2189   ) IS
2190 
2191     l_defaut_prefix             VARCHAR2(30) := ''; -- get_phone_format
2192 
2193     l_empty                     BOOLEAN;
2194 
2195     -- Query all the format styles along with other flags
2196     CURSOR c_formats IS
2197       SELECT pf.phone_format_style, pf.country_code_display_flag,
2198              pf.area_code_size, pcc.phone_country_code
2199       FROM   hz_phone_country_codes pcc, hz_phone_formats pf
2200       WHERE  pcc.territory_code = p_territory_code
2201              AND pcc.territory_code = pf.territory_code;
2202 
2203     l_phone_format_style        hz_phone_formats.phone_format_style%TYPE;
2204     l_area_code_size            NUMBER;
2205     l_phone_country_code        hz_phone_country_codes.phone_country_code%TYPE;
2206     l_country_code_display_flag hz_phone_formats.country_code_display_flag%TYPE;
2207     l_debug_prefix                     VARCHAR2(30) := '';
2208 
2209   BEGIN
2210 
2211     -- Debug info.
2212     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2213         hz_utility_v2pub.debug(p_message=>'get_phone_format (+)',
2214                                p_prefix=>l_debug_prefix,
2215                                p_msg_level=>fnd_log.level_procedure);
2216     END IF;
2217 
2218     -- Initialize return variables
2219     x_phone_format_style := fnd_api.g_miss_char;
2220     x_phone_country_code := fnd_api.g_miss_char;
2221     x_include_country_code := FALSE;
2222 
2223     -- No territory code passed
2224     IF p_territory_code = fnd_api.g_miss_char THEN
2225       x_msg := 'HZ_COUNTRY_CODE_NOT_DEFINED';
2226       RETURN;
2227     END IF;
2228 
2229     -- Open the cursor and check if format styles exist
2230     l_empty := TRUE;
2231 
2232     OPEN c_formats;
2233     LOOP
2234       FETCH c_formats
2235       INTO  l_phone_format_style, l_country_code_display_flag,
2236             l_area_code_size, l_phone_country_code;
2237       IF c_formats%NOTFOUND THEN
2238         IF l_empty THEN
2239           x_msg := 'HZ_COUNTRY_CODE_NOT_DEFINED';
2240           CLOSE c_formats;
2241           RETURN;
2242         ELSE
2243           EXIT;
2244         END IF;
2245       END IF;
2246 
2247       -- Loop through format styles and select the correct one based on
2248       -- the length of the raw phone number
2249 
2250       IF l_empty THEN
2251         l_empty := FALSE;
2252       END IF;
2253 
2254       IF LENGTHB(filter_phone_number(l_phone_format_style, 1)) =
2255          LENGTHB(p_raw_phone_number)
2256       THEN
2257         IF p_area_code IS NULL OR
2258            (p_area_code IS NOT NULL AND
2259              LENGTHB(p_area_code) = l_area_code_size)
2260         THEN
2261           x_phone_format_style := l_phone_format_style;
2262           IF l_country_code_display_flag = 'Y' THEN
2263             x_include_country_code := TRUE;
2264           END IF;
2265 
2266           x_area_code_size := l_area_code_size;
2267           x_phone_country_code := l_phone_country_code;
2268           EXIT;
2269 
2270         END IF;
2271       END IF;
2272 
2273     END LOOP;
2274     CLOSE c_formats;
2275 
2276     -- No appropriate format mask found
2277     IF x_phone_format_style = fnd_api.g_miss_char THEN
2278       x_msg := 'HZ_PHONE_FORMAT_NOT_DEFINED';
2279     END IF;
2280 
2281     -- Debug info.
2282     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2283         hz_utility_v2pub.debug(p_message=>'get_phone_format (-)',
2284                                p_prefix=>l_debug_prefix,
2285                                p_msg_level=>fnd_log.level_procedure);
2286     END IF;
2287 
2288   EXCEPTION
2289     WHEN OTHERS THEN
2290       RAISE fnd_api.g_exc_unexpected_error;
2291 
2292   END get_phone_format;
2293 
2294   --
2295   -- PRIVATE PROCEDURE translate_raw_phone_number
2296   --
2297   -- DESCRIPTION
2298   --     Private procedure to translate raw phone number.
2299   --
2300   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2301   --
2302   -- ARGUMENTS
2303   --   IN:
2304   --     p_raw_phone_number             Raw phone number.
2305   --     p_phone_format_style           Phone format style.
2306   --     p_area_code_size               Phone area code size.
2307   --   OUT:
2308   --     x_formatted_phone_number       Formatted phone number.
2309   --     x_phone_area_code              Phone area code.
2310   --     x_phone_number                 Phone number.
2311   --
2312   -- NOTES
2313   --
2314   -- MODIFICATION HISTORY
2315   --
2316   --   07-23-2001    Jianying Huang      o Created.
2317   --
2318   --
2319 
2320   PROCEDURE translate_raw_phone_number (
2321     p_raw_phone_number        IN     VARCHAR2 := fnd_api.g_miss_char,
2322     p_phone_format_style      IN     VARCHAR2 := fnd_api.g_miss_char,
2323     p_area_code_size          IN     NUMBER := 0,
2324     x_formatted_phone_number  OUT NOCOPY    VARCHAR2,
2325     x_phone_area_code         OUT NOCOPY    VARCHAR2,
2326     x_phone_number            OUT NOCOPY    VARCHAR2
2327   ) IS
2328 
2329     l_debug_prefix            VARCHAR2(30) := ''; -- translate_raw_phone_number
2330 
2331     l_phone_counter           NUMBER := 1;
2332     l_format_length           NUMBER;
2333     l_format_char             VARCHAR2(1);
2334 
2335   BEGIN
2336 
2337     -- Debug info.
2338     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2339         hz_utility_v2pub.debug(p_message=>'translate_raw_phone_number (+)',
2340                                p_prefix=>l_debug_prefix,
2341                                p_msg_level=>fnd_log.level_procedure);
2342     END IF;
2343 
2344     l_format_length := LENGTHB(p_phone_format_style);
2345     x_formatted_phone_number := '';
2346 
2347     -- Loop through each character of the phone format string
2348     -- and construct the formatted phone number
2349 
2350     FOR i IN 1..l_format_length LOOP
2351       l_format_char := SUBSTRB(p_phone_format_style, i, 1);
2352 
2353       IF l_format_char = '9' THEN
2354         x_formatted_phone_number := x_formatted_phone_number ||
2355                                     SUBSTRB(p_raw_phone_number,
2356                                             l_phone_counter, 1);
2357         l_phone_counter := l_phone_counter + 1;
2358       ELSE
2359         x_formatted_phone_number := x_formatted_phone_number || l_format_char;
2360       END IF;
2361     END LOOP;
2362 
2363     -- Parse out NOCOPY the area code and phone number components
2364     x_phone_area_code := SUBSTRB(p_raw_phone_number, 1, p_area_code_size);
2365     x_phone_number := SUBSTRB(p_raw_phone_number, p_area_code_size + 1);
2366 
2367     -- Debug info.
2368     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2369         hz_utility_v2pub.debug(p_message=>'translate_raw_phone_number (-)',
2370                                p_prefix=>l_debug_prefix,
2371                                p_msg_level=>fnd_log.level_procedure);
2372     END IF;
2373 
2374   END translate_raw_phone_number;
2375 
2376   --
2377   -- PROCEDURE get_contact_point_main
2378   --
2379   -- DESCRIPTION
2380   --     Cets contact point record.
2381   --
2382   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2383   --     hz_contact_points_PKG.Select_Row
2384   --
2385   -- ARGUMENTS
2386   --   IN:
2387   --     p_init_msg_list      Initialize message stack if it is set to
2388   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
2389   --     p_contact_point_id   Contact point ID.
2390   --   IN/OUT:
2391   --   OUT:
2392   --     x_contact_point_rec  Returned contact point record.
2393   --     x_edi_rec            Returned EDI record.
2394   --     x_eft_rec            Returned EFT record.
2395   --     x_email_rec          Returned email record.
2396   --     x_phone_rec          Returned phone record.
2397   --     x_telex_rec          Returned telex record.
2398   --     x_web_rec            Returned web record.
2399   --     x_return_status      Return status after the call. The status can
2400   --                          be fnd_api.g_ret_sts_success (success),
2401   --                          fnd_api.g_ret_sts_error (error),
2402   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
2403   --     x_msg_count          Number of messages in message stack.
2404   --     x_msg_data           Message text if x_msg_count is 1.
2405   --
2406   -- NOTES
2407   --
2408   -- MODIFICATION HISTORY
2409   --
2410   --   07-23-2001    Jianying Huang      o Created.
2411   --   19-NOV-2001   Joe del Callar      Bug 2116225: Added support for
2412   --                                     Bank Consolidation.
2413   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
2414   --                                     enhanced backward compatibility.
2415   --
2416 
2417   PROCEDURE get_contact_point_main (
2418     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
2419     p_contact_point_id          IN     NUMBER,
2420     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
2421     x_edi_rec                   OUT    NOCOPY edi_rec_type,
2422     x_eft_rec                   OUT    NOCOPY eft_rec_type,
2423     x_email_rec                 OUT    NOCOPY email_rec_type,
2424     x_phone_rec                 OUT    NOCOPY phone_rec_type,
2425     x_telex_rec                 OUT    NOCOPY telex_rec_type,
2426     x_web_rec                   OUT    NOCOPY web_rec_type,
2427     x_return_status             OUT NOCOPY    VARCHAR2,
2428     x_msg_count                 OUT NOCOPY    NUMBER,
2429     x_msg_data                  OUT NOCOPY    VARCHAR2
2430   ) IS
2431 
2432     l_transposed_phone_number   hz_contact_points.transposed_phone_number%TYPE;
2433     l_contact_point_rec         hz_contact_points%ROWTYPE;
2434     l_debug_prefix              VARCHAR2(30) := '';
2435   BEGIN
2436     -- Debug info.
2437 
2438     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2439         hz_utility_v2pub.debug(p_message=>'get_contact_point_main (+)',
2440                                p_prefix=>l_debug_prefix,
2441                                p_msg_level=>fnd_log.level_procedure);
2442     END IF;
2443 
2444     -- Initialize message list if p_init_msg_list is set to TRUE.
2445     IF fnd_api.to_boolean(p_init_msg_list) THEN
2446       fnd_msg_pub.initialize;
2447     END IF;
2448 
2449     -- Initialize API return status to success.
2450     x_return_status := fnd_api.g_ret_sts_success;
2451 
2452     -- Check whether primary key has been passed in.
2453     IF p_contact_point_id IS NULL OR
2454        p_contact_point_id = fnd_api.g_miss_num THEN
2455       fnd_message.set_name('AR', 'HZ_API_MISSING_COLUMN');
2456       fnd_message.set_token('COLUMN', 'contact_point_id');
2457       fnd_msg_pub.add;
2458       RAISE fnd_api.g_exc_error;
2459     END IF;
2460 
2461     x_contact_point_rec.contact_point_id := p_contact_point_id;
2462 
2463     -- Debug info.
2464     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2465         hz_utility_v2pub.debug(p_message=>'hz_contact_points_PKG.Select_Row (+)',
2466                                p_prefix=>l_debug_prefix,
2467                                p_msg_level=>fnd_log.level_procedure);
2468     END IF;
2469 
2470     -- Call table-handler
2471     hz_contact_points_pkg.select_row (
2472       x_contact_point_id                => x_contact_point_rec.contact_point_id,
2473       x_contact_point_type              => x_contact_point_rec.contact_point_type,
2474       x_status                          => x_contact_point_rec.status,
2475       x_owner_table_name                => x_contact_point_rec.owner_table_name,
2476       x_owner_table_id                  => x_contact_point_rec.owner_table_id,
2477       x_primary_flag                    => x_contact_point_rec.primary_flag,
2478       x_orig_system_reference           => x_contact_point_rec.orig_system_reference,
2479       x_attribute_category              => x_contact_point_rec.attribute_category,
2480       x_attribute1                      => x_contact_point_rec.attribute1,
2481       x_attribute2                      => x_contact_point_rec.attribute2,
2482       x_attribute3                      => x_contact_point_rec.attribute3,
2483       x_attribute4                      => x_contact_point_rec.attribute4,
2484       x_attribute5                      => x_contact_point_rec.attribute5,
2485       x_attribute6                      => x_contact_point_rec.attribute6,
2486       x_attribute7                      => x_contact_point_rec.attribute7,
2487       x_attribute8                      => x_contact_point_rec.attribute8,
2488       x_attribute9                      => x_contact_point_rec.attribute9,
2489       x_attribute10                     => x_contact_point_rec.attribute10,
2490       x_attribute11                     => x_contact_point_rec.attribute11,
2491       x_attribute12                     => x_contact_point_rec.attribute12,
2492       x_attribute13                     => x_contact_point_rec.attribute13,
2493       x_attribute14                     => x_contact_point_rec.attribute14,
2494       x_attribute15                     => x_contact_point_rec.attribute15,
2495       x_attribute16                     => x_contact_point_rec.attribute16,
2496       x_attribute17                     => x_contact_point_rec.attribute17,
2497       x_attribute18                     => x_contact_point_rec.attribute18,
2498       x_attribute19                     => x_contact_point_rec.attribute19,
2499       x_attribute20                     => x_contact_point_rec.attribute20,
2500       x_edi_transaction_handling        => x_edi_rec.edi_transaction_handling,
2501       x_edi_id_number                   => x_edi_rec.edi_id_number,
2502       x_edi_payment_method              => x_edi_rec.edi_payment_method,
2503       x_edi_payment_format              => x_edi_rec.edi_payment_format,
2504       x_edi_remittance_method           => x_edi_rec.edi_remittance_method,
2505       x_edi_remittance_instruction      => x_edi_rec.edi_remittance_instruction,
2506       x_edi_tp_header_id                => x_edi_rec.edi_tp_header_id,
2507       x_edi_ece_tp_location_code        => x_edi_rec.edi_ece_tp_location_code,
2508       x_eft_transmission_program_id     => x_eft_rec.eft_transmission_program_id,
2509       x_eft_printing_program_id         => x_eft_rec.eft_printing_program_id,
2510       x_eft_user_number                 => x_eft_rec.eft_user_number,
2511       x_eft_swift_code                  => x_eft_rec.eft_swift_code,
2512       x_email_format                    => x_email_rec.email_format,
2513       x_email_address                   => x_email_rec.email_address,
2514       x_phone_calling_calendar          => x_phone_rec.phone_calling_calendar,
2515       x_last_contact_dt_time            => x_phone_rec.last_contact_dt_time,
2516       x_timezone_id                     => x_phone_rec.timezone_id,
2517       x_phone_area_code                 => x_phone_rec.phone_area_code,
2518       x_phone_country_code              => x_phone_rec.phone_country_code,
2519       x_phone_number                    => x_phone_rec.phone_number,
2520       x_phone_extension                 => x_phone_rec.phone_extension,
2521       x_phone_line_type                 => x_phone_rec.phone_line_type,
2522       x_telex_number                    => x_telex_rec.telex_number,
2523       x_web_type                        => x_web_rec.web_type,
2524       x_url                             => x_web_rec.url,
2525       x_content_source_type             => x_contact_point_rec.content_source_type,
2526       x_raw_phone_number                => x_phone_rec.raw_phone_number,
2527       x_contact_point_purpose           => x_contact_point_rec.contact_point_purpose,
2528       x_primary_by_purpose              => x_contact_point_rec.primary_by_purpose,
2529       x_created_by_module               => x_contact_point_rec.created_by_module,
2530       x_application_id                  => x_contact_point_rec.application_id,
2531       x_transposed_phone_number         => l_transposed_phone_number,
2532       x_actual_content_source           => x_contact_point_rec.actual_content_source
2533     );
2534 
2535     -- Debug info.
2536     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2537         hz_utility_v2pub.debug(p_message=>'HZ_CONTACT_POINTS_PKG.Select_Row (-)',
2538                                p_prefix=>l_debug_prefix,
2539                                p_msg_level=>fnd_log.level_procedure);
2540     END IF;
2541 
2542     -- Standard call to get message count and if count is 1, get message info.
2543     fnd_msg_pub.count_and_get(
2544       p_encoded => fnd_api.g_false,
2545       p_count => x_msg_count,
2546       p_data  => x_msg_data);
2547 
2548     -- Debug info.
2549 
2550     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2551         hz_utility_v2pub.debug(p_message=>'get_contact_point_main (-)',
2552                                p_prefix=>l_debug_prefix,
2553                                p_msg_level=>fnd_log.level_procedure);
2554     END IF;
2555   END get_contact_point_main;
2556 
2557   --
2558   -- PROCEDURE create_contact_point_main
2559   --
2560   -- DESCRIPTION
2561   --     Creates contact point.
2562   --
2563   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2564   --     HZ_BUSINESS_EVENT_V2PVT.create_contact_point_event
2565   --
2566   -- ARGUMENTS
2567   --   IN:
2568   --     p_init_msg_list      Initialize message stack if it is set to
2569   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
2570   --     p_contact_point_rec  Contact point record.
2571   --     p_edi_rec            EDI record.
2572   --     p_eft_rec            EFT record.
2573   --     p_email_rec          Email record.
2574   --     p_phone_rec          Phone record.
2575   --     p_telex_rec          Telex record.
2576   --     p_web_rec            Web record.
2577   --   IN/OUT:
2578   --   OUT:
2579   --     x_contact_point_id   Contact point ID.
2580   --     x_return_status      Return status after the call. The status can
2581   --                          be fnd_api.g_ret_sts_success (success),
2582   --                          fnd_api.g_ret_sts_error (error),
2583   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
2584   --     x_msg_count          Number of messages in message stack.
2585   --     x_msg_data           Message text if x_msg_count is 1.
2586   --
2587   -- NOTES
2588   --
2589   -- MODIFICATION HISTORY
2590   --
2591   --   07-23-2001    Jianying Huang      Created.
2592   --   19-NOV-2001   Joe del Callar      Bug 2116225: Added support for
2593   --                                     Bank Consolidation.
2594   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
2595   --                                     enhanced backward compatibility.
2596   --   01-03-2005  Rajib Ranjan Borah   o SSM SST Integration and Extension.
2597   --                                      For non-profile entities, the concept of
2598   --                                      select/de-select data-sources is obsoleted.
2599 
2600   PROCEDURE create_contact_point_main (
2601     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
2602     p_contact_point_rec         IN     contact_point_rec_type,
2603     p_edi_rec                   IN     edi_rec_type := g_miss_edi_rec,
2604     p_eft_rec                   IN     eft_rec_type := g_miss_eft_rec,
2605     p_email_rec                 IN     email_rec_type := g_miss_email_rec,
2606     p_phone_rec                 IN     phone_rec_type := g_miss_phone_rec,
2607     p_telex_rec                 IN     telex_rec_type := g_miss_telex_rec,
2608     p_web_rec                   IN     web_rec_type := g_miss_web_rec,
2609     x_contact_point_id          OUT NOCOPY    NUMBER,
2610     x_return_status             OUT NOCOPY    VARCHAR2,
2611     x_msg_count                 OUT NOCOPY    NUMBER,
2612     x_msg_data                  OUT NOCOPY    VARCHAR2
2613   ) IS
2614 
2615     l_contact_point_rec         contact_point_rec_type := p_contact_point_rec;
2616     l_edi_rec                   edi_rec_type := p_edi_rec;
2617     l_email_rec                 email_rec_type := p_email_rec;
2618     l_phone_rec                 phone_rec_type := p_phone_rec;
2619     l_telex_rec                 telex_rec_type := p_telex_rec;
2620     l_web_rec                   web_rec_type := p_web_rec;
2621     l_eft_rec                   eft_rec_type := p_eft_rec;
2622 
2623     dss_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2624     dss_msg_count     NUMBER := 0;
2625     dss_msg_data      VARCHAR2(2000):= null;
2626     l_test_security   VARCHAR2(1):= 'F';
2627     l_debug_prefix    VARCHAR2(30) := '';
2628 
2629   BEGIN
2630     -- Debug info.
2631     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2632         hz_utility_v2pub.debug(p_message=>'create_contact_point_main (+)',
2633                                p_prefix=>l_debug_prefix,
2634                                p_msg_level=>fnd_log.level_procedure);
2635     END IF;
2636 
2637     -- Initialize message list if p_init_msg_list is set to TRUE.
2638     IF fnd_api.to_boolean(p_init_msg_list) THEN
2639        fnd_msg_pub.initialize;
2640     END IF;
2641 
2642     -- Initialize API return status to success.
2643     x_return_status := fnd_api.g_ret_sts_success;
2644 
2645     -- Bug 2197181: added for mix-n-match project. first load data
2646     -- sources for this entity. Then assign the actual_content_source
2647     -- to the real data source. The value of content_source_type is
2648     -- depended on if data source is seleted. If it is selected, we reset
2649     -- content_source_type to user-entered. We also check if user
2650     -- has the privilege to create user-entered data if mix-n-match
2651     -- is enabled.
2652 
2653     -- Bug 2444678: Removed caching.
2654 
2655     -- IF g_cpt_mixnmatch_enabled IS NULL THEN
2656     /*
2657      * SSM SST Integration and Extension
2658      * For non-profile entities, the concept of select/de-select data sources is obsoleted.
2659     HZ_MIXNM_UTILITY.LoadDataSources(
2660       p_entity_name                    => 'HZ_CONTACT_POINTS',
2661       p_entity_attr_id                 => g_cpt_entity_attr_id,
2662       p_mixnmatch_enabled              => g_cpt_mixnmatch_enabled,
2663       p_selected_datasources           => g_cpt_selected_datasources );
2664     -- END IF;
2665     */
2666     HZ_MIXNM_UTILITY.AssignDataSourceDuringCreation (
2667       p_entity_name                    => 'HZ_CONTACT_POINTS',
2668       p_entity_attr_id                 => g_cpt_entity_attr_id,
2669       p_mixnmatch_enabled              => g_cpt_mixnmatch_enabled,
2670       p_selected_datasources           => g_cpt_selected_datasources,
2671       p_content_source_type            => l_contact_point_rec.content_source_type,
2672       p_actual_content_source          => l_contact_point_rec.actual_content_source,
2673       x_is_datasource_selected         => g_cpt_is_datasource_selected,
2674       x_return_status                  => x_return_status );
2675 
2676     IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2677       RAISE FND_API.G_EXC_ERROR;
2678     END IF;
2679 
2680     -- Call to business logic.
2681     do_create_contact_point(l_contact_point_rec,
2682                             l_edi_rec,
2683                             l_eft_rec,
2684                             l_email_rec,
2685                             l_phone_rec,
2686                             l_telex_rec,
2687                             l_web_rec,
2688                             x_contact_point_id,
2689                             x_return_status);
2690 
2691     -- Bug 2486394 -Check if the DSS security is granted to the user
2692     -- Bug 3818648: check dss profile before call test_instance
2693     -- Bug 3867562: check dss only in party context
2694 
2695     IF NVL(fnd_profile.value('HZ_DSS_ENABLED'), 'N') = 'Y' AND
2696        l_contact_point_rec.owner_table_name IN ('HZ_PARTIES', 'HZ_PARTY_SITES')
2697     THEN
2698       l_test_security :=
2699            hz_dss_util_pub.test_instance(
2700                   p_operation_code     => 'INSERT',
2701                   p_db_object_name     => 'HZ_CONTACT_POINTS',
2702                   p_instance_pk1_value => x_contact_point_id,
2703                   p_user_name          => fnd_global.user_name,
2704                   x_return_status      => dss_return_status,
2705                   x_msg_count          => dss_msg_count,
2706                   x_msg_data           => dss_msg_data);
2707 
2708       if dss_return_status <> fnd_api.g_ret_sts_success THEN
2709          RAISE FND_API.G_EXC_ERROR;
2710       end if;
2711 
2712       if (l_test_security <> 'T' OR l_test_security <> FND_API.G_TRUE) then
2713         --
2714         -- Bug 3835601: replaced the dss message with a more user friendly message
2715         --
2716         FND_MESSAGE.SET_NAME('AR', 'HZ_DSS_NO_INSERT_PRIVILEGE');
2717         IF l_contact_point_rec.owner_table_name = 'HZ_PARTIES' THEN
2718           FND_MESSAGE.SET_TOKEN('ENTITY_NAME',
2719                                 hz_dss_util_pub.get_display_name(null, 'PARTY_CONTACT_POINTS'));
2720         ELSIF l_contact_point_rec.owner_table_name = 'HZ_PARTY_SITES' THEN
2721           FND_MESSAGE.SET_TOKEN('ENTITY_NAME',
2722                                 hz_dss_util_pub.get_display_name(null, 'PARTY_SITE_CONTACT_POINTS'));
2723         END IF;
2724         FND_MSG_PUB.ADD;
2725         RAISE FND_API.G_EXC_ERROR;
2726       end if;
2727     END IF;
2728 
2729     -- Invoke business event system.
2730 
2731     -- SSM SST Integration and Extension
2732     -- For non-profile entities, the concept of select/de-select data sources is obsoleted.
2733     -- There is no need to check if the data-source is selected.
2734 
2735     IF x_return_status = fnd_api.g_ret_sts_success /*AND
2736        -- Bug 2197181: Added below condition for Mix-n-Match
2737       g_cpt_is_datasource_selected = 'Y'*/
2738     THEN
2739       IF(HZ_UTILITY_V2PUB.G_EXECUTE_API_CALLOUTS in ('Y', 'EVENTS_ENABLED')) THEN
2740         hz_business_event_v2pvt.create_contact_point_event(
2741           l_contact_point_rec,
2742           l_edi_rec,
2743           l_eft_rec,
2744           l_email_rec,
2745           l_phone_rec,
2746           l_telex_rec,
2747           l_web_rec);
2748       END IF;
2749 
2750       IF(HZ_UTILITY_V2PUB.G_EXECUTE_API_CALLOUTS in ('EVENTS_ENABLED', 'BO_EVENTS_ENABLED')) THEN
2751         HZ_POPULATE_BOT_PKG.pop_hz_contact_points(
2752           p_operation        => 'I',
2753           p_contact_point_id => x_contact_point_id);
2754       END IF;
2755       -- Call to indicate contact point creation to DQM
2756       --Bug 4866187
2757       --Bug 5370799
2758       IF (p_contact_point_rec.orig_system IS NULL OR p_contact_point_rec.orig_system=FND_API.G_MISS_CHAR)
2759       THEN
2760          hz_dqm_sync.sync_contact_point(l_contact_point_rec.contact_point_id, 'C');
2761       END IF;
2762     END IF;
2763 
2764     -- Standard call to get message count and if count is 1, get message info.
2765     fnd_msg_pub.count_and_get(
2766       p_encoded => fnd_api.g_false,
2767       p_count => x_msg_count,
2768       p_data  => x_msg_data);
2769 
2770     -- Debug info.
2771     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2772         hz_utility_v2pub.debug(p_message=>'create_contact_point_main (-)',
2773                                p_prefix=>l_debug_prefix,
2774                                p_msg_level=>fnd_log.level_procedure);
2775     END IF;
2776   END create_contact_point_main;
2777 
2778   --
2779   -- PRIVATE PROCEDURE update_contact_point_main
2780   --
2781   -- DESCRIPTION
2782   --     Updates the given contact point.
2783   --
2784   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
2785   --     HZ_BUSINESS_EVENT_V2PVT.update_contact_point_main_event
2786   --
2787   -- ARGUMENTS
2788   --   IN:
2789   --     p_init_msg_list          Initialize message stack if it is set to
2790   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
2791   --     p_contact_point_rec      Contact point record.
2792   --     p_edi_rec                EDI record.
2793   --     p_email_rec              Email record.
2794   --     p_phone_rec              Phone record.
2795   --     p_telex_rec              Telex record.
2796   --     p_web_rec                Web record.
2797   --     p_eft_rec                EFT record.
2798   --   IN/OUT:
2799   --     p_object_version_number  Used for locking the being updated record.
2800   --   OUT:
2801   --     x_return_status          Return status after the call. The status can
2802   --                              be fnd_api.g_ret_sts_success (success),
2803   --                              fnd_api.g_ret_sts_error (error),
2804   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
2805   --     x_msg_count              Number of messages in message stack.
2806   --     x_msg_data               Message text if x_msg_count is 1.
2807   --
2808   -- NOTES
2809   --
2810   -- MODIFICATION HISTORY
2811   --
2812   --   07-23-2001    Jianying Huang      Created.
2813   --   19-NOV-2001   Joe del Callar      Bug 2116225: Added support for
2814   --                                     Bank Consolidation.
2815   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
2816   --                                     enhanced backward compatibility.
2817   --   06-JUL-2004   Rajib Ranjan Borah  Bug 3711740.If phone_area_code/
2818   --                                     phone_country_code is null, then do
2819   --                                     not assign the old value before calling
2820   --                                     hz_timezone_pub.get_phone_timezone_id.
2821 
2822   PROCEDURE update_contact_point_main (
2823     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
2824     p_contact_point_rec         IN     contact_point_rec_type,
2825     p_edi_rec                   IN     edi_rec_type := g_miss_edi_rec,
2826     p_eft_rec                   IN     eft_rec_type := g_miss_eft_rec,
2827     p_email_rec                 IN     email_rec_type := g_miss_email_rec,
2828     p_phone_rec                 IN     phone_rec_type := g_miss_phone_rec,
2829     p_telex_rec                 IN     telex_rec_type := g_miss_telex_rec,
2830     p_web_rec                   IN     web_rec_type := g_miss_web_rec,
2831     p_object_version_number     IN OUT NOCOPY NUMBER,
2832     x_return_status             OUT NOCOPY    VARCHAR2,
2833     x_msg_count                 OUT NOCOPY    NUMBER,
2834     x_msg_data                  OUT NOCOPY    VARCHAR2
2835   ) IS
2836 
2837     l_contact_point_rec         contact_point_rec_type := p_contact_point_rec;
2838     l_edi_rec                   edi_rec_type := p_edi_rec;
2839     l_email_rec                 email_rec_type := p_email_rec;
2840     l_phone_rec                 phone_rec_type := p_phone_rec;
2841     l_telex_rec                 telex_rec_type := p_telex_rec;
2842     l_web_rec                   web_rec_type := p_web_rec;
2843     l_eft_rec                   eft_rec_type := p_eft_rec;
2844 
2845     l_old_contact_point_rec     contact_point_rec_type;
2846     l_old_edi_rec               edi_rec_type;
2847     l_old_email_rec             email_rec_type;
2848     l_old_phone_rec             phone_rec_type;
2849     l_old_telex_rec             telex_rec_type;
2850     l_old_web_rec               web_rec_type;
2851     l_old_eft_rec               eft_rec_type;
2852     l_phone_country_code        HZ_CONTACT_POINTS.phone_country_code%type;
2853     l_phone_area_code           HZ_CONTACT_POINTS.phone_area_code%type;
2854 
2855     l_data_source_from          VARCHAR2(30);
2856 
2857     dss_return_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
2858     dss_msg_count     NUMBER := 0;
2859     dss_msg_data      VARCHAR2(2000):= null;
2860     l_test_security   VARCHAR2(1):= 'F';
2861 
2862     l_return_status             VARCHAR2(1);
2863     l_msg_count                 NUMBER;
2864     l_message_count number;
2865     l_msg_data                  VARCHAR2(2000);
2866     l_changed_flag varchar2(1) := 'N';
2867     l_debug_prefix              VARCHAR2(30) := '';
2868 
2869   BEGIN
2870     -- Debug info.
2871     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
2872         hz_utility_v2pub.debug(p_message=>'update_contact_point_main (+)',
2873                                p_prefix=>l_debug_prefix,
2874                                p_msg_level=>fnd_log.level_procedure);
2875     END IF;
2876 
2877     -- Initialize message list if p_init_msg_list is set to TRUE.
2878     IF fnd_api.to_boolean(p_init_msg_list) THEN
2879       fnd_msg_pub.initialize;
2880     END IF;
2881 
2882     -- Initialize API return status to success.
2883     x_return_status := fnd_api.g_ret_sts_success;
2884 
2885         -- if contact_point_id is not passed in, but orig system parameters are passed in
2886     -- get contact_point_id
2887 
2888       IF (p_contact_point_rec.orig_system is not null
2889          and p_contact_point_rec.orig_system <>fnd_api.g_miss_char)
2890        and (p_contact_point_rec.orig_system_reference is not null
2891          and p_contact_point_rec.orig_system_reference <>fnd_api.g_miss_char)
2892        and (p_contact_point_rec.contact_point_id = FND_API.G_MISS_NUM or p_contact_point_rec.contact_point_id is null) THEN
2893            hz_orig_system_ref_pub.get_owner_table_id
2894                         (p_orig_system => p_contact_point_rec.orig_system,
2895                         p_orig_system_reference => p_contact_point_rec.orig_system_reference,
2896                         p_owner_table_name => 'HZ_CONTACT_POINTS',
2897                         x_owner_table_id => l_contact_point_rec.contact_point_id,
2898                         x_return_status => x_return_status);
2899             IF x_return_status <> fnd_api.g_ret_sts_success THEN
2900                 RAISE FND_API.G_EXC_ERROR;
2901             END IF;
2902       END IF;
2903 
2904 
2905     -- Get old records. Will be used by business event system.
2906     get_contact_point_main (
2907       p_contact_point_id               => l_contact_point_rec.contact_point_id,
2908       x_contact_point_rec              => l_old_contact_point_rec,
2909       x_edi_rec                        => l_old_edi_rec,
2910       x_eft_rec                        => l_old_eft_rec,
2911       x_email_rec                      => l_old_email_rec,
2912       x_phone_rec                      => l_old_phone_rec,
2913       x_telex_rec                      => l_old_telex_rec,
2914       x_web_rec                        => l_old_web_rec,
2915       x_return_status                  => x_return_status,
2916       x_msg_count                      => x_msg_count,
2917       x_msg_data                       => x_msg_data);
2918 
2919     IF x_return_status = fnd_api.g_ret_sts_error THEN
2920       RAISE fnd_api.g_exc_error;
2921     ELSIF x_return_status = fnd_api.g_ret_sts_unexp_error THEN
2922       RAISE fnd_api.g_exc_unexpected_error;
2923     END IF;
2924 
2925     -- Bug 2486394 -Check if the DSS security is granted to the user
2926     -- Bug 3818648: check dss profile before call test_instance
2927     -- Bug 3867562: check dss only in party context
2928 
2929     IF NVL(fnd_profile.value('HZ_DSS_ENABLED'), 'N') = 'Y' AND
2930        l_old_contact_point_rec.owner_table_name IN ('HZ_PARTIES', 'HZ_PARTY_SITES')
2931     THEN
2932       l_test_security :=
2933            hz_dss_util_pub.test_instance(
2934                   p_operation_code     => 'UPDATE',
2935                   p_db_object_name     => 'HZ_CONTACT_POINTS',
2936                   p_instance_pk1_value => l_contact_point_rec.contact_point_id,
2937                   p_user_name          => fnd_global.user_name,
2938                   x_return_status      => dss_return_status,
2939                   x_msg_count          => dss_msg_count,
2940                   x_msg_data           => dss_msg_data);
2941 
2942       if dss_return_status <> fnd_api.g_ret_sts_success THEN
2943          RAISE FND_API.G_EXC_ERROR;
2944       end if;
2945 
2946       if (l_test_security <> 'T' OR l_test_security <> FND_API.G_TRUE) then
2947         --
2948         -- Bug 3835601: replaced the dss message with a more user friendly message
2949         --
2950         FND_MESSAGE.SET_NAME('AR', 'HZ_DSS_NO_UPDATE_PRIVILEGE');
2951         IF l_old_contact_point_rec.owner_table_name = 'HZ_PARTIES' THEN
2952           FND_MESSAGE.SET_TOKEN('ENTITY_NAME',
2953                                 hz_dss_util_pub.get_display_name(null, 'PARTY_CONTACT_POINTS'));
2954         ELSIF l_old_contact_point_rec.owner_table_name = 'HZ_PARTY_SITES' THEN
2955           FND_MESSAGE.SET_TOKEN('ENTITY_NAME',
2956                                 hz_dss_util_pub.get_display_name(null, 'PARTY_SITE_CONTACT_POINTS'));
2957         END IF;
2958         FND_MSG_PUB.ADD;
2959         RAISE FND_API.G_EXC_ERROR;
2960       end if;
2961     END IF;
2962 
2963     -- Bug 2197181: added for mix-n-match project. first load data
2964     -- sources for this entity.
2965 
2966     -- Bug 2444678: Removed caching.
2967 
2968     /* SSM SST Integration and Extension
2969      * For non-profile entities, the concept of select/de-select data-sources is obsoleted.
2970      * There is no need to check if the data-source is selected.
2971 
2972     -- IF g_cpt_mixnmatch_enabled IS NULL THEN
2973     HZ_MIXNM_UTILITY.LoadDataSources(
2974       p_entity_name                    => 'HZ_CONTACT_POINTS',
2975       p_entity_attr_id                 => g_cpt_entity_attr_id,
2976       p_mixnmatch_enabled              => g_cpt_mixnmatch_enabled,
2977       p_selected_datasources           => g_cpt_selected_datasources );
2978     -- END IF;
2979     */
2980 
2981     -- Bug 2197181: added for mix-n-match project.
2982     -- check if the data source is seleted.
2983     /* SSM SST Integration and Extension
2984      * For non-profile entities, the concept of select/de-select data-sources is obsoleted.
2985      * There is no need to check if the data-source is selected.
2986 
2987     g_cpt_is_datasource_selected :=
2988       HZ_MIXNM_UTILITY.isDataSourceSelected (
2989         p_selected_datasources           => g_cpt_selected_datasources,
2990         p_actual_content_source          => l_old_contact_point_rec.actual_content_source );
2991     */
2992     if (l_phone_rec.phone_country_code IS NOT NULL
2993            and l_phone_rec.phone_country_code <> nvl(l_old_phone_rec.phone_country_code,fnd_api.g_miss_char))
2994            or (l_phone_rec.phone_area_code is NOT NULL and l_phone_rec.phone_area_code <> nvl(l_old_phone_rec.phone_area_code,fnd_api.g_miss_char))
2995     then
2996         l_changed_flag := 'Y';
2997     end if;
2998 
2999     if l_changed_flag = 'Y' and ( l_phone_rec.timezone_id is null or l_phone_rec.timezone_id = fnd_api.g_miss_num)
3000     then
3001                 if l_phone_rec.phone_country_code IS NULL
3002                 then
3003                         l_phone_country_code := l_old_phone_rec.phone_country_code;
3004                 else
3005                         l_phone_country_code := l_phone_rec.phone_country_code;
3006                 end if;
3007 
3008                 if l_phone_rec.phone_area_code IS NULL
3009                 then
3010                         l_phone_area_code := l_old_phone_rec.phone_area_code;
3011                 else
3012                         l_phone_area_code := l_phone_rec.phone_area_code;
3013                 end if;
3014                  l_message_count := fnd_msg_pub.count_msg();
3015                  hz_timezone_pub.get_phone_timezone_id(
3016                         p_api_version => 1.0,
3017                         p_init_msg_list => FND_API.G_FALSE,
3018                         p_phone_country_code => l_phone_country_code,
3019                         p_area_code => l_phone_area_code,
3020                         p_phone_prefix => null,
3021                         p_country_code => null,-- don't need to pass in this
3022                         x_timezone_id => l_phone_rec.timezone_id,
3023                         x_return_status => l_return_status ,
3024                         x_msg_count =>l_msg_count ,
3025                         x_msg_data => l_msg_data);
3026                         if l_return_status <> fnd_api.g_ret_sts_success
3027                         then  -- we don't raise error
3028                                 l_phone_rec.timezone_id := fnd_api.g_miss_num;
3029                                 FOR i IN 1..(l_msg_count - l_message_count) LOOP
3030                                     fnd_msg_pub.delete_msg(l_msg_count - l_message_count + 1 - i);
3031                                 END LOOP;
3032                                 l_return_status := FND_API.G_RET_STS_SUCCESS;
3033                         end if;
3034      end if;
3035 
3036     -- Call to business logic.
3037     do_update_contact_point (
3038       l_contact_point_rec,
3039       l_edi_rec,
3040       l_eft_rec,
3041       l_email_rec,
3042       l_phone_rec,
3043       l_telex_rec,
3044       l_web_rec,
3045       p_object_version_number,
3046       x_return_status);
3047 
3048     IF x_return_status = fnd_api.g_ret_sts_success THEN
3049       update_contact_point_search(l_old_contact_point_rec,
3050                                   l_old_phone_rec,
3051                                   l_phone_rec,
3052                                   l_old_email_rec,
3053                                   l_email_rec
3054                                  );
3055     END IF;
3056 
3057     -- SSM SST Integration and Extension
3058     -- For non-profile entities, the concept of select/de-select data-sources is obsoleted.
3059     -- There is no need to check if the data-source is selected.
3060 
3061     -- Invoke business event system.
3062     IF x_return_status = fnd_api.g_ret_sts_success /*AND
3063        -- Bug 2197181: Added below condition for Mix-n-Match
3064       g_cpt_is_datasource_selected = 'Y'*/
3065     THEN
3066       l_old_contact_point_rec.orig_system := p_contact_point_rec.orig_system;
3067       IF(HZ_UTILITY_V2PUB.G_EXECUTE_API_CALLOUTS in ('Y', 'EVENTS_ENABLED')) THEN
3068         hz_business_event_v2pvt.update_contact_point_event (
3069           l_contact_point_rec,
3070           l_old_contact_point_rec,
3071           l_edi_rec,
3072           l_old_edi_rec,
3073           l_eft_rec,
3074           l_old_eft_rec,
3075           l_email_rec,
3076           l_old_email_rec,
3077           l_phone_rec,
3078           l_old_phone_rec,
3079           l_telex_rec,
3080           l_old_telex_rec,
3081           l_web_rec,
3082           l_old_web_rec);
3083       END IF;
3084 
3085       IF(HZ_UTILITY_V2PUB.G_EXECUTE_API_CALLOUTS in ('EVENTS_ENABLED', 'BO_EVENTS_ENABLED')) THEN
3086         HZ_POPULATE_BOT_PKG.pop_hz_contact_points(
3087           p_operation        => 'U',
3088           p_contact_point_id => l_contact_point_rec.contact_point_id);
3089       END IF;
3090       -- Call to indicate contact point update to DQM
3091       hz_dqm_sync.sync_contact_point(l_contact_point_rec.contact_point_id, 'U');
3092 
3093     END IF;
3094 
3095     -- Standard call to get message count and if count is 1, get message info.
3096     fnd_msg_pub.count_and_get(
3097       p_encoded => fnd_api.g_false,
3098       p_count => x_msg_count,
3099       p_data  => x_msg_data);
3100 
3101     -- Debug info.
3102     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3103         hz_utility_v2pub.debug(p_message=>'update_contact_point_main (-)',
3104                                p_prefix=>l_debug_prefix,
3105                                p_msg_level=>fnd_log.level_procedure);
3106     END IF;
3107   END update_contact_point_main;
3108 
3109   --------------------------------------
3110   -- public procedures and functions
3111   --------------------------------------
3112 
3113   --
3114   -- PROCEDURE create_contact_point
3115   --
3116   -- DESCRIPTION
3117   --     Creates a contact point.  Still here for backward compatibility.
3118   --
3119   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
3120   --
3121   -- ARGUMENTS
3122   --   IN:
3123   --     p_init_msg_list      Initialize message stack if it is set to
3124   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
3125   --     p_contact_point_rec  Contact point record.
3126   --     p_edi_rec            EDI record.
3127   --     p_email_rec          Email record.
3128   --     p_phone_rec          Phone record.
3129   --     p_telex_rec          Telex record.
3130   --     p_web_rec            Web record.
3131   --   IN/OUT:
3132   --   OUT:
3133   --     x_contact_point_id   Contact point ID.
3134   --     x_return_status      Return status after the call. The status can
3135   --                          be fnd_api.g_ret_sts_success (success),
3136   --                          fnd_api.g_ret_sts_error (error),
3137   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
3138   --     x_msg_count          Number of messages in message stack.
3139   --     x_msg_data           Message text if x_msg_count is 1.
3140   --
3141   -- NOTES
3142   --
3143   -- MODIFICATION HISTORY
3144   --
3145   --   07-23-2001    Jianying Huang      Created.
3146   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
3147   --                                     enhanced backward compatibility.
3148   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
3149   --                                     status and message data getting set
3150   --                                     incorrectly in update and create
3151   --                                     contact point APIs.
3152   --
3153 
3154   PROCEDURE create_contact_point (
3155     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
3156     p_contact_point_rec         IN     contact_point_rec_type,
3157     p_edi_rec                   IN     edi_rec_type := g_miss_edi_rec,
3158     p_email_rec                 IN     email_rec_type := g_miss_email_rec,
3159     p_phone_rec                 IN     phone_rec_type := g_miss_phone_rec,
3160     p_telex_rec                 IN     telex_rec_type := g_miss_telex_rec,
3161     p_web_rec                   IN     web_rec_type := g_miss_web_rec,
3162     x_contact_point_id          OUT NOCOPY    NUMBER,
3163     x_return_status             OUT NOCOPY    VARCHAR2,
3164     x_msg_count                 OUT NOCOPY    NUMBER,
3165     x_msg_data                  OUT NOCOPY    VARCHAR2
3166   ) IS
3167   l_debug_prefix                       VARCHAR2(30) := '';
3168   BEGIN
3169 
3170     -- Standard start of API savepoint
3171     SAVEPOINT create_contact_point;
3172 
3173     -- Check if API is called in debug mode. If yes, enable debug.
3174     --enable_debug;
3175 
3176     -- Debug info.
3177     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3178         hz_utility_v2pub.debug(p_message=>'create_contact_point (+)',
3179                                p_prefix=>l_debug_prefix,
3180                                p_msg_level=>fnd_log.level_procedure);
3181     END IF;
3182 
3183     -- Call to the main business logic.
3184     create_contact_point_main(
3185       p_init_msg_list           => p_init_msg_list,
3186       p_contact_point_rec       => p_contact_point_rec,
3187       p_edi_rec                 => p_edi_rec,
3188       p_email_rec               => p_email_rec,
3189       p_phone_rec               => p_phone_rec,
3190       p_telex_rec               => p_telex_rec,
3191       p_web_rec                 => p_web_rec,
3192       x_contact_point_id        => x_contact_point_id,
3193       x_return_status           => x_return_status,
3194       x_msg_count               => x_msg_count,
3195       x_msg_data                => x_msg_data
3196     );
3197 
3198     -- Debug info.
3199     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
3200          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3201                                p_msg_data=>x_msg_data,
3202                                p_msg_type=>'WARNING',
3203                                p_msg_level=>fnd_log.level_exception);
3204     END IF;
3205     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3206         hz_utility_v2pub.debug(p_message=>'create_contact_point (-)',
3207                                p_prefix=>l_debug_prefix,
3208                                p_msg_level=>fnd_log.level_procedure);
3209     END IF;
3210 
3211     -- Check if API is called in debug mode. If yes, disable debug.
3212     --disable_debug;
3213 
3214   EXCEPTION
3215     WHEN fnd_api.g_exc_error THEN
3216       ROLLBACK TO create_contact_point;
3217       x_return_status := fnd_api.g_ret_sts_error;
3218 
3219       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3220                                 p_count => x_msg_count,
3221                                 p_data  => x_msg_data);
3222 
3223       -- Debug info.
3224       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3225         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3226                                p_msg_data=>x_msg_data,
3227                                p_msg_type=>'ERROR',
3228                                p_msg_level=>fnd_log.level_error);
3229     END IF;
3230     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3231         hz_utility_v2pub.debug(p_message=>'create_contact_point (-)',
3232                                p_prefix=>l_debug_prefix,
3233                                p_msg_level=>fnd_log.level_procedure);
3234     END IF;
3235 
3236 
3237       -- Check if API is called in debug mode. If yes, disable debug.
3238       --disable_debug;
3239 
3240     WHEN fnd_api.g_exc_unexpected_error THEN
3241       ROLLBACK TO create_contact_point;
3242       x_return_status := fnd_api.g_ret_sts_unexp_error;
3243 
3244       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3245                                 p_count => x_msg_count,
3246                                 p_data  => x_msg_data);
3247 
3248       -- Debug info.
3249       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3250         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3251                                p_msg_data=>x_msg_data,
3252                                p_msg_type=>'UNEXPECTED ERROR',
3253                                p_msg_level=>fnd_log.level_error);
3254      END IF;
3255      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3256         hz_utility_v2pub.debug(p_message=>'create_contact_point (-)',
3257                                p_prefix=>l_debug_prefix,
3258                                p_msg_level=>fnd_log.level_procedure);
3259      END IF;
3260 
3261       -- Check if API is called in debug mode. If yes, disable debug.
3262       --disable_debug;
3263 
3264     WHEN OTHERS THEN
3265       ROLLBACK TO create_contact_point;
3266       x_return_status := fnd_api.g_ret_sts_unexp_error;
3267 
3268       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
3269       fnd_message.set_token('ERROR' ,SQLERRM);
3270       fnd_msg_pub.add;
3271 
3272       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3273                                 p_count => x_msg_count,
3274                                 p_data  => x_msg_data);
3275 
3276       -- Debug info.
3277       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3278         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3279                                p_msg_data=>x_msg_data,
3280                                p_msg_type=>'SQL ERROR',
3281                                p_msg_level=>fnd_log.level_error);
3282      END IF;
3283      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3284         hz_utility_v2pub.debug(p_message=>'create_contact_point (-)',
3285                                p_prefix=>l_debug_prefix,
3286                                p_msg_level=>fnd_log.level_procedure);
3287      END IF;
3288 
3289       -- Check if API is called in debug mode. If yes, disable debug.
3290       --disable_debug;
3291   END create_contact_point;
3292 
3293   --
3294   -- PROCEDURE create_edi_contact_point
3295   --
3296   -- DESCRIPTION
3297   --     Creates an EDI contact point.
3298   --
3299   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
3300   --
3301   -- ARGUMENTS
3302   --   IN:
3303   --     p_init_msg_list      Initialize message stack if it is set to
3304   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
3305   --     p_contact_point_rec  Contact point record.
3306   --     p_edi_rec            EDI record.
3307   --   IN/OUT:
3308   --   OUT:
3309   --     x_contact_point_id   Contact point ID.
3310   --     x_return_status      Return status after the call. The status can
3311   --                          be fnd_api.g_ret_sts_success (success),
3312   --                          fnd_api.g_ret_sts_error (error),
3313   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
3314   --     x_msg_count          Number of messages in message stack.
3315   --     x_msg_data           Message text if x_msg_count is 1.
3316   --
3317   -- NOTES
3318   --
3319   -- MODIFICATION HISTORY
3320   --
3321   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added to support
3322   --                                     enhanced backward compatibility.
3323   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
3324   --                                     status and message data getting set
3325   --                                     incorrectly in update and create
3326   --                                     contact point APIs.
3327   --
3328 
3329   PROCEDURE create_edi_contact_point (
3330     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
3331     p_contact_point_rec         IN     contact_point_rec_type,
3332     p_edi_rec                   IN     edi_rec_type := g_miss_edi_rec,
3333     x_contact_point_id          OUT NOCOPY    NUMBER,
3334     x_return_status             OUT NOCOPY    VARCHAR2,
3335     x_msg_count                 OUT NOCOPY    NUMBER,
3336     x_msg_data                  OUT NOCOPY    VARCHAR2
3337   ) IS
3338   l_debug_prefix                       VARCHAR2(30) := '';
3339   BEGIN
3340 
3341     -- Standard start of API savepoint
3342     SAVEPOINT create_edi_contact_point;
3343 
3344     -- Check if API is called in debug mode. If yes, enable debug.
3345     --enable_debug;
3346 
3347     -- Debug info.
3348     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3349         hz_utility_v2pub.debug(p_message=>'create_edi_contact_point (+)',
3350                                p_prefix=>l_debug_prefix,
3351                                p_msg_level=>fnd_log.level_procedure);
3352     END IF;
3353 
3354     -- Call to the main business logic.
3355     create_contact_point_main(
3356       p_init_msg_list           => p_init_msg_list,
3357       p_contact_point_rec       => p_contact_point_rec,
3358       p_edi_rec                 => p_edi_rec,
3359       x_contact_point_id        => x_contact_point_id,
3360       x_return_status           => x_return_status,
3361       x_msg_count               => x_msg_count,
3362       x_msg_data                => x_msg_data
3363     );
3364 
3365     -- Debug info.
3366     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
3367          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3368                                p_msg_data=>x_msg_data,
3369                                p_msg_type=>'WARNING',
3370                                p_msg_level=>fnd_log.level_exception);
3371     END IF;
3372     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3373         hz_utility_v2pub.debug(p_message=>'create_edi_contact_point (-)',
3374                                p_prefix=>l_debug_prefix,
3375                                p_msg_level=>fnd_log.level_procedure);
3376     END IF;
3377 
3378     -- Check if API is called in debug mode. If yes, disable debug.
3379     --disable_debug;
3380 
3381   EXCEPTION
3382     WHEN fnd_api.g_exc_error THEN
3383       ROLLBACK TO create_edi_contact_point;
3384       x_return_status := fnd_api.g_ret_sts_error;
3385 
3386       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3387                                 p_count => x_msg_count,
3388                                 p_data  => x_msg_data);
3389 
3390       -- Debug info.
3391       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3392         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3393                                p_msg_data=>x_msg_data,
3394                                p_msg_type=>'ERROR',
3395                                p_msg_level=>fnd_log.level_error);
3396      END IF;
3397      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3398         hz_utility_v2pub.debug(p_message=>'create_edi_contact_point (-)',
3399                                p_prefix=>l_debug_prefix,
3400                                p_msg_level=>fnd_log.level_procedure);
3401      END IF;
3402 
3403       -- Check if API is called in debug mode. If yes, disable debug.
3404       --disable_debug;
3405 
3406     WHEN fnd_api.g_exc_unexpected_error THEN
3407       ROLLBACK TO create_edi_contact_point;
3408       x_return_status := fnd_api.g_ret_sts_unexp_error;
3409 
3410       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3411                                 p_count => x_msg_count,
3412                                 p_data  => x_msg_data);
3413 
3414       -- Debug info.
3415       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3416         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3417                                p_msg_data=>x_msg_data,
3418                                p_msg_type=>'UNEXPECTED ERROR',
3419                                p_msg_level=>fnd_log.level_error);
3420       END IF;
3421       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3422         hz_utility_v2pub.debug(p_message=>'create_edi_contact_point (-)',
3423                                p_prefix=>l_debug_prefix,
3424                                p_msg_level=>fnd_log.level_procedure);
3425       END IF;
3426 
3427       -- Check if API is called in debug mode. If yes, disable debug.
3428       --disable_debug;
3429 
3430     WHEN OTHERS THEN
3431       ROLLBACK TO create_edi_contact_point;
3432       x_return_status := fnd_api.g_ret_sts_unexp_error;
3433 
3434       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
3435       fnd_message.set_token('ERROR' ,SQLERRM);
3436       fnd_msg_pub.add;
3437 
3438       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3439                                 p_count => x_msg_count,
3440                                 p_data  => x_msg_data);
3441 
3442       -- Debug info.
3443       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3444         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3445                                p_msg_data=>x_msg_data,
3446                                p_msg_type=>'SQL ERROR',
3447                                p_msg_level=>fnd_log.level_error);
3448       END IF;
3449       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3450         hz_utility_v2pub.debug(p_message=>'create_edi_contact_point (-)',
3451                                p_prefix=>l_debug_prefix,
3452                                p_msg_level=>fnd_log.level_procedure);
3453       END IF;
3454 
3455       -- Check if API is called in debug mode. If yes, disable debug.
3456       --disable_debug;
3457   END create_edi_contact_point;
3458 
3459   --
3460   -- PROCEDURE create_web_contact_point
3461   --
3462   -- DESCRIPTION
3463   --     Creates a Web contact point.
3464   --
3465   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
3466   --
3467   -- ARGUMENTS
3468   --   IN:
3469   --     p_init_msg_list      Initialize message stack if it is set to
3470   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
3471   --     p_contact_point_rec  Contact point record.
3472   --     p_web_rec            Web record.
3473   --   IN/OUT:
3474   --   OUT:
3475   --     x_contact_point_id   Contact point ID.
3476   --     x_return_status      Return status after the call. The status can
3477   --                          be fnd_api.g_ret_sts_success (success),
3478   --                          fnd_api.g_ret_sts_error (error),
3479   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
3480   --     x_msg_count          Number of messages in message stack.
3481   --     x_msg_data           Message text if x_msg_count is 1.
3482   --
3483   -- NOTES
3484   --
3485   -- MODIFICATION HISTORY
3486   --
3487   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
3488   --                                     enhanced backward compatibility.
3489   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
3490   --                                     status and message data getting set
3491   --                                     incorrectly in update and create
3492   --                                     contact point APIs.
3493   --
3494 
3495   PROCEDURE create_web_contact_point (
3496     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
3497     p_contact_point_rec         IN     contact_point_rec_type,
3498     p_web_rec                   IN     web_rec_type := g_miss_web_rec,
3499     x_contact_point_id          OUT NOCOPY    NUMBER,
3500     x_return_status             OUT NOCOPY    VARCHAR2,
3501     x_msg_count                 OUT NOCOPY    NUMBER,
3502     x_msg_data                  OUT NOCOPY    VARCHAR2
3503   ) IS
3504   l_debug_prefix                       VARCHAR2(30) := '';
3505   BEGIN
3506 
3507     -- Standard start of API savepoint
3508     SAVEPOINT create_web_contact_point;
3509 
3510     -- Check if API is called in debug mode. If yes, enable debug.
3511     --enable_debug;
3512 
3513     -- Debug info.
3514     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3515         hz_utility_v2pub.debug(p_message=>'create_web_contact_point (+)',
3516                                p_prefix=>l_debug_prefix,
3517                                p_msg_level=>fnd_log.level_procedure);
3518     END IF;
3519 
3520     -- Call to the main business logic.
3521     create_contact_point_main(
3522       p_init_msg_list           => p_init_msg_list,
3523       p_contact_point_rec       => p_contact_point_rec,
3524       p_web_rec                 => p_web_rec,
3525       x_contact_point_id        => x_contact_point_id,
3526       x_return_status           => x_return_status,
3527       x_msg_count               => x_msg_count,
3528       x_msg_data                => x_msg_data
3529     );
3530 
3531     -- Debug info.
3532     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
3533          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3534                                p_msg_data=>x_msg_data,
3535                                p_msg_type=>'WARNING',
3536                                p_msg_level=>fnd_log.level_exception);
3537     END IF;
3538     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3539         hz_utility_v2pub.debug(p_message=>'create_web_contact_point (-)',
3540                                p_prefix=>l_debug_prefix,
3541                                p_msg_level=>fnd_log.level_procedure);
3542     END IF;
3543 
3544     -- Check if API is called in debug mode. If yes, disable debug.
3545     --disable_debug;
3546 
3547   EXCEPTION
3548     WHEN fnd_api.g_exc_error THEN
3549       ROLLBACK TO create_web_contact_point;
3550       x_return_status := fnd_api.g_ret_sts_error;
3551 
3552       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3553                                 p_count => x_msg_count,
3554                                 p_data  => x_msg_data);
3555 
3556       -- Debug info.
3557       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3558         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3559                                p_msg_data=>x_msg_data,
3560                                p_msg_type=>'ERROR',
3561                                p_msg_level=>fnd_log.level_error);
3562     END IF;
3563     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3564         hz_utility_v2pub.debug(p_message=>'create_web_contact_point (-)',
3565                                p_prefix=>l_debug_prefix,
3566                                p_msg_level=>fnd_log.level_procedure);
3567     END IF;
3568 
3569       -- Check if API is called in debug mode. If yes, disable debug.
3570       --disable_debug;
3571 
3572     WHEN fnd_api.g_exc_unexpected_error THEN
3573       ROLLBACK TO create_web_contact_point;
3574       x_return_status := fnd_api.g_ret_sts_unexp_error;
3575 
3576       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3577                                 p_count => x_msg_count,
3578                                 p_data  => x_msg_data);
3579 
3580       -- Debug info.
3581       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3582         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3583                                p_msg_data=>x_msg_data,
3584                                p_msg_type=>'UNEXPECTED ERROR',
3585                                p_msg_level=>fnd_log.level_error);
3586       END IF;
3587       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3588         hz_utility_v2pub.debug(p_message=>'create_web_contact_point (-)',
3589                                p_prefix=>l_debug_prefix,
3590                                p_msg_level=>fnd_log.level_procedure);
3591       END IF;
3592 
3593       -- Check if API is called in debug mode. If yes, disable debug.
3594       --disable_debug;
3595 
3596     WHEN OTHERS THEN
3597       ROLLBACK TO create_web_contact_point;
3598       x_return_status := fnd_api.g_ret_sts_unexp_error;
3599 
3600       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
3601       fnd_message.set_token('ERROR' ,SQLERRM);
3602       fnd_msg_pub.add;
3603 
3604       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3605                                 p_count => x_msg_count,
3606                                 p_data  => x_msg_data);
3607 
3608       -- Debug info.
3609       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3610         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3611                                p_msg_data=>x_msg_data,
3612                                p_msg_type=>'SQL ERROR',
3613                                p_msg_level=>fnd_log.level_error);
3614       END IF;
3615       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3616         hz_utility_v2pub.debug(p_message=>'create_web_contact_point (-)',
3617                                p_prefix=>l_debug_prefix,
3618                                p_msg_level=>fnd_log.level_procedure);
3619       END IF;
3620 
3621       -- Check if API is called in debug mode. If yes, disable debug.
3622       --disable_debug;
3623   END create_web_contact_point;
3624 
3625   --
3626   -- PROCEDURE create_eft_contact_point
3627   --
3628   -- DESCRIPTION
3629   --     Creates an EFT contact point.
3630   --
3631   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
3632   --
3633   -- ARGUMENTS
3634   --   IN:
3635   --     p_init_msg_list      Initialize message stack if it is set to
3636   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
3637   --     p_contact_point_rec  Contact point record.
3638   --     p_eft_rec            EFT record.
3639   --   IN/OUT:
3640   --   OUT:
3641   --     x_contact_point_id   Contact point ID.
3642   --     x_return_status      Return status after the call. The status can
3643   --                          be fnd_api.g_ret_sts_success (success),
3644   --                          fnd_api.g_ret_sts_error (error),
3645   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
3646   --     x_msg_count          Number of messages in message stack.
3647   --     x_msg_data           Message text if x_msg_count is 1.
3648   --
3649   -- NOTES
3650   --
3651   -- MODIFICATION HISTORY
3652   --
3653   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
3654   --                                     enhanced backward compatibility.
3655   --                                     Bug 2100992: Added for bank
3656   --                                     consolidation support.
3657   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
3658   --                                     status and message data getting set
3659   --                                     incorrectly in update and create
3660   --                                     contact point APIs.
3661   --
3662 
3663   PROCEDURE create_eft_contact_point (
3664     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
3665     p_contact_point_rec         IN     contact_point_rec_type,
3666     p_eft_rec                   IN     eft_rec_type := g_miss_eft_rec,
3667     x_contact_point_id          OUT NOCOPY    NUMBER,
3668     x_return_status             OUT NOCOPY    VARCHAR2,
3669     x_msg_count                 OUT NOCOPY    NUMBER,
3670     x_msg_data                  OUT NOCOPY    VARCHAR2
3671   ) IS
3672   l_debug_prefix                       VARCHAR2(30) := '';
3673   BEGIN
3674 
3675     -- Standard start of API savepoint
3676     SAVEPOINT create_eft_contact_point;
3677 
3678     -- Check if API is called in debug mode. If yes, enable debug.
3679     --enable_debug;
3680 
3681     -- Debug info.
3682     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3683         hz_utility_v2pub.debug(p_message=>'create_eft_contact_point (+)',
3684                                p_prefix=>l_debug_prefix,
3685                                p_msg_level=>fnd_log.level_procedure);
3686     END IF;
3687 
3688     -- Call to the main business logic.
3689     create_contact_point_main(
3690       p_init_msg_list           => p_init_msg_list,
3691       p_contact_point_rec       => p_contact_point_rec,
3692       p_eft_rec                 => p_eft_rec,
3693       x_contact_point_id        => x_contact_point_id,
3694       x_return_status           => x_return_status,
3695       x_msg_count               => x_msg_count,
3696       x_msg_data                => x_msg_data
3697     );
3698 
3699     -- Debug info.
3700     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
3701          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3702                                p_msg_data=>x_msg_data,
3703                                p_msg_type=>'WARNING',
3704                                p_msg_level=>fnd_log.level_exception);
3705     END IF;
3706     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3707         hz_utility_v2pub.debug(p_message=>'create_eft_contact_point (-)',
3708                                p_prefix=>l_debug_prefix,
3709                                p_msg_level=>fnd_log.level_procedure);
3710     END IF;
3711 
3712 
3713     -- Check if API is called in debug mode. If yes, disable debug.
3714     --disable_debug;
3715 
3716   EXCEPTION
3717     WHEN fnd_api.g_exc_error THEN
3718       ROLLBACK TO create_eft_contact_point;
3719       x_return_status := fnd_api.g_ret_sts_error;
3720 
3721       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3722                                 p_count => x_msg_count,
3723                                 p_data  => x_msg_data);
3724 
3725       -- Debug info.
3726       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3727         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3728                                p_msg_data=>x_msg_data,
3729                                p_msg_type=>'ERROR',
3730                                p_msg_level=>fnd_log.level_error);
3731      END IF;
3732      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3733         hz_utility_v2pub.debug(p_message=>'create_eft_contact_point (-)',
3734                                p_prefix=>l_debug_prefix,
3735                                p_msg_level=>fnd_log.level_procedure);
3736      END IF;
3737 
3738       -- Check if API is called in debug mode. If yes, disable debug.
3739       --disable_debug;
3740 
3741     WHEN fnd_api.g_exc_unexpected_error THEN
3742       ROLLBACK TO create_eft_contact_point;
3743       x_return_status := fnd_api.g_ret_sts_unexp_error;
3744 
3745       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3746                                 p_count => x_msg_count,
3747                                 p_data  => x_msg_data);
3748 
3749       -- Debug info.
3750       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3751         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3752                                p_msg_data=>x_msg_data,
3753                                p_msg_type=>'UNEXPECTED ERROR',
3754                                p_msg_level=>fnd_log.level_error);
3755       END IF;
3756       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3757         hz_utility_v2pub.debug(p_message=>'create_eft_contact_point (-)',
3758                                p_prefix=>l_debug_prefix,
3759                                p_msg_level=>fnd_log.level_procedure);
3760       END IF;
3761 
3762       -- Check if API is called in debug mode. If yes, disable debug.
3763       --disable_debug;
3764 
3765     WHEN OTHERS THEN
3766       ROLLBACK TO create_eft_contact_point;
3767       x_return_status := fnd_api.g_ret_sts_unexp_error;
3768 
3769       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
3770       fnd_message.set_token('ERROR' ,SQLERRM);
3771       fnd_msg_pub.add;
3772 
3773       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3774                                 p_count => x_msg_count,
3775                                 p_data  => x_msg_data);
3776 
3777       -- Debug info.
3778       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3779         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3780                                p_msg_data=>x_msg_data,
3781                                p_msg_type=>'SQL ERROR',
3782                                p_msg_level=>fnd_log.level_error);
3783       END IF;
3784       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3785         hz_utility_v2pub.debug(p_message=>'create_eft_contact_point (-)',
3786                                p_prefix=>l_debug_prefix,
3787                                p_msg_level=>fnd_log.level_procedure);
3788       END IF;
3789 
3790       -- Check if API is called in debug mode. If yes, disable debug.
3791       --disable_debug;
3792   END create_eft_contact_point;
3793 
3794   --
3795   -- PROCEDURE create_phone_contact_point
3796   --
3797   -- DESCRIPTION
3798   --     Creates a phone contact point.
3799   --
3800   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
3801   --
3802   -- ARGUMENTS
3803   --   IN:
3804   --     p_init_msg_list      Initialize message stack if it is set to
3805   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
3806   --     p_contact_point_rec  Contact point record.
3807   --     p_phone_rec          Phone record.
3808   --   IN/OUT:
3809   --   OUT:
3810   --     x_contact_point_id   Contact point ID.
3811   --     x_return_status      Return status after the call. The status can
3812   --                          be fnd_api.g_ret_sts_success (success),
3813   --                          fnd_api.g_ret_sts_error (error),
3814   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
3815   --     x_msg_count          Number of messages in message stack.
3816   --     x_msg_data           Message text if x_msg_count is 1.
3817   --
3818   -- NOTES
3819   --
3820   -- MODIFICATION HISTORY
3821   --
3822   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
3823   --                                     enhanced backward compatibility.
3824   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
3825   --                                     status and message data getting set
3826   --                                     incorrectly in update and create
3827   --                                     contact point APIs.
3828   --
3829 
3830   PROCEDURE create_phone_contact_point (
3831     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
3832     p_contact_point_rec         IN     contact_point_rec_type,
3833     p_phone_rec                 IN     phone_rec_type := g_miss_phone_rec,
3834     x_contact_point_id          OUT NOCOPY    NUMBER,
3835     x_return_status             OUT NOCOPY    VARCHAR2,
3836     x_msg_count                 OUT NOCOPY    NUMBER,
3837     x_msg_data                  OUT NOCOPY    VARCHAR2
3838   ) IS
3839   l_debug_prefix                       VARCHAR2(30) := '';
3840   BEGIN
3841 
3842     -- Standard start of API savepoint
3843     SAVEPOINT create_phone_contact_point;
3844 
3845     -- Check if API is called in debug mode. If yes, enable debug.
3846     --enable_debug;
3847 
3848     -- Debug info.
3849     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3850         hz_utility_v2pub.debug(p_message=>'create_phone_contact_point (+)',
3851                                p_prefix=>l_debug_prefix,
3852                                p_msg_level=>fnd_log.level_procedure);
3853     END IF;
3854 
3855 
3856     -- Call to the main business logic.
3857     create_contact_point_main(
3858       p_init_msg_list           => p_init_msg_list,
3859       p_contact_point_rec       => p_contact_point_rec,
3860       p_phone_rec               => p_phone_rec,
3861       x_contact_point_id        => x_contact_point_id,
3862       x_return_status           => x_return_status,
3863       x_msg_count               => x_msg_count,
3864       x_msg_data                => x_msg_data
3865     );
3866 
3867     -- Debug info.
3868     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
3869          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3870                                p_msg_data=>x_msg_data,
3871                                p_msg_type=>'WARNING',
3872                                p_msg_level=>fnd_log.level_exception);
3873     END IF;
3874     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3875         hz_utility_v2pub.debug(p_message=>'create_phone_contact_point (-)',
3876                                p_prefix=>l_debug_prefix,
3877                                p_msg_level=>fnd_log.level_procedure);
3878     END IF;
3879 
3880     -- Check if API is called in debug mode. If yes, disable debug.
3881     --disable_debug;
3882 
3883   EXCEPTION
3884     WHEN fnd_api.g_exc_error THEN
3885       ROLLBACK TO create_phone_contact_point;
3886       x_return_status := fnd_api.g_ret_sts_error;
3887 
3888       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3889                                 p_count => x_msg_count,
3890                                 p_data  => x_msg_data);
3891 
3892       -- Debug info.
3893       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3894         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3895                                p_msg_data=>x_msg_data,
3896                                p_msg_type=>'ERROR',
3897                                p_msg_level=>fnd_log.level_error);
3898      END IF;
3899      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3900         hz_utility_v2pub.debug(p_message=>'create_phone_contact_point (-)',
3901                                p_prefix=>l_debug_prefix,
3902                                p_msg_level=>fnd_log.level_procedure);
3903      END IF;
3904 
3905       -- Check if API is called in debug mode. If yes, disable debug.
3906       --disable_debug;
3907 
3908     WHEN fnd_api.g_exc_unexpected_error THEN
3909       ROLLBACK TO create_phone_contact_point;
3910       x_return_status := fnd_api.g_ret_sts_unexp_error;
3911 
3912       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3913                                 p_count => x_msg_count,
3914                                 p_data  => x_msg_data);
3915 
3916       -- Debug info.
3917       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3918         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3919                                p_msg_data=>x_msg_data,
3920                                p_msg_type=>'UNEXPECTED ERROR',
3921                                p_msg_level=>fnd_log.level_error);
3922       END IF;
3923       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3924         hz_utility_v2pub.debug(p_message=>'create_phone_contact_point (-)',
3925                                p_prefix=>l_debug_prefix,
3926                                p_msg_level=>fnd_log.level_procedure);
3927       END IF;
3928 
3929       -- Check if API is called in debug mode. If yes, disable debug.
3930       --disable_debug;
3931 
3932     WHEN OTHERS THEN
3933       ROLLBACK TO create_phone_contact_point;
3934       x_return_status := fnd_api.g_ret_sts_unexp_error;
3935 
3936       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
3937       fnd_message.set_token('ERROR' ,SQLERRM);
3938       fnd_msg_pub.add;
3939 
3940       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
3941                                 p_count => x_msg_count,
3942                                 p_data  => x_msg_data);
3943 
3944       -- Debug info.
3945       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
3946         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
3947                                p_msg_data=>x_msg_data,
3948                                p_msg_type=>'SQL ERROR',
3949                                p_msg_level=>fnd_log.level_error);
3950      END IF;
3951      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
3952         hz_utility_v2pub.debug(p_message=>'create_phone_contact_point (-)',
3953                                p_prefix=>l_debug_prefix,
3954                                p_msg_level=>fnd_log.level_procedure);
3955      END IF;
3956 
3957       -- Check if API is called in debug mode. If yes, disable debug.
3958       --disable_debug;
3959   END create_phone_contact_point;
3960 
3961   --
3962   -- PROCEDURE create_telex_contact_point
3963   --
3964   -- DESCRIPTION
3965   --     Creates a telex contact point.
3966   --
3967   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
3968   --
3969   -- ARGUMENTS
3970   --   IN:
3971   --     p_init_msg_list      Initialize message stack if it is set to
3972   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
3973   --     p_contact_point_rec  Contact point record.
3974   --     p_telex_rec          Telex record.
3975   --   IN/OUT:
3976   --   OUT:
3977   --     x_contact_point_id   Contact point ID.
3978   --     x_return_status      Return status after the call. The status can
3979   --                          be fnd_api.g_ret_sts_success (success),
3980   --                          fnd_api.g_ret_sts_error (error),
3981   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
3982   --     x_msg_count          Number of messages in message stack.
3983   --     x_msg_data           Message text if x_msg_count is 1.
3984   --
3985   -- NOTES
3986   --
3987   -- MODIFICATION HISTORY
3988   --
3989   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
3990   --                                     enhanced backward compatibility.
3991   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
3992   --                                     status and message data getting set
3993   --                                     incorrectly in update and create
3994   --                                     contact point APIs.
3995   --
3996 
3997   PROCEDURE create_telex_contact_point (
3998     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
3999     p_contact_point_rec         IN     contact_point_rec_type,
4000     p_telex_rec                 IN     telex_rec_type := g_miss_telex_rec,
4001     x_contact_point_id          OUT NOCOPY    NUMBER,
4002     x_return_status             OUT NOCOPY    VARCHAR2,
4003     x_msg_count                 OUT NOCOPY    NUMBER,
4004     x_msg_data                  OUT NOCOPY    VARCHAR2
4005   ) IS
4006   l_debug_prefix                       VARCHAR2(30) := '';
4007   BEGIN
4008 
4009     -- Standard start of API savepoint
4010     SAVEPOINT create_telex_contact_point;
4011 
4012     -- Check if API is called in debug mode. If yes, enable debug.
4013     --enable_debug;
4014 
4015     -- Debug info.
4016     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4017         hz_utility_v2pub.debug(p_message=>'create_telex_contact_point (+)',
4018                                p_prefix=>l_debug_prefix,
4019                                p_msg_level=>fnd_log.level_procedure);
4020     END IF;
4021 
4022     -- Call to the main business logic.
4023     create_contact_point_main(
4024       p_init_msg_list           => p_init_msg_list,
4025       p_contact_point_rec       => p_contact_point_rec,
4026       p_telex_rec               => p_telex_rec,
4027       x_contact_point_id        => x_contact_point_id,
4028       x_return_status           => x_return_status,
4029       x_msg_count               => x_msg_count,
4030       x_msg_data                => x_msg_data
4031     );
4032 
4033     -- Debug info.
4034     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
4035          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4036                                p_msg_data=>x_msg_data,
4037                                p_msg_type=>'WARNING',
4038                                p_msg_level=>fnd_log.level_exception);
4039     END IF;
4040     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4041         hz_utility_v2pub.debug(p_message=>'create_telex_contact_point (-)',
4042                                p_prefix=>l_debug_prefix,
4043                                p_msg_level=>fnd_log.level_procedure);
4044     END IF;
4045 
4046 
4047     -- Check if API is called in debug mode. If yes, disable debug.
4048     --disable_debug;
4049 
4050   EXCEPTION
4051     WHEN fnd_api.g_exc_error THEN
4052       ROLLBACK TO create_telex_contact_point;
4053       x_return_status := fnd_api.g_ret_sts_error;
4054 
4055       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4056                                 p_count => x_msg_count,
4057                                 p_data  => x_msg_data);
4058 
4059       -- Debug info.
4060       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4061         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4062                                p_msg_data=>x_msg_data,
4063                                p_msg_type=>'ERROR',
4064                                p_msg_level=>fnd_log.level_error);
4065       END IF;
4066       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4067         hz_utility_v2pub.debug(p_message=>'create_telex_contact_point (-)',
4068                                p_prefix=>l_debug_prefix,
4069                                p_msg_level=>fnd_log.level_procedure);
4070       END IF;
4071 
4072       -- Check if API is called in debug mode. If yes, disable debug.
4073       --disable_debug;
4074 
4075     WHEN fnd_api.g_exc_unexpected_error THEN
4076       ROLLBACK TO create_telex_contact_point;
4077       x_return_status := fnd_api.g_ret_sts_unexp_error;
4078 
4079       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4080                                 p_count => x_msg_count,
4081                                 p_data  => x_msg_data);
4082 
4083       -- Debug info.
4084       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4085         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4086                                p_msg_data=>x_msg_data,
4087                                p_msg_type=>'UNEXPECTED ERROR',
4088                                p_msg_level=>fnd_log.level_error);
4089       END IF;
4090       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4091         hz_utility_v2pub.debug(p_message=>'create_telex_contact_point (-)',
4092                                p_prefix=>l_debug_prefix,
4093                                p_msg_level=>fnd_log.level_procedure);
4094       END IF;
4095 
4096       -- Check if API is called in debug mode. If yes, disable debug.
4097       --disable_debug;
4098 
4099     WHEN OTHERS THEN
4100       ROLLBACK TO create_telex_contact_point;
4101       x_return_status := fnd_api.g_ret_sts_unexp_error;
4102 
4103       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
4104       fnd_message.set_token('ERROR' ,SQLERRM);
4105       fnd_msg_pub.add;
4106 
4107       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4108                                 p_count => x_msg_count,
4109                                 p_data  => x_msg_data);
4110 
4111       -- Debug info.
4112       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4113         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4114                                p_msg_data=>x_msg_data,
4115                                p_msg_type=>'SQL ERROR',
4116                                p_msg_level=>fnd_log.level_error);
4117      END IF;
4118      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4119         hz_utility_v2pub.debug(p_message=>'create_telex_contact_point (-)',
4120                                p_prefix=>l_debug_prefix,
4121                                p_msg_level=>fnd_log.level_procedure);
4122      END IF;
4123 
4124       -- Check if API is called in debug mode. If yes, disable debug.
4125       --disable_debug;
4126   END create_telex_contact_point;
4127 
4128   --
4129   -- PROCEDURE create_email_contact_point
4130   --
4131   -- DESCRIPTION
4132   --     Creates a email contact point.
4133   --
4134   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
4135   --
4136   -- ARGUMENTS
4137   --   IN:
4138   --     p_init_msg_list      Initialize message stack if it is set to
4139   --                          FND_API.G_TRUE. Default is FND_API.G_FALSE.
4140   --     p_contact_point_rec  Contact point record.
4141   --     p_email_rec          Email record.
4142   --   IN/OUT:
4143   --   OUT:
4144   --     x_contact_point_id   Contact point ID.
4145   --     x_return_status      Return status after the call. The status can
4146   --                          be fnd_api.g_ret_sts_success (success),
4147   --                          fnd_api.g_ret_sts_error (error),
4148   --                          FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
4149   --     x_msg_count          Number of messages in message stack.
4150   --     x_msg_data           Message text if x_msg_count is 1.
4151   --
4152   -- NOTES
4153   --
4154   -- MODIFICATION HISTORY
4155   --
4156   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
4157   --                                     enhanced backward compatibility.
4158   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
4159   --                                     status and message data getting set
4160   --                                     incorrectly in update and create
4161   --                                     contact point APIs.
4162   --
4163 
4164   PROCEDURE create_email_contact_point (
4165     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
4166     p_contact_point_rec         IN     contact_point_rec_type,
4167     p_email_rec                 IN     email_rec_type := g_miss_email_rec,
4168     x_contact_point_id          OUT NOCOPY    NUMBER,
4169     x_return_status             OUT NOCOPY    VARCHAR2,
4170     x_msg_count                 OUT NOCOPY    NUMBER,
4171     x_msg_data                  OUT NOCOPY    VARCHAR2
4172   ) IS
4173   l_debug_prefix                       VARCHAR2(30) := '';
4174   BEGIN
4175 
4176     -- Standard start of API savepoint
4177     SAVEPOINT create_email_contact_point;
4178 
4179     -- Check if API is called in debug mode. If yes, enable debug.
4180     --enable_debug;
4181 
4182     -- Debug info.
4183     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4184         hz_utility_v2pub.debug(p_message=>'create_email_contact_point (+)',
4185                                p_prefix=>l_debug_prefix,
4186                                p_msg_level=>fnd_log.level_procedure);
4187     END IF;
4188 
4189 
4190     -- Call to the main business logic.
4191     create_contact_point_main(
4192       p_init_msg_list           => p_init_msg_list,
4193       p_contact_point_rec       => p_contact_point_rec,
4194       p_email_rec               => p_email_rec,
4195       x_contact_point_id        => x_contact_point_id,
4196       x_return_status           => x_return_status,
4197       x_msg_count               => x_msg_count,
4198       x_msg_data                => x_msg_data
4199     );
4200 
4201     -- Debug info.
4202     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
4203          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4204                                p_msg_data=>x_msg_data,
4205                                p_msg_type=>'WARNING',
4206                                p_msg_level=>fnd_log.level_exception);
4207     END IF;
4208     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4209         hz_utility_v2pub.debug(p_message=>'create_email_contact_point (-)',
4210                                p_prefix=>l_debug_prefix,
4211                                p_msg_level=>fnd_log.level_procedure);
4212     END IF;
4213 
4214     -- Check if API is called in debug mode. If yes, disable debug.
4215     --disable_debug;
4216 
4217   EXCEPTION
4218     WHEN fnd_api.g_exc_error THEN
4219       ROLLBACK TO create_email_contact_point;
4220       x_return_status := fnd_api.g_ret_sts_error;
4221 
4222       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4223                                 p_count => x_msg_count,
4224                                 p_data  => x_msg_data);
4225 
4226       -- Debug info.
4227       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4228         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4229                                p_msg_data=>x_msg_data,
4230                                p_msg_type=>'ERROR',
4231                                p_msg_level=>fnd_log.level_error);
4232       END IF;
4233       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4234         hz_utility_v2pub.debug(p_message=>'create_email_contact_point (-)',
4235                                p_prefix=>l_debug_prefix,
4236                                p_msg_level=>fnd_log.level_procedure);
4237       END IF;
4238 
4239       -- Check if API is called in debug mode. If yes, disable debug.
4240       --disable_debug;
4241 
4242     WHEN fnd_api.g_exc_unexpected_error THEN
4243       ROLLBACK TO create_email_contact_point;
4244       x_return_status := fnd_api.g_ret_sts_unexp_error;
4245 
4246       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4247                                 p_count => x_msg_count,
4248                                 p_data  => x_msg_data);
4249 
4250       -- Debug info.
4251       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4252         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4253                                p_msg_data=>x_msg_data,
4254                                p_msg_type=>'UNEXPECTED ERROR',
4255                                p_msg_level=>fnd_log.level_error);
4256     END IF;
4257     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4258         hz_utility_v2pub.debug(p_message=>'create_email_contact_point (-)',
4259                                p_prefix=>l_debug_prefix,
4260                                p_msg_level=>fnd_log.level_procedure);
4261     END IF;
4262 
4263       -- Check if API is called in debug mode. If yes, disable debug.
4264       --disable_debug;
4265 
4266     WHEN OTHERS THEN
4267       ROLLBACK TO create_email_contact_point;
4268       x_return_status := fnd_api.g_ret_sts_unexp_error;
4269 
4270       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
4271       fnd_message.set_token('ERROR' ,SQLERRM);
4272       fnd_msg_pub.add;
4273 
4274       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4275                                 p_count => x_msg_count,
4276                                 p_data  => x_msg_data);
4277 
4278       -- Debug info.
4279       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4280         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4281                                p_msg_data=>x_msg_data,
4282                                p_msg_type=>'SQL ERROR',
4283                                p_msg_level=>fnd_log.level_error);
4284       END IF;
4285       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4286         hz_utility_v2pub.debug(p_message=>'create_email_contact_point (-)',
4287                                p_prefix=>l_debug_prefix,
4288                                p_msg_level=>fnd_log.level_procedure);
4289       END IF;
4290 
4291       -- Check if API is called in debug mode. If yes, disable debug.
4292       --disable_debug;
4293   END create_email_contact_point;
4294 
4295   --
4296   -- PRIVATE PROCEDURE update_contact_point
4297   --
4298   -- DESCRIPTION
4299   --     Updates the given contact point.
4300   --
4301   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
4302   --
4303   -- ARGUMENTS
4304   --   IN:
4305   --     p_init_msg_list          Initialize message stack if it is set to
4306   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
4307   --     p_contact_point_rec      Contact point record.
4308   --     p_edi_rec                EDI record.
4309   --     p_email_rec              Email record.
4310   --     p_phone_rec              Phone record.
4311   --     p_telex_rec              Telex record.
4312   --     p_web_rec                Web record.
4313   --   IN/OUT:
4314   --     p_object_version_number  Used for locking the being updated record.
4315   --   OUT:
4316   --     x_return_status          Return status after the call. The status can
4317   --                              be fnd_api.g_ret_sts_success (success),
4318   --                              fnd_api.g_ret_sts_error (error),
4319   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
4320   --     x_msg_count              Number of messages in message stack.
4321   --     x_msg_data               Message text if x_msg_count is 1.
4322   --
4323   -- NOTES
4324   --
4325   -- MODIFICATION HISTORY
4326   --
4327   --   07-23-2001    Jianying Huang      Created.
4328   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
4329   --                                     enhanced backward compatibility.
4330   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
4331   --                                     status and message data getting set
4332   --                                     incorrectly in update and create
4333   --                                     contact point APIs.
4334   --
4335 
4336   PROCEDURE update_contact_point (
4337     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
4338     p_contact_point_rec         IN     contact_point_rec_type,
4339     p_edi_rec                   IN     edi_rec_type := g_miss_edi_rec,
4340     p_email_rec                 IN     email_rec_type := g_miss_email_rec,
4341     p_phone_rec                 IN     phone_rec_type := g_miss_phone_rec,
4342     p_telex_rec                 IN     telex_rec_type := g_miss_telex_rec,
4343     p_web_rec                   IN     web_rec_type := g_miss_web_rec,
4344     p_object_version_number     IN OUT NOCOPY NUMBER,
4345     x_return_status             OUT NOCOPY    VARCHAR2,
4346     x_msg_count                 OUT NOCOPY    NUMBER,
4347     x_msg_data                  OUT NOCOPY    VARCHAR2
4348   ) IS
4349   l_debug_prefix                       VARCHAR2(30) := '';
4350   BEGIN
4351 
4352     -- Standard start of API savepoint
4353     SAVEPOINT update_contact_point;
4354 
4355     -- Check if API is called in debug mode. If yes, enable debug.
4356     --enable_debug;
4357 
4358     -- Debug info.
4359     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4360         hz_utility_v2pub.debug(p_message=>'update_contact_point (+)',
4361                                p_prefix=>l_debug_prefix,
4362                                p_msg_level=>fnd_log.level_procedure);
4363     END IF;
4364 
4365     -- call main business logic.
4366     update_contact_point_main(
4367       p_init_msg_list           => p_init_msg_list,
4368       p_contact_point_rec       => p_contact_point_rec,
4369       p_edi_rec                 => p_edi_rec,
4370       p_email_rec               => p_email_rec,
4371       p_phone_rec               => p_phone_rec,
4372       p_telex_rec               => p_telex_rec,
4373       p_web_rec                 => p_web_rec,
4374       p_object_version_number   => p_object_version_number,
4375       x_return_status           => x_return_status,
4376       x_msg_count               => x_msg_count,
4377       x_msg_data                => x_msg_data
4378     );
4379 
4380     HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4381 
4382     -- Debug info.
4383     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
4384          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4385                                p_msg_data=>x_msg_data,
4386                                p_msg_type=>'WARNING',
4387                                p_msg_level=>fnd_log.level_exception);
4388     END IF;
4389     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4390         hz_utility_v2pub.debug(p_message=>'update_contact_point (-)',
4391                                p_prefix=>l_debug_prefix,
4392                                p_msg_level=>fnd_log.level_procedure);
4393     END IF;
4394 
4395     -- Check if API is called in debug mode. If yes, disable debug.
4396     --disable_debug;
4397 
4398   EXCEPTION
4399     WHEN fnd_api.g_exc_error THEN
4400       ROLLBACK TO update_contact_point;
4401       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4402       x_return_status := fnd_api.g_ret_sts_error;
4403 
4404       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4405                                 p_count => x_msg_count,
4406                                 p_data  => x_msg_data);
4407 
4408       -- Debug info.
4409       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4410         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4411                                p_msg_data=>x_msg_data,
4412                                p_msg_type=>'ERROR',
4413                                p_msg_level=>fnd_log.level_error);
4414       END IF;
4415       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4416         hz_utility_v2pub.debug(p_message=>'update_contact_point (-)',
4417                                p_prefix=>l_debug_prefix,
4418                                p_msg_level=>fnd_log.level_procedure);
4419       END IF;
4420 
4421       -- Check if API is called in debug mode. If yes, disable debug.
4422       --disable_debug;
4423 
4424     WHEN fnd_api.g_exc_unexpected_error THEN
4425       ROLLBACK TO update_contact_point;
4426       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4427       x_return_status := fnd_api.g_ret_sts_unexp_error;
4428 
4429       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4430                                 p_count => x_msg_count,
4431                                 p_data  => x_msg_data);
4432 
4433       -- Debug info.
4434       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4435         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4436                                p_msg_data=>x_msg_data,
4437                                p_msg_type=>'UNEXPECTED ERROR',
4438                                p_msg_level=>fnd_log.level_error);
4439      END IF;
4440      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4441         hz_utility_v2pub.debug(p_message=>'update_contact_point (-)',
4442                                p_prefix=>l_debug_prefix,
4443                                p_msg_level=>fnd_log.level_procedure);
4444      END IF;
4445 
4446       -- Check if API is called in debug mode. If yes, disable debug.
4447       --disable_debug;
4448 
4449     WHEN OTHERS THEN
4450       ROLLBACK TO update_contact_point;
4451       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4452       x_return_status := fnd_api.g_ret_sts_unexp_error;
4453 
4454       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
4455       fnd_message.set_token('ERROR' ,SQLERRM);
4456       fnd_msg_pub.add;
4457 
4458       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4459                                 p_count => x_msg_count,
4460                                 p_data  => x_msg_data);
4461 
4462       -- Debug info.
4463       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4464         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4465                                p_msg_data=>x_msg_data,
4466                                p_msg_type=>'SQL ERROR',
4467                                p_msg_level=>fnd_log.level_error);
4468       END IF;
4469       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4470         hz_utility_v2pub.debug(p_message=>'update_contact_point (-)',
4471                                p_prefix=>l_debug_prefix,
4472                                p_msg_level=>fnd_log.level_procedure);
4473       END IF;
4474 
4475       -- Check if API is called in debug mode. If yes, disable debug.
4476       --disable_debug;
4477   END update_contact_point;
4478 
4479   --
4480   -- PROCEDURE update_edi_contact_point
4481   --
4482   -- DESCRIPTION
4483   --     Updates the given EDI contact point.
4484   --
4485   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
4486   --
4487   -- ARGUMENTS
4488   --   IN:
4489   --     p_init_msg_list          Initialize message stack if it is set to
4490   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
4491   --     p_contact_point_rec      Contact point record.
4492   --     p_edi_rec                EDI record.
4493   --   IN/OUT:
4494   --     p_object_version_number  Used for locking the being updated record.
4495   --   OUT:
4496   --     x_return_status          Return status after the call. The status can
4497   --                              be fnd_api.g_ret_sts_success (success),
4498   --                              fnd_api.g_ret_sts_error (error),
4499   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
4500   --     x_msg_count              Number of messages in message stack.
4501   --     x_msg_data               Message text if x_msg_count is 1.
4502   --
4503   -- NOTES
4504   --
4505   -- MODIFICATION HISTORY
4506   --
4507   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added to support
4508   --                                     enhanced backward compatibility.
4509   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
4510   --                                     status and message data getting set
4511   --                                     incorrectly in update and create
4512   --                                     contact point APIs.
4513   --
4514 
4515   PROCEDURE update_edi_contact_point (
4516     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
4517     p_contact_point_rec         IN     contact_point_rec_type,
4518     p_edi_rec                   IN     edi_rec_type := g_miss_edi_rec,
4519     p_object_version_number     IN OUT NOCOPY NUMBER,
4520     x_return_status             OUT NOCOPY    VARCHAR2,
4521     x_msg_count                 OUT NOCOPY    NUMBER,
4522     x_msg_data                  OUT NOCOPY    VARCHAR2
4523   ) IS
4524   l_debug_prefix                       VARCHAR2(30) := '';
4525   BEGIN
4526     -- Standard start of API savepoint
4527     SAVEPOINT update_edi_contact_point;
4528 
4529     -- Check if API is called in debug mode. If yes, enable debug.
4530     --enable_debug;
4531 
4532     -- Debug info.
4533     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4534         hz_utility_v2pub.debug(p_message=>'update_edi_contact_point (+)',
4535                                p_prefix=>l_debug_prefix,
4536                                p_msg_level=>fnd_log.level_procedure);
4537     END IF;
4538 
4539     -- call main business logic.
4540     update_contact_point_main(
4541       p_init_msg_list           => p_init_msg_list,
4542       p_contact_point_rec       => p_contact_point_rec,
4543       p_edi_rec                 => p_edi_rec,
4544       p_object_version_number   => p_object_version_number,
4545       x_return_status           => x_return_status,
4546       x_msg_count               => x_msg_count,
4547       x_msg_data                => x_msg_data
4548     );
4549 
4550     -- Debug info.
4551     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
4552          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4553                                p_msg_data=>x_msg_data,
4554                                p_msg_type=>'WARNING',
4555                                p_msg_level=>fnd_log.level_exception);
4556     END IF;
4557     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4558         hz_utility_v2pub.debug(p_message=>'update_edi_contact_point (-)',
4559                                p_prefix=>l_debug_prefix,
4560                                p_msg_level=>fnd_log.level_procedure);
4561     END IF;
4562 
4563     -- Check if API is called in debug mode. If yes, disable debug.
4564     --disable_debug;
4565 
4566   EXCEPTION
4567     WHEN fnd_api.g_exc_error THEN
4568       ROLLBACK TO update_edi_contact_point;
4569       x_return_status := fnd_api.g_ret_sts_error;
4570 
4571       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4572                                 p_count => x_msg_count,
4573                                 p_data  => x_msg_data);
4574 
4575       -- Debug info.
4576      IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4577         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4578                                p_msg_data=>x_msg_data,
4579                                p_msg_type=>'ERROR',
4580                                p_msg_level=>fnd_log.level_error);
4581      END IF;
4582      IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4583         hz_utility_v2pub.debug(p_message=>'update_edi_contact_point (-)',
4584                                p_prefix=>l_debug_prefix,
4585                                p_msg_level=>fnd_log.level_procedure);
4586      END IF;
4587 
4588       -- Check if API is called in debug mode. If yes, disable debug.
4589       --disable_debug;
4590 
4591     WHEN fnd_api.g_exc_unexpected_error THEN
4592       ROLLBACK TO update_edi_contact_point;
4593       x_return_status := fnd_api.g_ret_sts_unexp_error;
4594 
4595       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4596                                 p_count => x_msg_count,
4597                                 p_data  => x_msg_data);
4598 
4599       -- Debug info.
4600       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4601         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4602                                p_msg_data=>x_msg_data,
4603                                p_msg_type=>'UNEXPECTED ERROR',
4604                                p_msg_level=>fnd_log.level_error);
4605       END IF;
4606       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4607         hz_utility_v2pub.debug(p_message=>'update_edi_contact_point (-)',
4608                                p_prefix=>l_debug_prefix,
4609                                p_msg_level=>fnd_log.level_procedure);
4610       END IF;
4611 
4612       -- Check if API is called in debug mode. If yes, disable debug.
4613       --disable_debug;
4614 
4615     WHEN OTHERS THEN
4616       ROLLBACK TO update_edi_contact_point;
4617       x_return_status := fnd_api.g_ret_sts_unexp_error;
4618 
4619       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
4620       fnd_message.set_token('ERROR' ,SQLERRM);
4621       fnd_msg_pub.add;
4622 
4623       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4624                                 p_count => x_msg_count,
4625                                 p_data  => x_msg_data);
4626 
4627       -- Debug info.
4628       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4629         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4630                                p_msg_data=>x_msg_data,
4631                                p_msg_type=>'SQL ERROR',
4632                                p_msg_level=>fnd_log.level_error);
4633       END IF;
4634       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4635         hz_utility_v2pub.debug(p_message=>'update_edi_contact_point (-)',
4636                                p_prefix=>l_debug_prefix,
4637                                p_msg_level=>fnd_log.level_procedure);
4638       END IF;
4639 
4640       -- Check if API is called in debug mode. If yes, disable debug.
4641       --disable_debug;
4642   END update_edi_contact_point;
4643 
4644   --
4645   -- PROCEDURE update_web_contact_point
4646   --
4647   -- DESCRIPTION
4648   --     Updates the given Web contact point.
4649   --
4650   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
4651   --
4652   -- ARGUMENTS
4653   --   IN:
4654   --     p_init_msg_list          Initialize message stack if it is set to
4655   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
4656   --     p_contact_point_rec      Contact point record.
4657   --     p_web_rec                WEB record.
4658   --   IN/OUT:
4659   --     p_object_version_number  Used for locking the being updated record.
4660   --   OUT:
4661   --     x_return_status          Return status after the call. The status can
4662   --                              be fnd_api.g_ret_sts_success (success),
4663   --                              fnd_api.g_ret_sts_error (error),
4664   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
4665   --     x_msg_count              Number of messages in message stack.
4666   --     x_msg_data               Message text if x_msg_count is 1.
4667   --
4668   -- NOTES
4669   --
4670   -- MODIFICATION HISTORY
4671   --
4672   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added to support
4673   --                                     enhanced backward compatibility.
4674   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
4675   --                                     status and message data getting set
4676   --                                     incorrectly in update and create
4677   --                                     contact point APIs.
4678   --
4679 
4680   PROCEDURE update_web_contact_point (
4681     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
4682     p_contact_point_rec         IN     contact_point_rec_type,
4683     p_web_rec                   IN     web_rec_type := g_miss_web_rec,
4684     p_object_version_number     IN OUT NOCOPY NUMBER,
4685     x_return_status             OUT NOCOPY    VARCHAR2,
4686     x_msg_count                 OUT NOCOPY    NUMBER,
4687     x_msg_data                  OUT NOCOPY    VARCHAR2
4688   ) IS
4689   l_debug_prefix                VARCHAR2(30) := '';
4690   BEGIN
4691     -- Standard start of API savepoint
4692     SAVEPOINT update_web_contact_point;
4693 
4694     -- Check if API is called in debug mode. If yes, enable debug.
4695     --enable_debug;
4696 
4697     -- Debug info.
4698     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4699         hz_utility_v2pub.debug(p_message=>'update_web_contact_point (+)',
4700                                p_prefix=>l_debug_prefix,
4701                                p_msg_level=>fnd_log.level_procedure);
4702     END IF;
4703 
4704     -- call main business logic.
4705     update_contact_point_main(
4706       p_init_msg_list           => p_init_msg_list,
4707       p_contact_point_rec       => p_contact_point_rec,
4708       p_web_rec                 => p_web_rec,
4709       p_object_version_number   => p_object_version_number,
4710       x_return_status           => x_return_status,
4711       x_msg_count               => x_msg_count,
4712       x_msg_data                => x_msg_data
4713     );
4714 
4715       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4716     -- Debug info.
4717     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
4718          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4719                                p_msg_data=>x_msg_data,
4720                                p_msg_type=>'WARNING',
4721                                p_msg_level=>fnd_log.level_exception);
4722     END IF;
4723     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4724         hz_utility_v2pub.debug(p_message=>'update_web_contact_point (-)',
4725                                p_prefix=>l_debug_prefix,
4726                                p_msg_level=>fnd_log.level_procedure);
4727     END IF;
4728 
4729     -- Check if API is called in debug mode. If yes, disable debug.
4730     --disable_debug;
4731 
4732   EXCEPTION
4733     WHEN fnd_api.g_exc_error THEN
4734       ROLLBACK TO update_web_contact_point;
4735       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4736       x_return_status := fnd_api.g_ret_sts_error;
4737 
4738       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4739                                 p_count => x_msg_count,
4740                                 p_data  => x_msg_data);
4741 
4742       -- Debug info.
4743       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4744         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4745                                p_msg_data=>x_msg_data,
4746                                p_msg_type=>'ERROR',
4747                                p_msg_level=>fnd_log.level_error);
4748       END IF;
4749       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4750         hz_utility_v2pub.debug(p_message=>'update_web_contact_point (-)',
4751                                p_prefix=>l_debug_prefix,
4752                                p_msg_level=>fnd_log.level_procedure);
4753       END IF;
4754 
4755       -- Check if API is called in debug mode. If yes, disable debug.
4756       --disable_debug;
4757 
4758     WHEN fnd_api.g_exc_unexpected_error THEN
4759       ROLLBACK TO update_web_contact_point;
4760       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4761       x_return_status := fnd_api.g_ret_sts_unexp_error;
4762 
4763       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4764                                 p_count => x_msg_count,
4765                                 p_data  => x_msg_data);
4766 
4767       -- Debug info.
4768       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4769         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4770                                p_msg_data=>x_msg_data,
4771                                p_msg_type=>'UNEXPECTED ERROR',
4772                                p_msg_level=>fnd_log.level_error);
4773       END IF;
4774       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4775         hz_utility_v2pub.debug(p_message=>'update_web_contact_point (-)',
4776                                p_prefix=>l_debug_prefix,
4777                                p_msg_level=>fnd_log.level_procedure);
4778       END IF;
4779 
4780 
4781       -- Check if API is called in debug mode. If yes, disable debug.
4782       --disable_debug;
4783 
4784     WHEN OTHERS THEN
4785       ROLLBACK TO update_web_contact_point;
4786       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
4787       x_return_status := fnd_api.g_ret_sts_unexp_error;
4788 
4789       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
4790       fnd_message.set_token('ERROR' ,SQLERRM);
4791       fnd_msg_pub.add;
4792 
4793       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4794                                 p_count => x_msg_count,
4795                                 p_data  => x_msg_data);
4796 
4797       -- Debug info.
4798       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4799         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4800                                p_msg_data=>x_msg_data,
4801                                p_msg_type=>'SQL ERROR',
4802                                p_msg_level=>fnd_log.level_error);
4803       END IF;
4804       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4805         hz_utility_v2pub.debug(p_message=>'update_web_contact_point (-)',
4806                                p_prefix=>l_debug_prefix,
4807                                p_msg_level=>fnd_log.level_procedure);
4808       END IF;
4809 
4810       -- Check if API is called in debug mode. If yes, disable debug.
4811       --disable_debug;
4812   END update_web_contact_point;
4813 
4814   --
4815   -- PROCEDURE update_eft_contact_point
4816   --
4817   -- DESCRIPTION
4818   --     Updates the given EFT contact point.
4819   --
4820   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
4821   --
4822   -- ARGUMENTS
4823   --   IN:
4824   --     p_init_msg_list          Initialize message stack if it is set to
4825   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
4826   --     p_contact_point_rec      Contact point record.
4827   --     p_eft_rec                EFT record.
4828   --   IN/OUT:
4829   --     p_object_version_number  Used for locking the being updated record.
4830   --   OUT:
4831   --     x_return_status          Return status after the call. The status can
4832   --                              be fnd_api.g_ret_sts_success (success),
4833   --                              fnd_api.g_ret_sts_error (error),
4834   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
4835   --     x_msg_count              Number of messages in message stack.
4836   --     x_msg_data               Message text if x_msg_count is 1.
4837   --
4838   -- NOTES
4839   --
4840   -- MODIFICATION HISTORY
4841   --
4842   --   19-NOV-2001   Joe del Callar      Bug 2116225: Added to support
4843   --                                     Bank Consolidation.
4844   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added to support
4845   --                                     enhanced backward compatibility.
4846   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
4847   --                                     status and message data getting set
4848   --                                     incorrectly in update and create
4849   --                                     contact point APIs.
4850   --
4851 
4852   PROCEDURE update_eft_contact_point (
4853     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
4854     p_contact_point_rec         IN     contact_point_rec_type,
4855     p_eft_rec                   IN     eft_rec_type := g_miss_eft_rec,
4856     p_object_version_number     IN OUT NOCOPY NUMBER,
4857     x_return_status             OUT NOCOPY    VARCHAR2,
4858     x_msg_count                 OUT NOCOPY    NUMBER,
4859     x_msg_data                  OUT NOCOPY    VARCHAR2
4860   ) IS
4861   l_debug_prefix                       VARCHAR2(30) := '';
4862   BEGIN
4863     -- Standard start of API savepoint
4864     SAVEPOINT update_eft_contact_point;
4865 
4866     -- Check if API is called in debug mode. If yes, enable debug.
4867     --enable_debug;
4868 
4869     -- Debug info.
4870     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4871         hz_utility_v2pub.debug(p_message=>'update_eft_contact_point (+)',
4872                                p_prefix=>l_debug_prefix,
4873                                p_msg_level=>fnd_log.level_procedure);
4874     END IF;
4875 
4876 
4877     -- call main business logic.
4878     update_contact_point_main(
4879       p_init_msg_list           => p_init_msg_list,
4880       p_contact_point_rec       => p_contact_point_rec,
4881       p_eft_rec                 => p_eft_rec,
4882       p_object_version_number   => p_object_version_number,
4883       x_return_status           => x_return_status,
4884       x_msg_count               => x_msg_count,
4885       x_msg_data                => x_msg_data
4886     );
4887 
4888     -- Debug info.
4889     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
4890          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4891                                p_msg_data=>x_msg_data,
4892                                p_msg_type=>'WARNING',
4893                                p_msg_level=>fnd_log.level_exception);
4894     END IF;
4895     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4896         hz_utility_v2pub.debug(p_message=>'update_eft_contact_point (-)',
4897                                p_prefix=>l_debug_prefix,
4898                                p_msg_level=>fnd_log.level_procedure);
4899     END IF;
4900 
4901     -- Check if API is called in debug mode. If yes, disable debug.
4902     --disable_debug;
4903 
4904   EXCEPTION
4905     WHEN fnd_api.g_exc_error THEN
4906       ROLLBACK TO update_eft_contact_point;
4907       x_return_status := fnd_api.g_ret_sts_error;
4908 
4909       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4910                                 p_count => x_msg_count,
4911                                 p_data  => x_msg_data);
4912 
4913       -- Debug info.
4914       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4915         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4916                                p_msg_data=>x_msg_data,
4917                                p_msg_type=>'ERROR',
4918                                p_msg_level=>fnd_log.level_error);
4919       END IF;
4920       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4921         hz_utility_v2pub.debug(p_message=>'update_eft_contact_point (-)',
4922                                p_prefix=>l_debug_prefix,
4923                                p_msg_level=>fnd_log.level_procedure);
4924       END IF;
4925 
4926       -- Check if API is called in debug mode. If yes, disable debug.
4927       --disable_debug;
4928 
4929     WHEN fnd_api.g_exc_unexpected_error THEN
4930       ROLLBACK TO update_eft_contact_point;
4931       x_return_status := fnd_api.g_ret_sts_unexp_error;
4932 
4933       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4934                                 p_count => x_msg_count,
4935                                 p_data  => x_msg_data);
4936 
4937       -- Debug info.
4938       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4939         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4940                                p_msg_data=>x_msg_data,
4941                                p_msg_type=>'UNEXPECTED ERROR',
4942                                p_msg_level=>fnd_log.level_error);
4943       END IF;
4944       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4945         hz_utility_v2pub.debug(p_message=>'update_eft_contact_point (-)',
4946                                p_prefix=>l_debug_prefix,
4947                                p_msg_level=>fnd_log.level_procedure);
4948       END IF;
4949 
4950       -- Check if API is called in debug mode. If yes, disable debug.
4951       --disable_debug;
4952 
4953     WHEN OTHERS THEN
4954       ROLLBACK TO update_eft_contact_point;
4955       x_return_status := fnd_api.g_ret_sts_unexp_error;
4956 
4957       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
4958       fnd_message.set_token('ERROR' ,SQLERRM);
4959       fnd_msg_pub.add;
4960 
4961       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
4962                                 p_count => x_msg_count,
4963                                 p_data  => x_msg_data);
4964 
4965       -- Debug info.
4966       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
4967         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
4968                                p_msg_data=>x_msg_data,
4969                                p_msg_type=>'SQL ERROR',
4970                                p_msg_level=>fnd_log.level_error);
4971       END IF;
4972       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
4973         hz_utility_v2pub.debug(p_message=>'update_eft_contact_point (-)',
4974                                p_prefix=>l_debug_prefix,
4975                                p_msg_level=>fnd_log.level_procedure);
4976       END IF;
4977 
4978 
4979       -- Check if API is called in debug mode. If yes, disable debug.
4980       --disable_debug;
4981   END update_eft_contact_point;
4982 
4983   --
4984   -- PROCEDURE update_phone_contact_point
4985   --
4986   -- DESCRIPTION
4987   --     Updates the given phone contact point.
4988   --
4989   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
4990   --
4991   -- ARGUMENTS
4992   --   IN:
4993   --     p_init_msg_list          Initialize message stack if it is set to
4994   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
4995   --     p_contact_point_rec      Contact point record.
4996   --     p_phone_rec              Phone record.
4997   --   IN/OUT:
4998   --     p_object_version_number  Used for locking the being updated record.
4999   --   OUT:
5000   --     x_return_status          Return status after the call. The status can
5001   --                              be fnd_api.g_ret_sts_success (success),
5002   --                              fnd_api.g_ret_sts_error (error),
5003   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
5004   --     x_msg_count              Number of messages in message stack.
5005   --     x_msg_data               Message text if x_msg_count is 1.
5006   --
5007   -- NOTES
5008   --
5009   -- MODIFICATION HISTORY
5010   --
5011   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added to support
5012   --                                     enhanced backward compatibility.
5013   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
5014   --                                     status and message data getting set
5015   --                                     incorrectly in update and create
5016   --                                     contact point APIs.
5017   --
5018 
5019   PROCEDURE update_phone_contact_point (
5020     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
5021     p_contact_point_rec         IN     contact_point_rec_type,
5022     p_phone_rec                   IN     phone_rec_type := g_miss_phone_rec,
5023     p_object_version_number     IN OUT NOCOPY NUMBER,
5024     x_return_status             OUT NOCOPY    VARCHAR2,
5025     x_msg_count                 OUT NOCOPY    NUMBER,
5026     x_msg_data                  OUT NOCOPY    VARCHAR2
5027   ) IS
5028   l_debug_prefix                       VARCHAR2(30) := '';
5029   BEGIN
5030     -- Standard start of API savepoint
5031     SAVEPOINT update_phone_contact_point;
5032 
5033     -- Check if API is called in debug mode. If yes, enable debug.
5034     --enable_debug;
5035 
5036     -- Debug info.
5037     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5038         hz_utility_v2pub.debug(p_message=>'update_phone_contact_point (+)',
5039                                p_prefix=>l_debug_prefix,
5040                                p_msg_level=>fnd_log.level_procedure);
5041     END IF;
5042 
5043     -- call main business logic.
5044     update_contact_point_main(
5045       p_init_msg_list           => p_init_msg_list,
5046       p_contact_point_rec       => p_contact_point_rec,
5047       p_phone_rec               => p_phone_rec,
5048       p_object_version_number   => p_object_version_number,
5049       x_return_status           => x_return_status,
5050       x_msg_count               => x_msg_count,
5051       x_msg_data                => x_msg_data
5052     );
5053 
5054       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5055     -- Debug info.
5056     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
5057          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5058                                p_msg_data=>x_msg_data,
5059                                p_msg_type=>'WARNING',
5060                                p_msg_level=>fnd_log.level_exception);
5061     END IF;
5062     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5063         hz_utility_v2pub.debug(p_message=>'update_phone_contact_point (-)',
5064                                p_prefix=>l_debug_prefix,
5065                                p_msg_level=>fnd_log.level_procedure);
5066     END IF;
5067 
5068     -- Check if API is called in debug mode. If yes, disable debug.
5069     --disable_debug;
5070 
5071   EXCEPTION
5072     WHEN fnd_api.g_exc_error THEN
5073       ROLLBACK TO update_phone_contact_point;
5074       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5075       x_return_status := fnd_api.g_ret_sts_error;
5076 
5077       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5078                                 p_count => x_msg_count,
5079                                 p_data  => x_msg_data);
5080 
5081       -- Debug info.
5082       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5083         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5084                                p_msg_data=>x_msg_data,
5085                                p_msg_type=>'ERROR',
5086                                p_msg_level=>fnd_log.level_error);
5087       END IF;
5088       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5089         hz_utility_v2pub.debug(p_message=>'update_phone_contact_point (-)',
5090                                p_prefix=>l_debug_prefix,
5091                                p_msg_level=>fnd_log.level_procedure);
5092       END IF;
5093 
5094       -- Check if API is called in debug mode. If yes, disable debug.
5095       --disable_debug;
5096 
5097     WHEN fnd_api.g_exc_unexpected_error THEN
5098       ROLLBACK TO update_phone_contact_point;
5099       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5100       x_return_status := fnd_api.g_ret_sts_unexp_error;
5101 
5102       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5103                                 p_count => x_msg_count,
5104                                 p_data  => x_msg_data);
5105 
5106       -- Debug info.
5107       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5108         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5109                                p_msg_data=>x_msg_data,
5110                                p_msg_type=>'UNEXPECTED ERROR',
5111                                p_msg_level=>fnd_log.level_error);
5112       END IF;
5113       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5114         hz_utility_v2pub.debug(p_message=>'update_phone_contact_point (-)',
5115                                p_prefix=>l_debug_prefix,
5116                                p_msg_level=>fnd_log.level_procedure);
5117       END IF;
5118 
5119       -- Check if API is called in debug mode. If yes, disable debug.
5120       --disable_debug;
5121 
5122     WHEN OTHERS THEN
5123       ROLLBACK TO update_phone_contact_point;
5124       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5125       x_return_status := fnd_api.g_ret_sts_unexp_error;
5126 
5127       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
5128       fnd_message.set_token('ERROR' ,SQLERRM);
5129       fnd_msg_pub.add;
5130 
5131       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5132                                 p_count => x_msg_count,
5133                                 p_data  => x_msg_data);
5134 
5135       -- Debug info.
5136       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5137         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5138                                p_msg_data=>x_msg_data,
5139                                p_msg_type=>'SQL ERROR',
5140                                p_msg_level=>fnd_log.level_error);
5141       END IF;
5142       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5143         hz_utility_v2pub.debug(p_message=>'update_phone_contact_point (-)',
5144                                p_prefix=>l_debug_prefix,
5145                                p_msg_level=>fnd_log.level_procedure);
5146       END IF;
5147 
5148       -- Check if API is called in debug mode. If yes, disable debug.
5149       --disable_debug;
5150   END update_phone_contact_point;
5151 
5152   --
5153   -- PROCEDURE update_telex_contact_point
5154   --
5155   -- DESCRIPTION
5156   --     Updates the given telex contact point.
5157   --
5158   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
5159   --
5160   -- ARGUMENTS
5161   --   IN:
5162   --     p_init_msg_list          Initialize message stack if it is set to
5163   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
5164   --     p_contact_point_rec      Contact point record.
5165   --     p_telex_rec              Telex record.
5166   --   IN/OUT:
5167   --     p_object_version_number  Used for locking the being updated record.
5168   --   OUT:
5169   --     x_return_status          Return status after the call. The status can
5170   --                              be fnd_api.g_ret_sts_success (success),
5171   --                              fnd_api.g_ret_sts_error (error),
5172   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
5173   --     x_msg_count              Number of messages in message stack.
5174   --     x_msg_data               Message text if x_msg_count is 1.
5175   --
5176   -- NOTES
5177   --
5178   -- MODIFICATION HISTORY
5179   --
5180   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added to support
5181   --                                     enhanced backward compatibility.
5182   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
5183   --                                     status and message data getting set
5184   --                                     incorrectly in update and create
5185   --                                     contact point APIs.
5186   --
5187 
5188   PROCEDURE update_telex_contact_point (
5189     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
5190     p_contact_point_rec         IN     contact_point_rec_type,
5191     p_telex_rec                   IN     telex_rec_type := g_miss_telex_rec,
5192     p_object_version_number     IN OUT NOCOPY NUMBER,
5193     x_return_status             OUT NOCOPY    VARCHAR2,
5194     x_msg_count                 OUT NOCOPY    NUMBER,
5195     x_msg_data                  OUT NOCOPY    VARCHAR2
5196   ) IS
5197   l_debug_prefix                       VARCHAR2(30) := '';
5198   BEGIN
5199     -- Standard start of API savepoint
5200     SAVEPOINT update_telex_contact_point;
5201 
5202     -- Check if API is called in debug mode. If yes, enable debug.
5203     --enable_debug;
5204 
5205     -- Debug info.
5206     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5207         hz_utility_v2pub.debug(p_message=>'update_telex_contact_point (+)',
5208                                p_prefix=>l_debug_prefix,
5209                                p_msg_level=>fnd_log.level_procedure);
5210     END IF;
5211 
5212     -- call main business logic.
5213     update_contact_point_main(
5214       p_init_msg_list           => p_init_msg_list,
5215       p_contact_point_rec       => p_contact_point_rec,
5216       p_telex_rec               => p_telex_rec,
5217       p_object_version_number   => p_object_version_number,
5218       x_return_status           => x_return_status,
5219       x_msg_count               => x_msg_count,
5220       x_msg_data                => x_msg_data
5221     );
5222 
5223       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5224     -- Debug info.
5225     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
5226          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5227                                p_msg_data=>x_msg_data,
5228                                p_msg_type=>'WARNING',
5229                                p_msg_level=>fnd_log.level_exception);
5230     END IF;
5231     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5232         hz_utility_v2pub.debug(p_message=>'update_telex_contact_point (-)',
5233                                p_prefix=>l_debug_prefix,
5234                                p_msg_level=>fnd_log.level_procedure);
5235     END IF;
5236 
5237 
5238     -- Check if API is called in debug mode. If yes, disable debug.
5239     --disable_debug;
5240 
5241   EXCEPTION
5242     WHEN fnd_api.g_exc_error THEN
5243       ROLLBACK TO update_telex_contact_point;
5244       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5245       x_return_status := fnd_api.g_ret_sts_error;
5246 
5247       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5248                                 p_count => x_msg_count,
5249                                 p_data  => x_msg_data);
5250 
5251       -- Debug info.
5252       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5253         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5254                                p_msg_data=>x_msg_data,
5255                                p_msg_type=>'ERROR',
5256                                p_msg_level=>fnd_log.level_error);
5257       END IF;
5258       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5259         hz_utility_v2pub.debug(p_message=>'update_telex_contact_point (-)',
5260                                p_prefix=>l_debug_prefix,
5261                                p_msg_level=>fnd_log.level_procedure);
5262       END IF;
5263 
5264 
5265 
5266       -- Check if API is called in debug mode. If yes, disable debug.
5267       --disable_debug;
5268 
5269     WHEN fnd_api.g_exc_unexpected_error THEN
5270       ROLLBACK TO update_telex_contact_point;
5271       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5272       x_return_status := fnd_api.g_ret_sts_unexp_error;
5273 
5274       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5275                                 p_count => x_msg_count,
5276                                 p_data  => x_msg_data);
5277 
5278       -- Debug info.
5279       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5280         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5281                                p_msg_data=>x_msg_data,
5282                                p_msg_type=>'UNEXPECTED ERROR',
5283                                p_msg_level=>fnd_log.level_error);
5284       END IF;
5285       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5286         hz_utility_v2pub.debug(p_message=>'update_telex_contact_point (-)',
5287                                p_prefix=>l_debug_prefix,
5288                                p_msg_level=>fnd_log.level_procedure);
5289       END IF;
5290 
5291       -- Check if API is called in debug mode. If yes, disable debug.
5292       --disable_debug;
5293 
5294     WHEN OTHERS THEN
5295       ROLLBACK TO update_telex_contact_point;
5296       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5297       x_return_status := fnd_api.g_ret_sts_unexp_error;
5298 
5299       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
5300       fnd_message.set_token('ERROR' ,SQLERRM);
5301       fnd_msg_pub.add;
5302 
5303       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5304                                 p_count => x_msg_count,
5305                                 p_data  => x_msg_data);
5306 
5307       -- Debug info.
5308       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5309         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5310                                p_msg_data=>x_msg_data,
5311                                p_msg_type=>'SQL ERROR',
5312                                p_msg_level=>fnd_log.level_error);
5313       END IF;
5314       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5315         hz_utility_v2pub.debug(p_message=>'update_telex_contact_point (-)',
5316                                p_prefix=>l_debug_prefix,
5317                                p_msg_level=>fnd_log.level_procedure);
5318       END IF;
5319 
5320       -- Check if API is called in debug mode. If yes, disable debug.
5321       --disable_debug;
5322   END update_telex_contact_point;
5323 
5324   --
5325   -- PROCEDURE update_email_contact_point
5326   --
5327   -- DESCRIPTION
5328   --     Updates the given email contact point.
5329   --
5330   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
5331   --
5332   -- ARGUMENTS
5333   --   IN:
5334   --     p_init_msg_list          Initialize message stack if it is set to
5335   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
5336   --     p_contact_point_rec      Contact point record.
5337   --     p_email_rec              Email record.
5338   --   IN/OUT:
5339   --     p_object_version_number  Used for locking the being updated record.
5340   --   OUT:
5341   --     x_return_status          Return status after the call. The status can
5342   --                              be fnd_api.g_ret_sts_success (success),
5343   --                              fnd_api.g_ret_sts_error (error),
5344   --                              FND_API.G_RET_STS_UNEXP_ERROR (unexpected error).
5345   --     x_msg_count              Number of messages in message stack.
5346   --     x_msg_data               Message text if x_msg_count is 1.
5347   --
5348   -- NOTES
5349   --
5350   -- MODIFICATION HISTORY
5351   --
5352   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added to support
5353   --                                     enhanced backward compatibility.
5354   --   04-FEB-2001   Joe del Callar      Bug 2211876: Fixed issue with error
5355   --                                     status and message data getting set
5356   --                                     incorrectly in update and create
5357   --                                     contact point APIs.
5358   --
5359 
5360   PROCEDURE update_email_contact_point (
5361     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
5362     p_contact_point_rec         IN     contact_point_rec_type,
5363     p_email_rec                 IN     email_rec_type := g_miss_email_rec,
5364     p_object_version_number     IN OUT NOCOPY NUMBER,
5365     x_return_status             OUT NOCOPY    VARCHAR2,
5366     x_msg_count                 OUT NOCOPY    NUMBER,
5367     x_msg_data                  OUT NOCOPY    VARCHAR2
5368   ) IS
5369   l_debug_prefix                       VARCHAR2(30) := '';
5370   BEGIN
5371     -- Standard start of API savepoint
5372     SAVEPOINT update_email_contact_point;
5373 
5374     -- Check if API is called in debug mode. If yes, enable debug.
5375     --enable_debug;
5376 
5377     -- Debug info.
5378     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5379         hz_utility_v2pub.debug(p_message=>'update_email_contact_point (+)',
5380                                p_prefix=>l_debug_prefix,
5381                                p_msg_level=>fnd_log.level_procedure);
5382     END IF;
5383 
5384     -- call main business logic.
5385     update_contact_point_main(
5386       p_init_msg_list           => p_init_msg_list,
5387       p_contact_point_rec       => p_contact_point_rec,
5388       p_email_rec               => p_email_rec,
5389       p_object_version_number   => p_object_version_number,
5390       x_return_status           => x_return_status,
5391       x_msg_count               => x_msg_count,
5392       x_msg_data                => x_msg_data
5393     );
5394 
5395       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5396     -- Debug info.
5397     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
5398          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5399                                p_msg_data=>x_msg_data,
5400                                p_msg_type=>'WARNING',
5401                                p_msg_level=>fnd_log.level_exception);
5402     END IF;
5403     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5404         hz_utility_v2pub.debug(p_message=>'update_email_contact_point (-)',
5405                                p_prefix=>l_debug_prefix,
5406                                p_msg_level=>fnd_log.level_procedure);
5407     END IF;
5408 
5409     -- Check if API is called in debug mode. If yes, disable debug.
5410     --disable_debug;
5411 
5412   EXCEPTION
5413     WHEN fnd_api.g_exc_error THEN
5414       ROLLBACK TO update_email_contact_point;
5415       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5416       x_return_status := fnd_api.g_ret_sts_error;
5417 
5418       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5419                                 p_count => x_msg_count,
5420                                 p_data  => x_msg_data);
5421 
5422       -- Debug info.
5423       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5424         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5425                                p_msg_data=>x_msg_data,
5426                                p_msg_type=>'ERROR',
5427                                p_msg_level=>fnd_log.level_error);
5428       END IF;
5429       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5430         hz_utility_v2pub.debug(p_message=>'update_email_contact_point (-)',
5431                                p_prefix=>l_debug_prefix,
5432                                p_msg_level=>fnd_log.level_procedure);
5433       END IF;
5434 
5435       -- Check if API is called in debug mode. If yes, disable debug.
5436       --disable_debug;
5437 
5438     WHEN fnd_api.g_exc_unexpected_error THEN
5439       ROLLBACK TO update_email_contact_point;
5440       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5441       x_return_status := fnd_api.g_ret_sts_unexp_error;
5442 
5443       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5444                                 p_count => x_msg_count,
5445                                 p_data  => x_msg_data);
5446 
5447       -- Debug info.
5448       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5449         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5450                                p_msg_data=>x_msg_data,
5451                                p_msg_type=>'UNEXPECTED ERROR',
5452                                p_msg_level=>fnd_log.level_error);
5453       END IF;
5454       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5455         hz_utility_v2pub.debug(p_message=>'update_email_contact_point (-)',
5456                                p_prefix=>l_debug_prefix,
5457                                p_msg_level=>fnd_log.level_procedure);
5458       END IF;
5459 
5460       -- Check if API is called in debug mode. If yes, disable debug.
5461       --disable_debug;
5462 
5463     WHEN OTHERS THEN
5464       ROLLBACK TO update_email_contact_point;
5465       HZ_UTILITY_V2PUB.G_UPDATE_ACS := NULL;
5466       x_return_status := fnd_api.g_ret_sts_unexp_error;
5467 
5468       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
5469       fnd_message.set_token('ERROR' ,SQLERRM);
5470       fnd_msg_pub.add;
5471 
5472       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5473                                 p_count => x_msg_count,
5474                                 p_data  => x_msg_data);
5475 
5476       -- Debug info.
5477       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5478         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5479                                p_msg_data=>x_msg_data,
5480                                p_msg_type=>'SQL ERROR',
5481                                p_msg_level=>fnd_log.level_error);
5482       END IF;
5483       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5484         hz_utility_v2pub.debug(p_message=>'update_email_contact_point (-)',
5485                                p_prefix=>l_debug_prefix,
5486                                p_msg_level=>fnd_log.level_procedure);
5487       END IF;
5488 
5489       -- Check if API is called in debug mode. If yes, disable debug.
5490       --disable_debug;
5491   END update_email_contact_point;
5492 
5493   --
5494   -- PROCEDURE phone_format
5495   --
5496   -- DESCRIPTION
5497   --      formats a phone number
5498   --
5499   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
5500   --
5501   -- ARGUMENTS
5502   --   IN:
5503   --     p_init_msg_list          Initialize message stack if it is set to
5504   --                              FND_API.G_TRUE. Default is fnd_api.g_false.
5505   --     p_raw_phone_number       Raw phone number.
5506   --     p_territory_code         Territory code.
5507   --   IN/OUT:
5508   --     x_phone_country_code     Phone country code.
5509   --     x_phone_area_code        Phone area code.
5510   --     x_phone_number           Phone number.
5511   --   OUT:
5512   --     x_formatted_phone_number Formatted phone number.
5513   --     x_return_status          Return status after the call. The status can
5514   --                              be fnd_api.g_ret_sts_success (success),
5515   --                              fnd_api.g_ret_sts_error (error),
5516   --                              fnd_api.g_ret_sts_unexp_error (unexpected error).
5517   --     x_msg_count              Number of messages in message stack.
5518   --     x_msg_data               Message text if x_msg_count is 1.
5519   --
5520   -- NOTES
5521   --
5522   -- MODIFICATION HISTORY
5523   --
5524   --   07-23-2001    Jianying Huang      o Created.
5525   --   02-05-2002    Jyoti Pandey        o Modified the parsing and formatting
5526   --                                       logic for Phone Normalization and Parsing
5527   --                                       project in version 115.9
5528   --
5529   --
5530 
5531   PROCEDURE phone_format (
5532     p_init_msg_list                     IN     VARCHAR2 := fnd_api.g_false,
5533     p_raw_phone_number                  IN     VARCHAR2 := fnd_api.g_miss_char,
5534     p_territory_code                    IN     VARCHAR2 := fnd_api.g_miss_char,
5535     x_formatted_phone_number            OUT NOCOPY    VARCHAR2,
5536     x_phone_country_code                IN OUT NOCOPY VARCHAR2,
5537     x_phone_area_code                   IN OUT NOCOPY VARCHAR2,
5538     x_phone_number                      IN OUT NOCOPY VARCHAR2,
5539     x_return_status                     OUT NOCOPY    VARCHAR2,
5540     x_msg_count                         OUT NOCOPY    NUMBER,
5541     x_msg_data                          OUT NOCOPY    VARCHAR2
5542   ) IS
5543     l_formatted_phone_number            VARCHAR2(100);
5544     l_phone_area_code                   VARCHAR2(30);
5545     l_phone_number                      VARCHAR2(30);
5546     l_phone_format_style                VARCHAR2(100);
5547     l_raw_phone_number                  VARCHAR2(100);
5548     l_phone_country_code                VARCHAR2(100);
5549     l_format_raw_phone                  BOOLEAN := FALSE;
5550     l_format_area_phone                 BOOLEAN := FALSE;
5551     l_include_country_code              BOOLEAN;
5552     l_area_code_size                    NUMBER;
5553     l_msg_name                          VARCHAR2(50) := NULL;
5554     l_territory_code                    VARCHAR2(30) := NULL;
5555     x_mobile_flag                       VARCHAR2(1)  := NULL;
5556 
5557     CURSOR c_territory(p_country_code VARCHAR2) IS
5558       SELECT territory_code
5559       FROM   hz_phone_country_codes
5560       WHERE  phone_country_code = p_country_code;
5561 
5562     l_debug_prefix                     VARCHAR2(30) := '';
5563 
5564   BEGIN
5565     -- Check if API is called in debug mode. If yes, enable debug.
5566     --enable_debug;
5567 
5568     -- Debug info.
5569     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5570         hz_utility_v2pub.debug(p_message=>'phone_format (+)',
5571                                p_prefix=>l_debug_prefix,
5572                                p_msg_level=>fnd_log.level_procedure);
5573     END IF;
5574 
5575     -- Initialize message list if p_init_msg_list is set to TRUE.
5576     IF fnd_api.to_boolean(p_init_msg_list) THEN
5577       fnd_msg_pub.initialize;
5578     END IF;
5579 
5580     -- Initialize API return status to success.
5581     x_return_status := fnd_api.g_ret_sts_success;
5582 
5583     -- Check if raw phone number is to be formatted
5584     IF p_raw_phone_number IS NOT NULL AND
5585        p_raw_phone_number <> fnd_api.g_miss_char THEN
5586       l_format_raw_phone := TRUE;
5587     END IF;
5588 
5589     -- Or Check if the area_code/phone number combination is to be formatted
5590     IF ((x_phone_number IS NOT NULL AND
5591            x_phone_number <> fnd_api.g_miss_char) OR
5592          (x_phone_area_code IS NOT NULL AND
5593            x_phone_area_code <> fnd_api.g_miss_char))
5594     THEN
5595       l_format_area_phone := TRUE;
5596     END IF;
5597 
5598     -- If neither need to be formatted or both need to be
5599     -- formatted, error out NOCOPY
5600     IF (l_format_raw_phone AND l_format_area_phone) OR
5601        (NOT l_format_raw_phone AND NOT l_format_area_phone)
5602     THEN
5603       fnd_message.set_name('AR', 'HZ_INVALID_PHONE_PARAMETER');
5604       fnd_msg_pub.add;
5605       RAISE fnd_api.g_exc_error;
5606     END IF;
5607 
5608     -- If not format a raw phone number, then create a raw phone
5609     -- number by appending the area code and phone number. This will
5610     -- allow use of common logic for both
5611 
5612     IF l_format_raw_phone THEN
5613        l_raw_phone_number := p_raw_phone_number;
5614     ELSIF l_format_area_phone THEN
5615       IF x_phone_area_code IS NULL OR
5616          x_phone_area_code = fnd_api.g_miss_char THEN
5617         l_raw_phone_number := filter_phone_number(x_phone_number);
5618       ELSE
5619         l_raw_phone_number := filter_phone_number(x_phone_area_code ||
5620                                                    x_phone_number);
5621       END IF;
5622     END IF;
5623 
5624     -- If Country code has been passed query the territory code for the
5625     -- country. If country code has not been passed, use territory_code.
5626 
5627     IF x_phone_country_code IS NOT NULL AND
5628        x_phone_country_code <> fnd_api.g_miss_char
5629     THEN
5630       OPEN c_territory(x_phone_country_code);
5631       FETCH c_territory INTO l_territory_code;
5632       IF c_territory%NOTFOUND THEN
5633         l_territory_code := NULL;
5634       END IF;
5635       CLOSE c_territory;
5636     ELSIF p_territory_code IS NOT NULL AND
5637           p_territory_code <> fnd_api.g_miss_char THEN
5638       l_territory_code := p_territory_code;
5639     ELSE
5640       l_territory_code := NULL;
5641     END IF;
5642 
5643    --Following commented code is replaced by parsing and displaying logic in
5644    --HZ_FORMAT_PHONE_V2PUB's phone_parse and phone_display. This was done in
5645    -- version 115.9 for Phone normalization and parsing project
5646 
5647    --Call to phone_parse to get parsed components
5648     HZ_FORMAT_PHONE_V2PUB.phone_parse (
5649     fnd_api.g_true      ,
5650     l_raw_phone_number  ,
5651     p_territory_code ,
5652     x_phone_country_code  ,
5653     x_phone_area_code    ,
5654     x_phone_number  ,
5655     x_mobile_flag ,
5656     x_return_status,
5657     x_msg_count,
5658     x_msg_data);
5659 
5660     --Parsed components are i/p to phone_display to get formateed number
5661     HZ_FORMAT_PHONE_V2PUB.phone_display(
5662     fnd_api.g_true                   ,
5663     p_territory_code,
5664     x_phone_country_code     ,
5665     x_phone_area_code        ,
5666     x_phone_number           ,
5667     x_formatted_phone_number ,
5668     x_return_status                  ,
5669     x_msg_count                 ,
5670     x_msg_data                  );
5671 
5672    /* -- Cannot get territory code, error out NOCOPY
5673    | IF l_territory_code IS NULL THEN
5674    |   fnd_message.set_name('AR', 'HZ_COUNTRY_CODE_NOT_DEFINED');
5675    |   fnd_msg_pub.add;
5676    |   RAISE fnd_api.g_exc_error;
5677    | END IF;
5678    |
5679    | -- Call subroutine to get the format style to be applied for the given
5680    | -- raw phone number and territory
5681    | get_phone_format(
5682    |   p_raw_phone_number                      => l_raw_phone_number,
5683    |   p_territory_code                        => l_territory_code,
5684    |   p_area_code                             => x_phone_area_code,
5685    |   x_phone_country_code                    => l_phone_country_code,
5686    |   x_phone_format_style                    => l_phone_format_style,
5687    |   x_area_code_size                        => l_area_code_size,
5688    |   x_include_country_code                  => l_include_country_code,
5689    |   x_msg                                   => l_msg_name);
5690    |
5691    | -- Check for errors in identifying format style
5692    | IF l_msg_name IS NOT NULL THEN
5693    |   fnd_message.set_name('AR', l_msg_name);
5694    |   fnd_msg_pub.add;
5695    |   RAISE fnd_api.g_exc_error;
5696    | END IF;
5697    |
5698    | -- Apply the format style and get translated number
5699    | translate_raw_phone_number (
5700    |   p_raw_phone_number                     => l_raw_phone_number,
5701    |   p_phone_format_style                   => l_phone_format_style,
5702    |   p_area_code_size                       => l_area_code_size,
5703    |   x_formatted_phone_number               => l_formatted_phone_number,
5704    |   x_phone_area_code                      => l_phone_area_code,
5705    |   x_phone_number                         => l_phone_number);
5706    |
5707    | -- Append country code if desired
5708    | IF l_include_country_code THEN
5709    |   x_formatted_phone_number := '+' || l_phone_country_code ||
5710    |                               ' ' || l_formatted_phone_number;
5711    | ELSE
5712    |   x_formatted_phone_number := l_formatted_phone_number;
5713    | END IF;
5714    |
5715    | -- Set the seperated area code and phone number for return
5716    | IF l_format_raw_phone THEN
5717    |   x_phone_area_code := l_phone_area_code;
5718    |   x_phone_number := l_phone_number;
5719    | END IF;
5720    |
5721    | x_phone_country_code := l_phone_country_code; */
5722 
5723     -- Standard call to get message count and if count is 1, get message info.
5724     fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5725                               p_count => x_msg_count,
5726                               p_data  => x_msg_data);
5727 
5728     -- Debug info.
5729     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
5730          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5731                                p_msg_data=>x_msg_data,
5732                                p_msg_type=>'WARNING',
5733                                p_msg_level=>fnd_log.level_exception);
5734     END IF;
5735     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5736         hz_utility_v2pub.debug(p_message=>'phone_format (-)',
5737                                p_prefix=>l_debug_prefix,
5738                                p_msg_level=>fnd_log.level_procedure);
5739     END IF;
5740 
5741     -- Check if API is called in debug mode. If yes, disable debug.
5742     --disable_debug;
5743 
5744   EXCEPTION
5745     WHEN fnd_api.g_exc_error THEN
5746       x_return_status := fnd_api.g_ret_sts_error;
5747 
5748       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5749                                 p_count => x_msg_count,
5750                                 p_data  => x_msg_data);
5751 
5752       -- Debug info.
5753       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5754         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5755                                p_msg_data=>x_msg_data,
5756                                p_msg_type=>'ERROR',
5757                                p_msg_level=>fnd_log.level_error);
5758       END IF;
5759       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5760         hz_utility_v2pub.debug(p_message=>'phone_format (-)',
5761                                p_prefix=>l_debug_prefix,
5762                                p_msg_level=>fnd_log.level_procedure);
5763       END IF;
5764 
5765       -- Check if API is called in debug mode. If yes, disable debug.
5766       --disable_debug;
5767 
5768     WHEN fnd_api.g_exc_unexpected_error THEN
5769       x_return_status := fnd_api.g_ret_sts_unexp_error;
5770 
5771       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5772                                 p_count => x_msg_count,
5773                                 p_data  => x_msg_data);
5774 
5775       -- Debug info.
5776       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5777         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5778                                p_msg_data=>x_msg_data,
5779                                p_msg_type=>'UNEXPECTED ERROR',
5780                                p_msg_level=>fnd_log.level_error);
5781       END IF;
5782       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5783         hz_utility_v2pub.debug(p_message=>'phone_format (-)',
5784                                p_prefix=>l_debug_prefix,
5785                                p_msg_level=>fnd_log.level_procedure);
5786       END IF;
5787 
5788       -- Check if API is called in debug mode. If yes, disable debug.
5789       --disable_debug;
5790 
5791     WHEN OTHERS THEN
5792       x_return_status := fnd_api.g_ret_sts_unexp_error;
5793 
5794       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
5795       fnd_message.set_token('ERROR' ,SQLERRM);
5796       fnd_msg_pub.add;
5797 
5798       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5799                                 p_count => x_msg_count,
5800                                 p_data  => x_msg_data);
5801 
5802       -- Debug info.
5803       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5804         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5805                                p_msg_data=>x_msg_data,
5806                                p_msg_type=>'SQL ERROR',
5807                                p_msg_level=>fnd_log.level_error);
5808       END IF;
5809       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5810         hz_utility_v2pub.debug(p_message=>'phone_format (-)',
5811                                p_prefix=>l_debug_prefix,
5812                                p_msg_level=>fnd_log.level_procedure);
5813       END IF;
5814 
5815       -- Check if API is called in debug mode. If yes, disable debug.
5816       --disable_debug;
5817 
5818   END phone_format;
5819 
5820   --
5821   -- PROCEDURE get_contact_point_rec
5822   --
5823   -- DESCRIPTION
5824   --     Gets contact point record.  Still here for backward compatibility.
5825   --
5826   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
5827   --
5828   -- ARGUMENTS
5829   --   IN:
5830   --     p_init_msg_list      Initialize message stack if it is set to
5831   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
5832   --     p_contact_point_id   Contact point ID.
5833   --   IN/OUT:
5834   --   OUT:
5835   --     x_contact_point_rec  Returned contact point record.
5836   --     x_edi_rec            Returned EDI record.
5837   --     x_email_rec          Returned email record.
5838   --     x_phone_rec          Returned phone record.
5839   --     x_telex_rec          Returned telex record.
5840   --     x_web_rec            Returned web record.
5841   --     x_return_status      Return status after the call. The status can
5842   --                          be fnd_api.g_ret_sts_success (success),
5843   --                          fnd_api.g_ret_sts_error (error),
5844   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
5845   --     x_msg_count          Number of messages in message stack.
5846   --     x_msg_data           Message text if x_msg_count is 1.
5847   --
5848   -- NOTES
5849   --
5850   -- MODIFICATION HISTORY
5851   --
5852   --   07-23-2001    Jianying Huang      o Created.
5853   --   19-NOV-2001   Joe del Callar      Bug 2116225: Added support for
5854   --                                     Bank Consolidation.
5855   --
5856 
5857   PROCEDURE get_contact_point_rec (
5858     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
5859     p_contact_point_id          IN     NUMBER,
5860     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
5861     x_edi_rec                   OUT    NOCOPY edi_rec_type,
5862     x_email_rec                 OUT    NOCOPY email_rec_type,
5863     x_phone_rec                 OUT    NOCOPY phone_rec_type,
5864     x_telex_rec                 OUT    NOCOPY telex_rec_type,
5865     x_web_rec                   OUT    NOCOPY web_rec_type,
5866     x_return_status             OUT NOCOPY    VARCHAR2,
5867     x_msg_count                 OUT NOCOPY    NUMBER,
5868     x_msg_data                  OUT NOCOPY    VARCHAR2
5869   ) IS
5870     l_eft_rec                   eft_rec_type := g_miss_eft_rec;
5871     l_debug_prefix              VARCHAR2(30) := '';
5872   BEGIN
5873 
5874     -- Check if API is called in debug mode. If yes, enable debug.
5875     --enable_debug;
5876 
5877     -- Debug info.
5878     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5879         hz_utility_v2pub.debug(p_message=>'get_contact_point_rec (+)',
5880                                p_prefix=>l_debug_prefix,
5881                                p_msg_level=>fnd_log.level_procedure);
5882     END IF;
5883 
5884     -- Execute main procedure
5885     get_contact_point_main (
5886       p_init_msg_list           => p_init_msg_list,
5887       p_contact_point_id        => p_contact_point_id,
5888       x_contact_point_rec       => x_contact_point_rec,
5889       x_edi_rec                 => x_edi_rec,
5890       x_eft_rec                 => l_eft_rec,
5891       x_email_rec               => x_email_rec,
5892       x_phone_rec               => x_phone_rec,
5893       x_telex_rec               => x_telex_rec,
5894       x_web_rec                 => x_web_rec,
5895       x_return_status           => x_return_status,
5896       x_msg_count               => x_msg_count,
5897       x_msg_data                => x_msg_data
5898     );
5899 
5900     -- Debug info.
5901     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
5902          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5903                                p_msg_data=>x_msg_data,
5904                                p_msg_type=>'WARNING',
5905                                p_msg_level=>fnd_log.level_exception);
5906     END IF;
5907     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5908         hz_utility_v2pub.debug(p_message=>'get_contact_point_rec (-)',
5909                                p_prefix=>l_debug_prefix,
5910                                p_msg_level=>fnd_log.level_procedure);
5911     END IF;
5912 
5913     -- Check if API is called in debug mode. If yes, disable debug.
5914     --disable_debug;
5915 
5916   EXCEPTION
5917     WHEN fnd_api.g_exc_error THEN
5918       x_return_status := fnd_api.g_ret_sts_error;
5919 
5920       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5921                                 p_count => x_msg_count,
5922                                 p_data  => x_msg_data);
5923 
5924       -- Debug info.
5925       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5926         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5927                                p_msg_data=>x_msg_data,
5928                                p_msg_type=>'ERROR',
5929                                p_msg_level=>fnd_log.level_error);
5930       END IF;
5931       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5932         hz_utility_v2pub.debug(p_message=>'get_contact_point_rec (-)',
5933                                p_prefix=>l_debug_prefix,
5934                                p_msg_level=>fnd_log.level_procedure);
5935       END IF;
5936 
5937       -- Check if API is called in debug mode. If yes, disable debug.
5938       --disable_debug;
5939 
5940     WHEN fnd_api.g_exc_unexpected_error THEN
5941       x_return_status := fnd_api.g_ret_sts_unexp_error;
5942 
5943       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5944                                 p_count => x_msg_count,
5945                                 p_data  => x_msg_data);
5946 
5947       -- Debug info.
5948       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5949         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5950                                p_msg_data=>x_msg_data,
5951                                p_msg_type=>'UNEXPECTED ERROR',
5952                                p_msg_level=>fnd_log.level_error);
5953       END IF;
5954       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5955         hz_utility_v2pub.debug(p_message=>'get_contact_point_rec (-)',
5956                                p_prefix=>l_debug_prefix,
5957                                p_msg_level=>fnd_log.level_procedure);
5958       END IF;
5959 
5960       -- Check if API is called in debug mode. If yes, disable debug.
5961       --disable_debug;
5962 
5963     WHEN OTHERS THEN
5964       x_return_status := fnd_api.g_ret_sts_unexp_error;
5965 
5966       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
5967       fnd_message.set_token('ERROR' ,SQLERRM);
5968       fnd_msg_pub.add;
5969 
5970       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
5971                                 p_count => x_msg_count,
5972                                 p_data  => x_msg_data);
5973 
5974       -- Debug info.
5975       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
5976         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
5977                                p_msg_data=>x_msg_data,
5978                                p_msg_type=>'SQL ERROR',
5979                                p_msg_level=>fnd_log.level_error);
5980       END IF;
5981       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
5982         hz_utility_v2pub.debug(p_message=>'get_contact_point_rec (-)',
5983                                p_prefix=>l_debug_prefix,
5984                                p_msg_level=>fnd_log.level_procedure);
5985       END IF;
5986 
5987       -- Check if API is called in debug mode. If yes, disable debug.
5988       --disable_debug;
5989   END get_contact_point_rec;
5990 
5991   --
5992   -- PROCEDURE get_edi_contact_point
5993   --
5994   -- DESCRIPTION
5995   --     Gets EDI contact point record.
5996   --
5997   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
5998   --
5999   -- ARGUMENTS
6000   --   IN:
6001   --     p_init_msg_list      Initialize message stack if it is set to
6002   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
6003   --     p_contact_point_id   Contact point ID.
6004   --   IN/OUT:
6005   --   OUT:
6006   --     x_contact_point_rec  Returned contact point record.
6007   --     x_edi_rec            Returned EDI record.
6008   --     x_return_status      Return status after the call. The status can
6009   --                          be fnd_api.g_ret_sts_success (success),
6010   --                          fnd_api.g_ret_sts_error (error),
6011   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
6012   --     x_msg_count          Number of messages in message stack.
6013   --     x_msg_data           Message text if x_msg_count is 1.
6014   --
6015   -- NOTES
6016   --
6017   -- MODIFICATION HISTORY
6018   --
6019   --   07-23-2001    Jianying Huang      o Created.
6020   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
6021   --                                     enhanced backward compatibility.
6022   --
6023 
6024   PROCEDURE get_edi_contact_point (
6025     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
6026     p_contact_point_id          IN     NUMBER,
6027     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
6028     x_edi_rec                   OUT    NOCOPY edi_rec_type,
6029     x_return_status             OUT NOCOPY    VARCHAR2,
6030     x_msg_count                 OUT NOCOPY    NUMBER,
6031     x_msg_data                  OUT NOCOPY    VARCHAR2
6032   ) IS
6033     l_eft_rec                   eft_rec_type := g_miss_eft_rec;
6034     l_web_rec                   web_rec_type := g_miss_web_rec;
6035     l_phone_rec                 phone_rec_type := g_miss_phone_rec;
6036     l_telex_rec                 telex_rec_type := g_miss_telex_rec;
6037     l_email_rec                 email_rec_type := g_miss_email_rec;
6038     l_debug_prefix              VARCHAR2(30) := '';
6039   BEGIN
6040     -- Check if API is called in debug mode. If yes, enable debug.
6041     --enable_debug;
6042 
6043     -- Debug info.
6044     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6045         hz_utility_v2pub.debug(p_message=>'get_edi_contact_point (+)',
6046                                p_prefix=>l_debug_prefix,
6047                                p_msg_level=>fnd_log.level_procedure);
6048     END IF;
6049 
6050     -- Execute main procedure
6051     get_contact_point_main (
6052       p_init_msg_list           => p_init_msg_list,
6053       p_contact_point_id        => p_contact_point_id,
6054       x_contact_point_rec       => x_contact_point_rec,
6055       x_edi_rec                 => x_edi_rec,
6056       x_eft_rec                 => l_eft_rec,
6057       x_email_rec               => l_email_rec,
6058       x_phone_rec               => l_phone_rec,
6059       x_telex_rec               => l_telex_rec,
6060       x_web_rec                 => l_web_rec,
6061       x_return_status           => x_return_status,
6062       x_msg_count               => x_msg_count,
6063       x_msg_data                => x_msg_data
6064     );
6065 
6066     -- Debug info.
6067     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
6068          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6069                                p_msg_data=>x_msg_data,
6070                                p_msg_type=>'WARNING',
6071                                p_msg_level=>fnd_log.level_exception);
6072     END IF;
6073     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6074         hz_utility_v2pub.debug(p_message=>'get_edi_contact_point (-)',
6075                                p_prefix=>l_debug_prefix,
6076                                p_msg_level=>fnd_log.level_procedure);
6077     END IF;
6078 
6079     -- Check if API is called in debug mode. If yes, disable debug.
6080     --disable_debug;
6081 
6082   EXCEPTION
6083     WHEN fnd_api.g_exc_error THEN
6084       x_return_status := fnd_api.g_ret_sts_error;
6085 
6086       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6087                                 p_count => x_msg_count,
6088                                 p_data  => x_msg_data);
6089 
6090       -- Debug info.
6091       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6092         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6093                                p_msg_data=>x_msg_data,
6094                                p_msg_type=>'ERROR',
6095                                p_msg_level=>fnd_log.level_error);
6096       END IF;
6097       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6098         hz_utility_v2pub.debug(p_message=>'get_edi_contact_point (-)',
6099                                p_prefix=>l_debug_prefix,
6100                                p_msg_level=>fnd_log.level_procedure);
6101       END IF;
6102 
6103       -- Check if API is called in debug mode. If yes, disable debug.
6104       --disable_debug;
6105 
6106     WHEN fnd_api.g_exc_unexpected_error THEN
6107       x_return_status := fnd_api.g_ret_sts_unexp_error;
6108 
6109       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6110                                 p_count => x_msg_count,
6111                                 p_data  => x_msg_data);
6112 
6113       -- Debug info.
6114       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6115         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6116                                p_msg_data=>x_msg_data,
6117                                p_msg_type=>'UNEXPECTED ERROR',
6118                                p_msg_level=>fnd_log.level_error);
6119       END IF;
6120       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6121         hz_utility_v2pub.debug(p_message=>'get_edi_contact_point (-)',
6122                                p_prefix=>l_debug_prefix,
6123                                p_msg_level=>fnd_log.level_procedure);
6124       END IF;
6125 
6126       -- Check if API is called in debug mode. If yes, disable debug.
6127       --disable_debug;
6128 
6129     WHEN OTHERS THEN
6130       x_return_status := fnd_api.g_ret_sts_unexp_error;
6131 
6132       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
6133       fnd_message.set_token('ERROR' ,SQLERRM);
6134       fnd_msg_pub.add;
6135 
6136       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6137                                 p_count => x_msg_count,
6138                                 p_data  => x_msg_data);
6139 
6140       -- Debug info.
6141       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6142         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6143                                p_msg_data=>x_msg_data,
6144                                p_msg_type=>'SQL ERROR',
6145                                p_msg_level=>fnd_log.level_error);
6146       END IF;
6147       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6148         hz_utility_v2pub.debug(p_message=>'get_edi_contact_point (-)',
6149                                p_prefix=>l_debug_prefix,
6150                                p_msg_level=>fnd_log.level_procedure);
6151       END IF;
6152 
6153       -- Check if API is called in debug mode. If yes, disable debug.
6154       --disable_debug;
6155   END get_edi_contact_point;
6156 
6157   --
6158   -- PROCEDURE get_eft_contact_point
6159   --
6160   -- DESCRIPTION
6161   --     Gets EFT contact point record.
6162   --
6163   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
6164   --
6165   -- ARGUMENTS
6166   --   IN:
6167   --     p_init_msg_list      Initialize message stack if it is set to
6168   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
6169   --     p_contact_point_id   Contact point ID.
6170   --   IN/OUT:
6171   --   OUT:
6172   --     x_contact_point_rec  Returned contact point record.
6173   --     x_eft_rec            Returned EFT record.
6174   --     x_return_status      Return status after the call. The status can
6175   --                          be fnd_api.g_ret_sts_success (success),
6176   --                          fnd_api.g_ret_sts_error (error),
6177   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
6178   --     x_msg_count          Number of messages in message stack.
6179   --     x_msg_data           Message text if x_msg_count is 1.
6180   --
6181   -- NOTES
6182   --
6183   -- MODIFICATION HISTORY
6184   --
6185   --   07-23-2001    Jianying Huang      o Created.
6186   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
6187   --                                     enhanced backward compatibility.
6188   --
6189 
6190   PROCEDURE get_eft_contact_point (
6191     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
6192     p_contact_point_id          IN     NUMBER,
6193     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
6194     x_eft_rec                   OUT    NOCOPY eft_rec_type,
6195     x_return_status             OUT NOCOPY    VARCHAR2,
6196     x_msg_count                 OUT NOCOPY    NUMBER,
6197     x_msg_data                  OUT NOCOPY    VARCHAR2
6198   ) IS
6199     l_edi_rec                   edi_rec_type := g_miss_edi_rec;
6200     l_web_rec                   web_rec_type := g_miss_web_rec;
6201     l_phone_rec                 phone_rec_type := g_miss_phone_rec;
6202     l_telex_rec                 telex_rec_type := g_miss_telex_rec;
6203     l_email_rec                 email_rec_type := g_miss_email_rec;
6204     l_debug_prefix              VARCHAR2(30) := '';
6205   BEGIN
6206     -- Check if API is called in debug mode. If yes, enable debug.
6207     --enable_debug;
6208 
6209     -- Debug info.
6210     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6211         hz_utility_v2pub.debug(p_message=>'get_eft_contact_point (+)',
6212                                p_prefix=>l_debug_prefix,
6213                                p_msg_level=>fnd_log.level_procedure);
6214     END IF;
6215 
6216     -- Execute main procedure
6217     get_contact_point_main (
6218       p_init_msg_list           => p_init_msg_list,
6219       p_contact_point_id        => p_contact_point_id,
6220       x_contact_point_rec       => x_contact_point_rec,
6221       x_edi_rec                 => l_edi_rec,
6222       x_eft_rec                 => x_eft_rec,
6223       x_email_rec               => l_email_rec,
6224       x_phone_rec               => l_phone_rec,
6225       x_telex_rec               => l_telex_rec,
6226       x_web_rec                 => l_web_rec,
6227       x_return_status           => x_return_status,
6228       x_msg_count               => x_msg_count,
6229       x_msg_data                => x_msg_data
6230     );
6231 
6232 
6233     -- Debug info.
6234     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
6235          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6236                                p_msg_data=>x_msg_data,
6237                                p_msg_type=>'WARNING',
6238                                p_msg_level=>fnd_log.level_exception);
6239     END IF;
6240     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6241         hz_utility_v2pub.debug(p_message=>'get_eft_contact_point (-)',
6242                                p_prefix=>l_debug_prefix,
6243                                p_msg_level=>fnd_log.level_procedure);
6244     END IF;
6245 
6246     -- Check if API is called in debug mode. If yes, disable debug.
6247     --disable_debug;
6248 
6249   EXCEPTION
6250     WHEN fnd_api.g_exc_error THEN
6251       x_return_status := fnd_api.g_ret_sts_error;
6252 
6253       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6254                                 p_count => x_msg_count,
6255                                 p_data  => x_msg_data);
6256 
6257       -- Debug info.
6258       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6259         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6260                                p_msg_data=>x_msg_data,
6261                                p_msg_type=>'ERROR',
6262                                p_msg_level=>fnd_log.level_error);
6263       END IF;
6264       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6265         hz_utility_v2pub.debug(p_message=>'get_eft_contact_point (-)',
6266                                p_prefix=>l_debug_prefix,
6267                                p_msg_level=>fnd_log.level_procedure);
6268       END IF;
6269 
6270       -- Check if API is called in debug mode. If yes, disable debug.
6271       --disable_debug;
6272 
6273     WHEN fnd_api.g_exc_unexpected_error THEN
6274       x_return_status := fnd_api.g_ret_sts_unexp_error;
6275 
6276       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6277                                 p_count => x_msg_count,
6278                                 p_data  => x_msg_data);
6279 
6280       -- Debug info.
6281       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6282         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6283                                p_msg_data=>x_msg_data,
6284                                p_msg_type=>'UNEXPECTED ERROR',
6285                                p_msg_level=>fnd_log.level_error);
6286       END IF;
6287       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6288         hz_utility_v2pub.debug(p_message=>'get_eft_contact_point (-)',
6289                                p_prefix=>l_debug_prefix,
6290                                p_msg_level=>fnd_log.level_procedure);
6291       END IF;
6292 
6293       -- Check if API is called in debug mode. If yes, disable debug.
6294       --disable_debug;
6295 
6296     WHEN OTHERS THEN
6297       x_return_status := fnd_api.g_ret_sts_unexp_error;
6298 
6299       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
6300       fnd_message.set_token('ERROR' ,SQLERRM);
6301       fnd_msg_pub.add;
6302 
6303       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6304                                 p_count => x_msg_count,
6305                                 p_data  => x_msg_data);
6306 
6307       -- Debug info.
6308       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6309         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6310                                p_msg_data=>x_msg_data,
6311                                p_msg_type=>'SQL ERROR',
6312                                p_msg_level=>fnd_log.level_error);
6313       END IF;
6314       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6315         hz_utility_v2pub.debug(p_message=>'get_eft_contact_point (-)',
6316                                p_prefix=>l_debug_prefix,
6317                                p_msg_level=>fnd_log.level_procedure);
6318       END IF;
6319 
6320       -- Check if API is called in debug mode. If yes, disable debug.
6321       --disable_debug;
6322   END get_eft_contact_point;
6323 
6324   --
6325   -- PROCEDURE get_web_contact_point
6326   --
6327   -- DESCRIPTION
6328   --     Gets Web contact point record.
6329   --
6330   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
6331   --
6332   -- ARGUMENTS
6333   --   IN:
6334   --     p_init_msg_list      Initialize message stack if it is set to
6335   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
6336   --     p_contact_point_id   Contact point ID.
6337   --   IN/OUT:
6338   --   OUT:
6339   --     x_contact_point_rec  Returned contact point record.
6340   --     x_web_rec            Returned Web record.
6341   --     x_return_status      Return status after the call. The status can
6342   --                          be fnd_api.g_ret_sts_success (success),
6343   --                          fnd_api.g_ret_sts_error (error),
6344   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
6345   --     x_msg_count          Number of messages in message stack.
6346   --     x_msg_data           Message text if x_msg_count is 1.
6347   --
6348   -- NOTES
6349   --
6350   -- MODIFICATION HISTORY
6351   --
6352   --   07-23-2001    Jianying Huang      o Created.
6353   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
6354   --                                     enhanced backward compatibility.
6355   --
6356 
6357   PROCEDURE get_web_contact_point (
6358     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
6359     p_contact_point_id          IN     NUMBER,
6360     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
6361     x_web_rec                   OUT    NOCOPY web_rec_type,
6362     x_return_status             OUT NOCOPY    VARCHAR2,
6363     x_msg_count                 OUT NOCOPY    NUMBER,
6364     x_msg_data                  OUT NOCOPY    VARCHAR2
6365   ) IS
6366     l_edi_rec                   edi_rec_type := g_miss_edi_rec;
6367     l_eft_rec                   eft_rec_type := g_miss_eft_rec;
6368     l_phone_rec                 phone_rec_type := g_miss_phone_rec;
6369     l_telex_rec                 telex_rec_type := g_miss_telex_rec;
6370     l_email_rec                 email_rec_type := g_miss_email_rec;
6371     l_debug_prefix              VARCHAR2(30) := '';
6372   BEGIN
6373 
6374     -- Check if API is called in debug mode. If yes, enable debug.
6375     --enable_debug;
6376 
6377     -- Debug info.
6378     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6379         hz_utility_v2pub.debug(p_message=>'get_web_contact_point (+)',
6380                                p_prefix=>l_debug_prefix,
6381                                p_msg_level=>fnd_log.level_procedure);
6382     END IF;
6383 
6384     -- Execute main procedure
6385     get_contact_point_main (
6386       p_init_msg_list           => p_init_msg_list,
6387       p_contact_point_id        => p_contact_point_id,
6388       x_contact_point_rec       => x_contact_point_rec,
6389       x_edi_rec                 => l_edi_rec,
6390       x_eft_rec                 => l_eft_rec,
6391       x_email_rec               => l_email_rec,
6392       x_phone_rec               => l_phone_rec,
6393       x_telex_rec               => l_telex_rec,
6394       x_web_rec                 => x_web_rec,
6395       x_return_status           => x_return_status,
6396       x_msg_count               => x_msg_count,
6397       x_msg_data                => x_msg_data
6398     );
6399 
6400     -- Debug info.
6401     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
6402          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6403                                p_msg_data=>x_msg_data,
6404                                p_msg_type=>'WARNING',
6405                                p_msg_level=>fnd_log.level_exception);
6406     END IF;
6407     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6408         hz_utility_v2pub.debug(p_message=>'get_web_contact_point (-)',
6409                                p_prefix=>l_debug_prefix,
6410                                p_msg_level=>fnd_log.level_procedure);
6411     END IF;
6412 
6413     -- Check if API is called in debug mode. If yes, disable debug.
6414     --disable_debug;
6415 
6416   EXCEPTION
6417     WHEN fnd_api.g_exc_error THEN
6418       x_return_status := fnd_api.g_ret_sts_error;
6419 
6420       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6421                                 p_count => x_msg_count,
6422                                 p_data  => x_msg_data);
6423 
6424       -- Debug info.
6425       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6426         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6427                                p_msg_data=>x_msg_data,
6428                                p_msg_type=>'ERROR',
6429                                p_msg_level=>fnd_log.level_error);
6430       END IF;
6431       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6432         hz_utility_v2pub.debug(p_message=>'get_web_contact_point (-)',
6433                                p_prefix=>l_debug_prefix,
6434                                p_msg_level=>fnd_log.level_procedure);
6435       END IF;
6436 
6437       -- Check if API is called in debug mode. If yes, disable debug.
6438       --disable_debug;
6439 
6440     WHEN fnd_api.g_exc_unexpected_error THEN
6441       x_return_status := fnd_api.g_ret_sts_unexp_error;
6442 
6443       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6444                                 p_count => x_msg_count,
6445                                 p_data  => x_msg_data);
6446 
6447       -- Debug info.
6448       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6449         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6450                                p_msg_data=>x_msg_data,
6451                                p_msg_type=>'UNEXPECTED ERROR',
6452                                p_msg_level=>fnd_log.level_error);
6453       END IF;
6454       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6455         hz_utility_v2pub.debug(p_message=>'get_web_contact_point (-)',
6456                                p_prefix=>l_debug_prefix,
6457                                p_msg_level=>fnd_log.level_procedure);
6458       END IF;
6459 
6460 
6461       -- Check if API is called in debug mode. If yes, disable debug.
6462       --disable_debug;
6463 
6464     WHEN OTHERS THEN
6465       x_return_status := fnd_api.g_ret_sts_unexp_error;
6466 
6467       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
6468       fnd_message.set_token('ERROR' ,SQLERRM);
6469       fnd_msg_pub.add;
6470 
6471       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6472                                 p_count => x_msg_count,
6473                                 p_data  => x_msg_data);
6474 
6475       -- Debug info.
6476       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6477         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6478                                p_msg_data=>x_msg_data,
6479                                p_msg_type=>'SQL ERROR',
6480                                p_msg_level=>fnd_log.level_error);
6481       END IF;
6482       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6483         hz_utility_v2pub.debug(p_message=>'get_web_contact_point (-)',
6484                                p_prefix=>l_debug_prefix,
6485                                p_msg_level=>fnd_log.level_procedure);
6486       END IF;
6487 
6488       -- Check if API is called in debug mode. If yes, disable debug.
6489       --disable_debug;
6490   END get_web_contact_point;
6491 
6492   --
6493   -- PROCEDURE get_phone_contact_point
6494   --
6495   -- DESCRIPTION
6496   --     Gets phone contact point record.
6497   --
6498   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
6499   --
6500   -- ARGUMENTS
6501   --   IN:
6502   --     p_init_msg_list      Initialize message stack if it is set to
6503   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
6504   --     p_contact_point_id   Contact point ID.
6505   --   IN/OUT:
6506   --   OUT:
6507   --     x_contact_point_rec  Returned contact point record.
6508   --     x_phone_rec          Returned phone record.
6509   --     x_return_status      Return status after the call. The status can
6510   --                          be fnd_api.g_ret_sts_success (success),
6511   --                          fnd_api.g_ret_sts_error (error),
6512   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
6513   --     x_msg_count          Number of messages in message stack.
6514   --     x_msg_data           Message text if x_msg_count is 1.
6515   --
6516   -- NOTES
6517   --
6518   -- MODIFICATION HISTORY
6519   --
6520   --   07-23-2001    Jianying Huang      o Created.
6521   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
6522   --                                     enhanced backward compatibility.
6523   --
6524 
6525   PROCEDURE get_phone_contact_point (
6526     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
6527     p_contact_point_id          IN     NUMBER,
6528     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
6529     x_phone_rec                   OUT    NOCOPY phone_rec_type,
6530     x_return_status             OUT NOCOPY    VARCHAR2,
6531     x_msg_count                 OUT NOCOPY    NUMBER,
6532     x_msg_data                  OUT NOCOPY    VARCHAR2
6533   ) IS
6534     l_edi_rec                   edi_rec_type := g_miss_edi_rec;
6535     l_eft_rec                   eft_rec_type := g_miss_eft_rec;
6536     l_web_rec                   web_rec_type := g_miss_web_rec;
6537     l_telex_rec                 telex_rec_type := g_miss_telex_rec;
6538     l_email_rec                 email_rec_type := g_miss_email_rec;
6539     l_debug_prefix              VARCHAR2(30) := '';
6540   BEGIN
6541     -- Check if API is called in debug mode. If yes, enable debug.
6542     --enable_debug;
6543 
6544     -- Debug info.
6545     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6546         hz_utility_v2pub.debug(p_message=>'get_phone_contact_point (+)',
6547                                p_prefix=>l_debug_prefix,
6548                                p_msg_level=>fnd_log.level_procedure);
6549     END IF;
6550 
6551     -- Execute main procedure
6552     get_contact_point_main (
6553       p_init_msg_list           => p_init_msg_list,
6554       p_contact_point_id        => p_contact_point_id,
6555       x_contact_point_rec       => x_contact_point_rec,
6556       x_edi_rec                 => l_edi_rec,
6557       x_eft_rec                 => l_eft_rec,
6558       x_email_rec               => l_email_rec,
6559       x_phone_rec               => x_phone_rec,
6560       x_telex_rec               => l_telex_rec,
6561       x_web_rec                 => l_web_rec,
6562       x_return_status           => x_return_status,
6563       x_msg_count               => x_msg_count,
6564       x_msg_data                => x_msg_data
6565     );
6566 
6567     -- Debug info.
6568     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
6569          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6570                                p_msg_data=>x_msg_data,
6571                                p_msg_type=>'WARNING',
6572                                p_msg_level=>fnd_log.level_exception);
6573     END IF;
6574     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6575         hz_utility_v2pub.debug(p_message=>'get_phone_contact_point (-)',
6576                                p_prefix=>l_debug_prefix,
6577                                p_msg_level=>fnd_log.level_procedure);
6578     END IF;
6579 
6580     -- Check if API is called in debug mode. If yes, disable debug.
6581     --disable_debug;
6582 
6583   EXCEPTION
6584     WHEN fnd_api.g_exc_error THEN
6585       x_return_status := fnd_api.g_ret_sts_error;
6586 
6587       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6588                                 p_count => x_msg_count,
6589                                 p_data  => x_msg_data);
6590 
6591       -- Debug info.
6592       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6593         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6594                                p_msg_data=>x_msg_data,
6595                                p_msg_type=>'ERROR',
6596                                p_msg_level=>fnd_log.level_error);
6597       END IF;
6598       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6599         hz_utility_v2pub.debug(p_message=>'get_phone_contact_point (-)',
6600                                p_prefix=>l_debug_prefix,
6601                                p_msg_level=>fnd_log.level_procedure);
6602       END IF;
6603 
6604       -- Check if API is called in debug mode. If yes, disable debug.
6605       --disable_debug;
6606 
6607     WHEN fnd_api.g_exc_unexpected_error THEN
6608       x_return_status := fnd_api.g_ret_sts_unexp_error;
6609 
6610       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6611                                 p_count => x_msg_count,
6612                                 p_data  => x_msg_data);
6613 
6614       -- Debug info.
6615       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6616         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6617                                p_msg_data=>x_msg_data,
6618                                p_msg_type=>'UNEXPECTED ERROR',
6619                                p_msg_level=>fnd_log.level_error);
6620       END IF;
6621       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6622         hz_utility_v2pub.debug(p_message=>'get_phone_contact_point (-)',
6623                                p_prefix=>l_debug_prefix,
6624                                p_msg_level=>fnd_log.level_procedure);
6625       END IF;
6626 
6627       -- Check if API is called in debug mode. If yes, disable debug.
6628       --disable_debug;
6629 
6630     WHEN OTHERS THEN
6631       x_return_status := fnd_api.g_ret_sts_unexp_error;
6632 
6633       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
6634       fnd_message.set_token('ERROR' ,SQLERRM);
6635       fnd_msg_pub.add;
6636 
6637       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6638                                 p_count => x_msg_count,
6639                                 p_data  => x_msg_data);
6640 
6641       -- Debug info.
6642       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6643         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6644                                p_msg_data=>x_msg_data,
6645                                p_msg_type=>'SQL ERROR',
6646                                p_msg_level=>fnd_log.level_error);
6647       END IF;
6648       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6649         hz_utility_v2pub.debug(p_message=>'get_phone_contact_point (-)',
6650                                p_prefix=>l_debug_prefix,
6651                                p_msg_level=>fnd_log.level_procedure);
6652       END IF;
6653 
6654       -- Check if API is called in debug mode. If yes, disable debug.
6655       --disable_debug;
6656   END get_phone_contact_point;
6657 
6658   --
6659   -- PROCEDURE get_telex_contact_point
6660   --
6661   -- DESCRIPTION
6662   --     Gets telex contact point record.
6663   --
6664   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
6665   --
6666   -- ARGUMENTS
6667   --   IN:
6668   --     p_init_msg_list      Initialize message stack if it is set to
6669   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
6670   --     p_contact_point_id   Contact point ID.
6671   --   IN/OUT:
6672   --   OUT:
6673   --     x_contact_point_rec  Returned contact point record.
6674   --     x_telex_rec          Returned telex record.
6675   --     x_return_status      Return status after the call. The status can
6676   --                          be fnd_api.g_ret_sts_success (success),
6677   --                          fnd_api.g_ret_sts_error (error),
6678   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
6679   --     x_msg_count          Number of messages in message stack.
6680   --     x_msg_data           Message text if x_msg_count is 1.
6681   --
6682   -- NOTES
6683   --
6684   -- MODIFICATION HISTORY
6685   --
6686   --   07-23-2001    Jianying Huang      o Created.
6687   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
6688   --                                     enhanced backward compatibility.
6689   --
6690 
6691   PROCEDURE get_telex_contact_point (
6692     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
6693     p_contact_point_id          IN     NUMBER,
6694     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
6695     x_telex_rec                   OUT    NOCOPY telex_rec_type,
6696     x_return_status             OUT NOCOPY    VARCHAR2,
6697     x_msg_count                 OUT NOCOPY    NUMBER,
6698     x_msg_data                  OUT NOCOPY    VARCHAR2
6699   ) IS
6700     l_edi_rec                   edi_rec_type := g_miss_edi_rec;
6701     l_eft_rec                   eft_rec_type := g_miss_eft_rec;
6702     l_web_rec                   web_rec_type := g_miss_web_rec;
6703     l_phone_rec                 phone_rec_type := g_miss_phone_rec;
6704     l_email_rec                 email_rec_type := g_miss_email_rec;
6705     l_debug_prefix              VARCHAR2(30) := '';
6706   BEGIN
6707     -- Check if API is called in debug mode. If yes, enable debug.
6708     --enable_debug;
6709 
6710     -- Debug info.
6711     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6712         hz_utility_v2pub.debug(p_message=>'get_telex_contact_point (+)',
6713                                p_prefix=>l_debug_prefix,
6714                                p_msg_level=>fnd_log.level_procedure);
6715     END IF;
6716 
6717     -- Execute main procedure
6718     get_contact_point_main (
6719       p_init_msg_list           => p_init_msg_list,
6720       p_contact_point_id        => p_contact_point_id,
6721       x_contact_point_rec       => x_contact_point_rec,
6722       x_edi_rec                 => l_edi_rec,
6723       x_eft_rec                 => l_eft_rec,
6724       x_email_rec               => l_email_rec,
6725       x_phone_rec               => l_phone_rec,
6726       x_telex_rec               => x_telex_rec,
6727       x_web_rec                 => l_web_rec,
6728       x_return_status           => x_return_status,
6729       x_msg_count               => x_msg_count,
6730       x_msg_data                => x_msg_data
6731     );
6732 
6733     -- Debug info.
6734     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
6735          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6736                                p_msg_data=>x_msg_data,
6737                                p_msg_type=>'WARNING',
6738                                p_msg_level=>fnd_log.level_exception);
6739     END IF;
6740     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6741         hz_utility_v2pub.debug(p_message=>'get_telex_contact_point (-)',
6742                                p_prefix=>l_debug_prefix,
6743                                p_msg_level=>fnd_log.level_procedure);
6744     END IF;
6745 
6746     -- Check if API is called in debug mode. If yes, disable debug.
6747     --disable_debug;
6748 
6749   EXCEPTION
6750     WHEN fnd_api.g_exc_error THEN
6751       x_return_status := fnd_api.g_ret_sts_error;
6752 
6753       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6754                                 p_count => x_msg_count,
6755                                 p_data  => x_msg_data);
6756 
6757       -- Debug info.
6758       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6759         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6760                                p_msg_data=>x_msg_data,
6761                                p_msg_type=>'ERROR',
6762                                p_msg_level=>fnd_log.level_error);
6763       END IF;
6764       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6765         hz_utility_v2pub.debug(p_message=>'get_telex_contact_point (-)',
6766                                p_prefix=>l_debug_prefix,
6767                                p_msg_level=>fnd_log.level_procedure);
6768       END IF;
6769 
6770       -- Check if API is called in debug mode. If yes, disable debug.
6771       --disable_debug;
6772 
6773     WHEN fnd_api.g_exc_unexpected_error THEN
6774       x_return_status := fnd_api.g_ret_sts_unexp_error;
6775 
6776       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6777                                 p_count => x_msg_count,
6778                                 p_data  => x_msg_data);
6779 
6780       -- Debug info.
6781       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6782         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6783                                p_msg_data=>x_msg_data,
6784                                p_msg_type=>'UNEXPECTED ERROR',
6785                                p_msg_level=>fnd_log.level_error);
6786       END IF;
6787       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6788         hz_utility_v2pub.debug(p_message=>'get_telex_contact_point (-)',
6789                                p_prefix=>l_debug_prefix,
6790                                p_msg_level=>fnd_log.level_procedure);
6791       END IF;
6792 
6793       -- Check if API is called in debug mode. If yes, disable debug.
6794       --disable_debug;
6795 
6796     WHEN OTHERS THEN
6797       x_return_status := fnd_api.g_ret_sts_unexp_error;
6798 
6799       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
6800       fnd_message.set_token('ERROR' ,SQLERRM);
6801       fnd_msg_pub.add;
6802 
6803       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6804                                 p_count => x_msg_count,
6805                                 p_data  => x_msg_data);
6806 
6807       -- Debug info.
6808       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6809         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6810                                p_msg_data=>x_msg_data,
6811                                p_msg_type=>'SQL ERROR',
6812                                p_msg_level=>fnd_log.level_error);
6813       END IF;
6814       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6815         hz_utility_v2pub.debug(p_message=>'get_telex_contact_point (-)',
6816                                p_prefix=>l_debug_prefix,
6817                                p_msg_level=>fnd_log.level_procedure);
6818       END IF;
6819 
6820       -- Check if API is called in debug mode. If yes, disable debug.
6821       --disable_debug;
6822   END get_telex_contact_point;
6823 
6824   --
6825   -- PROCEDURE get_email_contact_point
6826   --
6827   -- DESCRIPTION
6828   --     Gets email contact point record.
6829   --
6830   -- EXTERNAL PROCEDURES/FUNCTIONS ACCESSED
6831   --
6832   -- ARGUMENTS
6833   --   IN:
6834   --     p_init_msg_list      Initialize message stack if it is set to
6835   --                          FND_API.G_TRUE. Default is fnd_api.g_false.
6836   --     p_contact_point_id   Contact point ID.
6837   --   IN/OUT:
6838   --   OUT:
6839   --     x_contact_point_rec  Returned contact point record.
6840   --     x_email_rec          Returned email record.
6841   --     x_return_status      Return status after the call. The status can
6842   --                          be fnd_api.g_ret_sts_success (success),
6843   --                          fnd_api.g_ret_sts_error (error),
6844   --                          fnd_api.g_ret_sts_unexp_error (unexpected error).
6845   --     x_msg_count          Number of messages in message stack.
6846   --     x_msg_data           Message text if x_msg_count is 1.
6847   --
6848   -- NOTES
6849   --
6850   -- MODIFICATION HISTORY
6851   --
6852   --   07-23-2001    Jianying Huang      o Created.
6853   --   04-DEC-2001   Joe del Callar      Bug 2136283: Added support for
6854   --                                     enhanced backward compatibility.
6855   --
6856 
6857   PROCEDURE get_email_contact_point (
6858     p_init_msg_list             IN     VARCHAR2 := fnd_api.g_false,
6859     p_contact_point_id          IN     NUMBER,
6860     x_contact_point_rec         OUT    NOCOPY contact_point_rec_type,
6861     x_email_rec                   OUT    NOCOPY email_rec_type,
6862     x_return_status             OUT NOCOPY    VARCHAR2,
6863     x_msg_count                 OUT NOCOPY    NUMBER,
6864     x_msg_data                  OUT NOCOPY    VARCHAR2
6865   ) IS
6866     l_edi_rec                   edi_rec_type := g_miss_edi_rec;
6867     l_eft_rec                   eft_rec_type := g_miss_eft_rec;
6868     l_web_rec                   web_rec_type := g_miss_web_rec;
6869     l_phone_rec                 phone_rec_type := g_miss_phone_rec;
6870     l_telex_rec                 telex_rec_type := g_miss_telex_rec;
6871     l_debug_prefix              VARCHAR2(30) := '';
6872   BEGIN
6873     -- Check if API is called in debug mode. If yes, enable debug.
6874     --enable_debug;
6875 
6876     -- Debug info.
6877     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6878         hz_utility_v2pub.debug(p_message=>'get_email_contact_point (+)',
6879                                p_prefix=>l_debug_prefix,
6880                                p_msg_level=>fnd_log.level_procedure);
6881     END IF;
6882 
6883 
6884     -- Execute main procedure
6885     get_contact_point_main (
6886       p_init_msg_list           => p_init_msg_list,
6887       p_contact_point_id        => p_contact_point_id,
6888       x_contact_point_rec       => x_contact_point_rec,
6889       x_edi_rec                 => l_edi_rec,
6890       x_eft_rec                 => l_eft_rec,
6891       x_email_rec               => x_email_rec,
6892       x_phone_rec               => l_phone_rec,
6893       x_telex_rec               => l_telex_rec,
6894       x_web_rec                 => l_web_rec,
6895       x_return_status           => x_return_status,
6896       x_msg_count               => x_msg_count,
6897       x_msg_data                => x_msg_data
6898     );
6899 
6900     -- Debug info.
6901     IF fnd_log.level_exception>=fnd_log.g_current_runtime_level THEN
6902          hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6903                                p_msg_data=>x_msg_data,
6904                                p_msg_type=>'WARNING',
6905                                p_msg_level=>fnd_log.level_exception);
6906     END IF;
6907     IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6908         hz_utility_v2pub.debug(p_message=>'get_email_contact_point (-)',
6909                                p_prefix=>l_debug_prefix,
6910                                p_msg_level=>fnd_log.level_procedure);
6911     END IF;
6912 
6913     -- Check if API is called in debug mode. If yes, disable debug.
6914     --disable_debug;
6915 
6916   EXCEPTION
6917     WHEN fnd_api.g_exc_error THEN
6918       x_return_status := fnd_api.g_ret_sts_error;
6919 
6920       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6921                                 p_count => x_msg_count,
6922                                 p_data  => x_msg_data);
6923 
6924       -- Debug info.
6925       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6926         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6927                                p_msg_data=>x_msg_data,
6928                                p_msg_type=>'ERROR',
6929                                p_msg_level=>fnd_log.level_error);
6930       END IF;
6931       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6932         hz_utility_v2pub.debug(p_message=>'get_email_contact_point (-)',
6933                                p_prefix=>l_debug_prefix,
6934                                p_msg_level=>fnd_log.level_procedure);
6935       END IF;
6936 
6937       -- Check if API is called in debug mode. If yes, disable debug.
6938       --disable_debug;
6939 
6940     WHEN fnd_api.g_exc_unexpected_error THEN
6941       x_return_status := fnd_api.g_ret_sts_unexp_error;
6942 
6943       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6944                                 p_count => x_msg_count,
6945                                 p_data  => x_msg_data);
6946 
6947       -- Debug info.
6948       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6949         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6950                                p_msg_data=>x_msg_data,
6951                                p_msg_type=>'UNEXPECTED ERROR',
6952                                p_msg_level=>fnd_log.level_error);
6953       END IF;
6954       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6955         hz_utility_v2pub.debug(p_message=>'get_email_contact_point (-)',
6956                                p_prefix=>l_debug_prefix,
6957                                p_msg_level=>fnd_log.level_procedure);
6958       END IF;
6959 
6960       -- Check if API is called in debug mode. If yes, disable debug.
6961       --disable_debug;
6962 
6963     WHEN OTHERS THEN
6964       x_return_status := fnd_api.g_ret_sts_unexp_error;
6965 
6966       fnd_message.set_name('AR', 'HZ_API_OTHERS_EXCEP');
6967       fnd_message.set_token('ERROR' ,SQLERRM);
6968       fnd_msg_pub.add;
6969 
6970       fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
6971                                 p_count => x_msg_count,
6972                                 p_data  => x_msg_data);
6973 
6974       -- Debug info.
6975       IF fnd_log.level_error>=fnd_log.g_current_runtime_level THEN
6976         hz_utility_v2pub.debug_return_messages(p_msg_count=>x_msg_count,
6977                                p_msg_data=>x_msg_data,
6978                                p_msg_type=>'SQL ERROR',
6979                                p_msg_level=>fnd_log.level_error);
6980       END IF;
6981       IF fnd_log.level_procedure>=fnd_log.g_current_runtime_level THEN
6982         hz_utility_v2pub.debug(p_message=>'get_email_contact_point (-)',
6983                                p_prefix=>l_debug_prefix,
6984                                p_msg_level=>fnd_log.level_procedure);
6985       END IF;
6986 
6987       -- Check if API is called in debug mode. If yes, disable debug.
6988       --disable_debug;
6989   END get_email_contact_point;
6990 
6991   /*----------------------------------------------------------------------------*
6992  | procedure                                                                  |
6993  |    update_contact_point_search                                             |
6994  |                                                                            |
6995  | DESCRIPTION                                                                |
6996  |    This procedure updates the address_text column of                       |
6997  |    hz_cust_acct_sites_all with the NULL value                              |
6998  |    only to change the address_text column status                           |
6999  |    so that interMedia index can be created on it to perform text searches. |
7000  |                                                                            |
7001  | NOTE :- After Calling this procedure the user has to execute the           |
7002  |         Customer Text Data Creation concurrent program to see the changes. |
7003  |                                                                            |
7004  | PARAMETERS                                                                 |
7005  |   INPUT                                                                    |
7006  |    p_cp_rec                                                                |
7007  |    p_old_phone_rec                                                         |
7008  |    p_new_phone_rec                                                         |
7009  |    p_old_email_rec                                                         |
7010  |    p_new_email_rec                                                         |
7011  |                                                                            |
7012  |                                                                            |
7013  |                                                                            |
7014  |   OUTPUT                                                                   |
7015  |                                                                            |
7016  |                                                                            |
7017  | HISTORY                                                                    |
7018  |    15-Mar-2004    Ramesh Ch   Created                                       |
7019  *----------------------------------------------------------------------------*/
7020 
7021 PROCEDURE update_contact_point_search(p_cp_rec        IN HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE,
7022                                       p_old_phone_rec IN HZ_CONTACT_POINT_V2PUB.phone_rec_type,
7023                                       p_new_phone_rec IN HZ_CONTACT_POINT_V2PUB.phone_rec_type,
7024                                       p_old_email_rec IN HZ_CONTACT_POINT_V2PUB.email_rec_type,
7025                                       p_new_email_rec IN HZ_CONTACT_POINT_V2PUB.email_rec_type
7026                                      )
7027 IS
7028 
7029   ----(Party level Contact Point)
7030  CURSOR c_pl_cp(p_party_id NUMBER) IS
7031   SELECT ac.CUST_ACCT_SITE_ID
7032     FROM HZ_CUST_ACCOUNTS c,HZ_CUST_ACCT_SITES_ALL ac
7033     WHERE c.party_id=p_party_id
7034     AND c.cust_account_id = ac.cust_account_id;
7035 
7036   ----(Site level contact point)
7037 CURSOR c_sl_cp(p_party_site_id NUMBER) IS
7038     SELECT ac.CUST_ACCT_SITE_ID
7039     FROM HZ_PARTY_SITES ps,
7040          HZ_CUST_ACCT_SITES_ALL ac
7041     WHERE ps.PARTY_SITE_ID=p_party_site_id
7042     AND ps.PARTY_SITE_ID=ac.PARTY_SITE_ID;
7043 
7044  ----(Party level relationship's contact point )
7045  CURSOR c_pl_rel_cp(p_party_id NUMBER) IS
7046   SELECT distinct ac.CUST_ACCT_SITE_ID
7047     FROM HZ_PARTIES p, HZ_CUST_ACCOUNT_ROLES ar,
7048          HZ_RELATIONSHIPS rel,HZ_CUST_ACCT_SITES_ALL ac
7049     WHERE rel.party_id=p_party_id
7050     AND ar.ROLE_TYPE = 'CONTACT'
7051     AND rel.party_id=ar.party_id
7052     AND rel.subject_id=p.party_id
7053     AND ar.cust_account_id = ac.cust_account_id
7054     AND (ar.cust_acct_site_id is null);
7055 
7056  -----(Site Level relationship's contact point )
7057  CURSOR c_sl_rel_cp(p_party_id NUMBER) IS
7058   SELECT distinct ac.CUST_ACCT_SITE_ID
7059      FROM HZ_PARTIES p, HZ_CUST_ACCOUNT_ROLES ar,
7060           HZ_RELATIONSHIPS rel,HZ_CUST_ACCT_SITES_ALL ac
7061      WHERE rel.party_id=p_party_id
7062      AND ar.ROLE_TYPE = 'CONTACT'
7063      AND ar.party_id = rel.party_id
7064      AND p.party_id = rel.subject_id
7065      AND ar.cust_account_id = ac.cust_account_id
7066      AND ar.cust_acct_site_id = ac.cust_acct_site_id;
7067 
7068  CURSOR c_party_type(p_party_id NUMBER) IS
7069   SELECT party_type
7070   FROM HZ_PARTIES
7071   WHERE party_id=p_party_id;
7072 
7073 l_owner_table_name   HZ_CONTACT_POINTS.OWNER_TABLE_NAME%TYPE;
7074 l_contact_point_type HZ_CONTACT_POINTS.CONTACT_POINT_TYPE%TYPE;
7075 TYPE siteidtab IS TABLE OF HZ_CUST_ACCT_SITES_ALL.CUST_ACCT_SITE_ID%TYPE;
7076 l_siteidtab siteidtab;
7077 l_party_type       HZ_PARTIES.PARTY_TYPE%TYPE;
7078 BEGIN
7079  savepoint update_contact_point_search;
7080 
7081  l_owner_table_name   := p_cp_rec.owner_table_name;
7082  l_contact_point_type := p_cp_rec.contact_point_type;
7083 
7084  IF (l_owner_table_name='HZ_PARTY_SITES' AND l_contact_point_type NOT IN ('EDI', 'EMAIL', 'WEB'))
7085     OR (l_owner_table_name='HZ_PARTIES' AND l_contact_point_type NOT IN  ('EDI','WEB'))
7086  THEN
7087       IF(  isModified(   p_old_phone_rec.phone_number       ,p_new_phone_rec.phone_number)
7088            OR isModified(p_old_phone_rec.phone_area_code    ,p_new_phone_rec.phone_area_code)
7089            OR isModified(p_old_phone_rec.phone_country_code ,p_new_phone_rec.phone_country_code)
7090            OR isModified(p_old_email_rec.email_address      ,p_new_email_rec.email_address)
7091          ) THEN
7092               IF  l_owner_table_name ='HZ_PARTY_SITES'
7093               THEN
7094                   OPEN c_sl_cp(p_cp_rec.owner_table_id);
7095                   FETCH c_sl_cp BULK COLLECT INTO l_siteidtab;
7096                   CLOSE c_sl_cp;
7097                   IF l_siteidtab.COUNT >0 THEN
7098                      FORALL i IN l_siteidtab.FIRST..l_siteidtab.LAST
7099                         update HZ_CUST_ACCT_SITES_ALL set address_text=NULL where cust_acct_site_id=l_siteidtab(i);
7100                   END IF;
7101               ELSE  ---l_owner_table_name ='HZ_PARTIES'
7102                  OPEN c_party_type(p_cp_rec.owner_table_id);
7103                  FETCH c_party_type INTO l_party_type;
7104                  CLOSE c_party_type;
7105                  IF l_party_type='PARTY_RELATIONSHIP' THEN
7106                     --Process party level relationship's records
7107                     OPEN  c_pl_rel_cp(p_cp_rec.owner_table_id);
7108                     FETCH c_pl_rel_cp BULK COLLECT INTO l_siteidtab;
7109                     CLOSE c_pl_rel_cp;
7110                     IF l_siteidtab.COUNT >0 THEN
7111                        FORALL i IN l_siteidtab.FIRST..l_siteidtab.LAST
7112                          update HZ_CUST_ACCT_SITES_ALL set address_text=NULL where cust_acct_site_id=l_siteidtab(i);
7113                     END IF;
7114                     --Process site level relationship's records
7115                     OPEN  c_sl_rel_cp(p_cp_rec.owner_table_id);
7116                     FETCH c_sl_rel_cp BULK COLLECT INTO l_siteidtab;
7117                     CLOSE c_sl_rel_cp;
7118                     IF l_siteidtab.COUNT >0 THEN
7119                       FORALL i IN l_siteidtab.FIRST..l_siteidtab.LAST
7120                         update HZ_CUST_ACCT_SITES_ALL set address_text=NULL where cust_acct_site_id=l_siteidtab(i);
7121                     END IF;
7122                  ELSE
7123                    OPEN c_pl_cp(p_cp_rec.owner_table_id);
7124                    FETCH c_pl_cp BULK COLLECT INTO l_siteidtab;
7125                    CLOSE c_pl_cp;
7126                    IF l_siteidtab.COUNT >0 THEN
7127                       FORALL i IN l_siteidtab.FIRST..l_siteidtab.LAST
7128                         update HZ_CUST_ACCT_SITES_ALL set address_text=NULL where cust_acct_site_id=l_siteidtab(i);
7129                    END IF;
7130                  END IF;
7131               END IF;
7132       END IF;
7133  END IF;
7134 EXCEPTION
7135  WHEN OTHERS THEN
7136    ROLLBACK TO update_contact_point_search;
7137    RAISE;
7138 END;
7139 FUNCTION isModified(p_old_value IN VARCHAR2,p_new_value IN VARCHAR2) RETURN BOOLEAN
7140 IS
7141 BEGIN
7142   IF p_new_value IS NOT NULL AND p_new_value <> FND_API.G_MISS_CHAR THEN
7143      RETURN NVL(NOT (p_old_value=p_new_value),TRUE);
7144   ELSIF (p_old_value IS NOT NULL AND p_old_value <> FND_API.G_MISS_CHAR)
7145          AND p_new_value = FND_API.G_MISS_CHAR THEN
7146      RETURN TRUE;
7147   ELSE
7148     RETURN FALSE;
7149   END IF;
7150 END;
7151 
7152 END hz_contact_point_v2pub;