DBA Data[Home] [Help]

PACKAGE BODY: APPS.HZ_BANK_PUB

Source


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