DBA Data[Home] [Help]

PACKAGE BODY: APPS.HZ_BANK_PUB

Source


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