1 PACKAGE BODY PON_VENDOR_PURGE_GRP as
2 -- $Header: PONVDPGB.pls 120.0 2005/06/01 15:11:05 appldev noship $
3
4
5 -- returns 'Y' if the vendor can be purged
6 -- returns 'N' if the vendor should not be purged
7 function validate_vendor_purge (
8 p_api_version IN NUMBER,
9 p_init_msg_list IN VARCHAR2,
10 x_return_status OUT NOCOPY VARCHAR2,
11 x_msg_count OUT NOCOPY NUMBER,
12 x_msg_data OUT NOCOPY VARCHAR2,
13 p_vendor_id IN NUMBER)
14 RETURN VARCHAR2 IS
15
16 l_api_version NUMBER := 1.0;
17 l_api_name VARCHAR2(50) := 'validate_po_purge';
18 l_vendor_tp_id NUMBER;
19 l_vendor_refs NUMBER;
20
21 BEGIN
22 -- initialize return for unexpected error
23 x_return_status := fnd_api.g_ret_sts_unexp_error;
24
25 -- Standard call to check for call compatibility.
26 IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version,
27 l_api_name, l_api_name) THEN
28 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
29 END IF;
30
31 -- Initialize message list if p_init_msg_list is set to TRUE.
32 IF FND_API.to_boolean(p_init_msg_list) THEN
33 FND_MSG_PUB.initialize();
34 END IF;
35
36 select count(*)
37 into l_vendor_refs
38 from pon_bid_headers
39 where vendor_id = p_vendor_id;
40
41 if (l_vendor_refs > 0) then
42 if (fnd_log.level_statement >= fnd_log.g_current_runtime_level) then
43 fnd_log.string(fnd_log.level_statement,
44 'pon.vendor_purge',
45 'validation failed in pon_bid_headers');
46 end if;
47
48 x_return_status := fnd_api.g_ret_sts_success;
49 return 'N';
50 end if;
51
52 -- don't bother to check in pon_bid_item_prices
53 -- since you must have a header to have an item
54
55 -- also ignore vendor references in pon_acknowledgements
56 -- the caller knows that he may be eliminating a supplier who intends
57 -- to participate in a sourcing event
58
59 l_vendor_tp_id := POS_VENDOR_UTIL_PKG.get_party_id_for_vendor(p_vendor_id);
60
61 select count(*)
62 into l_vendor_refs
63 from pon_bidding_parties
64 where trading_partner_id = l_vendor_tp_id;
65
66 x_return_status := fnd_api.g_ret_sts_success;
67
68 if (l_vendor_refs > 0) then
69 if (fnd_log.level_statement >= fnd_log.g_current_runtime_level) then
70 fnd_log.string(fnd_log.level_statement,
71 'pon.vendor_purge',
72 'validation failed in pon_bidding_parties');
73 end if;
74
75 return 'N';
76 else
77 return 'Y';
78 end if;
79
80 END validate_vendor_purge;
81
82
83 -- this is a placeholder for future code.
84 -- this is not even called by AP
85 procedure vendor_purge (
86 p_api_version IN NUMBER,
87 p_init_msg_list IN VARCHAR2,
88 p_commit IN VARCHAR2,
89 x_return_status OUT NOCOPY VARCHAR2,
90 x_msg_count OUT NOCOPY NUMBER,
91 x_msg_data OUT NOCOPY VARCHAR2,
92 p_vendor_id IN NUMBER) IS
93
94 l_api_version NUMBER := 1.0;
95 l_api_name VARCHAR2(50) := 'validate_po_purge';
96 l_vendor_tp_id NUMBER;
97 l_vendor_refs NUMBER;
98
99 BEGIN
100 -- initialize return for unexpected error
101 x_return_status := fnd_api.g_ret_sts_unexp_error;
102
103 -- Standard call to check for call compatibility.
104 IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version,
105 l_api_name, l_api_name) THEN
106 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
107 END IF;
108
109 -- Initialize message list if p_init_msg_list is set to TRUE.
110 IF FND_API.to_boolean(p_init_msg_list) THEN
111 FND_MSG_PUB.initialize();
112 END IF;
113
114 -- since we never validate a vendor purge with a reference in sourcing,
115 -- there is nothing to do here
116
117 x_return_status := fnd_api.g_ret_sts_success;
118
119 if (p_commit = fnd_api.g_true) then
120 commit;
121 end if;
122
123 end vendor_purge;
124
125 end PON_VENDOR_PURGE_GRP;