DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_UM_BUSINESS_USER_PVT

Source


1 PACKAGE BODY JTF_UM_BUSINESS_USER_PVT as
2 /* $Header: JTFVUBRB.pls 120.2.12010000.2 2008/08/14 21:23:49 dbowles ship $ */
3 -- Start of Comments
4 -- Package name     : JTF_UM_BUSINESS_USER_PVT
5 -- Purpose          :
6 --   This package contains specification business user registration
7 G_PKG_NAME CONSTANT VARCHAR2(30):= 'JTF_UM_BUSINESS_USER_PVT';
8 G_FILE_NAME CONSTANT VARCHAR2(12) := 'JTFVUBRB.pls';
9 G_USER_ID         NUMBER := FND_GLOBAL.USER_ID;
10 G_LOGIN_ID        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
11 G_MODULE          VARCHAR2(40) := 'JTF.UM.PLSQL.REGBUSINESSUSER';
12 l_is_debug_parameter_on boolean := JTF_DEBUG_PUB.IS_LOG_PARAMETERS_ON(G_MODULE);
13 NEWLINE	VARCHAR2(1) := fnd_global.newline;
14 G_CREATED_BY_MODULE VARCHAR2(20):= 'JTA_USER_MANAGEMENT';
15 /**
16  * Procedure   :  RegisterBusinessUser
17  * Type        :  Private
18  * Pre_reqs    :
19  * Description :
20  * Parameters  :
21  *
22  * input parameters ()
23  *     param  requester_user_name     (*)
24  *  (*) required fields
25  *
26  * output parameters
27  *     param  x_return_status
28  *     param  x_msg_data
29  *     param  x_msg_count
30  *
31  * Errors      : Expected Errors
32  *
33  * Other Comments :
34  */
35 Procedure RegisterBusinessUser
36 (
37     P_Api_Version_Number        IN      NUMBER,
38     P_Init_Msg_List             IN      VARCHAR2     := FND_API.G_FALSE,
39     P_Commit                    IN      VARCHAR2     := FND_API.G_FALSE,
40     P_self_service_user         IN      VARCHAR2     := FND_API.G_FALSE,
41     P_um_person_Rec             IN out NOCOPY  JTF_UM_REGISTER_USER_PVT.Person_Rec_type,
42     P_um_organization_Rec       IN out NOCOPY  JTF_UM_REGISTER_USER_PVT.Organization_Rec_type,
43     X_Return_Status             out NOCOPY     VARCHAR2,
44     X_Msg_Count                 out NOCOPY     NUMBER,
45     X_Msg_data                  out NOCOPY     VARCHAR2
46 ) IS
47 l_api_version_number            number  := 1.0;
48 l_person_rec                    HZ_PARTY_V2PUB.PERSON_REC_TYPE;
49 l_contact_preference_rec HZ_CONTACT_PREFERENCE_V2PUB.CONTACT_PREFERENCE_REC_TYPE;
50 l_party_number                  varchar2(100);
51 l_org_contact_id	            NUMBER;
52 l_party_rel_id		            NUMBER;
53 l_party_id		                NUMBER;
54 l_contact_preference_id             NUMBER;
55 l_search_value                  varchar2(360);
56 l_profile_id                    number;
57 l_contact_point_id              number;
58 l_contact_point_rec             HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE;
59 l_email_rec                     HZ_CONTACT_POINT_V2PUB.EMAIL_REC_TYPE;
60 l_phone_rec                     HZ_CONTACT_POINT_V2PUB.PHONE_REC_TYPE;
61 l_api_name                      varchar2(50) := 'RegisterBusinessUser';
62 l_check_existing_org_option     varchar2(10) := 'N';
63 l_org_contact_rec               HZ_PARTY_CONTACT_V2PUB.org_contact_rec_type;
64 l_party_rel_rec                 HZ_RELATIONSHIP_V2PUB.relationship_rec_type;
65 l_password_Date                 date := null;
66 l_create_organization           boolean := false;
67 l_privacy_preference varchar2(5);
68 cursor c_user_id(p_user_name in varchar2) is select user_id from fnd_user where user_name = p_user_name;
69 BEGIN
70     JTF_DEBUG_PUB.LOG_ENTERING_METHOD( p_module => G_MODULE,
71                     p_message   => l_api_name);
72    -- Standard Start of API savepoint
73     SAVEPOINT RegisterBusinessUser;
74     -- Standard call to check for call compatibility.
75     IF NOT FND_API.Compatible_API_Call ( l_api_version_number, p_api_version_number, l_api_name, G_PKG_NAME ) THEN
76         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
77     END IF;
78     -- Initialize message list if p_init_msg_list is set to TRUE.
79     IF FND_API.to_Boolean( p_init_msg_list ) THEN
80         FND_MSG_PUB.initialize;
81     END IF;
82     --  Initialize API return status to success
83     x_return_status := FND_API.G_RET_STS_SUCCESS;
84     --
85     -- API body
86     --
87   -- creating a person in TCA schema
88   JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE, p_message   => 'invoking HZ_PARTY_V2PUB.create_person with first and last name');
89   l_person_rec.person_first_name := P_um_person_Rec.first_name;
90   l_person_rec.person_last_name  := P_um_person_Rec.last_name;
91   l_person_rec.created_by_module := G_CREATED_BY_MODULE;
92   l_person_rec.application_id    := 690;
93   l_privacy_preference := p_um_person_rec.privacy_preference;
94   HZ_PARTY_V2PUB.create_person (
95     p_person_rec                 => l_person_rec,
96     x_party_id                   => p_um_person_rec.party_id,
97     x_party_number               => l_party_number,
98     x_profile_id                 => l_profile_id,
99     x_return_status              => X_Return_Status,
100     x_msg_count                  => X_Msg_Count,
101     x_msg_data                   => X_Msg_Data);
102 if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
103     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
104 end if;
105     IF ( P_um_organization_Rec.organization_number is null ) then
106         --l_check_existing_org_option := nvl(fnd_profile.get('JTF_CHECK_EXISTING_ORG', l_check_existing_org_option ), l_check_existing_org_option );
107         l_create_organization   := true;
108         fnd_profile.get('JTF_CHECK_EXISTING_ORG', l_check_existing_org_option );
109         if ( l_check_existing_org_option = 'Y' ) then
110             l_search_value  := P_um_organization_Rec.organization_name;
111             if ( not Find_Organization(
112                 x_org_rec           => P_um_organization_Rec,
113                 p_search_value      => l_search_value,
114                 p_use_name          => true ) ) then
115                 Create_Organization(
116                     P_Api_Version_Number        =>  P_Api_Version_Number,
117                     P_Init_Msg_List             =>  P_Init_Msg_List,
118                     P_Commit                    =>  P_Commit,
119                     P_um_person_Rec             =>  P_um_person_Rec ,
120                     P_um_organization_Rec       =>  P_um_organization_Rec,
121                     X_Return_Status             =>  X_Return_Status,
122                     X_Msg_Count                 =>  X_Msg_Count,
123                     X_Msg_data                  =>  X_Msg_data );
124                 if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
125                     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
126                 end if;
127             end if;
128         else
129                 Create_Organization(
130                     P_Api_Version_Number        =>  P_Api_Version_Number,
131                     P_Init_Msg_List             =>  P_Init_Msg_List,
132                     P_Commit                    =>  P_Commit,
133                     P_um_person_Rec             =>  P_um_person_Rec ,
134                     P_um_organization_Rec       =>  P_um_organization_Rec,
135                     X_Return_Status             =>  X_Return_Status,
136                     X_Msg_Count                 =>  X_Msg_Count,
137                     X_Msg_data                  =>  X_Msg_data );
138                 if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
139                     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
140                 end if;
141         end if;
142     ELSE
143         l_search_value    := P_um_organization_Rec.organization_number;
144         if ( not Find_Organization(
145             x_org_rec           => P_um_organization_Rec,
146             p_search_value      => l_search_value,
147             p_use_name          => false ) ) then
148             FND_MESSAGE.Set_Name('JTF', 'JTA_UM_ORGANIZATION_NOT_FOUND');
149             FND_MSG_PUB.ADD;
150             RAISE FND_API.G_EXC_ERROR;
151         end if;
152   END IF;
153 --l_party_rel_rec.party_rec.total_num_of_orders   :=  0;
154 l_party_rel_rec.subject_id                      :=  p_um_person_rec.party_id;
155 l_party_rel_rec.subject_type                    :=  'PERSON';
156 l_party_rel_rec.subject_table_name             :=  'HZ_PARTIES';
157 l_party_rel_rec.relationship_type               :=  'EMPLOYMENT';
158 l_party_rel_rec.relationship_code              :=  'EMPLOYEE_OF';
159 l_party_rel_rec.start_date                     := nvl(p_um_person_rec.start_Date_active, sysdate);
160 l_party_rel_rec.object_id                       :=  p_um_organization_rec.org_party_id;
161 l_party_rel_rec.object_type                    :=  'ORGANIZATION';
162 l_party_rel_rec.object_table_name             :=  'HZ_PARTIES';
163 l_party_rel_rec.created_by_module := G_CREATED_BY_MODULE;
164 l_party_rel_rec.application_id    := 690;
165 l_org_contact_rec.party_rel_rec                 :=  l_party_rel_rec;
166 l_org_contact_rec.created_by_module := G_CREATED_BY_MODULE;
167 l_org_contact_rec.application_id    := 690;
168 HZ_PARTY_CONTACT_V2PUB.create_org_contact (
169         p_init_msg_list             =>  P_Init_Msg_List,
170         p_org_contact_rec	        =>  l_org_contact_rec,
171         x_org_contact_id            =>  p_um_organization_rec.org_contact_party_id,
172         x_party_rel_id              =>  l_party_rel_id,
173         x_party_id                  =>  l_party_id,
174         x_party_number              =>  l_party_number,
175         x_return_status             =>  X_Return_Status,
176         x_msg_count                 =>  X_Msg_Count,
177         x_msg_data                  =>  X_Msg_data
178         );
179 if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
180     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
181 end if;
182 /*if ( l_create_organization ) then
183     --JTF_UM_USERTYPE_CREDENTIALS.ASSIGN_ACCOUNT(P_um_organization_Rec.org_contact_party_id, 'PRIMARYUSERNEW', P_um_organization_Rec.org_party_id );
184     -- should send l_party_id as the param which is the
185     JTF_UM_USERTYPE_CREDENTIALS.ASSIGN_ACCOUNT(l_party_id, 'PRIMARYUSERNEW', P_um_organization_Rec.org_party_id );
186 end if;
187 */
188   -- if it is a self service user then set the password date to sysdate so
189   -- that the user is not prompted at the first logon
190   if (p_self_service_user = FND_API.G_TRUE) then
191     l_password_date := sysdate;
192   end if;
193  --Start Changes for Reserve-Release User Name: 3899304
194 /*
195 FND_USER_PKG.CreateUser (
196     x_user_name                 => p_um_person_rec.user_name,
197     x_owner                     => null,
198     x_unencrypted_password      => p_um_person_rec.password,
199     x_password_date             => l_password_date,
200     x_start_date                => nvl( p_um_person_rec.start_date_active, sysdate),
201     x_email_address             => p_um_person_rec.email_address,
202     x_customer_id	            => l_party_id
203     );
204   */
205   -- reserve this username dont create a FND_USER with this name
206 
207   p_um_person_rec.user_id :=fnd_user_pkg.CreatePendingUser (
208         x_user_name                  => p_um_person_rec.user_name,
209         x_owner                      => null,
210         x_unencrypted_password       => p_um_person_rec.password,
211         x_password_date              => l_password_date,
212         x_email_address              => p_um_person_rec.email_address,
213        x_person_party_id            => p_um_person_rec.party_id
214         );
215 
216 	fnd_user_pkg.UpdateUser(
217 			x_user_name=>p_um_person_rec.user_name,
218 			x_owner=>null,
219 			x_customer_id=>l_party_id
220 			);
221 
222 --for i in c_user_id(upper(p_um_person_rec.user_name)) loop
223 --    p_um_person_rec.user_id := i.user_id;
224 --end loop;
225 l_contact_point_rec.status            :=  'A';
226 l_contact_point_rec.owner_table_name  :=  'HZ_PARTIES';
227 l_contact_point_rec.owner_table_id    :=  l_party_id;
228 l_contact_point_rec.primary_flag      :=  'Y';
229 l_contact_point_rec.created_by_module :=  G_CREATED_BY_MODULE;
230 l_contact_point_rec.application_id    :=  690;
231 if ( p_um_person_rec.email_address is not NULL ) then
232     l_contact_point_rec.contact_point_type := 'EMAIL';
233     l_email_rec.email_address := p_um_person_rec.email_address;
234     l_email_rec.email_format  := 'MAILTEXT';
235     HZ_CONTACT_POINT_V2PUB.create_contact_point (
236         p_contact_point_rec           => l_contact_point_rec,
237         p_email_rec                   => l_email_rec,
238         x_contact_point_id            => l_contact_point_id,
239         x_return_status               => X_Return_Status,
240         x_msg_count                   => X_Msg_Count,
241         x_msg_data                    => X_Msg_Data);
242 end if;
243 if ( p_um_person_rec.phone_number is not NULL ) then
244     l_contact_point_rec.contact_point_type := 'PHONE';
245     l_phone_rec.phone_area_code := nvl( p_um_person_rec.phone_area_code, '' );
246     l_phone_rec.phone_number := p_um_person_rec.phone_number;
247     l_phone_rec.phone_line_type := 'GEN';
248     HZ_CONTACT_POINT_V2PUB.create_contact_point (
249       p_contact_point_rec               => l_contact_point_rec,
250       p_phone_rec                       => l_phone_rec,
251       x_contact_point_id                => l_contact_point_id,
252       x_return_status                   => X_Return_Status,
253       x_msg_count                       => X_Msg_Count,
254       x_msg_data                        => X_Msg_Data );
255     if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
256            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
257     end if;
258 end if;
259     JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE,
260                     p_message   => 'invoking JTF_UM_USERTYPE_CREDENTIALS.ASSIGN_ACCOUNT with party id ' || p_um_person_rec.party_id || ' usertypekey INDIVIDUALUSER');
261     --JTF_UM_USERTYPE_CREDENTIALS.ASSIGN_ACCOUNT(p_um_person_rec.party_id, 'BUSINESSUSER');
262      if (l_privacy_preference = 'YES') then
263    l_contact_preference_rec.preference_code := 'DO';
264    else
265    l_contact_preference_rec.preference_code := 'DO_NOT';
266    end if;
267      -- call Hz_contact_preference api to populate the
268      -- preference to recieve marketing/promotion mails
269   JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE,
270                     p_message   => 'invoking HZ_CONTACT_PREFERENCE_V2PUB.create_contact_preference for creating preference of receiving email preference:'||l_privacy_preference);
271      l_contact_preference_rec.contact_level_table := 'HZ_PARTIES';
272      -- populate contact level id with l_party_id which is the relationship_id
273      l_contact_preference_rec.contact_level_table_id := l_party_id;
274      l_contact_preference_rec.contact_type := 'EMAIL';
275      l_contact_preference_rec.requested_by := 'PARTY';
276      l_contact_preference_rec.created_by_module := G_CREATED_BY_MODULE;
277      l_contact_preference_rec.application_id := 690;
278      HZ_CONTACT_PREFERENCE_V2PUB.create_contact_preference(
279      --p_init_msg_list                         IN      VARCHAR2:= FND_API.G_FALSE,
280      p_contact_preference_rec          => l_contact_preference_rec,
281      x_contact_preference_id           => l_contact_preference_id,
282      x_return_status                   => x_return_status,
283      x_msg_count                       => x_msg_count,
284      x_msg_data                        => x_msg_data
285      );
286     if l_is_debug_parameter_on then
287     JTF_DEBUG_PUB.LOG_PARAMETERS( p_module => G_MODULE,
288     p_message => 'create contact preferece'||' l_cont_preference_id:'||l_contact_preference_id || ' returnStatus:'||x_return_status);
289     end if;
290     if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
291            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
292     end if;
293     -- Standard check for p_commit
294     IF FND_API.to_Boolean( p_commit )
295     THEN
296         COMMIT WORK;
297     END IF;
298     -- Standard call to get message count and if count is 1, get message info.
299     FND_MSG_PUB.Count_And_Get(
300 	p_count	=> x_msg_count,
301 	p_data	=> x_msg_data);
302     JTF_DEBUG_PUB.LOG_EXITING_METHOD(
303                     p_module => G_MODULE,
304                     p_message   => l_api_name);
305     EXCEPTION
306       WHEN FND_API.G_EXC_ERROR THEN
307 	JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
308 		   P_API_NAME => L_API_NAME
309 		  ,P_PKG_NAME => G_PKG_NAME
310 		  ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_ERROR
311 		  ,P_SQLCODE => SQLCODE
312 		  ,P_SQLERRM => SQLERRM
313 		  ,X_MSG_COUNT => X_MSG_COUNT
314 		  ,X_MSG_DATA => X_MSG_DATA
315 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
316        WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
317 	 JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
318 		   P_API_NAME => L_API_NAME
319 		  ,P_PKG_NAME => G_PKG_NAME
320 		  ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR
321 		  ,P_SQLCODE => SQLCODE
322 		  ,P_SQLERRM => SQLERRM
323 		  ,X_MSG_COUNT => X_MSG_COUNT
324 		  ,X_MSG_DATA => X_MSG_DATA
325 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
326        WHEN OTHERS THEN
327 	  JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
328 		   P_API_NAME => L_API_NAME
329 		  ,P_PKG_NAME => G_PKG_NAME
330 		  ,P_EXCEPTION_LEVEL => JTF_DEBUG_PUB.G_EXC_OTHERS
331 		  ,P_SQLCODE => SQLCODE
332 		  ,P_SQLERRM => SQLERRM
333 		  ,X_MSG_COUNT => X_MSG_COUNT
334 		  ,X_MSG_DATA => X_MSG_DATA
335 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
336 END RegisterBusinessUser;
337 /**
338  * Procedure   :  Create_Organization
339  * Type        :  Private
340  * Pre_reqs    :
341  * Description :
342  * Parameters  :
343  *
344  * input parameters ()
345  *     param  requester_user_name     (*)
346  *  (*) required fields
347  *
348  * output parameters
349  *     param  x_return_status
350  *     param  x_msg_data
351  *     param  x_msg_count
352  *
353  * Errors      : Expected Errors
354  *
355  * Other Comments :
356  */
357 Procedure Create_Organization
358 (
359     P_Api_Version_Number        IN      NUMBER,
360     P_Init_Msg_List             IN      VARCHAR2     := FND_API.G_FALSE,
361     P_Commit                    IN      VARCHAR2     := FND_API.G_FALSE,
362     P_um_person_Rec             IN out NOCOPY  JTF_UM_REGISTER_USER_PVT.Person_Rec_type,
363     P_um_organization_Rec       IN out NOCOPY  JTF_UM_REGISTER_USER_PVT.Organization_Rec_type,
364     X_Return_Status             out NOCOPY     VARCHAR2,
365     X_Msg_Count                 out NOCOPY     NUMBER,
366     X_Msg_data                  out NOCOPY     VARCHAR2
367 ) IS
368 l_api_version_number            number := 1.0;
369 l_person_rec                    HZ_PARTY_V2PUB.PERSON_REC_TYPE;
370 l_HzOrganizationRec             HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
371 l_profile_id                    number;
372 l_contact_point_id              number;
373 l_contact_point_rec             HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE;
374 l_location_rec                  HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
375 l_location_id                   l_location_rec.location_id%TYPE;
376 l_party_site_rec                HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
377 l_party_site_id                 l_party_site_rec.party_site_id%type;
378 l_party_site_number             l_party_site_rec.party_site_number%type;
379 l_email_rec                     HZ_CONTACT_POINT_V2PUB.EMAIL_REC_TYPE;
380 l_phone_rec                     HZ_CONTACT_POINT_V2PUB.PHONE_REC_TYPE;
381 l_api_name                      varchar2(50) := 'Create_Organization';
382 BEGIN
383     JTF_DEBUG_PUB.LOG_ENTERING_METHOD( p_module => G_MODULE, p_message   => l_api_name);
384    -- Standard Start of API savepoint
385     SAVEPOINT create_organization;
386     -- Standard call to check for call compatibility.
387     IF NOT FND_API.Compatible_API_Call ( l_api_version_number, p_api_version_number, l_api_name, G_PKG_NAME )
388     THEN
389         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
390     END IF;
391     -- Initialize message list if p_init_msg_list is set to TRUE.
392     IF FND_API.to_Boolean( p_init_msg_list ) THEN
393         FND_MSG_PUB.initialize;
394     END IF;
395     --  Initialize API return status to success
396     x_return_status := FND_API.G_RET_STS_SUCCESS;
397     --
398     -- API body
399     --
400 l_HzOrganizationRec.organization_name   := P_um_organization_Rec.organization_name;
401 l_HzOrganizationRec.created_by_module   := G_CREATED_BY_MODULE;
402 l_HzOrganizationRec.application_id      := 690;
403 HZ_PARTY_V2PUB.create_organization(
404     p_init_msg_list                    =>   P_Init_Msg_List,
405     p_organization_rec                 =>   l_HzOrganizationRec,
406     x_return_status                    =>   X_Return_Status,
407     x_msg_count                        =>   X_Msg_Count,
408     x_msg_data                         =>   X_Msg_data,
409     x_party_id                         =>   P_um_organization_Rec.org_party_id,
410     x_party_number                     =>   P_um_organization_Rec.organization_number, --check to see if this is null or not, if null get nextval from HZ_GENERATE_PARTY_NUMBER
411     x_profile_id                       =>   l_profile_id
412 );
413 if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
414     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
415 end if;
416 l_location_rec.address1                :=  P_um_organization_Rec.address1;
417 l_location_rec.address2                :=  P_um_organization_Rec.address2;
418 l_location_rec.address3                :=  P_um_organization_Rec.address3;
419 l_location_rec.address4                :=  P_um_organization_Rec.address4;
420 l_location_rec.city                    :=  P_um_organization_Rec.city;
421 l_location_rec.state                   :=  P_um_organization_Rec.state;
422 l_location_rec.postal_code             :=  P_um_organization_Rec.postal_code;
423 l_location_rec.country                 :=  P_um_organization_Rec.country;
424 l_location_rec.county                  :=  P_um_organization_Rec.county;
425 l_location_rec.province                :=  P_um_organization_Rec.province;
426 l_location_rec.address_lines_phonetic  :=  P_um_organization_Rec.altaddress;
427 l_location_rec.created_by_module    :=  G_CREATED_BY_MODULE;
428 l_location_rec.application_id       :=  690;
429 HZ_LOCATION_V2PUB.create_location(
430     p_init_msg_list                     =>  P_Init_Msg_List,
431     p_location_rec                      =>  l_location_rec,
432     x_location_id                       =>  l_location_id,
433     x_return_status                     =>  X_Return_Status,
434     x_msg_count                         =>  X_Msg_Count,
435     x_msg_data                          =>  X_Msg_data );
436 if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
437     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
438 end if;
439 l_party_site_rec.location_id    := l_location_id;
440 l_party_site_rec.party_id       := P_um_organization_Rec.org_party_id;
441 l_party_site_rec.created_by_module    :=  G_CREATED_BY_MODULE;
442 l_party_site_rec.application_id       :=  690;
443 HZ_PARTY_SITE_V2PUB.create_party_site(
444     p_init_msg_list                     =>  P_Init_Msg_List,
445     p_party_site_rec                    =>  l_party_site_rec,
446     x_party_site_id                     =>  l_party_site_id,
447     x_party_site_number                 =>  l_party_site_number,
448     x_return_status                     =>  X_Return_Status,
449     x_msg_count                         =>  X_Msg_Count,
450     x_msg_data                          =>  X_Msg_data );
451 if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
452     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
453 end if;
454 l_contact_point_rec.status            :=  'A';
455 l_contact_point_rec.owner_table_name  :=  'HZ_PARTIES';
456 l_contact_point_rec.owner_table_id    :=  P_um_organization_Rec.org_party_id;
457 l_contact_point_rec.primary_flag      :=  'Y';
458 l_contact_point_rec.created_by_module :=  G_CREATED_BY_MODULE;
459 l_contact_point_rec.application_id    :=  690;
460 if ( P_um_organization_Rec.phone_number is not NULL ) then
461     l_contact_point_rec.contact_point_type := 'PHONE';
462     l_phone_rec.phone_area_code := nvl( P_um_organization_Rec.phone_area_code, '' );
463     l_phone_rec.phone_number := P_um_organization_Rec.phone_number;
464     l_phone_rec.phone_line_type := 'GEN';
465     JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE, p_message   => 'invoking HZ_CONTACT_POINT_V2PUB.create_contact_point for creating phone');
466     HZ_CONTACT_POINT_V2PUB.create_contact_point (
467       p_contact_point_rec               => l_contact_point_rec,
468       p_phone_rec                       => l_phone_rec,
469       x_contact_point_id                => l_contact_point_id,
470       x_return_status                   => X_Return_Status,
471       x_msg_count                       => X_Msg_Count,
472       x_msg_data                        => X_Msg_Data );
473     if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
474         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
475     end if;
476 end if;
477 l_contact_point_rec.primary_flag      :=  'N';
478 if ( p_um_organization_rec.fax_number is not NULL ) then
479     l_contact_point_rec.contact_point_type := 'PHONE';
480     l_phone_rec.phone_area_code := nvl( P_um_organization_Rec.fax_area_code, '' );
481     l_phone_rec.phone_number := P_um_organization_Rec.fax_number;
482     l_phone_rec.phone_line_type := 'FAX';
483     JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE, p_message   => 'invoking HZ_CONTACT_POINT_V2PUB.create_contact_point for creating phone');
484     HZ_CONTACT_POINT_V2PUB.create_contact_point (
485       p_contact_point_rec               => l_contact_point_rec,
486       p_phone_rec                       => l_phone_rec,
487       x_contact_point_id                => l_contact_point_id,
488       x_return_status                   => X_Return_Status,
489       x_msg_count                       => X_Msg_Count,
490       x_msg_data                        => X_Msg_Data );
491     if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
492         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
493     end if;
494 end if;
495     -- Standard check for p_commit
496     IF FND_API.to_Boolean( p_commit )
497     THEN
498         COMMIT WORK;
499     END IF;
500     -- Standard call to get message count and if count is 1, get message info.
501     FND_MSG_PUB.Count_And_Get(
502 	p_count	=> x_msg_count,
503 	p_data	=> x_msg_data);
504     JTF_DEBUG_PUB.LOG_EXITING_METHOD( p_module => G_MODULE,
505                     p_message   => l_api_name);
506 END Create_Organization;
507 /**
508  * Procedure   :  Find_Organization
509  * Type        :  Private
510  * Pre_reqs    :
511  * Description :
512  * Parameters  :
513  *
514  * input parameters ()
515  *     param  requester_user_name     (*)
516  *  (*) required fields
517  *
518  * output parameters
519  *     param  x_return_status
520  *     param  x_msg_data
521  *     param  x_msg_count
522  *
523  * Errors      : Expected Errors
524  *
525  * Other Comments :
526  */
527  Function Find_Organization(
528             x_org_rec       IN out NOCOPY  JTF_UM_REGISTER_USER_PVT.Organization_Rec_type,
529             p_search_value  IN varchar2,
530             p_use_name      IN boolean ) return boolean is
531     cursor c_party_name IS
532         select party_id, party_name, party_number from hz_parties where party_name = x_org_rec.organization_name;
533     cursor c_party_num IS
534         select party_id, party_name, party_number from hz_parties where party_number = x_org_rec.organization_number;
535     l_party_rec     c_party_name%rowtype;
536     ret_val         boolean := false;
537 begin
538     if ( p_use_name ) then
539         Open c_party_name;
540         Fetch c_party_name into l_party_rec;
541         If (c_party_name%FOUND) then
542             x_org_rec.organization_number   := l_party_rec.party_number;
543             x_org_rec.organization_name     := l_party_rec.party_name;
544             x_org_rec.org_party_id          := l_party_rec.party_id;
545             ret_val := true;
546         end if;
547         Close c_party_name;
548     else
549         Open c_party_num;
550         Fetch c_party_num into l_party_rec;
551         If (c_party_num%FOUND) then
552             x_org_rec.organization_number   := l_party_rec.party_number;
553             x_org_rec.organization_name     := l_party_rec.party_name;
554             x_org_rec.org_party_id          := l_party_rec.party_id;
555             ret_val := true;
556         end if;
557         Close c_party_num;
558     end if;
559     return ret_val;
560 end Find_Organization;
561 end JTF_UM_BUSINESS_USER_PVT;