DBA Data[Home] [Help]

PACKAGE BODY: APPS.PA_PRODUCT_INSTALL_UTILS

Source


1 PACKAGE BODY PA_product_install_Utils AS
2 /* $Header: PAPIUTLB.pls 120.1.12010000.3 2009/08/05 12:36:34 vchilla ship $ */
3 
4 Function check_object_licensed ( p_object_type  IN  VARCHAR2,
5                                  p_object_code  IN VARCHAR2)
6    RETURN VARCHAR2
7    is
8 
9    /* l_licensed_flag  VARCHAR2(1):= 'Y';  Bug# 8719060 */
10 
11    l_licensed_ycnt NUMBER :=0;
12    l_licensed_ncnt NUMBER :=0;
13 
14    /* Commenting for bug 6352484
15    Cursor C is
16     Select 'Y'
17     from PA_PRODUCT_FUNCTIONS PF,
18          pa_product_installation_v pi
19     where PF.object_type = p_object_type
20     and PF.object_code = p_object_code
21     and PF.product_code=pi.product_short_code
22     and pi.installed_flag='Y';
23 
24    Cursor C2 is
25     Select 'N'
26     from PA_PRODUCT_FUNCTIONS PF,
27          pa_product_installation_v pi
28     where PF.object_type = p_object_type
29     and PF.object_code = p_object_code
30     and PF.product_code=pi.product_short_code
31     and pi.installed_flag='N';
32 */
33   /* Modified CNEW for bug# 8719060 */
34   Cursor CNEW is
35      Select SUM(DECODE(nvl(pi.installed_flag,'Y'),'Y',1,0)) YCnt,
36             SUM(DECODE(nvl(pi.installed_flag,'N'),'N',1,0)) NCnt
37      from PA_PRODUCT_FUNCTIONS PF,
38           pa_product_installation_v pi
39      where PF.object_type = p_object_type
40      and PF.object_code = p_object_code
41      and PF.product_code=pi.product_short_code;
42 
43    BEGIN
44     /*commenting the below code w.r.t bug 6352484
45     open C;
46     fetch C into l_licensed_flag;
47     if (C%FOUND) then
48 	close C;
49 	return l_licensed_flag;
50     end if;
51     close C;
52 
53     open C2;
54     fetch C2 into l_licensed_flag;
55     if (C2%FOUND) then
56 	close C2;
57 	return l_licensed_flag;
58     end if;
59     close C2;
60 */
61    open CNEW;
62    fetch CNEW into l_licensed_ycnt,l_licensed_ncnt;
63    close CNEW;
64 
65    /* If product is not available in PA_PRODUCT_INSTALLATIONS,
66       we need to return Y.
67 
68       IF product is available, we need to check for Y cnt and N cnt to return the value
69       We had cursors C, C2 for this purpose only.
70    */
71 
72    IF (nvl(l_licensed_ycnt,0) = 0 AND nvl(l_licensed_ncnt,0) = 0) THEN
73       RETURN 'Y';
74    ELSIF (nvl(l_licensed_ycnt,0) > 0) THEN
75       RETURN 'Y';
76    ELSIF (nvl(l_licensed_ncnt,0) > 0 AND nvl(l_licensed_ycnt,0) = 0) THEN
77       RETURN 'N';
78    END IF;
79 
80    RETURN 'Y';
81 /*
82    if (CNEW%FOUND) then
83      close CNEW;
84      return l_licensed_flag;
85    end if;
86    close CNEW;
87    return l_licensed_flag;
88    EXCEPTION
89     When others then
90     l_licensed_flag := 'Y';
91     return l_licensed_flag;*/
92 
93 END check_object_licensed;
94 
95   Procedure validate_object(
96    p_object_type    IN  VARCHAR2,
97    p_object_code    IN  VARCHAR2,
98    x_ret_code       out NOCOPY varchar2, --File.Sql.39 bug 4440895
99    x_return_status  out NOCOPY varchar2, --File.Sql.39 bug 4440895
100    x_msg_count      out NOCOPY number, --File.Sql.39 bug 4440895
101    x_msg_data       out NOCOPY varchar2) --File.Sql.39 bug 4440895
102   is
103    l_object_exists  varchar2(1):= null;
104    l_pa_fn_exists   varchar2(1):= null;
105 
106    Cursor valid_function is
107     select 'X' from fnd_form_functions
108     where function_name=p_object_code;
109 
110    Cursor valid_project_function is
111     select 'X' from pa_product_functions
112     where object_type = 'FND_FUNCTION'
113     and   object_code = p_object_code;
114 
115     Cursor valid_region is
116     select 'X' from ak_regions
117     where region_code=p_object_code
118     and region_application_id=275;
119 
120     Cursor valid_product_region is
121     select 'X' from pa_product_functions
122     where object_type = 'AK_REGION'
123     and   object_code = p_object_code;
124   Begin
125     pa_debug.Init_err_stack ( 'Validate Object');
126     x_msg_count :=0;
127     x_msg_data:= null;
128     x_return_status:=fnd_api.g_ret_sts_success;
129     x_ret_code:= 'Y' ;
130 
131   /** Validate the IN parameter  **/
132   if (p_object_type = 'FND_FUNCTION') then
133     open valid_function;
134     fetch valid_function into l_object_exists;
135     if (valid_function%NOTFOUND) then
136      PA_UTILS.Add_Message( p_app_short_name => 'PA'
137                           ,p_msg_name       => 'PA_INV_FUNCTION');
138      x_msg_count := x_msg_count + 1;
139      x_return_status := FND_API.G_RET_STS_ERROR;
140      --PA_DEBUG.Reset_Err_Stack;
141      --close valid_function;
142      --RETURN;
143     end if;
144     close valid_function;
145     open valid_project_function;
146     fetch valid_project_function into l_pa_fn_exists;
147     if (valid_project_function%NOTFOUND) then
148      PA_UTILS.Add_Message( p_app_short_name => 'PA'
149                          ,p_msg_name       => 'PA_INV_PROJECT_FUNCTION');
150      x_msg_count := x_msg_count + 1;
151      x_return_status := FND_API.G_RET_STS_ERROR;
152      --PA_DEBUG.Reset_Err_Stack;
153      --close valid_project_function;
154      --RETURN;
155     end if;
156     close valid_project_function;
157  elsif (p_object_type = 'AK_REGION') then
158     open valid_region;
159     fetch valid_region into l_object_exists;
160     if (valid_region%NOTFOUND) then
161      PA_UTILS.Add_Message( p_app_short_name => 'PA'
162                           ,p_msg_name       => 'PA_INV_AK_REGION');
163      x_msg_count := x_msg_count + 1;
164      x_return_status := FND_API.G_RET_STS_ERROR;
165      --PA_DEBUG.Reset_Err_Stack;
166      --close valid_region;
167      --RETURN;
168     end if;
169     close valid_region;
170     --Check valid region per product licensing
171     open valid_product_region;
172     fetch valid_product_region into l_pa_fn_exists;
173     if (valid_product_region%NOTFOUND) then
174      PA_UTILS.Add_Message( p_app_short_name => 'PA'
175                          ,p_msg_name       => 'PA_INV_PROJECT_REGION');
176      x_msg_count := x_msg_count + 1;
177      x_return_status := FND_API.G_RET_STS_ERROR;
178      /*--PA_DEBUG.Reset_Err_Stack;
179      --close valid_project_function;
180      --RETURN;*/
181     end if;
182     close valid_product_region;
183   end if;
184    if(x_return_status = FND_API.G_RET_STS_ERROR) then
185     x_ret_code := 'N';
186   end if;
187     PA_DEBUG.Reset_Err_Stack;
188   EXCEPTION
189     When others then
190        -- Set the excetption Message and the stack
191        FND_MSG_PUB.add_exc_msg ( p_pkg_name => 'PA_PRODUCT_INSTALL_UTILS.validate_object'
192                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
193         --
194        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
195        x_ret_code := 'N';  -- This is optional depending on the needs
196   END validate_object;
197 
198   Procedure check_function_licensed
199   (
200    p_function_name  IN  VARCHAR2,
201    x_ret_code       out NOCOPY varchar2, --File.Sql.39 bug 4440895
202    x_return_status  out NOCOPY varchar2, --File.Sql.39 bug 4440895
203    x_msg_count      out NOCOPY number, --File.Sql.39 bug 4440895
204    x_msg_data       out NOCOPY varchar2) --File.Sql.39 bug 4440895
205   is
206     l_object_type varchar2(30):='FND_FUNCTION';
207 
208   Begin
209   pa_debug.Init_err_stack ( 'Check function Licensed');
210   x_msg_count :=0;
211   x_msg_data:= null;
212   x_return_status:=fnd_api.g_ret_sts_success;
213   x_ret_code:= 'N' ;
214 
215   /** Validate the parameter  **/
216   validate_object(
217    p_object_type    => 'FND_FUNCTION',
218    p_object_code    => p_function_name,
219    x_ret_code       => x_ret_code,
220    x_return_status  => x_return_status,
221    x_msg_count      => x_msg_count,
222    x_msg_data       => x_msg_data);
223 
224   if(x_return_status <> FND_API.G_RET_STS_ERROR) then
225     x_ret_code := check_object_licensed ( p_object_type  => 'FND_FUNCTION',
226                                           p_object_code  => p_function_name);
227   end if;
228 
229   EXCEPTION
230     When others then
231        -- Set the excetption Message and the stack
232        FND_MSG_PUB.add_exc_msg ( p_pkg_name => 'PA_PRODUCT_INSTALL_UTILS.check_function_licensed'
233                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
234         --
235        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
236        RAISE;  -- This is optional depending on the needs
237    END check_function_licensed;
238 
239   /************************************************************************
240    This function detremines the whether it is licensed to use a function or Not
241    Name of the Function : check_function_licensed
242    IN PARAMETERS  p_function_name - Name of the function
243    RETURN VALUE   - Y - Eligible to use , N- Not  Eligible to use
244     *************************************************************************/
245    Function check_function_licensed ( p_function_name  IN  VARCHAR2)
246    RETURN VARCHAR2
247    is
248    l_fun_licensed  VARCHAR2(1):= 'Y';
249    BEGIN
250     l_fun_licensed := check_object_licensed ( p_object_type  => 'FND_FUNCTION',
251                                               p_object_code  => p_function_name);
252     return l_fun_licensed;
253    EXCEPTION
254     When others then
255     l_fun_licensed := 'N';
256     return l_fun_licensed;
257    END check_function_licensed;
258 
259    Function check_region_licensed ( p_region_code  IN  VARCHAR2)
260    RETURN VARCHAR2
261    is
262    l_fun_licensed  VARCHAR2(1):= 'Y';
263    BEGIN
264     l_fun_licensed := check_object_licensed ( p_object_type  => 'AK_REGION',
265                                               p_object_code  => p_region_code);
266     return l_fun_licensed;
267    EXCEPTION
268     When others then
269     l_fun_licensed := 'N';
270     return l_fun_licensed;
271    END check_region_licensed;
272 
273    Procedure check_region_licensed
274   (
275    p_region_code    IN  VARCHAR2,
276    x_ret_code       out NOCOPY varchar2, --File.Sql.39 bug 4440895
277    x_return_status  out NOCOPY varchar2, --File.Sql.39 bug 4440895
278    x_msg_count      out NOCOPY number, --File.Sql.39 bug 4440895
279    x_msg_data       out NOCOPY varchar2) --File.Sql.39 bug 4440895
280   is
281     l_object_type varchar2(30):='AK_REGION';
282 
283   Begin
284   pa_debug.Init_err_stack ( 'Check Region Licensed');
285   x_msg_count :=0;
286   x_msg_data:= null;
287   x_return_status:=fnd_api.g_ret_sts_success;
288   x_ret_code:= 'N' ;
289 
290   /** Validate the parameter  **/
291   validate_object(
292    p_object_type    => 'AK_REGION',
293    p_object_code    => p_region_code,
294    x_ret_code       => x_ret_code,
295    x_return_status  => x_return_status,
296    x_msg_count      => x_msg_count,
297    x_msg_data       => x_msg_data);
298 
299   if(x_return_status <> FND_API.G_RET_STS_ERROR) then
300     x_ret_code := check_object_licensed ( p_object_type  => 'AK_REGION',
301                                           p_object_code  => p_region_code);
302   end if;
303 
304   EXCEPTION
305     When others then
306        -- Set the excetption Message and the stack
307        FND_MSG_PUB.add_exc_msg ( p_pkg_name => 'PA_PRODUCT_INSTALL_UTILS.check_region_licensed'
308                                  ,p_procedure_name => PA_DEBUG.G_Err_Stack );
309         --
310        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
311        x_ret_code:= 'N' ;
312        RAISE;  -- This is optional depending on the needs
313    END check_region_licensed;
314 
315 
316 END PA_product_install_Utils;