[Home] [Help]
PACKAGE BODY: APPS.POS_SUPP_CONTACT_PKG
Source
1 PACKAGE BODY POS_SUPP_CONTACT_PKG AS
2 /*$Header: POSCONTB.pls 120.22.12010000.3 2008/09/11 18:35:49 jburugul ship $ */
3
4 g_module CONSTANT VARCHAR2(30) := 'POS_SUPP_CONTACT_PKG';
5
6 PROCEDURE create_org_contact_private
7 (p_vendor_party_id IN NUMBER,
8 p_person_party_id IN NUMBER,
9 p_job_title IN VARCHAR2,
10 p_inactive_date IN DATE DEFAULT NULL,
11 x_return_status OUT nocopy VARCHAR2,
12 x_msg_count OUT nocopy NUMBER,
13 x_msg_data OUT nocopy VARCHAR2,
14 x_rel_party_id OUT nocopy NUMBER
15 )
16 IS
17 l_rel_rec hz_relationship_v2pub.relationship_rec_type;
18 l_rel_party_rec hz_party_v2pub.party_rec_type;
19 l_rel_party_number hz_parties.party_number%TYPE;
20 l_rel_id NUMBER;
21 l_rel_party_id NUMBER;
22 l_org_contact_rec hz_party_contact_v2pub.org_contact_rec_type;
23 l_org_contact_id NUMBER;
24 l_method VARCHAR2(30);
25 l_step VARCHAR2(100);
26 BEGIN
27 l_method := 'create_org_contact_private';
28
29 l_rel_rec := NULL;
30 l_rel_party_rec := NULL;
31
32 l_rel_rec.object_id := p_vendor_party_id;
33 l_rel_rec.object_type := 'ORGANIZATION';
34 l_rel_rec.object_table_name := 'HZ_PARTIES';
35 l_rel_rec.subject_id := p_person_party_id;
36 l_rel_rec.subject_type := 'PERSON';
37 l_rel_rec.subject_table_name := 'HZ_PARTIES';
38 l_rel_rec.relationship_code := 'CONTACT_OF';
39 l_rel_rec.relationship_type := 'CONTACT';
40 l_rel_rec.start_date := Sysdate;
41 l_rel_rec.end_date := p_inactive_date;
42 l_rel_rec.created_by_module := 'POS_SUPPLIER_MGMT';
43 l_rel_rec.application_id := 177;
44 l_rel_rec.party_rec := l_rel_party_rec;
45 l_rel_rec.status := 'A';
46
47 l_org_contact_rec.created_by_module := 'POS_SUPPLIER_MGMT';
48 l_org_contact_rec.application_id := 177;
49 l_org_contact_rec.job_title := p_job_title;
50 l_org_contact_rec.party_rel_rec := l_rel_rec;
51
52 l_step := 'call hz_party_contact_v2pub.create_org_contact';
53 IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
54 fnd_log.string
55 ( fnd_log.level_statement
56 , g_module || '.' || l_method
57 , l_step
58 || ' with subject_id ' || l_rel_rec.subject_id
59 || ' object_id ' || l_rel_rec.object_id
60 || ' job_title ' || l_org_contact_rec.job_title
61 );
62 END IF;
63
64 hz_party_contact_v2pub.create_org_contact
65 (p_init_msg_list => fnd_api.g_false,
66 p_org_contact_rec => l_org_contact_rec,
67 x_return_status => x_return_status,
68 x_msg_count => x_msg_count,
69 x_msg_data => x_msg_data,
70 x_org_contact_id => l_org_contact_id,
71 x_party_rel_id => l_rel_id,
72 x_party_id => l_rel_party_id,
73 x_party_number => l_rel_party_number
74 );
75
76 pos_log.log_call_result
77 (p_module => 'POSCONTB',
78 p_prefix => 'call hz_party_v2pub.create_person',
79 p_return_status => x_return_status,
80 p_msg_count => x_msg_count,
81 p_msg_data => x_msg_data
82 );
83
84 IF x_return_status = fnd_api.g_ret_sts_success THEN
85 x_rel_party_id := l_rel_party_id;
86 END IF;
87
88 END create_org_contact_private;
89
90 PROCEDURE create_supplier_contact
91 (p_vendor_party_id IN NUMBER,
92 p_first_name IN VARCHAR2,
93 p_last_name IN VARCHAR2,
94 p_middle_name IN VARCHAR2 DEFAULT NULL,
95 p_contact_title IN VARCHAR2 DEFAULT NULL,
96 p_job_title IN VARCHAR2 DEFAULT NULL,
97 p_phone_area_code IN VARCHAR2 DEFAULT NULL,
98 p_phone_number IN VARCHAR2 DEFAULT NULL,
99 p_phone_extension IN VARCHAR2 DEFAULT NULL,
100 p_fax_area_code IN VARCHAR2 DEFAULT NULL,
101 p_fax_number IN VARCHAR2 DEFAULT NULL,
102 p_email_address IN VARCHAR2 DEFAULT NULL,
103 p_inactive_date IN DATE DEFAULT NULL,
104 x_return_status OUT nocopy VARCHAR2,
105 x_msg_count OUT nocopy NUMBER,
106 x_msg_data OUT nocopy VARCHAR2,
107 x_person_party_id OUT nocopy NUMBER
108 )
109 IS
110 l_person_party_rec hz_party_v2pub.party_rec_type;
111 l_person_party_number hz_parties.party_number%TYPE;
112 l_person_rec hz_party_v2pub.person_rec_type;
113 l_person_profile_id NUMBER;
114 l_method VARCHAR2(30);
115 l_step VARCHAR2(100);
116 l_rel_party_id NUMBER;
117
118 /* Added for bug 7366321 */
119 l_hzprofile_value varchar2(20);
120 l_hzprofile_changed varchar2(1) := 'N';
121 /* End */
122
123
124 BEGIN
125 SAVEPOINT create_supplier_contact_sp;
126
127 l_method := 'create_supplier_contact';
128
129 /* Added for bug 7366321 */
130 l_hzprofile_value := fnd_profile.value('HZ_GENERATE_PARTY_NUMBER');
131 if nvl(l_hzprofile_value, 'Y') = 'N' then
132 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', 'Y');
133 l_hzprofile_changed := 'Y';
134 end if;
135 /* End */
136
137 /* commented for bug 7366321
138 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER','Y');
139 */
140
141 -- create contact party
142 l_person_party_rec := NULL;
143 l_person_rec := NULL;
144
145 l_person_rec.person_first_name := p_first_name;
146 l_person_rec.person_middle_name := p_middle_name;
147 l_person_rec.person_last_name := p_last_name;
148 l_person_rec.person_title := p_job_title;
149 l_person_rec.created_by_module := 'POS_SUPPLIER_MGMT';
150 l_person_rec.application_id := 177;
151 l_person_rec.party_rec := l_person_party_rec;
152 l_person_rec.person_pre_name_adjunct := p_contact_title;
153
154 l_step := 'create contact party';
155
156 IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
157 fnd_log.string
158 ( fnd_log.level_statement
159 , g_module || '.' || l_method
160 , l_step
161 || ' with person_first_name ' || l_person_rec.person_first_name
162 || ' person_middle_name ' || l_person_rec.person_middle_name
163 || ' person_last_name ' || l_person_rec.person_last_name
164 || ' person_title ' || l_person_rec.person_title
165 || ' person_pre_name_adjunct ' || l_person_rec.person_pre_name_adjunct
166 );
167 END IF;
168
169 hz_party_v2pub.create_person
170 (p_init_msg_list => fnd_api.g_false,
171 p_person_rec => l_person_rec,
172 p_party_usage_code => 'SUPPLIER_CONTACT',
173 x_return_status => x_return_status,
174 x_msg_count => x_msg_count,
175 x_msg_data => x_msg_data,
176 x_party_id => x_person_party_id,
177 x_party_number => l_person_party_number,
178 x_profile_id => l_person_profile_id
179 );
180
181 /* Added for bug 7366321 */
182 if nvl(l_hzprofile_changed,'N') = 'Y' then
183 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', l_hzprofile_value);
184 l_hzprofile_changed := 'N';
185 end if;
186 /* End */
187
188 pos_log.log_call_result
189 (p_module => 'POSCONTB',
190 p_prefix => 'call hz_party_v2pub.create_person',
191 p_return_status => x_return_status,
192 p_msg_count => x_msg_count,
193 p_msg_data => x_msg_data
194 );
195
196 IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
197 /* Added for bug 7366321 */
198 if nvl(l_hzprofile_changed,'N') = 'Y' then
199 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', l_hzprofile_value);
200 l_hzprofile_changed := 'N';
201 end if;
202 /* End */
203
204 ROLLBACK TO create_supplier_contact_sp;
205 RETURN;
206 END IF;
207
208 create_org_contact_private
209 (p_vendor_party_id => p_vendor_party_id,
210 p_person_party_id => x_person_party_id,
211 p_job_title => p_job_title,
212 p_inactive_date => p_inactive_date,
213 x_return_status => x_return_status,
214 x_msg_count => x_msg_count,
215 x_msg_data => x_msg_data,
216 x_rel_party_id => l_rel_party_id
217 );
218
219 IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
220 ROLLBACK TO create_supplier_contact_sp;
221 RETURN;
222 END IF;
223
224 l_step := 'store phone for supplier contact';
225 IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
226 fnd_log.string
227 (fnd_log.level_statement
228 , g_module || '.' || l_method
229 , l_step
230 );
231 END IF;
232
233 pos_hz_contact_point_pkg.update_party_phone
234 (
235 p_party_id => l_rel_party_id,
236 p_country_code => NULL,
237 p_area_code => p_phone_area_code ,
238 p_number => p_phone_number,
239 p_extension => p_phone_extension,
240 x_return_status => x_return_status,
241 x_msg_count => x_msg_count,
242 x_msg_data => x_msg_data
243 );
244
245 IF x_return_status IS NULL OR
246 x_return_status <> fnd_api.g_ret_sts_success THEN
247 ROLLBACK TO create_supplier_contact_sp;
248 RETURN;
249 END IF;
250
251 l_step := 'store fax for supplier contact';
252 IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
253 fnd_log.string
254 (fnd_log.level_statement
255 , g_module || '.' || l_method
256 , l_step
257 );
258 END IF;
259
260 pos_hz_contact_point_pkg.update_party_fax
261 (
262 p_party_id => l_rel_party_id,
263 p_country_code => NULL,
264 p_area_code => p_fax_area_code ,
265 p_number => p_fax_number,
266 p_extension => NULL,
267 x_return_status => x_return_status,
268 x_msg_count => x_msg_count,
269 x_msg_data => x_msg_data
270 );
271
272 IF x_return_status IS NULL OR
273 x_return_status <> fnd_api.g_ret_sts_success THEN
274 ROLLBACK TO create_supplier_contact_sp;
275 RETURN;
276 END IF;
277
278 l_step := 'store email for supplier contact';
279 IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
280 fnd_log.string
281 (fnd_log.level_statement
282 , g_module || '.' || l_method
283 , l_step
284 );
285 END IF;
286
287 pos_hz_contact_point_pkg.update_party_email
288 (
289 p_party_id => l_rel_party_id,
290 p_email => p_email_address,
291 x_return_status => x_return_status,
292 x_msg_count => x_msg_count,
293 x_msg_data => x_msg_data
294 );
295
296 IF x_return_status IS NULL OR
297 x_return_status <> fnd_api.g_ret_sts_success THEN
298 ROLLBACK TO create_supplier_contact_sp;
299 RETURN;
300 END IF;
301
302 EXCEPTION
303 WHEN OTHERS THEN
304 /* Added for bug 7366321 */
305 if nvl(l_hzprofile_changed,'N') = 'Y' then
306 fnd_profile.put('HZ_GENERATE_PARTY_NUMBER', l_hzprofile_value);
307 l_hzprofile_changed := 'N';
308 end if;
309 /* End */
310 ROLLBACK TO create_supplier_contact_sp;
311 x_return_status := fnd_api.g_ret_sts_unexp_error;
312 x_msg_count := 1;
313 x_msg_data := Sqlerrm;
314 pos_log.log_sqlerrm('POSCONTB', 'in create_supplier_contact');
315
316 END create_supplier_contact;
317
318 /**
319 Name : update_supplier_contact
320 Description : This procedure is used to update the contact details
321 like name,email,phone number,fax etc.
322 Parameters :
323
324 IN :
325 p_contact_party_id - holds party id of the 'PERSON' party record in hz_parties.
326 p_vendor_party_id - holds party id of the 'ORGANIZATION' party record in hz_parties.
327 p_first_name - first name of the contact
328 p_last_name - last name of the contact
329 p_middle_name - middle name of the contact
330 p_contact_title - contact title of the contact
331 p_job_title - job title of the contact
332 p_phone_number - phone number of the contact
333 p_fax_number - fax number of the contact
334 p_email_address - email address of the contact
335 p_inactive_date - inactive date of the contact
336 p_party_object_version_number - object version number of the relationship record in hz_parties
337 p_email_object_version_number - object version number of the email contact in hz_contact_points
338 p_phone_object_version_number - object version number of the phone contact in hz_contact_points
339 p_fax_object_version_number - object version number of the fax contact in hz_contact_points
340 p_rel_object_version_number - object version number of the relationship record in hz_relationships
341 p_cont_object_version_number - object version number of the hz_org_contacts record
342 p_person_party_obversion_num - object version number of the 'PERSON' party record in hz_parties
343
344 OUT :
345 x_return_status - returns either success/failure
346 x_msg_count - returns the number of error messages
347 x_msg_data - returns error messages
348 **/
349
350 PROCEDURE update_supplier_contact
351 (p_contact_party_id IN NUMBER,
352 p_vendor_party_id IN NUMBER,
353 p_first_name IN VARCHAR2 DEFAULT NULL,
354 p_last_name IN VARCHAR2 DEFAULT NULL,
355 p_middle_name IN VARCHAR2 DEFAULT NULL,
356 p_contact_title IN VARCHAR2 DEFAULT NULL,
357 p_job_title IN VARCHAR2 DEFAULT NULL,
358 p_phone_area_code IN VARCHAR2 DEFAULT NULL,
359 p_phone_number IN VARCHAR2 DEFAULT NULL,
360 p_phone_extension IN VARCHAR2 DEFAULT NULL,
361 p_fax_area_code IN VARCHAR2 DEFAULT NULL,
362 p_fax_number IN VARCHAR2 DEFAULT NULL,
363 p_email_address IN VARCHAR2 DEFAULT NULL,
364 p_inactive_date IN DATE DEFAULT NULL,
365 --Start Bug 6620664 - Handling Concurrent Updates on ContactDirectory, BusinessClassifications ans Accounting pages
366 p_party_object_version_number IN NUMBER DEFAULT fnd_api.G_NULL_NUM,
367 p_email_object_version_number IN NUMBER DEFAULT fnd_api.G_NULL_NUM,
368 p_phone_object_version_number IN NUMBER DEFAULT fnd_api.G_NULL_NUM,
369 p_fax_object_version_number IN NUMBER DEFAULT fnd_api.G_NULL_NUM,
370 p_rel_object_version_number IN NUMBER DEFAULT fnd_api.G_NULL_NUM,
371 p_cont_object_version_number IN NUMBER DEFAULT fnd_api.G_NULL_NUM,
372 --End Bug 6620664 - Handling Concurrent Updates on ContactDirectory, BusinessClassifications ans Accounting pages
373 p_person_party_obversion_num IN NUMBER DEFAULT fnd_api.G_NULL_NUM,
374 x_return_status OUT nocopy VARCHAR2,
375 x_msg_count OUT nocopy NUMBER,
376 x_msg_data OUT nocopy VARCHAR2
377 )
378 IS
379 CURSOR l_contact_party_cur IS
380 SELECT person_first_name,
381 person_last_name,
382 person_middle_name,
383 person_pre_name_adjunct,
384 person_title,
385 object_version_number
386 FROM hz_parties
387 WHERE party_id = p_contact_party_id;
388
389 l_contact_party_rec l_contact_party_cur%ROWTYPE;
390 l_person_rec hz_party_v2pub.person_rec_type;
391 l_party_rec hz_party_v2pub.party_rec_type;
392 l_profile_id NUMBER;
393
394 CURSOR l_cur2 IS
395 SELECT hoc.org_contact_id,
396 hoc.job_title,
397 hoc.object_version_number cont_object_version_number,
398 hzr.object_version_number rel_object_version_number,
399 hzr.party_id,
400 hzr.relationship_id,
401 hp.object_version_number rel_party_obj_ver_num
402 FROM hz_org_contacts hoc, hz_relationships hzr, hz_parties hp
403 WHERE hoc.party_relationship_id = hzr.relationship_id
404 AND hzr.object_table_name = 'HZ_PARTIES'
405 AND hzr.object_id = p_vendor_party_id
406 AND hzr.subject_table_name = 'HZ_PARTIES'
407 AND hzr.subject_id = p_contact_party_id
408 AND hzr.relationship_type = 'CONTACT'
409 AND hzr.relationship_code = 'CONTACT_OF'
410 AND hzr.party_id = hp.party_id;
411
412 l_rec2 l_cur2%ROWTYPE;
413
414 l_org_contact_rec hz_party_contact_v2pub.org_contact_rec_type;
415 l_rel_rec hz_relationship_v2pub.relationship_rec_type;
416 l_rel_party_id NUMBER;
417 l_found_org_contact BOOLEAN;
418 l_enddate_changed BOOLEAN;
419
420 /* Start for Bug 6620664 */
421 l_party_object_version_number NUMBER;
422 l_phone_object_version_number NUMBER;
423 l_fax_object_version_number NUMBER;
424 l_email_object_version_number NUMBER;
425 l_rel_object_version_number NUMBER;
426 l_cont_object_version_number NUMBER;
427 /* End for Bug 6620664 */
428
429 /* Bug 7027825 Start */
430 l_person_party_obversion_num NUMBER;
431 /* Bug 7027825 End */
432
433
434 cursor l_user_cur is
435 select user_name
436 from fnd_user
437 WHERE person_party_id = p_contact_party_id;
438 l_user_rec l_user_cur%ROWTYPE;
439
440 BEGIN
441 SAVEPOINT update_supplier_contact_sp;
442
443 /* Start for Bug 6620664 */
444 l_phone_object_version_number := p_phone_object_version_number;
445 l_fax_object_version_number := p_fax_object_version_number;
446 l_email_object_version_number := p_email_object_version_number;
447 /* End for Bug 6620664 */
448
449 OPEN l_contact_party_cur;
450
451 FETCH l_contact_party_cur INTO l_contact_party_rec;
452
453 IF l_contact_party_cur%notfound THEN
454 CLOSE l_contact_party_cur;
455 x_return_status := fnd_api.g_ret_sts_error;
456 x_msg_count := 1;
457 x_msg_data := 'invalid contact party_id ' || p_contact_party_id;
458 RETURN;
459 END IF;
460 /* Bug 7027825 Start */
461 IF(p_person_party_obversion_num=fnd_api.G_NULL_NUM) THEN
462 l_person_party_obversion_num := l_contact_party_rec.object_version_number;
463 ELSE
464 l_person_party_obversion_num := p_person_party_obversion_num;
465 END IF ;
466 /* Bug 7027825 End */
467 CLOSE l_contact_party_cur;
468
469 OPEN l_cur2;
470 FETCH l_cur2 INTO l_rec2;
471 l_found_org_contact := l_cur2%found;
472 CLOSE l_cur2;
473
474 IF l_found_org_contact THEN
475 -- retrieve the relation record
476 HZ_RELATIONSHIP_V2PUB.get_relationship_rec (
477 p_relationship_id => l_rec2.relationship_id,
478 p_directional_flag => 'F',
479 x_rel_rec => l_rel_rec,
480 x_return_status => x_return_status,
481 x_msg_count => x_msg_count,
482 x_msg_data => x_msg_data
483 );
484 IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
485 ROLLBACK TO update_supplier_contact_sp;
486 RETURN;
487 END IF;
488
489 if ((l_rel_rec.end_date is null and p_inactive_date is null) or
490 (l_rel_rec.end_date is not null and l_rel_rec.end_date = p_inactive_date)) then
491 l_enddate_changed := false;
492 else
493 l_enddate_changed := true;
494 l_rel_rec.end_date := p_inactive_date;
495 end if;
496
497 /* Start Bug 6620664 */
498 IF(p_party_object_version_number = fnd_api.G_NULL_NUM) THEN
499 l_party_object_version_number := l_rec2.rel_party_obj_ver_num;
500 ELSE
501 l_party_object_version_number := p_party_object_version_number;
502 END IF;
503
504 IF(p_rel_object_version_number = fnd_api.G_NULL_NUM) THEN
505 l_rel_object_version_number := l_rec2.rel_object_version_number;
506 ELSE
507 l_rel_object_version_number := p_rel_object_version_number;
508 END IF;
509
510 IF(p_cont_object_version_number = fnd_api.G_NULL_NUM) THEN
511 l_cont_object_version_number := l_rec2.cont_object_version_number;
512 ELSE
513 l_cont_object_version_number := p_cont_object_version_number;
514 END IF;
515 /* End Bug 6620664 */
516
517 -- update org contact if needed
518 IF ((l_rec2.job_title IS NULL AND p_job_title IS NULL) OR
519 (l_rec2.job_title IS NOT NULL AND l_rec2.job_title = p_job_title))
520 AND (not l_enddate_changed)
521 THEN
522 NULL;
523 ELSE
524 l_org_contact_rec.job_title := p_job_title;
525 l_org_contact_rec.party_rel_rec := l_rel_rec;
526 l_org_contact_rec.org_contact_id := l_rec2.org_contact_id;
527
528 hz_party_contact_v2pub.update_org_contact
529 (p_init_msg_list => fnd_api.g_true,
530 p_org_contact_rec => l_org_contact_rec,
531 --Start Bug 6620664
532 p_cont_object_version_number => l_cont_object_version_number, --l_rec2.cont_object_version_number,
533 p_rel_object_version_number => l_rel_object_version_number, --l_rec2.rel_object_version_number,
534 p_party_object_version_number => l_party_object_version_number, --l_rec2.rel_party_obj_ver_num,
535 --End Bug 6620664
536 x_return_status => x_return_status,
537 x_msg_count => x_msg_count,
538 x_msg_data => x_msg_data
539 );
540 IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
541 ROLLBACK TO update_supplier_contact_sp;
542 RETURN;
543 END IF;
544 END IF;
545 ELSE
546 -- create org contact record as we did not find it
547 create_org_contact_private
548 (p_vendor_party_id => p_vendor_party_id,
549 p_person_party_id => p_contact_party_id,
550 p_job_title => p_job_title,
551 p_inactive_date => p_inactive_date,
552 x_return_status => x_return_status,
553 x_msg_count => x_msg_count,
554 x_msg_data => x_msg_data,
555 x_rel_party_id => l_rel_party_id
556 );
557
558 IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
559 --ROLLBACK TO create_supplier_contact_sp;
560 ROLLBACK TO update_supplier_contact_sp;
561 RETURN;
562 END IF;
563 END IF;
564
565 -- update party if needed
566 IF (p_first_name IS NULL AND l_contact_party_rec.person_first_name IS NULL OR
567 p_first_name IS NOT NULL AND l_contact_party_rec.person_first_name IS NOT NULL AND
568 p_first_name = l_contact_party_rec.person_first_name
569 ) AND
570 (p_last_name IS NULL AND l_contact_party_rec.person_last_name IS NULL OR
571 p_last_name IS NOT NULL AND l_contact_party_rec.person_last_name IS NOT NULL AND
572 p_last_name = l_contact_party_rec.person_last_name
573 ) AND
574 (p_middle_name IS NULL AND l_contact_party_rec.person_middle_name IS NULL OR
575 p_middle_name IS NOT NULL AND l_contact_party_rec.person_middle_name IS NOT NULL AND
576 p_middle_name = l_contact_party_rec.person_middle_name
577 ) AND
578 (p_contact_title IS NULL AND l_contact_party_rec.person_pre_name_adjunct IS NULL OR
579 p_contact_title IS NOT NULL AND l_contact_party_rec.person_pre_name_adjunct IS NOT NULL AND
580 p_contact_title = l_contact_party_rec.person_pre_name_adjunct
581 ) THEN
582
583 NULL; -- no change for party
584
585 ELSE
586 l_person_rec.person_first_name := nvl(p_first_name, fnd_api.g_miss_char);
587 l_person_rec.person_last_name := p_last_name;
588 l_person_rec.person_middle_name := nvl(p_middle_name, fnd_api.g_miss_char);
589 l_person_rec.person_pre_name_adjunct := nvl(p_contact_title, fnd_api.g_miss_char);
590 l_party_rec.party_id := p_contact_party_id;
591 l_person_rec.party_rec := l_party_rec;
592
593 /* Bug 7027825 , For Updating A Person Party Type We need to pass the object version number of the
594 PERSON record ,So changed the below object version number parameter to l_person_party_obversion_num */
595
596 hz_party_v2pub.update_person
597 (p_init_msg_list => fnd_api.g_true,
598 p_person_rec => l_person_rec,
599 p_party_object_version_number => l_person_party_obversion_num,
600 x_profile_id => l_profile_id,
601 x_return_status => x_return_status,
602 x_msg_count => x_msg_count,
603 x_msg_data => x_msg_data
604 );
605
606 IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
607 ROLLBACK TO update_supplier_contact_sp;
608 RETURN;
609 END IF;
610 END IF;
611
612 pos_hz_contact_point_pkg.update_party_phone
613 (
614 p_party_id => l_rec2.party_id,
615 p_country_code => NULL,
616 p_area_code => p_phone_area_code ,
617 p_number => p_phone_number,
618 p_extension => p_phone_extension,
619 --Start Bug 6620664
620 p_phone_object_version_number => l_phone_object_version_number,
621 --End Bug 6620664
622 x_return_status => x_return_status,
623 x_msg_count => x_msg_count,
624 x_msg_data => x_msg_data
625 );
626
627 IF x_return_status IS NULL OR
628 x_return_status <> fnd_api.g_ret_sts_success THEN
629 --ROLLBACK TO create_supplier_contact_sp;
630 ROLLBACK TO update_supplier_contact_sp;
631 RETURN;
632 END IF;
633
634 pos_hz_contact_point_pkg.update_party_fax
635 (
636 p_party_id => l_rec2.party_id,
637 p_country_code => NULL,
638 p_area_code => p_fax_area_code ,
639 p_number => p_fax_number,
640 p_extension => NULL,
641 --Start Bug 6620664
642 p_fax_object_version_number => l_fax_object_version_number,
643 --End Bug 6620664
644 x_return_status => x_return_status,
645 x_msg_count => x_msg_count,
646 x_msg_data => x_msg_data
647 );
648
649 IF x_return_status IS NULL OR
650 x_return_status <> fnd_api.g_ret_sts_success THEN
651 --ROLLBACK TO create_supplier_contact_sp;
652 ROLLBACK TO update_supplier_contact_sp;
653 RETURN;
654 END IF;
655
656 pos_hz_contact_point_pkg.update_party_email
657 (
658 p_party_id => l_rec2.party_id,
659 p_email => p_email_address,
660 --Start Bug 6620664
661 p_email_object_version_number => l_email_object_version_number,
662 --End Bug 6620664
663 x_return_status => x_return_status,
664 x_msg_count => x_msg_count,
665 x_msg_data => x_msg_data
666 );
667
668 for l_user_rec in l_user_cur loop
669
670 fnd_user_pkg.updateuser
671 (
672 x_user_name => l_user_rec.user_name,
673 x_email_address => p_email_address,
674 x_owner => NULL,
675 x_end_date => p_inactive_date
676 );
677
678 END LOOP;
679
680 IF x_return_status IS NULL OR
681 x_return_status <> fnd_api.g_ret_sts_success THEN
682 --ROLLBACK TO create_supplier_contact_sp;
683 ROLLBACK TO update_supplier_contact_sp;
684 RETURN;
685 END IF;
686
687 EXCEPTION
688 WHEN OTHERS THEN
689 ROLLBACK TO update_supplier_contact_sp;
690 x_return_status := fnd_api.g_ret_sts_unexp_error;
691 x_msg_count := 1;
692 x_msg_data := Sqlerrm;
693 pos_log.log_sqlerrm('POSCONTB', 'in update_supplier_contact');
694
695 END update_supplier_contact;
696
697 END POS_SUPP_CONTACT_PKG ;