[Home] [Help]
PACKAGE BODY: APPS.IBY_ADDRESS_PKG
Source
1 package body iby_address_pkg as
2 /*$Header: ibyadrsb.pls 120.1 2005/10/30 05:49:33 appldev noship $*/
3 /*
4 ** Function: createAddress
5 ** Purpose: Creates an entry in the iby_address table and assigns an id
6 ** to identify it.
7 ** Parameters:
8 **
9 ** In : i_address1, i_address2, i_address3, i_city, i_county,
10 ** i_state, i_country, i_postalcode.
11 ** Out : io_addressid.
12 **
13 */
14 procedure createAddress( i_address1 hz_locations.address1%type,
15 i_address2 hz_locations.address2%type,
16 i_address3 hz_locations.address3%type,
17 i_city hz_locations.city%type,
18 i_county hz_locations.county%type,
19 i_state hz_locations.state%type,
20 i_country hz_locations.country%type,
21 i_postalcode hz_locations.postal_code%type,
22 o_addressid out nocopy hz_locations.location_id%type)
23 is
24
25 p_api_version NUMBER := 1;
26 p_init_msg_list VARCHAR2(1) := fnd_api.G_TRUE;
27 p_commit VARCHAR2(1) := fnd_api.G_FALSE;
28 l_hz_location_v2_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
29 --location_rec hz_location_pub.location_rec_type;
30 l_location_id number;
31 msg_txt varchar2(2000);
32 l_return_status varchar2(100);
33
34 l_msg_count number;
35 l_msg_data varchar2(2000);
36
37 begin
38 --fnd_client_info.set_org_context(204);
39
40 l_hz_location_v2_rec.address1 := i_address1;
41 l_hz_location_v2_rec.address2 := i_address2;
42 l_hz_location_v2_rec.address3 := i_address3;
43 l_hz_location_v2_rec.city := i_city;
44 l_hz_location_v2_rec.state := i_state;
45 l_hz_location_v2_rec.county := i_county;
46 l_hz_location_v2_rec.postal_code := i_postalcode;
47 l_hz_location_v2_rec.country := i_country;
48 l_hz_location_v2_rec.created_by_module := 'IBY';
49
50 --dbms_output.put_line('Before hz_location.create ');
51
52 hz_location_v2pub.create_location(
53 p_location_rec => l_hz_location_v2_rec,
54 x_location_id => l_location_id,
55 x_return_status => l_return_status,
56 x_msg_count => l_msg_count,
57 x_msg_data => l_msg_data);
58 /*
59 HZ_LOCATION_PUB.create_location(
60 p_api_version,
61 p_init_msg_list,
62 p_commit,
63 location_rec,
64 l_return_status,
65 l_msg_count,
66 l_msg_data,
67 l_location_id);
68 */
69 --dbms_output.put_line('x_msg_count = '||to_char(l_msg_count));
70 --dbms_output.put_line('l_return_status = '||l_return_status);
71 --dbms_output.put_line('x_msg_data = '||l_msg_data);
72 --dbms_output.put_line('location_id = '||to_char(l_location_id));
73
74 /*
75 ** Catch the exception if create not successful
76 */
77 if l_return_status <> 'S' then
78 if l_msg_count = 1 then
79 msg_txt := l_msg_data;
80 else
81 for i in 1..l_msg_count loop
82
83 msg_txt := msg_txt ||' '|| FND_MSG_PUB.GET(i,'F');
84
85 end loop;
86
87 -- o_msg := msg_txt;
88 end if;
89 --dbms_output.put_line('text is : '||msg_txt);
90 --raise_application_error(-20000,'IBY_204550#CCM_API_MSG=' || msg_txt,FALSE);
91 raise_application_error(-20000,'IBY_20496#CCM_API_MSG=' || msg_txt,FALSE);
92 -- returns message 'Could not create or modify address information. Data entered could be invalid.'
93 --dbms_output.put_line('Error : '||'Location not created');
94 --ROLLBACK TO CreateOrganization;
95 end if;
96
97 o_addressid := l_location_id;
98 end createAddress;
99 /*
100 ** Function: modAddress
101 ** Purpose: modifies the entry in the hz_locations table that matches addressid
102 ** passed with the values specified.
103 ** Parameters:
104 **
105 ** In : i_addressid, i_address1, i_address2, i_address3, i_city,
106 ** i_county, i_state, i_country, i_postalcode.
107 ** Out : None.
108 **
109 */
110 procedure modAddress(i_addressid hz_locations.location_id%type,
111 i_address1 hz_locations.address1%type,
112 i_address2 hz_locations.address2%type,
113 i_address3 hz_locations.address3%type,
114 i_city hz_locations.city%type,
115 i_county hz_locations.county%type,
116 i_state hz_locations.state%type,
117 i_country hz_locations.country%type,
118 i_postalcode hz_locations.postal_code%type)
119 is
120 p_api_version NUMBER := 1;
121 p_init_msg_list VARCHAR2(1) := fnd_api.G_TRUE;
122 p_commit VARCHAR2(1) := fnd_api.G_FALSE;
123 -- location_rec hz_location_pub.location_rec_type;
124 l_hz_location_v2_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
125 l_ovn NUMBER;
126 l_location_id number;
127 msg_txt varchar2(2000);
128 l_return_status varchar2(100);
129 l_msg_count number;
130 l_msg_data varchar2(2000);
131 p_last_update_date date;
132 begin
133
134 /*
135 ** Get the last update date from hz_location
136 */
137 --fnd_client_info.set_org_context(204);
138 l_hz_location_v2_rec.address1 := i_address1;
139 l_hz_location_v2_rec.address2 := i_address2;
140 l_hz_location_v2_rec.address3 := i_address3;
141 l_hz_location_v2_rec.city := i_city;
142 l_hz_location_v2_rec.state := i_state;
143 l_hz_location_v2_rec.county := i_county;
144 l_hz_location_v2_rec.postal_code := i_postalcode;
145 l_hz_location_v2_rec.country := i_country;
146 l_hz_location_v2_rec.location_id := i_addressid;
147
148 /*
149 ** Get the last update date from hz_location
150 */
151 -- it doesn't make sense to change the payment API signature
152 -- for the OVN. we are assuming that no body has changed the
153 -- hz_location record since the user for our transaction read
154 -- the record. otherwise the change will simply be overwritten
155 select last_update_date, object_version_number into p_last_update_date, l_ovn
156 from hz_locations
157 where location_id = l_hz_location_v2_rec.location_id;
158
159 hz_location_v2pub.update_location(
160 p_location_rec => l_hz_location_v2_rec,
161 p_object_version_number => l_ovn,
162 x_return_status => l_return_status,
163 x_msg_count => l_msg_count,
164 x_msg_data => l_msg_data
165 );
166 /*
167 HZ_LOCATION_PUB.update_location(
168
169 p_api_version,
170 p_init_msg_list,
171 p_commit,
172 location_rec,
173 p_last_update_date,
174 l_return_status,
175 l_msg_count,
176 l_msg_data);
177 */
178
179 --dbms_output.put_line('x_msg_count = '||to_char(l_msg_count));
180
181 --dbms_output.put_line('l_return_status = '||l_return_status);
182 --dbms_output.put_line('x_msg_data = '||l_msg_data);
183
184 /*
185 ** Catch the exception if create not successful
186 */
187
188 if l_return_status <> 'S' then
189 if l_msg_count = 1 then
190 msg_txt := l_msg_data;
191 else
192
193 for i in 1..l_msg_count loop
194 msg_txt := msg_txt ||' '|| FND_MSG_PUB.GET(i,'F');
195 end loop;
196 -- o_msg := msg_txt;
197 end if;
198 --dbms_output.put_line('text is : '||msg_txt);
199 --raise_application_error(-20000,'IBY_204550#CCM_API_MSG=' || msg_txt,FALSE);
200 raise_application_error(-20000,'IBY_20496#CCM_API_MSG=' || msg_txt,FALSE);
201 -- returns message 'Could not create or modify address information. Data entered could be invalid.'
202 --dbms_output.put_line('Error : '||'Location not updated');
203 --ROLLBACK TO CreateOrganization;
204
205 end if;
206
207 --raise_application_error(-20902, 'NO Address Info matched ', FALSE);
208 end modAddress;
209 end iby_address_pkg;
210