DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_UM_INDIVIDUAL_USER_PVT

Source


1 PACKAGE BODY JTF_UM_INDIVIDUAL_USER_PVT as
2 /* $Header: JTFVUIRB.pls 120.2.12010000.4 2008/08/14 21:22:06 dbowles ship $ */
3 -- Start of Comments
4 -- Package name     : JTF_UM_INDIVIDUAL_USER_PVT
5 -- Purpose          :
6 --   This package contains specification individual user registration
7 
8 
9 G_PKG_NAME CONSTANT VARCHAR2(30):= 'JTF_UM_INDIVIDUAL_USER_PVT';
10 G_FILE_NAME CONSTANT VARCHAR2(12) := 'JTFVUIRB.pls';
11 
12 G_USER_ID         NUMBER := FND_GLOBAL.USER_ID;
13 G_LOGIN_ID        NUMBER := FND_GLOBAL.CONC_LOGIN_ID;
14 
15 G_MODULE          VARCHAR2(40) := 'JTF.UM.PLSQL.REGINDIVIDUALUSER';
16 l_is_debug_parameter_on boolean := JTF_DEBUG_PUB.IS_LOG_PARAMETERS_ON(G_MODULE);
17 G_CREATED_BY_MODULE VARCHAR2(20) := 'JTA_USER_MANAGEMENT';
18 NEWLINE	VARCHAR2(1) := fnd_global.newline;
19 
20 Procedure createPersonAndContact(
21     P_um_person_Rec          IN out NOCOPY   JTF_UM_REGISTER_USER_PVT.Person_Rec_type)IS
22 
23     X_Return_Status               VARCHAR2(20);
24     X_Msg_Count                   NUMBER;
25     X_Msg_data                    VARCHAR2(300);
26 l_api_version_number number := 1.0;
27 l_person_rec HZ_PARTY_V2PUB.PERSON_REC_TYPE;
28 l_party_number varchar2(100);
29 l_profile_id   number;
30 l_contact_point_id number;
31 l_contact_preference_id number;
32 l_contact_point_rec    HZ_CONTACT_POINT_V2PUB.CONTACT_POINT_REC_TYPE;
33 l_email_rec            HZ_CONTACT_POINT_V2PUB.EMAIL_REC_TYPE;
34 l_phone_rec            HZ_CONTACT_POINT_V2PUB.PHONE_REC_TYPE;
35 l_contact_preference_rec HZ_CONTACT_PREFERENCE_V2PUB.CONTACT_PREFERENCE_REC_TYPE;
36 l_api_name varchar2(50) := 'createPersonAndContact';
37 l_privacy_preference varchar2(5);
38 begin
39   JTF_DEBUG_PUB.LOG_ENTERING_METHOD( p_module => G_MODULE,
40                     p_message   => l_api_name);
41 
42     -- creating a person in TCA schema
43 
44   JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE,
45                     p_message   => 'invoking HZ_PARTY_V2PUB.create_person with first and last name');
46 
47   l_person_rec.person_first_name := P_um_person_Rec.first_name;
48   l_person_rec.person_last_name  := P_um_person_Rec.last_name;
49   l_person_rec.created_by_module := G_CREATED_BY_MODULE;
50   l_person_rec.application_id    := 690;
51   l_privacy_preference           := P_um_person_Rec.privacy_preference;
52 
53    HZ_PARTY_V2PUB.create_person (
54     p_person_rec                 => l_person_rec,
55     x_party_id                   => p_um_person_rec.party_id,
56     x_party_number               => l_party_number,
57     x_profile_id                 => l_profile_id,
58     x_return_status              => X_Return_Status,
59     x_msg_count                  => X_Msg_Count,
60     x_msg_data                   => X_Msg_Data);
61 
62     if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
63            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
64     end if;
65 
66       -- creating contact points for the user
67 
68   JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE,
69                     p_message   => 'invoking HZ_CONTACT_POINT_V2PUB.create_contact_point for creating email');
70 
71   l_contact_point_rec.status :=             'A';
72   l_contact_point_rec.owner_table_name :=        'HZ_PARTIES';
73   l_contact_point_rec.owner_table_id :=     p_um_person_rec.party_id;
74   l_contact_point_rec.primary_flag :=            'Y';
75   l_contact_point_rec.created_by_module := G_CREATED_BY_MODULE;
76   l_contact_point_rec.application_id    := 690;
77 
78   if p_um_person_rec.email_address is not NULL then
79     l_contact_point_rec.contact_point_type := 'EMAIL';
80 
81     l_email_rec.email_address := p_um_person_rec.email_address;
82     l_email_rec.email_format  := 'MAILTEXT';
83 
84     HZ_CONTACT_POINT_V2PUB.create_contact_point (
85     p_contact_point_rec           => l_contact_point_rec,
86     p_email_rec                   => l_email_rec,
87     x_contact_point_id            => l_contact_point_id,
88     x_return_status              => X_Return_Status,
89     x_msg_count                  => X_Msg_Count,
90     x_msg_data                   => X_Msg_Data);
91 
92 
93     if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
94            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
95     end if;
96     if l_is_debug_parameter_on then
97     JTF_DEBUG_PUB.LOG_PARAMETERS( p_module => G_MODULE,
98                     p_message => 'privacyPreference: '|| l_privacy_preference);
99     end if;
100 
101    if (l_privacy_preference = 'YES') then
102      l_contact_preference_rec.preference_code := 'DO';
103 
104    else
105      l_contact_preference_rec.preference_code := 'DO_NOT';
106    end if;
107      -- call Hz_contact_preference api to populate the
108      -- preference to recieve marketing/promotion mails
109   JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE,
110                     p_message   => 'invoking HZ_CONTACT_PREFERENCE_V2PUB.create_contact_preference for creating preference of receiving email');
111      l_contact_preference_rec.contact_level_table := 'HZ_PARTIES';
112      l_contact_preference_rec.contact_level_table_id := p_um_person_rec.party_id;
113      l_contact_preference_rec.contact_type := 'EMAIL';
114      l_contact_preference_rec.requested_by := 'INTERNAL';
115      l_contact_preference_rec.created_by_module := G_CREATED_BY_MODULE;
116      l_contact_preference_rec.application_id := 690;
117      HZ_CONTACT_PREFERENCE_V2PUB.create_contact_preference(
118      p_contact_preference_rec          => l_contact_preference_rec,
119      x_contact_preference_id           => l_contact_preference_id,
120      x_return_status                   => x_return_status,
121      x_msg_count                       => x_msg_count,
122      x_msg_data                        => x_msg_data
123      );
124 
125     if l_is_debug_parameter_on then
126     JTF_DEBUG_PUB.LOG_PARAMETERS( p_module => G_MODULE,
127                     p_message => 'create contact preferece'||' l_cont_preference_id:'||l_contact_preference_id || ' returnStatus:'||x_return_status);
128     end if;
129 
130     if x_return_status <> FND_API.G_RET_STS_SUCCESS  then
131            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
132     end if;
133 
134   end if;
135 
136   if p_um_person_rec.phone_number is not NULL then
137     l_contact_point_rec.contact_point_type := 'PHONE';
138 
139    JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE,
140                     p_message   => 'invoking HZ_CONTACT_POINT_V2PUB.create_contact_point for creating phone');
141     l_phone_rec.phone_area_code := p_um_person_rec.phone_area_code;
142     l_phone_rec.phone_number := p_um_person_rec.phone_number;
143     l_phone_rec.phone_line_type := 'GEN';
144 
145     HZ_CONTACT_POINT_V2PUB.create_contact_point (
146       p_contact_point_rec           => l_contact_point_rec,
147       p_phone_rec                   => l_phone_rec,
148       x_contact_point_id            => l_contact_point_id,
149       x_return_status              => X_Return_Status,
150       x_msg_count                  => X_Msg_Count,
151       x_msg_data                   => X_Msg_Data);
152 
153       if x_return_status <> FND_API.G_RET_STS_SUCCESS then
154            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
155       end if;
156 
157     end if;
158 
159       JTF_DEBUG_PUB.LOG_EXITING_METHOD( p_module => G_MODULE,
160                     p_message   => l_api_name);
161 
162 end createPersonAndContact;
163 
164 
165 
166 Procedure RegisterIndividualUser(P_Api_Version_Number         IN   NUMBER,
167     P_Init_Msg_List           IN   VARCHAR2     := FND_API.G_FALSE,
168     P_Commit                  IN   VARCHAR2     := FND_API.G_FALSE,
169     P_self_service_user       IN   VARCHAR2     := FND_API.G_FALSE,
170     P_um_person_Rec          IN out NOCOPY   JTF_UM_REGISTER_USER_PVT.Person_Rec_type,
171     X_Return_Status              out NOCOPY  VARCHAR2,
172     X_Msg_Count                  out NOCOPY  NUMBER,
173     X_Msg_data                   out NOCOPY  VARCHAR2) IS
174 
175 l_api_version_number number := 1.0;
176 l_api_name          varchar2(50) := 'RegisterIndividualUser';
177 l_password_Date        date := null;
178 
179 /*cursor c_user_id(p_user_name in varchar2) is
180 select user_id
181 from fnd_user
182 where user_name = p_user_name;*/
183 
184 BEGIN
185 
186     JTF_DEBUG_PUB.LOG_ENTERING_METHOD( p_module => G_MODULE,
187                     p_message   => l_api_name);
188 
189 
190    -- Standard Start of API savepoint
191     SAVEPOINT RegisterIndividualUser;
192 
193     -- Standard call to check for call compatibility.
194     IF NOT FND_API.Compatible_API_Call ( l_api_version_number,
195                          	         p_api_version_number,
196                                          l_api_name,
197                                          G_PKG_NAME)
198     THEN
199         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
200     END IF;
201 
202 
203     -- Initialize message list if p_init_msg_list is set to TRUE.
204     IF FND_API.to_Boolean( p_init_msg_list ) THEN
205         FND_MSG_PUB.initialize;
206     END IF;
207 
208     --  Initialize API return status to success
209     x_return_status := FND_API.G_RET_STS_SUCCESS;
210 
211     --
212     -- API body
213     --
214 
215   -- creating a person and contacts in TCA schema
216   createPersonAndContact(P_um_person_Rec);
217 
218 
219   -- creating a  user in fnd schema
220    JTF_DEBUG_PUB. LOG_EVENT( p_module    => G_MODULE,
221                     p_message   => 'invoking FND_USER_PKG.CreateUser with username, password, email and customer id '||p_um_person_rec.party_id);
222 
223   -- if it is a self service user then set the password date to sysdate so
224   -- that the user is not prompted at the first logon
225   if (p_self_service_user = FND_API.G_TRUE) then
226     l_password_date := sysdate;
227   end if;
228 
229 -- Start Changes for Reserve-Release User Name: 3899304
230 /*
231   FND_USER_PKG.CreateUser (
232     x_user_name                 => p_um_person_rec.user_name,
233     x_owner                     => null,
234     x_unencrypted_password      => p_um_person_rec.password,
235     x_password_date             => l_password_date,
236     x_start_date                => nvl( p_um_person_rec.start_date_active, sysdate),
237     x_email_address             => p_um_person_rec.email_address,
238     x_customer_id	        => p_um_person_rec.party_id) ;
239 
240 */
241  -- reserve this username dont create a FND_USER with this name
242  p_um_person_rec.user_id := fnd_user_pkg.CreatePendingUser (
243         x_user_name                  => p_um_person_rec.user_name,
244         x_owner                      => null,
245         x_unencrypted_password       => p_um_person_rec.password,
246         x_password_date              => l_password_date,
247         x_email_address              => p_um_person_rec.email_address
248 
249         );
250 
251  fnd_user_pkg.UpdateUser(
252 	  		 x_user_name=>p_um_person_rec.user_name,
253 			 x_owner=>null,
254 			 x_customer_id=>p_um_person_rec.party_id);
255 
256    -- for i in c_user_id(upper(p_um_person_rec.user_name)) loop
257      --p_um_person_rec.user_id := i.user_id;
258     --end loop;
259 
260     -- Standard check for p_commit
261     IF FND_API.to_Boolean( p_commit )
262     THEN
263         COMMIT WORK;
264     END IF;
265 
266     -- Standard call to get message count and if count is 1, get message info.
267 
268     FND_MSG_PUB.Count_And_Get(
269 	p_count	=> x_msg_count,
270 	p_data	=> x_msg_data);
271 
272     JTF_DEBUG_PUB.LOG_EXITING_METHOD( p_module => G_MODULE,
273                     p_message   => l_api_name);
274 
275 
276     EXCEPTION
277       WHEN FND_API.G_EXC_ERROR THEN
278 	JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
279 		   P_API_NAME => L_API_NAME
280 		  ,P_PKG_NAME => G_PKG_NAME
281 		  ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_ERROR
282 		  ,P_SQLCODE => SQLCODE
283 		  ,P_SQLERRM => SQLERRM
284 		  ,X_MSG_COUNT => X_MSG_COUNT
285 		  ,X_MSG_DATA => X_MSG_DATA
286 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
287 
288        WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
289 	 JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
290 		   P_API_NAME => L_API_NAME
291 		  ,P_PKG_NAME => G_PKG_NAME
292 		  ,P_EXCEPTION_LEVEL => FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR
293 		  ,P_SQLCODE => SQLCODE
294 		  ,P_SQLERRM => SQLERRM
295 		  ,X_MSG_COUNT => X_MSG_COUNT
296 		  ,X_MSG_DATA => X_MSG_DATA
297 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
298 
299        WHEN OTHERS THEN
300 	  JTF_DEBUG_PUB.HANDLE_EXCEPTIONS(
301 		   P_API_NAME => L_API_NAME
302 		  ,P_PKG_NAME => G_PKG_NAME
303 		  ,P_EXCEPTION_LEVEL => JTF_DEBUG_PUB.G_EXC_OTHERS
304 		  ,P_SQLCODE => SQLCODE
305 		  ,P_SQLERRM => SQLERRM
306 		  ,X_MSG_COUNT => X_MSG_COUNT
307 		  ,X_MSG_DATA => X_MSG_DATA
308 		  ,X_RETURN_STATUS => X_RETURN_STATUS);
309 END RegisterIndividualUser;
310 
311 end JTF_UM_INDIVIDUAL_USER_PVT;