DBA Data[Home] [Help]

PACKAGE BODY: APPS.CSD_PARTIES_PVT

Source


1 PACKAGE BODY CSD_PARTIES_PVT AS
2 /* $Header: csdvptyb.pls 120.1 2005/08/17 15:14:04 swai noship $ */
3 --
4 -- Package name     : CSD_PARTIES_PVT
5 -- Purpose          : This package contains the private APIs for managing
6 --                    TCA parties in Depot Repair.
7 -- History          :
8 -- Version       Date       Name        Description
9 -- 115.9         10/14/02   swai       Created.
10 
11 
12 G_PKG_NAME    CONSTANT VARCHAR2(30) := 'CSD_PARTIES_PVT';
13 G_FILE_NAME   CONSTANT VARCHAR2(12) := 'csdvptyb.pls';
14 l_debug       NUMBER := fnd_profile.value('CSD_DEBUG_LEVEL');
15 
16 
17 /*----------------------------------------------------------------*/
18 /* procedure name: Create_Customer                                */
19 /* description   : procedure used to create a Depot Repair        */
20 /*                 customer in TCA.  Also creates account,        */
21 /*                 contact points, bill-to and ship-to addresses  */
22 /*                                                                */
23 /*                                                                */
24 /* p_api_version                Standard IN param                 */
25 /* p_commit                     Standard IN param                 */
26 /* p_init_msg_list              Standard IN param                 */
27 /* p_validation_level           Standard IN param                 */
28 /* p_person_rec                 Person Information                */
29 /* p_org_rec                    Organization Info                 */
30 /*                              Required fields for org rec are:  */
31 /*                              Organization name                 */
32 /* p_party_type                 'PERSON' or 'ORGANIZATION'        */
33 /* p_account_rec                Account Info                      */
34 /* p_cust_profile_rec           Profile Info                      */
35 /* p_phone_rec                  Phone Info                        */
36 /* p_email_rec                  Email Info                        */
37 /* p_web_rec                    Web Info                          */
38 /* p_create_phone_flag          'Y' to create phone contact point */
39 /* p_create_email_flag          'Y' to create email contact point */
40 /* p_create_url_flag            'Y' to create url contact point   */
41 /* p_bill_loc_rec               Bill-to location                  */
42 /* p_bill_party_site_rec        Bill-to site                      */
43 /* p_bill_party_site_use_rec    Bill-to site use                  */
44 /* p_ship_loc_rec               Ship-to location                  */
45 /* p_ship_party_site_rec        Ship-to site                      */
46 /* p_ship_party_site_use_rec    Ship-to site use                  */
47 /* x_party_id                   Party ID generated                */
48 /* x_party_number               Party Number gnerated             */
49 /* x_cust_account_id            Account ID generated              */
50 /* x_cust_account_number        Account Number generated          */
51 /* x_phone_id                   Phone contact point ID            */
52 /* x_email_id                   Email contact point ID            */
53 /* x_url_id                     URL contact point ID              */
54 /* x_bill_party_site_rec        Bill-to site                      */
55 /* x_bill_party_site_use_rec    Bill-to site use                  */
56 /* x_bill_location_id           Bill-to location ID               */
57 /* x_bill_party_site_id         Bill-to site id                   */
58 /* x_bill_party_site_number     Bill-to site number               */
59 /* x_bill_party_site_use_id     Bill-to site use id               */
60 /* x_ship_party_site_rec        Ship-to site                      */
61 /* x_ship_party_site_use_rec    Ship-to site use                  */
62 /* x_ship_location_id           Ship-to location ID               */
63 /* x_ship_party_site_id         Ship-to site id                   */
64 /* x_ship_party_site_number     Ship-to site number               */
65 /* x_ship_party_site_use_id     Ship-to site use id               */
66 /* x_return_status              Standard OUT param                */
67 /* x_msg_count                  Standard OUT param                */
68 /* x_msg_data                   Standard OUT param                */
69 /*                                                                */
70 /*----------------------------------------------------------------*/
71 PROCEDURE Create_Customer
72 (  p_api_version             IN  NUMBER,
73    p_commit                  IN  VARCHAR2  := fnd_api.g_false,
74    p_init_msg_list           IN  VARCHAR2  := fnd_api.g_false,
75    p_validation_level        IN  NUMBER    := fnd_api.g_valid_level_full,
76    p_person_rec              IN  HZ_PARTY_V2PUB.person_rec_type,
77    p_org_rec                 IN  HZ_PARTY_V2PUB.organization_rec_type,
78    p_party_type              IN  VARCHAR2,
79    p_account_rec             IN  HZ_CUST_ACCOUNT_V2PUB.cust_account_rec_type,
80    p_cust_profile_rec        IN  HZ_CUSTOMER_PROFILE_V2PUB.customer_profile_rec_type,
81    p_phone_rec               IN  HZ_CONTACT_POINT_V2PUB.phone_rec_type,
82    p_email_rec               IN  HZ_CONTACT_POINT_V2PUB.email_rec_type,
83    p_web_rec                 IN  HZ_CONTACT_POINT_V2PUB.web_rec_type,
84    p_create_phone_flag       IN  VARCHAR2,
85    p_create_email_flag       IN  VARCHAR2,
86    p_create_url_flag         IN  VARCHAR2,
87    p_bill_loc_rec            IN  CSD_PROCESS_PVT.address_rec_type,
88    p_bill_location_id        IN  NUMBER := null,
89    p_ship_loc_rec            IN  CSD_PROCESS_PVT.address_rec_type,
90    p_ship_location_id        IN  NUMBER := null,
91    x_party_id                OUT NOCOPY NUMBER,
92    x_party_number            OUT NOCOPY VARCHAR2,
93    x_cust_account_id         OUT NOCOPY NUMBER,
94    x_cust_account_number     OUT NOCOPY VARCHAR2,
95    x_phone_id                OUT NOCOPY NUMBER,
96    x_email_id                OUT NOCOPY NUMBER,
97    x_url_id                  OUT NOCOPY NUMBER,
98    x_bill_party_site_rec     IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_rec_type,
99    x_bill_party_site_use_rec IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_use_rec_type,
100    x_bill_location_id        OUT NOCOPY NUMBER,
101    x_bill_party_site_id      OUT NOCOPY NUMBER,
102    x_bill_party_site_number  OUT NOCOPY NUMBER,
103    x_bill_party_site_use_id  OUT NOCOPY NUMBER,
104    x_ship_party_site_rec     IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_rec_type,
105    x_ship_party_site_use_rec IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_use_rec_type,
106    x_ship_location_id        OUT NOCOPY NUMBER,
107    x_ship_party_site_id      OUT NOCOPY NUMBER,
108    x_ship_party_site_number  OUT NOCOPY NUMBER,
109    x_ship_party_site_use_id  OUT NOCOPY NUMBER,
110    x_return_status           OUT NOCOPY VARCHAR2,
111    x_msg_count               OUT NOCOPY NUMBER,
112    x_msg_data                OUT NOCOPY VARCHAR2 )
113 IS
114    l_api_name                CONSTANT VARCHAR2(30) := 'Create_Customer';
115    l_api_version             CONSTANT NUMBER := 1.0;
116    l_person_rec              HZ_PARTY_V2PUB.person_rec_type := p_person_rec;
117    l_org_rec                 HZ_PARTY_V2PUB.organization_rec_type := p_org_rec;
118 BEGIN
119 
120     -- Standard Start of API savepoint
121     SAVEPOINT Create_Customer_Pvt;
122 
123     -- Standard call to check for call compatibility.
124     IF NOT FND_API.Compatible_API_Call (l_api_version,
125                                         p_api_version,
126                                         l_api_name,
127                                         G_PKG_NAME)
128     THEN
129         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
130     END IF;
131 
132     -- Initialize message list if p_init_msg_list is set to TRUE.
133     IF FND_API.to_Boolean(p_init_msg_list) THEN
134         FND_MSG_PUB.initialize;
135     END IF;
136 
137     -- Initialize API return status to success
138     x_return_status := FND_API.G_RET_STS_SUCCESS;
139 
140     --
141     -- Begin API Body
142     --
143     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
144                                         p_api_name  => l_api_name );
145     IF l_debug > 5 THEN
146           csd_gen_utility_pvt.dump_hz_org_rec
147                    ( p_org_rec => p_org_rec);
148           csd_gen_utility_pvt.dump_hz_person_rec
149                    ( p_person_rec => p_person_rec);
150           csd_gen_utility_pvt.dump_hz_phone_rec
151                    ( p_phone_rec => p_phone_rec);
152           csd_gen_utility_pvt.dump_hz_email_rec
153                    ( p_email_rec => p_email_rec);
154           csd_gen_utility_pvt.dump_hz_web_rec
155                    ( p_web_rec => p_web_rec);
156           csd_gen_utility_pvt.dump_hz_cust_profile_rec
157                    ( p_cust_profile_rec => p_cust_profile_rec);
158           csd_gen_utility_pvt.dump_hz_acct_rec
159                    ( p_account_rec => p_account_rec);
160 
161           csd_gen_utility_pvt.add('bill-to information');
162           csd_gen_utility_pvt.dump_address_rec
163                    ( p_addr_rec => p_bill_loc_rec);
164           csd_gen_utility_pvt.dump_hz_party_site_rec
165                    ( p_party_site_rec => x_bill_party_site_rec);
166           csd_gen_utility_pvt.dump_hz_party_site_use_rec
167                    ( p_party_site_use_rec => x_bill_party_site_use_rec);
168 
169           csd_gen_utility_pvt.add('ship-to information');
170           csd_gen_utility_pvt.dump_address_rec
171                    ( p_addr_rec => p_ship_loc_rec);
172           csd_gen_utility_pvt.dump_hz_party_site_rec
173                    ( p_party_site_rec => x_ship_party_site_rec);
174           csd_gen_utility_pvt.dump_hz_party_site_use_rec
175                    ( p_party_site_use_rec => x_ship_party_site_use_rec);
176     END IF;
177 
178     IF (p_party_type = 'PERSON') THEN
179         Create_Person( p_api_version      => 1.0,
180                        p_commit           => FND_API.G_FALSE,
181                        p_validation_level => p_validation_level,
182                        p_person_rec       => p_person_rec,
183                        x_party_id         => x_party_id,
184                        x_party_number     => x_party_number,
185                        x_return_status    => x_return_status,
186                        x_msg_count        => x_msg_count,
187                        x_msg_data         => x_msg_data);
188 
189         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
190             csd_gen_utility_pvt.ADD('Create_Person failed ');
191             RAISE FND_API.G_EXC_ERROR;
192         END IF;
193 
194         l_person_rec.party_rec.party_id := x_party_id;
195         l_person_rec.party_rec.party_number := x_party_number;
196         Create_Account(p_api_version          => 1.0,
197                        p_commit               => FND_API.G_FALSE,
198                        p_init_msg_list        => FND_API.G_FALSE,
199                        p_validation_level     => p_validation_level,
200                        p_account_rec          => p_account_rec,
201                        p_person_rec           => l_person_rec,
202                        p_cust_profile_rec     => p_cust_profile_rec,
203                        x_cust_account_id      => x_cust_account_id,
204                        x_cust_account_number  => x_cust_account_number,
205                        x_return_status        => x_return_status,
206                        x_msg_count            => x_msg_count,
207                        x_msg_data             => x_msg_data);
208         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
209             csd_gen_utility_pvt.ADD('Create_Account failed ');
210             RAISE FND_API.G_EXC_ERROR;
211         END IF;
212 
213     ELSIF (p_party_type = 'ORGANIZATION') THEN
214         Create_Organization( p_api_version      => 1.0,
215                              p_commit           => FND_API.G_FALSE,
216                              p_init_msg_list    => FND_API.G_FALSE,
217                              p_validation_level => p_validation_level,
218                              p_org_rec          => p_org_rec,
219                              x_party_id         => x_party_id,
220                              x_party_number     => x_party_number,
221                              x_return_status    => x_return_status,
222                              x_msg_count        => x_msg_count,
223                              x_msg_data         => x_msg_data);
224 
225         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
226             csd_gen_utility_pvt.ADD('Create_Organization failed ');
227             RAISE FND_API.G_EXC_ERROR;
228         END IF;
229 
230         l_org_rec.party_rec.party_id := x_party_id;
231         l_org_rec.party_rec.party_number := x_party_number;
232         Create_Account(p_api_version          => 1.0,
233                        p_commit               => FND_API.G_FALSE,
234                        p_init_msg_list        => FND_API.G_FALSE,
235                        p_validation_level     => p_validation_level,
236                        p_account_rec          => p_account_rec,
237                        p_org_rec              => l_org_rec,
238                        p_cust_profile_rec     => p_cust_profile_rec,
239                        x_cust_account_id      => x_cust_account_id,
240                        x_cust_account_number  => x_cust_account_number,
241                        x_return_status        => x_return_status,
242                        x_msg_count            => x_msg_count,
243                        x_msg_data             => x_msg_data);
244         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
245             csd_gen_utility_pvt.ADD('Create_Account failed ');
246             RAISE FND_API.G_EXC_ERROR;
247         END IF;
248 
249     END IF;
250 
251     IF (p_create_phone_flag = 'Y') OR
252        (p_create_email_flag = 'Y') OR
253        (p_create_url_flag = 'Y')
254     THEN
255         Create_ContactPoints(
256                        p_api_version       => 1.0,
257                        p_commit            => FND_API.G_FALSE,
258                        p_init_msg_list     => FND_API.G_FALSE,
259                        p_validation_level  => p_validation_level,
260                        p_phone_rec         => p_phone_rec,
261                        p_email_rec         => p_email_rec,
262                        p_web_rec           => p_web_rec,
263                        p_create_phone_flag => p_create_phone_flag,
264                        p_create_email_flag => p_create_email_flag,
265                        p_create_url_flag   => p_create_url_flag,
266                        p_party_id          => x_party_id,
267                        x_phone_id          => x_phone_id,
268                        x_email_id          => x_email_id,
269                        x_url_id            => x_url_id,
270                        x_return_status     => x_return_status,
271                        x_msg_count         => x_msg_count,
272                        x_msg_data          => x_msg_data);
273         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
274             csd_gen_utility_pvt.ADD('Create_ContactPoints failed ');
275             RAISE FND_API.G_EXC_ERROR;
276         END IF;
277 
278     END IF;
279 
280     -- bill to address records
281     x_bill_party_site_rec.party_id := x_party_id;
282     Create_AddressRecords(
283                        p_api_version        => 1.0,
284                        p_commit             => FND_API.G_FALSE,
285                        p_init_msg_list      => FND_API.G_FALSE,
286                        p_validation_level   => p_validation_level,
287                        p_loc_rec            => p_bill_loc_rec,
288                        p_location_id        => p_bill_location_id,
289                        x_party_site_rec     => x_bill_party_site_rec,
290                        x_party_site_use_rec => x_bill_party_site_use_rec,
291                        x_location_id        => x_bill_location_id,
292                        x_party_site_id      => x_bill_party_site_id,
293                        x_party_site_number  => x_bill_party_site_number,
294                        x_party_site_use_id  => x_bill_party_site_use_id,
295                        x_return_status      => x_return_status,
296                        x_msg_count          => x_msg_count,
297                        x_msg_data           => x_msg_data);
298     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
299         csd_gen_utility_pvt.ADD('Create_AddressRecords failed ');
300         RAISE FND_API.G_EXC_ERROR;
301     END IF;
302 
303     -- ship to address records
304     x_ship_party_site_rec.party_id := x_party_id;
308                        p_init_msg_list      => FND_API.G_FALSE,
305     Create_AddressRecords(
306                        p_api_version        => 1.0,
307                        p_commit             => FND_API.G_FALSE,
309                        p_validation_level   => p_validation_level,
310                        p_loc_rec            => p_ship_loc_rec,
311                        p_location_id        => p_ship_location_id,
312                        x_party_site_rec     => x_ship_party_site_rec,
313                        x_party_site_use_rec => x_ship_party_site_use_rec,
314                        x_location_id        => x_ship_location_id,
315                        x_party_site_id      => x_ship_party_site_id,
316                        x_party_site_number  => x_ship_party_site_number,
317                        x_party_site_use_id  => x_ship_party_site_use_id,
318                        x_return_status      => x_return_status,
319                        x_msg_count          => x_msg_count,
320                        x_msg_data           => x_msg_data);
321     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
322         csd_gen_utility_pvt.ADD('Create_AddressRecords failed ');
323         RAISE FND_API.G_EXC_ERROR;
324     END IF;
325 
326     --
327     -- End API Body
328     --
329 
330     -- Standard check of p_commit.
331     IF FND_API.To_Boolean( p_commit ) THEN
332        COMMIT WORK;
333     END IF;
334 
335     -- Standard call to get message count and IF count is  get message info.
336     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
337                                p_data   =>  x_msg_data );
338 EXCEPTION
339     WHEN FND_API.G_EXC_ERROR THEN
340           ROLLBACK TO Create_Customer_Pvt;
341           x_return_status := FND_API.G_RET_STS_ERROR ;
342           FND_MSG_PUB.Count_And_Get
343                 (p_count  =>  x_msg_count,
344                  p_data   =>  x_msg_data
345                 );
346     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
347           ROLLBACK TO Create_Customer_Pvt;
348           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
349           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
350                                      p_data   =>  x_msg_data );
351     WHEN OTHERS THEN
352           ROLLBACK TO Create_Customer_Pvt;
353           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
354           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
355           THEN
356               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
357                                        l_api_name  );
358           END IF;
359           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
360                                      p_data   =>  x_msg_data );
361 
362 END Create_Customer;
363 
364 
365 /*----------------------------------------------------------------*/
366 /* procedure name: Create_Contact                                 */
367 /* description   : procedure used to create a person contact      */
368 /*                 in TCA. Also creates contact points.           */
369 /*                                                                */
370 /* p_api_version                Standard IN param                 */
371 /* p_commit                     Standard IN param                 */
372 /* p_init_msg_list              Standard IN param                 */
373 /* p_validation_level           Standard IN param                 */
374 /* p_person_rec                 Person Information                */
375 /* p_phone_rec                  Phone Info                        */
376 /* p_email_rec                  Email Info                        */
377 /* p_web_rec                    Web Info                          */
378 /* p_create_phone_flag          'Y' to create phone contact point */
379 /* p_create_email_flag          'Y' to create email contact point */
380 /* p_create_url_flag            'Y' to create url contact point   */
381 /* x_party_id                   Party ID generated                */
382 /* x_party_number               Party Number generated             */
383 /* x_phone_id                   Phone contact point ID            */
384 /* x_email_id                   Email contact point ID            */
385 /* x_url_id                     URL contact point ID              */
386 /* x_return_status              Standard OUT param                */
387 /* x_msg_count                  Standard OUT param                */
388 /* x_msg_data                   Standard OUT param                */
389 /*                                                                */
390 /*----------------------------------------------------------------*/
391 PROCEDURE Create_Contact
392 (  p_api_version          IN  NUMBER,
393    p_commit               IN  VARCHAR2  := fnd_api.g_false,
394    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
395    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
396    p_person_rec           IN  HZ_PARTY_V2PUB.person_rec_type,
397    p_phone_rec            IN  HZ_CONTACT_POINT_V2PUB.phone_rec_type,
398    p_email_rec            IN  HZ_CONTACT_POINT_V2PUB.email_rec_type,
399    p_web_rec              IN  HZ_CONTACT_POINT_V2PUB.web_rec_type,
400    p_create_phone_flag    IN  VARCHAR2,
401    p_create_email_flag    IN  VARCHAR2,
402    p_create_url_flag      IN  VARCHAR2,
403    x_party_id             OUT NOCOPY NUMBER,
404    x_party_number         OUT NOCOPY VARCHAR2,
405    x_phone_id             OUT NOCOPY NUMBER,
406    x_email_id             OUT NOCOPY NUMBER,
407    x_url_id               OUT NOCOPY NUMBER,
411 IS
408    x_return_status        OUT NOCOPY VARCHAR2,
409    x_msg_count            OUT NOCOPY NUMBER,
410    x_msg_data             OUT NOCOPY VARCHAR2 )
412   l_api_name              CONSTANT VARCHAR2(30) := 'Create_Contact';
413   l_api_version           CONSTANT NUMBER := 1.0;
414 BEGIN
415 
416     -- Standard Start of API savepoint
417     SAVEPOINT Create_Contact_Pvt;
418 
419     -- Standard call to check for call compatibility.
420     IF NOT FND_API.Compatible_API_Call (l_api_version,
421                                         p_api_version,
422                                         l_api_name,
423                                         G_PKG_NAME)
424     THEN
425         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
426     END IF;
427 
428     -- Initialize message list if p_init_msg_list is set to TRUE.
429     IF FND_API.to_Boolean(p_init_msg_list) THEN
430         FND_MSG_PUB.initialize;
431     END IF;
432 
433     -- Initialize API return status to success
434     x_return_status := FND_API.G_RET_STS_SUCCESS;
435 
436     --
437     -- Begin API Body
438     --
439     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
440                                         p_api_name  => l_api_name );
441     IF l_debug > 5 THEN
442           csd_gen_utility_pvt.dump_hz_person_rec
443                    ( p_person_rec => p_person_rec);
444           csd_gen_utility_pvt.dump_hz_phone_rec
445                    ( p_phone_rec => p_phone_rec);
446           csd_gen_utility_pvt.dump_hz_email_rec
447                    ( p_email_rec => p_email_rec);
448           csd_gen_utility_pvt.dump_hz_web_rec
449                    ( p_web_rec => p_web_rec);
450     END IF;
451 
452     Create_Person(     p_api_version      => 1.0,
453                        p_commit           => FND_API.G_FALSE,
454                        p_init_msg_list    => FND_API.G_FALSE,
455                        p_validation_level => p_validation_level,
456                        p_person_rec       => p_person_rec,
457                        x_party_id         => x_party_id,
458                        x_party_number     => x_party_number,
459                        x_return_status    => x_return_status,
460                        x_msg_count        => x_msg_count,
461                        x_msg_data         => x_msg_data);
462     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
463         csd_gen_utility_pvt.ADD('Create_Person failed ');
464         RAISE FND_API.G_EXC_ERROR;
465     END IF;
466 
467     IF (p_create_phone_flag = 'Y') OR
468        (p_create_email_flag = 'Y') OR
469        (p_create_url_flag = 'Y')
470     THEN
471         Create_ContactPoints(
472                        p_api_version       => 1.0,
473                        p_commit            => FND_API.G_FALSE,
474                        p_init_msg_list     => FND_API.G_FALSE,
475                        p_validation_level  => p_validation_level,
476                        p_phone_rec         => p_phone_rec,
477                        p_email_rec         => p_email_rec,
478                        p_web_rec           => p_web_rec,
479                        p_create_phone_flag => p_create_phone_flag,
480                        p_create_email_flag => p_create_email_flag,
481                        p_create_url_flag   => p_create_url_flag,
482                        p_party_id          => x_party_id,
483                        x_phone_id          => x_phone_id,
484                        x_email_id          => x_email_id,
485                        x_url_id            => x_url_id,
486                        x_return_status     => x_return_status,
487                        x_msg_count         => x_msg_count,
488                        x_msg_data          => x_msg_data);
489         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
490             csd_gen_utility_pvt.ADD('Create_ContactPoints failed ');
491             RAISE FND_API.G_EXC_ERROR;
492         END IF;
493     END IF;
494 
495     --
496     -- End API Body
497     --
498 
499     -- Standard check of p_commit.
500     IF FND_API.To_Boolean( p_commit ) THEN
501        COMMIT WORK;
502     END IF;
503 
504     -- Standard call to get message count and IF count is  get message info.
505     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
506                                p_data   =>  x_msg_data );
507 EXCEPTION
508     WHEN FND_API.G_EXC_ERROR THEN
509           ROLLBACK TO Create_Contact_Pvt;
510           x_return_status := FND_API.G_RET_STS_ERROR ;
511           x_party_id      := NULL;
512           x_party_number  := '';
513           x_phone_id      := NULL;
514           x_email_id      := NULL;
515           x_url_id        := NULL;
516           FND_MSG_PUB.Count_And_Get
517                 (p_count  =>  x_msg_count,
518                  p_data   =>  x_msg_data
519                 );
520     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
521           ROLLBACK TO Create_Contact_Pvt;
522           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
523           x_party_id      := NULL;
524           x_party_number  := '';
525           x_phone_id      := NULL;
526           x_email_id      := NULL;
527           x_url_id        := NULL;
528           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
529                                      p_data   =>  x_msg_data );
530     WHEN OTHERS THEN
531           ROLLBACK TO Create_Contact_Pvt;
535           x_phone_id      := NULL;
532           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
533           x_party_id      := NULL;
534           x_party_number  := '';
536           x_email_id      := NULL;
537           x_url_id        := NULL;
538           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
539           THEN
540               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
541                                        l_api_name  );
542           END IF;
543           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
544                                      p_data   =>  x_msg_data );
545 END Create_Contact;
546 
547 
548 /*----------------------------------------------------------------*/
549 /* procedure name: Create_Person                                  */
550 /* description   : procedure used to create                       */
551 /*                 a person in TCA                                */
552 /*                                                                */
553 /* p_api_version                Standard IN param                 */
554 /* p_commit                     Standard IN param                 */
555 /* p_init_msg_list              Standard IN param                 */
556 /* p_validation_level           Standard IN param                 */
557 /* p_person_rec                 Person Information                */
558 /* x_party_id                   Party ID generated                */
559 /* x_party_number               Party Number generated             */
560 /* x_return_status              Standard OUT param                */
561 /* x_msg_count                  Standard OUT param                */
562 /* x_msg_data                   Standard OUT param                */
563 /*                                                                */
564 /*----------------------------------------------------------------*/
565 PROCEDURE Create_Person
566 (  p_api_version          IN  NUMBER,
567    p_commit               IN  VARCHAR2  := fnd_api.g_false,
568    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
569    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
570    p_person_rec           IN  HZ_PARTY_V2PUB.person_rec_type,
571    x_party_id             OUT NOCOPY NUMBER,
572    x_party_number         OUT NOCOPY VARCHAR2,
573    x_return_status        OUT NOCOPY VARCHAR2,
574    x_msg_count            OUT NOCOPY NUMBER,
575    x_msg_data             OUT NOCOPY VARCHAR2 )
576 
577 IS
578   l_api_name              CONSTANT VARCHAR2(30) := 'Create_Person';
579   l_api_version           CONSTANT NUMBER := 1.0;
580   l_profile_id                     NUMBER;
581 BEGIN
582 
583     -- Standard Start of API savepoint
584     SAVEPOINT Create_Person_Pvt;
585 
586     -- Standard call to check for call compatibility.
587     IF NOT FND_API.Compatible_API_Call (l_api_version,
588                                         p_api_version,
589                                         l_api_name,
590                                         G_PKG_NAME)
591     THEN
592         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
593     END IF;
594 
595     -- Initialize message list if p_init_msg_list is set to TRUE.
596     IF FND_API.to_Boolean(p_init_msg_list) THEN
597         FND_MSG_PUB.initialize;
598     END IF;
599 
600     -- Initialize API return status to success
601     x_return_status := FND_API.G_RET_STS_SUCCESS;
602 
603     --
604     -- Begin API Body
605     --
606     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
607                                         p_api_name  => l_api_name );
608     IF l_debug > 5 THEN
609           csd_gen_utility_pvt.dump_hz_person_rec
610                    ( p_person_rec => p_person_rec);
611     END IF;
612 
613     HZ_PARTY_V2PUB.Create_Person(
614                                 p_init_msg_list    => FND_API.G_FALSE,
615                                 p_person_rec       => p_person_rec,
616                                 x_party_id         => x_party_id,
617                                 x_party_number     => x_party_number,
618                                 x_profile_id       => l_profile_id,
619                                 x_return_status    => x_return_status,
620                                 x_msg_count        => x_msg_count,
621                                 x_msg_data         => x_msg_data
622                               );
623 
624     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
625         csd_gen_utility_pvt.ADD('Create_Person failed ');
626         RAISE FND_API.G_EXC_ERROR;
627     END IF;
628 
629     --
630     -- End API Body
631     --
632 
633     -- Standard check of p_commit.
634     IF FND_API.To_Boolean( p_commit ) THEN
635        COMMIT WORK;
636     END IF;
637 
638     -- Standard call to get message count and IF count is  get message info.
639     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
640                                p_data   =>  x_msg_data );
641 EXCEPTION
642     WHEN FND_API.G_EXC_ERROR THEN
643           ROLLBACK TO Create_Person_Pvt;
644           x_return_status := FND_API.G_RET_STS_ERROR ;
645           FND_MSG_PUB.Count_And_Get
646                 (p_count  =>  x_msg_count,
647                  p_data   =>  x_msg_data
648                 );
649     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
650           ROLLBACK TO Create_Person_Pvt;
654     WHEN OTHERS THEN
651           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
652           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
653                                      p_data   =>  x_msg_data );
655           ROLLBACK TO Create_Person_Pvt;
656           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
657           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
658           THEN
659               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
660                                        l_api_name  );
661           END IF;
662           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
663                                      p_data   =>  x_msg_data );
664 END Create_Person;
665 
666 /*----------------------------------------------------------------*/
667 /* procedure name: Create_Organization                            */
668 /* description   : procedure used to create an organization       */
669 /*                 in TCA                                         */
670 /*                                                                */
671 /* p_api_version                Standard IN param                 */
672 /* p_commit                     Standard IN param                 */
673 /* p_init_msg_list              Standard IN param                 */
674 /* p_validation_level           Standard IN param                 */
675 /* p_org_rec                    Organization Info                 */
676 /* x_party_id                   Party ID generated                */
677 /* x_party_number               Party Number generated             */
678 /* x_return_status              Standard OUT param                */
679 /* x_msg_count                  Standard OUT param                */
680 /* x_msg_data                   Standard OUT param                */
681 /*                                                                */
682 /*----------------------------------------------------------------*/
683 PROCEDURE Create_Organization
684 (  p_api_version          IN  NUMBER,
685    p_commit               IN  VARCHAR2  := fnd_api.g_false,
686    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
687    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
688    p_org_rec              IN  HZ_PARTY_V2PUB.organization_rec_type,
689    x_party_id             OUT NOCOPY NUMBER,
690    x_party_number         OUT NOCOPY VARCHAR2,
691    x_return_status        OUT NOCOPY VARCHAR2,
692    x_msg_count            OUT NOCOPY NUMBER,
693    x_msg_data             OUT NOCOPY VARCHAR2 )
694 IS
695   l_api_name              CONSTANT VARCHAR2(30) := 'Create_Organization';
696   l_api_version           CONSTANT NUMBER := 1.0;
697   l_profile_id                     NUMBER;
698 BEGIN
699 
700     -- Standard Start of API savepoint
701     SAVEPOINT Create_Organization_Pvt;
702 
703     -- Standard call to check for call compatibility.
704     IF NOT FND_API.Compatible_API_Call (l_api_version,
705                                         p_api_version,
706                                         l_api_name,
707                                         G_PKG_NAME)
708     THEN
709         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
710     END IF;
711 
712     -- Initialize message list if p_init_msg_list is set to TRUE.
713     IF FND_API.to_Boolean(p_init_msg_list) THEN
714         FND_MSG_PUB.initialize;
715     END IF;
716 
717     -- Initialize API return status to success
718     x_return_status := FND_API.G_RET_STS_SUCCESS;
719 
720     --
721     -- Begin API Body
722     --
723 
724     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
725                                         p_api_name  => l_api_name );
726 
727     IF l_debug > 5 THEN
728           csd_gen_utility_pvt.dump_hz_org_rec
729                    ( p_org_rec => p_org_rec);
730     END IF;
731 
732 
733     HZ_PARTY_V2PUB.Create_Organization(
734                                       p_init_msg_list    => FND_API.G_FALSE,
735                                       p_organization_rec => p_org_rec,
736                                       x_return_status    => x_return_status,
737                                       x_msg_count        => x_msg_count,
738                                       x_msg_data         => x_msg_data,
739                                       x_party_id         => x_party_id,
740                                       x_party_number     => x_party_number,
741                                       x_profile_id       => l_profile_id
742                                     );
743     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
744         csd_gen_utility_pvt.ADD('Create_Organization failed ');
745         RAISE FND_API.G_EXC_ERROR;
746     END IF;
747 
748     --
749     -- End API Body
750     --
751 
752     -- Standard check of p_commit.
753     IF FND_API.To_Boolean( p_commit ) THEN
754        COMMIT WORK;
755     END IF;
756 
757     -- Standard call to get message count and IF count is  get message info.
758     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
759                                p_data   =>  x_msg_data );
760 EXCEPTION
761     WHEN FND_API.G_EXC_ERROR THEN
762           ROLLBACK TO Create_Organization_Pvt;
763           x_return_status := FND_API.G_RET_STS_ERROR ;
764           FND_MSG_PUB.Count_And_Get
765                 (p_count  =>  x_msg_count,
766                  p_data   =>  x_msg_data
767                 );
771           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
768     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
769           ROLLBACK TO Create_Organization_Pvt;
770           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
772                                      p_data   =>  x_msg_data );
773     WHEN OTHERS THEN
774           ROLLBACK TO Create_Organization_Pvt;
775           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
776           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
777           THEN
778               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
779                                        l_api_name  );
780           END IF;
781           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
782                                      p_data   =>  x_msg_data );
783 END Create_Organization;
784 
785 /*----------------------------------------------------------------*/
786 /* procedure name: Create_Account                                 */
787 /* description   : procedure used to create                       */
788 /*                 an account for a person                        */
789 /*                                                                */
790 /* p_api_version                Standard IN param                 */
791 /* p_commit                     Standard IN param                 */
792 /* p_init_msg_list              Standard IN param                 */
793 /* p_validation_level           Standard IN param                 */
794 /* p_account_rec                Account Info                      */
795 /* p_person_rec                 Person Information                */
796 /* p_cust_profile_rec           Profile Info                      */
797 /* x_cust_account_id            Account ID generated              */
798 /* x_cust_account_number        Account Number generated          */
799 /* x_return_status              Standard OUT param                */
800 /* x_msg_count                  Standard OUT param                */
801 /* x_msg_data                   Standard OUT param                */
802 /*                                                                */
803 /*----------------------------------------------------------------*/
804 PROCEDURE Create_Account
805 (  p_api_version          IN  NUMBER,
806    p_commit               IN  VARCHAR2  := fnd_api.g_false,
807    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
808    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
809    p_account_rec          IN  HZ_CUST_ACCOUNT_V2PUB.cust_account_rec_type,
810    p_person_rec           IN  HZ_PARTY_V2PUB.person_rec_type,
811    p_cust_profile_rec     IN  HZ_CUSTOMER_PROFILE_V2PUB.customer_profile_rec_type,
812    x_cust_account_id      OUT NOCOPY NUMBER,
813    x_cust_account_number  OUT NOCOPY VARCHAR2,
814    x_return_status        OUT NOCOPY VARCHAR2,
815    x_msg_count            OUT NOCOPY NUMBER,
816    x_msg_data             OUT NOCOPY VARCHAR2 )
817 IS
818   l_api_name              CONSTANT VARCHAR2(30) := 'Create_Account';
819   l_api_version           CONSTANT NUMBER := 1.0;
820   l_party_id                       NUMBER;
821   l_party_number                   VARCHAR2(30);
822   l_profile_id                     NUMBER;
823 BEGIN
824 
825     -- Standard Start of API savepoint
826     SAVEPOINT Create_Account_Pvt;
827 
828     -- Standard call to check for call compatibility.
829     IF NOT FND_API.Compatible_API_Call (l_api_version,
830                                         p_api_version,
831                                         l_api_name,
832                                         G_PKG_NAME)
833     THEN
834         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
835     END IF;
836 
837     -- Initialize message list if p_init_msg_list is set to TRUE.
838     IF FND_API.to_Boolean(p_init_msg_list) THEN
839         FND_MSG_PUB.initialize;
840     END IF;
841 
842     -- Initialize API return status to success
843     x_return_status := FND_API.G_RET_STS_SUCCESS;
844 
845     --
846     -- Begin API Body
847     --
848     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
849                                         p_api_name  => l_api_name );
850     IF l_debug > 5 THEN
851           csd_gen_utility_pvt.dump_hz_acct_rec
852                    ( p_account_rec => p_account_rec);
853           csd_gen_utility_pvt.dump_hz_person_rec
854                    ( p_person_rec => p_person_rec);
855           csd_gen_utility_pvt.dump_hz_cust_profile_rec
856                    ( p_cust_profile_rec => p_cust_profile_rec);
857     END IF;
858 
859     HZ_CUST_ACCOUNT_V2PUB.create_cust_account(
860                                p_init_msg_list        => FND_API.G_FALSE,
861                                p_cust_account_rec     => p_account_rec,
862                                p_person_rec           => p_person_rec,
863                                p_customer_profile_rec => p_cust_profile_rec,
864                                p_create_profile_amt   => FND_API.G_TRUE,
865                                x_cust_account_id      => x_cust_account_id,
866                                x_account_number       => x_cust_account_number,
867                                x_party_id             => l_party_id,
868                                x_party_number         => l_party_number,
869                                x_profile_id           => l_profile_id,
870                                x_return_status        => x_return_status,
871                                x_msg_count            => x_msg_count,
875     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
872                                x_msg_data             => x_msg_data
873                                );
874 
876         csd_gen_utility_pvt.ADD('Create_Account failed ');
877         RAISE FND_API.G_EXC_ERROR;
878     END IF;
879 
880     --
881     -- End API Body
882     --
883 
884     -- Standard check of p_commit.
885     IF FND_API.To_Boolean( p_commit ) THEN
886        COMMIT WORK;
887     END IF;
888 
889     -- Standard call to get message count and IF count is  get message info.
890     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
891                                p_data   =>  x_msg_data );
892 EXCEPTION
893     WHEN FND_API.G_EXC_ERROR THEN
894           ROLLBACK TO Create_Account_Pvt;
895           x_return_status := FND_API.G_RET_STS_ERROR ;
896           FND_MSG_PUB.Count_And_Get
897                 (p_count  =>  x_msg_count,
898                  p_data   =>  x_msg_data
899                 );
900     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
901           ROLLBACK TO Create_Account_Pvt;
902           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
903           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
904                                      p_data   =>  x_msg_data );
905     WHEN OTHERS THEN
906           ROLLBACK TO Create_Account_Pvt;
907           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
908           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
909           THEN
910               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
911                                        l_api_name  );
912           END IF;
913           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
914                                      p_data   =>  x_msg_data );
915 END Create_Account;
916 
917 
918 
919 /*----------------------------------------------------------------*/
920 /* procedure name: Create_Account                                 */
921 /* description   : procedure used to create                       */
922 /*                 an account for an organization                 */
923 /*                                                                */
924 /* p_api_version                Standard IN param                 */
925 /* p_commit                     Standard IN param                 */
926 /* p_init_msg_list              Standard IN param                 */
927 /* p_validation_level           Standard IN param                 */
928 /* p_account_rec                Account Info                      */
929 /* p_org_rec                    Organization Info                 */
930 /* p_cust_profile_rec           Profile Info                      */
931 /* x_cust_account_id            Account ID generated              */
932 /* x_cust_account_number        Account Number generated          */
933 /* x_return_status              Standard OUT param                */
934 /* x_msg_count                  Standard OUT param                */
935 /* x_msg_data                   Standard OUT param                */
936 /*                                                                */
937 /*----------------------------------------------------------------*/
938 PROCEDURE Create_Account
939 (  p_api_version          IN  NUMBER,
940    p_commit               IN  VARCHAR2  := fnd_api.g_false,
941    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
942    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
943    p_account_rec          IN  HZ_CUST_ACCOUNT_V2PUB.cust_account_rec_type,
944    p_org_rec              IN  HZ_PARTY_V2PUB.organization_rec_type,
945    p_cust_profile_rec     IN  HZ_CUSTOMER_PROFILE_V2PUB.customer_profile_rec_type,
946    x_cust_account_id      OUT NOCOPY NUMBER,
947    x_cust_account_number  OUT NOCOPY VARCHAR2,
948    x_return_status        OUT NOCOPY VARCHAR2,
949    x_msg_count            OUT NOCOPY NUMBER,
950    x_msg_data             OUT NOCOPY VARCHAR2 )
951 IS
952   l_api_name              CONSTANT VARCHAR2(30) := 'Create_Account';
953   l_api_version           CONSTANT NUMBER := 1.0;
954   l_party_id                       NUMBER;
955   l_party_number                   VARCHAR2(30);
956   l_profile_id                     NUMBER;
957 BEGIN
958 
959     -- Standard Start of API savepoint
960     SAVEPOINT Create_Account_Pvt;
961 
962     -- Standard call to check for call compatibility.
963     IF NOT FND_API.Compatible_API_Call (l_api_version,
964                                         p_api_version,
965                                         l_api_name,
966                                         G_PKG_NAME)
967     THEN
968         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
969     END IF;
970 
971     -- Initialize message list if p_init_msg_list is set to TRUE.
972     IF FND_API.to_Boolean(p_init_msg_list) THEN
973         FND_MSG_PUB.initialize;
974     END IF;
975 
976     -- Initialize API return status to success
977     x_return_status := FND_API.G_RET_STS_SUCCESS;
978 
979     --
980     -- Begin API Body
981     --
982     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
983                                         p_api_name  => l_api_name );
984 
985     IF l_debug > 5 THEN
986           csd_gen_utility_pvt.dump_hz_acct_rec
987                    ( p_account_rec => p_account_rec);
988           csd_gen_utility_pvt.dump_hz_org_rec
989                    ( p_org_rec => p_org_rec);
993 
990           csd_gen_utility_pvt.dump_hz_cust_profile_rec
991                    ( p_cust_profile_rec => p_cust_profile_rec);
992     END IF;
994     HZ_CUST_ACCOUNT_V2PUB.create_cust_account(
995                                p_init_msg_list        => FND_API.G_FALSE,
996                                p_cust_account_rec     => p_account_rec,
997                                p_organization_rec     => p_org_rec,
998                                p_customer_profile_rec => p_cust_profile_rec,
999                                p_create_profile_amt   => FND_API.G_TRUE,
1000                                x_cust_account_id      => x_cust_account_id,
1001                                x_account_number       => x_cust_account_number,
1002                                x_party_id             => l_party_id,
1003                                x_party_number         => l_party_number,
1004                                x_profile_id           => l_profile_id,
1005                                x_return_status        => x_return_status,
1006                                x_msg_count            => x_msg_count,
1007                                x_msg_data             => x_msg_data
1008                                );
1009 
1010     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1011         csd_gen_utility_pvt.ADD('Create_Account failed ');
1012         RAISE FND_API.G_EXC_ERROR;
1013     END IF;
1014 
1015     --
1016     -- End API Body
1017     --
1018 
1019     -- Standard check of p_commit.
1020     IF FND_API.To_Boolean( p_commit ) THEN
1021        COMMIT WORK;
1022     END IF;
1023 
1024     -- Standard call to get message count and IF count is  get message info.
1025     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1026                                p_data   =>  x_msg_data );
1027 EXCEPTION
1028     WHEN FND_API.G_EXC_ERROR THEN
1029           ROLLBACK TO Create_Account_Pvt;
1030           x_return_status := FND_API.G_RET_STS_ERROR ;
1031           FND_MSG_PUB.Count_And_Get
1032                 (p_count  =>  x_msg_count,
1033                  p_data   =>  x_msg_data
1034                 );
1035     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1036           ROLLBACK TO Create_Account_Pvt;
1037           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1038           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1039                                      p_data   =>  x_msg_data );
1040     WHEN OTHERS THEN
1041           ROLLBACK TO Create_Account_Pvt;
1042           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1043           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1044           THEN
1045               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
1046                                        l_api_name  );
1047           END IF;
1048           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1049                                      p_data   =>  x_msg_data );
1050 END Create_Account;
1051 
1052 
1053 /*----------------------------------------------------------------*/
1054 /* procedure name: Create_ContactPoints                           */
1055 /* description   : procedure used to create                       */
1056 /*                 contact points for a party                     */
1057 /*                                                                */
1058 /* p_api_version                Standard IN param                 */
1059 /* p_commit                     Standard IN param                 */
1060 /* p_init_msg_list              Standard IN param                 */
1061 /* p_validation_level           Standard IN param                 */
1062 /* p_phone_rec                  Phone Info                        */
1063 /* p_email_rec                  Email Info                        */
1064 /* p_web_rec                    Web Info                          */
1065 /* p_create_phone_flag          'Y' to create phone contact point */
1066 /* p_create_email_flag          'Y' to create email contact point */
1067 /* p_create_url_flag            'Y' to create url contact point   */
1068 /* p_party_id                   Party ID for these contact points */
1069 /* x_phone_id                   Phone contact point ID            */
1070 /* x_email_id                   Email contact point ID            */
1071 /* x_url_id                     URL contact point ID              */
1072 /* x_return_status              Standard OUT param                */
1073 /* x_msg_count                  Standard OUT param                */
1074 /* x_msg_data                   Standard OUT param                */
1075 /*                                                                */
1076 /*----------------------------------------------------------------*/
1077 PROCEDURE Create_ContactPoints
1078 (  p_api_version       IN  NUMBER,
1079    p_commit            IN  VARCHAR2  := fnd_api.g_false,
1080    p_init_msg_list     IN  VARCHAR2  := fnd_api.g_false,
1081    p_validation_level  IN  NUMBER    := fnd_api.g_valid_level_full,
1082    p_phone_rec         IN  HZ_CONTACT_POINT_V2PUB.phone_rec_type,
1083    p_email_rec         IN  HZ_CONTACT_POINT_V2PUB.email_rec_type,
1084    p_web_rec           IN  HZ_CONTACT_POINT_V2PUB.web_rec_type,
1085    p_create_phone_flag IN  VARCHAR2,
1086    p_create_email_flag IN  VARCHAR2,
1087    p_create_url_flag   IN  VARCHAR2,
1088    p_party_id          IN  NUMBER,
1089    x_phone_id          OUT NOCOPY NUMBER,
1090    x_email_id          OUT NOCOPY NUMBER,
1091    x_url_id            OUT NOCOPY NUMBER,
1092    x_return_status     OUT NOCOPY VARCHAR2,
1093    x_msg_count         OUT NOCOPY NUMBER,
1097    l_api_version       CONSTANT NUMBER := 1.0;
1094    x_msg_data          OUT NOCOPY VARCHAR2 )
1095 IS
1096    l_api_name          CONSTANT VARCHAR2(30) := 'Create_ContactPoints';
1098    l_phone_create_rec  HZ_CONTACT_POINT_V2PUB.phone_rec_type
1099                                 := CSD_PROCESS_PVT.get_phone_rec_type;
1100    l_email_create_rec  HZ_CONTACT_POINT_V2PUB.email_rec_type
1101                                 := CSD_PROCESS_PVT.get_email_rec_type;
1102    l_web_create_rec    HZ_CONTACT_POINT_V2PUB.web_rec_type
1103                                 := CSD_PROCESS_PVT.get_web_rec_type;
1104    l_edi_create_rec    HZ_CONTACT_POINT_V2PUB.edi_rec_type
1105                                 := CSD_PROCESS_PVT.get_edi_rec_type;
1106    l_telex_create_rec  HZ_CONTACT_POINT_V2PUB.telex_rec_type
1107                                 := CSD_PROCESS_PVT.get_telex_rec_type;
1108    l_contpt_create_rec HZ_CONTACT_POINT_V2PUB.contact_point_rec_type
1109                                 := CSD_PROCESS_PVT.get_contact_points_rec_type;
1110 BEGIN
1111 
1112     -- Standard Start of API savepoint
1113     SAVEPOINT Create_ContactPoints_Pvt;
1114 
1115     -- Standard call to check for call compatibility.
1116     IF NOT FND_API.Compatible_API_Call (l_api_version,
1117                                         p_api_version,
1118                                         l_api_name,
1119                                         G_PKG_NAME)
1120     THEN
1121         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1122     END IF;
1123 
1124     -- Initialize message list if p_init_msg_list is set to TRUE.
1125     IF FND_API.to_Boolean(p_init_msg_list) THEN
1126         FND_MSG_PUB.initialize;
1127     END IF;
1128 
1129     -- Initialize API return status to success
1130     x_return_status := FND_API.G_RET_STS_SUCCESS;
1131 
1132     --
1133     -- Begin API Body
1134     --
1135     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
1136                                         p_api_name  => l_api_name );
1137     IF l_debug > 5 THEN
1138           csd_gen_utility_pvt.dump_hz_phone_rec
1139                    ( p_phone_rec => p_phone_rec);
1140           csd_gen_utility_pvt.dump_hz_email_rec
1141                    ( p_email_rec => p_email_rec);
1142           csd_gen_utility_pvt.dump_hz_web_rec
1143                    ( p_web_rec => p_web_rec);
1144     END IF;
1145 
1146     IF (p_create_phone_flag = 'Y') THEN
1147         l_contpt_create_rec.contact_point_type := 'PHONE';
1148         l_contpt_create_rec.owner_table_name   := 'HZ_PARTIES';
1149         l_contpt_create_rec.owner_table_id     := p_party_id;
1150 
1151         HZ_CONTACT_POINT_V2PUB.Create_contact_point(
1152                              p_init_msg_list         => FND_API.G_FALSE,
1153                              p_contact_point_rec     => l_contpt_create_rec,
1154                              p_edi_rec               => l_edi_create_rec,
1155                              p_email_rec             => l_email_create_rec,
1156                              p_phone_rec             => p_phone_rec,
1157                              p_telex_rec             => l_telex_create_rec,
1158                              p_web_rec               => l_web_create_rec,
1159                              x_contact_point_id      => x_phone_id,
1160                              x_return_status         => x_return_status,
1161                              x_msg_count             => x_msg_count,
1162                              x_msg_data              => x_msg_data
1163                              );
1164 
1165         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1166             csd_gen_utility_pvt.ADD('Create_contact_points failed ');
1167             RAISE FND_API.G_EXC_ERROR;
1168         END IF;
1169 
1170     END IF;  -- end create phone contact point
1171 
1172     IF (p_create_email_flag = 'Y') THEN
1173         l_contpt_create_rec.contact_point_type := 'EMAIL';
1174         l_contpt_create_rec.owner_table_name   := 'HZ_PARTIES';
1175         l_contpt_create_rec.owner_table_id     := p_party_id;
1176 
1177         HZ_CONTACT_POINT_V2PUB.Create_contact_point(
1178                              p_init_msg_list         => FND_API.G_FALSE,
1179                              p_contact_point_rec     => l_contpt_create_rec,
1180                              p_edi_rec               => l_edi_create_rec,
1181                              p_email_rec             => p_email_rec,
1182                              p_phone_rec             => l_phone_create_rec,
1183                              p_telex_rec             => l_telex_create_rec,
1184                              p_web_rec               => l_web_create_rec,
1185                              x_contact_point_id      => x_email_id,
1186                              x_return_status         => x_return_status,
1187                              x_msg_count             => x_msg_count,
1188                              x_msg_data              => x_msg_data
1189                              );
1190 
1191         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1192             csd_gen_utility_pvt.ADD('Create_contact_points failed ');
1193             RAISE FND_API.G_EXC_ERROR;
1194         END IF;
1195     END IF;   -- end create email contact point
1196 
1197     IF (p_create_url_flag = 'Y') THEN
1198         l_contpt_create_rec.contact_point_type := 'WEB';
1199         l_contpt_create_rec.owner_table_name   := 'HZ_PARTIES';
1200         l_contpt_create_rec.owner_table_id     := p_party_id;
1201 
1202         HZ_CONTACT_POINT_V2PUB.Create_contact_point(
1203                              p_init_msg_list         => FND_API.G_FALSE,
1207                              p_phone_rec             => l_phone_create_rec,
1204                              p_contact_point_rec     => l_contpt_create_rec,
1205                              p_edi_rec               => l_edi_create_rec,
1206                              p_email_rec             => l_email_create_rec,
1208                              p_telex_rec             => l_telex_create_rec,
1209                              p_web_rec               => p_web_rec,
1210                              x_contact_point_id      => x_url_id,
1211                              x_return_status         => x_return_status,
1212                              x_msg_count             => x_msg_count,
1213                              x_msg_data              => x_msg_data
1214                              );
1215 
1216         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1217             csd_gen_utility_pvt.ADD('Create_contact_points failed ');
1218             RAISE FND_API.G_EXC_ERROR;
1219         END IF;
1220     END IF;  -- end create url contact point
1221 
1222     --
1223     -- End API Body
1224     --
1225 
1226     -- Standard check of p_commit.
1227     IF FND_API.To_Boolean( p_commit ) THEN
1228        COMMIT WORK;
1229     END IF;
1230 
1231     -- Standard call to get message count and IF count is  get message info.
1232     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1233                                p_data   =>  x_msg_data );
1234 EXCEPTION
1235     WHEN FND_API.G_EXC_ERROR THEN
1236           ROLLBACK TO Create_ContactPoints_Pvt;
1237           x_return_status := FND_API.G_RET_STS_ERROR ;
1238           x_phone_id := NULL;
1239           x_email_id := NULL;
1240           x_url_id   := NULL;
1241           FND_MSG_PUB.Count_And_Get
1242                 (p_count  =>  x_msg_count,
1243                  p_data   =>  x_msg_data
1244                 );
1245     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1246           ROLLBACK TO Create_ContactPoints_Pvt;
1247           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1248           x_phone_id := NULL;
1249           x_email_id := NULL;
1250           x_url_id   := NULL;
1251           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1252                                      p_data   =>  x_msg_data );
1253     WHEN OTHERS THEN
1254           ROLLBACK TO Create_ContactPoints_Pvt;
1255           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1256           x_phone_id := NULL;
1257           x_email_id := NULL;
1258           x_url_id   := NULL;
1259           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1260           THEN
1261               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
1262                                        l_api_name  );
1263           END IF;
1264           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1265                                      p_data   =>  x_msg_data );
1266 END Create_ContactPoints;
1267 
1268 
1269 
1270 /*----------------------------------------------------------------*/
1271 /* procedure name: Create_AddressRecords                          */
1272 /* description   : procedure used to create                       */
1273 /*                 address records in TCA                         */
1274 /*                 This includes creating a location, site,       */
1275 /*                 and site use.                                  */
1276 /*                                                                */
1277 /* p_api_version                Standard IN param                 */
1278 /* p_commit                     Standard IN param                 */
1279 /* p_init_msg_list              Standard IN param                 */
1280 /* p_validation_level           Standard IN param                 */
1281 /* p_loc_rec                    Location                          */
1282 /* p_location_id                Location ID, if it already exists */
1283 /* x_party_site_rec             Site                              */
1284 /* x_party_site_use_rec         Site use                          */
1285 /* x_location_id                Location ID created/used          */
1286 /* x_party_site_id              Site id                           */
1287 /* x_party_site_number          Site number                       */
1288 /* x_party_site_use_id          Site use id                       */
1289 /* x_return_status              Standard OUT param                */
1290 /* x_msg_count                  Standard OUT param                */
1291 /* x_msg_data                   Standard OUT param                */
1292 /*                                                                */
1293 /*----------------------------------------------------------------*/
1294 PROCEDURE Create_AddressRecords
1295 (  p_api_version        IN  NUMBER,
1296    p_commit             IN  VARCHAR2  := fnd_api.g_false,
1297    p_init_msg_list      IN  VARCHAR2  := fnd_api.g_false,
1298    p_validation_level   IN  NUMBER    := fnd_api.g_valid_level_full,
1299    p_loc_rec            IN  CSD_PROCESS_PVT.address_rec_type,
1300    p_location_id        IN  NUMBER := NULL,
1301    x_party_site_rec     IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_rec_type,
1302    x_party_site_use_rec IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_use_rec_type,
1303    x_location_id        OUT NOCOPY NUMBER,
1304    x_party_site_id      OUT NOCOPY NUMBER,
1305    x_party_site_number  OUT NOCOPY NUMBER,
1306    x_party_site_use_id  OUT NOCOPY NUMBER,
1307    x_return_status      OUT NOCOPY VARCHAR2,
1308    x_msg_count          OUT NOCOPY NUMBER,
1309    x_msg_data           OUT NOCOPY VARCHAR2 )
1310 IS
1314 
1311    l_api_name           CONSTANT VARCHAR2(30) := 'Create_AddressRecords';
1312    l_api_version        CONSTANT NUMBER := 1.0;
1313 BEGIN
1315     -- Standard Start of API savepoint
1316     SAVEPOINT Create_AddressRecords_Pvt;
1317 
1318     -- Standard call to check for call compatibility.
1319     IF NOT FND_API.Compatible_API_Call (l_api_version,
1320                                         p_api_version,
1321                                         l_api_name,
1322                                         G_PKG_NAME)
1323     THEN
1324         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1325     END IF;
1326 
1327     -- Initialize message list if p_init_msg_list is set to TRUE.
1328     IF FND_API.to_Boolean(p_init_msg_list) THEN
1329         FND_MSG_PUB.initialize;
1330     END IF;
1331 
1332     -- Initialize API return status to success
1333     x_return_status := FND_API.G_RET_STS_SUCCESS;
1334 
1335     --
1336     -- Begin API Body
1337     --
1338     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
1339                                         p_api_name  => l_api_name );
1340     IF l_debug > 5 THEN
1341           csd_gen_utility_pvt.dump_address_rec
1342                    ( p_addr_rec => p_loc_rec);
1343           csd_gen_utility_pvt.dump_hz_party_site_rec
1344                    ( p_party_site_rec => x_party_site_rec);
1345           csd_gen_utility_pvt.dump_hz_party_site_use_rec
1346                    ( p_party_site_use_rec => x_party_site_use_rec);
1347     END IF;
1348 
1349 
1350     x_location_id := p_location_id;
1351     -- Create location if location_id is not passed in
1352     IF (p_location_id is null) THEN
1353         Create_Address (  p_api_version      => 1.0,
1354                           p_commit           => FND_API.G_FALSE,
1355                           p_init_msg_list    => FND_API.G_FALSE,
1356                           p_validation_level => p_validation_level,
1357                           p_address_rec      => p_loc_rec,
1358                           x_location_id      => x_location_id,
1359                           x_return_status    => x_return_status,
1360                           x_msg_count        => x_msg_count,
1361                           x_msg_data         => x_msg_data);
1362 
1363         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1364             csd_gen_utility_pvt.ADD('Create_Address failed ');
1365             RAISE FND_API.G_EXC_ERROR;
1366         END IF;
1367     END IF;  -- end create location
1368 
1369     -- Create party site if location is created or if location_id is passed in
1370     IF (p_location_id is not null) OR (x_location_id is not null) THEN
1371         -- First, set the location in the site record before creating the site
1372         IF (p_location_id is not null) THEN
1373             x_party_site_rec.location_id := p_location_id;
1374         ELSE
1375             x_party_site_rec.location_id := x_location_id;
1376         END IF;
1377 
1378         -- Second, create the site
1379         HZ_PARTY_SITE_V2PUB.Create_Party_Site(
1380                           p_init_msg_list       => FND_API.G_FALSE,
1381                           p_party_site_rec      => x_party_site_rec,
1382                           x_party_site_id       => x_party_site_id,
1383                           x_party_site_number   => x_party_site_number,
1384                           x_return_status       => x_return_status,
1385                           x_msg_count           => x_msg_count,
1386                           x_msg_data            => x_msg_data
1387                           );
1388         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1389             csd_gen_utility_pvt.ADD('Create_Party_Site failed ');
1390             RAISE FND_API.G_EXC_ERROR;
1391         END IF;
1392         x_party_site_rec.party_site_id := x_party_site_id;
1393         x_party_site_rec.party_site_number := x_party_site_number;
1394    END IF;  -- end create party site
1395 
1396    -- Create party site use if party site is created
1397    IF (x_party_site_id is not null) THEN
1398        -- IF (x_party_site_use_rec.site_use_type is not null) THEN
1399            -- First, set the party site id in the use record
1400            x_party_site_use_rec.party_site_id := x_party_site_id;
1401 
1402            -- Second, create the site use
1403            HZ_PARTY_SITE_V2PUB.Create_Party_Site_Use (
1404                           p_init_msg_list       => FND_API.G_FALSE,
1405                           p_party_site_use_rec  => x_party_site_use_rec,
1406                           x_party_site_use_id   => x_party_site_use_id,
1407                           x_return_status       => x_return_status,
1408                           x_msg_count           => x_msg_count,
1409                           x_msg_data            => x_msg_data
1410                           );
1411             IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1412                 csd_gen_utility_pvt.ADD('Create_Party_Site_Use failed ');
1413                 RAISE FND_API.G_EXC_ERROR;
1414             END IF;
1415        -- END IF;
1416     END IF;  -- end create site use
1417 
1418     --
1419     -- End API Body
1420     --
1421 
1422     -- Standard check of p_commit.
1423     IF FND_API.To_Boolean( p_commit ) THEN
1424        COMMIT WORK;
1425     END IF;
1426 
1427     -- Standard call to get message count and IF count is  get message info.
1428     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1429                                p_data   =>  x_msg_data );
1433           x_return_status := FND_API.G_RET_STS_ERROR ;
1430 EXCEPTION
1431     WHEN FND_API.G_EXC_ERROR THEN
1432           ROLLBACK TO Create_AddressRecords_Pvt;
1434           x_location_id       := NULL;
1435           x_party_site_id     := NULL;
1436           x_party_site_number := NULL;
1437           x_party_site_use_id := NULL;
1438           FND_MSG_PUB.Count_And_Get
1439                 (p_count  =>  x_msg_count,
1440                  p_data   =>  x_msg_data
1441                 );
1442     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1443           ROLLBACK TO Create_AddressRecords_Pvt;
1444           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1445           x_location_id       := NULL;
1446           x_party_site_id     := NULL;
1447           x_party_site_number := NULL;
1448           x_party_site_use_id := NULL;
1449           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1450                                      p_data   =>  x_msg_data );
1451     WHEN OTHERS THEN
1452           ROLLBACK TO Create_AddressRecords_Pvt;
1453           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1454           x_location_id       := NULL;
1455           x_party_site_id     := NULL;
1456           x_party_site_number := NULL;
1457           x_party_site_use_id := NULL;
1458           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1459           THEN
1460               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
1461                                        l_api_name  );
1462           END IF;
1463           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1464                                      p_data   =>  x_msg_data );
1465 END Create_AddressRecords;
1466 
1467 /*----------------------------------------------------------------*/
1468 /* procedure name: Create_Address                                 */
1469 /* description   : procedure used to create                       */
1470 /*                 a location in TCA                              */
1471 /*                                                                */
1472 /* p_api_version                Standard IN param                 */
1473 /* p_commit                     Standard IN param                 */
1474 /* p_init_msg_list              Standard IN param                 */
1475 /* p_validation_level           Standard IN param                 */
1476 /* p_address_rec                Location to create                */
1477 /* x_location_id                Location ID created               */
1478 /* x_return_status              Standard OUT param                */
1479 /* x_msg_count                  Standard OUT param                */
1480 /* x_msg_data                   Standard OUT param                */
1481 /*                                                                */
1482 /*----------------------------------------------------------------*/
1483 PROCEDURE Create_Address
1484 (  p_api_version        IN  NUMBER,
1485    p_commit             IN  VARCHAR2  := fnd_api.g_false,
1486    p_init_msg_list      IN  VARCHAR2  := fnd_api.g_false,
1487    p_validation_level   IN  NUMBER    := fnd_api.g_valid_level_full,
1488    p_address_rec        IN  CSD_PROCESS_PVT.address_rec_type,
1489    x_location_id        OUT NOCOPY NUMBER,
1490    x_return_status      OUT NOCOPY VARCHAR2,
1491    x_msg_count          OUT NOCOPY NUMBER,
1492    x_msg_data           OUT NOCOPY VARCHAR2 )
1493 IS
1494   l_api_name            CONSTANT VARCHAR2(30) := 'Create_Address';
1495   l_api_version         CONSTANT NUMBER := 1.0;
1496   -- swai: change to TCA v2
1497   l_location_rec        HZ_LOCATION_V2PUB.location_rec_type;
1498 BEGIN
1499 
1500     -- Standard Start of API savepoint
1501     SAVEPOINT Create_Address_Pvt;
1502 
1503     -- Standard call to check for call compatibility.
1504     IF NOT FND_API.Compatible_API_Call (l_api_version,
1505                                         p_api_version,
1506                                         l_api_name,
1507                                         G_PKG_NAME)
1508     THEN
1509         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1510     END IF;
1511 
1512     -- Initialize message list if p_init_msg_list is set to TRUE.
1513     IF FND_API.to_Boolean(p_init_msg_list) THEN
1514         FND_MSG_PUB.initialize;
1515     END IF;
1516 
1517     -- Initialize API return status to success
1518     x_return_status := FND_API.G_RET_STS_SUCCESS;
1519 
1520     --
1521     -- Begin API Body
1522     --
1523     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
1524                                         p_api_name  => l_api_name );
1525     IF l_debug > 5 THEN
1526           csd_gen_utility_pvt.dump_address_rec
1527                    ( p_addr_rec => p_address_rec);
1528     END IF;
1529 
1530     l_location_rec.location_id := p_address_rec.location_id;
1531     l_location_rec.address1 := p_address_rec.address1;
1532     l_location_rec.address2 := p_address_rec.address2;
1533     l_location_rec.address3 := p_address_rec.address3;
1534     l_location_rec.address4 := p_address_rec.address4;
1535     l_location_rec.city     := p_address_rec.city;
1536     l_location_rec.state    := p_address_rec.state;
1537     l_location_rec.postal_code := p_address_rec.postal_code;
1538     l_location_rec.province := p_address_rec.province;
1539     l_location_rec.county   := p_address_rec.county;
1540     l_location_rec.country  := p_address_rec.country;
1541     l_location_rec.language := p_address_rec.language;
1542     l_location_rec.position := p_address_rec.position;
1543     l_location_rec.address_key := p_address_rec.address_key;
1547     l_location_rec.location_directions := p_address_rec.location_directions;
1544     l_location_rec.postal_plus4_code := p_address_rec.postal_plus4_code;
1545     l_location_rec.position := p_address_rec.position;
1546     l_location_rec.delivery_point_code := p_address_rec.delivery_point_code;
1548     -- l_location_rec.address_error_code := p_address_rec.address_error_code;
1549     l_location_rec.clli_code := p_address_rec.clli_code;
1550     l_location_rec.short_description := p_address_rec.short_description;
1551     l_location_rec.description := p_address_rec.description;
1552     l_location_rec.sales_tax_geocode := p_address_rec.sales_tax_geocode;
1553     l_location_rec.sales_tax_inside_city_limits := p_address_rec.sales_tax_inside_city_limits;
1554     l_location_rec.address_effective_date := p_address_rec.address_effective_date;
1555     l_location_rec.address_expiration_date := p_address_rec.address_expiration_date;
1556     l_location_rec.address_style := p_address_rec.address_style;
1557     -- swai: unused fields in TCA, but still avail in v2 (per bug #2863096)
1558     l_location_rec.po_box_number := p_address_rec.po_box_number;
1559     l_location_rec.street   := p_address_rec.street;
1560     l_location_rec.house_number  := p_address_rec.house_number;
1561     l_location_rec.street_suffix := p_address_rec.street_suffix;
1562     l_location_rec.street_number := p_address_rec.street_number;
1563     l_location_rec.floor := p_address_rec.floor;
1564     l_location_rec.suite := p_address_rec.suite;
1565     -- swai: new TCA V2 fields --
1566     l_location_rec.timezone_id := p_address_rec.timezone_id;
1567     l_location_rec.created_by_module := p_address_rec.created_by_module;
1568     l_location_rec.application_id := p_address_rec.application_id;
1569     l_location_rec.actual_content_source := p_address_rec.actual_content_source;
1570     l_location_rec.delivery_point_code := p_address_rec.delivery_point_code;
1571     -- end new TCA V2 fields --
1572 
1573     -- swai: use new TCA v2 API
1574     HZ_LOCATION_V2PUB.create_location (
1575                           p_init_msg_list     => FND_API.G_FALSE,
1576                           p_location_rec      => l_location_rec,
1577                           x_location_id       => x_location_id,
1578                           x_return_status     => x_return_status,
1579                           x_msg_count         => x_msg_count,
1580                           x_msg_data          => x_msg_data);
1581 
1582         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1583             csd_gen_utility_pvt.ADD('create_location failed ');
1584             RAISE FND_API.G_EXC_ERROR;
1585         END IF;
1586     --
1587     -- End API Body
1588     --
1589 
1590     -- Standard check of p_commit.
1591     IF FND_API.To_Boolean( p_commit ) THEN
1592        COMMIT WORK;
1593     END IF;
1594 
1595     -- Standard call to get message count and IF count is  get message info.
1596     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1597                                p_data   =>  x_msg_data );
1598 EXCEPTION
1599     WHEN FND_API.G_EXC_ERROR THEN
1600           ROLLBACK TO Create_Address_Pvt;
1601           x_return_status := FND_API.G_RET_STS_ERROR ;
1602           FND_MSG_PUB.Count_And_Get
1603                 (p_count  =>  x_msg_count,
1604                  p_data   =>  x_msg_data
1605                 );
1606     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1607           ROLLBACK TO Create_Address_Pvt;
1608           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1609           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1610                                      p_data   =>  x_msg_data );
1611     WHEN OTHERS THEN
1612           ROLLBACK TO Create_Address_Pvt;
1613           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1614           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1615           THEN
1616               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
1617                                        l_api_name  );
1618           END IF;
1619           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1620                                      p_data   =>  x_msg_data );
1621 END Create_Address;
1622 
1623 /*----------------------------------------------------------------*/
1624 /* procedure name: Create_Relationship                            */
1625 /* description   : procedure used to create                       */
1626 /*                 a relationship between parties                 */
1627 /*                                                                */
1628 /* p_api_version                Standard IN param                 */
1629 /* p_commit                     Standard IN param                 */
1630 /* p_init_msg_list              Standard IN param                 */
1631 /* p_validation_level           Standard IN param                 */
1632 /* p_party_rel_rec              Party relationship to create      */
1633 /* x_party_rel_id               Relationship ID generated         */
1634 /* x_return_status              Standard OUT param                */
1635 /* x_msg_count                  Standard OUT param                */
1636 /* x_msg_data                   Standard OUT param                */
1637 /*                                                                */
1638 /*----------------------------------------------------------------*/
1639 PROCEDURE Create_Relationship
1640 (  p_api_version        IN  NUMBER,
1641    p_commit             IN  VARCHAR2  := fnd_api.g_false,
1642    p_init_msg_list      IN  VARCHAR2  := fnd_api.g_false,
1643    p_validation_level   IN  NUMBER    := fnd_api.g_valid_level_full,
1647    x_msg_count          OUT NOCOPY NUMBER,
1644    p_party_rel_rec      IN  HZ_RELATIONSHIP_V2PUB.relationship_rec_type,
1645    x_party_rel_id       OUT NOCOPY NUMBER,
1646    x_return_status      OUT NOCOPY VARCHAR2,
1648    x_msg_data           OUT NOCOPY VARCHAR2 )
1649 IS
1650    l_api_name           CONSTANT VARCHAR2(30) := 'Create_Relationship';
1651    l_api_version        CONSTANT NUMBER := 1.0;
1652    l_party_id           NUMBER;
1653    l_party_number       VARCHAR2(30);
1654 BEGIN
1655 
1656     -- Standard Start of API savepoint
1657     SAVEPOINT Create_Relationship_Pvt;
1658 
1659     -- Standard call to check for call compatibility.
1660     IF NOT FND_API.Compatible_API_Call (l_api_version,
1661                                         p_api_version,
1662                                         l_api_name,
1663                                         G_PKG_NAME)
1664     THEN
1665         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1666     END IF;
1667 
1668     -- Initialize message list if p_init_msg_list is set to TRUE.
1669     IF FND_API.to_Boolean(p_init_msg_list) THEN
1670         FND_MSG_PUB.initialize;
1671     END IF;
1672 
1673     -- Initialize API return status to success
1674     x_return_status := FND_API.G_RET_STS_SUCCESS;
1675 
1676     --
1677     -- Begin API Body
1678     --
1679     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
1680                                         p_api_name  => l_api_name );
1681 
1682     IF l_debug > 5 THEN
1683           csd_gen_utility_pvt.dump_hz_party_rel_rec
1684                    ( p_party_rel_rec => p_party_rel_rec);
1685     END IF;
1686 
1687 
1688     HZ_RELATIONSHIP_V2PUB.Create_Relationship(
1689         p_init_msg_list          => FND_API.G_FALSE,
1690         p_relationship_rec          => p_party_rel_rec,
1691         -- p_create_party           => 'N',
1692         -- p_create_org_contact     => 'Y'
1693         x_relationship_id        => x_party_rel_id,
1694         x_party_id               => l_party_id,
1695         x_party_number           => l_party_number,
1696         x_return_status          => x_return_status,
1697         x_msg_count              => x_msg_count,
1698         x_msg_data               => x_msg_data
1699         );
1700 
1701     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1702         csd_gen_utility_pvt.ADD('Create_Party_Relationship failed ');
1703         RAISE FND_API.G_EXC_ERROR;
1704     END IF;
1705 
1706     --
1707     -- End API Body
1708     --
1709 
1710     -- Standard check of p_commit.
1711     IF FND_API.To_Boolean( p_commit ) THEN
1712        COMMIT WORK;
1713     END IF;
1714 
1715     -- Standard call to get message count and IF count is  get message info.
1716     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1717                                p_data   =>  x_msg_data );
1718 EXCEPTION
1719     WHEN FND_API.G_EXC_ERROR THEN
1720           ROLLBACK TO Create_Relationship_Pvt;
1721           x_return_status := FND_API.G_RET_STS_ERROR ;
1722           FND_MSG_PUB.Count_And_Get
1723                 (p_count  =>  x_msg_count,
1724                  p_data   =>  x_msg_data
1725                 );
1726     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1727           ROLLBACK TO Create_Relationship_Pvt;
1728           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1729           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1730                                      p_data   =>  x_msg_data );
1731     WHEN OTHERS THEN
1732           ROLLBACK TO Create_Relationship_Pvt;
1733           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1734           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1735           THEN
1736               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
1737                                        l_api_name  );
1738           END IF;
1739           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1740                                      p_data   =>  x_msg_data );
1741 END Create_Relationship;
1742 
1743 
1744 /*----------------------------------------------------------------*/
1745 /* procedure name: Update_Party                                   */
1746 /* description   : procedure used to update                       */
1747 /*                 a  party in TCA                                */
1748 /*                                                                */
1749 /* p_api_version                Standard IN param                 */
1750 /* p_commit                     Standard IN param                 */
1751 /* p_init_msg_list              Standard IN param                 */
1752 /* p_validation_level           Standard IN param                 */
1753 /* p_person_rec                 Person Information                */
1754 /* p_org_rec                    Organization Info                 */
1755 /* p_party_type                 'PERSON' or 'ORGANIZATION'        */
1756 /* p_obj_ver_num                Last version for party            */
1757 /* x_obj_ver_num                New Last version for party        */
1758 /* x_return_status              Standard OUT param                */
1759 /* x_msg_count                  Standard OUT param                */
1760 /* x_msg_data                   Standard OUT param                */
1761 /*                                                                */
1762 /*----------------------------------------------------------------*/
1763 PROCEDURE Update_Party
1764 (  p_api_version          IN  NUMBER,
1768    p_person_rec           IN  HZ_PARTY_V2PUB.person_rec_type,
1765    p_commit               IN  VARCHAR2  := fnd_api.g_false,
1766    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
1767    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
1769    p_org_rec              IN  HZ_PARTY_V2PUB.organization_rec_type,
1770    p_party_type           IN  VARCHAR2,
1771    p_obj_ver_num          IN  NUMBER,
1772    x_obj_ver_num          OUT NOCOPY NUMBER,
1773    x_return_status        OUT NOCOPY VARCHAR2,
1774    x_msg_count            OUT NOCOPY NUMBER,
1775    x_msg_data             OUT NOCOPY VARCHAR2 )
1776 IS
1777    l_api_name             CONSTANT VARCHAR2(30) := 'Update_Party';
1778    l_api_version          CONSTANT NUMBER := 1.0;
1779 BEGIN
1780 
1781     -- Standard Start of API savepoint
1782     SAVEPOINT Update_Party_Pvt;
1783 
1784     -- Standard call to check for call compatibility.
1785     IF NOT FND_API.Compatible_API_Call (l_api_version,
1786                                         p_api_version,
1787                                         l_api_name,
1788                                         G_PKG_NAME)
1789     THEN
1790         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1791     END IF;
1792 
1793     -- Initialize message list if p_init_msg_list is set to TRUE.
1794     IF FND_API.to_Boolean(p_init_msg_list) THEN
1795         FND_MSG_PUB.initialize;
1796     END IF;
1797 
1798     -- Initialize API return status to success
1799     x_return_status := FND_API.G_RET_STS_SUCCESS;
1800 
1801     --
1802     -- Begin API Body
1803     --
1804     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
1805                                         p_api_name  => l_api_name );
1806     IF l_debug > 5 THEN
1807           csd_gen_utility_pvt.dump_hz_org_rec
1808                    ( p_org_rec => p_org_rec);
1809           csd_gen_utility_pvt.dump_hz_person_rec
1810                    ( p_person_rec => p_person_rec);
1811     END IF;
1812 
1813     IF (p_party_type = 'PERSON') THEN
1814         Update_Person( p_api_version      => 1.0,
1815                        p_commit           => FND_API.G_FALSE,
1816                        p_init_msg_list    => FND_API.G_FALSE,
1817                        p_validation_level => p_validation_level,
1818                        p_person_rec       => p_person_rec,
1819                        p_obj_ver_num      => p_obj_ver_num,
1820                        x_obj_ver_num      => x_obj_ver_num,
1821                        x_return_status    => x_return_status,
1822                        x_msg_count        => x_msg_count,
1823                        x_msg_data         => x_msg_data
1824                      );
1825         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1826             csd_gen_utility_pvt.ADD('Update_Person failed ');
1827             RAISE FND_API.G_EXC_ERROR;
1828         END IF;
1829 
1830     ELSIF (p_party_type = 'ORGANIZATION') THEN
1831         Update_Organization( p_api_version      => 1.0,
1832                              p_commit           => FND_API.G_FALSE,
1833                              p_init_msg_list    => FND_API.G_FALSE,
1834                              p_validation_level => p_validation_level,
1835                              p_org_rec          => p_org_rec,
1836                              p_obj_ver_num      => p_obj_ver_num,
1837                              x_obj_ver_num      => x_obj_ver_num,
1838                              x_return_status    => x_return_status,
1839                              x_msg_count        => x_msg_count,
1840                              x_msg_data         => x_msg_data
1841                            );
1842         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1843             csd_gen_utility_pvt.ADD('Update_Organization failed ');
1844             RAISE FND_API.G_EXC_ERROR;
1845         END IF;
1846     END IF;
1847 
1848     --
1849     -- End API Body
1850     --
1851 
1852     -- Standard check of p_commit.
1853     IF FND_API.To_Boolean( p_commit ) THEN
1854        COMMIT WORK;
1855     END IF;
1856 
1857     -- Standard call to get message count and IF count is  get message info.
1858     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1859                                p_data   =>  x_msg_data );
1860 EXCEPTION
1861     WHEN FND_API.G_EXC_ERROR THEN
1862           ROLLBACK TO Update_Party_Pvt;
1863           x_return_status := FND_API.G_RET_STS_ERROR ;
1864           FND_MSG_PUB.Count_And_Get
1865                 (p_count  =>  x_msg_count,
1866                  p_data   =>  x_msg_data
1867                 );
1868     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1869           ROLLBACK TO Update_Party_Pvt;
1870           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1871           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1872                                      p_data   =>  x_msg_data );
1873     WHEN OTHERS THEN
1874           ROLLBACK TO Update_Party_Pvt;
1875           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1876           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1877           THEN
1878               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
1879                                        l_api_name  );
1880           END IF;
1881           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1882                                      p_data   =>  x_msg_data );
1883 END Update_Party;
1884 
1885 /*----------------------------------------------------------------*/
1889 /*                                                                */
1886 /* procedure name: Update_Person                                  */
1887 /* description   : procedure used to update                       */
1888 /*                 a person in TCA                                */
1890 /* p_api_version                Standard IN param                 */
1891 /* p_commit                     Standard IN param                 */
1892 /* p_init_msg_list              Standard IN param                 */
1893 /* p_validation_level           Standard IN param                 */
1894 /* p_person_rec                 Person Information                */
1895 /* p_obj_ver_num                Last version for person           */
1896 /* x_obj_ver_num                New Last version for person       */
1897 /* x_return_status              Standard OUT param                */
1898 /* x_msg_count                  Standard OUT param                */
1899 /* x_msg_data                   Standard OUT param                */
1900 /*                                                                */
1901 /*----------------------------------------------------------------*/
1902 PROCEDURE Update_Person
1903 (  p_api_version          IN  NUMBER,
1904    p_commit               IN  VARCHAR2  := fnd_api.g_false,
1905    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
1906    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
1907    p_person_rec           IN  HZ_PARTY_V2PUB.person_rec_type,
1908    p_obj_ver_num          IN  NUMBER,
1909    x_obj_ver_num          OUT NOCOPY NUMBER,
1910    x_return_status        OUT NOCOPY VARCHAR2,
1911    x_msg_count            OUT NOCOPY NUMBER,
1912    x_msg_data             OUT NOCOPY VARCHAR2 )
1913 IS
1914    l_api_name            CONSTANT VARCHAR2(30) := 'Create_Relationship';
1915    l_api_version         CONSTANT NUMBER := 1.0;
1916    l_profile_id                   NUMBER;
1917 BEGIN
1918 
1919     -- Standard Start of API savepoint
1920     SAVEPOINT Update_Person_Pvt;
1921 
1922     -- Standard call to check for call compatibility.
1923     IF NOT FND_API.Compatible_API_Call (l_api_version,
1924                                         p_api_version,
1925                                         l_api_name,
1926                                         G_PKG_NAME)
1927     THEN
1928         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1929     END IF;
1930 
1931     -- Initialize message list if p_init_msg_list is set to TRUE.
1932     IF FND_API.to_Boolean(p_init_msg_list) THEN
1933         FND_MSG_PUB.initialize;
1934     END IF;
1935 
1936     -- Initialize API return status to success
1937     x_return_status := FND_API.G_RET_STS_SUCCESS;
1938 
1939     --
1940     -- Begin API Body
1941     --
1942     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
1943                                         p_api_name  => l_api_name );
1944     IF l_debug > 5 THEN
1945           csd_gen_utility_pvt.dump_hz_person_rec
1946                    ( p_person_rec => p_person_rec);
1947     END IF;
1948 
1949     x_obj_ver_num := p_obj_ver_num;
1950     HZ_PARTY_V2PUB.Update_Person(
1951                     p_init_msg_list                 => FND_API.G_FALSE,
1952                     p_person_rec                    => p_person_rec,
1953                     p_party_object_version_number   => x_obj_ver_num,
1954                     x_profile_id                    => l_profile_id,
1955                     x_return_status                 => x_return_status,
1956                     x_msg_count                     => x_msg_count,
1957                     x_msg_data                      => x_msg_data
1958                     );
1959     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
1960         csd_gen_utility_pvt.ADD('Update_Person failed ');
1961         RAISE FND_API.G_EXC_ERROR;
1962     END IF;
1963 
1964     --
1965     -- End API Body
1966     --
1967 
1968     -- Standard check of p_commit.
1969     IF FND_API.To_Boolean( p_commit ) THEN
1970        COMMIT WORK;
1971     END IF;
1972 
1973     -- Standard call to get message count and IF count is  get message info.
1974     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1975                                p_data   =>  x_msg_data );
1976 EXCEPTION
1977     WHEN FND_API.G_EXC_ERROR THEN
1978           ROLLBACK TO Update_Person_Pvt;
1979           x_return_status := FND_API.G_RET_STS_ERROR ;
1980           FND_MSG_PUB.Count_And_Get
1981                 (p_count  =>  x_msg_count,
1982                  p_data   =>  x_msg_data
1983                 );
1984     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1985           ROLLBACK TO Update_Person_Pvt;
1986           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1987           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1988                                      p_data   =>  x_msg_data );
1989     WHEN OTHERS THEN
1990           ROLLBACK TO Update_Person_Pvt;
1991           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1992           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1993           THEN
1994               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
1995                                        l_api_name  );
1996           END IF;
1997           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
1998                                      p_data   =>  x_msg_data );
1999 
2000 END Update_Person;
2001 
2002 
2003 /*----------------------------------------------------------------*/
2007 /*                                                                */
2004 /* procedure name: Update_Organization                            */
2005 /* description   : procedure used to update                       */
2006 /*                 an organization in TCA                         */
2008 /* p_api_version                Standard IN param                 */
2009 /* p_commit                     Standard IN param                 */
2010 /* p_init_msg_list              Standard IN param                 */
2011 /* p_validation_level           Standard IN param                 */
2012 /* p_org_rec                    Organization Info                 */
2013 /* p_obj_ver_num                Last version num for org          */
2014 /* x_obj_ver_num                New Last version num for org      */
2015 /* x_return_status              Standard OUT param                */
2016 /* x_msg_count                  Standard OUT param                */
2017 /* x_msg_data                   Standard OUT param                */
2018 /*                                                                */
2019 /*----------------------------------------------------------------*/
2020 PROCEDURE Update_Organization
2021 (  p_api_version          IN  NUMBER,
2022    p_commit               IN  VARCHAR2  := fnd_api.g_false,
2023    p_init_msg_list        IN  VARCHAR2  := fnd_api.g_false,
2024    p_validation_level     IN  NUMBER    := fnd_api.g_valid_level_full,
2025    p_org_rec              IN  HZ_PARTY_V2PUB.organization_rec_type,
2026    p_obj_ver_num          IN  NUMBER,
2027    x_obj_ver_num          OUT NOCOPY NUMBER,
2028    x_return_status        OUT NOCOPY VARCHAR2,
2029    x_msg_count            OUT NOCOPY NUMBER,
2030    x_msg_data             OUT NOCOPY VARCHAR2 )
2031 IS
2032    l_api_name             CONSTANT VARCHAR2(30) := 'Create_Relationship';
2033    l_api_version          CONSTANT NUMBER := 1.0;
2034    l_profile_id                   NUMBER;
2035 BEGIN
2036 
2037     -- Standard Start of API savepoint
2038     SAVEPOINT Update_Organization_Pvt;
2039 
2040     -- Standard call to check for call compatibility.
2041     IF NOT FND_API.Compatible_API_Call (l_api_version,
2042                                         p_api_version,
2043                                         l_api_name,
2044                                         G_PKG_NAME)
2045     THEN
2046         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2047     END IF;
2048 
2049     -- Initialize message list if p_init_msg_list is set to TRUE.
2050     IF FND_API.to_Boolean(p_init_msg_list) THEN
2051         FND_MSG_PUB.initialize;
2052     END IF;
2053 
2054     -- Initialize API return status to success
2055     x_return_status := FND_API.G_RET_STS_SUCCESS;
2056 
2057     --
2058     -- Begin API Body
2059     --
2060     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
2061                                         p_api_name  => l_api_name );
2062     IF l_debug > 5 THEN
2063           csd_gen_utility_pvt.dump_hz_org_rec
2064                    ( p_org_rec => p_org_rec);
2065     END IF;
2066 
2067     x_obj_ver_num:= p_obj_ver_num;
2068     HZ_PARTY_V2PUB.Update_Organization(
2069                     p_init_msg_list                 => FND_API.G_FALSE,
2070                     p_organization_rec              => p_org_rec,
2071                     p_party_object_version_number   => x_obj_ver_num,
2072                     x_return_status                 => x_return_status,
2073                     x_msg_count                     => x_msg_count,
2074                     x_msg_data                      => x_msg_data,
2075                     x_profile_id                    => l_profile_id
2076                     );
2077     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2078         csd_gen_utility_pvt.ADD('Update_Organization failed ');
2079         RAISE FND_API.G_EXC_ERROR;
2080     END IF;
2081 
2082     --
2083     -- End API Body
2084     --
2085 
2086     -- Standard check of p_commit.
2087     IF FND_API.To_Boolean( p_commit ) THEN
2088        COMMIT WORK;
2089     END IF;
2090 
2091     -- Standard call to get message count and IF count is  get message info.
2092     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2093                                p_data   =>  x_msg_data );
2094 EXCEPTION
2095     WHEN FND_API.G_EXC_ERROR THEN
2096           ROLLBACK TO Update_Organization_Pvt;
2097             x_return_status := FND_API.G_RET_STS_ERROR ;
2098             FND_MSG_PUB.Count_And_Get
2099                 (p_count  =>  x_msg_count,
2100                  p_data   =>  x_msg_data
2101                 );
2102     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2103           ROLLBACK TO Update_Organization_Pvt;
2104           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2105           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2106                                      p_data   =>  x_msg_data );
2107     WHEN OTHERS THEN
2108           ROLLBACK TO Update_Organization_Pvt;
2109           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2110           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2111           THEN
2112               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
2113                                        l_api_name  );
2114           END IF;
2115           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2116                                      p_data   =>  x_msg_data );
2117 
2118 END Update_Organization;
2119 
2120 
2124 /*                 an account for a party                         */
2121 /*----------------------------------------------------------------*/
2122 /* procedure name: Update_Account                                 */
2123 /* description   : procedure used to update                       */
2125 /*                                                                */
2126 /* p_api_version                Standard IN param                 */
2127 /* p_commit                     Standard IN param                 */
2128 /* p_init_msg_list              Standard IN param                 */
2129 /* p_validation_level           Standard IN param                 */
2130 /* p_cust_acct_rec              Account Info                      */
2131 /* p_obj_ver_num                Last version num for account      */
2132 /* x_obj_ver_num                New Last version num for account  */
2133 /* x_return_status              Standard OUT param                */
2134 /* x_msg_count                  Standard OUT param                */
2135 /* x_msg_data                   Standard OUT param                */
2136 /*                                                                */
2137 /*----------------------------------------------------------------*/
2138 PROCEDURE Update_Account
2139 (  p_api_version        IN  NUMBER,
2140    p_commit             IN  VARCHAR2  := fnd_api.g_false,
2141    p_init_msg_list      IN  VARCHAR2  := fnd_api.g_false,
2142    p_validation_level   IN  NUMBER    := fnd_api.g_valid_level_full,
2143    p_cust_acct_rec      IN  HZ_CUST_ACCOUNT_V2PUB.cust_account_rec_type,
2144    p_obj_ver_num        IN  NUMBER,
2145    x_obj_ver_num        OUT NOCOPY NUMBER,
2146    x_return_status      OUT NOCOPY VARCHAR2,
2147    x_msg_count          OUT NOCOPY NUMBER,
2148    x_msg_data           OUT NOCOPY VARCHAR2 )
2149 IS
2150    l_api_name           CONSTANT VARCHAR2(30) := 'Update_Account';
2151    l_api_version        CONSTANT NUMBER := 1.0;
2152 BEGIN
2153 
2154     -- Standard Start of API savepoint
2155     SAVEPOINT Update_Account_Pvt;
2156 
2157     -- Standard call to check for call compatibility.
2158     IF NOT FND_API.Compatible_API_Call (l_api_version,
2159                                         p_api_version,
2160                                         l_api_name,
2161                                         G_PKG_NAME)
2162     THEN
2163         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2164     END IF;
2165 
2166     -- Initialize message list if p_init_msg_list is set to TRUE.
2167     IF FND_API.to_Boolean(p_init_msg_list) THEN
2168         FND_MSG_PUB.initialize;
2169     END IF;
2170 
2171     -- Initialize API return status to success
2172     x_return_status := FND_API.G_RET_STS_SUCCESS;
2173 
2174     --
2175     -- Begin API Body
2176     --
2177     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
2178                                         p_api_name  => l_api_name );
2179 
2180     x_obj_ver_num:= p_obj_ver_num;
2181     HZ_CUST_ACCOUNT_V2PUB.Update_Cust_Account(
2182                           p_init_msg_list          =>  FND_API.G_FALSE,
2183                           p_cust_account_rec       =>  p_cust_acct_rec,
2184                           p_object_version_number  =>  x_obj_ver_num,
2185                           x_return_status          =>  x_return_status,
2186                           x_msg_count              =>  x_msg_count,
2187                           x_msg_data               =>  x_msg_data
2188                           );
2189 
2190     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2191         csd_gen_utility_pvt.ADD('Update_Account failed ');
2192         RAISE FND_API.G_EXC_ERROR;
2193     END IF;
2194 
2195     --
2196     -- End API Body
2197     --
2198 
2199     -- Standard check of p_commit.
2200     IF FND_API.To_Boolean( p_commit ) THEN
2201        COMMIT WORK;
2202     END IF;
2203 
2204     -- Standard call to get message count and IF count is  get message info.
2205     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2206                                p_data   =>  x_msg_data );
2207 EXCEPTION
2208     WHEN FND_API.G_EXC_ERROR THEN
2209           ROLLBACK TO Update_Account_Pvt;
2210           x_return_status := FND_API.G_RET_STS_ERROR ;
2211           FND_MSG_PUB.Count_And_Get
2212                 (p_count  =>  x_msg_count,
2213                  p_data   =>  x_msg_data
2214                 );
2215     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2216           ROLLBACK TO Update_Account_Pvt;
2217           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2218           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2219                                      p_data   =>  x_msg_data );
2220     WHEN OTHERS THEN
2221           ROLLBACK TO Update_Account_Pvt;
2222           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2223           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2224           THEN
2225               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
2226                                        l_api_name  );
2227           END IF;
2228           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2229                                      p_data   =>  x_msg_data );
2230 END Update_Account;
2231 
2232 /*----------------------------------------------------------------*/
2233 /* procedure name: Update_ContactPoints                           */
2234 /* description   : procedure used to update                       */
2235 /*                 contact points for a party                     */
2239 /* p_init_msg_list              Standard IN param                 */
2236 /*                                                                */
2237 /* p_api_version                Standard IN param                 */
2238 /* p_commit                     Standard IN param                 */
2240 /* p_validation_level           Standard IN param                 */
2241 /* p_phone_rec                  Phone Info                        */
2242 /* p_email_rec                  Email Info                        */
2243 /* p_web_rec                    Web Info                          */
2244 /* p_phone_cnt_point_id         ID of phone contact point         */
2245 /* p_email_cnt_point_id         ID of email contact point         */
2246 /* p_url_cnt_point_id           ID of url contact point           */
2247 /* p_phone_obj_ver_num          Last version num for phone        */
2248 /* p_email_obj_ver_num          Last version num for email        */
2249 /* p_url_obj_ver_num            Last version num for url          */
2250 /* p_update_phone_flag          'Y' to update phone contact point */
2251 /* p_update_email_flag          'Y' to update email contact point */
2252 /* p_update_url_flag            'Y' to update url contact point   */
2253 /* x_phone_obj_ver_num          New Last version num for phone    */
2254 /* x_email_obj_ver_num          New Last version num for email    */
2255 /* x_url_obj_ver_num            New Last version num for url      */
2256 /* x_return_status              Standard OUT param                */
2257 /* x_msg_count                  Standard OUT param                */
2258 /* x_msg_data                   Standard OUT param                */
2259 /*                                                                */
2260 /*----------------------------------------------------------------*/
2261 PROCEDURE Update_ContactPoints
2262 (
2263    p_api_version            IN  NUMBER,
2264    p_commit                 IN  VARCHAR2  := fnd_api.g_false,
2265    p_init_msg_list          IN  VARCHAR2  := fnd_api.g_false,
2266    p_validation_level       IN  NUMBER    := fnd_api.g_valid_level_full,
2267    p_phone_rec              IN  HZ_CONTACT_POINT_V2PUB.phone_rec_type,
2268    p_email_rec              IN  HZ_CONTACT_POINT_V2PUB.email_rec_type,
2269    p_web_rec                IN  HZ_CONTACT_POINT_V2PUB.web_rec_type,
2270    p_phone_cnt_point_id     IN  NUMBER,
2271    p_email_cnt_point_id     IN  NUMBER,
2272    p_url_cnt_point_id       IN  NUMBER,
2273    p_phone_obj_ver_num      IN  NUMBER,
2274    p_email_obj_ver_num      IN  NUMBER,
2275    p_url_obj_ver_num        IN  NUMBER,
2276    p_update_phone_flag      IN  VARCHAR2,
2277    p_update_email_flag      IN  VARCHAR2,
2278    p_update_url_flag        IN  VARCHAR2,
2279    x_phone_obj_ver_num      OUT NOCOPY NUMBER,
2280    x_email_obj_ver_num      OUT NOCOPY NUMBER,
2281    x_url_obj_ver_num        OUT NOCOPY NUMBER,
2282    x_return_status          OUT NOCOPY VARCHAR2,
2283    x_msg_count              OUT NOCOPY NUMBER,
2284    x_msg_data               OUT NOCOPY VARCHAR2 )
2285 IS
2286    l_api_name               CONSTANT VARCHAR2(30) := 'Update_ContactPoints';
2287    l_api_version            CONSTANT NUMBER := 1.0;
2288 
2289    -- the following are default records: --
2290    l_phone_update_rec       HZ_CONTACT_POINT_V2PUB.phone_rec_type
2291                                := CSD_PROCESS_PVT.get_phone_rec_type;
2292    l_email_update_rec       HZ_CONTACT_POINT_V2PUB.email_rec_type
2293                                := CSD_PROCESS_PVT.get_email_rec_type;
2294    l_web_update_rec         HZ_CONTACT_POINT_V2PUB.web_rec_type
2295                                := CSD_PROCESS_PVT.get_web_rec_type;
2296    l_edi_update_rec         HZ_CONTACT_POINT_V2PUB.edi_rec_type
2297                                := CSD_PROCESS_PVT.get_edi_rec_type;
2298    l_telex_update_rec       HZ_CONTACT_POINT_V2PUB.telex_rec_type
2299                                := CSD_PROCESS_PVT.get_telex_rec_type;
2300    l_contpt_update_rec      HZ_CONTACT_POINT_V2PUB.contact_point_rec_type
2301                                := CSD_PROCESS_PVT.get_contact_points_rec_type;
2302 BEGIN
2303 
2304     -- Standard Start of API savepoint
2305     SAVEPOINT Update_ContactPoints_Pvt;
2306 
2307     -- Standard call to check for call compatibility.
2308     IF NOT FND_API.Compatible_API_Call (l_api_version,
2309                                         p_api_version,
2310                                         l_api_name,
2311                                         G_PKG_NAME)
2312     THEN
2313         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2314     END IF;
2315 
2316     -- Initialize message list if p_init_msg_list is set to TRUE.
2317     IF FND_API.to_Boolean(p_init_msg_list) THEN
2318         FND_MSG_PUB.initialize;
2319     END IF;
2320 
2321     -- Initialize API return status to success
2322     x_return_status := FND_API.G_RET_STS_SUCCESS;
2323 
2324     --
2325     -- Begin API Body
2326     --
2327     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
2328                                         p_api_name  => l_api_name );
2329     IF l_debug > 5 THEN
2330           csd_gen_utility_pvt.dump_hz_phone_rec
2331                    ( p_phone_rec => p_phone_rec);
2332           csd_gen_utility_pvt.dump_hz_email_rec
2333                    ( p_email_rec => p_email_rec);
2334           csd_gen_utility_pvt.dump_hz_web_rec
2335                    ( p_web_rec => p_web_rec);
2336     END IF;
2337 
2338     x_phone_obj_ver_num:= p_phone_obj_ver_num;
2339     IF (p_update_phone_flag = 'Y') THEN
2340         l_contpt_update_rec.contact_point_type := 'PHONE';
2344         HZ_CONTACT_POINT_V2PUB.Update_contact_point(
2341         l_contpt_update_rec.owner_table_name   := 'HZ_PARTIES';
2342         l_contpt_update_rec.contact_point_id   := p_phone_cnt_point_id;
2343 
2345                           p_init_msg_list      => FND_API.G_FALSE,
2346                           p_contact_point_rec  => l_contpt_update_rec,
2347                           p_edi_rec            => l_edi_update_rec,
2348                           p_email_rec          => l_email_update_rec,
2349                           p_phone_rec          => p_phone_rec,
2350                           p_telex_rec          => l_telex_update_rec,
2351                           p_web_rec            => l_web_update_rec,
2352                           p_object_version_number => x_phone_obj_ver_num,
2353                           x_return_status      => x_return_status,
2354                           x_msg_count          => x_msg_count,
2355                           x_msg_data           => x_msg_data
2356                           );
2357 
2358         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2359             csd_gen_utility_pvt.ADD('Update_contact_points phone failed ');
2360             RAISE FND_API.G_EXC_ERROR;
2361         END IF;
2362     END IF;
2363 
2364     x_email_obj_ver_num := p_email_obj_ver_num;
2365     IF (p_update_email_flag = 'Y') THEN
2366         l_contpt_update_rec.contact_point_type := 'EMAIL';
2367         l_contpt_update_rec.owner_table_name   := 'HZ_PARTIES';
2368         l_contpt_update_rec.contact_point_id   := p_email_cnt_point_id;
2369 
2370         HZ_CONTACT_POINT_V2PUB.Update_contact_point(
2371                                 p_init_msg_list      => FND_API.G_FALSE,
2372                                 x_return_status      => x_return_status,
2373                                 x_msg_count          => x_msg_count,
2374                                 x_msg_data           => x_msg_data,
2375                                 p_contact_point_rec  => l_contpt_update_rec,
2376                                 p_edi_rec            => l_edi_update_rec,
2377                                 p_phone_rec          => l_phone_update_rec,
2378                                 p_email_rec          => p_email_rec,
2379                                 p_telex_rec          => l_telex_update_rec,
2380                                 p_web_rec            => l_web_update_rec,
2381                                 p_object_version_number => x_email_obj_ver_num
2382                                 );
2383 
2384         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2385             csd_gen_utility_pvt.ADD('Update_contact_points email failed ');
2386             RAISE FND_API.G_EXC_ERROR;
2387         END IF;
2388     END IF;
2389 
2390     x_url_obj_ver_num := p_url_obj_ver_num;
2391     IF (p_update_url_flag = 'Y') THEN
2392         l_contpt_update_rec.contact_point_type := 'WEB';
2393         l_contpt_update_rec.owner_table_name   := 'HZ_PARTIES';
2394         l_contpt_update_rec.contact_point_id   := p_url_cnt_point_id;
2395 
2396 
2397         HZ_CONTACT_POINT_V2PUB.Update_contact_point(
2398                                 p_init_msg_list      => FND_API.G_FALSE,
2399                                 x_return_status      => x_return_status,
2400                                 x_msg_count          => x_msg_count,
2401                                 x_msg_data           => x_msg_data,
2402                                 p_contact_point_rec  => l_contpt_update_rec,
2403                                 p_edi_rec            => l_edi_update_rec,
2404                                 p_phone_rec          => l_phone_update_rec,
2405                                 p_email_rec          => l_email_update_rec,
2406                                 p_telex_rec          => l_telex_update_rec,
2407                                 p_web_rec            => p_web_rec,
2408                                 p_object_version_number => x_url_obj_ver_num
2409                                 );
2410         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2411             csd_gen_utility_pvt.ADD('Update_contact_points url failed ');
2412             RAISE FND_API.G_EXC_ERROR;
2413         END IF;
2414     END IF;
2415 
2416     --
2417     -- End API Body
2418     --
2419 
2420     -- Standard check of p_commit.
2421     IF FND_API.To_Boolean( p_commit ) THEN
2422        COMMIT WORK;
2423     END IF;
2424 
2425     -- Standard call to get message count and IF count is  get message info.
2426     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2427                                p_data   =>  x_msg_data );
2428 EXCEPTION
2429     WHEN FND_API.G_EXC_ERROR THEN
2430           ROLLBACK TO Update_ContactPoints_Pvt;
2431           x_return_status := FND_API.G_RET_STS_ERROR ;
2432           x_phone_obj_ver_num := p_phone_obj_ver_num;
2433           x_email_obj_ver_num := p_email_obj_ver_num;
2434           x_url_obj_ver_num   := p_url_obj_ver_num;
2435           FND_MSG_PUB.Count_And_Get
2436                 (p_count  =>  x_msg_count,
2437                  p_data   =>  x_msg_data
2438                 );
2439     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2440           ROLLBACK TO Update_ContactPoints_Pvt;
2441           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2442           x_phone_obj_ver_num := p_phone_obj_ver_num;
2443           x_email_obj_ver_num := p_email_obj_ver_num;
2444           x_url_obj_ver_num   := p_url_obj_ver_num;
2445           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2446                                      p_data   =>  x_msg_data );
2447     WHEN OTHERS THEN
2448           ROLLBACK TO Update_ContactPoints_Pvt;
2452           x_url_obj_ver_num   := p_url_obj_ver_num;
2449           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2450           x_phone_obj_ver_num := p_phone_obj_ver_num;
2451           x_email_obj_ver_num := p_email_obj_ver_num;
2453           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2454           THEN
2455               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
2456                                        l_api_name  );
2457           END IF;
2458           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2459                                      p_data   =>  x_msg_data );
2460 END Update_ContactPoints;
2461 
2462 /*----------------------------------------------------------------*/
2463 /* procedure name: Update_AddressRecords                          */
2464 /* description   : procedure used to update                       */
2465 /*                 an address record in TCA                       */
2466 /*                                                                */
2467 /* p_api_version                Standard IN param                 */
2468 /* p_commit                     Standard IN param                 */
2469 /* p_init_msg_list              Standard IN param                 */
2470 /* p_validation_level           Standard IN param                 */
2471 /* p_location_id                Location ID, if it already exists */
2472 /* p_loc_rec                    Location                          */
2473 /* p_addr_obj_ver_num           Last version of the location      */
2474 /* p_site_obj_ver_num           Last version of the site          */
2475 /* x_party_site_rec             Site                              */
2476 /* x_addr_obj_ver_num           New Last version of the location  */
2477 /* x_site_obj_ver_num           New Last version of the site      */
2478 /* x_return_status              Standard OUT param                */
2479 /* x_msg_count                  Standard OUT param                */
2480 /* x_msg_data                   Standard OUT param                */
2481 /*                                                                */
2482 /*----------------------------------------------------------------*/
2483 PROCEDURE Update_AddressRecords
2484 (
2485    p_api_version           IN  NUMBER,
2486    p_commit                IN  VARCHAR2 := fnd_api.g_false,
2487    p_init_msg_list         IN  VARCHAR2 := fnd_api.g_false,
2488    p_validation_level      IN  NUMBER   := fnd_api.g_valid_level_full,
2489    p_location_id           IN  NUMBER := null,
2490    p_loc_rec               IN  CSD_PROCESS_PVT.address_rec_type,
2491    p_addr_obj_ver_num      IN  NUMBER,
2492    p_site_obj_ver_num      IN  NUMBER,
2493    x_party_site_rec        IN OUT NOCOPY HZ_PARTY_SITE_V2PUB.party_site_rec_type,
2494    x_addr_obj_ver_num      OUT NOCOPY NUMBER,
2495    x_site_obj_ver_num      OUT NOCOPY NUMBER,
2496    x_return_status         OUT NOCOPY VARCHAR2,
2497    x_msg_count             OUT NOCOPY NUMBER,
2498    x_msg_data              OUT NOCOPY VARCHAR2 )
2499 IS
2500    l_api_name              CONSTANT VARCHAR2(30) := 'Update_AddressRecords';
2501    l_api_version           CONSTANT NUMBER := 1.0;
2502 BEGIN
2503 
2504     -- Standard Start of API savepoint
2505     SAVEPOINT Update_AddressRecords_Pvt;
2506 
2507     -- Standard call to check for call compatibility.
2508     IF NOT FND_API.Compatible_API_Call (l_api_version,
2509                                         p_api_version,
2510                                         l_api_name,
2511                                         G_PKG_NAME)
2512     THEN
2513         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2514     END IF;
2515 
2516     -- Initialize message list if p_init_msg_list is set to TRUE.
2517     IF FND_API.to_Boolean(p_init_msg_list) THEN
2518         FND_MSG_PUB.initialize;
2519     END IF;
2520 
2521     -- Initialize API return status to success
2522     x_return_status := FND_API.G_RET_STS_SUCCESS;
2523 
2524     --
2525     -- Begin API Body
2526     --
2527     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
2528                                         p_api_name  => l_api_name );
2529     IF l_debug > 5 THEN
2530           csd_gen_utility_pvt.dump_address_rec
2531                    ( p_addr_rec => p_loc_rec);
2532           csd_gen_utility_pvt.dump_hz_party_site_rec
2533                    ( p_party_site_rec => x_party_site_rec);
2534     END IF;
2535 
2536     IF (p_location_id is not null) THEN
2537         -- Update location
2538         Update_Address (  p_api_version      => 1.0,
2539                           p_commit           => FND_API.G_FALSE,
2540                           p_init_msg_list    => FND_API.G_FALSE,
2541                           p_validation_level => p_validation_level,
2542                           p_address_rec      => p_loc_rec,
2543 			              p_obj_ver_num      => p_addr_obj_ver_num,
2544 					      x_obj_ver_num      => x_addr_obj_ver_num,
2545                           x_return_status    => x_return_status,
2546                           x_msg_count        => x_msg_count,
2547                           x_msg_data         => x_msg_data);
2548         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2549             csd_gen_utility_pvt.ADD('Update_Address failed ');
2550             RAISE FND_API.G_EXC_ERROR;
2551         END IF;
2552 
2553 
2554         -- Update party sites to make this address as the identifying address.
2555         x_party_site_rec.location_id  := p_location_id;
2556         x_site_obj_ver_num := p_site_obj_ver_num;
2557         HZ_PARTY_SITE_V2PUB.Update_Party_Site (
2561                           x_return_status       => x_return_status,
2558                           p_init_msg_list       => FND_API.G_FALSE,
2559                           p_party_site_rec      => x_party_site_rec,
2560                           p_object_version_number => x_site_obj_ver_num,
2562                           x_msg_count           => x_msg_count,
2563                           x_msg_data            => x_msg_data
2564                           );
2565         IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2566             csd_gen_utility_pvt.ADD('Update_Party_Site failed ');
2567             RAISE FND_API.G_EXC_ERROR;
2568         END IF;
2569     END IF;
2570 
2571     --
2572     -- End API Body
2573     --
2574 
2575     -- Standard check of p_commit.
2576     IF FND_API.To_Boolean( p_commit ) THEN
2577        COMMIT WORK;
2578     END IF;
2579 
2580     -- Standard call to get message count and IF count is  get message info.
2581     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2582                                p_data   =>  x_msg_data );
2583 EXCEPTION
2584     WHEN FND_API.G_EXC_ERROR THEN
2585           ROLLBACK TO Update_AddressRecords_Pvt;
2586           x_return_status := FND_API.G_RET_STS_ERROR ;
2587           FND_MSG_PUB.Count_And_Get
2588                 (p_count  =>  x_msg_count,
2589                  p_data   =>  x_msg_data
2590                 );
2591     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2592           ROLLBACK TO Update_AddressRecords_Pvt;
2593           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2594           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2595                                      p_data   =>  x_msg_data );
2596     WHEN OTHERS THEN
2597           ROLLBACK TO Update_AddressRecords_Pvt;
2598           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2599           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2600           THEN
2601               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
2602                                        l_api_name  );
2603           END IF;
2604           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2605                                      p_data   =>  x_msg_data );
2606 END Update_AddressRecords;
2607 
2608 /*----------------------------------------------------------------*/
2609 /* procedure name: Update_Address                                 */
2610 /* description   : procedure used to update                       */
2611 /*                 a location in TCA                              */
2612 /*                                                                */
2613 /* p_api_version                Standard IN param                 */
2614 /* p_commit                     Standard IN param                 */
2615 /* p_init_msg_list              Standard IN param                 */
2616 /* p_validation_level           Standard IN param                 */
2617 /* p_address_rec                Location to create                */
2618 /* p_obj_ver_num                Last version of the location      */
2619 /*                              prior to calling this procedure   */
2620 /* x_obj_ver_num                Last version of the location      */
2621 /*                              after completing this procedure   */
2622 /* x_return_status              Standard OUT param                */
2623 /* x_msg_count                  Standard OUT param                */
2624 /* x_msg_data                   Standard OUT param                */
2625 /*                                                                */
2626 /*----------------------------------------------------------------*/
2627 PROCEDURE Update_Address
2628 (
2629    p_api_version      IN  NUMBER,
2630    p_commit           IN  VARCHAR2  := fnd_api.g_false,
2631    p_init_msg_list    IN  VARCHAR2  := fnd_api.g_false,
2632    p_validation_level IN  NUMBER   := fnd_api.g_valid_level_full,
2633    p_address_rec      IN  CSD_PROCESS_PVT.address_rec_type,
2634    p_obj_ver_num      IN  NUMBER,
2635    x_obj_ver_num      OUT NOCOPY NUMBER,
2636    x_return_status    OUT NOCOPY VARCHAR2,
2637    x_msg_count        OUT NOCOPY NUMBER,
2638    x_msg_data         OUT NOCOPY VARCHAR2)
2639 IS
2640    l_api_name         CONSTANT      VARCHAR2(30) := 'Update_Address';
2641    l_api_version      CONSTANT      NUMBER := 1.0;
2642    -- swai: change to TCA v2
2643    -- l_location_rec                   HZ_LOCATION_PUB.location_rec_type;
2644    l_location_rec        HZ_LOCATION_V2PUB.location_rec_type;
2645 BEGIN
2646 
2647     -- Standard Start of API savepoint
2648     SAVEPOINT Update_Address_Pvt;
2649 
2650     -- Standard call to check for call compatibility.
2651     IF NOT FND_API.Compatible_API_Call (l_api_version,
2652                                         p_api_version,
2653                                         l_api_name,
2654                                         G_PKG_NAME)
2655     THEN
2656         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2657     END IF;
2658 
2659     -- Initialize message list if p_init_msg_list is set to TRUE.
2660     IF FND_API.to_Boolean(p_init_msg_list) THEN
2661         FND_MSG_PUB.initialize;
2662     END IF;
2663 
2664     -- Initialize API return status to success
2665     x_return_status := FND_API.G_RET_STS_SUCCESS;
2666 
2667     --
2668     -- Begin API Body
2669     --
2670     csd_gen_utility_pvt.dump_api_info ( p_pkg_name  => G_PKG_NAME,
2671                                         p_api_name  => l_api_name );
2672     IF l_debug > 5 THEN
2676     l_location_rec.location_id := p_address_rec.location_id;
2673           csd_gen_utility_pvt.dump_address_rec
2674                    ( p_addr_rec => p_address_rec);
2675     END IF;
2677     l_location_rec.address1 := p_address_rec.address1;
2678     l_location_rec.address2 := p_address_rec.address2;
2679     l_location_rec.address3 := p_address_rec.address3;
2680     l_location_rec.address4 := p_address_rec.address4;
2681     l_location_rec.city     := p_address_rec.city;
2682     l_location_rec.state    := p_address_rec.state;
2683     l_location_rec.postal_code := p_address_rec.postal_code;
2684     l_location_rec.province := p_address_rec.province;
2685     l_location_rec.county   := p_address_rec.county;
2686     l_location_rec.country  := p_address_rec.country;
2687     l_location_rec.language := p_address_rec.language;
2688     l_location_rec.position := p_address_rec.position;
2692     l_location_rec.delivery_point_code := p_address_rec.delivery_point_code;
2689     l_location_rec.address_key := p_address_rec.address_key;
2690     l_location_rec.postal_plus4_code := p_address_rec.postal_plus4_code;
2691     l_location_rec.position := p_address_rec.position;
2693     l_location_rec.location_directions := p_address_rec.location_directions;
2694     -- l_location_rec.address_error_code := p_address_rec.address_error_code;
2695     l_location_rec.clli_code := p_address_rec.clli_code;
2696     l_location_rec.short_description := p_address_rec.short_description;
2697     l_location_rec.description := p_address_rec.description;
2698     l_location_rec.sales_tax_geocode := p_address_rec.sales_tax_geocode;
2699     l_location_rec.sales_tax_inside_city_limits := p_address_rec.sales_tax_inside_city_limits;
2700     l_location_rec.address_effective_date := p_address_rec.address_effective_date;
2701     l_location_rec.address_expiration_date := p_address_rec.address_expiration_date;
2702     l_location_rec.address_style := p_address_rec.address_style;
2703     -- swai: unused fields in TCA, but still avail in v2 (per bug #2863096)
2704     l_location_rec.po_box_number := p_address_rec.po_box_number;
2705     l_location_rec.street   := p_address_rec.street;
2706     l_location_rec.house_number  := p_address_rec.house_number;
2707     l_location_rec.street_suffix := p_address_rec.street_suffix;
2708     l_location_rec.street_number := p_address_rec.street_number;
2709     l_location_rec.floor := p_address_rec.floor;
2710     l_location_rec.suite := p_address_rec.suite;
2711     -- swai: new TCA V2 fields --
2712     l_location_rec.timezone_id := p_address_rec.timezone_id;
2713     l_location_rec.created_by_module := p_address_rec.created_by_module;
2714     l_location_rec.application_id := p_address_rec.application_id;
2715     l_location_rec.actual_content_source := p_address_rec.actual_content_source;
2716     l_location_rec.delivery_point_code := p_address_rec.delivery_point_code;
2717     -- end new TCA V2 fields --
2718 
2719     -- x_last_upd_date := p_last_upd_date;
2720     x_obj_ver_num := p_obj_ver_num;
2721 
2722     -- swai: use new TCA v2 API
2723     HZ_LOCATION_V2PUB.update_location (
2724                           p_init_msg_list     => FND_API.G_FALSE,
2725                           p_location_rec      => l_location_rec,
2726                           p_object_version_number  => x_obj_ver_num,
2727                           x_return_status     => x_return_status,
2728                           x_msg_count         => x_msg_count,
2729                           x_msg_data          => x_msg_data);
2730 
2731     IF NOT(x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
2732         csd_gen_utility_pvt.ADD('update_location failed ');
2733         RAISE FND_API.G_EXC_ERROR;
2734     END IF;
2735 
2736     --
2737     -- End API Body
2738     --
2739 
2740     -- Standard check of p_commit.
2741     IF FND_API.To_Boolean( p_commit ) THEN
2742        COMMIT WORK;
2743     END IF;
2744 
2745     -- Standard call to get message count and IF count is  get message info.
2746     FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2747                                p_data   =>  x_msg_data );
2748 EXCEPTION
2749     WHEN FND_API.G_EXC_ERROR THEN
2750           ROLLBACK TO Update_Address_Pvt;
2751           x_return_status := FND_API.G_RET_STS_ERROR ;
2752           FND_MSG_PUB.Count_And_Get
2753                 (p_count  =>  x_msg_count,
2754                  p_data   =>  x_msg_data
2755                 );
2756     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2757           ROLLBACK TO Update_Address_Pvt;
2758           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2759           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2760                                      p_data   =>  x_msg_data );
2761     WHEN OTHERS THEN
2762           ROLLBACK TO Update_Address_Pvt;
2763           x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2764           IF  FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2765           THEN
2766               FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME ,
2767                                        l_api_name  );
2768           END IF;
2769           FND_MSG_PUB.Count_And_Get (p_count  =>  x_msg_count,
2770                                      p_data   =>  x_msg_data );
2771 END Update_Address;
2772 
2773 
2774 END CSD_PARTIES_PVT ;