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