[Home] [Help]
PACKAGE BODY: APPS.PV_PARTNER_UTIL_PVT
Source
1 PACKAGE BODY PV_PARTNER_UTIL_PVT AS
2 /* $Header: pvxvputb.pls 120.13 2006/02/26 21:01:48 rdsharma noship $ */
3
4 PV_DEBUG_HIGH_ON CONSTANT boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_HIGH);
5 PV_DEBUG_LOW_ON CONSTANT boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW);
6 PV_DEBUG_MEDIUM_ON CONSTANT boolean := FND_MSG_PUB.CHECK_MSG_LEVEL(FND_MSG_PUB.G_MSG_LVL_DEBUG_MEDIUM);
7
8
9 PROCEDURE map_location_rec( p_location_rec IN PV_PARTNER_UTIL_PVT.location_rec_type,
10 x_location_rec OUT NOCOPY HZ_LOCATION_V2PUB.location_rec_type)
11 IS
12 BEGIN
13
14 x_location_rec.orig_system_reference := p_location_rec.orig_system_reference ;
15 x_location_rec.orig_system := p_location_rec.orig_system ;
16 x_location_rec.country := p_location_rec.country ;
17 x_location_rec.address1 := p_location_rec.address1 ;
18 x_location_rec.address2 := p_location_rec.address2 ;
19 x_location_rec.address3 := p_location_rec.address3 ;
20 x_location_rec.address4 := p_location_rec.address4 ;
21 x_location_rec.city := p_location_rec.city ;
22 x_location_rec.postal_code := p_location_rec.postal_code ;
23 x_location_rec.state := p_location_rec.state ;
24 x_location_rec.province := p_location_rec.province ;
25 x_location_rec.county := p_location_rec.county ;
26 x_location_rec.address_key := p_location_rec.address_key ;
27 x_location_rec.address_style := p_location_rec.address_style ;
28 x_location_rec.validated_flag := p_location_rec.validated_flag ;
29 x_location_rec.address_lines_phonetic:= p_location_rec.address_lines_phonetic ;
30 x_location_rec.po_box_number := p_location_rec.po_box_number ;
31 x_location_rec.house_number := p_location_rec.house_number ;
32 x_location_rec.street_suffix := p_location_rec.street_suffix ;
33 x_location_rec.street := p_location_rec.street ;
34 x_location_rec.street_number := p_location_rec.street_number ;
35 x_location_rec.floor := p_location_rec.floor ;
36 x_location_rec.suite := p_location_rec.suite ;
37 x_location_rec.postal_plus4_code := p_location_rec.postal_plus4_code ;
38 x_location_rec.position := p_location_rec.position ;
39 x_location_rec.location_directions := p_location_rec.location_directions ;
40 x_location_rec.address_effective_date:= p_location_rec.address_effective_date ;
41 x_location_rec.address_expiration_date := p_location_rec.address_expiration_date ;
42 x_location_rec.clli_code := p_location_rec.clli_code ;
43 x_location_rec.language := p_location_rec.language ;
44 x_location_rec.short_description := p_location_rec.short_description ;
45 x_location_rec.description := p_location_rec.description ;
46 x_location_rec.geometry_status_code := p_location_rec.geometry_status_code ;
47 x_location_rec.loc_hierarchy_id := p_location_rec.loc_hierarchy_id ;
48 x_location_rec.sales_tax_geocode := p_location_rec.sales_tax_geocode ;
49 x_location_rec.sales_tax_inside_city_limits := p_location_rec.sales_tax_inside_city_limits ;
50 x_location_rec.fa_location_id := p_location_rec.fa_location_id ;
51 x_location_rec.content_source_type := p_location_rec.content_source_type ;
52 x_location_rec.attribute_category := p_location_rec.attribute_category ;
53 x_location_rec.attribute1 := p_location_rec.attribute1 ;
54 x_location_rec.attribute2 := p_location_rec.attribute2 ;
55 x_location_rec.attribute3 := p_location_rec.attribute3 ;
56 x_location_rec.attribute4 := p_location_rec.attribute4 ;
57 x_location_rec.attribute5 := p_location_rec.attribute5 ;
58 x_location_rec.attribute6 := p_location_rec.attribute6 ;
59 x_location_rec.attribute7 := p_location_rec.attribute7 ;
60 x_location_rec.attribute8 := p_location_rec.attribute8 ;
61 x_location_rec.attribute9 := p_location_rec.attribute9 ;
62 x_location_rec.attribute10 := p_location_rec.attribute10 ;
63 x_location_rec.attribute11 := p_location_rec.attribute11 ;
64 x_location_rec.attribute12 := p_location_rec.attribute12 ;
65 x_location_rec.attribute13 := p_location_rec.attribute13 ;
66 x_location_rec.attribute14 := p_location_rec.attribute14 ;
67 x_location_rec.attribute15 := p_location_rec.attribute15 ;
68 x_location_rec.attribute16 := p_location_rec.attribute16 ;
69 x_location_rec.attribute17 := p_location_rec.attribute17 ;
70 x_location_rec.attribute18 := p_location_rec.attribute18 ;
71 x_location_rec.attribute19 := p_location_rec.attribute19 ;
72 x_location_rec.attribute20 := p_location_rec.attribute20 ;
73 x_location_rec.timezone_id := p_location_rec.timezone_id ;
74 x_location_rec.created_by_module := p_location_rec.created_by_module ;
75 x_location_rec.application_id := p_location_rec.application_id ;
76 x_location_rec.actual_content_source := p_location_rec.actual_content_source ;
77
78 END map_location_rec;
79
80 PROCEDURE map_person_rec(
81 p_person_rec IN PV_PARTNER_UTIL_PVT.person_rec_type,
82 x_person_rec OUT NOCOPY HZ_PARTY_V2PUB.person_rec_type)
83 IS
84 BEGIN
85
86 x_person_rec.person_pre_name_adjunct := p_person_rec.person_pre_name_adjunct;
87 x_person_rec.person_first_name := p_person_rec.person_first_name ;
88 x_person_rec.person_middle_name := p_person_rec.person_middle_name;
89 x_person_rec.person_last_name := p_person_rec.person_last_name ;
90 x_person_rec.person_name_suffix := p_person_rec.person_name_suffix ;
91 x_person_rec.person_title := p_person_rec.person_title ;
92 x_person_rec.person_academic_title := p_person_rec.person_academic_title ;
93 x_person_rec.person_previous_last_name := p_person_rec.person_previous_last_name ;
94 x_person_rec.person_initials := p_person_rec.person_initials ;
95 x_person_rec.known_as := p_person_rec.known_as ;
96 x_person_rec.known_as2 := p_person_rec.known_as2 ;
97 x_person_rec.known_as3 := p_person_rec.known_as3 ;
98 x_person_rec.known_as4 := p_person_rec.known_as4 ;
99 x_person_rec.known_as5 := p_person_rec.known_as5 ;
100 x_person_rec.person_name_phonetic := p_person_rec.person_name_phonetic ;
101 x_person_rec.person_first_name_phonetic := p_person_rec.person_first_name_phonetic ;
102 x_person_rec.person_last_name_phonetic := p_person_rec.person_last_name_phonetic ;
103 x_person_rec.middle_name_phonetic := p_person_rec.middle_name_phonetic ;
104 x_person_rec.tax_reference := p_person_rec.tax_reference ;
105 x_person_rec.jgzz_fiscal_code := p_person_rec.jgzz_fiscal_code ;
106 x_person_rec.person_iden_type := p_person_rec.person_iden_type ;
107 x_person_rec.person_identifier := p_person_rec.person_identifier;
108 x_person_rec.date_of_birth := p_person_rec.date_of_birth ;
109 x_person_rec.place_of_birth := p_person_rec.place_of_birth ;
110 x_person_rec.date_of_death := p_person_rec.date_of_death ;
111 x_person_rec.deceased_flag := null;
112 x_person_rec.gender := p_person_rec.gender ;
113 x_person_rec.declared_ethnicity := p_person_rec.declared_ethnicity ;
114 x_person_rec.marital_status := p_person_rec.marital_status ;
115 x_person_rec.marital_status_effective_date := p_person_rec.marital_status_effective_date ;
116 x_person_rec.personal_income := p_person_rec.personal_income ;
117 x_person_rec.head_of_household_flag := p_person_rec.head_of_household_flag ;
118 x_person_rec.household_income := p_person_rec.household_income ;
119 x_person_rec.household_size := p_person_rec.household_size ;
120 x_person_rec.rent_own_ind := p_person_rec.rent_own_ind ;
121 x_person_rec.last_known_gps := p_person_rec.last_known_gps ;
122 x_person_rec.content_source_type := p_person_rec.content_source_type ;
123 x_person_rec.internal_flag := p_person_rec.internal_flag ;
124 x_person_rec.attribute_category := p_person_rec.attribute_category ;
125 x_person_rec.attribute1 := p_person_rec.attribute1 ;
126 x_person_rec.attribute2 := p_person_rec.attribute2 ;
127 x_person_rec.attribute3 := p_person_rec.attribute3 ;
128 x_person_rec.attribute4 := p_person_rec.attribute4 ;
129 x_person_rec.attribute5 := p_person_rec.attribute5 ;
130 x_person_rec.attribute6 := p_person_rec.attribute6 ;
131 x_person_rec.attribute7 := p_person_rec.attribute7 ;
132 x_person_rec.attribute8 := p_person_rec.attribute8 ;
133 x_person_rec.attribute9 := p_person_rec.attribute9 ;
134 x_person_rec.attribute10 := p_person_rec.attribute10 ;
135 x_person_rec.attribute11 := p_person_rec.attribute11 ;
136 x_person_rec.attribute12 := p_person_rec.attribute12 ;
137 x_person_rec.attribute13 := p_person_rec.attribute13 ;
138 x_person_rec.attribute14 := p_person_rec.attribute14 ;
139 x_person_rec.attribute15 := p_person_rec.attribute15 ;
140 x_person_rec.attribute16 := p_person_rec.attribute16 ;
141 x_person_rec.attribute17 := p_person_rec.attribute17 ;
142 x_person_rec.attribute18 := p_person_rec.attribute18 ;
143 x_person_rec.attribute19 := p_person_rec.attribute19 ;
144 x_person_rec.attribute20 := p_person_rec.attribute20 ;
145 x_person_rec.created_by_module := p_person_rec.created_by_module ;
146 x_person_rec.application_id := p_person_rec.application_id ;
147 x_person_rec.actual_content_source := p_person_rec.actual_content_source ;
148 x_person_rec.party_rec := p_person_rec.party_rec ;
149
150 END map_person_rec;
151
152 FUNCTION get_Person_ID(p_resource_id IN NUMBER)
153 RETURN NUMBER
154 IS
155 l_person_id NUMBER;
156
157 CURSOR l_person_id_csr(cv_resource_id NUMBER) IS
158 SELECT source_id
159 FROM jtf_rs_resource_extns
160 WHERE resource_id = cv_resource_id
161 AND category='EMPLOYEE' ;
162 BEGIN
163
164 OPEN l_person_id_csr(p_resource_id );
165 FETCH l_person_id_csr INTO l_person_id;
166 CLOSE l_person_id_csr;
167
168 return l_person_id;
169 END get_Person_ID;
170
171 /*============================================================================
172 -- Start of comments
173 -- API name : Create_Search_Attr_Values
174 -- Type : Private.
175 -- Function : This API consolidates three operations in single API call. These
176 -- operations are as follows -
177 -- * Create a party
178 -- * Create a location
179 -- * Create a party site
180 -- for a given party. Once the party is successfully created then
181 -- it return the PARTY_ID of that organization.
182 --
183 -- Pre-reqs : None.
184 -- Parameters :
185 -- IN : p_api_version IN NUMBER Required
186 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
187 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
188 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
189 --
190 -- p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE Required
191 -- p_location_rec IN PV_PARTNER_UTIL_PVT.LOCATION_REC_TYPE Required
192 -- p_party_site_rec IN HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE Required
193 -- p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.ATTR_VALUE_TBL_TYPE
194 -- p_vad_partner_id IN NUMBER
195 -- p_member_type IN VARCHAR2
196 -- p_global_partner_id IN NUMBER
197 --
198 -- OUT : x_return_status OUT VARCHAR2(1)
199 -- x_msg_count OUT NUMBER
200 -- x_msg_data OUT VARCHAR2(2000)
201 -- x_party_id NUMBER
202 -- x_default_resp_id OUT NOCOPY NUMBER
203 -- x_group_id OUT NOCOPY NUMBER
204 --
205 -- Version : Current version 1.0
206 -- Initial version 1.0
207 --
208 -- Notes : Note text
209 --
210 -- End of comments
211 ============================================================================*/
212 PROCEDURE Create_Search_Attr_Values (
213 p_api_version_number IN NUMBER,
214 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
215 p_commit IN VARCHAR2 := FND_API.G_FALSE,
216 p_partner_id IN NUMBER,
217 x_return_status OUT NOCOPY VARCHAR2,
218 x_msg_count OUT NOCOPY NUMBER,
219 x_msg_data OUT NOCOPY VARCHAR2
220 ) IS
221
222 l_api_name CONSTANT VARCHAR2(30) := 'Create_Search_Attr_values';
223 l_partner_id NUMBER := p_partner_id;
224 begin
225
226 -- vansub
227 -- Start : Rivendell Changes
228 -- Insert into pv_search_attr_values at the time of creating partner
229 -- Debug Message
230 IF (PV_DEBUG_HIGH_ON) THEN
231 PVX_UTILITY_PVT.debug_message('Start : Inserting into pv_search_attr_values table for partner :'||l_partner_id);
232 END IF;
233
234 EXECUTE IMMEDIATE
235 ' INSERT INTO pv_search_attr_values
236 SELECT pv_search_attr_values_s.nextval
237 , partner_id
238 , null
239 , attr_text
240 , SYSDATE
241 , FND_GLOBAL.user_id
242 , SYSDATE
243 , FND_GLOBAL.user_id
244 , 1.0
245 , FND_GLOBAL.user_id
246 , null
247 , attribute_id
248 , null
249 from (
250 SELECT distinct 4 attribute_id, hl.country attr_text, pvpp.partner_id partner_id
251 FROM hz_locations hl,
252 hz_party_sites hs,
253 pv_partner_profiles pvpp
254 WHERE hl.location_id = hs.location_id
255 AND hs.party_id = pvpp.partner_party_id
256 AND pvpp.partner_id = :1
257 AND (hs.status = ''A'' OR hs.status IS NULL)
258 UNION all
259 SELECT 11 attribute_id, UPPER(PARTNER.party_name) attr_text ,PVPP.partner_id partner_id
260 FROM hz_organization_profiles HZOP_PRT,
261 pv_enty_attr_values PEAV,
262 hz_parties PARTNER,
263 hz_organization_profiles HZOP,
264 hz_parties INTERNAL,
265 hz_relationships HZR,
266 pv_partner_profiles PVPP
267 WHERE HZR.party_id = PVPP.partner_id
268 AND HZR.object_id = INTERNAL.party_id
269 AND HZR.subject_id = PVPP.partner_party_id
270 AND HZR.subject_id = PARTNER.party_id
271 AND HZR.subject_table_name = ''HZ_PARTIES''
272 AND HZR.object_table_name = ''HZ_PARTIES''
273 AND HZR.subject_type = ''ORGANIZATION''
274 AND HZR.object_type = ''ORGANIZATION''
275 AND HZR.RELATIONSHIP_TYPE IN (''PARTNER'',''PARTNER_MANAGED_CUSTOMER'')
276 AND INTERNAL.PARTY_TYPE=''ORGANIZATION''
277 AND PARTNER.PARTY_TYPE =''ORGANIZATION''
278 AND HZOP.party_id = INTERNAL.party_id
279 AND HZOP.effective_end_date is null
280 AND INTERNAL.status IN (''A'',''I'')
281 AND PARTNER.status IN (''A'',''I'')
282 AND HZR.status IN (''A'',''I'')
283 AND HZOP_PRT.party_id = PARTNER.party_id
284 AND HZOP_PRT.effective_end_date is null
285 AND PEAV.entity_id(+) = HZR.party_id
286 AND PEAV.entity(+) = ''PARTNER''
287 AND PEAV.attribute_id(+) = 3
288 AND PEAV.attr_value(+) = ''VAD''
289 AND PEAV.latest_flag(+) = ''Y''
290 AND HZOP.internal_flag = ''Y''
291 AND PVPP.partner_id = :1
292 UNION all
293 SELECT 3 attribute_id,pear.attr_value attr_text, pear.entity_id partner_id
294 FROM pv_enty_attr_values pear
295 WHERE pear.entity_id = :1
296 AND pear.latest_flag = ''Y''
297 AND attr_value is not null
298 AND attribute_id = 3 )' USING l_partner_id,l_partner_id,l_partner_id ;
299
300 -- end : Rivendell Changes
301 -- vansub
302 IF (PV_DEBUG_HIGH_ON) THEN
303 PVX_UTILITY_PVT.debug_message('End : Inserting into search table ');
304 END IF;
305
306 -- Standard check for p_commit
307 IF FND_API.to_Boolean( p_commit )
308 THEN
309 COMMIT WORK;
310 END IF;
311
312 -- Debug Message
313 IF (PV_DEBUG_HIGH_ON) THEN
314 PVX_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'end');
315 END IF;
316
317 -- Standard call to get message count and if count is 1, get message info.
318 FND_MSG_PUB.Count_And_Get
319 (p_count => x_msg_count,
320 p_data => x_msg_data
321 );
322
323 end Create_Search_Attr_values;
324 /*============================================================================
325 -- Start of comments
326 -- API name : Create_Partner
327 -- Type : Public.
328 -- Function : This API consolidates three operations in single API call. These
329 -- operations are as follows -
330 -- * Create a party
331 -- * Create a location
332 -- * Create a party site
333 -- for a given party. Once the party is successfully created then
334 -- it return the PARTY_ID of that organization.
335 --
336 -- Pre-reqs : None.
337 -- Parameters :
338 -- IN : p_api_version IN NUMBER Required
339 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
340 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
341 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
342 --
343 -- p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE Required
344 -- p_location_rec IN PV_PARTNER_UTIL_PVT.LOCATION_REC_TYPE Required
345 -- p_party_site_rec IN HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE Required
346 -- p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.ATTR_VALUE_TBL_TYPE
347 -- p_vad_partner_id IN NUMBER
348 -- p_member_type IN VARCHAR2
349 -- p_global_partner_id IN NUMBER
350 --
351 -- OUT : x_return_status OUT VARCHAR2(1)
352 -- x_msg_count OUT NUMBER
353 -- x_msg_data OUT VARCHAR2(2000)
354 -- x_party_id NUMBER
355 -- x_default_resp_id OUT NOCOPY NUMBER
356 -- x_group_id OUT NOCOPY NUMBER
357 --
358 -- Version : Current version 1.0
359 -- Initial version 1.0
360 --
361 -- Notes : Note text
362 --
363 -- End of comments
364 ============================================================================*/
365 PROCEDURE Create_Partner (
366 p_api_version_number IN NUMBER,
367 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
368 p_commit IN VARCHAR2 := FND_API.G_FALSE,
369 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
370 x_return_status OUT NOCOPY VARCHAR2,
371 x_msg_count OUT NOCOPY NUMBER,
372 x_msg_data OUT NOCOPY VARCHAR2,
373 p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE,
374 p_location_rec IN PV_PARTNER_UTIL_PVT.LOCATION_REC_TYPE,
375 p_party_site_rec IN HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE,
376 -- p_partner_types_tbl IN partner_types_tbl_type := g_miss_partner_types_tbl,
377 p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.attr_value_tbl_type,
378 p_vad_partner_id IN NUMBER,
379 p_member_type IN VARCHAR2 ,
380 p_global_partner_id IN NUMBER ,
381 x_party_id OUT NOCOPY NUMBER,
382 x_default_resp_id OUT NOCOPY NUMBER,
383 x_resp_map_rule_id OUT NOCOPY NUMBER,
384 x_group_id OUT NOCOPY NUMBER
385 ) IS
386
387 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_Partner';
388 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
389
390 -- Local variable declaration for Organization API.
391 l_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
392 l_party_id NUMBER;
393 l_party_number VARCHAR2(30);
394
395 -- Local variable declaration for Location API.
396 l_location_rec HZ_LOCATION_V2PUB.location_rec_type;
397 l_location_id NUMBER;
398
399 -- Local variable declaration for Party Site API.
400 l_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE ;
401 l_party_site_id NUMBER;
402 l_party_site_number VARCHAR2(30);
403
404 -- Local variable declaration for Create_Relationship API.
405 l_partner_id NUMBER;
406 l_default_resp_id NUMBER;
407
408 -- Local variable declaration for Standard Out variables.
409 l_return_status VARCHAR2(1);
410 l_msg_count NUMBER;
411 l_msg_data VARCHAR2(2000);
412
413 -- Declaration of variable for some other common purpose.
414 l_profile_id NUMBER;
415 l_vad_partner_id NUMBER;
416 l_resp_map_rule_id NUMBER;
417 l_group_id NUMBER;
418
419
420 BEGIN
421
422 -- Standard Start of API savepoint
423 SAVEPOINT create_partner_pvt;
424
425 -- Standard call to check for call compatibility.
426 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
427 p_api_version_number,
428 l_api_name,
429 G_PKG_NAME)
430 THEN
431 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
432 END IF;
433
434 -- Initialize message list if p_init_msg_list is set to TRUE.
435 IF FND_API.to_Boolean( p_init_msg_list )
436 THEN
437 FND_MSG_PUB.initialize;
438 END IF;
439
440 -- Debug Message
441 IF (PV_DEBUG_HIGH_ON) THEN
442 PVX_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
443 END IF;
444
445 -- Initialize API return status to SUCCESS
446 x_return_status := FND_API.G_RET_STS_SUCCESS;
447
448 -- Local variable initialization
449 l_organization_rec.organization_name := p_organization_rec.organization_name;
450
451 -- Debug Message
452 IF (PV_DEBUG_HIGH_ON) THEN
453 PVX_UTILITY_PVT.debug_message( 'Public API: Calling create Organization API');
454 END IF;
455
456 -- Call HZ_PARTY_V2PUB.Create_Organization API, for creating a Party record
457 -- in HZ_PARTIES table for the supplied organization.
458
459 HZ_PARTY_V2PUB.Create_organization (
460 p_init_msg_list => FND_API.G_FALSE,
461 p_organization_rec => p_organization_rec,
462 x_return_status => l_return_status,
463 x_msg_count => l_msg_count,
464 x_msg_data => l_msg_data,
465 x_party_id => l_party_id,
466 x_party_number => l_party_number,
467 x_profile_id => l_profile_id
468 );
469
470 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
471 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
472 RAISE FND_API.G_EXC_ERROR;
473 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
474 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
475 END IF;
476 END IF;
477
478 -- Debug Message
479 IF (PV_DEBUG_HIGH_ON) THEN
480 PVX_UTILITY_PVT.debug_message( 'Public API: Successfully completed HZ_PARTY_V2PUB.Create_Organization API Call');
481 END IF;
482
483 -- Debug Message
484 IF (PV_DEBUG_HIGH_ON) THEN
485 PVX_UTILITY_PVT.debug_message( 'Private API: Calling create Location API');
486 END IF;
487
488 -- Initialize the l_location rec from the supplied parameter p_location_rec variable.
489 map_location_rec( p_location_rec => p_location_rec ,
490 x_location_rec => l_location_rec );
491
492 -- Call the HZ_LOCATION_V2PUB.Create_Location API for creating the location.
493 HZ_LOCATION_V2PUB.Create_Location(
494 p_init_msg_list => FND_API.G_FALSE,
495 p_location_rec => l_location_rec,
496 x_location_id => l_location_id,
497 x_return_status => l_return_status,
498 x_msg_count => l_msg_count,
499 x_msg_data => l_msg_data
500 );
501
502 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
503 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
504 RAISE FND_API.G_EXC_ERROR;
505 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
506 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
507 END IF;
508 END IF;
509
510 -- Debug Message
511 IF (PV_DEBUG_HIGH_ON) THEN
512 PVX_UTILITY_PVT.debug_message( 'Public API: Successfully completed HZ_LOCATION_V2PUB.Create_Location API Call');
513 END IF;
514
515 -- Debug Message
516 IF (PV_DEBUG_HIGH_ON) THEN
517 PVX_UTILITY_PVT.debug_message( 'Public API: Calling create Party Site API');
518 END IF;
519
520 -- Initialize some of the Party Site related variable.
521 l_party_site_rec := p_party_site_rec;
522 l_party_site_rec.location_id := l_location_id;
523 l_party_site_rec.party_id := l_party_id;
524
525 -- Call the HZ_PARTY_SITE_V2PUB.Create_Party_site API for creating the party site.
526
527 HZ_PARTY_SITE_V2PUB.create_party_site (
528 p_init_msg_list => FND_API.G_FALSE,
529 p_party_site_rec => l_party_site_rec,
530 x_party_site_id => l_party_site_id,
531 x_party_site_number => l_party_site_number,
532 x_return_status => l_return_status,
533 x_msg_count => l_msg_count,
534 x_msg_data => l_msg_data
535 );
536
537
538 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
539 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
540 RAISE FND_API.G_EXC_ERROR;
541 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
542 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
543 END IF;
544 END IF;
545
546 -- Debug Message
547 IF (PV_DEBUG_HIGH_ON) THEN
548 PVX_UTILITY_PVT.debug_message( 'Private API: Successfully completed create Party Site API Call');
549 END IF;
550
551 -- Call the Create_Realtionship API for creating rest of the stuff
552 -- related to partner organization.
553
554 Create_Relationship(
555 p_api_version_number => 1.0
556 ,p_init_msg_list => FND_API.G_FALSE
557 ,p_commit => FND_API.G_FALSE
558 ,p_validation_level => FND_API.G_VALID_LEVEL_FULL
559 ,x_return_status => l_return_status
560 ,x_msg_data => l_msg_data
561 ,x_msg_count => l_msg_count
562 ,p_party_id => l_party_id
563 ,p_partner_types_tbl => p_partner_types_tbl
564 ,p_vad_partner_id => p_vad_partner_id
565 ,p_member_type => p_member_type
566 ,p_global_partner_id => p_global_partner_id
567 ,x_partner_id => l_partner_id
568 ,x_default_resp_id => l_default_resp_id
569 ,x_resp_map_rule_id => l_resp_map_rule_id
570 ,x_group_id => l_group_id
571 );
572
573 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
574 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
575 RAISE FND_API.G_EXC_ERROR;
576 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
577 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
578 END IF;
579 END IF;
580
581 -- Initialize the output parameters
582 x_party_id := l_party_id;
583 x_default_resp_id := l_default_resp_id;
584 x_resp_map_rule_id := l_resp_map_rule_id;
585 x_group_id := l_group_id;
586
587
588 Create_Search_Attr_Values (
589 p_api_version_number => 1.0
590 ,p_init_msg_list => FND_API.G_FALSE
591 ,p_commit => FND_API.G_FALSE
592 ,x_return_status => l_return_status
593 ,x_msg_data => l_msg_data
594 ,x_msg_count => l_msg_count
595 ,p_partner_id => l_partner_id
596 );
597 /*
598
599 -- vansub
600 -- Start : Rivendell Changes
601 -- Insert into pv_search_attr_values at the time of creating partner
602 -- Debug Message
603 IF (PV_DEBUG_HIGH_ON) THEN
604 PVX_UTILITY_PVT.debug_message('Start : Inserting into pv_search_attr_values table for partner :'||l_partner_id);
605 END IF;
606
607 EXECUTE IMMEDIATE
608 ' INSERT INTO pv_search_attr_values
609 SELECT pv_search_attr_values_s.nextval
610 , partner_id
611 , null
612 , attr_text
613 , SYSDATE
614 , FND_GLOBAL.user_id
615 , SYSDATE
616 , FND_GLOBAL.user_id
617 , 1.0
618 , FND_GLOBAL.user_id
619 , null
620 , attribute_id
621 , null
622 from (
623 SELECT distinct 4 attribute_id, hl.country attr_text, pvpp.partner_id partner_id
624 FROM hz_locations hl,
625 hz_party_sites hs,
626 pv_partner_profiles pvpp
627 WHERE hl.location_id = hs.location_id
628 AND hs.party_id = pvpp.partner_party_id
629 AND pvpp.partner_id = :1
630 AND (hs.status = ''A'' OR hs.status IS NULL)
631 UNION all
632 SELECT 11 attribute_id, UPPER(PARTNER.party_name) attr_text ,PVPP.partner_id partner_id
633 FROM hz_organization_profiles HZOP_PRT,
634 pv_enty_attr_values PEAV,
635 hz_parties PARTNER,
636 hz_organization_profiles HZOP,
637 hz_parties INTERNAL,
638 hz_relationships HZR,
639 pv_partner_profiles PVPP
640 WHERE HZR.party_id = PVPP.partner_id
641 AND HZR.object_id = INTERNAL.party_id
642 AND HZR.subject_id = PVPP.partner_party_id
643 AND HZR.subject_id = PARTNER.party_id
644 AND HZR.subject_table_name = ''HZ_PARTIES''
645 AND HZR.object_table_name = ''HZ_PARTIES''
646 AND HZR.subject_type = ''ORGANIZATION''
647 AND HZR.object_type = ''ORGANIZATION''
648 AND HZR.RELATIONSHIP_TYPE IN (''PARTNER'',''PARTNER_MANAGED_CUSTOMER'')
649 AND INTERNAL.PARTY_TYPE=''ORGANIZATION''
650 AND PARTNER.PARTY_TYPE =''ORGANIZATION''
651 AND HZOP.party_id = INTERNAL.party_id
652 AND HZOP.effective_end_date is null
653 AND INTERNAL.status IN (''A'',''I'')
654 AND PARTNER.status IN (''A'',''I'')
655 AND HZR.status IN (''A'',''I'')
656 AND HZOP_PRT.party_id = PARTNER.party_id
657 AND HZOP_PRT.effective_end_date is null
658 AND PEAV.entity_id(+) = HZR.party_id
659 AND PEAV.entity(+) = ''PARTNER''
660 AND PEAV.attribute_id(+) = 3
661 AND PEAV.attr_value(+) = ''VAD''
662 AND PEAV.latest_flag(+) = ''Y''
663 AND HZOP.internal_flag = ''Y''
664 AND PVPP.partner_id = :1
665 UNION all
666 SELECT 3 attribute_id,pear.attr_value attr_text, pear.entity_id partner_id
667 FROM pv_enty_attr_values pear
668 WHERE pear.entity_id = :1
669 AND pear.latest_flag = ''Y''
670 AND attr_value is not null
671 AND attribute_id = 3 )' USING l_partner_id,l_partner_id,l_partner_id ;
672
673 -- end : Rivendell Changes
674 -- vansub
675 IF (PV_DEBUG_HIGH_ON) THEN
676 PVX_UTILITY_PVT.debug_message('End : Inserting into search table ');
677 END IF;
678
679 -- Standard check for p_commit
680 IF FND_API.to_Boolean( p_commit )
681 THEN
682 COMMIT WORK;
683 END IF;
684
685 -- Debug Message
686 IF (PV_DEBUG_HIGH_ON) THEN
687 PVX_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'end');
688 END IF;
689
690 -- Standard call to get message count and if count is 1, get message info.
691 FND_MSG_PUB.Count_And_Get
692 (p_count => x_msg_count,
693 p_data => x_msg_data
694 );
695 */
696 EXCEPTION
697
698 WHEN PVX_UTILITY_PVT.resource_locked THEN
699 x_return_status := FND_API.g_ret_sts_error;
700 PVX_UTILITY_PVT.Error_Message(p_message_name => 'PV_API_RESOURCE_LOCKED');
701
702 WHEN FND_API.G_EXC_ERROR THEN
703 ROLLBACK TO create_partner_pvt;
704 x_return_status := FND_API.G_RET_STS_ERROR;
705 -- Standard call to get message count and if count=1, get the message
706 FND_MSG_PUB.Count_And_Get (
707 p_encoded => FND_API.G_FALSE,
708 p_count => x_msg_count,
709 p_data => x_msg_data
710 );
711
712 -- Debug Message
713 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW) THEN
714 hz_utility_v2pub.debug_return_messages (
715 x_msg_count, x_msg_data, 'ERROR');
716 hz_utility_v2pub.debug('Create_Partner (-)');
717 END IF;
718
719 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
720 ROLLBACK TO create_partner_pvt;
721 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
722 -- Standard call to get message count and if count=1, get the message
723 FND_MSG_PUB.Count_And_Get (
724 p_encoded => FND_API.G_FALSE,
725 p_count => x_msg_count,
726 p_data => x_msg_data
727 );
728
729 -- Debug Message
730 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW) THEN
731 hz_utility_v2pub.debug_return_messages (
732 x_msg_count, x_msg_data, 'UNEXPECTED ERROR');
733 hz_utility_v2pub.debug('Create_Partner (-)');
734 END IF;
735
736 WHEN OTHERS THEN
737 ROLLBACK TO create_partner_pvt;
738 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
739 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
740 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
741 END IF;
742
743 -- Standard call to get message count and if count=1, get the message
744 FND_MSG_PUB.Count_And_Get (
745 p_encoded => FND_API.G_FALSE,
746 p_count => x_msg_count,
747 p_data => x_msg_data );
748
749 -- Debug Message
750 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_DEBUG_LOW) THEN
751 hz_utility_v2pub.debug_return_messages (
752 x_msg_count, x_msg_data, 'SQL ERROR');
753 hz_utility_v2pub.debug('Create_Partner (-)');
754 END IF;
755
756 End Create_Partner;
757
758 /*============================================================================
759 -- Start of comments
760 -- API name : Create_Party_Site_Uses
761 -- Type : Public.
762 -- Function : This api checks if the party already has party sites with
763 -- BILL_TO and SHIP_TO site use type. If it does not exists adds
764 -- these use types to the identifying address
765 --
766 -- Pre-reqs : None.
767 -- Parameters :
768 -- IN :
769 -- p_party_id IN NUMBER Required
770 --
771 -- OUT : x_return_status OUT VARCHAR2(1)
772 -- x_msg_count OUT NUMBER
773 -- x_msg_data OUT VARCHAR2(2000)
774 --
775 -- Version : Current version 1.0
776 -- Initial version 1.0
777 --
778 -- Notes : Note text
779 --
780 -- End of comments
781 ============================================================================*/
782
783 PROCEDURE Create_Party_Site_Uses (
784 p_party_id IN NUMBER
785 ,x_return_status OUT NOCOPY VARCHAR2
786 ,x_msg_data OUT NOCOPY VARCHAR2
787 ,x_msg_count OUT NOCOPY NUMBER
788 )
789 IS
790
791
792 CURSOR get_site_use_type(cv_party_id NUMBER) IS
793 SELECT distinct site_use_type
794 FROM hz_party_site_uses hpsu,
795 hz_party_sites hps
796 WHERE hpsu.party_site_id = hps.party_site_id
797 AND site_use_type in ('SHIP_TO','BILL_TO')
798 AND hps.party_id = cv_party_id ;
799
800 CURSOR get_ident_party_site_dtls(cv_party_id NUMBER) is
801 SELECT party_site_id FROM HZ_PARTY_SITES WHERE PARTY_ID = CV_PARTY_ID AND IDENTIFYING_ADDRESS_FLAG = 'Y';
802
803
804 l_party_site_use_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_USE_REC_TYPE;
805 l_vendor_org_id number;
806 l_party_site_id number;
807 l_party_site_use_id number;
808 l_party_site_use VARCHAR2(20);
809
810 -- Local variable declaration for Standard Out variables.
811 l_return_status VARCHAR2(1);
812 l_msg_count NUMBER;
813 l_msg_data VARCHAR2(2000);
814 l_cnt NUMBER;
815 cur_cnt get_site_use_type%ROWTYPE;
816
817
818 BEGIN
819
820 hz_utility_v2pub.debug('Party Id:' || p_party_id);
821
822 l_cnt := 0;
823 FOR cur_cnt IN get_site_use_type(p_party_id)
824 LOOP
825 l_party_site_use:= cur_cnt.site_use_type;
826 l_cnt := l_cnt + 1;
827 END LOOP;
828
829 IF NOT (l_cnt = 2) then
830
831 OPEN get_ident_party_site_dtls(p_party_id);
832 FETCH get_ident_party_site_dtls into l_party_site_id;
833 close get_ident_party_site_dtls ;
834
835
836
837 l_party_site_use_rec.party_site_use_id := FND_API.G_MISS_NUM;
838 l_party_site_use_rec.comments := FND_API.G_MISS_CHAR ;
839
840 l_party_site_use_rec.party_site_id := l_party_site_id;
841 l_party_site_use_rec.primary_per_type := FND_API.G_MISS_CHAR;
842 l_party_site_use_rec.status := 'A';
843 l_party_site_use_rec.created_by_module := 'PV';
844 l_party_site_use_rec.application_id := '691';
845
846
847 IF (l_party_site_use = 'SHIP_TO') THEN
848 l_party_site_use_rec.site_use_type := 'BILL_TO';
849
850 hz_party_site_v2pub.create_party_site_use (
851 p_init_msg_list => FND_API.G_FALSE,
852 p_party_site_use_rec => l_party_site_use_rec,
853 x_party_site_use_id => l_party_site_use_id,
854 x_return_status => l_return_status,
855 x_msg_count => l_msg_count,
856 x_msg_data => l_msg_data );
857
858
859 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
860 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
861 RAISE FND_API.G_EXC_ERROR;
862 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
863 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
864 END IF;
865 END IF;
866
867
868 ELSIF (l_party_site_use = 'BILL_TO') then
869 l_party_site_use_rec.site_use_type := 'SHIP_TO';
870
871 hz_party_site_v2pub.create_party_site_use (
872 p_init_msg_list => FND_API.G_FALSE,
873 p_party_site_use_rec => l_party_site_use_rec,
874 x_party_site_use_id => l_party_site_use_id,
875 x_return_status => l_return_status,
876 x_msg_count => l_msg_count,
877 x_msg_data => l_msg_data );
878
879 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
880 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
881 RAISE FND_API.G_EXC_ERROR;
882 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
883 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
884 END IF;
885 END IF;
886
887 ELSE
888
889 l_party_site_use_rec.site_use_type := 'BILL_TO';
890
891 hz_party_site_v2pub.create_party_site_use (
892 p_init_msg_list => FND_API.G_FALSE,
893 p_party_site_use_rec => l_party_site_use_rec,
894 x_party_site_use_id => l_party_site_use_id,
895 x_return_status => l_return_status,
896 x_msg_count => l_msg_count,
897 x_msg_data => l_msg_data );
898
899
900 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
901 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
902 RAISE FND_API.G_EXC_ERROR;
903 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
904 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
905 END IF;
906 END IF;
907
908
909 l_party_site_use_rec.site_use_type := 'SHIP_TO';
910
911 hz_party_site_v2pub.create_party_site_use (
912 p_init_msg_list => FND_API.G_FALSE,
913 p_party_site_use_rec => l_party_site_use_rec,
914 x_party_site_use_id => l_party_site_use_id,
915 x_return_status => l_return_status,
916 x_msg_count => l_msg_count,
917 x_msg_data => l_msg_data );
918
919
920 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
921 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
922 RAISE FND_API.G_EXC_ERROR;
923 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
924 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
925 END IF;
926 END IF;
927 END IF;
928 END IF;
929
930 EXCEPTION
931 WHEN FND_API.g_exc_error THEN
932 x_return_status := FND_API.g_ret_sts_error;
933 FND_MSG_PUB.count_and_get (
934 p_encoded => FND_API.g_false
935 ,p_count => x_msg_count
936 ,p_data => x_msg_data
937 );
938
939 WHEN FND_API.g_exc_unexpected_error THEN
940 x_return_status := FND_API.g_ret_sts_unexp_error ;
941 FND_MSG_PUB.count_and_get (
942 p_encoded => FND_API.g_false
943 ,p_count => x_msg_count
944 ,p_data => x_msg_data
945 );
946
947 WHEN OTHERS THEN
948 x_return_status := FND_API.g_ret_sts_unexp_error ;
949
950 FND_MSG_PUB.count_and_get(
951 p_encoded => FND_API.g_false
952 ,p_count => x_msg_count
953 ,p_data => x_msg_data
954 );
955
956 END Create_Party_Site_Uses;
957 /*============================================================================
958 -- Start of comments
959 -- API name : Do_Create_Relationship
960 -- Type : Public.
961 -- Function : This API consolidates few artner creation related operations in
962 -- single API call. These operations are as follows -
963 -- * Get the vendor Organization based on the default
964 -- responsibility of the logged in user
965 -- * Create a relationship record between Vendor Org and the Partner Org
966 -- * Create Resource for the partner
967 -- * Create role for the above resource
968 -- * Create Group for the above resource
969 -- * Create Partner Profile
970 -- * Get Sales Team for the given partner
971 -- * Add Sales Team for the given Partner
972 -- * Add Channel Manager in Channel Team from TAP
973 -- * Add Partner types to Attributes table
974 -- * If partner type is subsidiary, establish a relationship with the global partner
975 --
976 -- Pre-reqs : None.
977 -- Parameters :
978 -- IN : p_api_version IN NUMBER Required
979 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
980 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
981 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
982 --
983 -- p_party_id IN NUMBER Required
984 -- p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.ATTR_VALUE_TBL_TYPE
985 -- p_vad_partner_id IN NUMBER
986 -- p_member_type IN VARCHAR2
987 -- p_global_partner_id IN NUMBER
988 --
989 -- OUT : x_return_status OUT VARCHAR2(1)
990 -- x_msg_count OUT NUMBER
991 -- x_msg_data OUT VARCHAR2(2000)
992 -- x_partner_id OUT NOCOPY NUMBER
993 -- x_default_resp_id OUT NOCOPY NUMBER
994 -- x_resp_map_rule_id OUT NOCOPY NUMBER,
995 -- x_group_id OUT NOCOPY NUMBER
996 --
997 -- Version : Current version 1.0
998 -- Initial version 1.0
999 --
1000 -- Notes : Note text
1001 --
1002 -- End of comments
1003 ============================================================================*/
1004
1005 PROCEDURE Do_Create_Relationship(
1006 p_api_version_number IN NUMBER
1007 ,p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
1008 ,p_commit IN VARCHAR2 := FND_API.G_FALSE
1009 ,p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
1010 ,x_return_status OUT NOCOPY VARCHAR2
1011 ,x_msg_data OUT NOCOPY VARCHAR2
1012 ,x_msg_count OUT NOCOPY NUMBER
1013 ,p_party_id IN NUMBER
1014 ,p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.attr_value_tbl_type
1015 ,p_vad_partner_id IN NUMBER
1016 ,p_member_type IN VARCHAR2
1017 ,p_global_partner_id IN NUMBER
1018 ,p_partner_qualifiers_tbl IN PV_TERR_ASSIGN_PUB.partner_qualifiers_tbl_type
1019 ,x_partner_id OUT NOCOPY NUMBER
1020 ,x_default_resp_id OUT NOCOPY NUMBER
1021 ,x_resp_map_rule_id OUT NOCOPY NUMBER
1022 ,x_group_id OUT NOCOPY NUMBER
1023 ) IS
1024
1025 L_API_NAME CONSTANT VARCHAR2(30) := 'Do_Create_Relationship';
1026 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1027
1028 l_partner_qualifiers_tbl PV_TERR_ASSIGN_PUB.partner_qualifiers_tbl_type := p_partner_qualifiers_tbl;
1029 -- Cursor l_org_details_csr to get partner party details
1030 CURSOR l_org_details_csr (cv_party_id NUMBER) IS
1031 SELECT party_site_id
1032 FROM hz_party_sites
1033 WHERE party_id = cv_party_id
1034 AND identifying_address_flag = 'Y'
1035 AND status = 'A';
1036
1037 -- Cursor l_relationship_details_csr to get partner party details
1038 CURSOR l_relationship_details_csr (cv_partner_id NUMBER) IS
1039 SELECT party_name
1040 FROM hz_parties PARTY
1041 WHERE PARTY.party_id = cv_partner_id
1042 AND PARTY.status = 'A'
1043 AND PARTY.party_type = 'PARTY_RELATIONSHIP';
1044
1045
1046 -- Cursor l_chk_relationship_exists_csr to check whether the relationship
1047 -- exists in between Partner and the Vendor organizations.
1048 CURSOR l_chk_relationship_exists_csr (cv_vendor_party_id NUMBER,
1049 cv_partner_party_id NUMBER) IS
1050 SELECT hzr.relationship_id relationship_id,
1051 hzp.party_id party_id,
1052 hzp.party_number party_number
1053 FROM hz_relationships hzr,
1054 hz_parties hzp
1055 WHERE hzr.subject_id = cv_partner_party_id
1056 AND hzr.object_id = cv_vendor_party_id
1057 AND hzr.status = 'A'
1058 AND hzr.end_date > sysdate
1059 AND relationship_code = 'PARTNER_OF'
1060 AND relationship_type = 'PARTNER'
1061 AND hzr.party_id = hzp.party_id;
1062
1063 l_party_id NUMBER ;
1064 l_partner_types VARCHAR2(500);
1065 l_partner_level VARCHAR2(30);
1066 l_party_site_id NUMBER ;
1067 l_user_role_code VARCHAR2(30):= Pv_User_Resp_Pvt.G_PRIMARY;
1068 l_responsibility_id NUMBER;
1069 l_resp_map_rule_id NUMBER;
1070 l_application_id NUMBER := 691;
1071 l_vendor_org_id NUMBER;
1072 l_defined_flag BOOLEAN;
1073
1074 -- Delaration of local variables needed in Create_Relationship API call
1075 l_relationship_id NUMBER;
1076 l_party_number VARCHAR2(30);
1077 l_partner_id NUMBER;
1078 l_relactionship_rec HZ_RELATIONSHIP_V2PUB.relationship_rec_type;
1079 l_relship_party_name VARCHAR2(360);
1080
1081 -- Declaration of local variables needed in Create_Resource API call
1082 l_party_name VARCHAR2(360);
1083 l_admin_rec PVX_MISC_PVT.ADMIN_REC_TYPE;
1084 l_resource_id NUMBER;
1085 l_resource_number VARCHAR2(30);
1086 l_mode VARCHAR2(10);
1087
1088 -- Declaration of local variables needed in Create_Role API call
1089 l_role_relate_id NUMBER;
1090
1091 -- Declaration of local variables needed in Create_Group API call
1092 l_group_id NUMBER;
1093 l_group_number VARCHAR2(30);
1094 l_group_usage_id NUMBER;
1095 l_group_member_id NUMBER;
1096
1097 -- Declaration of local variables needed in Create_Prtnr_Prfls API call
1098 l_prtnr_prfls_rec PVX_PRTNR_PRFLS_PVT.prtnr_prfls_rec_type;
1099 l_partner_profile_id NUMBER;
1100
1101 -- Declaration of local variables needed in TAP_Get_Channel_Managers API call
1102 l_resource_id_tbl JTF_NUMBER_TABLE;
1103 l_group_id_tbl JTF_NUMBER_TABLE;
1104
1105 -- Declaration of local variables needed in Create_SalesTeam API call
1106 l_admin_group_id NUMBER;
1107 l_person_id NUMBER;
1108 l_def_cm_id NUMBER;
1109 l_user_id NUMBER := FND_GLOBAL.user_id;
1110 l_chk_access_flag VARCHAR2(1);
1111 l_admin_flag VARCHAR2(1);
1112 l_identity_sales_force_id NUMBER;
1113 l_access_id NUMBER;
1114 l_access_profile_rec AS_ACCESS_PUB.access_profile_rec_type;
1115
1116 l_attr_value_tbl PV_ENTY_ATTR_VALUE_PUB.attr_value_tbl_type;
1117 l_prtnr_access_id_tbl PV_TERR_ASSIGN_PUB.prtnr_aces_tbl_type;
1118
1119 -- Local variable declaration for Standard Out variables.
1120 l_return_status VARCHAR2(1);
1121 l_msg_count NUMBER;
1122 l_msg_data VARCHAR2(2000);
1123
1124 BEGIN
1125 -- Standard Start of API savepoint
1126 SAVEPOINT create_relationship_pvt;
1127
1128 -- Standard call to check for call compatibility.
1129 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
1130 p_api_version_number,
1131 l_api_name,
1132 G_PKG_NAME)
1133 THEN
1134 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1135 END IF;
1136
1137 -- Initialize message list if p_init_msg_list is set to TRUE.
1138 IF FND_API.to_Boolean( p_init_msg_list )
1139 THEN
1140 FND_MSG_PUB.initialize;
1141 END IF;
1142
1143 -- Debug Message
1144 PVX_UTILITY_PVT.debug_message('Private API: ' || l_api_name || 'start');
1145
1146 -- Initialize API return status to SUCCESS
1147 x_return_status := FND_API.G_RET_STS_SUCCESS;
1148
1149 -- Local variable initialization
1150 l_party_id := p_party_id;
1151
1152 -- Initilize the l_relationship_rec with required values.
1153 l_relactionship_rec.subject_id := l_party_id;
1154 l_relactionship_rec.subject_type := 'ORGANIZATION';
1155 l_relactionship_rec.subject_table_name := 'HZ_PARTIES';
1156
1157 -- Get the Default responsibility for the supplied Organization Id.
1158 Pv_User_Resp_Pvt.get_default_org_resp(
1159 p_api_version_number => 1.0
1160 ,p_init_msg_list => FND_API.G_FALSE
1161 ,p_commit => FND_API.G_FALSE
1162 ,x_return_status => l_return_status
1163 ,x_msg_count => l_msg_count
1164 ,x_msg_data => l_msg_data
1165 ,p_partner_org_id => l_party_id
1166 ,p_user_role_code => l_user_role_code
1167 ,x_responsibility_id => l_responsibility_id
1168 ,x_resp_map_rule_id => l_resp_map_rule_id
1169 );
1170
1171 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1172 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1173 RAISE FND_API.G_EXC_ERROR;
1174 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1175 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1176 END IF;
1177 END IF;
1178
1179 -- Get the default vendor org id, for the supplied responsibility id.
1180 FND_PROFILE.GET_SPECIFIC(
1181 NAME_Z => 'PV_DEFAULT_VENDOR_ORG'
1182 ,USER_ID_Z => null
1183 ,RESPONSIBILITY_ID_Z => l_responsibility_id
1184 ,APPLICATION_ID_Z => l_application_id
1185 ,VAL_Z => l_vendor_org_id
1186 ,DEFINED_Z => l_defined_flag
1187 ,ORG_ID_Z => null
1188 ,SERVER_ID_Z => null);
1189
1190 IF l_vendor_org_id IS NULL OR l_vendor_org_id = FND_API.g_miss_num THEN
1191 l_return_status := FND_API.G_RET_STS_ERROR ;
1192 fnd_message.Set_Name('PV', 'PV_NO_DEF_VENDOR_ORG');
1193 fnd_msg_pub.Add;
1194 RAISE FND_API.G_EXC_ERROR;
1195 END IF;
1196
1197
1198 OPEN l_chk_relationship_exists_csr(l_vendor_org_id, l_party_id);
1199 FETCH l_chk_relationship_exists_csr INTO l_relationship_id, l_partner_id, l_party_number;
1200
1201 IF l_chk_relationship_exists_csr%NOTFOUND THEN
1202
1203 -- Iniliatize the local variables required for Relationship creation.
1204 l_relactionship_rec.object_id := l_vendor_org_id ;
1205 l_relactionship_rec.object_type := 'ORGANIZATION';
1206 l_relactionship_rec.object_table_name := 'HZ_PARTIES';
1207 l_relactionship_rec.relationship_code := 'PARTNER_OF';
1208 l_relactionship_rec.relationship_type := 'PARTNER';
1209 l_relactionship_rec.start_date := SYSDATE;
1210 l_relactionship_rec.created_by_module:= 'PV';
1211 l_relactionship_rec.application_id:= l_application_id;
1212 l_relactionship_rec.status:= 'A';
1213
1214 -- Create the relationship.
1215 HZ_RELATIONSHIP_V2PUB.create_relationship (
1216 p_init_msg_list => FND_API.G_FALSE,
1217 p_relationship_rec => l_relactionship_rec,
1218 x_relationship_id => l_relationship_id,
1219 x_party_id => l_partner_id,
1220 x_party_number => l_party_number,
1221 x_return_status => l_return_status,
1222 x_msg_count => l_msg_count,
1223 x_msg_data => l_msg_data,
1224 p_create_org_contact => 'N');
1225
1226 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1227 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1228 RAISE FND_API.G_EXC_ERROR;
1229 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1230 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1231 END IF;
1232 END IF;
1233 END IF; -- End if of check l_chk_relationship_exists_csr
1234
1235 -- Close the cursor l_chk_relationship_exists_csr
1236 CLOSE l_chk_relationship_exists_csr;
1237
1238 -- set the out variables
1239 x_partner_id := l_partner_id ;
1240 x_default_resp_id := l_responsibility_id;
1241 x_resp_map_rule_id := l_resp_map_rule_id;
1242
1243
1244 -- After successful creation of relationship, create resource for the
1245 -- partner by calling the Admin_Resource API from PVX_MISC_PVT package.
1246
1247 -- Initilize the l_admin_rec with required values.
1248 l_admin_rec.partner_relationship_id := l_relationship_id;
1249 l_admin_rec.partner_id := l_partner_id;
1250 l_admin_rec.resource_type := 'PARTNER';
1251
1252 -- Get the Partner relationship name from cursor l_relationship_details_csr.
1253 OPEN l_relationship_details_csr(l_partner_id);
1254 FETCH l_relationship_details_csr INTO l_relship_party_name;
1255 CLOSE l_relationship_details_csr;
1256
1257 -- Get the partner details from l_partner_details_csr cursor for a given partner_id.
1258 l_admin_rec.source_name := l_relship_party_name;
1259 l_admin_rec.resource_name := l_relship_party_name;
1260
1261 -- Get the party site details from l_org_details_csr cursor.
1262 OPEN l_org_details_csr(l_party_id);
1263 FETCH l_org_details_csr INTO l_party_site_id;
1264 CLOSE l_org_details_csr;
1265
1266 l_admin_rec.party_site_id := l_party_site_id;
1267 l_mode := 'CREATE';
1268
1269
1270 -- Create the resource for the partner relationship
1271 PVX_MISC_PVT.Admin_Resource (
1272 p_api_version => 1.0
1273 ,p_init_msg_list => FND_API.g_false
1274 ,p_commit => FND_API.g_false
1275 ,x_return_status => l_return_status
1276 ,x_msg_count => l_msg_count
1277 ,x_msg_data => l_msg_data
1278 ,p_admin_rec => l_admin_rec
1279 ,p_mode => l_mode
1280 ,x_resource_id => l_resource_id
1281 ,x_resource_number => l_resource_number);
1282
1283 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1284 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1285 RAISE FND_API.G_EXC_ERROR;
1286 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1287 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1288 END IF;
1289 END IF;
1290
1291 -- After successful creation of partner resource, create role for the resource,
1292 -- created in the previous step by calling Admin_Role API from PVX_MISC_PVT package.
1293
1294 -- Initilize the l_admin_rec with required values.
1295 l_admin_rec.role_resource_id := l_resource_id;
1296 l_admin_rec.role_resource_type := 'RS_INDIVIDUAL';
1297 l_admin_rec.role_code := 'PARTNER_ORGANIZATION';
1298
1299
1300 PVX_MISC_PVT.Admin_Role(
1301 p_api_version => 1.0
1302 ,p_init_msg_list => FND_API.g_false
1303 ,p_commit => FND_API.g_false
1304 ,x_return_status => l_return_status
1305 ,x_msg_count => l_msg_count
1306 ,x_msg_data => l_msg_data
1307 ,p_admin_rec => l_admin_rec
1308 ,p_mode => FND_API.G_MISS_CHAR
1309 ,x_role_relate_id => l_role_relate_id);
1310
1311 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1312 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1313 RAISE FND_API.G_EXC_ERROR;
1314 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1315 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1316 END IF;
1317 END IF;
1318
1319 -- After successful creation of resource role, create Group for the
1320 -- partner resource by calling Admin_Group API from PVX_MISC_PVT package.
1321
1322 -- Initilize the l_admin_rec with required values.
1323 l_admin_rec.role_resource_id := l_resource_id;
1324 l_admin_rec.resource_number := l_resource_number;
1325
1326 -- Create the Group
1327 PVX_MISC_PVT.Admin_Group(
1328 p_api_version => 1.0
1329 ,p_init_msg_list => FND_API.g_false
1330 ,p_commit => FND_API.g_false
1331 ,x_return_status => l_return_status
1332 ,x_msg_count => l_msg_count
1333 ,x_msg_data => l_msg_data
1334 ,p_admin_rec => l_admin_rec
1335 ,p_mode => FND_API.G_MISS_CHAR
1336 ,x_group_id => l_group_id
1337 ,x_group_number => l_group_number
1338 ,x_group_usage_id => l_group_usage_id
1339 ,x_group_member_id => l_group_member_id);
1340
1341 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1342 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1343 RAISE FND_API.G_EXC_ERROR;
1344 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1345 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1346 END IF;
1347 END IF;
1348
1349 -- set the out variables
1350 x_group_id := l_group_id ;
1351
1352 -- Create the partner profile by calling Create_Prtnr_Prfls API from
1353 -- PVX_PRTNR_PRFLS_PVT package.
1354
1355 -- Initialize the auto_match_allowed_flag.
1356 l_prtnr_prfls_rec.auto_match_allowed_flag := 'N';
1357 l_prtnr_prfls_rec.lead_share_appr_flag := 'N';
1358 l_prtnr_prfls_rec.sales_partner_flag := 'N';
1359 l_prtnr_prfls_rec.indirectly_managed_flag := 'N';
1360
1361 l_prtnr_prfls_rec.partner_id := l_partner_id;
1362 l_prtnr_prfls_rec.partner_relationship_id := l_relationship_id;
1363 l_prtnr_prfls_rec.partner_resource_id := l_resource_id;
1364 l_prtnr_prfls_rec.partner_group_id := l_group_id;
1365 l_prtnr_prfls_rec.partner_group_number := l_group_number;
1366 l_prtnr_prfls_rec.partner_party_id := l_party_id;
1367
1368 -- Added to add default partner level during create partner in case
1369 -- of Invite Partner or Customer to Partner conversion for bug # 3418136.
1370 l_prtnr_prfls_rec.partner_level := fnd_profile.value('PV_DEFAULT_PARTNER_LEVEL');
1371
1372 -- Removing the reference of SALES_PARTNER_FLAG in case of Partner Type
1373 -- is 'VAD' or 'RESELLER'.
1374 -- Set the Sales_Partner_Flag based on the Partner types.
1375 -- FOR i IN p_partner_types_tbl.first..p_partner_types_tbl.last LOOP
1376 -- l_partner_types := p_partner_types_tbl(i).attr_value ;
1377 -- IF l_partner_types= 'RESELLER' or l_partner_types = 'VAD' THEN
1378 -- l_prtnr_prfls_rec.sales_partner_flag := 'Y';
1379 -- EXIT;
1380 -- END IF;
1381 -- END LOOP;
1382
1383 -- Call the Create_Prtnr_Prfls API.
1384 PVX_PRTNR_PRFLS_PVT.Create_Prtnr_Prfls (
1385 p_api_version => 1.0
1386 ,p_init_msg_list => FND_API.g_false
1387 ,p_commit => FND_API.g_false
1388 ,p_validation_level => FND_API.g_valid_level_full
1389 ,x_return_status => l_return_status
1390 ,x_msg_count => l_msg_count
1391 ,x_msg_data => l_msg_data
1392 ,p_prtnr_prfls_rec => l_prtnr_prfls_rec
1393 ,x_partner_profile_id => l_partner_profile_id );
1394
1395 -- Check the return status.
1396 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1397 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1398 RAISE FND_API.G_EXC_ERROR;
1399 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1400 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1401 END IF;
1402 END IF;
1403
1404 -- Add all Partner types in the attribute table by calling
1405 -- Upsert_Attr_Value API from PV_ENTY_ATTR_VALUE_PUB package.
1406
1407 FOR I IN p_partner_types_tbl.first..p_partner_types_tbl.last
1408 LOOP
1409 l_partner_types := p_partner_types_tbl(I).attr_value;
1410 l_attr_value_tbl(I).attr_value:= l_partner_types;
1411 l_attr_value_tbl(I).attr_value_extn := p_partner_types_tbl(I).attr_value_extn;
1412 END LOOP;
1413
1414 -- Call the API to insert the partner types in the attribute table.
1415 PV_ENTY_ATTR_VALUE_PUB.Upsert_Attr_Value (
1416 p_api_version_number=> 1.0
1417 ,p_init_msg_list => FND_API.g_false
1418 ,p_commit => FND_API.g_false
1419 ,p_validation_level => FND_API.g_valid_level_full
1420 ,x_return_status => l_return_status
1421 ,x_msg_count => l_msg_count
1422 ,x_msg_data => l_msg_data
1423 ,p_attribute_id => 3
1424 ,p_entity => 'PARTNER'
1425 ,p_entity_id => l_partner_id
1426 ,p_version => 0
1427 ,p_attr_val_tbl => l_attr_value_tbl
1428 );
1429
1430 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1431 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1432 RAISE FND_API.G_EXC_ERROR;
1433 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1434 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1435 END IF;
1436 END IF;
1437
1438 -- Call Register_term_ptr_memb_type API from Pv_ptr_member_type_pvt package
1439 -- to tag a partner with a member type.
1440
1441 Pv_ptr_member_type_pvt.Register_term_ptr_memb_type (
1442 p_api_version_number => 1.0
1443 ,p_init_msg_list => FND_API.G_FALSE
1444 ,p_commit => FND_API.G_FALSE
1445 ,p_validation_level => FND_API.G_VALID_LEVEL_FULL
1446 ,p_partner_id => l_partner_id
1447 ,p_current_memb_type => null
1448 ,p_new_memb_type => p_member_type
1449 ,p_global_ptr_id => p_global_partner_id
1450 ,x_return_status => l_return_status
1451 ,x_msg_count => l_msg_count
1452 ,x_msg_data => l_msg_data );
1453
1454 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1455 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1456 RAISE FND_API.G_EXC_ERROR;
1457 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1458 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1459 END IF;
1460 END IF;
1461
1462 -- Create the Channel Team
1463 /*
1464 PV_TERR_ASSIGN_PUB.Create_Channel_Team (
1465 p_api_version_number => 1.0,
1466 p_init_msg_list => FND_API.G_FALSE ,
1467 p_commit => FND_API.G_FALSE ,
1468 p_validation_level => FND_API.G_VALID_LEVEL_FULL ,
1469 p_partner_id => l_partner_id,
1470 p_vad_partner_id => p_vad_partner_id,
1471 p_mode => 'CREATE',
1472 p_login_user => l_user_id,
1473 x_return_status => l_return_status,
1474 x_msg_count => l_msg_count,
1475 x_msg_data => l_msg_data,
1476 x_prtnr_access_id_tbl => l_prtnr_access_id_tbl
1477 );
1478 */
1479 -- Change the call to create channel team with qualifiers record
1480
1481
1482 PV_TERR_ASSIGN_PUB.Do_Create_Channel_Team (
1483 p_api_version_number => 1.0,
1484 p_init_msg_list => FND_API.G_FALSE ,
1485 p_commit => FND_API.G_FALSE ,
1486 p_validation_level => FND_API.G_VALID_LEVEL_FULL ,
1487 p_partner_id => l_partner_id,
1488 p_vad_partner_id => p_vad_partner_id,
1489 p_mode => 'CREATE',
1490 p_login_user => l_user_id,
1491 p_partner_qualifiers_tbl => l_partner_qualifiers_tbl,
1492 x_return_status => l_return_status,
1493 x_msg_count => l_msg_count,
1494 x_msg_data => l_msg_data,
1495 x_prtnr_access_id_tbl => l_prtnr_access_id_tbl
1496 );
1497
1498
1499 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1500 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1501 RAISE FND_API.G_EXC_ERROR;
1502 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1503 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1504 END IF;
1505 END IF;
1506
1507 -- Debug Message
1508 IF (PV_DEBUG_HIGH_ON) THEN
1509 PVX_UTILITY_PVT.debug_message('Prior to calling Create_Default_Membership API ');
1510 END IF;
1511
1512 pv_prgm_approval_pvt.Create_Default_Membership (
1513 p_api_version_number => p_api_version_number
1514 ,p_init_msg_list => FND_API.g_false
1515 ,p_commit => FND_API.G_FALSE
1516 ,p_validation_level => FND_API.G_VALID_LEVEL_FULL
1517 ,p_partner_id => l_partner_id
1518 ,p_requestor_resource_id => -1
1519 ,x_return_status => l_return_status
1520 ,x_msg_count => l_msg_count
1521 ,x_msg_data => l_msg_data
1522 );
1523
1524 -- Debug Message
1525 IF (PV_DEBUG_HIGH_ON) THEN
1526 PVX_UTILITY_PVT.debug_message('After call to Create_Default_Membership API. l_return_status: ' || l_return_status);
1527 END IF;
1528
1529 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1530 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1531 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1532 RAISE FND_API.G_EXC_ERROR;
1533 END IF;
1534
1535 -- Debug Message
1536 IF (PV_DEBUG_HIGH_ON) THEN
1537 PVX_UTILITY_PVT.debug_message('Prior to calling update_elig_prgm_4_new_ptnr ');
1538 END IF;
1539
1540
1541 PV_USER_MGMT_PVT.update_elig_prgm_4_new_ptnr(
1542 p_api_version_number => p_api_version_number
1543 ,p_init_msg_list => FND_API.g_false
1544 ,p_commit => FND_API.G_FALSE
1545 ,p_validation_level => FND_API.g_valid_level_full
1546 ,x_return_status => l_return_status
1547 ,x_msg_count => l_msg_count
1548 ,x_msg_data => l_msg_data
1549 ,p_partner_id => l_partner_id
1550 ,p_member_type => NULL
1551 );
1552
1553 -- Debug Message
1554 IF (PV_DEBUG_HIGH_ON) THEN
1555 PVX_UTILITY_PVT.debug_message('After call to update_elig_prgm_4_new_ptnr API. l_return_status: ' || l_return_status);
1556 END IF;
1557
1558 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1559 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1560 ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
1561 RAISE FND_API.G_EXC_ERROR;
1562 END IF;
1563
1564
1565 -- Standard check for p_commit
1566 IF FND_API.to_Boolean( p_commit )
1567 THEN
1568 COMMIT WORK;
1569 END IF;
1570
1571 -- Debug Message
1572 IF (PV_DEBUG_HIGH_ON) THEN
1573 PVX_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'end');
1574 END IF;
1575
1576 -- Standard call to get message count and if count is 1, get message info.
1577 FND_MSG_PUB.Count_And_Get
1578 (p_count => x_msg_count,
1579 p_data => x_msg_data
1580 );
1581
1582
1583
1584
1585 EXCEPTION
1586
1587 WHEN PVX_UTILITY_PVT.resource_locked THEN
1588 x_return_status := FND_API.g_ret_sts_error;
1589 PVX_UTILITY_PVT.Error_Message(p_message_name => 'PV_API_RESOURCE_LOCKED');
1590
1591 WHEN FND_API.G_EXC_ERROR THEN
1592 ROLLBACK TO create_relationship_pvt;
1593 x_return_status := FND_API.G_RET_STS_ERROR;
1594 -- Standard call to get message count and if count=1, get the message
1595 FND_MSG_PUB.Count_And_Get (
1596 p_encoded => FND_API.G_FALSE,
1597 p_count => x_msg_count,
1598 p_data => x_msg_data
1599 );
1600
1601 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1602 ROLLBACK TO create_relationship_pvt;
1603 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1604 -- Standard call to get message count and if count=1, get the message
1605 FND_MSG_PUB.Count_And_Get (
1606 p_encoded => FND_API.G_FALSE,
1607 p_count => x_msg_count,
1608 p_data => x_msg_data
1609 );
1610
1611 WHEN OTHERS THEN
1612 ROLLBACK TO create_relationship_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) THEN
1615 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1616 END IF;
1617
1618 -- Standard call to get message count and if count=1, get the message
1619 FND_MSG_PUB.Count_And_Get (
1620 p_encoded => FND_API.G_FALSE,
1621 p_count => x_msg_count,
1622 p_data => x_msg_data );
1623
1624 END Do_Create_Relationship;
1625
1626 /*============================================================================
1627 -- Start of comments
1628 -- API name : Create_Relationship
1629 -- Type : Public.
1630 -- Function : This API consolidates few partner creation related operations in
1631 -- single API call. These operations are as follows -
1632 -- * Get the vendor Organization based on the default
1633 -- responsibility for the supplied partner org id.
1634 -- * Create a relationship record between Vendor Org and the Partner Org
1635 -- * Create Resource for the partner
1636 -- * Create role for the above resource
1637 -- * Create Group for the above resource
1638 -- * Create Partner Profile
1639 -- * Add Channel Manager in Channel Team from TAP
1640 -- * Add Partner types to Attributes table
1641 -- * If partner type is subsidiary, establish a relationship with the global partner
1642 --
1643 -- Pre-reqs : None.
1644 -- Parameters :
1645 -- IN : p_api_version IN NUMBER Required
1646 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
1647 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
1648 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
1649 --
1650 -- p_party_id IN NUMBER Required
1651 -- p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.ATTR_VALUE_TBL_TYPE
1652 -- p_vad_partner_id IN NUMBER
1653 -- p_member_type IN VARCHAR2
1654 -- p_global_partner_id IN NUMBER
1655 --
1656 -- OUT : x_return_status OUT VARCHAR2(1)
1657 -- x_msg_count OUT NUMBER
1658 -- x_msg_data OUT VARCHAR2(2000)
1659 -- x_partner_id OUT NUMBER
1660 -- x_default_resp_id OUT NUMBER
1661 -- x_resp_map_rule_id OUT NOCOPY NUMBER
1662 -- x_group_id OUT NOCOPY NUMBER
1663 --
1664 -- Version : Current version 1.0
1665 -- Initial version 1.0
1666 --
1667 -- Notes : Note text
1668 --
1669 -- End of comments
1670 ============================================================================*/
1671 PROCEDURE Create_Relationship(
1672 p_api_version_number IN NUMBER
1673 ,p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
1674 ,p_commit IN VARCHAR2 := FND_API.G_FALSE
1675 ,p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
1676 ,x_return_status OUT NOCOPY VARCHAR2
1677 ,x_msg_data OUT NOCOPY VARCHAR2
1678 ,x_msg_count OUT NOCOPY NUMBER
1679 ,p_party_id IN NUMBER
1680 -- ,p_partner_types_tbl IN partner_types_tbl_type := g_miss_partner_types_tbl
1681 ,p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.attr_value_tbl_type
1682 ,p_vad_partner_id IN NUMBER
1683 ,p_member_type IN VARCHAR2
1684 ,p_global_partner_id IN NUMBER
1685 ,x_partner_id OUT NOCOPY NUMBER
1686 ,x_default_resp_id OUT NOCOPY NUMBER
1687 ,x_resp_map_rule_id OUT NOCOPY NUMBER
1688 ,x_group_id OUT NOCOPY NUMBER
1689 ) IS
1690
1691 L_API_NAME CONSTANT VARCHAR2(30) := 'Create_Relationship';
1692 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1693
1694
1695 --Table for qualifier records
1696 l_partner_qualifiers_tbl PV_TERR_ASSIGN_PUB.partner_qualifiers_tbl_type;
1697 l_party_id NUMBER := p_party_id;
1698
1699 -- Local variable declaration for Standard Out variables.
1700 l_return_status VARCHAR2(1);
1701 l_msg_count NUMBER;
1702 l_msg_data VARCHAR2(2000);
1703
1704 BEGIN
1705
1706 -- Initialize API return status to SUCCESS
1707 x_return_status := FND_API.G_RET_STS_SUCCESS;
1708
1709 SAVEPOINT create_relationship_pvt;
1710 --Code to build the qualifiers rec and call the relationshi API
1711
1712 PV_TERR_ASSIGN_PUB. get_partner_details(
1713 p_party_id => l_party_id ,
1714 x_return_status => l_return_status ,
1715 x_msg_count => l_msg_count ,
1716 x_msg_data => l_msg_data ,
1717 x_partner_qualifiers_tbl => l_partner_qualifiers_tbl );
1718
1719 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1720 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1721 RAISE FND_API.G_EXC_ERROR;
1722 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1723 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1724 END IF;
1725 END IF;
1726
1727
1728 Do_Create_Relationship(
1729 p_api_version_number => 1.0
1730 ,p_init_msg_list => FND_API.G_FALSE
1731 ,p_commit => FND_API.G_FALSE
1732 ,p_validation_level => FND_API.G_VALID_LEVEL_FULL
1733 ,x_return_status => l_return_status
1734 ,x_msg_data => l_msg_data
1735 ,x_msg_count => l_msg_count
1736 ,p_party_id => l_party_id
1737 ,p_partner_types_tbl => p_partner_types_tbl
1738 ,p_vad_partner_id => p_vad_partner_id
1739 ,p_member_type => p_member_type
1740 ,p_global_partner_id => p_global_partner_id
1741 ,p_partner_qualifiers_tbl => l_partner_qualifiers_tbl
1742 ,x_partner_id => x_partner_id
1743 ,x_default_resp_id => x_default_resp_id
1744 ,x_resp_map_rule_id => x_resp_map_rule_id
1745 ,x_group_id => x_group_id
1746 );
1747
1748 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1749 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1750 RAISE FND_API.G_EXC_ERROR;
1751 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1752 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1753 END IF;
1754 END IF;
1755
1756
1757
1758 --PINAGARA Changes for the ER # 4715607
1759 --Call the API to create party site uses BILL_TO and SHIP_TO
1760
1761 Create_Party_Site_Uses (
1762 p_party_id => l_party_id
1763 ,x_return_status => l_return_status
1764 ,x_msg_data => l_msg_count
1765 ,x_msg_count => l_msg_data);
1766
1767
1768 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1769 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
1770 RAISE FND_API.G_EXC_ERROR;
1771 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1772 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1773 END IF;
1774 END IF;
1775
1776
1777 EXCEPTION
1778
1779
1780 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1781 ROLLBACK TO create_relationship_pvt;
1782 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1783 -- Standard call to get message count and if count=1, get the message
1784 FND_MSG_PUB.Count_And_Get (
1785 p_encoded => FND_API.G_FALSE,
1786 p_count => x_msg_count,
1787 p_data => x_msg_data
1788 );
1789
1790 WHEN OTHERS THEN
1791 ROLLBACK TO create_relationship_pvt;
1792 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1793 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
1794 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
1795 END IF;
1796
1797 -- Standard call to get message count and if count=1, get the message
1798 FND_MSG_PUB.Count_And_Get (
1799 p_encoded => FND_API.G_FALSE,
1800 p_count => x_msg_count,
1801 p_data => x_msg_data );
1802
1803 End Create_Relationship;
1804
1805 /*============================================================================
1806 -- Start of comments
1807 -- API name : Invite_Partner
1808 -- Type : Public.
1809 -- Function : Detail has to be entered.
1810 --
1811 -- Pre-reqs : None.
1812 -- Parameters :
1813 -- IN : p_api_version IN NUMBER Required
1814 -- p_init_msg_list IN VARCHAR2 Optional Default = FND_API.G_FALSE
1815 -- p_commit IN VARCHAR2 Optional Default = FND_API.G_FALSE
1816 -- p_validation_level IN NUMBER Optional Default = FND_API.G_VALID_LEVEL_FULL
1817 --
1818 -- p_party_id IN NUMBER Required
1819 -- p_partner_types IN JTF_VARCHAR2 Required
1820 -- p_vad_partner_id IN NUMBER
1821 -- p_member_type IN VARCHAR2
1822 -- p_global_partner_id IN NUMBER
1823 --
1824 -- OUT : x_return_status OUT VARCHAR2(1)
1825 -- x_msg_count OUT NUMBER
1826 -- x_msg_data OUT VARCHAR2(2000)
1827 -- x_partner_id OUT NUMBER
1828 -- x_default_resp_id OUT NUMBER
1829 -- x_resp_map_rule_id OUT NOCOPY NUMBER
1830 -- x_group_id OUT NOCOPY NUMBER
1831 --
1832 -- Version : Current version 1.0
1833 -- Initial version 1.0
1834 --
1835 -- Notes : Note text
1836 --
1837 -- End of comments
1838 ============================================================================*/
1839 PROCEDURE Invite_Partner(
1840 p_api_version_number IN NUMBER
1841 ,p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
1842 ,p_commit IN VARCHAR2 := FND_API.G_FALSE
1843 ,p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL
1844 ,x_return_status OUT NOCOPY VARCHAR2
1845 ,x_msg_data OUT NOCOPY VARCHAR2
1846 ,x_msg_count OUT NOCOPY NUMBER
1847 /*
1848 ,p_organization_rec IN HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE
1849 ,p_location_rec IN PV_PARTNER_UTIL_PVT.LOCATION_REC_TYPE
1850 ,p_party_site_rec IN HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE
1851 */
1852
1853 ,p_party_id IN Number
1854 ,p_partner_qualifiers_tbl IN PV_TERR_ASSIGN_PUB.partner_qualifiers_tbl_type
1855 -- ,p_partner_types_tbl IN partner_types_tbl_type
1856 ,p_partner_types_tbl IN PV_ENTY_ATTR_VALUE_PUB.attr_value_tbl_type
1857 ,p_vad_partner_id IN NUMBER
1858 ,p_person_rec IN PV_PARTNER_UTIL_PVT.PERSON_REC_TYPE
1859 ,p_phone_rec IN HZ_CONTACT_POINT_V2PUB.PHONE_REC_TYPE
1860 ,p_email_rec IN HZ_CONTACT_POINT_V2PUB.EMAIL_REC_TYPE
1861 ,p_member_type IN VARCHAR2
1862 ,p_global_partner_id IN NUMBER
1863 ,x_partner_party_id OUT NOCOPY NUMBER
1864 ,x_partner_id OUT NOCOPY NUMBER
1865 ,x_cnt_party_id OUT NOCOPY NUMBER
1866 ,x_cnt_partner_id OUT NOCOPY NUMBER
1867 ,x_cnt_rel_start_date OUT NOCOPY DATE
1868 ,x_default_resp_id OUT NOCOPY NUMBER
1869 ,x_resp_map_rule_id OUT NOCOPY NUMBER
1870 ,x_group_id OUT NOCOPY NUMBER
1871 ) IS
1872 L_API_NAME CONSTANT VARCHAR2(30) := 'Invite_Partner';
1873 L_API_VERSION_NUMBER CONSTANT NUMBER := 1.0;
1874
1875 -- Cursor l_partner_csr to get partner details
1876 CURSOR l_partner_csr (cv_party_id NUMBER) IS
1877 SELECT partner_id
1878 FROM pv_partner_profiles
1879 WHERE partner_party_id = cv_party_id;
1880
1881
1882 -- Details of local variables used in Create_Partner API call.
1883 -- l_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE := p_organization_rec;
1884 -- l_location_rec PV_PARTNER_UTIL_PVT.LOCATION_REC_TYPE := p_location_rec;
1885 -- l_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE := p_party_site_rec;
1886 l_partner_types_tbl PV_ENTY_ATTR_VALUE_PUB.attr_value_tbl_type := p_partner_types_tbl;
1887 l_partner_id NUMBER ;
1888 l_vad_partner_id NUMBER := p_vad_partner_id;
1889 l_member_type VARCHAR2(30) := p_member_type;
1890 l_global_partner_id NUMBER := p_global_partner_id;
1891 l_partner_party_id NUMBER;
1892 l_default_resp_id NUMBER;
1893 l_resp_map_rule_id NUMBER;
1894 l_group_id NUMBER;
1895
1896 l_party_id NUMBER := p_party_id;
1897 l_partner_qualifiers_tbl PV_TERR_ASSIGN_PUB.partner_qualifiers_tbl_type := p_partner_qualifiers_tbl;
1898 -- Details of local variables used in Create_Person API call.
1899 l_person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE := HZ_PARTY_V2PUB.g_miss_person_rec;
1900 l_cnt_per_party_id NUMBER;
1901 l_cnt_per_party_number NUMBER;
1902 l_cnt_per_profile_id NUMBER;
1903
1904
1905 -- Details of local variables used in Create_Org_Contact API call.
1906 l_org_contact_rec HZ_PARTY_CONTACT_V2PUB.org_contact_rec_type ;
1907 l_org_contact_id NUMBER;
1908 l_contact_rel_id NUMBER;
1909 l_contact_rel_party_id NUMBER;
1910 l_person_party_number NUMBER;
1911
1912 -- Details of local variables used in Create_Phone_Contact_Point API call.
1913 l_contact_point_rec HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE ;
1914 l_phone_rec HZ_CONTACT_POINT_V2PUB.PHONE_REC_TYPE := p_phone_rec;
1915 l_phone_cnt_point_id NUMBER;
1916
1917 -- Details of local variables used in Create_Email_Contact_Point API call.
1918 l_email_rec HZ_CONTACT_POINT_V2PUB.EMAIL_REC_TYPE := p_email_rec;
1919 l_email_cnt_point_id NUMBER;
1920
1921 -- Some common local variables used by all the API call.
1922 l_application_id NUMBER := 691; -- FND_GLOBAL.application_id;
1923 l_appl_short_name VARCHAR2(5) := 'PV'; -- FND_GLOBAL.APPLICATION_SHORT_NAME;
1924
1925 -- Local variable declaration for Standard Out variables.
1926 l_return_status VARCHAR2(1);
1927 l_msg_count NUMBER;
1928 l_msg_data VARCHAR2(2000);
1929
1930 BEGIN
1931
1932 -- Standard Start of API savepoint
1933 SAVEPOINT invite_partner_pvt;
1934
1935 -- Standard call to check for call compatibility.
1936 IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
1937 p_api_version_number,
1938 l_api_name,
1939 G_PKG_NAME)
1940 THEN
1941 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1942 END IF;
1943
1944 -- Initialize message list if p_init_msg_list is set to TRUE.
1945 IF FND_API.to_Boolean( p_init_msg_list )
1946 THEN
1947 FND_MSG_PUB.initialize;
1948 END IF;
1949
1950 -- Debug Message
1951 PVX_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'start');
1952
1953 -- Initialize API return status to SUCCESS
1954 x_return_status := FND_API.G_RET_STS_SUCCESS;
1955
1956 -- Local variable initialization
1957
1958
1959 -- Call the Create_Partner API to create the following -
1960 -- * Partner Organization record in HZ_PARTIES table
1961 -- * Partner Location record in HZ_LOCATIONS table
1962 -- * Partner Party Site record in HZ_PARTY_SITES table
1963 -- * Call the Create_Relationship API to create the followings -
1964 -- o Get the Default responsibility for the supplied Organization Id
1965 -- o Get the default vendor org id, for the supplied Responsibility id
1966 -- o Create Partner Relationship record in HZ_RELATIONSHIPS table
1967 -- o Create resource for the partner by calling the Admin_Resource API
1968 -- o Create role for the resource by calling Admin_Role API
1969 -- o Create Group for the partner resource by calling Admin_Group API
1970
1971 /*
1972 Create_Partner(
1973 p_api_version_number => 1.0,
1974 p_init_msg_list => FND_API.G_FALSE ,
1975 p_commit => FND_API.G_FALSE ,
1976 p_validation_level => FND_API.G_VALID_LEVEL_FULL ,
1977 x_return_status => l_return_status,
1978 x_msg_count => l_msg_count,
1979 x_msg_data => l_msg_data,
1980 p_organization_rec => l_organization_rec ,
1981 p_location_rec => l_location_rec,
1982 p_party_site_rec => l_party_site_rec,
1983 p_partner_types_tbl => l_partner_types_tbl,
1984 p_vad_partner_id => l_vad_partner_id,
1985 p_member_type => l_member_type,
1986 p_global_partner_id => l_global_partner_id ,
1987 x_party_id => l_partner_party_id,
1988 x_default_resp_id => l_default_resp_id,
1989 x_resp_map_rule_id => l_resp_map_rule_id ,
1990 x_group_id => l_group_id );
1991
1992 */
1993
1994
1995 Do_Create_Relationship(
1996 p_api_version_number => 1.0
1997 ,p_init_msg_list => FND_API.G_FALSE
1998 ,p_commit => FND_API.G_FALSE
1999 ,p_validation_level => FND_API.G_VALID_LEVEL_FULL
2000 ,x_return_status => l_return_status
2001 ,x_msg_data => l_msg_data
2002 ,x_msg_count => l_msg_count
2003 ,p_party_id => l_party_id
2004 ,p_partner_types_tbl => p_partner_types_tbl
2005 ,p_vad_partner_id => p_vad_partner_id
2006 ,p_member_type => p_member_type
2007 ,p_global_partner_id => p_global_partner_id
2008 ,p_partner_qualifiers_tbl => l_partner_qualifiers_tbl
2009 ,x_partner_id => x_partner_id
2010 ,x_default_resp_id => x_default_resp_id
2011 ,x_resp_map_rule_id => x_resp_map_rule_id
2012 ,x_group_id => x_group_id
2013 );
2014
2015
2016 -- Check for return status of the API call.
2017 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2018 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2019 RAISE FND_API.G_EXC_ERROR;
2020 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2021 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2022 END IF;
2023 END IF;
2024
2025 Create_Search_Attr_Values (
2026 p_api_version_number => 1.0
2027 ,p_init_msg_list => FND_API.G_FALSE
2028 ,p_commit => FND_API.G_FALSE
2029 ,x_return_status => l_return_status
2030 ,x_msg_data => l_msg_data
2031 ,x_msg_count => l_msg_count
2032 ,p_partner_id => x_partner_id
2033 );
2034
2035 -- Check for return status of the API call.
2036 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2037 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2038 RAISE FND_API.G_EXC_ERROR;
2039 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2040 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2041 END IF;
2042 END IF;
2043
2044
2045 -- Map the person-rec from PV_PARTNER_UTIL_PVT's person_rec_type to
2046 -- HZ_PARTY_V2PUB's person_rec_type
2047 map_person_rec( p_person_rec => p_person_rec,
2048 x_person_rec => l_person_rec);
2049
2050 -- Call the Create_Person API to create the contact person as a Party record
2051 -- in HZ_PARTIES table.
2052 HZ_PARTY_V2PUB.create_person (
2053 p_init_msg_list => FND_API.G_FALSE,
2054 p_person_rec => l_person_rec,
2055 x_party_id => l_cnt_per_party_id,
2056 x_party_number => l_cnt_per_party_number,
2057 x_profile_id => l_cnt_per_profile_id,
2058 x_return_status => l_return_status,
2059 x_msg_count => l_msg_count,
2060 x_msg_data => l_msg_data);
2061
2062 -- Check for return status of the API call.
2063 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2064 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2065 RAISE FND_API.G_EXC_ERROR;
2066 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2067 FND_MESSAGE.SET_NAME('PV', 'PV_API_FAILED');
2068 FND_MESSAGE.SET_TOKEN('API_NAME', 'HZ_PARTY_V2PUB.create_person');
2069 FND_MSG_PUB.Add;
2070 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2071 END IF;
2072 END IF;
2073
2074 -- Iniliatize the local variables required for Relationship creation
2075 -- between the Contact and the Partner Organinzation.
2076 l_org_contact_rec.application_id := l_application_id;
2077 l_org_contact_rec.created_by_module:= l_appl_short_name;
2078 l_org_contact_rec.party_rel_rec.subject_id := l_cnt_per_party_id;
2079 l_org_contact_rec.party_rel_rec.subject_type := 'PERSON';
2080 l_org_contact_rec.party_rel_rec.subject_table_name := 'HZ_PARTIES';
2081 l_org_contact_rec.party_rel_rec.object_id := l_party_id ;
2082 l_org_contact_rec.party_rel_rec.object_type := 'ORGANIZATION';
2083 l_org_contact_rec.party_rel_rec.object_table_name := 'HZ_PARTIES';
2084 l_org_contact_rec.party_rel_rec.relationship_code := 'EMPLOYEE_OF';
2085 l_org_contact_rec.party_rel_rec.relationship_type := 'EMPLOYMENT';
2086 l_org_contact_rec.party_rel_rec.start_date := SYSDATE;
2087 l_org_contact_rec.party_rel_rec.created_by_module:= l_appl_short_name;
2088 l_org_contact_rec.party_rel_rec.application_id:= l_application_id;
2089 l_org_contact_rec.party_rel_rec.status:= 'A';
2090
2091 -- Call the Create_Org_Contact API to create a contact person relationship record
2092 -- with the Partner organization in HZ_RELATIONSHIPS table.
2093 HZ_PARTY_CONTACT_V2PUB.create_org_contact (
2094 p_init_msg_list => FND_API.G_FALSE,
2095 p_org_contact_rec => l_org_contact_rec,
2096 x_org_contact_id => l_org_contact_id,
2097 x_party_rel_id => l_contact_rel_id,
2098 x_party_id => l_contact_rel_party_id,
2099 x_party_number => l_person_party_number,
2100 x_return_status => l_return_status,
2101 x_msg_count => l_msg_count,
2102 x_msg_data => l_msg_data);
2103
2104 -- Check for return status of the API call.
2105 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2106 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2107 RAISE FND_API.G_EXC_ERROR;
2108 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2109 FND_MESSAGE.SET_NAME('PV', 'PV_API_FAILED');
2110 FND_MESSAGE.SET_TOKEN('API_NAME', 'HZ_PARTY_CONTACT_V2PUB.create_org_contact');
2111 FND_MSG_PUB.Add;
2112 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2113 END IF;
2114 END IF;
2115
2116 -- Call the create_phone_contact_point API to create a Phone type Contact Point record
2117 -- in HZ_CONTACT_POINTS table.
2118
2119 l_contact_point_rec.owner_table_name := 'HZ_PARTIES';
2120 l_contact_point_rec.owner_table_id := l_contact_rel_party_id;
2121 l_contact_point_rec.status := 'A';
2122 l_contact_point_rec.primary_flag := 'Y';
2123 l_contact_point_rec.contact_point_type := 'PHONE';
2124 l_contact_point_rec.application_id := l_application_id;
2125 l_contact_point_rec.created_by_module:= l_appl_short_name;
2126 l_phone_rec.phone_line_type := 'GEN';
2127
2128 HZ_CONTACT_POINT_V2PUB.create_phone_contact_point (
2129 p_init_msg_list => FND_API.G_TRUE,
2130 p_contact_point_rec => l_contact_point_rec,
2131 p_phone_rec => l_phone_rec,
2132 x_contact_point_id => l_phone_cnt_point_id,
2133 x_return_status => l_return_status,
2134 x_msg_count => l_msg_count,
2135 x_msg_data => l_msg_data);
2136
2137 -- Check for return status of the API call.
2138 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2139 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2140 RAISE FND_API.G_EXC_ERROR;
2141 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2142 FND_MESSAGE.SET_NAME('PV', 'PV_API_FAILED');
2143 FND_MESSAGE.SET_TOKEN('API_NAME', 'HZ_CONTACT_POINT_V2PUB.create_phone_contact_point');
2144 FND_MSG_PUB.Add;
2145 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2146 END IF;
2147 END IF;
2148
2149 -- Call the create_email_contact_point API to create a Email type Contact Point record
2150 -- in HZ_CONTACT_POINTS table.
2151
2152 l_contact_point_rec.contact_point_type := 'EMAIL';
2153
2154 HZ_CONTACT_POINT_V2PUB.create_email_contact_point (
2155 p_init_msg_list => FND_API.G_FALSE,
2156 p_contact_point_rec => l_contact_point_rec,
2157 p_email_rec => l_email_rec,
2158 x_contact_point_id => l_email_cnt_point_id,
2159 x_return_status => l_return_status,
2160 x_msg_count => l_msg_count,
2161 x_msg_data => l_msg_data);
2162
2163 -- Check for return status of the API call.
2164 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2165 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2166 RAISE FND_API.G_EXC_ERROR;
2167 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2168 FND_MESSAGE.SET_NAME('PV', 'PV_API_FAILED');
2169 FND_MESSAGE.SET_TOKEN('API_NAME', 'HZ_CONTACT_POINT_V2PUB.create_email_contact_point');
2170 FND_MSG_PUB.Add;
2171 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2172 END IF;
2173 END IF;
2174
2175 -- set the out variables
2176 -- x_partner_party_id := l_partner_party_id;
2177 x_partner_party_id := l_party_id;
2178 x_cnt_party_id := l_cnt_per_party_id;
2179 x_cnt_partner_id := l_contact_rel_party_id;
2180 x_cnt_rel_start_date := l_org_contact_rec.party_rel_rec.start_date;
2181 x_default_resp_id := l_default_resp_id;
2182 x_resp_map_rule_id := l_resp_map_rule_id;
2183 x_group_id := l_group_id;
2184
2185 OPEN l_partner_csr(l_party_id);
2186 FETCH l_partner_csr INTO l_partner_id;
2187 CLOSE l_partner_csr;
2188 x_partner_id := l_partner_id;
2189
2190 -- Call Create_Default_Membership API to create membership into a
2191 -- default program to fix bug # 3435989.
2192
2193 -- Commented out by SPEDDU on 11/22/05 as this call is part of do_create_relationship API as part of fix bug # 4748978
2194
2195 /** pv_prgm_approval_pvt.Create_Default_Membership (
2196 p_api_version_number => 1.0
2197 ,p_init_msg_list => FND_API.G_FALSE
2198 ,p_commit => FND_API.G_FALSE
2199 ,p_validation_level => FND_API.G_VALID_LEVEL_FULL
2200 ,p_partner_id => l_partner_id
2201 ,p_requestor_resource_id => -1
2202 ,x_return_status => l_return_status
2203 ,x_msg_count => l_msg_count
2204 ,x_msg_data => l_msg_data);
2205
2206 -- Check for return status of the API call.
2207 IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
2208 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
2209 RAISE FND_API.G_EXC_ERROR;
2210 ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
2211 FND_MESSAGE.SET_NAME('PV', 'PV_API_FAILED');
2212 FND_MESSAGE.SET_TOKEN('API_NAME', 'PV_PRGM_APPROVAL_PVT.Create_Default_Membership');
2213 FND_MSG_PUB.Add;
2214 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2215 END IF;
2216 END IF;
2217 **/
2218
2219 -- Standard check for p_commit
2220 IF FND_API.to_Boolean( p_commit )
2221 THEN
2222 COMMIT WORK;
2223 END IF;
2224
2225 -- Debug Message
2226 IF (PV_DEBUG_HIGH_ON) THEN
2227 PVX_UTILITY_PVT.debug_message('Public API: ' || l_api_name || ' end.');
2228 END IF;
2229
2230 -- Standard call to get message count and if count is 1, get message info.
2231 FND_MSG_PUB.Count_And_Get
2232 (p_count => x_msg_count,
2233 p_data => x_msg_data
2234 );
2235
2236 EXCEPTION
2237
2238 WHEN PVX_UTILITY_PVT.resource_locked THEN
2239 x_return_status := FND_API.g_ret_sts_error;
2240 PVX_UTILITY_PVT.Error_Message(p_message_name => 'PV_API_RESOURCE_LOCKED');
2241
2242 WHEN FND_API.G_EXC_ERROR THEN
2243 ROLLBACK TO invite_partner_pvt;
2244 x_return_status := FND_API.G_RET_STS_ERROR;
2245 -- Standard call to get message count and if count=1, get the message
2246 FND_MSG_PUB.Count_And_Get (
2247 p_encoded => FND_API.G_FALSE,
2248 p_count => x_msg_count,
2249 p_data => x_msg_data
2250 );
2251
2252 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2253 ROLLBACK TO invite_partner_pvt;
2254 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2255 -- Standard call to get message count and if count=1, get the message
2256 FND_MSG_PUB.Count_And_Get (
2257 p_encoded => FND_API.G_FALSE,
2258 p_count => x_msg_count,
2259 p_data => x_msg_data
2260 );
2261
2262 WHEN OTHERS THEN
2263 ROLLBACK TO invite_partner_pvt;
2264 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2265 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
2266 FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
2267 END IF;
2268
2269 -- Standard call to get message count and if count=1, get the message
2270 FND_MSG_PUB.Count_And_Get (
2271 p_encoded => FND_API.G_FALSE,
2272 p_count => x_msg_count,
2273 p_data => x_msg_data );
2274
2275 End Invite_Partner;
2276
2277
2278 -- -------------------------------------------------------------------------------
2279 -- FUNCTION: can_see_all_partners
2280 --
2281 -- Given a resource_id, the function returns
2282 --
2283 -- 0 - if the resource does not have any of the following permissions:
2284 -- PV_UPDATE_ALL_PARTNERS, PV_VIEW_ALL_PARTNERS
2285 --
2286 -- 1 - if the resource has either or both or the permissions:
2287 -- PV_UPDATE_ALL_PARTNERS, PV_VIEW_ALL_PARTNERS
2288 --
2289 -- -------------------------------------------------------------------------------
2290 FUNCTION can_see_all_partners (
2291 p_resource_id IN NUMBER
2292 )
2293 RETURN NUMBER
2294 IS
2295 l_ret_val NUMBER := 0;
2296
2297 BEGIN
2298 FOR x IN (
2299 SELECT COUNT(*) cnt
2300 FROM jtf_rs_resource_extns jtfre,
2301 jtf_auth_principals_b jtfp1,
2302 jtf_auth_principal_maps jtfpm,
2303 jtf_auth_domains_b jtfd,
2304 jtf_auth_principals_b jtfp2,
2305 jtf_auth_role_perms jtfrp,
2306 jtf_auth_permissions_b jtfperm
2307 WHERE jtfre.resource_id = p_resource_id AND
2308 jtfre.user_name = jtfp1.principal_name AND
2309 jtfp1.is_user_flag = 1 AND
2310 jtfp1.jtf_auth_principal_id = jtfpm.jtf_auth_principal_id AND
2311 jtfpm.jtf_auth_domain_id = jtfd.jtf_auth_domain_id AND
2312 jtfd.domain_name = 'CRM_DOMAIN' AND
2313 jtfpm.jtf_auth_parent_principal_id = jtfp2.jtf_auth_principal_id AND
2314 jtfp2.is_user_flag = 0 AND
2315 jtfp2.jtf_auth_principal_id = jtfrp.jtf_auth_principal_id AND
2316 jtfrp.positive_flag = 1 AND
2317 jtfrp.jtf_auth_permission_id = jtfperm.jtf_auth_permission_id AND
2318 jtfperm.permission_name IN ('PV_UPDATE_ALL_PARTNERS', 'PV_VIEW_ALL_PARTNERS'))
2319 LOOP
2320 IF (x.cnt > 0) THEN
2321 l_ret_val := 1;
2322 END IF;
2323 END LOOP;
2324
2325 RETURN l_ret_val;
2326 END;
2327
2328
2329 END PV_PARTNER_UTIL_PVT;