DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_RS_GROUP_MEMBERS_PVT

Source


1 PACKAGE BODY  jtf_rs_group_members_pvt AS
2   /* $Header: jtfrsvmb.pls 120.0 2005/05/11 08:23:08 appldev ship $ */
3 
4   /*****************************************************************************************
5    This private package body defines the procedures for managing resource group members,
6    like create and delete resource group members.
7    Its main procedures are as following:
8    Create Resource Group Members
9    Delete Resource Group Members
10    These procedures does the business validations and then Calls the corresponding
11    table handlers to do actual inserts and deletes into tables.
12    ******************************************************************************************/
13 
14   /* Package variables. */
15 
16   G_PKG_NAME         VARCHAR2(30) := 'JTF_RS_GROUP_MEMBERS_PVT';
17 
18 
19  /*Procedure to assign value to the global variable */
20  PROCEDURE  assign_value_to_global
21   (P_API_VERSION  IN NUMBER,
22    P_INIT_MSG_LIST        IN   VARCHAR2,
23    P_COMMIT               IN   VARCHAR2,
24    P_GROUP_ID             IN   JTF_RS_GROUP_MEMBERS.GROUP_ID%TYPE,
25    X_RETURN_STATUS        OUT NOCOPY  VARCHAR2,
26    X_MSG_COUNT            OUT NOCOPY  NUMBER,
27    X_MSG_DATA             OUT NOCOPY  VARCHAR2
28  )
29  IS
30     l_api_version         CONSTANT NUMBER := 1.0;
31     l_api_name            CONSTANT VARCHAR2(30) := 'ASSIGN_VALUE_TO_GLOBAL';
32 
33  BEGIN
34     SAVEPOINT assign_value_sp;
35 
36     x_return_status := fnd_api.g_ret_sts_success;
37 
38     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
39       RAISE fnd_api.g_exc_unexpected_error;
40     END IF;
41 
42 
43     IF fnd_api.to_boolean(p_init_msg_list) THEN
44       fnd_msg_pub.initialize;
45     END IF;
46 
47    --assign the value;
48    jtf_rs_group_members_pvt.g_moved_fr_group_id := p_group_id;
49 
50    EXCEPTION
51     WHEN OTHERS THEN
52       ROLLBACK TO assign_value_sp;
53       fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
54       fnd_message.set_token('P_SQLCODE',SQLCODE);
55       fnd_message.set_token('P_SQLERRM',SQLERRM);
56       fnd_message.set_token('P_API_NAME',l_api_name);
57       FND_MSG_PUB.add;
58       x_return_status := fnd_api.g_ret_sts_unexp_error;
59       fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
60 
61   END assign_value_to_global;
62 
63   /* Procedure to create the resource group members
64 	based on input values passed by calling routines. */
65 
66   PROCEDURE  create_resource_group_members
67   (P_API_VERSION          IN   NUMBER,
68    P_INIT_MSG_LIST        IN   VARCHAR2,
69    P_COMMIT               IN   VARCHAR2,
70    P_GROUP_ID             IN   JTF_RS_GROUP_MEMBERS.GROUP_ID%TYPE,
71    P_RESOURCE_ID          IN   JTF_RS_GROUP_MEMBERS.RESOURCE_ID%TYPE,
72    P_ATTRIBUTE1           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE1%TYPE,
73    P_ATTRIBUTE2           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE2%TYPE,
74    P_ATTRIBUTE3           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE3%TYPE,
75    P_ATTRIBUTE4           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE4%TYPE,
76    P_ATTRIBUTE5           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE5%TYPE,
77    P_ATTRIBUTE6           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE6%TYPE,
78    P_ATTRIBUTE7           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE7%TYPE,
79    P_ATTRIBUTE8           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE8%TYPE,
80    P_ATTRIBUTE9           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE9%TYPE,
81    P_ATTRIBUTE10          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE10%TYPE,
82    P_ATTRIBUTE11          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE11%TYPE,
83    P_ATTRIBUTE12          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE12%TYPE,
84    P_ATTRIBUTE13          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE13%TYPE,
85    P_ATTRIBUTE14          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE14%TYPE,
86    P_ATTRIBUTE15          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE15%TYPE,
87    P_ATTRIBUTE_CATEGORY   IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE_CATEGORY%TYPE,
88    X_RETURN_STATUS        OUT NOCOPY  VARCHAR2,
89    X_MSG_COUNT            OUT NOCOPY  NUMBER,
90    X_MSG_DATA             OUT NOCOPY  VARCHAR2,
91    X_GROUP_MEMBER_ID      OUT NOCOPY JTF_RS_GROUP_MEMBERS.GROUP_MEMBER_ID%TYPE
92   ) IS
93 
94     l_api_version         CONSTANT NUMBER := 1.0;
95     l_api_name            CONSTANT VARCHAR2(30) := 'CREATE_RESOURCE_GROUP_MEMBERS';
96     l_rowid                        ROWID;
97     l_group_id                     jtf_rs_group_members.group_id%TYPE := p_group_id;
98     l_resource_id                  jtf_rs_group_members.resource_id%type := p_resource_id;
99     l_group_member_id              jtf_rs_group_members.group_member_id%TYPE;
100     l_person_id                    jtf_rs_group_members.person_id%TYPE;
101     l_check_char                   VARCHAR2(1);
102     l_check_count                  NUMBER;
103     l_bind_data_id                 NUMBER;
104     l_return_status                VARCHAR2(1);
105     l_msg_data                     VARCHAR2(2000);
106     l_msg_count                    NUMBER;
107 
108     CURSOR c_jtf_rs_group_members( l_rowid   IN  ROWID ) IS
109 	 SELECT 'Y'
110 	 FROM jtf_rs_group_members
111 	 WHERE ROWID = l_rowid;
112 
113 
114     CURSOR c_employee_person_id( l_resource_id   IN  NUMBER ) IS
115       SELECT source_id
116       FROM jtf_rs_resource_extns
117       WHERE resource_id = l_resource_id
118 	   AND category = 'EMPLOYEE';
119 
120     CURSOR c_is_active(l_group_id IN NUMBER, l_resource_id IN NUMBER) IS
121       SELECT 'x'
122       FROM JTF_RS_GROUPS_B a, JTF_RS_RESOURCE_EXTNS b
123       WHERE a.group_id = l_group_id
124        AND b.resource_id = l_resource_id
125        AND trunc(sysdate) between a.start_date_active and nvl(a.end_date_active, sysdate)
126        AND trunc(sysdate) between b.start_date_active and nvl(b.end_date_active, sysdate);
127 
128     is_active_flag c_is_active%rowtype;
129 
130     CURSOR c_jtf_rs_active_grp_mbrs( l_rowid   IN  ROWID ) IS
131 	 SELECT 'Y'
132 	 FROM jtf_rs_active_grp_mbrs
133 	 WHERE ROWID = l_rowid;
134 
135 
136   BEGIN
137 
138 
139     SAVEPOINT create_resource_member_pvt;
140 
141     x_return_status := fnd_api.g_ret_sts_success;
142 
143 --    DBMS_OUTPUT.put_line(' Started Create Resource Member Pvt ');
144 
145 
146     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
147 
148       RAISE fnd_api.g_exc_unexpected_error;
149 
150     END IF;
151 
152 
153     IF fnd_api.to_boolean(p_init_msg_list) THEN
154 
155       fnd_msg_pub.initialize;
156 
157     END IF;
158 
159 
160 
161     /* Make the pre processing call to the user hooks */
162 
163     /* Pre Call to the Customer Type User Hook */
164 
165     IF jtf_resource_utl.ok_to_execute(
166 	 'JTF_RS_GROUP_MEMBERS_PVT',
167 	 'CREATE_RESOURCE_GROUP_MEMBERS',
168 	 'B',
169 	 'C')
170     THEN
171     IF jtf_usr_hks.ok_to_execute(
172 	 'JTF_RS_GROUP_MEMBERS_PVT',
173 	 'CREATE_RESOURCE_GROUP_MEMBERS',
174 	 'B',
175 	 'C')
176     THEN
177 
178       jtf_rs_group_member_cuhk.create_group_members_pre(
179         p_group_id => l_group_id,
180         p_resource_id => l_resource_id,
181 	   x_return_status => x_return_status);
182 
183       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
184 
185 	 --	   dbms_output.put_line('Returned Error status from the Pre Customer User Hook');
186 
187 	fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
188 	fnd_msg_pub.add;
189 
190 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
191 	   RAISE FND_API.G_EXC_ERROR;
192 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
193 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
194 	END IF;
195 
196       END IF;
197 
198     END IF;
199     END IF;
200 
201 
202     /* Pre Call to the Vertical Type User Hook */
203 
204     IF jtf_resource_utl.ok_to_execute(
205 	 'JTF_RS_GROUP_MEMBERS_PVT',
206 	 'CREATE_RESOURCE_GROUP_MEMBERS',
207 	 'B',
208 	 'V')
209     THEN
210     IF jtf_usr_hks.ok_to_execute(
211 	 'JTF_RS_GROUP_MEMBERS_PVT',
212 	 'CREATE_RESOURCE_GROUP_MEMBERS',
213 	 'B',
214 	 'V')
215     THEN
216 
217       jtf_rs_group_member_vuhk.create_group_members_pre(
218         p_group_id => l_group_id,
219         p_resource_id => l_resource_id,
220 	   x_return_status => x_return_status);
221 
222       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
223 
224 --	   dbms_output.put_line('Returned Error status from the Pre Vertical User Hook');
225 
226 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
227 	   fnd_msg_pub.add;
228 
229 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
230 	   RAISE FND_API.G_EXC_ERROR;
231 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
232 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
233 	END IF;
234 
235       END IF;
236 
237     END IF;
238     END IF;
239 
240 
241     /* Pre Call to the Internal Type User Hook */
242 
243     IF jtf_resource_utl.ok_to_execute(
244 	 'JTF_RS_GROUP_MEMBERS_PVT',
245 	 'CREATE_RESOURCE_GROUP_MEMBERS',
246 	 'B',
247 	 'I')
248     THEN
249     IF jtf_usr_hks.ok_to_execute(
250 	 'JTF_RS_GROUP_MEMBERS_PVT',
251 	 'CREATE_RESOURCE_GROUP_MEMBERS',
252 	 'B',
253 	 'I')
254     THEN
255 
256       jtf_rs_group_member_iuhk.create_group_members_pre(
257         p_group_id => l_group_id,
258         p_resource_id => l_resource_id,
259 	   x_return_status => x_return_status);
260 
261       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
262 
263 
264 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
265 	   fnd_msg_pub.add;
266 
267 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
268 	   RAISE FND_API.G_EXC_ERROR;
269 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
270 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
271 	END IF;
272 
273       END IF;
274 
275     END IF;
276     END IF;
277 
278 
279 
280     /* Validate that the resource is not an existing member of the group. */
281 
282     l_check_count := 0;
283 
284     SELECT count(*)
285     INTO l_check_count
286     FROM jtf_rs_group_members
287     WHERE group_id = l_group_id
288 	 AND resource_id = l_resource_id
289 	 AND nvl(delete_flag,'N') <> 'Y';
290 
291     IF l_check_count > 0 THEN
292 
293 --	 dbms_output.put_line('Resource already exists in the group');
294 
295 	 x_return_status := fnd_api.g_ret_sts_error;
296 
297 	 fnd_message.set_name('JTF', 'JTF_RS_RESOURCE_EXISTS');
298 	 fnd_msg_pub.add;
299 
300 	 RAISE fnd_api.g_exc_error;
301 
302     END IF;
303 
304 
305 
306     /* Get the Employee Person Id from the Resource Extension table. */
307 
308     OPEN c_employee_person_id(l_resource_id);
309 
310     FETCH c_employee_person_id INTO l_person_id;
311 
312 
313     IF c_employee_person_id%NOTFOUND THEN
314 
315 	 l_person_id := NULL;
316 
317     END IF;
318 
319 
320     /* Get the next value of the Group_member_id from the sequence. */
321 
322     SELECT jtf_rs_group_members_s.nextval
323     INTO l_group_member_id
324     FROM dual;
325 
326 
327     /* Make a call to the group member Audit API */
328 
329     jtf_rs_group_members_aud_pvt.insert_member
330     (P_API_VERSION => 1,
331      P_INIT_MSG_LIST => fnd_api.g_false,
332      P_COMMIT => fnd_api.g_false,
333      P_GROUP_MEMBER_ID => l_group_member_id,
334      P_GROUP_ID => l_group_id,
335      P_RESOURCE_ID => l_resource_id,
336      P_PERSON_ID => l_person_id,
337 	P_OBJECT_VERSION_NUMBER => 1,
338      X_RETURN_STATUS => x_return_status,
339      X_MSG_COUNT => x_msg_count,
340      X_MSG_DATA => x_msg_data
341     );
342 
343 
344     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
345 
346 --	 dbms_output.put_line('Failed status from call to audit procedure');
347 
348 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
349 	   RAISE FND_API.G_EXC_ERROR;
350 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
351 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
352 	END IF;
353 
354     END IF;
355 
356 
357     /* Insert the row into the table by calling the table handler. */
358 
359     jtf_rs_group_members_pkg.insert_row(
360       x_rowid => l_rowid,
361       x_group_member_id => l_group_member_id,
362       x_group_id => l_group_id,
363       x_resource_id => l_resource_id,
364       x_person_id => l_person_id,
365 	 x_delete_flag => 'N',
366       x_attribute1 => p_attribute1,
367       x_attribute2 => p_attribute2,
368       x_attribute3 => p_attribute3,
369       x_attribute4 => p_attribute4,
370       x_attribute5 => p_attribute5,
371       x_attribute6 => p_attribute6,
372       x_attribute7 => p_attribute7,
373       x_attribute8 => p_attribute8,
374       x_attribute9 => p_attribute9,
375       x_attribute10 => p_attribute10,
376       x_attribute11 => p_attribute11,
377       x_attribute12 => p_attribute12,
378       x_attribute13 => p_attribute13,
379       x_attribute14 => p_attribute14,
380       x_attribute15 => p_attribute15,
381       x_attribute_category => p_attribute_category,
382       x_creation_date => SYSDATE,
383       x_created_by => jtf_resource_utl.created_by,
384       x_last_update_date => SYSDATE,
385       x_last_updated_by => jtf_resource_utl.updated_by,
386       x_last_update_login => jtf_resource_utl.login_id
387     );
388 
389 
390 --    dbms_output.put_line('Inserted Row');
391 
392     OPEN c_jtf_rs_group_members(l_rowid);
393 
394     FETCH c_jtf_rs_group_members INTO l_check_char;
395 
396 
397     IF c_jtf_rs_group_members%NOTFOUND THEN
398 
399 --	 dbms_output.put_line('Error in Table Handler');
400 
401 
402 	 fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
403 	 fnd_msg_pub.add;
404 
405 	 IF c_jtf_rs_group_members%ISOPEN THEN
406 
407 	    CLOSE c_jtf_rs_group_members;
408 
409 	 END IF;
410 
411 	 RAISE fnd_api.g_exc_error;
412 
413     ELSE
414 
415        OPEN C_IS_ACTIVE(l_group_id, l_resource_id);
416        FETCH C_IS_ACTIVE INTO is_active_flag;
417 
418        IF c_is_active%FOUND THEN
419 	  /* Insert the row into the active group members table by
420 	  calling the table handler. */
421 
422           jtf_rs_active_grp_mbrs_pkg.insert_row(x_rowid => l_rowid,
423 						x_group_member_id => l_group_member_id,
424 						x_group_id => l_group_id,
425 						x_resource_id => l_resource_id,
426 						x_person_id => l_person_id,
427 						x_creation_date => SYSDATE,
428 						x_created_by => jtf_resource_utl.created_by,
429 						x_last_update_date => SYSDATE,
430 						x_last_updated_by => jtf_resource_utl.updated_by,
431 						x_last_update_login => jtf_resource_utl.login_id
432 						);
433 
434 
435 	  OPEN c_jtf_rs_active_grp_mbrs(l_rowid);
436 
437 	  FETCH c_jtf_rs_active_grp_mbrs INTO l_check_char;
438 
439 
440 	  IF c_jtf_rs_active_grp_mbrs%NOTFOUND THEN
441 
442 	     fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
443 	     fnd_msg_pub.add;
444 
445 	     IF c_jtf_rs_active_grp_mbrs%ISOPEN THEN
446 
447 		CLOSE c_jtf_rs_active_grp_mbrs;
448 
449 	     END IF;
450 
451 	     RAISE fnd_api.g_exc_error;
452 	  END IF;
453 	  IF c_jtf_rs_active_grp_mbrs%ISOPEN THEN
454 
455 	     CLOSE c_jtf_rs_active_grp_mbrs;
456 
457 	  END IF;
458        END IF;
459 
460        IF c_jtf_rs_group_members%ISOPEN THEN
461 
462 	  CLOSE c_jtf_rs_group_members;
463 
464        END IF;
465        x_group_member_id := l_group_member_id;
466 
467     END IF;
468 
469 
470     /* Close the cursors */
471 
472     IF c_employee_person_id%ISOPEN THEN
473 
474       CLOSE c_employee_person_id;
475 
476     END IF;
477 
478 
479     IF c_jtf_rs_group_members%ISOPEN THEN
480 
481       CLOSE c_jtf_rs_group_members;
482 
483     END IF;
484 
485 
486     /* Make the post processing call to the user hooks */
487 
488     /* Post Call to the Customer Type User Hook */
489 
490     IF jtf_resource_utl.ok_to_execute(
491 	 'JTF_RS_GROUP_MEMBERS_PVT',
492 	 'CREATE_RESOURCE_GROUP_MEMBERS',
493 	 'A',
494 	 'C')
495     THEN
496     IF jtf_usr_hks.ok_to_execute(
497 	 'JTF_RS_GROUP_MEMBERS_PVT',
498 	 'CREATE_RESOURCE_GROUP_MEMBERS',
499 	 'A',
500 	 'C')
501     THEN
502 
503       jtf_rs_group_member_cuhk.create_group_members_post(
504 	   p_group_member_id => l_group_member_id,
505         p_group_id => l_group_id,
506         p_resource_id => l_resource_id,
507 	   x_return_status => x_return_status);
508 
509       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
510 
511 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
512 
513 
514 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
515 	   fnd_msg_pub.add;
516 
517 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
518 	   RAISE FND_API.G_EXC_ERROR;
519 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
520 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
521 	END IF;
522 
523       END IF;
524 
525     END IF;
526     END IF;
527 
528 
529     /* Post Call to the Vertical Type User Hook */
530 
531     IF jtf_resource_utl.ok_to_execute(
532 	 'JTF_RS_GROUP_MEMBERS_PVT',
533 	 'CREATE_RESOURCE_GROUP_MEMBERS',
534 	 'A',
535 	 'V')
536     THEN
537     IF jtf_usr_hks.ok_to_execute(
538 	 'JTF_RS_GROUP_MEMBERS_PVT',
539 	 'CREATE_RESOURCE_GROUP_MEMBERS',
540 	 'A',
541 	 'V')
542     THEN
543 
544       jtf_rs_group_member_vuhk.create_group_members_post(
545 	   p_group_member_id => l_group_member_id,
546         p_group_id => l_group_id,
547         p_resource_id => l_resource_id,
548 	   x_return_status => x_return_status);
549 
550       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
551 
552 --	   dbms_output.put_line('Returned Error status from the Post Vertical User Hook');
553 
554 
555 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
556 	   fnd_msg_pub.add;
557 
558 
559 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
560 	   RAISE FND_API.G_EXC_ERROR;
561 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
562 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
563 	END IF;
564 
565       END IF;
566 
567     END IF;
568     END IF;
569 
570 
571     /* Post Call to the Internal Type User Hook */
572 
573     IF jtf_resource_utl.ok_to_execute(
574 	 'JTF_RS_GROUP_MEMBERS_PVT',
575 	 'CREATE_RESOURCE_GROUP_MEMBERS',
576 	 'A',
577 	 'I')
578     THEN
579     IF jtf_usr_hks.ok_to_execute(
580 	 'JTF_RS_GROUP_MEMBERS_PVT',
581 	 'CREATE_RESOURCE_GROUP_MEMBERS',
582 	 'A',
583 	 'I')
584     THEN
585 
586       jtf_rs_group_member_iuhk.create_group_members_post(
587 	   p_group_member_id => l_group_member_id,
588         p_group_id => l_group_id,
589         p_resource_id => l_resource_id,
590 	   x_return_status => x_return_status);
591 
592       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
593 
594 
595 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
596 	   fnd_msg_pub.add;
597 
598 
599 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
600 	   RAISE FND_API.G_EXC_ERROR;
601 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
602 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
603 	END IF;
604 
605       END IF;
606 
607     END IF;
608     END IF;
609 
610 
611     /* Standard call for Message Generation */
612 
613     IF jtf_resource_utl.ok_to_execute(
614 	 'JTF_RS_GROUP_MEMBERS_PVT',
615 	 'CREATE_RESOURCE_GROUP_MEMBERS',
616 	 'M',
617 	 'M')
618     THEN
619     IF jtf_usr_hks.ok_to_execute(
620 	 'JTF_RS_GROUP_MEMBERS_PVT',
621 	 'CREATE_RESOURCE_GROUP_MEMBERS',
622 	 'M',
623 	 'M')
624     THEN
625 
626       IF (jtf_rs_group_member_cuhk.ok_to_generate_msg(
627 	       p_group_member_id => l_group_member_id,
628 	       x_return_status => x_return_status) )
629       THEN
630 
631         /* Get the bind data id for the Business Object Instance */
632 
633         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
634 
635 
636         /* Set bind values for the bind variables in the Business Object SQL */
637 
638         jtf_usr_hks.load_bind_data(l_bind_data_id, 'group_member_id', l_group_member_id, 'S', 'N');
639 
640 
641         /* Call the message generation API */
642 
643         jtf_usr_hks.generate_message(
644 		p_prod_code => 'JTF',
645 		p_bus_obj_code => 'RS_GMBR',
646 		p_action_code => 'I',
647 		p_bind_data_id => l_bind_data_id,
648 		x_return_code => x_return_status);
649 
650 
651         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
652 
653 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
654 
655           x_return_status := fnd_api.g_ret_sts_unexp_error;
656 
657 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
658 	     fnd_msg_pub.add;
659 
660 
661 	  IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
662 	     RAISE FND_API.G_EXC_ERROR;
663 	  ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
664 	     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
665 	  END IF;
666 
667         END IF;
668 
669       END IF;
670 
671     END IF;
672     END IF;
673 
674 
675     -- create wf_user_role record for the new group member
676     -- Don't care for its success status
677     BEGIN
678       jtf_rs_wf_integration_pub.create_resource_group_members
679 	(P_API_VERSION      => 1.0,
680 	 P_RESOURCE_ID      =>  l_resource_id,
681 	 P_GROUP_ID   => l_group_id,
682 	 X_RETURN_STATUS   => l_return_status,
683 	 X_MSG_COUNT      => l_msg_count,
684 	 X_MSG_DATA      => l_msg_data);
685     EXCEPTION
686       WHEN OTHERS THEN
687 	NULL;
688     END;
689 
690 
691     IF fnd_api.to_boolean(p_commit) THEN
692 
693 	 COMMIT WORK;
694 
695     END IF;
696 
697     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
698 
699   EXCEPTION
700 
701 
702     WHEN fnd_api.g_exc_error THEN
703       ROLLBACK TO create_resource_member_pvt;
704       x_return_status := fnd_api.g_ret_sts_error;
705       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
706                                  p_data => x_msg_data);
707     WHEN fnd_api.g_exc_unexpected_error THEN
708       ROLLBACK TO create_resource_member_pvt;
709       x_return_status := fnd_api.g_ret_sts_unexp_error;
710       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
711                                  p_data => x_msg_data);
712     WHEN OTHERS THEN
713       ROLLBACK TO create_resource_member_pvt;
714       fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
715       fnd_message.set_token('P_SQLCODE',SQLCODE);
716       fnd_message.set_token('P_SQLERRM',SQLERRM);
717       fnd_message.set_token('P_API_NAME', l_api_name);
718       FND_MSG_PUB.add;
719       x_return_status := fnd_api.g_ret_sts_unexp_error;
720       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
721                                  p_data => x_msg_data);
722 
723   END create_resource_group_members;
724 
725 
726   /* Procedure to update the resource group members. */
727 
728   PROCEDURE  update_resource_group_members
729   (P_API_VERSION          IN   NUMBER,
730    P_INIT_MSG_LIST        IN   VARCHAR2,
731    P_COMMIT               IN   VARCHAR2,
732    P_GROUP_MEMBER_ID      IN   JTF_RS_GROUP_MEMBERS.GROUP_MEMBER_ID%TYPE,
733    P_GROUP_ID             IN   JTF_RS_GROUP_MEMBERS.GROUP_ID%TYPE,
734    P_RESOURCE_ID          IN   JTF_RS_GROUP_MEMBERS.RESOURCE_ID%TYPE,
735    P_PERSON_ID            IN   JTF_RS_GROUP_MEMBERS.PERSON_ID%TYPE,
736    P_DELETE_FLAG          IN   JTF_RS_GROUP_MEMBERS.DELETE_FLAG%TYPE,
737    P_ATTRIBUTE1           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE1%TYPE,
738    P_ATTRIBUTE2           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE2%TYPE,
739    P_ATTRIBUTE3           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE3%TYPE,
740    P_ATTRIBUTE4           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE4%TYPE,
741    P_ATTRIBUTE5           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE5%TYPE,
742    P_ATTRIBUTE6           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE6%TYPE,
743    P_ATTRIBUTE7           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE7%TYPE,
744    P_ATTRIBUTE8           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE8%TYPE,
745    P_ATTRIBUTE9           IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE9%TYPE,
746    P_ATTRIBUTE10          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE10%TYPE,
747    P_ATTRIBUTE11          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE11%TYPE,
748    P_ATTRIBUTE12          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE12%TYPE,
749    P_ATTRIBUTE13          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE13%TYPE,
750    P_ATTRIBUTE14          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE14%TYPE,
751    P_ATTRIBUTE15          IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE15%TYPE,
752    P_ATTRIBUTE_CATEGORY   IN   JTF_RS_GROUP_MEMBERS.ATTRIBUTE_CATEGORY%TYPE,
753    P_OBJECT_VERSION_NUMBER   IN OUT NOCOPY  JTF_RS_GROUP_MEMBERS.OBJECT_VERSION_NUMBER%TYPE,
754    X_RETURN_STATUS        OUT NOCOPY  VARCHAR2,
755    X_MSG_COUNT            OUT NOCOPY  NUMBER,
756    X_MSG_DATA             OUT NOCOPY VARCHAR2
757   )
758  IS
759       l_api_version         	CONSTANT NUMBER := 1.0;
760       l_api_name            	CONSTANT VARCHAR2(30) := 'UPDATE_RESOURCE_GROUP_MEMBERS';
761       l_group_member_id        	jtf_rs_group_members.group_member_id%type    	:= p_group_member_id;
762       l_object_version_number   jtf_rs_group_members.object_version_number%type :=p_object_version_number;
763       l_attribute1              jtf_rs_group_members.attribute1%type		:= p_attribute1;
764       l_attribute2              jtf_rs_group_members.attribute2%type		:= p_attribute2;
765       l_attribute3              jtf_rs_group_members.attribute3%type		:= p_attribute3;
766       l_attribute4              jtf_rs_group_members.attribute4%type		:= p_attribute4;
767       l_attribute5              jtf_rs_group_members.attribute5%type		:= p_attribute5;
768       l_attribute6              jtf_rs_group_members.attribute6%type		:= p_attribute6;
769       l_attribute7              jtf_rs_group_members.attribute7%type		:= p_attribute7;
770       l_attribute8              jtf_rs_group_members.attribute8%type		:= p_attribute8;
771       l_attribute9              jtf_rs_group_members.attribute9%type		:= p_attribute9;
772       l_attribute10             jtf_rs_group_members.attribute10%type	:= p_attribute10;
773       l_attribute11             jtf_rs_group_members.attribute11%type	:= p_attribute11;
774       l_attribute12             jtf_rs_group_members.attribute12%type	:= p_attribute12;
775       l_attribute13             jtf_rs_group_members.attribute13%type	:= p_attribute13;
776       l_attribute14             jtf_rs_group_members.attribute14%type	:= p_attribute14;
777       l_attribute15             jtf_rs_group_members.attribute15%type	:= p_attribute15;
778       l_attribute_category      jtf_rs_group_members.attribute_category%type	:= p_attribute_category;
779 
780 
781     l_bind_data_id                 NUMBER;
782 
783       CURSOR c_rs_group_members_update(l_group_member_id IN NUMBER) is
784       SELECT
785          DECODE(p_group_id, fnd_api.g_miss_num, group_id, p_group_id) l_group_id,
786          DECODE(p_resource_id, fnd_api.g_miss_num, resource_id, p_resource_id) l_resource_id,
787          DECODE(p_person_id, fnd_api.g_miss_num, person_id, p_person_id) l_person_id,
788          DECODE(p_delete_flag, fnd_api.g_miss_char, delete_flag, p_delete_flag) l_delete_flag,
789          DECODE(p_attribute1,fnd_api.g_miss_char, attribute1, p_attribute1) l_attribute1,
790          DECODE(p_attribute2,fnd_api.g_miss_char, attribute2, p_attribute2) l_attribute2,
791          DECODE(p_attribute3,fnd_api.g_miss_char, attribute3, p_attribute3) l_attribute3,
792          DECODE(p_attribute4,fnd_api.g_miss_char, attribute4, p_attribute4) l_attribute4,
793          DECODE(p_attribute5,fnd_api.g_miss_char, attribute5, p_attribute5) l_attribute5,
794          DECODE(p_attribute6,fnd_api.g_miss_char, attribute6, p_attribute6) l_attribute6,
795          DECODE(p_attribute7,fnd_api.g_miss_char, attribute7, p_attribute7) l_attribute7,
796          DECODE(p_attribute8,fnd_api.g_miss_char, attribute8, p_attribute8) l_attribute8,
797          DECODE(p_attribute9,fnd_api.g_miss_char, attribute9, p_attribute9) l_attribute9,
798          DECODE(p_attribute10,fnd_api.g_miss_char, attribute10, p_attribute10) l_attribute10,
799          DECODE(p_attribute11,fnd_api.g_miss_char, attribute11, p_attribute11) l_attribute11,
800          DECODE(p_attribute12,fnd_api.g_miss_char, attribute12, p_attribute12) l_attribute12,
801          DECODE(p_attribute13,fnd_api.g_miss_char, attribute13, p_attribute13) l_attribute13,
802          DECODE(p_attribute14,fnd_api.g_miss_char, attribute14, p_attribute14) l_attribute14,
803          DECODE(p_attribute15,fnd_api.g_miss_char, attribute15, p_attribute15) l_attribute15,
804          DECODE(p_attribute_category,fnd_api.g_miss_char, attribute1, p_attribute_category) l_attribute_category
805       FROM jtf_rs_group_members
806       WHERE group_member_id = l_group_member_id;
807 
808     rs_group_member_rec c_rs_group_members_update%ROWTYPE;
809  BEGIN
810       SAVEPOINT update_rs_group_members_pvt;
811       x_return_status := fnd_api.g_ret_sts_success;
812       IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
813          RAISE fnd_api.g_exc_unexpected_error;
814       END IF;
815       IF fnd_api.to_boolean(p_init_msg_list) THEN
816          fnd_msg_pub.initialize;
817       END IF;
818 
819     /* Make the pre processing call to the user hooks */
820 
821     /* Pre Call to the Customer Type User Hook */
822 
823     IF jtf_resource_utl.ok_to_execute(
824 	 'JTF_RS_GROUP_MEMBERS_PVT',
825 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
826 	 'B',
827 	 'C')
828     THEN
829     IF jtf_usr_hks.ok_to_execute(
830 	 'JTF_RS_GROUP_MEMBERS_PVT',
831 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
832 	 'B',
833 	 'C')
834     THEN
835 
836       jtf_rs_group_member_cuhk.update_group_members_pre(
837         p_group_member_id => l_group_member_id,
838 	   x_return_status => x_return_status);
839 
840       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
841 
842 --	   dbms_output.put_line('Returned Error status from the Pre Customer User Hook');
843 
844         x_return_status := fnd_api.g_ret_sts_unexp_error;
845 
846 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
847 	   fnd_msg_pub.add;
848 
849         RAISE fnd_api.g_exc_unexpected_error;
850 
851       END IF;
852 
853     END IF;
854     END IF;
855 
856 
857     /* Pre Call to the Vertical Type User Hook */
858 
859     IF jtf_resource_utl.ok_to_execute(
860 	 'JTF_RS_GROUP_MEMBERS_PVT',
861 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
862 	 'B',
863 	 'V')
864     THEN
865     IF jtf_usr_hks.ok_to_execute(
866 	 'JTF_RS_GROUP_MEMBERS_PVT',
867 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
868 	 'B',
869 	 'V')
870     THEN
871 
872       jtf_rs_group_member_vuhk.update_group_members_pre(
873         p_group_member_id => l_group_member_id,
874 	   x_return_status => x_return_status);
875 
876       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
877 
878 --	   dbms_output.put_line('Returned Error status from the Pre Vertical User Hook');
879 
880         x_return_status := fnd_api.g_ret_sts_unexp_error;
881 
882 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
883 	   fnd_msg_pub.add;
884 
885         RAISE fnd_api.g_exc_unexpected_error;
886 
887       END IF;
888 
889     END IF;
890     END IF;
891 
892 
893     /* Pre Call to the Internal Type User Hook */
894 
895     IF jtf_resource_utl.ok_to_execute(
896 	 'JTF_RS_GROUP_MEMBERS_PVT',
897 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
898 	 'B',
899 	 'I')
900     THEN
901     IF jtf_usr_hks.ok_to_execute(
902 	 'JTF_RS_GROUP_MEMBERS_PVT',
903 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
904 	 'B',
905 	 'I')
906     THEN
907 
908       jtf_rs_group_member_iuhk.update_group_members_pre(
909         p_group_member_id => l_group_member_id,
910 	   x_return_status => x_return_status);
911 
912       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
913 
914         x_return_status := fnd_api.g_ret_sts_unexp_error;
915 
916 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
917 	   fnd_msg_pub.add;
918 
919         RAISE fnd_api.g_exc_unexpected_error;
920 
921       END IF;
922 
923     END IF;
924     END IF;
925 
926    --Validate the group member for Update
927       OPEN c_rs_group_members_update(l_group_member_id);
928       FETCH c_rs_group_members_update INTO rs_group_member_rec;
929       IF c_rs_group_members_update%NOTFOUND THEN
930          CLOSE c_rs_group_members_update;
931          fnd_message.set_name('JTF', 'JTF_RS_INVALID_GRP_MBR_ID');
932          fnd_message.set_token('P_GRP_MBR_ID', p_group_member_id);
933          fnd_msg_pub.add;
934          x_return_status := fnd_api.g_ret_sts_unexp_error;
935          RAISE fnd_api.g_exc_unexpected_error;
936       END IF;
937 
938 
939    --Call the Lock Row Table Handler before updating the record
940       jtf_rs_group_members_pkg.lock_row (
941          X_GROUP_MEMBER_ID                      => l_group_member_id,
942          X_OBJECT_VERSION_NUMBER        => l_object_version_number
943       );
944 
945     /* Make a call to the group member Audit API */
946 
947     jtf_rs_group_members_aud_pvt.update_member
948     (
949      P_API_VERSION => 1,
950      P_INIT_MSG_LIST => fnd_api.g_false,
951      P_COMMIT => fnd_api.g_false,
952      P_GROUP_MEMBER_ID => l_group_member_id,
953      P_GROUP_ID   => rs_group_member_rec.l_group_id,
954      P_RESOURCE_ID => rs_group_member_rec.l_resource_id,
955      P_PERSON_ID => rs_group_member_rec.l_person_id,
956      P_OBJECT_VERSION_NUMBER => l_object_version_number,
957      X_RETURN_STATUS => x_return_status,
958      X_MSG_COUNT => x_msg_count,
959      X_MSG_DATA => x_msg_data
960     );
961 
962 
963     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
964 
965 --	 dbms_output.put_line('Failed status from call to audit procedure');
966 
967       RAISE fnd_api.g_exc_unexpected_error;
968 
969     END IF;
970 
971    --Update the Object Version Number by Incrementing It
972       l_object_version_number    := l_object_version_number+1;
973 
974    --Call the Table Handler to Update the Values in jtf_rs_role tables
975    BEGIN
976       jtf_rs_group_members_pkg.update_row (
977          X_GROUP_MEMBER_ID              => l_group_member_id,
978          X_ATTRIBUTE1           => rs_group_member_rec.l_attribute1,
979          X_ATTRIBUTE2           => rs_group_member_rec.l_attribute2,
980          X_ATTRIBUTE3           => rs_group_member_rec.l_attribute3,
981          X_ATTRIBUTE4           => rs_group_member_rec.l_attribute4,
982          X_ATTRIBUTE5           => rs_group_member_rec.l_attribute5,
983          X_ATTRIBUTE6           => rs_group_member_rec.l_attribute6,
984          X_ATTRIBUTE7           => rs_group_member_rec.l_attribute7,
985          X_ATTRIBUTE8           => rs_group_member_rec.l_attribute8,
986          X_ATTRIBUTE9           => rs_group_member_rec.l_attribute9,
987          X_ATTRIBUTE10          => rs_group_member_rec.l_attribute10,
988          X_ATTRIBUTE11          => rs_group_member_rec.l_attribute11,
989          X_ATTRIBUTE12          => rs_group_member_rec.l_attribute12,
990          X_ATTRIBUTE13          => rs_group_member_rec.l_attribute13,
991          X_ATTRIBUTE14          => rs_group_member_rec.l_attribute14,
992          X_ATTRIBUTE15          => rs_group_member_rec.l_attribute15,
993          X_ATTRIBUTE_CATEGORY   => rs_group_member_rec.l_attribute_category,
994          X_GROUP_ID            => rs_group_member_rec.l_group_id,
995          X_RESOURCE_ID       => rs_group_member_rec.l_resource_id,
996          X_PERSON_ID          => rs_group_member_rec.l_person_id,
997          X_DELETE_FLAG        => rs_group_member_rec.l_delete_flag,
998          X_OBJECT_VERSION_NUMBER=> l_object_version_number,
999          X_LAST_UPDATE_DATE     => sysdate,
1000          X_LAST_UPDATED_BY	=> jtf_resource_utl.updated_by,
1001          X_LAST_UPDATE_LOGIN	=> jtf_resource_utl.login_id
1002       );
1003 
1004       p_object_version_number := l_object_version_number;
1005 
1006    EXCEPTION
1007       WHEN NO_DATA_FOUND THEN
1008          CLOSE c_rs_group_members_update;
1009          x_return_status := fnd_api.g_ret_sts_unexp_error;
1010          fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
1011          fnd_msg_pub.add;
1012          RAISE fnd_api.g_exc_unexpected_error;
1013    END;
1014 
1015     /* Make the post processing call to the user hooks */
1016 
1017     /* Post Call to the Customer Type User Hook */
1018 
1019     IF jtf_resource_utl.ok_to_execute(
1020 	 'JTF_RS_GROUP_MEMBERS_PVT',
1021 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1022 	 'A',
1023 	 'C')
1024     THEN
1025     IF jtf_usr_hks.ok_to_execute(
1026 	 'JTF_RS_GROUP_MEMBERS_PVT',
1027 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1028 	 'A',
1029 	 'C')
1030     THEN
1031 
1032       jtf_rs_group_member_cuhk.update_group_members_post(
1033         p_group_member_id => l_group_member_id,
1034 	   x_return_status => x_return_status);
1035 
1036       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1037 
1038 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
1039 
1040         x_return_status := fnd_api.g_ret_sts_unexp_error;
1041 
1042 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
1043 	   fnd_msg_pub.add;
1044 
1045         RAISE fnd_api.g_exc_unexpected_error;
1046 
1047       END IF;
1048 
1049     END IF;
1050     END IF;
1051 
1052 
1053     /* Post Call to the Vertical Type User Hook */
1054 
1055     IF jtf_resource_utl.ok_to_execute(
1056 	 'JTF_RS_GROUP_MEMBERS_PVT',
1057 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1058 	 'A',
1059 	 'V')
1060     THEN
1061     IF jtf_usr_hks.ok_to_execute(
1062 	 'JTF_RS_GROUP_MEMBERS_PVT',
1063 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1064 	 'A',
1065 	 'V')
1066     THEN
1067 
1068       jtf_rs_group_member_vuhk.update_group_members_post(
1069         p_group_member_id => l_group_member_id,
1070 	   x_return_status => x_return_status);
1071 
1072       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1073 
1074 --	   dbms_output.put_line('Returned Error status from the Post Vertical User Hook');
1075 
1076         x_return_status := fnd_api.g_ret_sts_unexp_error;
1077 
1078 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
1079 	   fnd_msg_pub.add;
1080 
1081         RAISE fnd_api.g_exc_unexpected_error;
1082 
1083       END IF;
1084 
1085     END IF;
1086     END IF;
1087 
1088 
1089     /* Post Call to the Internal Type User Hook */
1090 
1091     IF jtf_resource_utl.ok_to_execute(
1092 	 'JTF_RS_GROUP_MEMBERS_PVT',
1093 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1094 	 'A',
1095 	 'I')
1096     THEN
1097     IF jtf_usr_hks.ok_to_execute(
1098 	 'JTF_RS_GROUP_MEMBERS_PVT',
1099 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1100 	 'A',
1101 	 'I')
1102     THEN
1103 
1104       jtf_rs_group_member_iuhk.update_group_members_post(
1105         p_group_member_id => l_group_member_id,
1106 	   x_return_status => x_return_status);
1107 
1108       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1109 
1110         x_return_status := fnd_api.g_ret_sts_unexp_error;
1111 
1112 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
1113 	   fnd_msg_pub.add;
1114 
1115         RAISE fnd_api.g_exc_unexpected_error;
1116 
1117       END IF;
1118 
1119     END IF;
1120     END IF;
1121 
1122 
1123     /* Standard call for Message Generation */
1124 
1125     IF jtf_resource_utl.ok_to_execute(
1126 	 'JTF_RS_GROUP_MEMBERS_PVT',
1127 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1128 	 'M',
1129 	 'M')
1130     THEN
1131     IF jtf_usr_hks.ok_to_execute(
1132 	 'JTF_RS_GROUP_MEMBERS_PVT',
1133 	 'UPDATE_RESOURCE_GROUP_MEMBERS',
1134 	 'M',
1135 	 'M')
1136     THEN
1137 
1138       IF (jtf_rs_group_member_cuhk.ok_to_generate_msg(
1139 	       p_group_member_id => l_group_member_id,
1140 	       x_return_status => x_return_status) )
1141       THEN
1142 
1143         /* Get the bind data id for the Business Object Instance */
1144 
1145         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
1146 
1147 
1148         /* Set bind values for the bind variables in the Business Object SQL */
1149 
1150         jtf_usr_hks.load_bind_data(l_bind_data_id, 'group_member_id', l_group_member_id, 'S', 'N');
1151 
1152 
1153         /* Call the message generation API */
1154 
1155         jtf_usr_hks.generate_message(
1156 		p_prod_code => 'RS',
1157 		p_bus_obj_code => 'GMBR',
1158 		p_action_code => 'D',
1159 		p_bind_data_id => l_bind_data_id,
1160 		x_return_code => x_return_status);
1161 
1162 
1163         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1164 
1165 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
1166 
1167           x_return_status := fnd_api.g_ret_sts_unexp_error;
1168 
1169 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
1170 	     fnd_msg_pub.add;
1171 
1172           RAISE fnd_api.g_exc_unexpected_error;
1173 
1174         END IF;
1175 
1176       END IF;
1177 
1178     END IF;
1179     END IF;
1180 
1181 
1182     IF fnd_api.to_boolean(p_commit) THEN
1183 
1184 	 COMMIT WORK;
1185 
1186     END IF;
1187 
1188     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
1189 
1190    EXCEPTION
1191       WHEN fnd_api.g_exc_unexpected_error THEN
1192          --DBMS_OUTPUT.put_line (' ========================================== ');
1193          --DBMS_OUTPUT.put_line ('===========  Raised Unexpected Error  =============== ');
1194          ROLLBACK TO update_rs_group_members_pvt;
1195          x_return_status := fnd_api.g_ret_sts_unexp_error;
1196          fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
1197       WHEN OTHERS THEN
1198          --DBMS_OUTPUT.put_line (' ========================================== ');
1199          --DBMS_OUTPUT.put_line (' ===========  Raised Others in Update Resource Role Pub =============');
1200          --DBMS_OUTPUT.put_line (SQLCODE || SQLERRM);
1201          ROLLBACK TO update_rs_group_members_pvt;
1202          fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
1203          fnd_message.set_token('P_SQLCODE',SQLCODE);
1204          fnd_message.set_token('P_SQLERRM',SQLERRM);
1205          fnd_message.set_token('P_API_NAME',l_api_name);
1206          FND_MSG_PUB.add;
1207          x_return_status := fnd_api.g_ret_sts_unexp_error;
1208          fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
1209 
1210  END;
1211 
1212 
1213   /* Procedure to delete the resource group members. */
1214 
1215   PROCEDURE  delete_resource_group_members
1216   (P_API_VERSION          IN   NUMBER,
1217    P_INIT_MSG_LIST        IN   VARCHAR2,
1218    P_COMMIT               IN   VARCHAR2,
1219    P_GROUP_ID             IN   JTF_RS_GROUP_MEMBERS.GROUP_ID%TYPE,
1220    P_RESOURCE_ID          IN   JTF_RS_GROUP_MEMBERS.RESOURCE_ID%TYPE,
1221    P_OBJECT_VERSION_NUM   IN   JTF_RS_GROUP_MEMBERS.OBJECT_VERSION_NUMBER%TYPE,
1222    X_RETURN_STATUS        OUT NOCOPY  VARCHAR2,
1223    X_MSG_COUNT            OUT NOCOPY  NUMBER,
1224    X_MSG_DATA             OUT NOCOPY VARCHAR2
1225   )
1226 
1227   IS
1228 
1229     l_api_version         CONSTANT NUMBER := 1.0;
1230     l_api_name            CONSTANT VARCHAR2(30) := 'DELETE_RESOURCE_GROUP_MEMBERS';
1231     l_group_id                     jtf_rs_group_members.group_id%TYPE := p_group_id;
1232     l_resource_id                  jtf_rs_group_members.resource_id%type := p_resource_id;
1233     l_check_char                   VARCHAR2(1);
1234     l_group_member_id              jtf_rs_group_members.group_member_id%TYPE;
1235     l_role_relate_count            NUMBER;
1236     l_bind_data_id                 NUMBER;
1237 
1238     l_return_status                VARCHAR2(1);
1239     l_msg_data                     VARCHAR2(2000);
1240     l_msg_count                    NUMBER;
1241 
1242 
1243     CURSOR c_group_member_id(
1244 	 l_group_id       IN  NUMBER,
1245 	 l_resource_id    IN  NUMBER )
1246     IS
1247       SELECT group_member_id
1248       FROM jtf_rs_group_members
1249       WHERE group_id = l_group_id
1250 	   AND resource_id = l_resource_id
1251 	   AND nvl(delete_flag,'N') <> 'Y';
1252 
1253 
1254     CURSOR c_related_role_count(
1255 	 l_group_member_id    IN  NUMBER)
1256     IS
1257 	 SELECT count(*)
1258 	 FROM jtf_rs_role_relations
1259 	 WHERE role_resource_type = 'RS_GROUP_MEMBER'
1260 	   AND role_resource_id = l_group_member_id
1261 	   AND nvl(delete_flag,'N') <> 'Y';
1262 
1263 /*	   removed the below where condition from above statement
1264            by baianand to check any active or expired role exists or not
1265 
1266            AND ( end_date_active is null OR end_date_active >= sysdate )
1267 */
1268 
1269 
1270   BEGIN
1271 
1272 
1273     SAVEPOINT delete_resource_member_pvt;
1274 
1275     x_return_status := fnd_api.g_ret_sts_success;
1276 
1277 --    DBMS_OUTPUT.put_line(' Started Delete Resource Member Pvt ');
1278 
1279 
1280     IF NOT fnd_api.compatible_api_call(l_api_version, p_api_version, l_api_name, g_pkg_name) THEN
1281 
1282       RAISE fnd_api.g_exc_unexpected_error;
1283 
1284     END IF;
1285 
1286 
1287     IF fnd_api.to_boolean(p_init_msg_list) THEN
1288 
1289       fnd_msg_pub.initialize;
1290 
1291     END IF;
1292 
1293 
1294     /* Make the pre processing call to the user hooks */
1295 
1296     /* Pre Call to the Customer Type User Hook */
1297 
1298     IF jtf_resource_utl.ok_to_execute(
1299 	 'JTF_RS_GROUP_MEMBERS_PVT',
1300 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1301 	 'B',
1302 	 'C')
1303     THEN
1304     IF jtf_usr_hks.ok_to_execute(
1305 	 'JTF_RS_GROUP_MEMBERS_PVT',
1306 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1307 	 'B',
1308 	 'C')
1309     THEN
1310 
1311       jtf_rs_group_member_cuhk.delete_group_members_pre(
1312         p_group_id => l_group_id,
1313         p_resource_id => l_resource_id,
1314 	   x_return_status => x_return_status);
1315 
1316       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1317 
1318 --	   dbms_output.put_line('Returned Error status from the Pre Customer User Hook');
1319 
1320 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_CUST_USR_HOOK');
1321 	   fnd_msg_pub.add;
1322 
1323 
1324 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1325 	   RAISE FND_API.G_EXC_ERROR;
1326 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1327 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1328 	END IF;
1329 
1330 
1331       END IF;
1332 
1333     END IF;
1334     END IF;
1335 
1336 
1337     /* Pre Call to the Vertical Type User Hook */
1338 
1339     IF jtf_resource_utl.ok_to_execute(
1340 	 'JTF_RS_GROUP_MEMBERS_PVT',
1341 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1342 	 'B',
1343 	 'V')
1344     THEN
1345     IF jtf_usr_hks.ok_to_execute(
1346 	 'JTF_RS_GROUP_MEMBERS_PVT',
1347 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1348 	 'B',
1349 	 'V')
1350     THEN
1351 
1352       jtf_rs_group_member_vuhk.delete_group_members_pre(
1353         p_group_id => l_group_id,
1354         p_resource_id => l_resource_id,
1355 	   x_return_status => x_return_status);
1356 
1357       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1358 
1359 --	   dbms_output.put_line('Returned Error status from the Pre Vertical User Hook');
1360 
1361 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_VERT_USR_HOOK');
1362 	   fnd_msg_pub.add;
1363 
1364 
1365 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1366 	   RAISE FND_API.G_EXC_ERROR;
1367 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1368 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1369 	END IF;
1370 
1371       END IF;
1372 
1373     END IF;
1374     END IF;
1375 
1376 
1377     /* Pre Call to the Internal Type User Hook */
1378 
1379     IF jtf_resource_utl.ok_to_execute(
1380 	 'JTF_RS_GROUP_MEMBERS_PVT',
1381 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1382 	 'B',
1383 	 'I')
1384     THEN
1385     IF jtf_usr_hks.ok_to_execute(
1386 	 'JTF_RS_GROUP_MEMBERS_PVT',
1387 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1388 	 'B',
1389 	 'I')
1390     THEN
1391 
1392       jtf_rs_group_member_iuhk.delete_group_members_pre(
1393         p_group_id => l_group_id,
1394         p_resource_id => l_resource_id,
1395 	   x_return_status => x_return_status);
1396 
1397       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1398 
1399 
1400 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_PRE_INT_USR_HOOK');
1401 	   fnd_msg_pub.add;
1402 
1403 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1404 	   RAISE FND_API.G_EXC_ERROR;
1405 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1406 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1407 	END IF;
1408 
1409       END IF;
1410 
1411     END IF;
1412     END IF;
1413 
1414 
1415     /* Validate that the specified resource exists as a member of the
1416 	  specified group */
1417 
1418     OPEN c_group_member_id(l_group_id, l_resource_id);
1419 
1420     FETCH c_group_member_id INTO l_group_member_id;
1421 
1422 
1423     IF c_group_member_id%NOTFOUND THEN
1424 
1425 --	 dbms_output.put_line('Resource is not setup as a member of the Group');
1426 
1427       IF c_group_member_id%ISOPEN THEN
1428 
1429         CLOSE c_group_member_id;
1430 
1431       END IF;
1432 
1433       fnd_message.set_name('JTF', 'JTF_RS_INVALID_GROUP_MEMBER');
1434       fnd_message.set_token('P_RESOURCE_ID', l_resource_id);
1435       fnd_msg_pub.add;
1436 
1437       RAISE fnd_api.g_exc_error;
1438 
1439     END IF;
1440 
1441 
1442     /* Close the cursor */
1443 
1444     IF c_group_member_id%ISOPEN THEN
1445 
1446       CLOSE c_group_member_id;
1447 
1448     END IF;
1449 
1450 
1451 
1452     /* Validate that there are no associated roles with the group member
1453 	  which are presently active or will be active in future */
1454 
1455     OPEN c_related_role_count(l_group_member_id);
1456 
1457     FETCH c_related_role_count INTO l_role_relate_count;
1458 
1459 
1460     IF c_related_role_count%NOTFOUND THEN
1461 
1462 --	 dbms_output.put_line('Error in getting the count of the related role records');
1463 
1464       IF c_related_role_count%ISOPEN THEN
1465 
1466         CLOSE c_related_role_count;
1467 
1468       END IF;
1469 
1470       fnd_message.set_name('JTF', 'JTF_RS_ERROR_ROLE_COUNT');
1471       fnd_msg_pub.add;
1472 
1473       RAISE fnd_api.g_exc_error;
1474 
1475     ELSE
1476 
1477       IF l_role_relate_count > 0 THEN
1478 
1479 --	   dbms_output.put_line('Active Role Related Records found');
1480 
1481         IF c_related_role_count%ISOPEN THEN
1482 
1483           CLOSE c_related_role_count;
1484 
1485         END IF;
1486 
1487         fnd_message.set_name('JTF', 'JTF_RS_ACTIVE_ROLE_EXIST');
1488         fnd_msg_pub.add;
1489 
1490         x_return_status := fnd_api.g_ret_sts_unexp_error;
1491 
1492         RAISE fnd_api.g_exc_error;
1493 
1494       END IF;
1495 
1496     END IF;
1497 
1498 
1499 
1500     /* Call the lock row procedure to ensure that the object version number
1501 	  is still valid. */
1502 
1503     BEGIN
1504 
1505       jtf_rs_group_members_pkg.lock_row(
1506         x_group_member_id => l_group_member_id,
1507 	   x_object_version_number => p_object_version_num
1508       );
1509 
1510     EXCEPTION
1511 
1512 	 WHEN OTHERS THEN
1513 
1514 --	   dbms_output.put_line('Error in Locking the Row');
1515 
1516 	   x_return_status := fnd_api.g_ret_sts_unexp_error;
1517 
1518 	   fnd_message.set_name('JTF', 'JTF_RS_ROW_LOCK_ERROR');
1519 	   fnd_msg_pub.add;
1520 
1521 	   RAISE fnd_api.g_exc_error;
1522 
1523     END;
1524 
1525 
1526     /* Make a call to the group member Audit API */
1527 
1528     jtf_rs_group_members_aud_pvt.delete_member
1529     (P_API_VERSION => 1,
1530      P_INIT_MSG_LIST => fnd_api.g_false,
1531      P_COMMIT => fnd_api.g_false,
1532      P_GROUP_MEMBER_ID => l_group_member_id,
1533      X_RETURN_STATUS => x_return_status,
1534      X_MSG_COUNT => x_msg_count,
1535      X_MSG_DATA => x_msg_data
1536     );
1537 
1538 
1539     IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1540 
1541 --	 dbms_output.put_line('Failed status from call to audit procedure');
1542 
1543 
1544 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1545 	   RAISE FND_API.G_EXC_ERROR;
1546 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1547 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1548 	END IF;
1549 
1550     END IF;
1551 
1552 
1553 
1554     /* Call the private procedure for logical delete */
1555 
1556     BEGIN
1557 
1558       -- delete wf_user_role record for the new group member
1559       -- Don't care for its success status
1560       BEGIN
1561 	jtf_rs_wf_integration_pub.delete_resource_group_members
1562 	  (P_API_VERSION      => 1.0,
1563 	   P_RESOURCE_ID      =>  l_resource_id,
1564 	   P_GROUP_ID   => l_group_id,
1565 	   X_RETURN_STATUS   => l_return_status,
1566 	   X_MSG_COUNT      => l_msg_count,
1567 	   X_MSG_DATA      => l_msg_data);
1568       EXCEPTION
1569 	WHEN OTHERS THEN
1570 	  NULL;
1571       END;
1572 
1573       /* Delete the row into the table by calling the table handler. */
1574 
1575       jtf_rs_group_members_pkg.logical_delete_row(
1576         x_group_member_id => l_group_member_id
1577       );
1578 
1579       -- Delete record in active group members table
1580       BEGIN
1581 	jtf_rs_active_grp_mbrs_pkg.delete_row(
1582 	  x_group_member_id => l_group_member_id
1583 	);
1584       EXCEPTION
1585 	 WHEN no_data_found THEN
1586 	    NULL;
1587       END;
1588 
1589     EXCEPTION
1590 
1591 	 WHEN NO_DATA_FOUND THEN
1592 
1593 --	   dbms_output.put_line('Error in Table Handler');
1594 
1595 	   fnd_message.set_name('JTF', 'JTF_RS_TABLE_HANDLER_ERROR');
1596 	   fnd_msg_pub.add;
1597 
1598 	   RAISE fnd_api.g_exc_error;
1599 
1600     END;
1601 
1602 
1603     /* Make the post processing call to the user hooks */
1604 
1605     /* Post Call to the Customer Type User Hook */
1606 
1607     IF jtf_resource_utl.ok_to_execute(
1608 	 'JTF_RS_GROUP_MEMBERS_PVT',
1609 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1610 	 'A',
1611 	 'C')
1612     THEN
1613     IF jtf_usr_hks.ok_to_execute(
1614 	 'JTF_RS_GROUP_MEMBERS_PVT',
1615 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1616 	 'A',
1617 	 'C')
1618     THEN
1619 
1620       jtf_rs_group_member_cuhk.delete_group_members_post(
1621         p_group_id => l_group_id,
1622         p_resource_id => l_resource_id,
1623 	   x_return_status => x_return_status);
1624 
1625       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1626 
1627 --	   dbms_output.put_line('Returned Error status from the Post Customer User Hook');
1628 
1629 
1630 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_CUST_USR_HOOK');
1631 	   fnd_msg_pub.add;
1632 
1633 
1634 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1635 	   RAISE FND_API.G_EXC_ERROR;
1636 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1637 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1638 	END IF;
1639 
1640       END IF;
1641 
1642     END IF;
1643     END IF;
1644 
1645 
1646     /* Post Call to the Vertical Type User Hook */
1647 
1648     IF jtf_resource_utl.ok_to_execute(
1649 	 'JTF_RS_GROUP_MEMBERS_PVT',
1650 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1651 	 'A',
1652 	 'V')
1653     THEN
1654     IF jtf_usr_hks.ok_to_execute(
1655 	 'JTF_RS_GROUP_MEMBERS_PVT',
1656 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1657 	 'A',
1658 	 'V')
1659     THEN
1660 
1661       jtf_rs_group_member_vuhk.delete_group_members_post(
1662         p_group_id => l_group_id,
1663         p_resource_id => l_resource_id,
1664 	   x_return_status => x_return_status);
1665 
1666       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1667 
1668 --	   dbms_output.put_line('Returned Error status from the Post Vertical User Hook');
1669 
1670 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_VERT_USR_HOOK');
1671 	   fnd_msg_pub.add;
1672 
1673 
1674 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1675 	   RAISE FND_API.G_EXC_ERROR;
1676 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1677 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1678 	END IF;
1679 
1680       END IF;
1681 
1682     END IF;
1683     END IF;
1684 
1685 
1686     /* Post Call to the Internal Type User Hook */
1687 
1688     IF jtf_resource_utl.ok_to_execute(
1689 	 'JTF_RS_GROUP_MEMBERS_PVT',
1690 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1691 	 'A',
1692 	 'I')
1693     THEN
1694     IF jtf_usr_hks.ok_to_execute(
1695 	 'JTF_RS_GROUP_MEMBERS_PVT',
1696 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1697 	 'A',
1698 	 'I')
1699     THEN
1700 
1701       jtf_rs_group_member_iuhk.delete_group_members_post(
1702         p_group_id => l_group_id,
1703         p_resource_id => l_resource_id,
1704 	   x_return_status => x_return_status);
1705 
1706       IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1707 
1708 	   fnd_message.set_name('JTF', 'JTF_RS_ERR_POST_INT_USR_HOOK');
1709 	   fnd_msg_pub.add;
1710 
1711 
1712 	IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1713 	   RAISE FND_API.G_EXC_ERROR;
1714 	ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1715 	   RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1716 	END IF;
1717 
1718       END IF;
1719 
1720     END IF;
1721     END IF;
1722 
1723 
1724     /* Standard call for Message Generation */
1725 
1726     IF jtf_resource_utl.ok_to_execute(
1727 	 'JTF_RS_GROUP_MEMBERS_PVT',
1728 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1729 	 'M',
1730 	 'M')
1731     THEN
1732     IF jtf_usr_hks.ok_to_execute(
1733 	 'JTF_RS_GROUP_MEMBERS_PVT',
1734 	 'DELETE_RESOURCE_GROUP_MEMBERS',
1735 	 'M',
1736 	 'M')
1737     THEN
1738 
1739       IF (jtf_rs_group_member_cuhk.ok_to_generate_msg(
1740 	       p_group_member_id => l_group_member_id,
1741 	       x_return_status => x_return_status) )
1742       THEN
1743 
1744         /* Get the bind data id for the Business Object Instance */
1745 
1746         l_bind_data_id := jtf_usr_hks.get_bind_data_id;
1747 
1748 
1749         /* Set bind values for the bind variables in the Business Object SQL */
1750 
1751         jtf_usr_hks.load_bind_data(l_bind_data_id, 'group_member_id', l_group_member_id, 'S', 'N');
1752 
1753 
1754         /* Call the message generation API */
1755 
1756         jtf_usr_hks.generate_message(
1757 		p_prod_code => 'RS',
1758 		p_bus_obj_code => 'GMBR',
1759 		p_action_code => 'D',
1760 		p_bind_data_id => l_bind_data_id,
1761 		x_return_code => x_return_status);
1762 
1763 
1764         IF NOT (x_return_status = fnd_api.g_ret_sts_success) THEN
1765 
1766 --	     dbms_output.put_line('Returned Error status from the Message Generation API');
1767 
1768 	     fnd_message.set_name('JTF', 'JTF_RS_ERR_MESG_GENERATE_API');
1769 	     fnd_msg_pub.add;
1770 
1771 
1772 	   IF X_RETURN_STATUS = FND_API.G_RET_STS_ERROR THEN
1773 	      RAISE FND_API.G_EXC_ERROR;
1774 	   ELSIF X_RETURN_STATUS = FND_API.G_RET_STS_UNEXP_ERROR THEN
1775 	      RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1776 	   END IF;
1777 
1778         END IF;
1779 
1780       END IF;
1781 
1782     END IF;
1783     END IF;
1784 
1785 
1786     IF fnd_api.to_boolean(p_commit) THEN
1787 
1788 	 COMMIT WORK;
1789 
1790     END IF;
1791 
1792     fnd_msg_pub.count_and_get (p_count => x_msg_count, p_data => x_msg_data);
1793 
1794 
1795   EXCEPTION
1796 
1797     WHEN fnd_api.g_exc_error THEN
1798       ROLLBACK TO delete_resource_member_pvt;
1799       x_return_status := fnd_api.g_ret_sts_error;
1800       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
1801                                  p_data => x_msg_data);
1802     WHEN fnd_api.g_exc_unexpected_error THEN
1803       ROLLBACK TO delete_resource_member_pvt;
1804       x_return_status := fnd_api.g_ret_sts_unexp_error;
1805       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
1806                                  p_data => x_msg_data);
1807     WHEN OTHERS THEN
1808       ROLLBACK TO delete_resource_member_pvt;
1809       fnd_message.set_name ('JTF', 'JTF_RS_UNEXP_ERROR');
1810       fnd_message.set_token('P_SQLCODE',SQLCODE);
1811       fnd_message.set_token('P_SQLERRM',SQLERRM);
1812       fnd_message.set_token('P_API_NAME', l_api_name);
1813       FND_MSG_PUB.add;
1814       x_return_status := fnd_api.g_ret_sts_unexp_error;
1815       FND_MSG_PUB.count_and_get (p_count => x_msg_count,
1816                                  p_data => x_msg_data);
1817 
1818   END delete_resource_group_members;
1819 
1820 
1821     /* Procedure to move member hook  */
1822 
1823   PROCEDURE  execute_sales_hook
1824   (P_API_VERSION          IN   NUMBER,
1825    P_INIT_MSG_LIST        IN   VARCHAR2,
1826    P_COMMIT               IN   VARCHAR2,
1827    P_OLD_GROUP_ID         IN   JTF_RS_GROUP_MEMBERS.GROUP_ID%TYPE,
1828    P_NEW_GROUP_ID         IN   JTF_RS_GROUP_MEMBERS.GROUP_ID%TYPE,
1829    P_RESOURCE_ID          IN   JTF_RS_RESOURCE_EXTNS.RESOURCE_ID%TYPE,
1830    P_OLD_START_DATE       IN   DATE,
1831    P_OLD_END_DATE         IN   DATE,
1832    P_NEW_START_DATE       IN   DATE,
1833    P_NEW_END_DATE         IN   DATE,
1834    X_RETURN_STATUS        OUT NOCOPY VARCHAR2
1835   )
1836 
1837   IS
1838 
1839   BEGIN
1840 
1841      null;
1842 
1843   END execute_sales_hook;
1844 
1845 
1846 END jtf_rs_group_members_pvt;