DBA Data[Home] [Help]

PACKAGE BODY: APPS.CN_SFP_GROUP_UTIL_PVT

Source


1 PACKAGE BODY CN_SFP_GROUP_UTIL_PVT AS
2 -- $Header: cnvsfgrb.pls 115.4 2003/08/19 22:31:44 sbadami noship $
3 
4 G_PKG_NAME               CONSTANT VARCHAR2(30) := 'CN_SFP_GROUP_UTIL_PVT';
5 G_FILE_NAME              CONSTANT VARCHAR2(12) := 'cnvsfgrb.pls';
6 
7 
8 PROCEDURE check_success(p_return_status IN VARCHAR2) IS
9     BEGIN
10      IF p_return_status = FND_API.G_RET_STS_ERROR THEN
11         RAISE FND_API.G_EXC_ERROR;
12      ELSIF p_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
13         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
14      END IF;
15 END;
16 
17 FUNCTION check_exist_group(p_grp_list IN grpnum_tbl_type,
18                            p_grp      IN NUMBER)
19 RETURN VARCHAR2 IS
20   x_exist VARCHAR2(1);
21 BEGIN
22    x_exist := 'N';
23 
24    IF p_grp_list.COUNT > 0 THEN
25      FOR i IN p_grp_list.first..p_grp_list.last LOOP
26         IF (p_grp_list(i) = p_grp) THEN
27            x_exist := 'Y';
28         END IF;
29      END LOOP;
30    END IF;
31 
32    RETURN x_exist;
33 END;
34 
35 FUNCTION check_exist_srprole(p_srprole_list IN srprole_tbl_type,
36                              p_srp_role IN NUMBER,
37                              p_comp_group IN NUMBER)
38 RETURN VARCHAR2 IS
39   x_exist VARCHAR2(1);
40 BEGIN
41    x_exist := 'N';
42 
43    IF p_srprole_list.COUNT > 0 THEN
44      FOR i IN p_srprole_list.first..p_srprole_list.last LOOP
45         IF ((p_srprole_list(i).srp_role_id = p_srp_role) AND (p_srprole_list(i).comp_group_id = p_comp_group) )THEN
46            x_exist := 'Y';
47         END IF;
48      END LOOP;
49    END IF;
50 
51    RETURN x_exist;
52 END;
53 
54 PROCEDURE pre_process_groups(p_selected_groups IN  grpnum_tbl_type,
55                              x_process_groups  OUT NOCOPY grpnum_tbl_type) IS
56     l_selected_groups grpnum_tbl_type;
57     l_found boolean := false;
58     l_out_counter NUMBER := 0;
59     CURSOR groups_cur(p_comp_group_id NUMBER) IS
60     SELECT group_id,parent_group_id from jtf_rs_groups_denorm
61     where group_id = p_comp_group_id and parent_group_id <> p_comp_group_id;
62 BEGIN
63     l_selected_groups := p_selected_groups;
64     IF (p_selected_groups.COUNT > 0) THEN
65        FOR i IN l_selected_groups.FIRST .. l_selected_groups.LAST LOOP
66          l_found := false;
67          FOR eachrec in groups_cur(l_selected_groups(i)) LOOP
68              FOR z in p_selected_groups.FIRST .. p_selected_groups.LAST LOOP
69                 IF (eachrec.parent_group_id = p_selected_groups(z)) THEN
70                   l_found := true;
71                 END IF;
72              END LOOP;
73          END LOOP;
74 
75          IF (l_found = false) THEN
76             x_process_groups(l_out_counter) := l_selected_groups(i);
77             l_out_counter := l_out_counter + 1;
78          END IF;
79        END LOOP;
80     END IF;
81 END;
82 
83 
84 -- Start of comments
85 --    API name        : Get_Descendant_Groups
86 --    Type            : Private.
87 --    Function        :
88 --    Pre-reqs        : None.
89 --    Parameters      :
90 --    IN              : p_api_version         IN NUMBER       Required
91 --                      p_init_msg_list       IN VARCHAR2     Optional
92 --                        Default = FND_API.G_FALSE
93 --                      p_commit              IN VARCHAR2     Optional
94 --                        Default = FND_API.G_FALSE
95 --                      p_validation_level    IN NUMBER       Optional
96 --                        Default = FND_API.G_VALID_LEVEL_FULL
97 --                      p_selected_groups     IN   DBMS_SQL.NUMBER_TABLE,
98 --                      p_effective_date
99 --    OUT             : x_return_status       OUT VARCHAR2(1)
100 --                      x_msg_count           OUT NUMBER
101 --                      x_msg_data            OUT VARCHAR2(2000)
102 --                      x_descendant_groups   OUT DBMS_SQL.NUMBER_TABLE
103 --    Version :         Current version       1.0
104 --
105 --
106 --
107 --    Notes           : This procedures takes many comp group ids as parameters
108 --                      and tries to generate the distinct comp group id list.
109 --
110 -- End of comments
111 
112 PROCEDURE Get_Descendant_Groups
113  ( p_api_version             IN  NUMBER,
114    p_init_msg_list           IN  VARCHAR2 := FND_API.G_FALSE,
115    p_commit                  IN  VARCHAR2 := FND_API.G_FALSE,
116    p_validation_level        IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
117    p_selected_groups         IN  grpnum_tbl_type,
118    p_effective_date          IN  DATE := SYSDATE,
119    x_descendant_groups       OUT NOCOPY    grpnum_tbl_type,
120    x_return_status           OUT NOCOPY    VARCHAR2 ,
121    x_msg_count               OUT NOCOPY    NUMBER ,
122    x_msg_data                OUT NOCOPY    VARCHAR2
123  ) IS
124       l_api_name     CONSTANT VARCHAR2(30) := 'Get_Descendant_Groups';
125       l_api_version  CONSTANT NUMBER  := 1.0;
126       l_error_code NUMBER;
127       l_temp_groups grpnum_tbl_type;
128       l_counter NUMBER := 0;
129       l_selected_groups grpnum_tbl_type;
130       j NUMBER;
131       CURSOR desc_groups_cur(p_comp_group_id NUMBER,p_date DATE) IS
132       select
133       rgd.group_id,
134       rg.group_name,
135       rgd.parent_group_id,
136       rgd.start_date_active,
137       rgd.end_date_active
138       from jtf_rs_groups_denorm rgd,jtf_rs_group_usages rgu,jtf_rs_groups_vl rg
139       where
140           rgd.group_id = rgu.group_id
141           and rg.group_id = rgu.group_id
142           and rg.group_id = rgd.group_id
143           and rgu.usage = 'SF_PLANNING'
144           and rgd.parent_group_id = p_comp_group_id
145           and p_date between rgd.start_date_active and nvl(rgd.end_date_active,p_date)
146       ORDER by rgd.denorm_level;
147 
148 BEGIN
149 
150    SAVEPOINT   Get_Descendant_Groups;
151    -- Standard call to check for call compatibility.
152    IF NOT FND_API.compatible_api_call
153      ( l_api_version ,p_api_version ,l_api_name ,G_PKG_NAME )
154      THEN
155       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
156    END IF;
157 
158     -- Initialize message list if p_init_msg_list is set to TRUE.
159    IF FND_API.to_Boolean( p_init_msg_list ) THEN
160       FND_MSG_PUB.initialize;
161    END IF;
162    --  Initialize API return status to success
163    x_return_status  := FND_API.G_RET_STS_SUCCESS;
164 
165    -- API body
166    /* OLD CODE WITH NO ORDERING */
167    /*
168    FOR i IN p_selected_groups.first..p_selected_groups.last LOOP
169      FOR l_desc_grp IN desc_groups_cur(p_selected_groups(i),p_effective_date) LOOP
170            l_temp_groups(l_desc_grp.group_id) := nvl(l_desc_grp.group_id,0) + 1;
171      END LOOP;
172    END LOOP ;
173 
174    j := l_temp_groups.FIRST;
175    WHILE j IS NOT NULL LOOP
176       x_descendant_groups(l_counter) := j;
177       l_counter := l_counter + 1;
178       j := l_temp_groups.NEXT(j);
179    END LOOP;
180    */
181 
182    /* New Groups Code with Ordering */
183 
184    pre_process_groups(p_selected_groups,l_selected_groups);
185 
186 
187    FOR i IN l_selected_groups.first..l_selected_groups.last LOOP
188         FOR l_desc_grp IN desc_groups_cur(l_selected_groups(i),p_effective_date) LOOP
189            IF (check_exist_group(l_temp_groups,l_desc_grp.group_id) = 'N') THEN
190               l_temp_groups(l_counter) := l_desc_grp.group_id;
191               l_counter := l_counter + 1;
192            END IF;
193         END LOOP;
194    END LOOP ;
195 
196    x_descendant_groups := l_temp_groups;
197 
198    -- End of API body.
199 
200    << end_Get_Descendant_Groups >>
201    NULL;
202 
203    -- Standard check of p_commit.
204    IF FND_API.To_Boolean( p_commit ) THEN
205       COMMIT WORK;
206    END IF;
207    -- Standard call to get message count and if count is 1, get message info.
208    FND_MSG_PUB.Count_And_Get
209      (
210       p_count   =>  x_msg_count ,
211       p_data    =>  x_msg_data  ,
212       p_encoded => FND_API.G_FALSE
213       );
214 
215 EXCEPTION
216    WHEN FND_API.G_EXC_ERROR THEN
217       ROLLBACK TO Get_Descendant_Groups  ;
218       x_return_status := FND_API.G_RET_STS_ERROR ;
219       FND_MSG_PUB.Count_And_Get
220   (
221    p_count   =>  x_msg_count ,
222    p_data    =>  x_msg_data  ,
223    p_encoded => FND_API.G_FALSE
224    );
225 
226    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
227       ROLLBACK TO Get_Descendant_Groups ;
228       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
229       FND_MSG_PUB.Count_And_Get
230   (
231    p_count   =>  x_msg_count ,
232    p_data    =>  x_msg_data   ,
233    p_encoded => FND_API.G_FALSE
234    );
235    WHEN OTHERS THEN
236       ROLLBACK TO Get_Descendant_Groups ;
237       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
238       FND_MSG_PUB.Count_And_Get
239   (
240    p_count   =>  x_msg_count ,
241    p_data    =>  x_msg_data  ,
242    p_encoded => FND_API.G_FALSE
243    );
244 END Get_Descendant_Groups;
245 
246 
247 -- Start of comments
248 --    API name        : Get_Salesrep_Roles
249 --    Type            : Private.
250 --    Function        :
251 --    Pre-reqs        : None.
252 --    Parameters      :
253 --    IN              : p_api_version         IN NUMBER       Required
254 --                      p_init_msg_list       IN VARCHAR2     Optional
255 --                        Default = FND_API.G_FALSE
256 --                      p_commit              IN VARCHAR2     Optional
257 --                        Default = FND_API.G_FALSE
258 --                      p_validation_level    IN NUMBER       Optional
259 --                        Default = FND_API.G_VALID_LEVEL_FULL
260 --                      p_selected_groups     IN  DBMS_SQL.NUMBER_TABLE,
261 --                      p_status              IN  VARCHAR2
262 --                      p_effective_date      IN  DATE
263 --    OUT             : x_return_status       OUT VARCHAR2(1)
264 --                      x_msg_count           OUT NUMBER
265 --                      x_msg_data            OUT VARCHAR2(2000)
266 --                      x_salesrep_roles      OUT srprole_tbl_type
267 --    Version :         Current version       1.0
268 --
269 --
270 --
271 --    Notes           : This procedure gets the srp role ids for all the
272 --                      groups that have been selected based on the status
273 --                      Status could be PENDING, LOCKED,GENERATED, SUBMITTED
274 --                      APPROVED, ISSUED and ACCEPTED or ALL
275 --
276 -- End of comments
277 
278 PROCEDURE Get_Salesrep_Roles
279  ( p_api_version             IN  NUMBER,
280    p_init_msg_list           IN  VARCHAR2 := FND_API.G_FALSE,
281    p_commit                  IN  VARCHAR2 := FND_API.G_FALSE,
282    p_validation_level        IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
283    p_selected_groups         IN  grpnum_tbl_type,
284    p_status                  IN  VARCHAR2 := 'ALL',
285    p_effective_date          IN  DATE := SYSDATE,
286    x_salesrep_roles          OUT NOCOPY    srprole_tbl_type,
287    x_return_status           OUT NOCOPY    VARCHAR2,
288    x_msg_count               OUT NOCOPY    NUMBER,
289    x_msg_data                OUT NOCOPY    VARCHAR2
290  )IS
291     l_api_name     CONSTANT VARCHAR2(30) := 'Get_Salesrep_Roles';
292     l_api_version  CONSTANT NUMBER  := 1.0;
293     l_error_code NUMBER;
294     l_temp_srproles grpnum_tbl_type;
295     l_counter NUMBER := 0;
296     j NUMBER;
297     l_status VARCHAR2(20);
298     l_descendant_groups grpnum_tbl_type;
299     l_return_status VARCHAR2(2);
300     l_msg_count NUMBER;
301     l_msg_data VARCHAR2(255);
302          CURSOR srp_roles_cur(p_comp_group_id NUMBER,p_date DATE,p_status VARCHAR2) IS
303           select srd.srp_role_id,
304 	         comp_group_id,
305 	         group_name,
306 	         qmsg.srp_id,
307 	         qmsg.role_id,
308 	         qmsg.role_name,
309 	         start_date,
310 	         end_date,
311 	         srd.status,
312 	         srd.plan_activate_status,
313 	         srd.org_code
314 	  from cn_qm_mgr_srp_groups qmsg, cn_srp_role_dtls_v srd
315 	  where comp_group_id = p_comp_group_id
316 	  and   qmsg.srp_role_id = srd.srp_role_id
317 	  and   srd.role_model_id is null
318 	  and   srd.job_title_id <> -99
319 	  and   p_date between start_date_active and nvl(end_date_active,p_date)
320 	  and   p_date between srd.start_date and nvl(srd.end_date,p_date)
321 	  and   srd.status like p_status
322 	 order by manager_flag desc;
323 
324 BEGIN
325    SAVEPOINT   Get_Salesrep_Roles;
326    -- Standard call to check for call compatibility.
327    IF NOT FND_API.compatible_api_call
328      ( l_api_version ,p_api_version ,l_api_name ,G_PKG_NAME )
329      THEN
330       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
331    END IF;
332 
333     -- Initialize message list if p_init_msg_list is set to TRUE.
334    IF FND_API.to_Boolean( p_init_msg_list ) THEN
335       FND_MSG_PUB.initialize;
336    END IF;
337    --  Initialize API return status to success
338    x_return_status  := FND_API.G_RET_STS_SUCCESS;
339 
340    -- API body
341      l_status := p_status;
342      IF (l_status = 'ALL') THEN
343        l_status := '%';
344      END IF;
345 
346      cn_sfp_group_util_pvt.get_descendant_groups(p_api_version,
347                                                  p_init_msg_list,
348                                                  p_commit,
349                                                  p_validation_level,
350                                                  p_selected_groups,
351                                                  p_effective_date,
352                                                  l_descendant_groups,
353                                                  l_return_status,
354                                                  l_msg_count,
355                                                  l_msg_data);
356      check_success(p_return_status => l_return_status);
357 
358      /*
359      FOR i IN l_descendant_groups.first..l_descendant_groups.last LOOP
360        FOR l_srp_role IN srp_roles_cur(l_descendant_groups(i),p_effective_date,l_status) LOOP
361              l_temp_srproles(l_srp_role.srp_role_id) := l_srp_role.comp_group_id;
362        END LOOP;
363      END LOOP ;
364 
365      j :=l_temp_srproles.FIRST;
366      WHILE j IS NOT NULL LOOP
367         x_salesrep_roles(l_counter).srp_role_id := j;
368         x_salesrep_roles(l_counter).comp_group_id := l_temp_srproles(j);
369         l_counter := l_counter + 1;
370         j :=l_temp_srproles.NEXT(j);
371      END LOOP;*/
372 
373 
374      FOR i IN l_descendant_groups.first..l_descendant_groups.last LOOP
375         FOR l_srp_role IN srp_roles_cur(l_descendant_groups(i),p_effective_date,l_status) LOOP
376              IF(check_exist_srprole(x_salesrep_roles,
377 	                            l_srp_role.srp_role_id,
378                                     l_srp_role.comp_group_id) = 'N') THEN
379                       x_salesrep_roles(l_counter).srp_role_id := l_srp_role.srp_role_id;
380 		      x_salesrep_roles(l_counter).comp_group_id := l_srp_role.comp_group_id;
381 		      x_salesrep_roles(l_counter).org_code := l_srp_role.org_code;
382 		      l_counter := l_counter + 1;
383              END IF;
384          END LOOP;
385      END LOOP ;
386 
387    -- End of API body.
388    << end_Get_Salesrep_Roles >>
389    -- Standard check of p_commit.
390    IF FND_API.To_Boolean( p_commit ) THEN
391       COMMIT WORK;
392    END IF;
393    -- Standard call to get message count and if count is 1, get message info.
394    FND_MSG_PUB.Count_And_Get
395      (
396       p_count   =>  x_msg_count ,
397       p_data    =>  x_msg_data  ,
398       p_encoded => FND_API.G_FALSE
399       );
400 
401 EXCEPTION
402    WHEN FND_API.G_EXC_ERROR THEN
403       ROLLBACK TO Get_Salesrep_Roles  ;
404       x_return_status := FND_API.G_RET_STS_ERROR ;
405       FND_MSG_PUB.Count_And_Get(p_count   =>  x_msg_count ,
406                                 p_data    =>  x_msg_data  ,
407                                 p_encoded => FND_API.G_FALSE);
408 
409    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
410       ROLLBACK TO Get_Salesrep_Roles ;
411       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
412       FND_MSG_PUB.Count_And_Get(p_count   =>  x_msg_count ,
413                                 p_data    =>  x_msg_data  ,
414                                 p_encoded => FND_API.G_FALSE);
415    WHEN OTHERS THEN
416       ROLLBACK TO Get_Salesrep_Roles ;
417       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
418       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
419       THEN
420           FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME ,l_api_name) ;
421       END IF ;
422       FND_MSG_PUB.Count_And_Get(p_count   =>  x_msg_count ,
423                                 p_data    =>  x_msg_data  ,
424                                 p_encoded => FND_API.G_FALSE);
425 END Get_Salesrep_Roles;
426 
427 -- Start of comments
428 --    API name        : Get_Grp_Organization_Access
429 --    Type            : Private.
430 --    Function        :
431 --    Pre-reqs        : None.
432 --    Parameters      :
433 --    IN              : p_api_version         IN NUMBER       Required
434 --                      p_init_msg_list       IN VARCHAR2     Optional
435 --                        Default = FND_API.G_FALSE
436 --                      p_commit              IN VARCHAR2     Optional
437 --                        Default = FND_API.G_FALSE
438 --                      p_validation_level    IN NUMBER       Optional
439 --                        Default = FND_API.G_VALID_LEVEL_FULL
440 --                      p_comp_group_id       IN  NUMBER,
441 --                      p_effective_date      IN  DATE
442 --    OUT             : x_return_status       OUT VARCHAR2(1)
443 --                      x_msg_count           OUT NUMBER
444 --                      x_msg_data            OUT VARCHAR2(2000)
445 --                      x_updview_organization OUT grporg_tbl_type
446 --                      x_upd_organization OUT grporg_tbl_type
447 --                      x_view_organization OUT grporg_tbl_type
448 --                      x_noview_organization OUT grporg_tbl_type
449 --    Version :         Current version       1.0
450 --
451 --
452 --
453 --    Notes           : This procedure given a comp group id and an effective
454 --                      date lists the Organization user has UPDATE/VIEW or
455 --                      NO_READ accesses for that group.
456 --
457 -- End of comments
458 
459 PROCEDURE Get_Grp_Organization_Access
460 (  p_api_version             IN  NUMBER,
461    p_init_msg_list           IN  VARCHAR2 := FND_API.G_FALSE,
462    p_commit                  IN  VARCHAR2 := FND_API.G_FALSE,
463    p_validation_level        IN  NUMBER   := FND_API.G_VALID_LEVEL_FULL,
464    p_comp_group_id           IN  NUMBER,
465    p_effective_date          IN  DATE := SYSDATE,
466    x_updview_organization    OUT NOCOPY    grporg_tbl_type,
467    x_upd_organization        OUT NOCOPY    grporg_tbl_type,
468    x_view_organization       OUT NOCOPY    grporg_tbl_type,
469    x_noview_organization     OUT NOCOPY    grporg_tbl_type,
470    x_return_status           OUT NOCOPY    VARCHAR2,
471    x_msg_count               OUT NOCOPY    NUMBER,
472    x_msg_data                OUT NOCOPY    VARCHAR2
473  ) IS
474     l_api_name     CONSTANT VARCHAR2(30) := 'Get_Grp_Organization_Access';
475     l_api_version  CONSTANT NUMBER  := 1.0;
476     l_updview_counter NUMBER := 0;
477     l_upd_counter NUMBER:= 0;
478     l_view_counter NUMBER:= 0;
479     l_noview_counter NUMBER:= 0;
480     l_updview_organization grporg_tbl_type;
481     l_upd_organization grporg_tbl_type;
482     l_view_organization grporg_tbl_type;
483     l_noview_organization grporg_tbl_type;
484     l_update_groups SYS.DBMS_SQL.NUMBER_TABLE;
485     l_view_groups SYS.DBMS_SQL.NUMBER_TABLE;
486     l_return_status VARCHAR2(10);
487     l_msg_count NUMBER;
488     l_msg_data VARCHAR2(300);
489     l_privilege VARCHAR2(10);
490 
491     CURSOR c_lkup is
492     SELECT LOOKUP_CODE , MEANING FROM CN_LOOKUPS
493     WHERE lookup_type = 'ORGANIZATION' order by meaning;
494 
495 BEGIN
496    SAVEPOINT   Get_Grp_Organization_Access;
497    -- Standard call to check for call compatibility.
498    IF NOT FND_API.compatible_api_call
499      ( l_api_version ,p_api_version ,l_api_name ,G_PKG_NAME )
500      THEN
501       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
502    END IF;
503 
504     -- Initialize message list if p_init_msg_list is set to TRUE.
505    IF FND_API.to_Boolean( p_init_msg_list ) THEN
506       FND_MSG_PUB.initialize;
507    END IF;
508    --  Initialize API return status to success
509    x_return_status  := FND_API.G_RET_STS_SUCCESS;
510 
511    -- API body
512    for eachrec in c_lkup LOOP
513       l_view_groups.delete;
514       l_update_groups.delete;
515       cn_sfp_srp_util_pvt.get_all_groups_access(p_api_version => l_api_version,
516                                                 p_org_code => eachrec.lookup_code,
517                                                 p_date => p_effective_date,
518                                                 x_update_groups => l_update_groups,
519                                                 x_view_groups => l_view_groups,
520                                                 x_return_status => l_return_status,
521                                                 x_msg_count => l_msg_count,
522                                                 x_msg_data => l_msg_data);
523       IF (l_return_status = FND_API.G_RET_STS_SUCCESS) THEN
524 	  cn_sfp_srp_util_pvt.get_group_access(p_api_version => l_api_version,
525 					       p_group_id => p_comp_group_id,
526 					       p_update_groups => l_update_groups,
527 					       p_view_groups => l_view_groups,
528 					       x_privilege => l_privilege,
529 					       x_return_status => l_return_status,
530 					       x_msg_count => l_msg_count,
531 					       x_msg_data => l_msg_data);
532 
533 	  IF (l_privilege = 'READ') THEN
534 	     l_updview_organization(l_updview_counter).org_code := eachrec.lookup_code;
535 	     l_updview_organization(l_updview_counter).org_meaning := eachrec.meaning;
536 	     l_updview_counter := l_updview_counter + 1;
537 
538 	     l_view_organization(l_view_counter).org_code := eachrec.lookup_code;
539 	     l_view_organization(l_view_counter).org_meaning := eachrec.meaning;
540 	     l_view_counter := l_view_counter + 1;
541 	  END IF;
542 
543 
544 	  IF (l_privilege = 'WRITE') THEN
545 	     l_updview_organization(l_updview_counter).org_code := eachrec.lookup_code;
546 	     l_updview_organization(l_updview_counter).org_meaning := eachrec.meaning;
547 	     l_updview_counter := l_updview_counter + 1;
548 
549 	     l_upd_organization(l_upd_counter).org_code := eachrec.lookup_code;
550 	     l_upd_organization(l_upd_counter).org_meaning := eachrec.meaning;
551 	     l_upd_counter := l_upd_counter + 1;
552 	  END IF;
553 
554 	  IF (l_privilege = 'NO_READ') THEN
555 	     l_noview_organization(l_noview_counter).org_code := eachrec.lookup_code;
556 	     l_noview_organization(l_noview_counter).org_meaning := eachrec.meaning;
557 	     l_noview_counter := l_noview_counter + 1;
558 	  END IF;
559 
560       END IF;
561    end loop;
562 
563    x_updview_organization := l_updview_organization;
564    x_upd_organization := l_upd_organization;
565    x_view_organization := l_view_organization;
566    x_noview_organization := l_noview_organization;
567 
568    -- End of API body.
569    << end_Get_Grp_Organ_Access >>
570    -- Standard check of p_commit.
571    IF FND_API.To_Boolean( p_commit ) THEN
572       COMMIT WORK;
573    END IF;
574    -- Standard call to get message count and if count is 1, get message info.
575    FND_MSG_PUB.Count_And_Get
576      (
577       p_count   =>  x_msg_count ,
578       p_data    =>  x_msg_data  ,
579       p_encoded => FND_API.G_FALSE
580       );
581 
582 EXCEPTION
583    WHEN FND_API.G_EXC_ERROR THEN
584       ROLLBACK TO Get_Grp_Organization_Access  ;
585       x_return_status := FND_API.G_RET_STS_ERROR ;
586       FND_MSG_PUB.Count_And_Get(p_count   =>  x_msg_count ,
587                                 p_data    =>  x_msg_data  ,
588                                 p_encoded => FND_API.G_FALSE);
589 
590    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
591       ROLLBACK TO Get_Grp_Organization_Access ;
592       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
593       FND_MSG_PUB.Count_And_Get(p_count   =>  x_msg_count ,
594                                 p_data    =>  x_msg_data  ,
595                                 p_encoded => FND_API.G_FALSE);
596    WHEN OTHERS THEN
597       ROLLBACK TO Get_Grp_Organization_Access ;
598       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
599       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
600       THEN
601           FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME ,l_api_name) ;
602       END IF ;
603       FND_MSG_PUB.Count_And_Get(p_count   =>  x_msg_count ,
604                                 p_data    =>  x_msg_data  ,
605                                 p_encoded => FND_API.G_FALSE);
606 END Get_Grp_Organization_Access;
607 
608 END CN_SFP_GROUP_UTIL_PVT;