DBA Data[Home] [Help]

PACKAGE BODY: APPS.POS_SUPPLIER_ADDRESS_PKG

Source


1 PACKAGE BODY pos_supplier_address_pkg AS
2 /* $Header: POSSAB.pls 120.17.12010000.2 2008/08/02 14:56:08 sthoppan ship $ */
3 
4 g_module VARCHAR2(30) := 'POS_SUPPLIER_ADDRESS_PKG';
5 
6 PROCEDURE assign_address_type
7   ( p_party_site_id      IN  NUMBER,
8     p_address_type       IN  VARCHAR2,
9     x_party_site_use_id  OUT nocopy NUMBER,
10     x_return_status      OUT nocopy VARCHAR2,
11     x_msg_count          OUT nocopy NUMBER,
12     x_msg_data           OUT nocopy VARCHAR2
13     )
14   IS
15      CURSOR l_cur IS
16         SELECT party_site_use_id
17           FROM hz_party_site_uses
18          WHERE party_site_id = p_party_site_id
19            AND site_use_type = p_address_type
20            AND status = 'A';
21 
22      l_rec    l_cur%ROWTYPE;
23      l_found  BOOLEAN;
24 
25      l_party_site_use_rec hz_party_site_v2pub.party_site_use_rec_type;
26 
27      l_method VARCHAR(30);
28      l_step   VARCHAR2(100);
29 BEGIN
30 
31    l_method := 'assign_address_type';
32    -- log_values p_party_site_id p_address_type
33    IF  (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
34       fnd_log.string( fnd_log.level_statement
35                       , g_module || '.' || l_method
36                       , ' p_party_site_id = ' || p_party_site_id
37                       || ' p_address_type = ' || p_address_type
38                       );
39    END IF;
40 
41    l_step := 'check existing address type';
42    IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
43       fnd_log.string
44         (fnd_log.level_statement
45          , g_module || '.' || l_method
46          , l_step
47          );
48    END IF;
49 
50    OPEN l_cur;
51    FETCH l_cur INTO l_rec;
52    l_found := l_cur%found;
53    CLOSE l_cur;
54 
55    IF l_found THEN
56       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
57          fnd_log.string
58            (fnd_log.level_statement
59             , g_module || '.' || l_method
60             , l_step || ' found an existing record'
61          );
62       END IF;
63 
64       x_return_status := fnd_api.g_ret_sts_success;
65       RETURN;
66    ELSE
67       l_step := 'call hz_party_site_v2pub.create_party_site_use';
68 
69       l_party_site_use_rec.party_site_id     := p_party_site_id;
70       l_party_site_use_rec.application_id    := 177;
71       l_party_site_use_rec.created_by_module := 'POS_SUPPLIER_MGMT';
72       l_party_site_use_rec.status            := 'A';
73       l_party_site_use_rec.site_use_type     := p_address_type;
74 
75       hz_party_site_v2pub.create_party_site_use
76         ( p_init_msg_list        => FND_API.G_FALSE,
77           p_party_site_use_rec   => l_party_site_use_rec,
78           x_party_site_use_id    => x_party_site_use_id,
79           x_return_status        => x_return_status,
80           x_msg_count            => x_msg_count,
81           x_msg_data             => x_msg_data
82           );
83 
84       -- log_callresult x_party_site_use_id
85       IF x_return_status = FND_API.g_ret_sts_success THEN
86          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
87             fnd_log.string( fnd_log.level_statement
88                           , g_module || '.' || l_method
89                           , l_step || ' x_party_site_use_id = ' || x_party_site_use_id
90                           );
91          END IF;
92       ELSE
93          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level) THEN
94             fnd_log.string( fnd_log.level_error
95                           , g_module || '.' || l_method
96                           , l_step || ': x_return_status = ' || x_return_status
97                             || ' x_msg_count = ' || x_msg_count
98                             || ', x_msg_data = ' || x_msg_data
99                           );
100          END IF;
101       END IF;
102    END IF;
103 END assign_address_type;
104 
105 PROCEDURE remove_address_type
106   ( p_party_site_id      IN  NUMBER,
107     p_address_type       IN  VARCHAR2,
108     x_return_status      OUT nocopy VARCHAR2,
109     x_msg_count          OUT nocopy NUMBER,
110     x_msg_data           OUT nocopy VARCHAR2
111     )
112   IS
113      CURSOR l_cur IS
114         SELECT party_site_use_id, object_version_number
115           FROM hz_party_site_uses
116          WHERE party_site_id = p_party_site_id
117            AND site_use_type = p_address_type
118            AND status = 'A';
119 
120      l_rec    l_cur%ROWTYPE;
121      l_found  BOOLEAN;
122 
123      l_party_site_use_rec hz_party_site_v2pub.party_site_use_rec_type;
124 
125      l_method VARCHAR(30);
126      l_step   VARCHAR2(100);
127 BEGIN
128 
129    l_method := 'remove_address_type';
130    -- log_values p_party_site_id p_address_type
131    IF  (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
132       fnd_log.string( fnd_log.level_statement
133                       , g_module || '.' || l_method
134                       , ' p_party_site_id = ' || p_party_site_id
135                       || ' p_address_type = ' || p_address_type
136                       );
137    END IF;
138 
139    l_step := 'check existing address type';
140    IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
141       fnd_log.string
142         (fnd_log.level_statement
143          , g_module || '.' || l_method
144          , l_step
145          );
146    END IF;
147 
148    OPEN l_cur;
149    FETCH l_cur INTO l_rec;
150    l_found := l_cur%found;
151    CLOSE l_cur;
152 
153    IF NOT l_found THEN
154       IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
155          fnd_log.string
156            (fnd_log.level_statement
157             , g_module || '.' || l_method
158             , l_step || ' existing record not found so no record to end-date.'
159          );
160       END IF;
161 
162       x_return_status := fnd_api.g_ret_sts_success;
163       RETURN;
164    ELSE
165       l_step := 'call hz_party_site_v2pub.update_party_site_use';
166       l_party_site_use_rec.party_site_use_id := l_rec.party_site_use_id;
167       l_party_site_use_rec.status            := 'I';
168 
169       hz_party_site_v2pub.update_party_site_use
170         ( p_init_msg_list         => FND_API.G_FALSE,
171           p_party_site_use_rec    => l_party_site_use_rec,
172           p_object_version_number => l_rec.object_version_number,
173           x_return_status         => x_return_status,
174           x_msg_count             => x_msg_count,
175           x_msg_data              => x_msg_data
176           );
177 
178       IF x_return_status = FND_API.g_ret_sts_success THEN
179          IF (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
180             fnd_log.string( fnd_log.level_statement
181                           , g_module || '.' || l_method
182                           , l_step || ' succeeded'
183                           );
184          END IF;
185       ELSE
186          IF (fnd_log.level_error >= fnd_log.g_current_runtime_level) THEN
187             fnd_log.string( fnd_log.level_error
188                           , g_module || '.' || l_method
189                           , l_step || ': x_return_status = ' || x_return_status
190                             || ' x_msg_count = ' || x_msg_count
191                             || ', x_msg_data = ' || x_msg_data
192                           );
193          END IF;
194       END IF;
195    END IF;
196 END remove_address_type;
197 
198 PROCEDURE handle_address_type
199   (p_party_site_id  IN  NUMBER,
200    p_address_type   IN  VARCHAR2,
201    p_value          IN  VARCHAR2,
202    x_return_status  OUT nocopy VARCHAR2,
203    x_msg_count      OUT nocopy NUMBER,
204    x_msg_data       OUT nocopy VARCHAR2
205    )
206   IS
207      l_method            VARCHAR2(30);
208      l_step              VARCHAR2(100);
209      l_party_site_use_id NUMBER;
210 BEGIN
211 
212    IF p_value = 'Y' THEN
213       l_step := 'call assign_address_type ';
214     ELSE
215       l_step := 'call remove_address_type ';
216    END IF;
217 
218    IF  (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
219       fnd_log.string
220         (fnd_log.level_statement
221          , g_module || '.' || l_method
222          , l_step || ' p_address_type = ' || p_address_type
223            || ' p_party_site_id = ' || p_party_site_id
224          );
225    END IF;
226 
227    IF p_value = 'Y' THEN
228       assign_address_type
229         (p_party_site_id           => p_party_site_id,
230          p_address_type            => p_address_type,
231          x_party_site_use_id       => l_party_site_use_id,
232          x_return_status           => x_return_status,
233          x_msg_count               => x_msg_count,
234          x_msg_data                => x_msg_data
235          );
236     ELSE
237       remove_address_type
238         (p_party_site_id           => p_party_site_id,
239          p_address_type            => p_address_type,
240          x_return_status           => x_return_status,
241          x_msg_count               => x_msg_count,
242          x_msg_data                => x_msg_data
243          );
244    END IF;
245 
246 END handle_address_type;
247 
248 PROCEDURE check_payables_options
249   (x_return_status    OUT nocopy VARCHAR2,
250    x_msg_count        OUT nocopy NUMBER,
251    x_msg_data         OUT nocopy VARCHAR2
252    )
253   IS
254      l_orgs  VARCHAR2(3000);
255      l_found BOOLEAN;
256 BEGIN
257    l_found := FALSE;
258    FOR x IN (SELECT name
259              FROM hr_operating_units o
260              WHERE mo_global.check_access(organization_id) = 'Y'
261              AND NOT exists
262                  (SELECT 1
263                   FROM ap_system_parameters_all
264                   WHERE o.organization_id = org_id
265                   )
266              )
267      LOOP
268         l_found := TRUE;
269         IF l_orgs IS NULL THEN
270            l_orgs := x.name;
271          ELSE
272            l_orgs := l_orgs || ', ' || x.name;
273         END IF;
274    END LOOP;
275 
276    IF l_found THEN
277       x_return_status := 'E';
278       fnd_message.set_name('POS','POS_ORG_PAY_PARAM_MISS');
279       fnd_message.set_token('OPERATING_UNITS', l_orgs);
280       fnd_msg_pub.add;
281       fnd_msg_pub.count_and_get
282         (p_count => x_msg_count,
283          p_data  => x_msg_data
284         );
285     ELSE
286       x_return_status := 'S';
287    END IF;
288 
289 END check_payables_options;
290 
291 PROCEDURE create_supplier_address
292   (p_vendor_id        IN  NUMBER,
293    p_vendor_party_id  IN  NUMBER,
294    p_party_site_name  IN  VARCHAR2,
295    p_address_line1    IN  VARCHAR2,
296    p_address_line2    IN  VARCHAR2,
297    p_address_line3    IN  VARCHAR2,
298    p_address_line4    IN  VARCHAR2,
299    p_country          IN  VARCHAR2,
300    p_city             IN  VARCHAR2,
301    p_state            IN  VARCHAR2,
302    p_province         IN  VARCHAR2,
303    p_postal_code      IN  VARCHAR2,
304    p_county           IN  VARCHAR2,
305    p_rfq_flag         IN  VARCHAR2,
306    p_pur_flag         IN  VARCHAR2,
307    p_pay_flag         IN  VARCHAR2,
308    p_primary_pay_flag IN  VARCHAR2,
309    p_phone_area_code  IN  VARCHAR2,
310    p_phone_number     IN  VARCHAR2,
311    p_phone_extension  IN  VARCHAR2,
312    p_fax_area_code    IN  VARCHAR2,
313    p_fax_number       IN  VARCHAR2,
314    p_email_address    IN  VARCHAR2,
315    x_return_status    OUT nocopy VARCHAR2,
316    x_msg_count        OUT nocopy NUMBER,
317    x_msg_data         OUT nocopy VARCHAR2,
318    x_party_site_id    OUT nocopy NUMBER
319    )
320   IS
321      l_party_site_number hz_party_sites.party_site_number%TYPE;
322      l_party_site_id     NUMBER;
323      l_location_id       NUMBER;
324      l_party_site_use_id NUMBER;
325      l_ou_ids            pos_security_profile_utl_pkg.number_table;
326      l_ou_count          NUMBER;
327      l_vendor_site_rec   ap_vendor_pub_pkg.r_vendor_site_rec_type;
328      l_vendor_site_id    NUMBER;
329      l_dummy_location_id NUMBER;
330      l_dummy_party_site_id NUMBER;
331 BEGIN
332    SAVEPOINT create_supplier_address_sp;
333 
334    check_payables_options(x_return_status => x_return_status,
335                          x_msg_count     => x_msg_count,
336                          x_msg_data      => x_msg_data);
337 
338    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
339       ROLLBACK TO create_supplier_address_sp;
340       RETURN;
341    END IF;
342 
343    pos_security_profile_utl_pkg.get_current_ous (l_ou_ids, l_ou_count);
344 
345    pos_hz_util_pkg.pos_create_hz_location
346      (p_country_code  => p_country,
347       p_address1      => p_address_line1,
348       p_address2      => p_address_line2,
349       p_address3      => p_address_line3,
350       p_address4      => p_address_line4,
351       p_city          => p_city,
352       p_postal_code   => p_postal_code,
353       p_county        => p_county,
354       p_state         => p_state ,
355       p_province      => p_province,
356       x_location_id   => l_location_id,
357       x_return_status => x_return_status,
358       x_msg_count     => x_msg_count,
359       x_msg_data      => x_msg_data
360       );
361 
362    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
363       ROLLBACK TO create_supplier_address_sp;
364       RETURN;
365    END IF;
366 
367    pos_hz_util_pkg.pos_create_party_site
368      (p_party_id          => p_vendor_party_id,
369       p_location_id       => l_location_id,
370       p_party_site_name   => p_party_site_name,
371       x_party_site_id     => l_party_site_id,
372       x_party_site_number => l_party_site_number,
373       x_return_status     => x_return_status,
374       x_msg_count         => x_msg_count,
375       x_msg_data          => x_msg_data
376       );
377 
378    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
379       ROLLBACK TO create_supplier_address_sp;
380       RETURN;
381    END IF;
382 
383    x_party_site_id := l_party_site_id;
384 
385    IF p_rfq_flag IS NOT NULL AND p_rfq_flag = 'Y' THEN
386       assign_address_type
387         (p_party_site_id           => l_party_site_id,
388          p_address_type            => 'RFQ', -- 'RFQ',
389          x_party_site_use_id       => l_party_site_use_id,
390          x_return_status           => x_return_status,
391          x_msg_count               => x_msg_count,
392          x_msg_data                => x_msg_data
393          );
394       IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
395          ROLLBACK TO create_supplier_address_sp;
396          RETURN;
397       END IF;
398    END IF;
399 
400    IF p_pur_flag IS NOT NULL AND p_pur_flag = 'Y' THEN
401       assign_address_type
402         (p_party_site_id           => l_party_site_id,
403          p_address_type            => 'PURCHASING', -- 'PURCHASING',
404          x_party_site_use_id       => l_party_site_use_id,
405          x_return_status           => x_return_status,
406          x_msg_count               => x_msg_count,
407          x_msg_data                => x_msg_data
408          );
409       IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
410          ROLLBACK TO create_supplier_address_sp;
411          RETURN;
412       END IF;
413    END IF;
414 
415    IF p_pay_flag IS NOT NULL AND p_pay_flag = 'Y' THEN
416       assign_address_type
417         (p_party_site_id           => l_party_site_id,
418          p_address_type            => 'PAY', --'PAY',
419          x_party_site_use_id       => l_party_site_use_id,
420          x_return_status           => x_return_status,
421          x_msg_count               => x_msg_count,
422          x_msg_data                => x_msg_data
423          );
424       IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
425          ROLLBACK TO create_supplier_address_sp;
426          RETURN;
427       END IF;
428    END IF;
429 
430    IF p_primary_pay_flag IS NOT NULL AND p_primary_pay_flag = 'Y' THEN
431       --       assign_address_type
432       --         (p_party_site_id           => l_party_site_id,
433       --          p_address_type            => 'PRIMARY_PAY', -- ap has not seeded this
434       --          x_party_site_use_id       => l_party_site_use_id,
435       --          x_return_status           => x_return_status,
436       --          x_msg_count               => x_msg_count,
437       --          x_msg_data                => x_msg_data
438       --          );
439       --       IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
440       --          RETURN;
441       --       END IF;
442       NULL;
443    END IF;
444 
445    pos_hz_contact_point_pkg.update_party_site_phone
446      (
447       p_party_site_id     => l_party_site_id,
448       p_country_code      =>  NULL,
449       p_area_code         => p_phone_area_code ,
450       p_number            => p_phone_number,
451       p_extension         => NULL,
452       x_return_status     => x_return_status,
453       x_msg_count         => x_msg_count,
454       x_msg_data          => x_msg_data
455     );
456 
457    IF x_return_status IS NULL OR
458      x_return_status <> fnd_api.g_ret_sts_success THEN
459       ROLLBACK TO create_supplier_address_sp;
460       RETURN;
461    END IF;
462 
463    pos_hz_contact_point_pkg.update_party_site_fax
464      (
465       p_party_site_id     => l_party_site_id,
466       p_country_code      =>  NULL,
467       p_area_code         => p_fax_area_code ,
468       p_number            => p_fax_number,
469       p_extension         => NULL,
470       x_return_status     => x_return_status,
471       x_msg_count         => x_msg_count,
472       x_msg_data          => x_msg_data
473     );
474 
475    IF x_return_status IS NULL OR
476      x_return_status <> fnd_api.g_ret_sts_success THEN
477       ROLLBACK TO create_supplier_address_sp;
478       RETURN;
479    END IF;
480 
481    pos_hz_contact_point_pkg.update_party_site_email
482      (
483       p_party_site_id     => l_party_site_id,
484       p_email             => p_email_address,
485       x_return_status     => x_return_status,
486       x_msg_count         => x_msg_count,
487       x_msg_data          => x_msg_data
488     );
489 
490    IF x_return_status IS NULL OR
491      x_return_status <> fnd_api.g_ret_sts_success THEN
492       ROLLBACK TO create_supplier_address_sp;
493       RETURN;
494    END IF;
495 
496    -- create vendor sites
497    FOR l_index IN 1..l_ou_count LOOP
498 
499       l_vendor_site_rec := NULL;
500 
501       l_vendor_site_rec.org_id                := l_ou_ids(l_index);
502       l_vendor_site_rec.vendor_id             := p_vendor_id;
503       l_vendor_site_rec.location_id           := l_location_id;
504       l_vendor_site_rec.party_site_id         := l_party_site_id;
505       l_vendor_site_rec.vendor_site_code      := substrb(p_party_site_name, 1, 15);
506       l_vendor_site_rec.purchasing_site_flag  := p_pur_flag;
507       l_vendor_site_rec.rfq_only_site_flag    := p_rfq_flag;
508       l_vendor_site_rec.pay_site_flag         := p_pay_flag;
509       l_vendor_site_rec.primary_pay_site_flag := p_primary_pay_flag;
510       l_vendor_site_rec.email_address         := p_email_address;
511       l_vendor_site_rec.area_code             := p_phone_area_code;
512       l_vendor_site_rec.phone                 := p_phone_number;
513       l_vendor_site_rec.fax_area_code         := p_fax_area_code;
514       l_vendor_site_rec.fax                   := p_fax_number;
515 
516       pos_vendor_pub_pkg.create_vendor_site
517         ( p_vendor_site_rec => l_vendor_site_rec,
518           x_return_status   => x_return_status,
519           x_msg_count       => x_msg_count,
520           x_msg_data        => x_msg_data,
521           x_vendor_site_id  => l_vendor_site_id,
522           x_party_site_id   => l_dummy_party_site_id,
523           x_location_id     => l_dummy_location_id
524           );
525 
526       IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
527          ROLLBACK TO create_supplier_address_sp;
528          RETURN;
529       END IF;
530 
531    END LOOP;
532 
533    x_return_status := fnd_api.g_ret_sts_success;
534 
535 EXCEPTION
536    WHEN OTHERS THEN
537       ROLLBACK TO create_supplier_address_sp;
538       x_return_status := fnd_api.g_ret_sts_unexp_error;
539       x_msg_data := Sqlerrm;
540       x_msg_count := 1;
541       pos_log.log_sqlerrm('POSSAB','create_supplier_address');
542 END create_supplier_address;
543 
544 PROCEDURE update_supplier_address
545   (p_vendor_id        IN  NUMBER,
546    p_vendor_party_id  IN  NUMBER,
547    p_party_site_id    IN  NUMBER,
548    p_party_site_name  IN  VARCHAR2,
549    p_address_line1    IN  VARCHAR2,
550    p_address_line2    IN  VARCHAR2,
551    p_address_line3    IN  VARCHAR2,
552    p_address_line4    IN  VARCHAR2,
553    p_country          IN  VARCHAR2,
554    p_city             IN  VARCHAR2,
555    p_state            IN  VARCHAR2,
556    p_province         IN  VARCHAR2,
557    p_postal_code      IN  VARCHAR2,
558    p_county           IN  VARCHAR2,
559    p_rfq_flag         IN  VARCHAR2,
560    p_pur_flag         IN  VARCHAR2,
561    p_pay_flag         IN  VARCHAR2,
562    p_primary_pay_flag IN  VARCHAR2,
563    p_phone_area_code  IN  VARCHAR2,
564    p_phone_number     IN  VARCHAR2,
565    p_phone_extension  IN  VARCHAR2,
566    p_fax_area_code    IN  VARCHAR2,
567    p_fax_number       IN  VARCHAR2,
568    p_email_address    IN  VARCHAR2,
569    x_return_status    OUT nocopy VARCHAR2,
570    x_msg_count        OUT nocopy NUMBER,
571    x_msg_data         OUT nocopy VARCHAR2
572    )
573    IS
574      l_party_site_rec    hz_party_site_v2pub.party_site_rec_type;
575      l_location_rec      hz_location_v2pub.location_rec_type;
576      l_obj_ver           hz_locations.object_version_number%TYPE;
577 
578      CURSOR l_cur IS
579         SELECT object_version_number,location_id
580           from hz_locations
581           where location_id =
582           (SELECT location_id
583            FROM hz_party_sites
584            WHERE party_site_id = p_party_site_id
585            ) FOR UPDATE;
586 
587      l_rec l_cur%ROWTYPE;
588 
589      CURSOR l_cur2 IS
590         select object_version_number, party_site_name
591           from hz_party_sites
592           where party_site_id = p_party_site_id FOR UPDATE;
593 
594      l_rec2 l_cur2%ROWTYPE;
595 
596 BEGIN
597    SAVEPOINT update_supplier_address_sp;
598    OPEN l_cur;
599    FETCH l_cur INTO l_rec;
600    IF l_cur%notfound THEN
601       CLOSE l_cur;
602       -- prepare err msg
603       RETURN;
604    END IF;
605    CLOSE l_cur;
606 
607    OPEN l_cur2;
608    FETCH l_cur2 INTO l_rec2;
609    IF l_cur2%notfound THEN
610       CLOSE l_cur2;
611       -- prepare err msg
612       RETURN;
613    END IF;
614    CLOSE l_cur2;
615 
616    l_location_rec.location_id  := l_rec.location_id;
617    l_location_rec.address1     := Nvl(p_address_line1, fnd_api.g_miss_char);
618    l_location_rec.address2     := Nvl(p_address_line2, fnd_api.g_miss_char);
619    l_location_rec.address3     := Nvl(p_address_line3, fnd_api.g_miss_char);
620    l_location_rec.address4     := Nvl(p_address_line4, fnd_api.g_miss_char);
621    l_location_rec.city         := Nvl(p_city         , fnd_api.g_miss_char);
622    l_location_rec.postal_code  := Nvl(p_postal_code  , fnd_api.g_miss_char);
623    l_location_rec.state        := Nvl(p_state        , fnd_api.g_miss_char);
624    l_location_rec.province     := Nvl(p_province     , fnd_api.g_miss_char);
625    l_location_rec.county       := Nvl(p_county       , fnd_api.g_miss_char);
626    l_location_rec.country      := Nvl(p_country      , fnd_api.g_miss_char);
627 
628    l_obj_ver := l_rec.object_version_number;
629 
630    hz_location_v2pub.update_location
631      (  p_init_msg_list         => fnd_api.g_true,
632         p_location_rec          => l_location_rec,
633         p_object_version_number => l_obj_ver,
634         x_return_status         => x_return_status,
635         x_msg_count             => x_msg_count,
636         x_msg_data              => x_msg_data
637     );
638 
639    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
640       ROLLBACK TO update_supplier_address_sp;
641       RETURN;
642    END IF;
643 
644    IF l_rec2.party_site_name IS NULL AND p_party_site_name IS NOT NULL OR
645      l_rec2.party_site_name IS NOT NULL AND p_party_site_name IS NULL OR
646        l_rec2.party_site_name <> p_party_site_name THEN
647 
648       l_party_site_rec.party_site_id := p_party_site_id;
649       l_party_site_rec.party_site_name := p_party_site_name;
650 
651       hz_party_site_v2pub.update_party_site
652         (p_init_msg_list         => fnd_api.g_false,
653          p_party_site_rec        => l_party_site_rec,
654          p_object_version_number => l_rec2.object_version_number,
655          x_return_status         => x_return_status,
656          x_msg_count             => x_msg_count,
657          x_msg_data              => x_msg_data
658          );
659 
660       IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
661          ROLLBACK TO update_supplier_address_sp;
662          RETURN;
663       END IF;
664    END IF;
665 
666    -- set phone for the address
667    pos_hz_contact_point_pkg.update_party_site_phone
668      (
669       p_party_site_id     => p_party_site_id,
670       p_country_code      =>  NULL,
671       p_area_code         => p_phone_area_code ,
672       p_number            => p_phone_number,
673       p_extension         => NULL,
674       x_return_status     => x_return_status,
675       x_msg_count         => x_msg_count,
676       x_msg_data          => x_msg_data
677     );
678 
679    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
680       ROLLBACK TO update_supplier_address_sp;
681       RETURN;
682    END IF;
683 
684    -- set fax for the address
685    pos_hz_contact_point_pkg.update_party_site_fax
686      (
687       p_party_site_id     => p_party_site_id,
688       p_country_code      =>  NULL,
689       p_area_code         => p_fax_area_code ,
690       p_number            => p_fax_number,
691       p_extension         => NULL,
692       x_return_status     => x_return_status,
693       x_msg_count         => x_msg_count,
694       x_msg_data          => x_msg_data
695     );
696 
697    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
698       ROLLBACK TO update_supplier_address_sp;
699       RETURN;
700    END IF;
701 
702    -- set email for the address
703    pos_hz_contact_point_pkg.update_party_site_email
704      (
705       p_party_site_id     => p_party_site_id,
706       p_email             => p_email_address,
707       x_return_status     => x_return_status,
708       x_msg_count         => x_msg_count,
709       x_msg_data          => x_msg_data
710       );
711 
712    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
713       ROLLBACK TO update_supplier_address_sp;
714       RETURN;
715    END IF;
716 
717    handle_address_type
718      (p_party_site_id    => p_party_site_id,
719       p_address_type     => 'PAY',
720       p_value            => p_pay_flag,
721       x_return_status    => x_return_status,
722       x_msg_count        => x_msg_count,
723       x_msg_data         => x_msg_data
724       );
725 
726    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
727       ROLLBACK TO update_supplier_address_sp;
728       RETURN;
729    END IF;
730 
731    handle_address_type
732      (p_party_site_id    => p_party_site_id,
733       p_address_type     => 'PURCHASING',
734       p_value            => p_pur_flag,
735       x_return_status    => x_return_status,
736       x_msg_count        => x_msg_count,
737       x_msg_data         => x_msg_data
738       );
739 
740    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
741       ROLLBACK TO update_supplier_address_sp;
742       RETURN;
743    END IF;
744 
745    handle_address_type
746      (p_party_site_id    => p_party_site_id,
747       p_address_type     => 'RFQ',
748       p_value            => p_rfq_flag,
749       x_return_status    => x_return_status,
750       x_msg_count        => x_msg_count,
751       x_msg_data         => x_msg_data
752       );
753 
754    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
755       ROLLBACK TO update_supplier_address_sp;
756       RETURN;
757    END IF;
758 
759    -- logic for primary pay still need to be worked out
760    x_return_status := fnd_api.g_ret_sts_success;
761 
762 END update_supplier_address;
763 
764 PROCEDURE unassign_address_to_contact
765   (p_contact_party_id   IN  NUMBER,
766    p_org_party_site_id  IN  NUMBER,
767    p_vendor_id          IN  NUMBER,
768    x_return_status      OUT nocopy VARCHAR2,
769    x_msg_count          OUT nocopy NUMBER,
770    x_msg_data           OUT nocopy VARCHAR2
771    )
772 IS
773 
774 CURSOR l_cur IS
775         select ASCS.vendor_site_id, ASCS.relationship_id, ASCS.org_contact_id,
776         ASCS.rel_party_id, ASCS.party_site_id, ASCS.vendor_contact_id
777         from ap_supplier_contacts ASCS
778         where (ASCS.inactive_date is null OR ASCS.inactive_date > sysdate)
779         AND ASCS.org_party_site_id = p_org_party_site_id
780         AND ASCS.per_party_id = p_contact_party_id;
781 
782 l_rec l_cur%ROWTYPE;
783 l_vendor_contact_rec ap_vendor_pub_pkg.r_vendor_contact_rec_type;
784 
785 BEGIN
786 
787     for l_rec in l_cur loop
788 
789       l_vendor_contact_rec.vendor_site_id    := l_rec.vendor_site_id;
790       l_vendor_contact_rec.per_party_id      := p_contact_party_id;
791       l_vendor_contact_rec.relationship_id   := l_rec.relationship_id;
792       l_vendor_contact_rec.rel_party_id      := l_rec.rel_party_id;
793       l_vendor_contact_rec.org_party_site_id := p_org_party_site_id;
794       l_vendor_contact_rec.inactive_date     := sysdate;
795       l_vendor_contact_rec.vendor_contact_id := l_rec.vendor_contact_id;
796       l_vendor_contact_rec.org_contact_id    := l_rec.org_contact_id;
797       l_vendor_contact_rec.party_site_id     := l_rec.party_site_id;
798 
799       IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
800                 FND_LOG.string(fnd_log.level_statement, g_module,
801             ' Before Calling pos_vendor_pub_pkg.update_vendor_contact');
802             FND_LOG.string(fnd_log.level_statement, g_module,
803             ' per_party_id ' || p_contact_party_id);
804             FND_LOG.string(fnd_log.level_statement, g_module,
805             ' org_party_site_id ' || p_org_party_site_id);
806             FND_LOG.string(fnd_log.level_statement, g_module,
807             ' rel_party_id ' || l_rec.rel_party_id);
808             FND_LOG.string(fnd_log.level_statement, g_module,
809             ' relationship_id ' || l_rec.relationship_id);
810             FND_LOG.string(fnd_log.level_statement, g_module,
811             ' vendor_site_id ' || l_rec.vendor_site_id);
812             FND_LOG.string(fnd_log.level_statement, g_module,
813             ' org_contact_id ' || l_rec.org_contact_id);
814 
815       END IF;
816 
817       AP_VENDOR_PUB_PKG.Update_Vendor_Contact
818         (
819           p_api_version           => 1.0,
820           p_init_msg_list         => FND_API.G_TRUE,
821           p_commit                => FND_API.G_FALSE,
822           p_validation_level      => FND_API.G_VALID_LEVEL_FULL,
823           p_vendor_contact_rec    => l_vendor_contact_rec,
824           x_return_status         => x_return_status,
825           x_msg_count             => x_msg_count,
826           x_msg_data              => x_msg_data
827         );
828 
829       IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
830                 FND_LOG.string(fnd_log.level_statement, g_module,
831             ' After Calling pos_vendor_pub_pkg.update_vendor_contact');
832                 FND_LOG.string(fnd_log.level_statement, g_module,
833             ' x_return_status ' || x_return_status);
834                 FND_LOG.string(fnd_log.level_statement, g_module,
835             ' x_msg_count ' || x_msg_count);
836                 FND_LOG.string(fnd_log.level_statement, g_module,
837             ' x_msg_data ' || x_msg_data);
838       END IF;
839 
840     end loop;
841 
842 x_return_status := 'S';
843 x_msg_data := null;
844 
845 EXCEPTION
846     WHEN OTHERS THEN
847       raise_application_error(-20020, 'Failure error status ' || x_return_status || x_msg_data || Sqlerrm, true);
848 
849 END unassign_address_to_contact;
850 
851 PROCEDURE assign_address_to_contact
852   (p_contact_party_id   IN  NUMBER,
853    p_org_party_site_id  IN  NUMBER,
854    p_vendor_id          IN  NUMBER,
855    x_attribute_category   IN VARCHAR2 default null,
856    x_attribute1 IN VARCHAR2 default null,
857    x_attribute2 IN VARCHAR2 default null,
858    x_attribute3 IN VARCHAR2 default null,
859    x_attribute4 IN VARCHAR2 default null,
860    x_attribute5 IN VARCHAR2 default null,
861    x_attribute6 IN VARCHAR2 default null,
862    x_attribute7 IN VARCHAR2 default null,
863    x_attribute8 IN VARCHAR2 default null,
864    x_attribute9 IN VARCHAR2 default null,
865    x_attribute10 IN VARCHAR2 default null,
866    x_attribute11 IN VARCHAR2 default null,
867    x_attribute12 IN VARCHAR2 default null,
868    x_attribute13 IN VARCHAR2 default null,
869    x_attribute14 IN VARCHAR2 default null,
870    x_attribute15 IN VARCHAR2 default null,
871    x_return_status      OUT nocopy VARCHAR2,
872    x_msg_count          OUT nocopy NUMBER,
873    x_msg_data           OUT nocopy VARCHAR2
874    )
875   IS
876 
877     CURSOR l_cur IS
878         SELECT 1
879           FROM ap_supplier_contacts
880          WHERE org_party_site_id = p_org_party_site_id
881            AND per_party_id = p_contact_party_id
882            AND (inactive_date is null OR inactive_date >= sysdate)
883            AND rownum = 1;
884 
885      l_number NUMBER;
886 
887      l_vendor_contact_rec ap_vendor_pub_pkg.r_vendor_contact_rec_type;
888 
889      /* Bug 6610366 , Checking the Status from hz_relationships as status column
890         in hz_org_contacts is obsoleted in R12 ,Also checking for */
891 
892      CURSOR l_cur3 IS
893         SELECT hzr.relationship_id, hzr.party_id rel_party_id, hoc.org_contact_id
894           FROM ap_suppliers pv, hz_relationships hzr, hz_org_contacts hoc
895          WHERE pv.vendor_id = p_vendor_id
896             AND hzr.relationship_type = 'CONTACT'
897             AND hzr.relationship_code = 'CONTACT_OF'
898             AND hzr.subject_id = p_contact_party_id
899             AND hzr.subject_type = 'PERSON'
900             AND hzr.subject_table_name = 'HZ_PARTIES'
901             AND hzr.object_type = 'ORGANIZATION'
902             AND hzr.object_table_name = 'HZ_PARTIES'
903             AND hzr.object_id = pv.party_id
904             AND hzr.status = 'A'
905 	    AND trunc(SYSDATE) between Trunc(hzr.START_DATE) AND
906 	        NVL(Trunc(hzr.END_DATE),trunc(SYSDATE + 1))
907             AND hzr.relationship_id = hoc.party_relationship_id;
908 
909      l_rec3 l_cur3%ROWTYPE;
910      l_step                 NUMBER;
911      l_vendor_contact_id    NUMBER;
912      l_per_party_id         NUMBER;
913      l_rel_party_id         NUMBER;
914      l_rel_id               NUMBER;
915      l_org_contact_id       NUMBER;
916      l_person_party_site_id NUMBER;
917 BEGIN
918 
919    l_step := 0;
920 
921    OPEN l_cur;
922    FETCH l_cur INTO l_number;
923    IF l_cur%found THEN
924       -- already has such assignment
925       CLOSE l_cur;
926       x_return_status := fnd_api.g_ret_sts_success;
927       x_msg_count := 1;
928       x_msg_data := NULL;
929       RETURN;
930    END IF;
931 
932    l_step := 1;
933 
934    OPEN l_cur3;
935    FETCH l_cur3 INTO l_rec3;
936    IF l_cur3%notfound THEN
937       CLOSE l_cur3;
938       x_return_status := fnd_api.g_ret_sts_error;
939       x_msg_count := 1;
940       x_msg_data := 'invalid supplier contact info';
941       RETURN;
942    END IF;
943    CLOSE l_cur3;
944 
945    l_step := 2;
946 
947    l_vendor_contact_rec.vendor_site_id    := null;
948    l_vendor_contact_rec.per_party_id      := p_contact_party_id;
949    l_vendor_contact_rec.relationship_id   := l_rec3.relationship_id;
950    l_vendor_contact_rec.rel_party_id      := l_rec3.rel_party_id;
951    l_vendor_contact_rec.org_party_site_id := p_org_party_site_id;
952    l_vendor_contact_rec.org_contact_id    := l_rec3.org_contact_id;
953 
954    /* Bug 6599374 Start */
955 
956    l_vendor_contact_rec.attribute_category:=x_attribute_category;
957    l_vendor_contact_rec.attribute1:=x_attribute1;
958    l_vendor_contact_rec.attribute2:=x_attribute2;
959    l_vendor_contact_rec.attribute3:=x_attribute3;
960    l_vendor_contact_rec.attribute4:=x_attribute4;
961    l_vendor_contact_rec.attribute5:=x_attribute5;
962    l_vendor_contact_rec.attribute6:=x_attribute6;
963    l_vendor_contact_rec.attribute7:=x_attribute7;
964    l_vendor_contact_rec.attribute8:=x_attribute8;
965    l_vendor_contact_rec.attribute9:=x_attribute9;
966    l_vendor_contact_rec.attribute10:=x_attribute10;
967    l_vendor_contact_rec.attribute11:=x_attribute11;
968    l_vendor_contact_rec.attribute12:=x_attribute12;
969    l_vendor_contact_rec.attribute13:=x_attribute13;
970    l_vendor_contact_rec.attribute14:=x_attribute14;
971    l_vendor_contact_rec.attribute15:=x_attribute15;
972 
973    /* Bug 6599374 End   */
974 
975    l_step := 3;
976 
977    IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
978                 FND_LOG.string(fnd_log.level_statement, g_module,
979             ' Before Calling pos_vendor_pub_pkg.create_vendor_contact');
980             FND_LOG.string(fnd_log.level_statement, g_module,
981             ' per_party_id ' || p_contact_party_id);
982             FND_LOG.string(fnd_log.level_statement, g_module,
983             ' org_party_site_id ' || p_org_party_site_id);
984             FND_LOG.string(fnd_log.level_statement, g_module,
985             ' rel_party_id ' || l_rec3.rel_party_id);
986             FND_LOG.string(fnd_log.level_statement, g_module,
987             ' relationship_id ' || l_rec3.relationship_id);
988    END IF;
989 
990    pos_vendor_pub_pkg.create_vendor_contact
991      ( p_vendor_contact_rec  => l_vendor_contact_rec,
992        x_return_status       => x_return_status,
993        x_msg_count           => x_msg_count,
994        x_msg_data            => x_msg_data,
995        x_vendor_contact_id   => l_vendor_contact_id,
996        x_per_party_id        => l_per_party_id,
997        x_rel_party_id        => l_rel_party_id,
998        x_rel_id              => l_rel_id,
999        x_org_contact_id      => l_org_contact_id,
1000        x_party_site_id       => l_person_party_site_id
1001        );
1002 
1003    l_step := 4;
1004 
1005    IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
1006                 FND_LOG.string(fnd_log.level_statement, g_module,
1007             ' After Calling pos_vendor_pub_pkg.create_vendor_contact');
1008                 FND_LOG.string(fnd_log.level_statement, g_module,
1009             ' x_return_status ' || x_return_status);
1010                 FND_LOG.string(fnd_log.level_statement, g_module,
1011             ' x_msg_count ' || x_msg_count);
1012                 FND_LOG.string(fnd_log.level_statement, g_module,
1013             ' x_msg_data ' || x_msg_data);
1014    END IF;
1015 
1016 EXCEPTION
1017     WHEN OTHERS THEN
1018       raise_application_error(-20020, 'Failure at step ' || l_step || Sqlerrm, true);
1019 END assign_address_to_contact;
1020 
1021 /* Bug 6599374 Start */
1022 
1023 PROCEDURE update_address_assignment_dff
1024   (x_contact_party_id   IN  NUMBER,
1025    x_org_party_site_id  IN  NUMBER,
1026    x_vendor_id          IN  NUMBER,
1027    x_attribute_category   IN VARCHAR2 default null,
1028    x_attribute1 IN VARCHAR2 default null,
1029    x_attribute2 IN VARCHAR2 default null,
1030    x_attribute3 IN VARCHAR2 default null,
1031    x_attribute4 IN VARCHAR2 default null,
1032    x_attribute5 IN VARCHAR2 default null,
1033    x_attribute6 IN VARCHAR2 default null,
1034    x_attribute7 IN VARCHAR2 default null,
1035    x_attribute8 IN VARCHAR2 default null,
1036    x_attribute9 IN VARCHAR2 default null,
1037    x_attribute10 IN VARCHAR2 default null,
1038    x_attribute11 IN VARCHAR2 default null,
1039    x_attribute12 IN VARCHAR2 default null,
1040    x_attribute13 IN VARCHAR2 default null,
1041    x_attribute14 IN VARCHAR2 default null,
1042    x_attribute15 IN VARCHAR2 default null,
1043    x_return_status OUT nocopy VARCHAR2,
1044    x_msg_count OUT nocopy NUMBER,
1045    x_msg_data  OUT nocopy VARCHAR2
1046    ) IS
1047    BEGIN
1048 
1049    /* Here We Need To Call AP Package For Updating The Address Assignments */
1050 
1051    AP_VENDOR_PUB_PKG.Update_Address_Assignments_DFF
1052     (
1053     p_api_version       => 1,
1054     p_init_msg_list     => FND_API.G_FALSE,
1055     p_commit            => FND_API.G_FALSE,
1056     p_contact_party_id  => x_contact_party_id,
1057     p_org_party_site_id => x_org_party_site_id,
1058     p_attribute_category=> x_attribute_category,
1059     p_attribute1        => x_attribute1,
1060     p_attribute2        => x_attribute2,
1061     p_attribute3        => x_attribute3,
1062     p_attribute4        => x_attribute4,
1063     p_attribute5        => x_attribute5,
1064     p_attribute6        => x_attribute6,
1065     p_attribute7        => x_attribute7,
1066     p_attribute8        => x_attribute8,
1067     p_attribute9        => x_attribute9,
1068     p_attribute10       => x_attribute10,
1069     p_attribute11       => x_attribute11,
1070     p_attribute12       => x_attribute12,
1071     p_attribute13       => x_attribute13,
1072     p_attribute14       => x_attribute14,
1073     p_attribute15       => x_attribute15,
1074     x_return_status     => x_return_status,
1075     x_msg_count         => x_msg_count,
1076     x_msg_data          => x_msg_data
1077     );
1078 
1079     IF ( fnd_log.level_statement >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
1080                 FND_LOG.string(fnd_log.level_statement, g_module,
1081             ' After Calling AP_VENDOR_PUB_PKG.Update_Address_Assignments_DFF ');
1082                 FND_LOG.string(fnd_log.level_statement, g_module,
1083             ' x_return_status ' || x_return_status);
1084                 FND_LOG.string(fnd_log.level_statement, g_module,
1085             ' x_msg_count ' || x_msg_count);
1086                 FND_LOG.string(fnd_log.level_statement, g_module,
1087             ' x_msg_data ' || x_msg_data);
1088     END IF;
1089 
1090    EXCEPTION
1091    WHEN OTHERS
1092    THEN
1093    x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1094 
1095    END update_address_assignment_dff;
1096 
1097 /* Bug 6599374 End   */
1098 
1099 -- This procedure is used by the new supplier UI in r12
1100 -- to update details such as site use flags, phone,
1101 -- fax, email, notes for a supplier address
1102 PROCEDURE buyer_update_address_details
1103 (p_party_site_id     IN  NUMBER,
1104  p_rfqFlag           IN  VARCHAR2,
1105  p_purFlag           IN  VARCHAR2,
1106  p_payFlag           IN  VARCHAR2,
1107  p_primaryPayFlag    IN  VARCHAR2,
1108  p_note              IN  VARCHAR2,
1109  p_phone_area_code   IN  VARCHAR2 DEFAULT NULL,
1110  p_phone             IN  VARCHAR2 DEFAULT NULL,
1111  p_phone_contact_id  IN  NUMBER DEFAULT NULL,
1112  p_phone_obj_ver_num IN  NUMBER DEFAULT NULL,
1113  p_fax_area_code     IN  VARCHAR2 DEFAULT NULL,
1114  p_fax               IN  VARCHAR2 DEFAULT NULL,
1115  p_fax_contact_id    IN  NUMBER DEFAULT NULL,
1116  p_fax_obj_ver_num   IN  NUMBER DEFAULT NULL,
1117  p_email             IN  VARCHAR2 DEFAULT NULL,
1118  p_email_contact_id  IN  NUMBER DEFAULT NULL,
1119  p_email_obj_ver_num IN  NUMBER DEFAULT NULL,
1120  x_return_status     OUT NOCOPY VARCHAR2,
1121  x_msg_count         OUT NOCOPY NUMBER,
1122  x_msg_data          OUT NOCOPY VARCHAR2
1123  )
1124   IS
1125      l_status VARCHAR2(1);
1126      l_msg    VARCHAR2(2000);
1127 BEGIN
1128    SAVEPOINT update_supplier_address_sp;
1129 
1130    -- set phone for the address
1131    pos_hz_contact_point_pkg.update_party_site_phone
1132      (
1133       p_party_site_id     => p_party_site_id,
1134       p_country_code      =>  NULL,
1135       p_area_code         => p_phone_area_code ,
1136       p_number            => p_phone,
1137       p_extension         => NULL,
1138       x_return_status     => x_return_status,
1139       x_msg_count         => x_msg_count,
1140       x_msg_data          => x_msg_data
1141     );
1142 
1143    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
1144       ROLLBACK TO update_supplier_address_sp;
1145       RETURN;
1146    END IF;
1147 
1148    -- set fax for the address
1149    pos_hz_contact_point_pkg.update_party_site_fax
1150      (
1151       p_party_site_id     => p_party_site_id,
1152       p_country_code      =>  NULL,
1153       p_area_code         => p_fax_area_code ,
1154       p_number            => p_fax,
1155       p_extension         => NULL,
1156       x_return_status     => x_return_status,
1157       x_msg_count         => x_msg_count,
1158       x_msg_data          => x_msg_data
1159     );
1160 
1161    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
1162       ROLLBACK TO update_supplier_address_sp;
1163       RETURN;
1164    END IF;
1165 
1166    -- set email for the address
1167    pos_hz_contact_point_pkg.update_party_site_email
1168      (
1169       p_party_site_id     => p_party_site_id,
1170       p_email             => p_email,
1171       x_return_status     => x_return_status,
1172       x_msg_count         => x_msg_count,
1173       x_msg_data          => x_msg_data
1174       );
1175 
1176    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
1177       ROLLBACK TO update_supplier_address_sp;
1178       RETURN;
1179    END IF;
1180 
1181    handle_address_type
1182      (p_party_site_id    => p_party_site_id,
1183       p_address_type     => 'PAY',
1184       p_value            => p_payflag,
1185       x_return_status    => x_return_status,
1186       x_msg_count        => x_msg_count,
1187       x_msg_data         => x_msg_data
1188       );
1189 
1190    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
1191       ROLLBACK TO update_supplier_address_sp;
1192       RETURN;
1193    END IF;
1194 
1195    handle_address_type
1196      (p_party_site_id    => p_party_site_id,
1197       p_address_type     => 'PURCHASING',
1198       p_value            => p_purflag,
1199       x_return_status    => x_return_status,
1200       x_msg_count        => x_msg_count,
1201       x_msg_data         => x_msg_data
1202       );
1203 
1204    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
1205       ROLLBACK TO update_supplier_address_sp;
1206       RETURN;
1207    END IF;
1208 
1209    handle_address_type
1210      (p_party_site_id    => p_party_site_id,
1211       p_address_type     => 'RFQ',
1212       p_value            => p_rfqflag,
1213       x_return_status    => x_return_status,
1214       x_msg_count        => x_msg_count,
1215       x_msg_data         => x_msg_data
1216       );
1217 
1218    IF x_return_status IS NULL OR x_return_status <> fnd_api.g_ret_sts_success THEN
1219       ROLLBACK TO update_supplier_address_sp;
1220       RETURN;
1221    END IF;
1222 
1223    -- logic for primary pay still need to be worked out
1224    pos_address_notes_pkg.update_note
1225      ( p_party_site_id => p_party_site_id,
1226        p_note          => p_note,
1227        x_status        => l_status,
1228        x_exception_msg => l_msg
1229        );
1230 
1231    IF l_status IS NULL OR l_status <> 'S' THEN
1232       x_return_status := fnd_api.g_ret_sts_error;
1233       x_msg_data := l_msg;
1234       IF l_msg IS NOT NULL THEN
1235          x_msg_count := 1;
1236        ELSE
1237          x_msg_count := 0;
1238       END IF;
1239     ELSE
1240       x_return_status := fnd_api.g_ret_sts_success;
1241    END IF;
1242 
1243 END buyer_update_address_details;
1244 
1245 
1246 
1247 END pos_supplier_address_pkg;