DBA Data[Home] [Help]

PACKAGE BODY: APPS.AMS_SCRIPTING_PUB

Source


1 PACKAGE BODY ams_scripting_pub as
2 /* $Header: amspscrb.pls 115.5 2003/02/18 21:07:09 sodixit noship $ */
3 -- ===============================================================
4 -- Start of Comments
5 -- Package name
6 --          ams_scripting_pub
7 -- Purpose
8 --
9 -- History
10 --
11 -- NOTE
12 --
13 -- End of Comments
14 -- ===============================================================
15 
16 
17 G_PKG_NAME CONSTANT VARCHAR2(30):= 'ams_scripting_pub';
18 G_FILE_NAME CONSTANT VARCHAR2(12) := 'amspscrb.pls';
19 
20 
21 PROCEDURE Create_Customer(
22     p_api_version_number         IN   NUMBER,
23     p_init_msg_list              IN   VARCHAR2     := FND_API.G_FALSE,
24     p_commit                     IN   VARCHAR2     := FND_API.G_FALSE,
25     p_validation_level           IN   NUMBER       := FND_API.g_valid_level_full,
26     x_return_status              OUT  NOCOPY VARCHAR2,
27     x_msg_count                  OUT  NOCOPY NUMBER,
28     x_msg_data                   OUT  NOCOPY VARCHAR2,
29 
30     p_party_id			 IN OUT NOCOPY NUMBER,
31     p_b2b_flag			 IN   VARCHAR2,
32     p_import_list_header_id      IN   NUMBER,
33 
34     p_ams_party_rec              IN   ams_party_rec_type  := g_miss_ams_party_rec,
35 
36     x_new_party			 OUT  NOCOPY VARCHAR2,
37     p_component_name             OUT  NOCOPY VARCHAR2
38 )
39 
40 IS
41 L_API_NAME                  CONSTANT VARCHAR2(30) := 'Create_Customer';
42 L_API_VERSION_NUMBER        CONSTANT NUMBER   := 1.0;
43 
44 
45 
46  partyRec       	hz_party_v2pub.party_rec_type;
47  organisationRec       	hz_party_v2pub.organization_rec_type;
48  personRec      	hz_party_v2pub.person_rec_type;
49  locationRec    	hz_location_v2pub.location_rec_type;
50  partySiteRec       	hz_party_site_v2pub.party_site_rec_type;
51  partySiteUseRec   	hz_party_site_v2pub.party_site_use_rec_type;
52  contactPointRec      	hz_contact_point_v2pub.contact_point_rec_type;
53  emailRec       	hz_contact_point_v2pub.email_rec_type;
54  phoneRec       	hz_contact_point_v2pub.phone_rec_type;
55  orgContactRec        	hz_party_contact_v2pub.org_contact_rec_type;
56  webRec			hz_contact_point_v2pub.web_rec_type;
57 
58 BEGIN
59       -- Standard Start of API savepoint
60       SAVEPOINT Create_Customer_Pub;
61 
62       -- Standard call to check for call compatibility.
63       IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
64                                            p_api_version_number,
65                                            l_api_name,
66                                            G_PKG_NAME)
67       THEN
68           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
69       END IF;
70 
71 
72       -- Initialize message list if p_init_msg_list is set to TRUE.
73       IF FND_API.to_Boolean( p_init_msg_list )
74       THEN
75          FND_MSG_PUB.initialize;
76       END IF;
77 
78       -- Debug Message
79       AMS_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'start');
80 
81 
82       -- Initialize API return status to SUCCESS
83       x_return_status := FND_API.G_RET_STS_SUCCESS;
84 
85     -- Local variable initialization
86 
87       	--partyRec.party_id := p_party_id;
88 
89 
90 	organisationRec.organization_name := p_ams_party_rec.organization;
91 
92 	--personRec.party_rec     	:= p_ams_party_recpartyRec;
93 	personRec.person_first_name     := p_ams_party_rec.firstname;
94 	personRec.person_middle_name	:= p_ams_party_rec.middlename;
95 	personRec.person_last_name      := p_ams_party_rec.lastname ;
96 
97 	locationRec.country 		:= p_ams_party_rec.country;
98 	locationRec.address1		:= p_ams_party_rec.address1;
99 	locationRec.address2 		:= p_ams_party_rec.address2;
100 	locationRec.address3 		:= p_ams_party_rec.address3;
101 	locationRec.address4 		:= p_ams_party_rec.address4;
102 	locationRec.city 		:= p_ams_party_rec.city;
103 	locationRec.postal_code 	:= p_ams_party_rec.postal_code;
104 	locationRec.state 		:= p_ams_party_rec.state;
105 	locationRec.county 		:= p_ams_party_rec.county;
106 
107 	emailRec.email_address 		:= p_ams_party_rec.email;
108 
109 	phoneRec.phone_area_code 	:= p_ams_party_rec.dayareacode;
110 	phoneRec.phone_number 		:= p_ams_party_rec.daynumber;
111 	phoneRec.phone_extension 	:= p_ams_party_rec.dayextension;
112 
113 
114 
115 
116       -- =========================================================================
117       -- Validate Environment
118       -- =========================================================================
119 
120       IF FND_GLOBAL.USER_ID IS NULL
121       THEN
122          AMS_Utility_PVT.Error_Message(p_message_name => 'USER_PROFILE_MISSING');
123           RAISE FND_API.G_EXC_ERROR;
124       END IF;
125 
126 
127       -- Debug Message
128       AMS_UTILITY_PVT.debug_message( 'Public API: Calling AMS_List_Import_PUB.Create_Customer');
129 
130 	AMS_List_Import_PUB.Create_Customer (
131 	p_api_version              => p_api_version_number,
132 	p_init_msg_list            => p_init_msg_list,
133 	p_commit                   => p_commit,
134 	p_validation_level         => FND_API.g_valid_level_full,
135 	x_return_status            => x_return_status,
136 	x_msg_count                => x_msg_count,
137 	x_msg_data                 => x_msg_data,
138 	p_party_id                 => p_party_id,
139 	p_b2b_flag                 => p_b2b_flag,
140 	p_import_list_header_id    => p_import_list_header_id,
141 	p_party_rec                => partyRec,
142 	p_org_rec                  => organisationRec,
143 	p_person_rec               => personRec,
144 	p_location_rec             => locationRec,
145 	p_psite_rec                => partySiteRec,
146 	p_cpoint_rec               => contactPointRec,
147 	p_email_rec                => emailRec,
148 	p_phone_rec                => phoneRec,
149 	p_fax_rec                  => phoneRec,
150 	p_ocon_rec                 => orgContactRec,
151 	p_siteuse_rec		   => partySiteUseRec,
152         p_web_rec                  => webRec,
153 	x_new_party                => x_new_party,
154 	p_component_name           => p_component_name);
155 
156 
157 
158       --subir
159       IF x_return_status is NULL THEN
160       	x_return_status := FND_API.G_RET_STS_ERROR;
161       END IF;
162       --end
163 
164 
165       IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
166           RAISE FND_API.G_EXC_ERROR;
167       END IF;
168 
169 --
170 -- End of API body
171 --
172 
173       -- Standard check for p_commit
174       IF FND_API.to_Boolean( p_commit )
175       THEN
176          COMMIT WORK;
177       END IF;
178 
179 
180       -- Debug Message
181       AMS_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'end');
182 
183 
184       -- Standard call to get message count and if count is 1, get message info.
185       FND_MSG_PUB.Count_And_Get
186         (p_count          =>   x_msg_count,
187          p_data           =>   x_msg_data
188       );
189 EXCEPTION
190 
191    WHEN AMS_Utility_PVT.resource_locked THEN
192      x_return_status := FND_API.g_ret_sts_error;
193          AMS_Utility_PVT.Error_Message(p_message_name => 'AMS_API_RESOURCE_LOCKED');
194 
195    WHEN FND_API.G_EXC_ERROR THEN
196      ROLLBACK TO Create_Customer_Pub;
197      x_return_status := FND_API.G_RET_STS_ERROR;
198      -- Standard call to get message count and if count=1, get the message
199      FND_MSG_PUB.Count_And_Get (
200             p_encoded => FND_API.G_FALSE,
201             p_count   => x_msg_count,
202             p_data    => x_msg_data
203      );
204 
205    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
206      ROLLBACK TO Create_Customer_Pub;
207      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
208      -- Standard call to get message count and if count=1, get the message
209      FND_MSG_PUB.Count_And_Get (
210             p_encoded => FND_API.G_FALSE,
211             p_count => x_msg_count,
212             p_data  => x_msg_data
213      );
214 
215    WHEN OTHERS THEN
216      ROLLBACK TO Create_Customer_Pub;
217      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
218      IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
219      THEN
220         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
221      END IF;
222      -- Standard call to get message count and if count=1, get the message
223      FND_MSG_PUB.Count_And_Get (
224             p_encoded => FND_API.G_FALSE,
225             p_count => x_msg_count,
226             p_data  => x_msg_data
227      );
228 End Create_Customer;
229 
230 
231 
232 
233 
234 
235 
236 
237 
238 PROCEDURE Update_Person_Profile(
239 	p_api_version_number		IN  NUMBER,
240 	p_init_msg_list                 IN  VARCHAR2	 := FND_API.G_FALSE,
241 	p_commit			IN  VARCHAR2     := FND_API.G_FALSE,
242 	p_validation_level		IN  NUMBER       := FND_API.g_valid_level_full,
243 	x_return_status                 OUT NOCOPY VARCHAR2,
244 	x_msg_count                     OUT NOCOPY NUMBER,
245 	x_msg_data                      OUT NOCOPY VARCHAR2,
246 
247 	p_party_id			IN      NUMBER,
248 	p_profile_id                    IN  OUT NOCOPY NUMBER,
249 	p_person_profile_rec            IN      ams_person_profile_rec_type := g_miss_ams_person_profile_rec,
250 	p_party_object_version_number   IN  OUT NOCOPY  NUMBER
251 )
252 IS
253 
254 	L_API_NAME                  CONSTANT VARCHAR2(30) := 'Update_Person_Profile';
255 	L_API_VERSION_NUMBER        CONSTANT NUMBER   := 1.0;
256 
257 	l_personRec      	hz_party_v2pub.person_rec_type;
258 	l_partyRec       	hz_party_v2pub.party_rec_type;
259 
260 
261 BEGIN
262 	-- Standard Start of API savepoint
263 	SAVEPOINT Create_Customer_Pub;
264 
265 	-- Standard call to check for call compatibility.
266 	IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
267 			   p_api_version_number,
268 			   l_api_name,
269 			   G_PKG_NAME)
270 	THEN
271 	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
272 	END IF;
273 
274 
275 	-- Initialize message list if p_init_msg_list is set to TRUE.
276 	IF FND_API.to_Boolean( p_init_msg_list )
277 	THEN
278 		FND_MSG_PUB.initialize;
279 	END IF;
280 
281 	-- Debug Message
282 	AMS_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'start');
283 
284 
285 	-- Initialize API return status to SUCCESS
286 	x_return_status := FND_API.G_RET_STS_SUCCESS;
287 
288 	-- Local variable initialization
289 
290 	---------------------------------------------------------------------------------
291 
292 	l_partyRec.party_id := p_party_id;
293 
294 	l_personRec.date_of_birth := p_person_profile_rec.date_of_birth;
295 	l_personRec.place_of_birth := p_person_profile_rec.place_of_birth;
296 	l_personRec.gender := p_person_profile_rec.gender;
297 	l_personRec.marital_status := p_person_profile_rec.marital_status;
298 	l_personRec.marital_status_effective_date := p_person_profile_rec.marital_status_effective_date;
299 	l_personRec.personal_income := p_person_profile_rec.personal_income;
303 	l_personRec.rent_own_ind := p_person_profile_rec.rent_own_ind;
300 	l_personRec.head_of_household_flag := p_person_profile_rec.head_of_household_flag;
301 	l_personRec.household_income := p_person_profile_rec.household_income;
302 	l_personRec.household_size := p_person_profile_rec.household_size;
304 
305 	l_personRec.party_rec := l_partyRec;
306 
307 	---------------------------------------------------------------------------------
308 
309 
310 	-- =========================================================================
311 	-- Validate Environment
312 	-- =========================================================================
313 
314 	IF FND_GLOBAL.USER_ID IS NULL
315 	THEN
316 		AMS_Utility_PVT.Error_Message(p_message_name => 'USER_PROFILE_MISSING');
317 		RAISE FND_API.G_EXC_ERROR;
318 	END IF;
319 
320 	-- Debug Message
321 	AMS_UTILITY_PVT.debug_message( 'Public API: Calling HZ_PARTY_V2PUB.UPDATE_PERSON');
322 	---------------------------------------------------------------------------------
323 
324 	hz_party_v2pub.update_person (
325 	    p_init_msg_list => p_init_msg_list,
326 	    p_person_rec => l_personRec,
327 	    p_party_object_version_number  => p_party_object_version_number,
328 	    x_profile_id => p_profile_id,
329 	    x_return_status => x_return_status,
330 	    x_msg_count => x_msg_count,
331 	    x_msg_data => x_msg_data
332 	);
333 
334 	---------------------------------------------------------------------------------
335 
336 
337 	IF x_return_status is NULL THEN
338 	x_return_status := FND_API.G_RET_STS_ERROR;
339 	END IF;
340 	--end
341 
342 
343 	IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
344 	  RAISE FND_API.G_EXC_ERROR;
345 	END IF;
346 
347 	--
348 	-- End of API body
349 	--
350 
351 	-- Standard check for p_commit
352 	IF FND_API.to_Boolean( p_commit )
353 	THEN
354 	 COMMIT WORK;
355 	END IF;
356 
357 
358 	-- Debug Message
359 	AMS_UTILITY_PVT.debug_message('Public API: ' || l_api_name || 'end');
360 
361 
362 	-- Standard call to get message count and if count is 1, get message info.
363 	FND_MSG_PUB.Count_And_Get
364 	(p_count          =>   x_msg_count,
365 	 p_data           =>   x_msg_data
366 	);
367 
368 EXCEPTION
369 
370 	WHEN AMS_Utility_PVT.resource_locked THEN
371 		x_return_status := FND_API.g_ret_sts_error;
372 		AMS_Utility_PVT.Error_Message(p_message_name => 'AMS_API_RESOURCE_LOCKED');
373 
374 	WHEN FND_API.G_EXC_ERROR THEN
375 		ROLLBACK TO Create_Customer_Pub;
376 		x_return_status := FND_API.G_RET_STS_ERROR;
377 		-- Standard call to get message count and if count=1, get the message
378 		FND_MSG_PUB.Count_And_Get (
379 		    p_encoded => FND_API.G_FALSE,
380 		    p_count   => x_msg_count,
381 		    p_data    => x_msg_data
382 		);
383 
384 	WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
385 		ROLLBACK TO Create_Customer_Pub;
386 		x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
387 		-- Standard call to get message count and if count=1, get the message
388 		FND_MSG_PUB.Count_And_Get (
389 		    p_encoded => FND_API.G_FALSE,
390 		    p_count => x_msg_count,
391 		    p_data  => x_msg_data
392 		);
393 
394 	WHEN OTHERS THEN
395 		ROLLBACK TO Create_Customer_Pub;
396 		x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
397 		IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
398 		THEN
399 		FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
400 		END IF;
401 		-- Standard call to get message count and if count=1, get the message
402 		FND_MSG_PUB.Count_And_Get (
403 		    p_encoded => FND_API.G_FALSE,
404 		    p_count => x_msg_count,
405 		    p_data  => x_msg_data
406 		);
407 
408 END Update_Person_Profile;
409 
410 END ams_scripting_pub;