1 package body PA_BUDGET_PVT as
2 --$Header: PAPMBUVB.pls 120.40.12020000.2 2013/04/10 07:43:59 djambhek ship $
3 --package constants to be used in error messages
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'PA_BUDGET_PVT';
5
6 --package constants to be used during updates
7 G_USER_ID CONSTANT NUMBER := FND_GLOBAL.user_id;
8 G_LOGIN_ID CONSTANT NUMBER := FND_GLOBAL.login_id;
9
10 -- Bug Fix: 4569365. Removed MRC code.
11 -- g_mrc_exception EXCEPTION; /* FPB2 */
12
13 g_module_name VARCHAR2(100) := 'pa.plsql.PA_BUDGET_PVT';
14
15 -- Cursor to get the budget amount code of the budget type passed
16 CURSOR l_budget_amount_code_csr
17 (c_budget_type_code VARCHAR2 )
18 IS
19 SELECT budget_amount_code
20 FROM pa_budget_types
21 WHERE budget_type_code = c_budget_type_code;
22
23 -- Cursor to validate the change reason code
24 CURSOR l_budget_change_reason_csr ( c_change_reason_code VARCHAR2 )
25 IS
26 SELECT 'x'
27 FROM pa_lookups
28 WHERE lookup_type = 'BUDGET CHANGE REASON'
29 AND lookup_code = c_change_reason_code;
30
31 --Bug 2871603: Added the following PLSQL table to remove build dependency.
32 TYPE l_txn_currency_code_tbl_typ IS TABLE OF
33 pa_budget_lines.TXN_CURRENCY_CODE%TYPE INDEX BY BINARY_INTEGER ;
34
35 --This record type will contain key and a value. A pl/sql tbl of this record type can be declared and it can be
36 --used for different purposes. One such case is : if its required to get the wbs level for a task id at many
37 --places in the code then instead of firing a select each time we can fetch it and store in this record. The key
38 --will be the task id and the value will be top task id.
39 --Created for bug 3678314
40 TYPE key_value_rec IS RECORD
41 (key NUMBER
42 ,value VARCHAR2(30));
43
44 TYPE key_value_rec_tbl_type IS TABLE OF key_value_rec
45 INDEX BY BINARY_INTEGER;
46
47 -- This procedure accepts the rate types at the plan version level and plan type level
48 -- FALSE is returned if the rate type at plan type is not User and the rate type at
49 -- plan version is user.TRUE is returned otherwise
50 -- Created 19-FEB-03 sgoteti
51 --
52 PROCEDURE valid_rate_type
53 ( p_pt_project_cost_rate_type IN pa_proj_fp_options.project_cost_rate_type%TYPE
54 ,p_pt_project_rev_rate_type IN pa_proj_fp_options.project_rev_rate_type%TYPE
55 ,p_pt_projfunc_cost_rate_type IN pa_proj_fp_options.projfunc_cost_rate_type%TYPE
56 ,p_pt_projfunc_rev_rate_type IN pa_proj_fp_options.projfunc_rev_rate_type%TYPE
57 ,p_pv_project_cost_rate_type IN pa_proj_fp_options.project_cost_rate_type%TYPE
58 ,p_pv_project_rev_rate_type IN pa_proj_fp_options.project_rev_rate_type%TYPE
59 ,p_pv_projfunc_cost_rate_type IN pa_proj_fp_options.projfunc_cost_rate_type%TYPE
60 ,p_pv_projfunc_rev_rate_type IN pa_proj_fp_options.projfunc_rev_rate_type%TYPE
61 ,x_is_rate_type_valid OUT NOCOPY BOOLEAN --File.Sql.39 bug 4440895
62 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
63 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
64 ,x_msg_data OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
65 )
66 IS
67
68 l_debug_mode VARCHAR2(1);
69 l_module_name VARCHAR2(80);
70 l_debug_level3 CONSTANT NUMBER := 3;
71 BEGIN
72
73 x_msg_count :=0;
74 x_return_status := FND_API.G_RET_STS_SUCCESS;
75 l_debug_mode := NVL(FND_PROFILE.value('PA_DEBUG_MODE'),'N');
76 l_module_name := 'valid_rate_type: ' || g_module_name;
77
78 IF l_debug_mode = 'Y' THEN
79 pa_debug.set_curr_function( p_function => 'valid_rate_type',
80 p_debug_mode => l_debug_mode );
81 END IF;
82
83 x_is_rate_type_valid := TRUE;
84
85 IF (nvl(p_pv_project_cost_rate_type,'-99') = PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER AND
86 nvl(p_pt_project_cost_rate_type,'-99') <> PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER ) THEN
87
88 x_is_rate_type_valid := FALSE;
89
90 END IF;
91
92 IF (nvl(p_pv_project_rev_rate_type,'-99') = PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER AND
93 nvl(p_pt_project_rev_rate_type,'-99') <> PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER ) THEN
94
95 x_is_rate_type_valid := FALSE;
96
97 END IF;
98
99 IF (nvl(p_pv_projfunc_cost_rate_type,'-99') = PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER AND
100 nvl(p_pt_projfunc_cost_rate_type,'-99') <> PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER ) THEN
101
102 x_is_rate_type_valid := FALSE;
103
104 END IF;
105
106 IF (nvl(p_pv_projfunc_rev_rate_type,'-99') = PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER AND
107 nvl(p_pt_projfunc_rev_rate_type,'-99') <> PA_FP_CONSTANTS_PKG.G_RATE_TYPE_USER ) THEN
108
109 x_is_rate_type_valid := FALSE;
110
111 END IF;
112
113 IF(l_debug_mode='Y') THEN
114
115 pa_debug.g_err_stage := 'Leaving valid_rate_type';
116 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
117 pa_debug.reset_curr_function;
118 END IF;
119 EXCEPTION
120
121 WHEN OTHERS THEN
122 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
123 x_msg_count := 1;
124 x_msg_data := SQLERRM;
125
126 FND_MSG_PUB.add_exc_msg
127 ( p_pkg_name => 'PA_BUDGET_PUB'
128 ,p_procedure_name => 'VALID_RATE_TYPE'
129 ,p_error_text => sqlerrm);
130
131 IF l_debug_mode = 'Y' THEN
132 pa_debug.G_Err_Stack := SQLERRM;
133 pa_debug.write( l_module_name,pa_debug.G_Err_Stack,4);
134 pa_debug.reset_curr_function;
135 END IF;
136 RAISE;
137
138
139 END valid_rate_type;
140
141
142
143 -- This API is created as part of FinPlan Development. All header level validations are moved
144 -- from create_draft_budget API to this API. This API handles validations of versions in new
145 -- as well as old models.
146
147 -- Created 19-FEB-03 sgoteti
148
149 PROCEDURE Validate_Header_Info
150 ( p_api_version_number IN NUMBER
151 ,p_budget_version_name IN VARCHAR2 /* Introduced for bug 3133930*/
152 ,p_init_msg_list IN VARCHAR2
153 ,px_pa_project_id IN OUT NOCOPY pa_projects_all.project_id%TYPE --File.Sql.39 bug 4440895
154 ,p_pm_project_reference IN pa_projects_all.pm_project_reference%TYPE
155 ,p_pm_product_code IN pa_projects_all.pm_product_code%TYPE
156 ,p_budget_type_code IN pa_budget_types.budget_type_code%TYPE
157 ,p_entry_method_code IN pa_budget_entry_methods.budget_entry_method_code%TYPE
158 ,px_resource_list_name IN OUT NOCOPY pa_resource_lists_tl.name%TYPE --File.Sql.39 bug 4440895
159 ,px_resource_list_id IN OUT NOCOPY pa_resource_lists_all_bg.resource_list_id%TYPE --File.Sql.39 bug 4440895
160 ,px_fin_plan_type_id IN OUT NOCOPY pa_fin_plan_types_b.fin_plan_type_id%TYPE --File.Sql.39 bug 4440895
161 ,px_fin_plan_type_name IN OUT NOCOPY pa_fin_plan_types_tl.name%TYPE --File.Sql.39 bug 4440895
162 ,px_version_type IN OUT NOCOPY pa_budget_versions.version_type%TYPE --File.Sql.39 bug 4440895
163 ,px_fin_plan_level_code IN OUT NOCOPY pa_proj_fp_options.cost_fin_plan_level_code%TYPE --File.Sql.39 bug 4440895
164 ,px_time_phased_code IN OUT NOCOPY pa_proj_fp_options.cost_time_phased_code%TYPE --File.Sql.39 bug 4440895
165 ,px_plan_in_multi_curr_flag IN OUT NOCOPY pa_proj_fp_options.plan_in_multi_curr_flag%TYPE --File.Sql.39 bug 4440895
166 ,px_projfunc_cost_rate_type IN OUT NOCOPY pa_proj_fp_options.projfunc_cost_rate_type%TYPE --File.Sql.39 bug 4440895
167 ,px_projfunc_cost_rate_date_typ IN OUT NOCOPY pa_proj_fp_options.projfunc_cost_rate_date_type%TYPE --File.Sql.39 bug 4440895
168 ,px_projfunc_cost_rate_date IN OUT NOCOPY pa_proj_fp_options.projfunc_cost_rate_date%TYPE --File.Sql.39 bug 4440895
169 ,px_projfunc_rev_rate_type IN OUT NOCOPY pa_proj_fp_options.projfunc_rev_rate_type%TYPE --File.Sql.39 bug 4440895
170 ,px_projfunc_rev_rate_date_typ IN OUT NOCOPY pa_proj_fp_options.projfunc_rev_rate_date_type%TYPE --File.Sql.39 bug 4440895
171 ,px_projfunc_rev_rate_date IN OUT NOCOPY pa_proj_fp_options.projfunc_rev_rate_date%TYPE --File.Sql.39 bug 4440895
172 ,px_project_cost_rate_type IN OUT NOCOPY pa_proj_fp_options.project_cost_rate_type%TYPE --File.Sql.39 bug 4440895
173 ,px_project_cost_rate_date_typ IN OUT NOCOPY pa_proj_fp_options.project_cost_rate_date_type%TYPE --File.Sql.39 bug 4440895
174 ,px_project_cost_rate_date IN OUT NOCOPY pa_proj_fp_options.project_cost_rate_date%TYPE --File.Sql.39 bug 4440895
175 ,px_project_rev_rate_type IN OUT NOCOPY pa_proj_fp_options.project_rev_rate_type%TYPE --File.Sql.39 bug 4440895
176 ,px_project_rev_rate_date_typ IN OUT NOCOPY pa_proj_fp_options.project_rev_rate_date_type%TYPE --File.Sql.39 bug 4440895
177 ,px_project_rev_rate_date IN OUT NOCOPY pa_proj_fp_options.project_rev_rate_date%TYPE --File.Sql.39 bug 4440895
178 ,px_raw_cost_flag IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
179 ,px_burdened_cost_flag IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
180 ,px_revenue_flag IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
181 ,px_cost_qty_flag IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
182 ,px_revenue_qty_flag IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
183 ,px_all_qty_flag IN OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
184 ,p_create_new_curr_working_flag IN VARCHAR2
185 ,p_replace_current_working_flag IN VARCHAR2
186 ,p_change_reason_code IN pa_budget_versions.change_reason_code%TYPE
187 ,p_calling_module IN VARCHAR2
188 ,p_using_resource_lists_flag IN VARCHAR2
189 ,x_budget_amount_code OUT NOCOPY pa_budget_types.budget_amount_code%TYPE --Added for bug 4224464. --File.Sql.39 bug 4440895
190 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
191 ,x_msg_data OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
192 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
193 ) IS
194
195 -- Cursor to get the cost and revenue budget entry flags from the project type
196 CURSOR l_cost_rev_budget_entry_csr
197 (c_project_id pa_projects.project_id%type)
198 IS
199 SELECT ppt.allow_cost_budget_entry_flag
200 ,ppt.allow_rev_budget_entry_flag
201 FROM pa_project_types ppt
202 ,pa_projects_all ppa
203 WHERE ppa.project_id = c_project_id
204 AND ppa.project_type = ppt.project_type;
205
206 -- Cursor to get the details of the budget entry method passed
207 CURSOR l_budget_entry_method_csr
208 (c_budget_entry_method_code pa_budget_entry_methods.budget_entry_method_code%type )
209 IS
210 SELECT *
211 FROM pa_budget_entry_methods
212 WHERE budget_entry_method_code = c_budget_entry_method_code
213 AND trunc(sysdate) BETWEEN trunc(start_date_active) and trunc(nvl(end_date_active,sysdate));
214
215 l_budget_entry_method_rec pa_budget_entry_methods%rowtype;
216
217
218 l_budget_amount_code pa_budget_types.budget_amount_code%TYPE;
219
220 -- Cursor to get the plan type details of the version being created. Created as part
221 -- of changes due to fin plan in AMG
222 CURSOR l_proj_fp_options_csr
223 ( c_project_id pa_projects.project_id%TYPE
224 ,c_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE)
225 IS
226 SELECT fin_plan_preference_code
227 ,nvl(plan_in_multi_curr_flag,'N') plan_in_multi_curr_flag
228 ,approved_rev_plan_type_flag
229 ,projfunc_cost_rate_type
230 ,projfunc_cost_rate_date_type
231 ,projfunc_cost_rate_date
232 ,projfunc_rev_rate_type
233 ,projfunc_rev_rate_date_type
234 ,projfunc_rev_rate_date
235 ,project_cost_rate_type
236 ,project_cost_rate_date_type
237 ,project_cost_rate_date
238 ,project_rev_rate_type
239 ,project_rev_rate_date_type
240 ,project_rev_rate_date
241 FROM pa_proj_fp_options
242 WHERE project_id=c_project_id
243 AND fin_plan_type_id=c_fin_plan_type_id
244 AND fin_plan_version_id IS NULL
245 AND fin_plan_option_level_code= PA_FP_CONSTANTS_PKG.G_OPTION_LEVEL_PLAN_TYPE;
246
247 l_proj_fp_options_rec l_proj_fp_options_csr%ROWTYPE;
248
249 -- Cursot to get the segment 1 of the project. Added baseline funding flag as part
250 -- changes due to finplan in AMG
251 CURSOR l_amg_project_csr
252 (c_project_id pa_projects_all.project_id%TYPE)
253 IS
254 SELECT segment1
255 ,baseline_funding_flag
256 FROM pa_projects_all
257 WHERE project_id=c_project_id;
258
259 l_amg_project_rec l_amg_project_csr%ROWTYPE;
260
261 -- Cursor to get the planning level ,resource list and time phasing from the plan type
262 -- Added as part of changes due to finplan in AMG
263 CURSOR l_plan_type_settings_csr
264 ( c_project_id pa_projects.project_id%TYPE
265 ,c_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE
266 ,c_version_type VARCHAR2)
267
268 IS
269 SELECT decode(c_version_type,
270 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST, cost_fin_plan_level_code,
271 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE, revenue_fin_plan_level_code,
272 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL, all_fin_plan_level_code) fin_plan_level_code
273 ,decode(c_version_type,
274 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST, cost_resource_list_id,
275 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE, revenue_resource_list_id,
276 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL, all_resource_list_id) resource_list_id
277 ,decode(c_version_type,
278 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST, cost_time_phased_code,
279 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE, revenue_time_phased_code,
280 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL, all_time_phased_code) time_phased_code
281 FROM pa_proj_fp_options
282 WHERE project_id=c_project_id
283 AND fin_plan_type_id=c_fin_plan_type_id
284 AND fin_plan_version_id IS NULL
285 AND fin_plan_option_level_code= PA_FP_CONSTANTS_PKG.G_OPTION_LEVEL_PLAN_TYPE;
286
287 l_plan_type_settings_rec l_plan_type_settings_csr%ROWTYPE;
288
289
290
291 -- Cursor to get the existing version details of the budget type code passed
292
293 CURSOR l_budget_version_csr
294 ( c_project_id NUMBER
295 ,c_budget_type_code VARCHAR2 )
296 IS
297 SELECT budget_version_id
298 ,budget_status_code
299 FROM pa_budget_versions
300 WHERE project_id = c_project_id
301 AND budget_type_code = c_budget_type_code
302 AND budget_status_code IN ('W','S')
303 AND ci_id IS NULL; -- Bug # 3507156 --Added an extra clause ci_id IS NULL
304
305 -- Cursor to get the details of the current working version in finplan model. Added
306 -- as part of changes due to finplan in AMG
307 CURSOR l_finplan_CW_ver_csr
308 ( c_project_id NUMBER
309 ,c_fin_plan_type_id VARCHAR2
310 ,c_version_type VARCHAR2)
311 IS
312 SELECT budget_version_id
313 ,budget_status_code
314 ,record_version_number
315 ,plan_processing_code
316 FROM pa_budget_versions
317 WHERE project_id = c_project_id
318 AND fin_plan_type_id = c_fin_plan_type_id
319 AND current_working_flag='Y'
320 AND version_type = c_version_type
321 AND budget_status_code IN ('W','S')
322 AND ci_id IS NULL; -- Bug # 3507156 --Added an extra clause ci_id IS NULL
323
324
325 l_finplan_CW_ver_rec l_finplan_CW_ver_csr%ROWTYPE;
326
327 -- Cursor to know whether a version exists for plan type created by upgrading the budget type
328 -- which is given as input. Crated as part of changes due to finplan in AMG
329 CURSOR is_budget_type_upgraded_csr
330 ( c_budget_type_code pa_budget_types.budget_type_code%TYPE
331 ,c_project_id pa_projects_all.project_id%TYPE)
332 IS
333 SELECT 'X'
334 FROM pa_fin_plan_types_b fin ,pa_proj_fp_options pfo
335 WHERE pfo.project_id=c_project_id
336 AND pfo.fin_plan_option_level_code=PA_FP_CONSTANTS_PKG.G_OPTION_LEVEL_PLAN_TYPE --AMG UT2
337 AND pfo.fin_plan_type_id = fin.fin_plan_type_id
338 AND fin.migrated_frm_bdgt_typ_code = c_budget_type_code;
339
340 l_budget_type_upgraded_rec is_budget_type_upgraded_csr%ROWTYPE;
341
342 -- Cursor to lock the version
343 CURSOR l_lock_old_budget_csr( c_budget_version_id NUMBER )
344 IS
345 SELECT 'x'
346 FROM pa_budget_versions bv
347 ,pa_resource_assignments ra
348 ,pa_budget_lines bl
349 WHERE bv.budget_version_id = c_budget_version_id
350 AND bv.budget_version_id = ra.budget_version_id (+)
351 AND ra.resource_assignment_id = bl.resource_assignment_id (+)
352 AND bv.ci_id IS NULL -- Bug # 3507156 --Added an extra clause ci_id IS NULL
353
354 FOR UPDATE OF bv.budget_version_id,ra.budget_version_id,bl.resource_assignment_id NOWAIT;
355
356 -- Cursor used in validating the product code
357 Cursor p_product_code_csr (c_pm_product_code IN VARCHAR2)
358 Is
359 Select 'X'
360 from pa_lookups
361 where lookup_type='PM_PRODUCT_CODE'
362 and lookup_code = c_pm_product_code;
363
364
365 l_msg_count NUMBER := 0;
366 l_data VARCHAR2(2000);
367 l_msg_data VARCHAR2(2000);
368 l_msg_index_out NUMBER;
369 l_debug_mode VARCHAR2(1);
370 l_function_allowed VARCHAR2(1);
371 l_resp_id NUMBER := 0;
372 l_user_id NUMBER := 0;
373 l_module_name VARCHAR2(80);
374
375 -- <Patchset M:B and F impact changes : AMG:> -- Bug # 3507156
376 -- Added the variable l_editable_flag for call to procedure pa_fin_plan_utils.Check_if_plan_type_editable
377
378 l_editable_flag VARCHAR2(1);
379
380 l_copy_conv_attr boolean;
381 l_conv_attrs_to_be_validated VARCHAR2(10);
382 l_old_budget_version_id pa_budget_versions.budget_version_id%TYPE;
383 l_budget_status_code pa_budget_versions.budget_status_code%TYPE;
384 l_approved_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE;
385
386 l_allow_cost_budget_entry_flag pa_project_types_all.allow_cost_budget_entry_flag%TYPE;
387 l_allow_rev_budget_entry_flag pa_project_types_all.allow_rev_budget_entry_flag%TYPE;
388
389 -- Budget Integration Variables --------------------------
390 l_fck_req_flag VARCHAR2(1) := NULL;
391 l_bdgt_intg_flag VARCHAR2(1) := NULL;
392 l_bdgt_ver_id NUMBER := NULL;
393 l_encum_type_id NUMBER := NULL;
394 l_balance_type VARCHAR2(1) := NULL;
395
396 -- --------------------------------------------------------
397 l_uncategorized_list_id pa_resource_lists_all_bg.resource_list_id%TYPE;
398 l_uncategorized_resid pa_resource_list_members.resource_id%TYPE;
399 l_err_code NUMBER;
400 l_err_stage VARCHAR2(120);
401 l_err_stack VARCHAR2(630);
402 l_track_as_labor_flag pa_resource_list_members.track_as_labor_flag%TYPE;
403 l_period_type VARCHAR2(2);
404 l_period_profile_id pa_proj_period_profiles.period_profile_id%TYPE;
405 l_start_period pa_proj_period_profiles.period_name1%TYPE;
406 l_end_period pa_proj_period_profiles.profile_end_period_name%TYPE;
407 l_security_ret_code VARCHAR2(1);
408 l_dummy VARCHAR2(1);
409 l_debug_level2 CONSTANT NUMBER := 2;
410 l_debug_level3 CONSTANT NUMBER := 3;
411 l_debug_level4 CONSTANT NUMBER := 4;
412 l_debug_level5 CONSTANT NUMBER := 5;
413 l_pm_product_code VARCHAR2(2) :='Z';
414
415 -- Following variable will be set when atleast one error
416 -- is reported while validating the input parameters
417 -- passed by the user
418 l_any_error_occurred_flag VARCHAR2(1) :='N';
419
420 l_multi_currency_billing_flag pa_projects_all.multi_currency_billing_flag%TYPE;
421 l_project_currency_code pa_projects_all.project_currency_code%TYPE ;
422 l_projfunc_currency_code pa_projects_all.projfunc_currency_code%TYPE ;
423 l_project_cost_rate_type pa_projects_all.project_rate_type%TYPE ;
424 l_projfunc_cost_rate_type pa_projects_all.projfunc_cost_rate_type%TYPE ;
425 l_project_bil_rate_type pa_projects_all.project_bil_rate_type%TYPE ;
426 l_projfunc_bil_rate_type pa_projects_all.projfunc_bil_rate_type%TYPE ;
427 l_uncategorized_rlmid pa_resource_list_members.resource_list_member_id%TYPE;
428 l_is_rate_type_valid BOOLEAN;
429 l_planning_level_lookup CONSTANT VARCHAR2(30) := 'BUDGET ENTRY LEVEL';
430 l_time_phasing_lookup CONSTANT VARCHAR2(30) := 'BUDGET TIME PHASED TYPE';
431 l_validate_mc_attributes VARCHAR2(1);
432 l_project_cost_exchange_rate pa_budget_lines.project_cost_exchange_rate%TYPE;
433 l_projfunc_cost_exchange_rate pa_budget_lines.projfunc_cost_exchange_rate%TYPE;
434 l_project_rev_exchange_rate pa_budget_lines.project_rev_exchange_rate%TYPE;
435 l_projfunc_rev_exchange_rate pa_budget_lines.projfunc_rev_exchange_rate%TYPE;
436 l_fin_plan_type_name pa_fin_plan_types_tl.name%TYPE;
437 l_context_info pa_fin_plan_types_tl.name%TYPE;
438
439 l_called_from_agr_pub VARCHAR2(1) := NULL; -- Bug 3099706
440
441 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
442 --Added extra parameters
443 l_autobaseline_flag VARCHAR2(1) := NULL;
444 l_workplan_flag VARCHAR2(1) := NULL;
445 l_exists VARCHAR2(1) := NULL;
446
447 -- for bug 3954329
448 l_res_list_migration_code pa_resource_list_members.migration_code%TYPE := FND_API.G_MISS_CHAR;
449 l_targ_request_id pa_budget_versions.request_id%TYPE;
450 px_pa_project_id_in pa_projects_all.project_id%TYPE;
451 px_resource_list_id_in pa_resource_lists_all_bg.resource_list_id%TYPE;
452 px_fin_plan_type_id_in pa_fin_plan_types_b.fin_plan_type_id%TYPE;
453
454 BEGIN
455
456 --dbms_output.put_line('In validate header info');
457 x_msg_count :=0;
458 x_return_status := FND_API.G_RET_STS_SUCCESS;
459 l_debug_mode := NVL(FND_PROFILE.value('PA_DEBUG_MODE'),'N');
460 l_module_name := 'validate_header_info: ' || g_module_name;
461
462 IF l_debug_mode = 'Y' THEN
463 pa_debug.set_curr_function( p_function => 'validate_header_info',
464 p_debug_mode => l_debug_mode );
465 pa_debug.g_err_stage:= 'Validating input parameters';
466 pa_debug.write(l_module_name,pa_debug.g_err_stage,
467 l_debug_level3);
468 END IF;
469 --dbms_output.put_line('About to validate budget type code and fin plan type id');
470
471 -- Initialize the message table if requested.Moved this above as the messages will be added from
472 -- this point.
473 IF FND_API.TO_BOOLEAN( p_init_msg_list )
474 THEN
475
476 FND_MSG_PUB.initialize;
477
478 END IF;
479
480
481
482 -- Both Budget Type Code and Fin Plan Type Id should not be null
483 IF ((p_budget_type_code IS NULL OR
484 p_budget_type_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR ) AND
485 (px_fin_plan_type_name IS NULL) AND
486 (px_fin_plan_type_id IS NULL) )THEN
487
488 PA_UTILS.ADD_MESSAGE
489 (p_app_short_name => 'PA',
490 p_msg_name => 'PA_BUDGET_FP_BOTH_MISSING');
491
492 IF l_debug_mode = 'Y' THEN
493 pa_debug.g_err_stage:= 'Fin Plan type info and budget type info are missing';
494 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
495 END IF;
496
497 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
498
499 END IF;
500
501 -- Both Budget Type Code and Fin Plan Type Id should not be not null
502
503 IF ((p_budget_type_code IS NOT NULL AND
504 p_budget_type_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) AND
505 ((px_fin_plan_type_name IS NOT NULL) OR
506 (px_fin_plan_type_id IS NOT NULL))) THEN
507
508 PA_UTILS.ADD_MESSAGE
509 (p_app_short_name => 'PA',
510 p_msg_name => 'PA_BUDGET_FP_BOTH_NOT_NULL');
511
512 IF l_debug_mode = 'Y' THEN
513 pa_debug.g_err_stage:= 'Fin Plan type info and budget type info both are provided';
514 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
515 END IF;
516
517 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
518
519 END IF;
520
521 --dbms_output.put_line('After validating budget and finplan ids');
522
523 --product_code is mandatory
524 IF p_pm_product_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
525 OR p_pm_product_code IS NULL
526 THEN
527 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
528 THEN
529 pa_interface_utils_pub.map_new_amg_msg
530 ( p_old_message_code => 'PA_PRODUCT_CODE_IS_MISSING'
531 ,p_msg_attribute => 'CHANGE'
532 ,p_resize_flag => 'N'
533 ,p_msg_context => 'GENERAL'
534 ,p_attribute1 => ''
535 ,p_attribute2 => ''
536 ,p_attribute3 => ''
537 ,p_attribute4 => ''
538 ,p_attribute5 => '');
539 --dbms_output.put_line('MSG count in the stack ' || FND_MSG_PUB.count_msg);
540 --dbms_output.put_line('added msg to stack');
541 --dbms_output.put_line('MSG count in the stack 2 ' || FND_MSG_PUB.count_msg);
542 IF l_debug_mode = 'Y' THEN
543 pa_debug.g_err_stage:= 'PM Product code is missing';
544 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
545 END IF;
546
547 END IF;
548 x_return_status := FND_API.G_RET_STS_ERROR;
549 l_any_error_occurred_flag := 'Y';
550
551
552 --dbms_output.put_line('pm product code is null or miss');
553
554
555 -- RAISE FND_API.G_EXC_ERROR;
556 ELSE
557
558 -- added for bug no :2413400
559 OPEN p_product_code_csr (p_pm_product_code);
560 FETCH p_product_code_csr INTO l_pm_product_code;
561 CLOSE p_product_code_csr;
562 IF l_pm_product_code <> 'X'
563 THEN
564 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
565 THEN
566 pa_interface_utils_pub.map_new_amg_msg
567 ( p_old_message_code => 'PA_PRODUCT_CODE_IS_INVALID'
568 ,p_msg_attribute => 'CHANGE'
569 ,p_resize_flag => 'N'
570 ,p_msg_context => 'GENERAL'
571 ,p_attribute1 => ''
572 ,p_attribute2 => ''
573 ,p_attribute3 => ''
574 ,p_attribute4 => ''
575 ,p_attribute5 => '');
576 END IF;
577 IF l_debug_mode = 'Y' THEN
578 pa_debug.g_err_stage:= 'PM Product code is invalid';
579 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
580 END IF;
581
582 x_return_status := FND_API.G_RET_STS_ERROR;
583 l_any_error_occurred_flag := 'Y';
584 -- RAISE FND_API.G_EXC_ERROR;
585 END IF;
586
587 --dbms_output.put_line('pm product code is not valid '||l_pm_product_code);
588 END IF;-- p_pm_product_code IS NULL
589
590 l_resp_id := FND_GLOBAL.Resp_id;
591 l_user_id := FND_GLOBAL.User_id;
592
593 -- l_module_name := p_pm_product_code||'.'||'PA_PM_CREATE_DRAFT_BUDGET';
594
595 /* Replaced the security checks with a call to single api
596
597 -- As part of enforcing project security, which would determine
598 -- whether the user has the necessary privileges to update the project
599 -- If a user does not have privileges to update the project, then
600 -- cannot create a budget
601 -- need to call the pa_security package
602
603 pa_security.initialize (X_user_id => l_user_id,
604 X_calling_module => l_module_name);
605 */
606
607 -- Actions performed using the APIs would be subject to
608 -- function security. If the responsibility does not allow
609 -- such functions to be executed, the API should not proceed further
610 -- since the user does not have access to such functions
611
612
613
614 /*
615 PA_PM_FUNCTION_SECURITY_PUB.check_function_security
616 (p_api_version_number => p_api_version_number,
617 p_responsibility_id => l_resp_id,
618 p_function_name => 'PA_PM_CREATE_DRAFT_BUDGET',
619 p_msg_count => l_msg_count,
620 p_msg_data => l_msg_data,
621 p_return_status => x_return_status,
622 p_function_allowed => l_function_allowed );
623
624 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
625 THEN
626 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
627 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
628 THEN
629 RAISE FND_API.G_EXC_ERROR;
630 END IF;
631
632 IF l_function_allowed = 'N' THEN
633 pa_interface_utils_pub.map_new_amg_msg
634 ( p_old_message_code => 'PA_FUNCTION_SECURITY_ENFORCED'
635 ,p_msg_attribute => 'CHANGE'
636 ,p_resize_flag => 'Y'
637 ,p_msg_context => 'GENERAL'
638 ,p_attribute1 => ''
639 ,p_attribute2 => ''
640 ,p_attribute3 => ''
641 ,p_attribute4 => ''
642 ,p_attribute5 => '');
643 x_return_status := FND_API.G_RET_STS_ERROR;
644 -- RAISE FND_API.G_EXC_ERROR;
645 END IF;
646 */
647
648 -- CHECK FOR MANDATORY FIELDS and CONVERT VALUES to ID's
649 -- convert pm_project_reference to id
650
651 px_pa_project_id_in := px_pa_project_id;
652
653 Pa_project_pvt.Convert_pm_projref_to_id (
654 p_pm_project_reference => p_pm_project_reference,
655 p_pa_project_id => px_pa_project_id_in,
656 p_out_project_id => px_pa_project_id,
657 p_return_status => x_return_status );
658
659 --dbms_output.put_line('x_return_status is '|| x_return_status);
660 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
661 THEN
662 --dbms_output.put_line('unexpected error while deriving project id '|| px_pa_project_id);
663 --dbms_output.put_line('expected error while deriving l project id '||px_pa_project_id );
664 IF l_debug_mode = 'Y' THEN
665 pa_debug.g_err_stage:= 'Unexpected error while deriving project id';
666 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
667 END IF;
668 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
669
670 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
671 THEN
672 --dbms_output.put_line('expected error while deriving px project id '||px_pa_project_id );
673 --dbms_output.put_line('expected error while deriving l project id '||px_pa_project_id );
674 IF l_debug_mode = 'Y' THEN
675 pa_debug.g_err_stage:= 'Error while deriving project id';
676 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
677 END IF;
678
679 --RAISE FND_API.G_EXC_ERROR; --AMG UT2
680 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
681
682 END IF;
683
684 PA_INTERFACE_UTILS_PUB.G_PROJECT_ID := px_pa_project_id;
685
686 -- Now verify whether project security allows the user to update
687 -- the project
688 -- If a user does not have privileges to update the project, then
689 -- cannot create a budget
690
691 /* dbms_output.put_line('Before project security'); */
692
693 /*
694 IF pa_security.allow_query (x_project_id => px_pa_project_id ) = 'N' THEN
695
696 -- The user does not have query privileges on this project
697 -- Hence, cannot create a draft budget.Raise error
698
699 pa_interface_utils_pub.map_new_amg_msg
700 ( p_old_message_code => 'PA_PROJECT_SECURITY_ENFORCED'
701 ,p_msg_attribute => 'CHANGE'
702 ,p_resize_flag => 'Y'
703 ,p_msg_context => 'GENERAL'
704 ,p_attribute1 => ''
705 ,p_attribute2 => ''
706 ,p_attribute3 => ''
707 ,p_attribute4 => ''
708 ,p_attribute5 => '');
709 x_return_status := FND_API.G_RET_STS_ERROR;
710 -- RAISE FND_API.G_EXC_ERROR;
711 ELSE
712 -- If the user has query privileges, then check whether
713 -- update privileges are also available
714 IF pa_security.allow_update (x_project_id => px_pa_project_id ) = 'N' THEN
715
716 -- The user does not have update privileges on this project
717 -- Hence , raise error
718
719 pa_interface_utils_pub.map_new_amg_msg
720 ( p_old_message_code => 'PA_PROJECT_SECURITY_ENFORCED'
721 ,p_msg_attribute => 'CHANGE'
722 ,p_resize_flag => 'Y'
723 ,p_msg_context => 'GENERAL'
724 ,p_attribute1 => ''
725 ,p_attribute2 => ''
726 ,p_attribute3 => ''
727 ,p_attribute4 => ''
728 ,p_attribute5 => '');
729 x_return_status := FND_API.G_RET_STS_ERROR;
730 -- RAISE FND_API.G_EXC_ERROR;
731 END IF;
732 END IF;
733 */
734
735
736 -- Get the segment 1 of the project so that it can be used in the
737 -- later part of the code
738 OPEN l_amg_project_csr( px_pa_project_id );
739 FETCH l_amg_project_csr INTO l_amg_project_rec;
740 CLOSE l_amg_project_csr;
741
742 -- Get the cost and rev budget entry flags so that they can be
743 -- used in budget and finplan models
744 OPEN l_cost_rev_budget_entry_csr(px_pa_project_id);
745 FETCH l_cost_rev_budget_entry_csr
746 INTO l_allow_cost_budget_entry_flag,
747 l_allow_rev_budget_entry_flag ;
748 CLOSE l_cost_rev_budget_entry_csr;
749
750 --dbms_output.put_line('Starting the budget type validations');
751
752 -- Do the validations required for the budget model
753 IF (p_budget_type_code IS NOT NULL AND
754 p_budget_type_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
755
756 --dbms_output.put_line('About to call the security api');
757 --Check for the security
758 PA_PM_FUNCTION_SECURITY_PUB.CHECK_BUDGET_SECURITY (
759 p_api_version_number => p_api_version_number
760 ,p_project_id => px_pa_project_id
761 ,p_calling_context => PA_FP_CONSTANTS_PKG.G_CALLING_MODULE_BUDGET
762 ,p_function_name => p_calling_module
763 ,p_version_type => null
764 ,x_return_status => x_return_status
765 ,x_ret_code => l_security_ret_code );
766
767 -- the above API adds the error message to stack. Hence the message is not added here.
768 -- Also, as security check is important further validations are not done in case this
769 -- validation fails.
770 IF (x_return_status<>FND_API.G_RET_STS_SUCCESS OR
771 l_security_ret_code = 'N') THEN
772 --dbms_output.put_line('Security api failed l_security_ret_code '||l_security_ret_code);
773 IF l_debug_mode = 'Y' THEN
774 pa_debug.g_err_stage:= 'Security API Failed';
775 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
776 END IF;
777
778 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
779 END IF;
780
781 --dbms_output.put_line('About to validate the budget type');
782 -- Get the budget amount code. Check whether the project type allows the
783 -- creation of plan versions with obtained budget amounT code.
784 OPEN l_budget_amount_code_csr( p_budget_type_code );
785 FETCH l_budget_amount_code_csr
786 INTO l_budget_amount_code; --will be used later on during validation of Budget lines.
787
788 x_budget_amount_code := l_budget_amount_code; -- Added for bug 4224464
789
790 IF l_budget_amount_code_csr%NOTFOUND
791 THEN
792 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
793 THEN
794 pa_interface_utils_pub.map_new_amg_msg
795 ( p_old_message_code => 'PA_BUDGET_TYPE_IS_INVALID'
796 ,p_msg_attribute => 'CHANGE'
797 ,p_resize_flag => 'N'
798 ,p_msg_context => 'BUDG'
799 ,p_attribute1 => l_amg_project_rec.segment1
800 ,p_attribute2 => ''
801 ,p_attribute3 => p_budget_type_code
802 ,p_attribute4 => ''
803 ,p_attribute5 => '');
804
805 IF l_debug_mode = 'Y' THEN
806 pa_debug.g_err_stage:= 'Budget type is invalid';
807 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
808 END IF;
809
810 END IF;
811 x_return_status := FND_API.G_RET_STS_ERROR;
812 l_any_error_occurred_flag := 'Y';
813
814 CLOSE l_budget_amount_code_csr;
815 -- RAISE FND_API.G_EXC_ERROR;
816
817 ELSE
818
819 CLOSE l_budget_amount_code_csr;
820
821
822 IF l_budget_amount_code = PA_FP_CONSTANTS_PKG.G_BUDGET_AMOUNT_CODE_C THEN
823
824 IF NVL(l_allow_cost_budget_entry_flag,'N') = 'N' THEN
825 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
826 THEN
827 PA_UTILS.ADD_MESSAGE
828 (p_app_short_name => 'PA',
829 p_msg_name => 'PA_COST_BUDGET_NOT_ALLOWED',
830 p_token1 => 'PROJECT',
831 p_value1 => l_amg_project_rec.segment1,
832 p_token2 => 'BUDGET_TYPE',
833 p_value2 => p_budget_type_code );
834 IF l_debug_mode = 'Y' THEN
835 pa_debug.g_err_stage:= 'Creation of cost version is not allowed';
836 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
837 END IF;
838 END IF;
839 x_return_status := FND_API.G_RET_STS_ERROR;
840 l_any_error_occurred_flag := 'Y';
841
842 -- RAISE FND_API.G_EXC_ERROR;
843 END IF;
844
845 ELSIF l_budget_amount_code = PA_FP_CONSTANTS_PKG.G_BUDGET_AMOUNT_CODE_R THEN
846
847 IF NVL(l_allow_rev_budget_entry_flag,'N') = 'N' THEN
848 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
849 THEN
850 PA_UTILS.ADD_MESSAGE
851 (p_app_short_name => 'PA',
852 p_msg_name => 'PA_REV_BUDGET_NOT_ALLOWED',
853 p_token1 => 'PROJECT',
854 p_value1 => l_amg_project_rec.segment1,
855 p_token2 => 'BUDGET_TYPE',
856 p_value2 => p_budget_type_code );
857 IF l_debug_mode = 'Y' THEN
858 pa_debug.g_err_stage:= 'Creation of rev version is not allowed';
859 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
860 END IF;
861 END IF;
862 x_return_status := FND_API.G_RET_STS_ERROR;
863 l_any_error_occurred_flag := 'Y';
864
865 -- RAISE FND_API.G_EXC_ERROR;
866 END IF;
867
868 END IF; --End of l_budget_amount_code = PA_FP_CONSTANTS_PKG.G_BUDGET_AMOUNT_CODE_C
869
870 END IF; --End of l_budget_amount_code_csr%NOTFOUND
871
872 --Added this for bug#4460139
873 --Verify that the budget is not of type FORECASTING_BUDGET_TYPE
874 IF p_budget_type_code='FORECASTING_BUDGET_TYPE' THEN
875 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
876 THEN
877 PA_UTILS.add_message
878 (p_app_short_name => 'PA',
879 p_msg_name => 'PA_FP_CANT_EDIT_FCST_BUD_TYPE');
880 END IF;
881 IF l_debug_mode = 'Y' THEN
882 pa_debug.g_err_stage := 'Budget of type FORECASTING_BUDGET_TYPE' ;
883 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
884 END IF;
885 x_return_status := FND_API.G_RET_STS_ERROR;
886 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
887 END IF;
888
889 -- Budget Integration Validation ---------------------------------------
890
891 --dbms_output.put_line('About to call get_bdget_ctrl_options');
892
893 PA_BUDGET_FUND_PKG.get_budget_ctrl_options (p_project_Id => px_pa_project_id
894 , p_budget_type_code => p_budget_type_code
895 , p_calling_mode => 'BUDGET'
896 , x_fck_req_flag => l_fck_req_flag
897 , x_bdgt_intg_flag => l_bdgt_intg_flag
898 , x_bdgt_ver_id => l_bdgt_ver_id
899 , x_encum_type_id => l_encum_type_id
900 , x_balance_type => l_balance_type
901 , x_return_status => x_return_status
902 , x_msg_data => x_msg_data
903 , x_msg_count => x_msg_count
904 );
905
906 -- calling api above adds the error message to stack hence not adding the error message here.
907 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
908 THEN
909
910 IF l_debug_mode = 'Y' THEN
911 pa_debug.g_err_stage:= 'get_budget_ctrl_options returned unexp error';
912 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
913 END IF;
914
915 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
916
917 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
918 THEN
919 -- RAISE FND_API.G_EXC_ERROR;
920 IF l_debug_mode = 'Y' THEN
921 pa_debug.g_err_stage:= 'get_budget_ctrl_options returned error';
922 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
923 END IF;
924
925 l_any_error_occurred_flag := 'Y';
926 END IF;
927
928 IF (nvl(l_fck_req_flag,'N') = 'Y')
929 THEN
930 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
931 THEN
932 pa_interface_utils_pub.map_new_amg_msg
933 ( p_old_message_code => 'PA_BC_BGT_TYPE_IS_BAD_AMG'
934 ,p_msg_attribute => 'CHANGE'
935 ,p_resize_flag => 'N'
936 ,p_msg_context => 'BUDG'
937 ,p_attribute1 => l_amg_project_rec.segment1
938 ,p_attribute2 => ''
939 ,p_attribute3 => p_budget_type_code
940 ,p_attribute4 => ''
941 ,p_attribute5 => '');
942 END IF;
943 x_return_status := FND_API.G_RET_STS_ERROR;
944 l_any_error_occurred_flag := 'Y';
945
946 -- RAISE FND_API.G_EXC_ERROR;
947 END IF;
948
949 -- ----------------------------------------------------------------------
950
951 -- entry method code is mandatory
952
953 IF p_entry_method_code IS NULL
954 OR p_entry_method_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
955 THEN
956
957 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
958 THEN
959 pa_interface_utils_pub.map_new_amg_msg
960 ( p_old_message_code => 'PA_ENTRY_METHOD_IS_MISSING'
961 ,p_msg_attribute => 'CHANGE'
962 ,p_resize_flag => 'N'
963 ,p_msg_context => 'BUDG'
964 ,p_attribute1 => l_amg_project_rec.segment1
965 ,p_attribute2 => ''
966 ,p_attribute3 => p_budget_type_code
967 ,p_attribute4 => ''
968 ,p_attribute5 => '');
969
970 IF l_debug_mode = 'Y' THEN
971 pa_debug.g_err_stage:= 'Budget entry method is missing';
972 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
973 END IF;
974 END IF;
975 x_return_status := FND_API.G_RET_STS_ERROR;
976 l_any_error_occurred_flag := 'Y';
977
978 -- RAISE FND_API.G_EXC_ERROR;
979 ELSE -- entry method is not null
980
981 -- check validity of this budget entry method code, and store associated fields in record
982
983 OPEN l_budget_entry_method_csr(p_entry_method_code);
984 FETCH l_budget_entry_method_csr INTO l_budget_entry_method_rec;
985
986 IF l_budget_entry_method_csr%NOTFOUND
987 THEN
988
989 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
990 THEN
991 pa_interface_utils_pub.map_new_amg_msg
992 ( p_old_message_code => 'PA_ENTRY_METHOD_IS_INVALID'
993 ,p_msg_attribute => 'CHANGE'
994 ,p_resize_flag => 'N'
995 ,p_msg_context => 'BUDG'
996 ,p_attribute1 => l_amg_project_rec.segment1
997 ,p_attribute2 => ''
998 ,p_attribute3 => p_budget_type_code
999 ,p_attribute4 => ''
1000 ,p_attribute5 => '');
1001 IF l_debug_mode = 'Y' THEN
1002 pa_debug.g_err_stage:= 'Budget entry method is invlaid';
1003 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1004 END IF;
1005 END IF;
1006 x_return_status := FND_API.G_RET_STS_ERROR;
1007 l_any_error_occurred_flag := 'Y';
1008
1009 CLOSE l_budget_entry_method_csr;
1010 -- RAISE FND_API.G_EXC_ERROR;
1011
1012 ELSE
1013
1014 CLOSE l_budget_entry_method_csr;
1015
1016 IF l_budget_entry_method_rec.categorization_code = 'N' THEN
1017
1018 pa_get_resource.Get_Uncateg_Resource_Info
1019 (p_resource_list_id => l_uncategorized_list_id,
1020 p_resource_list_member_id => l_uncategorized_rlmid,
1021 p_resource_id => l_uncategorized_resid,
1022 p_track_as_labor_flag => l_track_as_labor_flag,
1023 p_err_code => l_err_code,
1024 p_err_stage => l_err_stage,
1025 p_err_stack => l_err_stack );
1026
1027 IF l_err_code <> 0 THEN
1028 IF NOT pa_project_pvt.check_valid_message(l_err_stage) THEN
1029 pa_interface_utils_pub.map_new_amg_msg
1030 ( p_old_message_code => 'PA_NO_UNCATEGORIZED_LIST'
1031 ,p_msg_attribute => 'CHANGE'
1032 ,p_resize_flag => 'N'
1033 ,p_msg_context => 'BUDG'
1034 ,p_attribute1 => l_amg_project_rec.segment1
1035 ,p_attribute2 => ''
1036 ,p_attribute3 => p_budget_type_code
1037 ,p_attribute4 => ''
1038 ,p_attribute5 => '');
1039
1040 IF l_debug_mode = 'Y' THEN
1041 pa_debug.g_err_stage:= 'Uncategorized res list is missing';
1042 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1043 END IF;
1044 ELSE
1045 pa_interface_utils_pub.map_new_amg_msg
1046 ( p_old_message_code => l_err_stage
1047 ,p_msg_attribute => 'CHANGE'
1048 ,p_resize_flag => 'N'
1049 ,p_msg_context => 'BUDG'
1050 ,p_attribute1 => l_amg_project_rec.segment1
1051 ,p_attribute2 => ''
1052 ,p_attribute3 => p_budget_type_code
1053 ,p_attribute4 => ''
1054 ,p_attribute5 => '');
1055 IF l_debug_mode = 'Y' THEN
1056 pa_debug.g_err_stage:= 'Unexp error while deriving uncat res list';
1057 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1058 END IF;
1059 END IF;
1060
1061 ELSE
1062
1063 px_resource_list_id := l_uncategorized_list_id;
1064
1065 -- RAISE FND_API.G_EXC_ERROR;
1066 END IF; -- IF l_err_code <> 0 THEN
1067
1068
1069 ELSIF l_budget_entry_method_rec.categorization_code = 'R' THEN
1070 IF (px_resource_list_name <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
1071 AND px_resource_list_name IS NOT NULL)
1072 OR (px_resource_list_id <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
1073 AND px_resource_list_id IS NOT NULL) THEN
1074 -- convert resource_list_name to resource_list_id
1075 px_resource_list_id_in := px_resource_list_id;
1076 pa_resource_pub.Convert_List_name_to_id
1077 ( p_resource_list_name => px_resource_list_name,
1078 p_resource_list_id => px_resource_list_id_in,
1079 p_out_resource_list_id => px_resource_list_id,
1080 p_return_status => x_return_status );
1081
1082 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
1083 x_return_status := x_return_status;
1084 --dbms_output.put_line('Unexp error as Resource list id not derived properly');
1085 IF l_debug_mode = 'Y' THEN
1086 pa_debug.g_err_stage:= 'Unexp error while deriving res list';
1087 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1088 END IF;
1089
1090 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1091
1092 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
1093 x_return_status := x_return_status;
1094 -- RAISE FND_API.G_EXC_ERROR;
1095 PA_UTILS.ADD_MESSAGE
1096 (p_app_short_name => 'PA',
1097 p_msg_name => 'PA_FP_INVALID_RESOURCE_LIST',
1098 p_token1 => 'PROJECT',
1099 p_value1 => l_amg_project_rec.segment1);
1100 x_return_status := FND_API.G_RET_STS_ERROR;
1101 --dbms_output.put_line('exp error as Resource list id not derived properly');
1102 l_any_error_occurred_flag := 'Y';
1103 IF l_debug_mode = 'Y' THEN
1104 pa_debug.g_err_stage:= 'error while deriving uncat res list';
1105 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1106 END IF;
1107
1108 END IF;
1109
1110 /* changes for bug 3954329: following check included */
1111 BEGIN
1112 SELECT migration_code
1113 INTO l_res_list_migration_code
1114 FROM pa_resource_lists_all_bg
1115 WHERE resource_list_id = px_resource_list_id;
1116 EXCEPTION
1117 WHEN NO_DATA_FOUND THEN
1118 x_return_status := FND_API.G_RET_STS_ERROR;
1119 PA_UTILS.ADD_MESSAGE
1120 (p_app_short_name => 'PA',
1121 p_msg_name => 'PA_FP_INVALID_RESOURCE_LIST',
1122 p_token1 => 'PROJECT',
1123 p_value1 => l_amg_project_rec.segment1);
1124 x_return_status := FND_API.G_RET_STS_ERROR;
1125
1126 l_any_error_occurred_flag := 'Y';
1127 IF l_debug_mode = 'Y' THEN
1128 pa_debug.g_err_stage:= 'error while deriving uncat res list';
1129 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1130 END IF;
1131 END;
1132 IF l_res_list_migration_code = 'N' THEN
1133 x_return_status := FND_API.G_RET_STS_ERROR;
1134 l_any_error_occurred_flag := 'Y';
1135 PA_UTILS.ADD_MESSAGE
1136 (p_app_short_name => 'PA',
1137 p_msg_name => 'PA_FP_NEW_RES_LIST_OLD_MODEL');
1138 IF l_debug_mode = 'Y' THEN
1139 pa_debug.g_err_stage:= 'res list is new in old budget model';
1140 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1141 END IF;
1142 END IF;
1143 /* bug 3954329 ends */
1144 ELSE -- There is no valid resource list id
1145 x_return_status := FND_API.G_RET_STS_ERROR; --AMG UT2
1146 l_any_error_occurred_flag := 'Y';
1147
1148 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1149 pa_interface_utils_pub.map_new_amg_msg
1150 ( p_old_message_code => 'PA_RESOURCE_LIST_IS_MISSING'
1151 ,p_msg_attribute => 'CHANGE'
1152 ,p_resize_flag => 'Y'
1153 ,p_msg_context => 'BUDG'
1154 ,p_attribute1 => l_amg_project_rec.segment1
1155 ,p_attribute2 => ''
1156 ,p_attribute3 => p_budget_type_code
1157 ,p_attribute4 => ''
1158 ,p_attribute5 => '');
1159 END IF;
1160 IF l_debug_mode = 'Y' THEN
1161 pa_debug.g_err_stage:= 'res list is missing';
1162 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1163 END IF;
1164
1165 -- RAISE FND_API.G_EXC_ERROR;
1166 END IF;
1167 END IF ; -- If l_budget_entry_method_rec.categorization_code = 'N
1168 END IF;--l_budget_entry_method_csr%NOTFOUND
1169 END IF;--p_entry_method_code IS NULL
1170
1171 -- If autobaselining is enabled for the project and If the budget type code is 'AR' then the
1172 -- version can not be created thru AMG
1173
1174 l_called_from_agr_pub := PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB; -- Bug # 3099706
1175
1176 IF (nvl(PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB,'N') = 'Y') THEN
1177 PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB := 'N'; -- reset the value bug 3099706
1178 END IF;
1179
1180 IF ( (NVL(l_amg_project_rec.baseline_funding_flag,'N')='Y')
1181 AND (p_budget_type_code = PA_FP_CONSTANTS_PKG.G_BUDGET_TYPE_CODE_AR)
1182 AND (NVL(l_called_from_agr_pub,'N') = 'N')) THEN -- Bug 3099706
1183
1184 -- Added the param p_called_from_baseline to skip the autobaseline validation if
1185 -- the create_draft_budget API is called to create a draft budget while creating
1186 -- a baselined budget. If this API is called to create a draft version directly,
1187 -- this check should be done. In this case, the param p_called_from_baseline
1188 -- is defaulted to 'N' (for bug # 3099706)
1189
1190 IF l_debug_mode = 'Y' THEN
1191 pa_debug.g_err_stage := 'Auto base line error' ;
1192 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1193 END IF;
1194
1195 PA_UTILS.ADD_MESSAGE
1196 (p_app_short_name => 'PA',
1197 p_msg_name => 'PA_FP_AUTO_BASELINE_ENABLED',
1198 p_token1 => 'PROJECT',
1199 p_value1 => l_amg_project_rec.segment1);
1200 x_return_status := FND_API.G_RET_STS_ERROR;
1201 l_any_error_occurred_flag := 'Y';
1202
1203 --RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1204 --dbms_output.put_line('Autobaseline error');
1205
1206 END IF;
1207
1208 -- A version can not be created for a budget type that is already
1209 -- upgraded.
1210 OPEN is_budget_type_upgraded_csr( p_budget_type_code
1211 ,px_pa_project_id);
1212 FETCH is_budget_type_upgraded_csr INTO l_budget_type_upgraded_rec;
1213 IF (is_budget_type_upgraded_csr%FOUND) THEN
1214
1215 CLOSE is_budget_type_upgraded_csr;
1216
1217 PA_UTILS.ADD_MESSAGE
1218 (p_app_short_name => 'PA',
1219 p_msg_name => 'PA_FP_BUDGET_TYPE_UPGRADED');
1220
1221 x_return_status := FND_API.G_RET_STS_ERROR;
1222 l_any_error_occurred_flag := 'Y';
1223 --dbms_output.put_line('Budget type upgraded error');
1224 IF l_debug_mode = 'Y' THEN
1225 pa_debug.g_err_stage:= 'Budget type is already upgraded';
1226 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1227 END IF;
1228
1229
1230 ELSE
1231
1232 CLOSE is_budget_type_upgraded_csr;
1233
1234 END IF;
1235
1236 -- If an Approved Cost plan version exists for the project in new model then a budget version
1237 -- for budget type 'AC' can not be created for that project.
1238 IF (p_budget_type_code = PA_FP_CONSTANTS_PKG.G_BUDGET_TYPE_CODE_AC) THEN
1239
1240 -- Call the utility function that gives the id of the approved cost plan type, if exists,
1241 -- that is added to the project
1242 pa_fin_plan_utils.Get_Appr_Cost_Plan_Type_Info(
1243 p_project_id => px_pa_project_id
1244 ,x_plan_type_id => l_approved_fin_plan_type_id
1245 ,x_return_status => x_return_status
1246 ,x_msg_count => x_msg_count
1247 ,x_msg_data => x_msg_data);
1248
1249 -- Throw the error if the above API is not successfully executed
1250 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1251
1252 IF l_debug_mode = 'Y' THEN
1253 pa_debug.g_err_stage := 'Get_Appr_Cost_Plan_Type_Info API returned error' ;
1254 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
1255 END IF;
1256 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1257
1258 -- The Get_Appr_Cost_Plan_Type_Info api got executed successfully.Approved cost version
1259 -- is already added to the project
1260 ELSIF (l_approved_fin_plan_type_id IS NOT NULL) THEN
1261
1262 IF l_debug_mode = 'Y' THEN
1263 pa_debug.g_err_stage := 'Approved cost plan version is already added ' ;
1264 pa_debug.write(l_module_name,pa_debug.g_err_stage, l_debug_level3);
1265 END IF;
1266
1267 PA_UTILS.ADD_MESSAGE
1268 (p_app_short_name => 'PA',
1269 p_msg_name => 'PA_FP_AC_PLAN_TYPE_EXISTS');
1270
1271 x_return_status := FND_API.G_RET_STS_ERROR;
1272 l_any_error_occurred_flag := 'Y';
1273
1274 END IF; --IF x_return_status <> FND_API.G_RET_STS_SUCCESS
1275
1276 END IF; --IF (p_budget_type_code = PA_FP_CONSTANTS_PKG.G_BUDGET_TYPE_CODE_AC)
1277
1278 -- If an Approved Revenue plan version exists for the project in new model then a budget
1279 -- version of budget type 'AR' can not be created for that project.
1280 IF (p_budget_type_code = PA_FP_CONSTANTS_PKG.G_BUDGET_TYPE_CODE_AR) THEN
1281
1282 -- Call the utility function that gives the id of the approved revenue plan type, if exists,
1283 -- that is added to the project
1284 pa_fin_plan_utils.Get_Appr_Rev_Plan_Type_Info(
1285 p_project_id => px_pa_project_id
1286 ,x_plan_type_id => l_approved_fin_plan_type_id
1287 ,x_return_status => x_return_status
1288 ,x_msg_count => x_msg_count
1289 ,x_msg_data => x_msg_data) ;
1290
1291 -- Throw the error if the above API is not successfully executed
1292 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1293
1294 IF l_debug_mode = 'Y' THEN
1295 pa_debug.g_err_stage := 'Get_Appr_Cost_Plan_Type_Info API returned error' ;
1296 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
1297 END IF;
1298 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1299
1300 -- The Get_Appr_Cost_Plan_Type_Info api got executed successfully.Approved cost version
1301 -- is already added to the project
1302 ELSIF( l_approved_fin_plan_type_id IS NOT NULL) THEN
1303
1304 IF l_debug_mode = 'Y' THEN
1305 pa_debug.g_err_stage := 'Approved Revenue plan version is already added ' ;
1306 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1307 END IF;
1308
1309 PA_UTILS.ADD_MESSAGE
1310 (p_app_short_name => 'PA',
1311 p_msg_name => 'PA_FP_AR_PLAN_TYPE_EXISTS');
1312 x_return_status := FND_API.G_RET_STS_ERROR;
1313 l_any_error_occurred_flag := 'Y';
1314
1315 END IF;
1316 END IF;
1317
1318
1319 -- Get the ID of the old draft budget and then
1320 -- Lock the old draft budget and it budget lines (if it exists)
1321 -- because it will be deleted by create_draft.
1322 OPEN l_budget_version_csr( px_pa_project_id, p_budget_type_code );
1323 FETCH l_budget_version_csr INTO l_old_budget_version_id, l_budget_status_code;
1324 CLOSE l_budget_version_csr;
1325
1326 --if working bugdet is submitted no new working budget can be created
1327 IF l_budget_status_code = 'S'
1328 THEN
1329 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
1330 THEN
1331 pa_interface_utils_pub.map_new_amg_msg
1332 ( p_old_message_code => 'PA_BUDGET_IS_SUBMITTED'
1333 ,p_msg_attribute => 'CHANGE'
1334 ,p_resize_flag => 'N'
1335 ,p_msg_context => 'BUDG'
1336 ,p_attribute1 => l_amg_project_rec.segment1
1337 ,p_attribute2 => ''
1338 ,p_attribute3 => p_budget_type_code
1339 ,p_attribute4 => ''
1340 ,p_attribute5 => '');
1341 END IF;
1342 x_return_status := FND_API.G_RET_STS_ERROR;
1343 l_any_error_occurred_flag := 'Y';
1344 --RAISE FND_API.G_EXC_ERROR;
1345
1346 END IF;--l_budget_status_code = 'S'
1347
1348
1349 -- Validations for fin plan model
1350 ELSE
1351 px_fin_plan_type_id_in := px_fin_plan_type_id;
1352 PA_FIN_PLAN_PVT.convert_plan_type_name_to_id
1353 ( p_fin_plan_type_id => px_fin_plan_type_id_in
1354 ,p_fin_plan_type_name => px_fin_plan_type_name
1355 ,x_fin_plan_type_id => px_fin_plan_type_id
1356 ,x_return_status => x_return_status
1357 ,x_msg_count => x_msg_count
1358 ,x_msg_data => x_msg_data);
1359 --dbms_output.put_line('After the getting plan id');
1360
1361 -- Throw the error if the above API is not successfully executed
1362 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1363
1364 IF l_debug_mode = 'Y' THEN
1365 pa_debug.g_err_stage := 'Can not get the value of Fin Plan Type Id' ;
1366 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
1367 END IF;
1368
1369
1370 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1371
1372 END IF;
1373
1374 -- Get the plan type level settings
1375
1376 OPEN l_proj_fp_options_csr(px_pa_project_id,px_fin_plan_type_id);
1377 FETCH l_proj_fp_options_csr
1378 INTO l_proj_fp_options_rec;
1379
1380 --Bug # 3507156 : Patchset M: B and F impact changes : AMG
1381 --Added the parameter use_for_workplan_flag.We need to check this flag as workplan versions
1382 --cannot be created using AMG interface.Error handling also done.
1383
1384 -- Get the name of the plan type
1385 SELECT name,use_for_workplan_flag
1386 INTO l_fin_plan_type_name,l_workplan_flag
1387 FROM pa_fin_plan_types_vl
1388 WHERE fin_plan_type_id = px_fin_plan_type_id;
1389
1390 IF l_workplan_flag = 'Y' THEN
1391
1392 IF l_debug_mode = 'Y' THEN
1393 pa_debug.g_err_stage := 'WorkPlan Versions cannot be created using this AMG interface' ;
1394 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
1395 END IF;
1396
1397 PA_UTILS.ADD_MESSAGE
1398 (p_app_short_name => 'PA',
1399 p_msg_name => 'PA_FP_WP_BV_CR_NO_ALLOWED');
1400
1401 --Bug # 3507156 : Patchset M: B and F impact changes : AMG
1402 x_return_status := FND_API.G_RET_STS_ERROR;
1403 l_any_error_occurred_flag := 'Y';
1404
1405 END IF;
1406
1407 -- Throw an error if the plan type is not attached to the project
1408 IF l_proj_fp_options_csr%NOTFOUND THEN
1409
1410 IF l_debug_mode = 'Y' THEN
1411 pa_debug.g_err_stage := 'Plan type options does not exist' ;
1412 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
1413 END IF;
1414
1415 PA_UTILS.ADD_MESSAGE
1416 (p_app_short_name => 'PA',
1417 p_msg_name => 'PA_FP_NO_PLAN_TYPE_OPTION',
1418 p_token1 => 'PROJECT',
1419 p_value1 => l_amg_project_rec.segment1,
1420 p_token2 => 'PLAN_TYPE',
1421 p_value2 => l_fin_plan_type_name);
1422
1423
1424 CLOSE l_proj_fp_options_csr;
1425
1426 IF l_debug_mode = 'Y' THEN
1427 pa_debug.g_err_stage:= 'Plan type is not yet added to the project';
1428 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1429 END IF;
1430
1431 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1432
1433 ELSE
1434
1435 CLOSE l_proj_fp_options_csr;
1436
1437 END IF;
1438
1439 -- If autobaselining is enabled for the project and If the budget type code is 'AR' then the
1440 -- version can not be created thru AMG
1441
1442 l_called_from_agr_pub := PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB; -- Bug # 3099706
1443
1444 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1445 --PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB should be reset to N even in case of errors.
1446
1447 IF (nvl(PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB,'N') = 'Y') THEN
1448 PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB := 'N'; -- reset the value bug 3099706
1449 END IF;
1450
1451 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1452 -- To check whether finplan is auto baselined by calling the api.
1453
1454 l_autobaseline_flag := pa_fp_control_items_utils.IsFpAutoBaselineEnabled(px_pa_project_id);
1455
1456 --dbms_output.put_line('About to get ver type');
1457
1458 -- Derive the version type. An error will be thrown by this api if preference code is
1459 -- COST_AND_REV_SEP and version type is not passed
1460 pa_fin_plan_utils.get_version_type
1461 ( p_project_id => px_pa_project_id
1462 ,p_fin_plan_type_id => px_fin_plan_type_id
1463 ,px_version_type => px_version_type
1464 ,x_return_status => x_return_status
1465 ,x_msg_count => x_msg_count
1466 ,x_msg_data => x_msg_data);
1467
1468 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1469
1470 IF l_debug_mode = 'Y' THEN
1471 pa_debug.g_err_stage := 'Faied in get_Version_type' ;
1472 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
1473 END IF;
1474 --dbms_output.put_line('Exc in getting ver type');
1475
1476 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1477
1478 END IF;
1479
1480 IF l_autobaseline_flag = 'N' THEN
1481
1482 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1483 --If validate_header_info is called for create_budget_context call pa_fin_plan_utils.allow_edit_after_baseline_flag.
1484
1485 pa_fin_plan_utils.Check_if_plan_type_editable (
1486 P_project_id => px_pa_project_id
1487 ,P_fin_plan_type_id => px_fin_plan_type_id
1488 ,P_version_type => px_version_type
1489 ,X_editable_flag => l_editable_flag
1490 ,X_return_status => x_return_status
1491 ,X_msg_count => x_msg_count
1492 ,X_msg_data => x_msg_data);
1493
1494 -- Throw the error if the above API is not successfully executed
1495
1496 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1497
1498 IF l_debug_mode = 'Y' THEN
1499 pa_debug.g_err_stage := 'Can not check if plan type is editable' ;
1500 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1501 END IF;
1502
1503 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1504 END IF;
1505
1506 --<Patchset M: B and F impact changes : AMG:> -- Bug # 3507156
1507 --If it returns N, then raise PA_FP_PLAN_TYPE_NON_EDITABLE.
1508
1509 IF l_editable_flag = 'N' THEN
1510
1511 IF l_debug_mode = 'Y' THEN
1512 pa_debug.g_err_stage := 'Plan type is not editable' ;
1513 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1514 END IF;
1515
1516 PA_UTILS.ADD_MESSAGE
1517 (p_app_short_name => 'PA',
1518 p_msg_name => 'PA_FP_PLAN_TYPE_NON_EDITABLE',
1519 p_token1 => 'PROJECT',
1520 p_value1 => l_amg_project_rec.segment1,
1521 p_token2 => 'PLAN_TYPE',
1522 p_value2 => l_fin_plan_type_name);
1523
1524 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1525 --Setting the error statuses if plan type is not editable.
1526
1527 x_return_status := FND_API.G_RET_STS_ERROR;
1528 l_any_error_occurred_flag := 'Y';
1529
1530 END IF;
1531 END IF;
1532
1533 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1534 -- Commented out as it is redundant over here.
1535 /*
1536 IF (nvl(PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB,'N') = 'Y') THEN
1537 PA_FP_CONSTANTS_PKG.G_CALLED_FROM_AGREEMENT_PUB := 'N'; -- reset the value bug 3099706
1538 END IF;
1539 */
1540
1541
1542 IF ( (NVL(l_amg_project_rec.baseline_funding_flag,'N')='Y')
1543 AND (p_budget_type_code = PA_FP_CONSTANTS_PKG.G_BUDGET_TYPE_CODE_AR)
1544 AND (NVL(l_called_from_agr_pub,'N') = 'N')) THEN -- Bug 3099706
1545
1546
1547 -- Added the param p_called_from_baseline to skip the autobaseline validation if
1548 -- the create_draft_budget API is called to create a draft budget while creating
1549 -- a baselined budget. If this API is called to create a draft version directly,
1550 -- this check should be done. In this case, the param p_called_from_baseline
1551 -- is defaulted to 'N' (for bug # 3099706)
1552
1553 IF l_debug_mode = 'Y' THEN
1554 pa_debug.g_err_stage := 'Auto base line error' ;
1555 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1556 END IF;
1557
1558 PA_UTILS.ADD_MESSAGE
1559 (p_app_short_name => 'PA',
1560 p_msg_name => 'PA_FP_AUTO_BASELINE_ENABLED',
1561 p_token1 => 'PROJECT',
1562 p_value1 => l_amg_project_rec.segment1);
1563
1564 x_return_status := FND_API.G_RET_STS_ERROR;
1565 l_any_error_occurred_flag := 'Y';
1566
1567 --RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1568 --dbms_output.put_line('Autobaseline error');
1569
1570 END IF;
1571
1572 PA_PM_FUNCTION_SECURITY_PUB.CHECK_BUDGET_SECURITY (
1573 p_api_version_number => p_api_version_number
1574 ,p_project_id => px_pa_project_id
1575 ,p_fin_plan_type_id => px_fin_plan_type_id /* Bug 3139924 */
1576 ,p_calling_context => PA_FP_CONSTANTS_PKG.G_CALLING_MODULE_FIN_PLAN
1577 ,p_function_name => p_calling_module
1578 ,p_version_type => px_version_type
1579 ,x_return_status => x_return_status
1580 ,x_ret_code => l_security_ret_code );
1581
1582 IF (x_return_status <>FND_API.G_RET_STS_SUCCESS OR
1583 l_security_ret_code='N') THEN
1584 --dbms_output.put_line('Exc in security');
1585 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1586 END IF;
1587
1588
1589 /* Bug 3133930- Version name validation is included */
1590
1591 IF p_budget_version_name IS NULL OR
1592 p_budget_version_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
1593 PA_UTILS.ADD_MESSAGE(
1594 p_app_short_name => 'PA'
1595 ,p_msg_name => 'PA_VERSION_NAME_IS_MISSING');
1596 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1597 END IF;
1598
1599 --dbms_output.put_line('DONE with sec');
1600 -- Added the check to skip the autobaseline validation if
1601 -- the create_draft_budget API is called to create a draft budget while creating
1602 -- a baselined budget. --4738996
1603 -- Auto Baseline check. If auto baselining is enabled for the project the user can not
1604 -- create an approved revenue plan version thru AMG
1605 IF ((NVL(l_amg_project_rec.baseline_funding_flag,'N')='Y')
1606 AND (px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE)
1607 AND (l_proj_fp_options_rec.approved_rev_plan_type_flag = 'Y')
1608 AND (NVL(l_called_from_agr_pub,'N') = 'N')) THEN -- Added for bug 4738996
1609
1610 IF l_debug_mode = 'Y' THEN
1611 pa_debug.g_err_stage := 'Auto base line error' ;
1612 pa_debug.write( l_module_name,pa_debug.g_err_stage,l_debug_level3);
1613 END IF;
1614
1615 PA_UTILS.ADD_MESSAGE
1616 (p_app_short_name => 'PA',
1617 p_msg_name => 'PA_FP_AUTO_BASELINE_ENABLED',
1618 p_token1 => 'PROJECT',
1619 p_value1 => l_amg_project_rec.segment1);
1620
1621 x_return_status := FND_API.G_RET_STS_ERROR;
1622 l_any_error_occurred_flag := 'Y';
1623 --RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1624
1625 END IF;
1626
1627 -- Validate planning level, resource list id and time phasing if they are passed. If they
1628 -- are not passed, default them from the plan type options.
1629 -- Get the plan type level settings so that they can be used in the defaulting
1630 OPEN l_plan_type_settings_csr( px_pa_project_id
1631 ,px_fin_plan_type_id
1632 ,px_version_type);
1633 FETCH l_plan_type_settings_csr
1634 INTO l_plan_type_settings_rec;
1635
1636 IF (l_plan_type_settings_csr%NOTFOUND) THEN --This condition should never be true
1637
1638 IF l_debug_mode = 'Y' THEN
1639 pa_debug.g_err_stage := 'l_plan_type_settings_csr returned 0 rows' ;
1640 pa_debug.write( l_module_name,pa_debug.g_err_stage,l_debug_level3);
1641 END IF;
1642 CLOSE l_plan_type_settings_csr;
1643 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1644
1645 ELSE
1646
1647 CLOSE l_plan_type_settings_csr;
1648
1649 END IF;
1650
1651
1652
1653 -- Get the planning level
1654 IF ( px_fin_plan_level_code IS NULL) THEN
1655
1656 IF l_debug_mode = 'Y' THEN
1657 pa_debug.g_err_stage := 'Defaulting planning level from the plan type' ;
1658 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1659 END IF;
1660
1661 px_fin_plan_level_code := l_plan_type_settings_rec.fin_plan_level_code;
1662
1663 ELSE -- validate the passed planning level
1664
1665 -- Use the utility function that returns the meaning given the lookup type and code
1666 -- to validate the planning level given by the user
1667
1668 -- <Patchset M : B andF impact changes : AMG:> -- Bug # 3507156
1669 -- Added a check to filter out budgets where fin_plan_level_code = 'M'
1670
1671 IF ((pa_fin_plan_utils.get_lookup_value(l_planning_level_lookup ,px_fin_plan_level_code) IS NULL)
1672 OR (px_fin_plan_level_code = 'M'))
1673 THEN
1674 IF l_debug_mode = 'Y' THEN
1675 pa_debug.g_err_stage := 'Planning level passed is '|| px_fin_plan_level_code ;
1676 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1677 END IF;
1678
1679 PA_UTILS.ADD_MESSAGE
1680 (p_app_short_name => 'PA',
1681 p_msg_name => 'PA_FP_INVALID_PLANNING_LEVEL',
1682 p_token1 => 'PROJECT',
1683 p_value1 => l_amg_project_rec.segment1,
1684 p_token2 => 'PLAN_TYPE',
1685 p_value2 => l_fin_plan_type_name);
1686
1687 x_return_status := FND_API.G_RET_STS_ERROR;
1688 l_any_error_occurred_flag := 'Y';
1689
1690 END IF;
1691
1692
1693 END IF;--IF ( px_fin_plan_level_code IS NULL) THEN
1694
1695 -- Get the resource list
1696 IF p_using_resource_lists_flag = 'N' THEN
1697 pa_get_resource.Get_Uncateg_Resource_Info
1698 (p_resource_list_id => l_uncategorized_list_id,
1699 p_resource_list_member_id => l_uncategorized_rlmid,
1700 p_resource_id => l_uncategorized_resid,
1701 p_track_as_labor_flag => l_track_as_labor_flag,
1702 p_err_code => l_err_code,
1703 p_err_stage => l_err_stage,
1704 p_err_stack => l_err_stack );
1705
1706 IF l_err_code <> 0 THEN
1707 IF NOT pa_project_pvt.check_valid_message(l_err_stage) THEN
1708 pa_interface_utils_pub.map_new_amg_msg
1709 ( p_old_message_code => 'PA_NO_UNCATEGORIZED_LIST'
1710 ,p_msg_attribute => 'CHANGE'
1711 ,p_resize_flag => 'N'
1712 ,p_msg_context => 'BUDG'
1713 ,p_attribute1 => l_amg_project_rec.segment1
1714 ,p_attribute2 => ''
1715 ,p_attribute3 => p_budget_type_code
1716 ,p_attribute4 => ''
1717 ,p_attribute5 => '');
1718
1719 IF l_debug_mode = 'Y' THEN
1720 pa_debug.g_err_stage:= 'Uncategorized res list is missing';
1721 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1722 END IF;
1723 ELSE
1724 pa_interface_utils_pub.map_new_amg_msg
1725 ( p_old_message_code => l_err_stage
1726 ,p_msg_attribute => 'CHANGE'
1727 ,p_resize_flag => 'N'
1728 ,p_msg_context => 'BUDG'
1729 ,p_attribute1 => l_amg_project_rec.segment1
1730 ,p_attribute2 => ''
1731 ,p_attribute3 => p_budget_type_code
1732 ,p_attribute4 => ''
1733 ,p_attribute5 => '');
1734 IF l_debug_mode = 'Y' THEN
1735 pa_debug.g_err_stage:= 'Unexp error while deriving uncat res list';
1736 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1737 END IF;
1738 END IF;
1739
1740 ELSE
1741
1742 px_resource_list_id := l_uncategorized_list_id;
1743
1744 -- RAISE FND_API.G_EXC_ERROR;
1745 END IF; -- IF l_err_code <> 0 THEN
1746 ELSE
1747 IF( px_resource_list_name IS NULL OR
1748 px_resource_list_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR )AND
1749 (px_resource_list_id IS NULL OR
1750 px_resource_list_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM) THEN
1751
1752 IF l_debug_mode = 'Y' THEN
1753 pa_debug.g_err_stage := 'Defaulting Resource List Id from the plan type' ;
1754 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1755 END IF;
1756
1757 px_resource_list_id := l_plan_type_settings_rec.resource_list_id;
1758 ELSE
1759
1760 -- convert resource_list_name to resource_list_id
1761 px_resource_list_id_in := px_resource_list_id;
1762 pa_resource_pub.Convert_List_name_to_id
1763 ( p_resource_list_name => px_resource_list_name,
1764 p_resource_list_id => px_resource_list_id_in,
1765 p_out_resource_list_id => px_resource_list_id,
1766 p_return_status => x_return_status );
1767
1768 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1769
1770 PA_UTILS.ADD_MESSAGE
1771 (p_app_short_name => 'PA',
1772 p_msg_name => 'PA_FP_INVALID_RESOURCE_LIST',
1773 p_token1 => 'PROJECT',
1774 p_value1 => l_amg_project_rec.segment1);
1775
1776 IF l_debug_mode = 'Y' THEN
1777 pa_debug.g_err_stage:= 'Resource list passed is invalid';
1778 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1779 END IF;
1780
1781
1782 x_return_status := FND_API.G_RET_STS_ERROR;
1783 l_any_error_occurred_flag := 'Y';
1784
1785 END IF;
1786
1787 /* changes for bug 3954329: following check included */
1788 BEGIN
1789 SELECT migration_code
1790 INTO l_res_list_migration_code
1791 FROM pa_resource_lists_all_bg
1792 WHERE resource_list_id = px_resource_list_id;
1793 EXCEPTION
1794 WHEN NO_DATA_FOUND THEN
1795 x_return_status := FND_API.G_RET_STS_ERROR;
1796 PA_UTILS.ADD_MESSAGE
1797 (p_app_short_name => 'PA',
1798 p_msg_name => 'PA_FP_INVALID_RESOURCE_LIST',
1799 p_token1 => 'PROJECT',
1800 p_value1 => l_amg_project_rec.segment1);
1801 x_return_status := FND_API.G_RET_STS_ERROR;
1802
1803 l_any_error_occurred_flag := 'Y';
1804 IF l_debug_mode = 'Y' THEN
1805 pa_debug.g_err_stage:= 'error while deriving uncat res list';
1806 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1807 END IF;
1808 END;
1809 IF l_res_list_migration_code IS NULL THEN
1810 x_return_status := FND_API.G_RET_STS_ERROR;
1811 l_any_error_occurred_flag := 'Y';
1812 PA_UTILS.ADD_MESSAGE
1813 (p_app_short_name => 'PA',
1814 p_msg_name => 'PA_FP_OLD_RES_LIST_NEW_MODEL');
1815 IF l_debug_mode = 'Y' THEN
1816 pa_debug.g_err_stage:= 'res list is OLD in NEW budget model';
1817 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1818 END IF;
1819 END IF;
1820 /* bug 3954329 ends */
1821 END IF;
1822 END IF;
1823
1824 -- Get the Time Phasing
1825 IF ( px_time_phased_code IS NULL) THEN
1826
1827 IF l_debug_mode = 'Y' THEN
1828 pa_debug.g_err_stage := 'Defaulting Time Phasing from the plan type' ;
1829 pa_debug.write( l_module_name,pa_debug.g_err_stage, l_debug_level3);
1830 END IF;
1831
1832 px_time_phased_code := l_plan_type_settings_rec.time_phased_code;
1833
1834 ELSE -- validate the passed time phased code
1835
1836 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1837 --Added the extra condition to check for time phasing as 'R'(Date Range) as date range time phasing is not supported in FP M.
1838
1839 IF ((pa_fin_plan_utils.get_lookup_value( l_time_phasing_lookup,px_time_phased_code) IS NULL) OR (px_time_phased_code = 'R'))
1840 THEN
1841
1842 IF l_debug_mode = 'Y' THEN
1843 pa_debug.g_err_stage := 'Time Phased Code passed is '|| px_time_phased_code ;
1844 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1845 END IF;
1846
1847 PA_UTILS.ADD_MESSAGE
1848 (p_app_short_name => 'PA',
1849 p_msg_name => 'PA_FP_INVALID_TIME_PHASING',
1850 p_token1 => 'PROJECT',
1851 p_value1 => l_amg_project_rec.segment1,
1852 p_token2 => 'PLAN_TYPE',
1853 p_value2 => l_fin_plan_type_name);
1854
1855 x_return_status := FND_API.G_RET_STS_ERROR;
1856 l_any_error_occurred_flag := 'Y';
1857
1858
1859 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1860 -- Call to Pa_Prj_Period_Profile_Utils.Get_Curr_Period_Profile_Info has become obsolete as per the FP M
1861 -- model so this condition has been commented out.
1862 --Comment START.
1863 /*
1864 -- The time phasing passed is valid. Time phasing can not be 'PA' or 'GL' if the
1865 -- period profile is not defined for the project.
1866 ELSE
1867 IF px_time_phased_code IN (PA_FP_CONSTANTS_PKG.G_TIME_PHASED_CODE_P,
1868 PA_FP_CONSTANTS_PKG.G_TIME_PHASED_CODE_G) THEN
1869 -- If the time phasing is either PA or GL check whether a period profile for that project
1870 -- exists or not
1871 IF px_time_phased_code = PA_FP_CONSTANTS_PKG.G_TIME_PHASED_CODE_P THEN
1872 l_period_type := PA_FP_CONSTANTS_PKG.G_PERIOD_TYPE_PA;
1873 ELSE
1874 l_period_type := PA_FP_CONSTANTS_PKG.G_PERIOD_TYPE_GL;
1875 END IF;
1876
1877 Pa_Prj_Period_Profile_Utils.Get_Curr_Period_Profile_Info
1878 ( p_project_id => px_pa_project_id,
1879 p_period_type => l_period_type,
1880 p_period_profile_type => PA_FP_CONSTANTS_PKG.G_PD_PROFILE_FIN_PLANNING,
1881 x_period_profile_id => l_period_profile_id,
1882 x_start_period => l_start_period,
1883 x_end_period => l_end_period,
1884 x_return_status => x_return_status,
1885 x_msg_count => x_msg_count,
1886 x_msg_data => x_msg_data );
1887
1888 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1889
1890 IF l_debug_mode = 'Y' THEN
1891 pa_debug.g_err_stage:= 'get current period profile gave error' ||px_pa_project_id;
1892 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1893
1894 END IF;
1895 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1896
1897 END IF;
1898
1899 IF(l_period_profile_id IS NULL) THEN
1900
1901 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
1902 p_msg_name => 'PA_FP_NO_PERIOD_PROFILE');
1903 x_return_status := FND_API.G_RET_STS_ERROR;
1904 l_any_error_occurred_flag := 'Y';
1905 IF l_debug_mode = 'Y' THEN
1906 pa_debug.g_err_stage:= 'Project does not have a period profile';
1907 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1908
1909 END IF;
1910
1911 END IF;
1912 END IF; --IF px_time_phased_code IN (PA_FP_CONSTANTS_PKG.G_TIME_PHASED_CODE_P,
1913 */
1914
1915 --<Patchset M: B and F impact changes : AMG:>-- Bug # 3507156
1916 -- Replaced the call to Pa_Prj_Period_Profile_Utils.Get_Curr_Period_Profile_Info
1917 -- by a check for existence of record in pa_period_masks_b
1918
1919 ELSIF px_time_phased_code IN (PA_FP_CONSTANTS_PKG.G_TIME_PHASED_CODE_P,
1920 PA_FP_CONSTANTS_PKG.G_TIME_PHASED_CODE_G) THEN
1921 BEGIN
1922 SELECT 'Y'
1923 INTO l_exists
1924 FROM dual
1925 WHERE exists(SELECT 'X' FROM pa_period_masks_b WHERE trunc(sysdate) between EFFECTIVE_START_DATE
1926 AND nvl( EFFECTIVE_END_DATE,sysdate)
1927 AND TIME_PHASE_CODE = px_time_phased_code); -- Bug # 3507156
1928
1929 EXCEPTION
1930 WHEN no_data_found THEN
1931 l_exists := 'N' ; /* No record exists in pa_period_masks_b */
1932 l_any_error_occurred_flag := 'Y';
1933
1934 PA_UTILS.ADD_MESSAGE
1935 (p_app_short_name => 'PA',
1936 p_msg_name => 'PA_FP_NO_PERIOD_MASK');
1937
1938 x_return_status := FND_API.G_RET_STS_ERROR;
1939 END;
1940 END IF; -- IF pa_fin_plan_utils.get_lookup_value
1941
1942 END IF; -- IF(px_time_phased_code IS NULL) THEN
1943 --dbms_output.put_line('About to start mc');
1944
1945 -- Multi currency flag validation.
1946
1947 -- Depending on px_version_type initialise l_conv_attrs_to_be_validated
1948 IF (px_version_type <> PA_FP_CONSTANTS_PKG.G_VERSION_TYPE_ALL) THEN
1949 l_conv_attrs_to_be_validated := px_version_type;
1950 ELSE
1951 l_conv_attrs_to_be_validated := PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_BOTH;
1952 END IF;
1953
1954
1955 -- Get the project and project functional currencies.
1956 pa_fin_plan_utils.Get_Project_Curr_Attributes
1957 ( p_project_id => px_pa_project_id
1958 ,x_multi_currency_billing_flag => l_multi_currency_billing_flag
1959 ,x_project_currency_code => l_project_currency_code
1960 ,x_projfunc_currency_code => l_projfunc_currency_code
1961 ,x_project_cost_rate_type => l_project_cost_rate_type
1962 ,x_projfunc_cost_rate_type => l_projfunc_cost_rate_type
1963 ,x_project_bil_rate_type => l_project_bil_rate_type
1964 ,x_projfunc_bil_rate_type => l_projfunc_bil_rate_type
1965 ,x_return_status => x_return_status
1966 ,x_msg_count => x_msg_count
1967 ,x_msg_data => x_msg_data);
1968
1969 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1970
1971 IF l_debug_mode = 'Y' THEN
1972 pa_debug.g_err_stage:= 'pa_fin_plan_utils.Get_Project_Curr_Attributes errored out for project' ||px_pa_project_id;
1973 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1974
1975 END IF;
1976 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
1977
1978 END IF;
1979
1980
1981 -- Validate the MC flag.
1982 l_validate_mc_attributes := 'Y';
1983 IF (px_plan_in_multi_curr_flag IS NULL) THEN
1984
1985 IF l_debug_mode = 'Y' THEN
1986 pa_debug.g_err_stage := 'Defaulting MC from plan type' ;
1987 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
1988 END IF;
1989
1990 px_plan_in_multi_curr_flag := l_proj_fp_options_rec.plan_in_multi_curr_flag ;
1991
1992 IF px_plan_in_multi_curr_flag = 'N' THEN
1993 l_validate_mc_attributes := 'N';
1994
1995 px_projfunc_cost_rate_type := NULL;
1996 px_projfunc_cost_rate_date_typ := NULL;
1997 px_projfunc_cost_rate_date := NULL;
1998 px_projfunc_rev_rate_type := NULL;
1999 px_projfunc_rev_rate_date_typ := NULL;
2000 px_projfunc_rev_rate_date := NULL;
2001 px_project_cost_rate_type := NULL;
2002 px_project_cost_rate_date_typ := NULL;
2003 px_project_cost_rate_date := NULL;
2004 px_project_rev_rate_type := NULL;
2005 px_project_rev_rate_date_typ := NULL;
2006 px_project_rev_rate_date := NULL;
2007
2008 END IF;
2009
2010 END IF;
2011
2012 IF px_plan_in_multi_curr_flag = 'Y' THEN
2013 -- if plan type does not allow MC then it is also not allowed at the version level.
2014 IF l_proj_fp_options_rec.plan_in_multi_curr_flag = 'N' THEN
2015
2016 IF l_debug_mode = 'Y' THEN
2017 pa_debug.g_err_stage := 'mc is not enabled at plan type level';
2018 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2019 END IF;
2020
2021 PA_UTILS.ADD_MESSAGE
2022 (p_app_short_name => 'PA',
2023 p_msg_name => 'PA_FP_MC_MISMATCH',
2024 p_token1 => 'PROJECT',
2025 p_value1 => l_amg_project_rec.segment1,
2026 p_token2 => 'PLAN_TYPE',
2027 p_value2 => l_fin_plan_type_name);
2028
2029 x_return_status := FND_API.G_RET_STS_ERROR;
2030 l_any_error_occurred_flag := 'Y';
2031 l_validate_mc_attributes := 'N';
2032
2033 END IF;
2034
2035 -- when plan type is approved revenue and PC = PFC then its not allowed
2036 -- to enable MC for revenue versions
2037 IF l_proj_fp_options_rec.approved_rev_plan_type_flag = 'Y' AND
2038 l_project_currency_code = l_projfunc_currency_code AND
2039 px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE THEN
2040
2041 IF l_debug_mode = 'Y' THEN
2042 pa_debug.g_err_stage := 'mc is wrongly enabled at version level';
2043 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2044 END IF;
2045
2046 PA_UTILS.ADD_MESSAGE
2047 (p_app_short_name => 'PA',
2048 p_msg_name => 'PA_FP_INVALID_AR_AT_PROJ_TEMP');
2049 x_return_status := FND_API.G_RET_STS_ERROR;
2050 l_any_error_occurred_flag := 'Y';
2051
2052 l_validate_mc_attributes := 'N';
2053
2054 END IF;
2055
2056 ELSIF px_plan_in_multi_curr_flag = 'N' THEN
2057
2058 l_validate_mc_attributes := 'N';
2059 IF (l_project_currency_code <> l_projfunc_currency_code) THEN
2060 --24-APR-03. Changes made for post_fpk by Xin Liu
2061 /*
2062 IF l_debug_mode = 'Y' THEN
2063 pa_debug.g_err_stage := 'mc should be enabled at version level since PC <> PFC';
2064 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2065 END IF;
2066
2067 l_copy_conv_attr :=FALSE;
2068
2069 PA_UTILS.ADD_MESSAGE
2070 (p_app_short_name => 'PA',
2071 p_msg_name => 'PA_FP_MC_DISABLED_AT_VER',
2072 p_token1 => 'PROJECT',
2073 p_value1 => l_amg_project_rec.segment1,
2074 p_token2 => 'PLAN_TYPE',
2075 p_value2 => l_fin_plan_type_name);
2076
2077
2078 x_return_status := FND_API.G_RET_STS_ERROR;
2079 l_any_error_occurred_flag := 'Y';
2080 */
2081 l_validate_mc_attributes := 'Y';
2082 px_plan_in_multi_curr_flag := 'Y';
2083 --Done with changes
2084
2085
2086 ELSE
2087
2088 px_projfunc_cost_rate_type := NULL;
2089 px_projfunc_cost_rate_date_typ := NULL;
2090 px_projfunc_cost_rate_date := NULL;
2091 px_projfunc_rev_rate_type := NULL;
2092 px_projfunc_rev_rate_date_typ := NULL;
2093 px_projfunc_rev_rate_date := NULL;
2094 px_project_cost_rate_type := NULL;
2095 px_project_cost_rate_date_typ := NULL;
2096 px_project_cost_rate_date := NULL;
2097 px_project_rev_rate_type := NULL;
2098 px_project_rev_rate_date_typ := NULL;
2099 px_project_rev_rate_date := NULL;
2100
2101 END IF;--IF (l_project_currency_code <> l_projfunc_currency_code) THEN
2102
2103 ELSE--Invalid value for MC flagg
2104
2105 IF l_debug_mode = 'Y' THEN
2106 pa_debug.g_err_stage := 'Value of mc flag is' ||px_plan_in_multi_curr_flag;
2107 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2108 END IF;
2109
2110 PA_UTILS.ADD_MESSAGE
2111 (p_app_short_name => 'PA',
2112 p_msg_name => 'PA_FP_INVALID_VAL_FOR_MC',
2113 p_token1 => 'PROJECT',
2114 p_value1 => l_amg_project_rec.segment1,
2115 p_token2 => 'PLAN_TYPE',
2116 p_value2 => l_fin_plan_type_name);
2117
2118 x_return_status := FND_API.G_RET_STS_ERROR;
2119 l_any_error_occurred_flag := 'Y';
2120 l_validate_mc_attributes := 'N';
2121
2122
2123 END IF; -- IF ( px_plan_in_multi_curr_flag = 'Y') THEN
2124
2125 IF l_validate_mc_attributes = 'Y' THEN
2126
2127 IF (px_project_cost_rate_type IS NULL AND
2128 px_project_cost_rate_date_typ IS NULL AND
2129 px_project_cost_rate_date IS NULL AND
2130 px_projfunc_cost_rate_type IS NULL AND
2131 px_projfunc_cost_rate_date_typ IS NULL AND
2132 px_projfunc_cost_rate_date IS NULL AND
2133 px_project_rev_rate_type IS NULL AND
2134 px_project_rev_rate_date_typ IS NULL AND
2135 px_project_rev_rate_date IS NULL AND
2136 px_projfunc_rev_rate_type IS NULL AND
2137 px_projfunc_rev_rate_date_typ IS NULL AND
2138 px_projfunc_rev_rate_date IS NULL ) THEN
2139
2140 IF l_debug_mode = 'Y' THEN
2141 pa_debug.g_err_stage := 'Deriving the conversion attrs from plan type';
2142 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2143 END IF;
2144
2145 px_projfunc_cost_rate_type := l_proj_fp_options_rec.projfunc_cost_rate_type;
2146 px_projfunc_cost_rate_date_typ:= l_proj_fp_options_rec.projfunc_cost_rate_date_type;
2147 px_projfunc_cost_rate_date := l_proj_fp_options_rec.projfunc_cost_rate_date;
2148 px_projfunc_rev_rate_type := l_proj_fp_options_rec.projfunc_rev_rate_type;
2149 px_projfunc_rev_rate_date_typ := l_proj_fp_options_rec.projfunc_rev_rate_date_type;
2150 px_projfunc_rev_rate_date := l_proj_fp_options_rec.projfunc_rev_rate_date;
2151 px_project_cost_rate_type := l_proj_fp_options_rec.project_cost_rate_type;
2152 px_project_cost_rate_date_typ := l_proj_fp_options_rec.project_cost_rate_date_type;
2153 px_project_cost_rate_date := l_proj_fp_options_rec.project_cost_rate_date;
2154 px_project_rev_rate_type := l_proj_fp_options_rec.project_rev_rate_type;
2155 px_project_rev_rate_date_typ := l_proj_fp_options_rec.project_rev_rate_date_type;
2156 px_project_rev_rate_date := l_proj_fp_options_rec.project_rev_rate_date;
2157
2158 -- Conversion attributes are passed. Validate them
2159 ELSE
2160
2161 -- Null out the cost attributes for revenue version and vice versa AMG UT2
2162 IF l_conv_attrs_to_be_validated = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST THEN
2163
2164 px_project_rev_rate_type :=NULL;
2165 px_project_rev_rate_date_typ :=NULL;
2166 px_project_rev_rate_date :=NULL;
2167
2168 px_projfunc_rev_rate_type :=NULL;
2169 px_projfunc_rev_rate_date_typ :=NULL;
2170 px_projfunc_rev_rate_date :=NULL;
2171
2172 ELSIF l_conv_attrs_to_be_validated = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE THEN
2173
2174 px_project_cost_rate_type :=NULL;
2175 px_project_cost_rate_date_typ :=NULL;
2176 px_project_cost_rate_date :=NULL;
2177
2178 px_projfunc_cost_rate_type :=NULL;
2179 px_projfunc_cost_rate_date_typ :=NULL;
2180 px_projfunc_cost_rate_date :=NULL;
2181
2182 END IF;
2183
2184 -- If the rate type is not user at plan type and the rate type provided
2185 -- is User then throw an error since the rates at the option level can not
2186 -- be obtained
2187
2188 pa_budget_pvt.valid_rate_type
2189 (p_pt_project_cost_rate_type => l_proj_fp_options_rec.project_cost_rate_type,
2190 p_pt_project_rev_rate_type => l_proj_fp_options_rec.project_rev_rate_type,
2191 p_pt_projfunc_cost_rate_type=> l_proj_fp_options_rec.projfunc_cost_rate_type,
2192 p_pt_projfunc_rev_rate_type => l_proj_fp_options_rec.projfunc_rev_rate_type,
2193 p_pv_project_cost_rate_type => px_project_cost_rate_type,
2194 p_pv_project_rev_rate_type => px_project_rev_rate_type,
2195 p_pv_projfunc_cost_rate_type=> px_projfunc_cost_rate_type,
2196 p_pv_projfunc_rev_rate_type => px_projfunc_rev_rate_type,
2197 x_is_rate_type_valid => l_is_rate_type_valid,
2198 x_return_status => x_return_status,
2199 x_msg_count => x_msg_count,
2200 x_msg_data => x_msg_data);
2201
2202 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2203
2204 IF l_debug_mode = 'Y' THEN
2205 pa_debug.g_err_stage:= 'valid_rate_type returned error';
2206 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2207 END IF;
2208
2209 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
2210
2211 END IF;
2212
2213 IF NOT l_is_rate_type_valid THEN
2214
2215 IF l_debug_mode = 'Y' THEN
2216 pa_debug.g_err_stage := 'mc is wrongly enabled at version level';
2217 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2218 END IF;
2219
2220 PA_UTILS.ADD_MESSAGE
2221 (p_app_short_name => 'PA',
2222 p_msg_name => 'PA_FP_RATE_TYPE_NOT_USER_AT_PT',
2223 p_token1 => 'PROJECT',
2224 p_value1 => l_amg_project_rec.segment1,
2225 p_token2 => 'PLAN_TYPE',
2226 p_value2 => l_fin_plan_type_name);
2227
2228 x_return_status := FND_API.G_RET_STS_ERROR;
2229 l_any_error_occurred_flag := 'Y';
2230
2231 ELSE
2232 --dbms_output.put_line('The value of l_conv_attrs_to_be_validated is ' ||l_conv_attrs_to_be_validated);
2233
2234 pa_fin_plan_utils.validate_currency_attributes
2235 (px_project_cost_rate_type =>px_project_cost_rate_type
2236 ,px_project_cost_rate_date_typ =>px_project_cost_rate_date_typ
2237 ,px_project_cost_rate_date =>px_project_cost_rate_date
2238 ,px_project_cost_exchange_rate =>l_project_cost_exchange_rate
2239 ,px_projfunc_cost_rate_type =>px_projfunc_cost_rate_type
2240 ,px_projfunc_cost_rate_date_typ =>px_projfunc_cost_rate_date_typ
2241 ,px_projfunc_cost_rate_date =>px_projfunc_cost_rate_date
2242 ,px_projfunc_cost_exchange_rate =>l_projfunc_cost_exchange_rate
2243 ,px_project_rev_rate_type =>px_project_rev_rate_type
2244 ,px_project_rev_rate_date_typ =>px_project_rev_rate_date_typ
2245 ,px_project_rev_rate_date =>px_project_rev_rate_date
2246 ,px_project_rev_exchange_rate =>l_project_rev_exchange_rate
2247 ,px_projfunc_rev_rate_type =>px_projfunc_rev_rate_type
2248 ,px_projfunc_rev_rate_date_typ =>px_projfunc_rev_rate_date_typ
2249 ,px_projfunc_rev_rate_date =>px_projfunc_rev_rate_date
2250 ,px_projfunc_rev_exchange_rate =>l_projfunc_rev_exchange_rate
2251 ,p_project_currency_code =>l_project_currency_code
2252 ,p_projfunc_currency_code =>l_projfunc_currency_code
2253 ,p_context =>PA_FP_CONSTANTS_PKG.G_AMG_API_HEADER
2254 ,p_attrs_to_be_validated =>l_conv_attrs_to_be_validated
2255 ,x_return_status =>x_return_status
2256 ,x_msg_count =>x_msg_count
2257 ,x_msg_data =>x_msg_data);
2258
2259 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2260 x_return_status:=FND_API.G_RET_STS_ERROR;
2261
2262 IF l_debug_mode = 'Y' THEN
2263 pa_debug.g_err_stage:= 'Validate currency attributes returned error';
2264 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2265 END IF;
2266 l_any_error_occurred_flag := 'Y';
2267 END IF;
2268 END IF;
2269
2270 END IF;-- For If where all the conv attrs are checked for NULL
2271 END IF;--l_validate_mc_attributes = 'Y'
2272
2273 -- Added for Bug#5510196 START
2274
2275 px_revenue_flag := nvl(px_revenue_flag,'N');
2276 px_revenue_qty_flag := nvl(px_revenue_qty_flag,'N');
2277
2278 px_raw_cost_flag:= nvl(px_raw_cost_flag,'N');
2279 px_burdened_cost_flag := nvl(px_burdened_cost_flag,'N');
2280 px_cost_qty_flag := nvl(px_cost_qty_flag,'N');
2281 px_all_qty_flag := nvl(px_all_qty_flag,'N');
2282
2283 -- Addeed for Bug#5510196 END
2284
2285
2286 -- Validate amount and quantity flags
2287 IF( px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST) THEN
2288
2289 px_raw_cost_flag:= nvl(px_raw_cost_flag,'N');
2290 px_burdened_cost_flag := nvl(px_burdened_cost_flag,'N');
2291 px_cost_qty_flag := nvl(px_cost_qty_flag,'N');
2292
2293 IF( px_raw_cost_flag NOT IN ('Y','N')) OR
2294 ( px_burdened_cost_flag NOT IN ('Y','N')) OR
2295 ( px_cost_qty_flag NOT IN ('Y','N')) THEN
2296
2297 PA_UTILS.ADD_MESSAGE
2298 (p_app_short_name => 'PA',
2299 p_msg_name => 'PA_FP_INVALID_AMT_FLAGS',
2300 p_token1 => 'PROJECT',
2301 p_value1 => l_amg_project_rec.segment1,
2302 p_token2 => 'PLAN_TYPE',
2303 p_value2 => l_fin_plan_type_name);
2304 x_return_status := FND_API.G_RET_STS_ERROR;
2305 l_any_error_occurred_flag := 'Y';
2306 IF l_debug_mode = 'Y' THEN
2307 pa_debug.g_err_stage:= 'Invalid values for amount flags ';
2308 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2309 END IF;
2310 END IF;
2311
2312
2313 IF( px_raw_cost_flag = 'N') AND
2314 ( px_burdened_cost_flag = 'N') AND
2315 ( px_cost_qty_flag = 'N') THEN
2316
2317 PA_UTILS.ADD_MESSAGE
2318 (p_app_short_name => 'PA',
2319 p_msg_name => 'PA_FP_NO_PLAN_AMT_CHECKED');
2320 x_return_status := FND_API.G_RET_STS_ERROR;
2321 l_any_error_occurred_flag := 'Y';
2322 IF l_debug_mode = 'Y' THEN
2323 pa_debug.g_err_stage:= 'None of the amount flags are Y ';
2324 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2325 END IF;
2326 END IF;
2327
2328 ELSIF( px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE ) THEN
2329
2330 px_revenue_flag := nvl(px_revenue_flag,'N');
2331 px_revenue_qty_flag := nvl(px_revenue_qty_flag,'N');
2332
2333 IF( px_revenue_flag NOT IN ('Y','N')) OR
2334 ( px_revenue_qty_flag NOT IN ('Y','N')) THEN
2335
2336 PA_UTILS.ADD_MESSAGE
2337 (p_app_short_name => 'PA',
2338 p_msg_name => 'PA_FP_INVALID_AMT_FLAGS',
2339 p_token1 => 'PROJECT',
2340 p_value1 => l_amg_project_rec.segment1,
2341 p_token2 => 'PLAN_TYPE',
2342 p_value2 => l_fin_plan_type_name);
2343 x_return_status := FND_API.G_RET_STS_ERROR;
2344 l_any_error_occurred_flag := 'Y';
2345 IF l_debug_mode = 'Y' THEN
2346 pa_debug.g_err_stage:= 'Invalid value for the amount flags ';
2347 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2348 END IF;
2349
2350 END IF;
2351
2352
2353 IF( px_revenue_flag ='N') AND
2354 ( px_revenue_qty_flag ='N') THEN
2355
2356 PA_UTILS.ADD_MESSAGE
2357 (p_app_short_name => 'PA',
2358 p_msg_name => 'PA_FP_NO_PLAN_AMT_CHECKED');
2359 x_return_status := FND_API.G_RET_STS_ERROR;
2360 l_any_error_occurred_flag := 'Y';
2361 IF l_debug_mode = 'Y' THEN
2362 pa_debug.g_err_stage:= 'None of the amount flags are Y ';
2363 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2364 END IF;
2365
2366 END IF;
2367
2368 ELSIF( px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL ) THEN
2369
2370 px_raw_cost_flag:= nvl(px_raw_cost_flag,'N');
2371 px_burdened_cost_flag := nvl(px_burdened_cost_flag,'N');
2372 px_revenue_flag := nvl(px_revenue_flag,'N');
2373 px_all_qty_flag := nvl(px_all_qty_flag,'N');
2374
2375 IF( px_raw_cost_flag NOT IN ('Y','N')) OR
2376 ( px_burdened_cost_flag NOT IN ('Y','N')) OR
2377 ( px_revenue_flag NOT IN ('Y','N')) OR
2378 ( px_all_qty_flag NOT IN ('Y','N')) THEN
2379
2380 PA_UTILS.ADD_MESSAGE
2381 (p_app_short_name => 'PA',
2382 p_msg_name => 'PA_FP_INVALID_AMT_FLAGS',
2383 p_token1 => 'PROJECT',
2384 p_value1 => l_amg_project_rec.segment1,
2385 p_token2 => 'PLAN_TYPE',
2386 p_value2 => l_fin_plan_type_name);
2387 x_return_status := FND_API.G_RET_STS_ERROR;
2388 l_any_error_occurred_flag := 'Y';
2389 IF l_debug_mode = 'Y' THEN
2390 pa_debug.g_err_stage:= 'Invalid value for the amount flags ';
2391 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2392 END IF;
2393
2394 END IF;
2395
2396 IF( px_raw_cost_flag ='N') AND
2397 ( px_burdened_cost_flag='N') AND
2398 ( px_revenue_flag ='N') AND
2399 ( px_cost_qty_flag = 'N') AND --Fix for 7172129
2400 ( px_revenue_qty_flag ='N') AND
2401 ( px_all_qty_flag ='N') THEN
2402
2403 PA_UTILS.ADD_MESSAGE
2404 (p_app_short_name => 'PA',
2405 p_msg_name => 'PA_FP_NO_PLAN_AMT_CHECKED');
2406 x_return_status := FND_API.G_RET_STS_ERROR;
2407 l_any_error_occurred_flag := 'Y';
2408 IF l_debug_mode = 'Y' THEN
2409 pa_debug.g_err_stage:= 'None of the amount flags are Y ';
2410 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2411 END IF;
2412
2413 END IF;
2414
2415 END IF; -- Validate amount and quantity flags
2416
2417 -- Check create_new_working_flag and replace_current_working_flag
2418 IF ( p_create_new_curr_working_flag IS NULL OR
2419 p_replace_current_working_flag IS NULL OR
2420 p_create_new_curr_working_flag NOT IN ('Y','N') OR
2421 p_replace_current_working_flag NOT IN ('Y','N')) THEN
2422
2423 PA_UTILS.ADD_MESSAGE
2424 (p_app_short_name => 'PA',
2425 p_msg_name => 'PA_FP_CR_REP_FLAGS_INVALID',
2426 p_token1 => 'PROJECT',
2427 p_value1 => l_amg_project_rec.segment1,
2428 p_token2 => 'PLAN_TYPE',
2429 p_value2 => l_fin_plan_type_name);
2430
2431 x_return_status := FND_API.G_RET_STS_ERROR;
2432 l_any_error_occurred_flag := 'Y';
2433 IF l_debug_mode = 'Y' THEN
2434 pa_debug.g_err_stage:= 'Create replace CW version flags are invalid ';
2435 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2436 END IF;
2437
2438
2439 --Create and Replace flags have valid values
2440 ELSE
2441
2442 IF (p_replace_current_working_flag = 'Y' OR
2443 p_create_new_curr_working_flag = 'Y') THEN
2444
2445 -- Get the status of the current working version. If the status is submitted then
2446 -- it can not be updated/deleted
2447 OPEN l_finplan_CW_ver_csr(px_pa_project_id,px_fin_plan_type_id,px_version_type);
2448 FETCH l_finplan_CW_ver_csr
2449 INTO l_finplan_CW_ver_rec;
2450
2451 IF( l_finplan_CW_ver_csr%NOTFOUND) THEN
2452
2453 IF l_debug_mode = 'Y' THEN
2454 pa_debug.g_err_stage := 'A working version does not exist for the project '||px_pa_project_id;
2455 pa_debug.write( l_module_name,pa_debug.g_err_stage,l_debug_level3);
2456 END IF;
2457 CLOSE l_finplan_CW_ver_csr;
2458
2459 ELSE
2460
2461 CLOSE l_finplan_CW_ver_csr;
2462
2463 IF l_debug_mode = 'Y' THEN
2464 pa_debug.g_err_stage := 'One of the create replace flags is Y';
2465 pa_debug.write( l_module_name,pa_debug.g_err_stage,l_debug_level3);
2466 END IF;
2467
2468 IF nvl(l_finplan_CW_ver_rec.budget_status_code,'X') = 'S' THEN
2469 IF l_debug_mode = 'Y' THEN
2470 pa_debug.g_err_stage := 'Version exists in submitted status';
2471 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2472 END IF;
2473
2474 pa_interface_utils_pub.map_new_amg_msg
2475 ( p_old_message_code => 'PA_BUDGET_IS_SUBMITTED'
2476 ,p_msg_attribute => 'CHANGE'
2477 ,p_resize_flag => 'N'
2478 ,p_msg_context => 'BUDG'
2479 ,p_attribute1 => l_amg_project_rec.segment1
2480 ,p_attribute2 => ''
2481 ,p_attribute3 => l_fin_plan_type_name
2482 ,p_attribute4 => ''
2483 ,p_attribute5 => '');
2484 x_return_status := FND_API.G_RET_STS_ERROR;
2485 l_any_error_occurred_flag := 'Y';
2486
2487 IF l_finplan_CW_ver_rec.plan_processing_code IN ('XLUE','XLUP') THEN
2488
2489 pa_fin_plan_utils.return_and_vldt_plan_prc_code
2490 (p_plan_processing_code => l_finplan_CW_ver_rec.plan_processing_code
2491 ,x_final_plan_prc_code => l_finplan_CW_ver_rec.plan_processing_code
2492 ,x_targ_request_id => l_targ_request_id
2493 ,x_return_status => x_return_status
2494 ,x_msg_count => x_msg_count
2495 ,x_msg_data => x_msg_data);
2496
2497 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2498 x_return_status:=FND_API.G_RET_STS_ERROR;
2499
2500 IF l_debug_mode = 'Y' THEN
2501 pa_debug.g_err_stage:= 'pa_fin_plan_utils.return_and_vldt_plan_prc_code returned error';
2502 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2503 END IF;
2504 l_any_error_occurred_flag := 'Y';
2505 END IF;
2506
2507 END IF;
2508
2509 END IF; -- if budget version is in submitted status.
2510
2511 END IF;--IF( l_finplan_CW_ver_csr%NOTFOUND) THEN
2512
2513 END IF;--IF ((p_replace_current_working_flag <> 'N' OR
2514
2515 END IF; -- p_create_new_curr_working_flag IS NULL OR
2516
2517 END IF; -- END OF CHECKS FOR FINPLAN MODEL
2518
2519 -- check validity of the budget change reason code, passing NULL is OK
2520
2521 IF (p_change_reason_code IS NOT NULL AND
2522 p_change_reason_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
2523
2524 --dbms_output.put_line('In head p_change_reason_code is '||p_change_reason_code);
2525 OPEN l_budget_change_reason_csr( p_change_reason_code );
2526 FETCH l_budget_change_reason_csr INTO l_dummy;
2527 IF (p_budget_type_code IS NULL OR
2528 p_budget_type_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR ) THEN
2529
2530 l_context_info := l_fin_plan_type_name;
2531
2532 ELSE
2533
2534 l_context_info := p_budget_type_code;
2535
2536 END IF;
2537 IF l_budget_change_reason_csr%NOTFOUND THEN
2538 CLOSE l_budget_change_reason_csr;
2539
2540 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
2541 THEN
2542 pa_interface_utils_pub.map_new_amg_msg
2543 ( p_old_message_code => 'PA_CHANGE_REASON_INVALID'
2544 ,p_msg_attribute => 'CHANGE'
2545 ,p_resize_flag => 'N'
2546 ,p_msg_context => 'BUDG'
2547 ,p_attribute1 => l_amg_project_rec.segment1
2548 ,p_attribute2 => ''
2549 ,p_attribute3 => l_context_info
2550 ,p_attribute4 => ''
2551 ,p_attribute5 => '');
2552 IF l_debug_mode = 'Y' THEN
2553 pa_debug.g_err_stage:= 'Invalid Change Reason code ';
2554 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2555 END IF;
2556 END IF;
2557 x_return_status := FND_API.G_RET_STS_ERROR;
2558 l_any_error_occurred_flag := 'Y';
2559
2560 --RAISE FND_API.G_EXC_ERROR;
2561
2562 ELSE
2563
2564 CLOSE l_budget_change_reason_csr;
2565 END IF;
2566
2567
2568
2569 END IF;--IF (p_change_reason_code IS NOT NULL AND
2570 --dbms_output.put_line('Leaving val header info');
2571 IF(l_debug_mode='Y') THEN
2572 pa_debug.g_err_stage := 'Leaving validate_header_info';
2573 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2574 END IF;
2575
2576 -- Stop further processing if any errors are reported
2577 --dbms_output.put_line('MSG count in the stack ' || FND_MSG_PUB.count_msg);
2578 IF(l_any_error_occurred_flag='Y') THEN
2579 IF(l_debug_mode='Y') THEN
2580 pa_debug.g_err_stage := 'About to display all the messages';
2581 pa_debug.write( l_module_name,pa_debug.g_err_stage,l_debug_level5);
2582 END IF;
2583 x_return_status := FND_API.G_RET_STS_ERROR;
2584 l_any_error_occurred_flag := 'Y';
2585 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
2586 END IF;
2587
2588 IF l_debug_mode = 'Y' THEN
2589 pa_debug.reset_curr_function;
2590 END IF;
2591 EXCEPTION
2592
2593 WHEN PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc THEN
2594 IF x_return_status IS NULL OR
2595 x_return_status = FND_API.G_RET_STS_SUCCESS THEN
2596 x_return_status := FND_API.G_RET_STS_ERROR;
2597 END IF;
2598
2599 l_msg_count := FND_MSG_PUB.count_msg;
2600 --dbms_output.put_line('MSG count in the stack ' || l_msg_count);
2601
2602 IF l_msg_count = 1 AND x_msg_data IS NULL THEN
2603 PA_INTERFACE_UTILS_PUB.get_messages
2604 (p_encoded => FND_API.G_TRUE,
2605 p_msg_index => 1,
2606 p_msg_count => l_msg_count,
2607 p_msg_data => l_msg_data,
2608 p_data => l_data,
2609 p_msg_index_out => l_msg_index_out);
2610
2611 x_msg_data := l_data;
2612 x_msg_count := l_msg_count;
2613 ELSE
2614 x_msg_count := l_msg_count;
2615 END IF;
2616 --dbms_output.put_line('MSG count in the stack ' || l_msg_count);
2617
2618 IF l_debug_mode = 'Y' THEN
2619 pa_debug.reset_curr_function;
2620 END IF;
2621 RETURN;
2622
2623 WHEN OTHERS THEN
2624 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
2625 x_msg_count := 1;
2626 x_msg_data := SQLERRM;
2627
2628 FND_MSG_PUB.add_exc_msg
2629 ( p_pkg_name => 'PA_BUDGET_PVT'
2630 ,p_procedure_name => 'VALIDATE_HEADER_INFO'
2631 ,p_error_text => sqlerrm);
2632
2633 IF l_debug_mode = 'Y' THEN
2634 pa_debug.G_Err_Stack := SQLERRM;
2635 pa_debug.write( l_module_name,pa_debug.G_Err_Stack,4);
2636 pa_debug.reset_curr_function;
2637 END IF;
2638 RAISE;
2639
2640 END VALIDATE_HEADER_INFO;
2641
2642
2643 --###This API is an overloaded version of an already existing procedure. It is
2644 --created as part of FP.M Changes for FP AMG Apis. All header level validations
2645 --required for PA_BUDGET_PUB.add_budget_line have been added to this API.
2646 --This API handles validations for budget versions in new as well as old models.
2647
2648 -- 26-APR-2005 Ritesh Shukla Created.
2649 -- 01-Jun-2005 Ritesh Shukla Bug 4224464: Commented out the budgetary control check
2650 -- in this API as per the discussions between PM and Dev.
2651 -- At present this API is being called from following APIs:
2652 -- PA_BUDGET_PBU.add_budget_line
2653 -- PA_BUDGET_PBU.update_budget_line
2654 -- PA_BUDGET_PBU.delete_budget_line
2655 -- PA_BUDGET_PBU.update_budget
2656 -- These APIs do not require the budgetary control check.
2657 -- If in future this API is called from any API that
2658 -- requires the budgetary control check then this code may
2659 -- be uncommented and following design suggested by
2660 -- Jeff White (PM) may be used. "Add a IN-paramter,
2661 -- say p_budgetary_control_flag (Y to enforece edit,
2662 -- N to disable edit) Default 'N'.
2663 --
2664 -- 27-SEP-2005 jwhite -Bug 4588279
2665 -- For overloaded procedure Validate_Header_Info,
2666 -- 1) Renabled the budgetary control api call.
2667 -- 2) Rewrote logic to populate a package global for budget LINE validation
2668 -- by pa_budget_check_pvt.GET_VALID_PERIOD_DATES_PVT procedure.
2669 --
2670 -- Note:
2671 -- 1) For the PA_BUDGET_PBU.delete_budget_line, this procedure is NOT impacted
2672 -- by these code changes. Also, it is OK to delete budget lines for
2673 -- budgetary control project/budget-types.
2674 -- 21-Oct-2008 rthumma -Bug 7498493
2675 -- Added a variable px_pa_project_id_tmp to prevent the error
2676 -- PA_PROJECT_REF_AND_ID_MISSING
2677 --
2678 --
2679
2680
2681
2682
2683 PROCEDURE Validate_Header_Info
2684 ( p_api_version_number IN NUMBER
2685 ,p_api_name IN VARCHAR2
2686 ,p_init_msg_list IN VARCHAR2
2687 ,px_pa_project_id IN OUT NOCOPY NUMBER
2688 ,p_pm_project_reference IN VARCHAR2
2689 ,p_pm_product_code IN VARCHAR2
2690 ,px_budget_type_code IN OUT NOCOPY VARCHAR2
2691 ,px_fin_plan_type_id IN OUT NOCOPY NUMBER
2692 ,px_fin_plan_type_name IN OUT NOCOPY VARCHAR2
2693 ,px_version_type IN OUT NOCOPY VARCHAR2
2694 ,p_budget_version_number IN NUMBER
2695 ,p_change_reason_code IN VARCHAR2
2696 ,p_function_name IN VARCHAR2
2697 ,x_budget_entry_method_code OUT NOCOPY VARCHAR2
2698 ,x_resource_list_id OUT NOCOPY NUMBER
2699 ,x_budget_version_id OUT NOCOPY NUMBER
2700 ,x_fin_plan_level_code OUT NOCOPY VARCHAR2
2701 ,x_time_phased_code OUT NOCOPY VARCHAR2
2702 ,x_plan_in_multi_curr_flag OUT NOCOPY VARCHAR2
2703 ,x_budget_amount_code OUT NOCOPY VARCHAR2
2704 ,x_categorization_code OUT NOCOPY VARCHAR2
2705 ,x_project_number OUT NOCOPY VARCHAR2
2706 /* Plan Amount Entry flags introduced by bug 6408139 */
2707 ,px_raw_cost_flag IN OUT NOCOPY VARCHAR2
2708 ,px_burdened_cost_flag IN OUT NOCOPY VARCHAR2
2709 ,px_revenue_flag IN OUT NOCOPY VARCHAR2
2710 ,px_cost_qty_flag IN OUT NOCOPY VARCHAR2
2711 ,px_revenue_qty_flag IN OUT NOCOPY VARCHAR2
2712 ,px_all_qty_flag IN OUT NOCOPY VARCHAR2
2713 ,px_bill_rate_flag IN OUT NOCOPY VARCHAR2
2714 ,px_cost_rate_flag IN OUT NOCOPY VARCHAR2
2715 ,px_burden_rate_flag IN OUT NOCOPY VARCHAR2
2716 /* Plan Amount Entry flags introduced by bug 6408139 */
2717 ,x_msg_count OUT NOCOPY NUMBER
2718 ,x_msg_data OUT NOCOPY VARCHAR2
2719 ,x_return_status OUT NOCOPY VARCHAR2)
2720
2721 IS
2722
2723 --This cursor is used to check if a fin_plan_type_id is
2724 --used to store workplan data
2725 CURSOR l_use_for_wp_csr
2726 ( p_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE)
2727 IS
2728 SELECT 1
2729 FROM pa_fin_plan_types_b
2730 WHERE fin_plan_type_id = p_fin_plan_type_id
2731 AND use_for_workplan_flag = 'Y';
2732
2733 --Cursor to get the details of the budget entry method passed
2734 CURSOR l_budget_entry_method_csr
2735 (c_budget_entry_method_code pa_budget_entry_methods.budget_entry_method_code%type )
2736 IS
2737 SELECT entry_level_code
2738 ,categorization_code
2739 ,time_phased_type_code
2740 FROM pa_budget_entry_methods
2741 WHERE budget_entry_method_code = c_budget_entry_method_code
2742 AND trunc(sysdate) BETWEEN trunc(start_date_active) and trunc(nvl(end_date_active,sysdate));
2743
2744 --Cursor to get the plan type details of the version being created.
2745 CURSOR l_proj_fp_options_csr
2746 ( c_project_id pa_projects.project_id%TYPE
2747 ,c_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE
2748 ,c_version_type pa_budget_versions.version_type%TYPE
2749 ,c_fin_plan_version_id pa_budget_versions.budget_version_id%TYPE)
2750 IS
2751 SELECT nvl(plan_in_multi_curr_flag,'N') multi_curr_flag
2752 ,decode(c_version_type,
2753 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST, cost_fin_plan_level_code,
2754 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE, revenue_fin_plan_level_code,
2755 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL, all_fin_plan_level_code) fin_plan_level_code
2756 ,decode(c_version_type,
2757 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST, cost_resource_list_id,
2758 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE, revenue_resource_list_id,
2759 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL, all_resource_list_id) resource_list_id
2760 ,decode(c_version_type,
2761 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST, cost_time_phased_code,
2762 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE, revenue_time_phased_code,
2763 PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL, all_time_phased_code) time_phased_code
2764 FROM pa_proj_fp_options
2765 WHERE project_id=c_project_id
2766 AND fin_plan_type_id=c_fin_plan_type_id
2767 AND fin_plan_version_id = c_fin_plan_version_id;
2768
2769
2770 -- Cursor to get the segment 1 of the project.
2771 CURSOR l_amg_project_csr
2772 (c_project_id pa_projects_all.project_id%TYPE)
2773 IS
2774 SELECT segment1
2775 FROM pa_projects_all
2776 WHERE project_id=c_project_id;
2777
2778 -- Cursor used in validating the product code
2779 Cursor p_product_code_csr (c_pm_product_code IN VARCHAR2)
2780 Is
2781 Select 'X'
2782 from pa_lookups
2783 where lookup_type='PM_PRODUCT_CODE'
2784 and lookup_code = c_pm_product_code;
2785
2786 -- needed to get the related budget_version, entry_method and resource_list
2787 CURSOR l_budget_version_csr
2788 ( c_project_id NUMBER
2789 , c_budget_type_code VARCHAR2 )
2790 IS
2791 SELECT budget_version_id
2792 , budget_entry_method_code
2793 , resource_list_id
2794 FROM pa_budget_versions
2795 WHERE project_id = c_project_id
2796 AND budget_type_code = c_budget_type_code
2797 AND budget_status_code = 'W'
2798 AND ci_id IS NULL;
2799
2800 --Cursor to get FinPlan ver id for a FinPlan version
2801 CURSOR l_finplan_version_id_csr
2802 (c_project_id NUMBER
2803 ,c_fin_plan_type_id NUMBER
2804 ,c_version_type VARCHAR2
2805 ,c_version_number NUMBER )
2806 IS
2807 SELECT budget_version_id
2808 FROM pa_budget_versions
2809 WHERE project_id=c_project_id
2810 AND fin_plan_type_id=c_fin_plan_type_id
2811 AND version_type=c_version_type
2812 AND version_number=c_version_number
2813 AND budget_status_code='W'
2814 AND ci_id is null;
2815
2816 l_data VARCHAR2(2000);
2817 l_msg_index_out NUMBER;
2818 l_debug_mode VARCHAR2(1);
2819 l_module_name VARCHAR2(80);
2820
2821 l_security_ret_code VARCHAR2(1);
2822 l_dummy NUMBER;
2823 l_dummy1 VARCHAR2(1); -- Bug 5359585;
2824 l_debug_level2 CONSTANT NUMBER := 2;
2825 l_debug_level3 CONSTANT NUMBER := 3;
2826 l_debug_level4 CONSTANT NUMBER := 4;
2827 l_debug_level5 CONSTANT NUMBER := 5;
2828 l_pm_product_code VARCHAR2(2) :='Z';
2829 l_result VARCHAR2(30);
2830 l_locked_by_persion_id pa_budget_versions.locked_by_person_id%TYPE;
2831 l_val_err_code VARCHAR2(30);
2832
2833 -- Following variable will be set when atleast one error
2834 -- is reported while validating the input parameters
2835 -- passed by the user
2836 l_any_error_occurred_flag VARCHAR2(1) :='N';
2837
2838 l_context_info pa_fin_plan_types_tl.name%TYPE;
2839 l_plan_processing_code pa_budget_versions.plan_processing_code%TYPE;
2840
2841 --Local variables needed for calling Funds Check API
2842 l_fck_req_flag VARCHAR2(1) := NULL;
2843 l_bdgt_intg_flag VARCHAR2(1) := NULL;
2844 l_bdgt_ver_id NUMBER := NULL;
2845 l_encum_type_id NUMBER := NULL;
2846
2847 l_balance_type VARCHAR2(1) := NULL;
2848
2849 l_targ_request_id pa_budget_versions.request_id%TYPE;
2850 /*Variables added for bug 6408139*/
2851 l_amount_set_id pa_proj_fp_options.all_amount_set_id%TYPE;
2852 lx_raw_cost_flag VARCHAR2(1) ;
2853 lx_burdened_cost_flag VARCHAR2(1);
2854 lx_revenue_flag VARCHAR2(1);
2855 lx_cost_qty_flag VARCHAR2(1);
2856 lx_revenue_qty_flag VARCHAR2(1);
2857 lx_all_qty_flag VARCHAR2(1);
2858 lx_bill_rate_flag VARCHAR2(1);
2859 lx_cost_rate_flag VARCHAR2(1);
2860 lx_burden_rate_flag VARCHAR2(1);
2861 px_pa_project_id_tmp NUMBER := NULL; /* Bug 7498493 */
2862
2863 px_fin_plan_type_id_in pa_fin_plan_types_b.fin_plan_type_id%TYPE; --Bug 6920539
2864
2865 BEGIN
2866
2867
2868 x_msg_count :=0;
2869 x_return_status := FND_API.G_RET_STS_SUCCESS;
2870 l_debug_mode := NVL(FND_PROFILE.value('PA_DEBUG_MODE'),'N');
2871 l_module_name := g_module_name || 'validate_header_info: ';
2872
2873 IF l_debug_mode = 'Y' THEN
2874 pa_debug.set_curr_function( p_function => 'validate_header_info',
2875 p_debug_mode => l_debug_mode );
2876 END IF;
2877
2878 -- Initialize the message table if requested.
2879 IF FND_API.TO_BOOLEAN( p_init_msg_list )
2880 THEN
2881 FND_MSG_PUB.initialize;
2882 END IF;
2883
2884 IF l_debug_mode = 'Y' THEN
2885 pa_debug.g_err_stage:= 'Validating input parameters';
2886 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
2887 END IF;
2888
2889
2890 --Standard call to check for call compatibility.
2891 --We do not perform the call compatibility check if p_api_name
2892 --is null. Internal APIs should pass this parameter as null.
2893 IF p_api_name IS NOT NULL THEN
2894 IF NOT FND_API.compatible_api_call ( PA_BUDGET_PUB.g_api_version_number,
2895 p_api_version_number ,
2896 p_api_name ,
2897 PA_BUDGET_PUB.G_PKG_NAME )
2898 THEN
2899 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2900 END IF;
2901 END IF;
2902
2903 --Convert following IN parameters from G_PA_MISS_XXX to null
2904
2905 IF px_pa_project_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
2906 px_pa_project_id := NULL;
2907 END IF;
2908
2909 IF px_budget_type_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
2910 px_budget_type_code := NULL;
2911 END IF;
2912
2913 IF px_fin_plan_type_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
2914 px_fin_plan_type_id := NULL;
2915 END IF;
2916
2917 IF px_fin_plan_type_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
2918 px_fin_plan_type_name := NULL;
2919 END IF;
2920
2921 IF px_version_type = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR THEN
2922 px_version_type := NULL;
2923 END IF;
2924
2925 -- Both Budget Type Code and Fin Plan Type Id should not be null
2926 IF (px_budget_type_code IS NULL AND px_fin_plan_type_name IS NULL AND
2927 px_fin_plan_type_id IS NULL) THEN
2928
2929 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
2930 PA_UTILS.ADD_MESSAGE
2931 (p_app_short_name => 'PA',
2932 p_msg_name => 'PA_BUDGET_FP_BOTH_MISSING');
2933 END IF;
2934
2935 IF l_debug_mode = 'Y' THEN
2936 pa_debug.g_err_stage:= 'Fin Plan type info and budget type info are missing';
2937 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
2938 END IF;
2939
2940 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
2941
2942 END IF;
2943
2944 -- Both Budget Type Code and Fin Plan Type Id should not be not null
2945
2946 IF ((px_budget_type_code IS NOT NULL) AND
2947 (px_fin_plan_type_name IS NOT NULL OR px_fin_plan_type_id IS NOT NULL)) THEN
2948
2949 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
2950 PA_UTILS.ADD_MESSAGE
2951 (p_app_short_name => 'PA',
2952 p_msg_name => 'PA_BUDGET_FP_BOTH_NOT_NULL');
2953 END IF;
2954
2955 IF l_debug_mode = 'Y' THEN
2956 pa_debug.g_err_stage:= 'Fin Plan type info and budget type info both are provided';
2957 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
2958 END IF;
2959
2960 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
2961
2962 END IF;
2963
2964 --product_code is mandatory
2965 IF p_pm_product_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
2966 OR p_pm_product_code IS NULL
2967 THEN
2968 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
2969 THEN
2970 PA_INTERFACE_UTILS_PUB.map_new_amg_msg
2971 ( p_old_message_code => 'PA_PRODUCT_CODE_IS_MISSING'
2972 ,p_msg_attribute => 'CHANGE'
2973 ,p_resize_flag => 'N'
2974 ,p_msg_context => 'GENERAL'
2975 ,p_attribute1 => ''
2976 ,p_attribute2 => ''
2977 ,p_attribute3 => ''
2978 ,p_attribute4 => ''
2979 ,p_attribute5 => '');
2980 END IF;
2981 IF l_debug_mode = 'Y' THEN
2982 pa_debug.g_err_stage:= 'PM Product code is missing';
2983 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
2984 END IF;
2985
2986 x_return_status := FND_API.G_RET_STS_ERROR;
2987 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
2988
2989 ELSE --p_pm_product_code is not null
2990
2991 OPEN p_product_code_csr (p_pm_product_code);
2992 FETCH p_product_code_csr INTO l_pm_product_code;
2993 CLOSE p_product_code_csr;
2994 IF l_pm_product_code <> 'X'
2995 THEN
2996 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
2997 THEN
2998 pa_interface_utils_pub.map_new_amg_msg
2999 ( p_old_message_code => 'PA_PRODUCT_CODE_IS_INVALID'
3000 ,p_msg_attribute => 'CHANGE'
3001 ,p_resize_flag => 'N'
3002 ,p_msg_context => 'GENERAL'
3003 ,p_attribute1 => ''
3004 ,p_attribute2 => ''
3005 ,p_attribute3 => ''
3006 ,p_attribute4 => ''
3007 ,p_attribute5 => '');
3008 END IF;
3009 IF l_debug_mode = 'Y' THEN
3010 pa_debug.g_err_stage:= 'PM Product code is invalid';
3011 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3012 END IF;
3013
3014 x_return_status := FND_API.G_RET_STS_ERROR;
3015 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3016 END IF;
3017 END IF;-- p_pm_product_code IS NULL
3018
3019
3020 -- convert pm_project_reference to id
3021 Pa_project_pvt.Convert_pm_projref_to_id (
3022 p_pm_project_reference => p_pm_project_reference,
3023 p_pa_project_id => px_pa_project_id,
3024 p_out_project_id => px_pa_project_id_tmp, /* Bug 7498493 */
3025 p_return_status => x_return_status );
3026
3027 IF px_pa_project_id_tmp IS NOT NULL then /* Bug 7498493 */
3028 px_pa_project_id := px_pa_project_id_tmp;
3029 END IF;
3030
3031 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
3032 THEN
3033 IF l_debug_mode = 'Y' THEN
3034 pa_debug.g_err_stage:= 'Unexpected error while deriving project id';
3035 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3036 END IF;
3037 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3038
3039 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
3040 THEN
3041 IF l_debug_mode = 'Y' THEN
3042 pa_debug.g_err_stage:= 'Error while deriving project id';
3043 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3044 END IF;
3045
3046 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3047
3048 END IF;
3049
3050 PA_INTERFACE_UTILS_PUB.G_PROJECT_ID := px_pa_project_id;
3051
3052 -- Get the segment 1 of the project so that it can be used in the
3053 -- later part of the code
3054 OPEN l_amg_project_csr( px_pa_project_id );
3055 FETCH l_amg_project_csr INTO x_project_number;
3056 CLOSE l_amg_project_csr;
3057
3058
3059 -- Bug 4588279, 27-SEP-05, jwhite -----------------------------------------
3060 -- Initialize for Budget LINE Conditional Validation
3061
3062 -- Storing -99 here is essential for proper Budget LINE conditional validation
3063 -- for both the budget_type and FP models.
3064
3065 PA_BUDGET_PUB.G_Latest_Encumbrance_Year := -99;
3066
3067
3068 -- End Bug 4588279, 27-SEP-05, jwhite -----------------------------------------
3069
3070
3071
3072
3073 -- Do the validations required for the BUDGET_TYPE_CODE budget model
3074 IF (px_budget_type_code IS NOT NULL) THEN
3075
3076
3077 --Check for the security
3078 PA_PM_FUNCTION_SECURITY_PUB.CHECK_BUDGET_SECURITY (
3079 p_api_version_number => p_api_version_number
3080 ,p_project_id => px_pa_project_id
3081 ,p_calling_context => PA_FP_CONSTANTS_PKG.G_CALLING_MODULE_BUDGET
3082 ,p_function_name => p_function_name
3083 ,p_version_type => null
3084 ,x_return_status => x_return_status
3085 ,x_ret_code => l_security_ret_code );
3086
3087 -- the above API adds the error message to stack. Hence the message is not added here.
3088 -- Also, as security check is important further validations are not done in case this
3089 -- validation fails.
3090 IF (x_return_status<>FND_API.G_RET_STS_SUCCESS OR
3091 l_security_ret_code = 'N') THEN
3092
3093 IF l_debug_mode = 'Y' THEN
3094 pa_debug.g_err_stage:= 'Security API Failed';
3095 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3096 END IF;
3097
3098 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3099 END IF;
3100
3101 --Verify Budget Type and get the budget amount code.
3102 OPEN l_budget_amount_code_csr( px_budget_type_code );
3103 FETCH l_budget_amount_code_csr
3104 INTO x_budget_amount_code;
3105
3106 IF l_budget_amount_code_csr%NOTFOUND
3107 THEN
3108 CLOSE l_budget_amount_code_csr;
3109 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3110 THEN
3111 pa_interface_utils_pub.map_new_amg_msg
3112 ( p_old_message_code => 'PA_BUDGET_TYPE_IS_INVALID'
3113 ,p_msg_attribute => 'CHANGE'
3114 ,p_resize_flag => 'N'
3115 ,p_msg_context => 'BUDG'
3116 ,p_attribute1 => x_project_number
3117 ,p_attribute2 => ''
3118 ,p_attribute3 => px_budget_type_code
3119 ,p_attribute4 => ''
3120 ,p_attribute5 => '');
3121 END IF;
3122 x_return_status := FND_API.G_RET_STS_ERROR;
3123
3124 IF l_debug_mode = 'Y' THEN
3125 pa_debug.g_err_stage:= 'Budget type is invalid';
3126 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3127 END IF;
3128
3129 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3130 ELSE
3131 CLOSE l_budget_amount_code_csr;
3132 END IF; --End of l_budget_amount_code_csr%NOTFOUND
3133
3134
3135 --Verify that the budget is not of type FORECASTING_BUDGET_TYPE
3136 IF px_budget_type_code='FORECASTING_BUDGET_TYPE' THEN
3137 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3138 THEN
3139 PA_UTILS.add_message
3140 (p_app_short_name => 'PA',
3141 p_msg_name => 'PA_FP_CANT_EDIT_FCST_BUD_TYPE');
3142 END IF;
3143 IF l_debug_mode = 'Y' THEN
3144 pa_debug.g_err_stage := 'Budget of type FORECASTING_BUDGET_TYPE' ;
3145 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3146 END IF;
3147 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3148 END IF;
3149
3150 -- Budgetary Control Check
3151 -- Bug 4588279, 27-SEP-05, jwhite -----------------------------------------
3152
3153 -- If project/budget-type enabled for budgetary control, then a package spec
3154 -- global is used for budget LINE validation by the lower-level
3155 -- pa_budget_check_pvt.GET_VALID_PERIOD_DATES_PVT procedure.
3156
3157
3158
3159 --Check if budgetary control is enabled for the given project and
3160 --budget type code.
3161 PA_BUDGET_FUND_PKG.get_budget_ctrl_options
3162 ( p_project_Id => px_pa_project_id
3163 , p_budget_type_code => px_budget_type_code
3164 , p_calling_mode => 'BUDGET'
3165 , x_fck_req_flag => l_fck_req_flag
3166 , x_bdgt_intg_flag => l_bdgt_intg_flag
3167 , x_bdgt_ver_id => l_bdgt_ver_id
3168 , x_encum_type_id => l_encum_type_id
3169 , x_balance_type => l_balance_type
3170 , x_return_status => x_return_status
3171 , x_msg_data => x_msg_data
3172 , x_msg_count => x_msg_count
3173 );
3174
3175 -- calling api above adds the error message to stack hence not adding the error message here.
3176 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
3177 THEN
3178 IF l_debug_mode = 'Y' THEN
3179 pa_debug.g_err_stage:= 'get_budget_ctrl_options returned unexp error';
3180 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3181 END IF;
3182 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3183
3184 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
3185 THEN
3186 IF l_debug_mode = 'Y' THEN
3187 pa_debug.g_err_stage:= 'get_budget_ctrl_options returned error';
3188 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3189 END IF;
3190 l_any_error_occurred_flag := 'Y';
3191 END IF;
3192
3193
3194 --If funds check is required then this budget cannot be inserted or updated thru AMG interface
3195 --FOR PERIOD_YEARS THAT FALL AFTER THE LATEST ENCUMBRANCE YEAR.
3196 --Deletes are OK.
3197
3198
3199 IF (nvl(l_fck_req_flag,'N') = 'Y')
3200 THEN
3201
3202 --RE-Populate global for subsequent conditional budget LINE validation
3203 -- Storing a value other than -99 is essential to conditional LINE validation
3204
3205 PA_BUDGET_PVT.Get_Latest_BC_Year
3206 ( p_pa_project_id => px_pa_project_id
3207 ,x_latest_encumbrance_year => PA_BUDGET_PUB.G_Latest_Encumbrance_Year
3208 ,x_return_status => x_return_status
3209 ,x_msg_count => x_msg_count
3210 ,x_msg_data => x_msg_data
3211 );
3212
3213
3214 -- calling api above adds the error message to stack hence not adding the error message here.
3215 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
3216 THEN
3217 IF l_debug_mode = 'Y' THEN
3218 pa_debug.g_err_stage:= 'Get_Latest_BC_Year returned unexp error';
3219 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3220 END IF;
3221 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
3222 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
3223 THEN
3224 IF l_debug_mode = 'Y' THEN
3225 pa_debug.g_err_stage:= 'Get_Latest_BC_Year returned error';
3226 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3227 END IF;
3228 l_any_error_occurred_flag := 'Y';
3229 END IF;
3230
3231
3232 /* Since PA.M, this rule no longer applies for bugetary control
3233 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3234 THEN
3235 pa_interface_utils_pub.map_new_amg_msg
3236 ( p_old_message_code => 'PA_BC_BGT_TYPE_IS_BAD_AMG'
3237 ,p_msg_attribute => 'CHANGE'
3238 ,p_resize_flag => 'N'
3239 ,p_msg_context => 'BUDG'
3240 ,p_attribute1 => x_project_number
3241 ,p_attribute2 => ''
3242 ,p_attribute3 => px_budget_type_code
3243 ,p_attribute4 => ''
3244 ,p_attribute5 => '');
3245
3246 x_return_status := FND_API.G_RET_STS_ERROR;
3247 l_any_error_occurred_flag := 'Y';
3248 END IF;
3249 */
3250
3251 END IF; --(nvl(l_fck_req_flag,'N') = 'Y')
3252
3253
3254 -- Bug 4588279, 27-SEP-05, jwhite -----------------------------------------
3255
3256
3257 --Get the budget_version_id, budget_entry_method_code and resource_list_id
3258 --from table pa_budget_version
3259 OPEN l_budget_version_csr( px_pa_project_id
3260 , px_budget_type_code );
3261 FETCH l_budget_version_csr
3262 INTO x_budget_version_id
3263 , x_budget_entry_method_code
3264 , x_resource_list_id;
3265
3266 IF l_budget_version_csr%NOTFOUND
3267 THEN
3268 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3269 THEN
3270 pa_interface_utils_pub.map_new_amg_msg
3271 ( p_old_message_code => 'PA_NO_BUDGET_VERSION'
3272 ,p_msg_attribute => 'CHANGE'
3273 ,p_resize_flag => 'N'
3274 ,p_msg_context => 'BUDG'
3275 ,p_attribute1 => x_project_number
3276 ,p_attribute2 => ''
3277 ,p_attribute3 => px_budget_type_code
3278 ,p_attribute4 => ''
3279 ,p_attribute5 => '');
3280 END IF;
3281
3282 CLOSE l_budget_version_csr;
3283 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3284
3285 END IF;--l_budget_version_csr%NOTFOUND
3286
3287 CLOSE l_budget_version_csr;
3288
3289 --entry method code is mandatory
3290 IF x_budget_entry_method_code IS NULL
3291 OR x_budget_entry_method_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
3292 THEN
3293
3294 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3295 THEN
3296 pa_interface_utils_pub.map_new_amg_msg
3297 (p_old_message_code => 'PA_ENTRY_METHOD_IS_MISSING'
3298 ,p_msg_attribute => 'CHANGE'
3299 ,p_resize_flag => 'N'
3300 ,p_msg_context => 'BUDG'
3301 ,p_attribute1 => x_project_number
3302 ,p_attribute2 => ''
3303 ,p_attribute3 => px_budget_type_code
3304 ,p_attribute4 => ''
3305 ,p_attribute5 => '');
3306 END IF;
3307
3308 x_return_status := FND_API.G_RET_STS_ERROR;
3309 l_any_error_occurred_flag := 'Y';
3310 IF l_debug_mode = 'Y' THEN
3311 pa_debug.g_err_stage:= 'Budget entry method is missing';
3312 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3313 END IF;
3314
3315 ELSE -- entry method is not null
3316
3317 -- check validity of this budget entry method code, and store associated fields in record
3318 OPEN l_budget_entry_method_csr(x_budget_entry_method_code);
3319 FETCH l_budget_entry_method_csr INTO x_fin_plan_level_code
3320 ,x_categorization_code
3321 ,x_time_phased_code;
3322
3323 IF l_budget_entry_method_csr%NOTFOUND
3324 THEN
3325 CLOSE l_budget_entry_method_csr;
3326 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3327 THEN
3328 pa_interface_utils_pub.map_new_amg_msg
3329 ( p_old_message_code => 'PA_ENTRY_METHOD_IS_INVALID'
3330 ,p_msg_attribute => 'CHANGE'
3331 ,p_resize_flag => 'N'
3332 ,p_msg_context => 'BUDG'
3333 ,p_attribute1 => x_project_number
3334 ,p_attribute2 => ''
3335 ,p_attribute3 => px_budget_type_code
3336 ,p_attribute4 => ''
3337 ,p_attribute5 => '');
3338 END IF;
3339 x_return_status := FND_API.G_RET_STS_ERROR;
3340 l_any_error_occurred_flag := 'Y';
3341 IF l_debug_mode = 'Y' THEN
3342 pa_debug.g_err_stage:= 'Budget entry method is invalid';
3343 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3344 END IF;
3345 ELSE
3346 CLOSE l_budget_entry_method_csr;
3347 END IF;--l_budget_entry_method_csr%NOTFOUND
3348
3349 END IF;--x_budget_entry_method_code IS NULL
3350
3351
3352 ELSE -- Validations for fin plan model
3353
3354 px_fin_plan_type_id_in := px_fin_plan_type_id; --Bug 6920539
3355
3356 PA_FIN_PLAN_PVT.convert_plan_type_name_to_id
3357 ( p_fin_plan_type_id => px_fin_plan_type_id_in
3358 ,p_fin_plan_type_name => px_fin_plan_type_name
3359 ,x_fin_plan_type_id => px_fin_plan_type_id
3360 ,x_return_status => x_return_status
3361 ,x_msg_count => x_msg_count
3362 ,x_msg_data => x_msg_data);
3363
3364 -- Throw the error if the above API is not successfully executed
3365 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3366 IF l_debug_mode = 'Y' THEN
3367 pa_debug.g_err_stage := 'Cannot get the value of Fin Plan Type Id' ;
3368 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3369 END IF;
3370 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3371 END IF;
3372
3373 --We need to check use_for_workplan_flag as workplan versions
3374 --cannot be edited using this AMG interface.
3375 --reset the value of l_dummy
3376 l_dummy := 0;
3377 OPEN l_use_for_wp_csr( px_fin_plan_type_id );
3378 FETCH l_use_for_wp_csr INTO l_dummy;
3379 CLOSE l_use_for_wp_csr;
3380
3381 IF l_dummy = 1
3382 THEN
3383 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3384 THEN
3385 PA_UTILS.add_message
3386 (p_app_short_name => 'PA',
3387 p_msg_name => 'PA_FP_CANT_EDIT_WP_DATA');
3388 END IF;
3389 IF l_debug_mode = 'Y' THEN
3390 pa_debug.g_err_stage := 'Fin Plan Type Id is used for WP' ;
3391 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3392 END IF;
3393
3394 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3395
3396 END IF;
3397
3398
3399
3400 -- Derive the version type. An error will be thrown by this api if preference code is
3401 -- COST_AND_REV_SEP and version type is not passed
3402 pa_fin_plan_utils.get_version_type
3403 ( p_project_id => px_pa_project_id
3404 ,p_fin_plan_type_id => px_fin_plan_type_id
3405 ,px_version_type => px_version_type
3406 ,x_return_status => x_return_status
3407 ,x_msg_count => x_msg_count
3408 ,x_msg_data => x_msg_data);
3409
3410 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3411 IF l_debug_mode = 'Y' THEN
3412 pa_debug.g_err_stage := 'Failed in get_Version_type' ;
3413 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3414 END IF;
3415 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3416 END IF;
3417
3418 --if the budget version belongs to an org forecasting project then throw an error
3419 IF px_version_type = 'ORG_FORECAST' THEN
3420 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3421 THEN
3422 PA_UTILS.add_message
3423 (p_app_short_name => 'PA',
3424 p_msg_name => 'PA_FP_ORG_FCST_PLAN_TYPE');
3425 END IF;
3426 IF l_debug_mode = 'Y' THEN
3427 pa_debug.g_err_stage := 'Org_Forecast plan type has been passed' ;
3428 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3429 END IF;
3430
3431 x_return_status := FND_API.G_RET_STS_ERROR;
3432 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3433 END IF; --org_forecast
3434
3435 --Check function security
3436 PA_PM_FUNCTION_SECURITY_PUB.CHECK_BUDGET_SECURITY (
3437 p_api_version_number => p_api_version_number
3438 ,p_project_id => px_pa_project_id
3439 ,p_fin_plan_type_id => px_fin_plan_type_id
3440 ,p_calling_context => PA_FP_CONSTANTS_PKG.G_CALLING_MODULE_FIN_PLAN
3441 ,p_function_name => p_function_name
3442 ,p_version_type => px_version_type
3443 ,x_return_status => x_return_status
3444 ,x_ret_code => l_security_ret_code );
3445
3446 IF (x_return_status <>FND_API.G_RET_STS_SUCCESS OR
3447 l_security_ret_code='N') THEN
3448 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3449 END IF;
3450
3451 --Derive the fin plan version id based on the unique combination of
3452 --project id, fin plan type id, version type and version number
3453 IF p_budget_version_number IS NOT NULL
3454 AND p_budget_Version_number <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
3455 THEN
3456
3457 OPEN l_finplan_version_id_csr( px_pa_project_id
3458 ,px_fin_plan_type_id
3459 ,px_version_type
3460 ,p_budget_version_number);
3461 FETCH l_finplan_version_id_csr INTO x_budget_version_id;
3462 CLOSE l_finplan_version_id_csr;
3463
3464 ELSE --p_budget_version_number IS NULL
3465
3466 -- Fetch the current working version for the project, finplan type and verion type
3467 PA_FIN_PLAN_UTILS.Get_Curr_Working_Version_Info(
3468 p_project_id => px_pa_project_id
3469 ,p_fin_plan_type_id => px_fin_plan_type_id
3470 ,p_version_type => px_version_type
3471 ,x_fp_options_id => l_dummy
3472 ,x_fin_plan_version_id => x_budget_version_id
3473 ,x_return_status => x_return_status
3474 ,x_msg_count => x_msg_count
3475 ,x_msg_data => x_msg_data );
3476
3477 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3478 IF l_debug_mode = 'Y' THEN
3479 pa_debug.g_err_stage := 'Get_Curr_Working_Version_Info api Failed ' ;
3480 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3481 END IF;
3482 RAISE FND_API.G_EXC_ERROR;
3483 END IF;
3484
3485 END IF; --p_budget_version_number IS NOT NULL
3486
3487 --If budget version id can't be found throw appropriate error message
3488 IF x_budget_version_id IS NULL OR x_budget_version_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
3489 THEN
3490 --Throw appropriate error message
3491 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
3492 PA_UTILS.ADD_MESSAGE
3493 (p_app_short_name => 'PA',
3494 p_msg_name => 'PA_FP_NO_WORKING_VERSION',
3495 p_token1 => 'PROJECT',
3496 p_value1 => x_project_number,
3497 p_token2 => 'PLAN_TYPE',
3498 p_value2 => px_fin_plan_type_name,
3499 p_token3 => 'VERSION_NUMBER',
3500 p_value3 => p_budget_Version_number );
3501 END IF;
3502
3503 IF l_debug_mode = 'Y' THEN
3504 pa_debug.g_err_stage := 'Budget Version does not exist' ;
3505 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3506 END IF;
3507 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3508
3509 END IF;--x_budget_version_id IS NULL
3510
3511 --Calling PA_FIN_PLAN_UTILS.validate_editable_bv API to check
3512 --if the budget version is locked by another user/process
3513 --or Edit after initial baseline setup is true and baseline
3514 --versions exist.
3515
3516 pa_fin_plan_utils.validate_editable_bv
3517 (p_budget_version_id => x_budget_version_id,
3518 p_user_id => FND_GLOBAL.user_id,
3519 p_context => PA_FP_CONSTANTS_PKG.G_AMG_API,
3520 x_locked_by_person_id => l_locked_by_persion_id,
3521 x_err_code => l_val_err_code,
3522 x_return_status => x_return_status,
3523 x_msg_count => x_msg_count,
3524 x_msg_data => x_msg_data);
3525
3526 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3527 IF l_debug_mode = 'Y' THEN
3528 pa_debug.g_err_stage := 'This budget version can not be edited';
3529 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3530 END IF;
3531 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3532 END IF;
3533
3534 -- Get the plan type level settings so that they can be passed as out parameters
3535 OPEN l_proj_fp_options_csr( px_pa_project_id
3536 , px_fin_plan_type_id
3537 , px_version_type
3538 , x_budget_version_id);
3539 FETCH l_proj_fp_options_csr
3540 INTO x_plan_in_multi_curr_flag
3541 ,x_fin_plan_level_code
3542 ,x_resource_list_id
3543 ,x_time_phased_code;
3544
3545 --Control will never really enter this IF block since this check is
3546 --already made inside pa_fin_plan_utils.get_version_type before
3547 --control reaches here
3548 IF (l_proj_fp_options_csr%NOTFOUND) THEN
3549 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
3550 PA_UTILS.ADD_MESSAGE
3551 (p_app_short_name => 'PA',
3552 p_msg_name => 'PA_FP_NO_PLAN_TYPE_OPTION',
3553 p_token1 => 'PROJECT',
3554 p_value1 => x_project_number,
3555 p_token2 => 'PLAN_TYPE',
3556 p_value2 => px_fin_plan_type_name);
3557 END IF;
3558 CLOSE l_proj_fp_options_csr;
3559 IF l_debug_mode = 'Y' THEN
3560 pa_debug.g_err_stage:= 'Plan type is not yet added to the project';
3561 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3562 END IF;
3563 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3564 ELSE
3565 CLOSE l_proj_fp_options_csr;
3566 END IF;--(l_proj_fp_options_csr%NOTFOUND)
3567
3568
3569 END IF; -- END OF CHECKS FOR FINPLAN MODEL
3570
3571
3572 -- check validity of the budget change reason code, passing NULL is OK
3573 IF (p_change_reason_code IS NOT NULL AND
3574 p_change_reason_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR)
3575 THEN
3576 OPEN l_budget_change_reason_csr( p_change_reason_code );
3577 FETCH l_budget_change_reason_csr INTO l_dummy1;
3578
3579 IF px_budget_type_code IS NULL THEN
3580 l_context_info := px_fin_plan_type_name;
3581 ELSE
3582 l_context_info := px_budget_type_code;
3583 END IF;
3584
3585 IF l_budget_change_reason_csr%NOTFOUND THEN
3586 CLOSE l_budget_change_reason_csr;
3587
3588 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
3589 THEN
3590 pa_interface_utils_pub.map_new_amg_msg
3591 ( p_old_message_code => 'PA_CHANGE_REASON_INVALID'
3592 ,p_msg_attribute => 'CHANGE'
3593 ,p_resize_flag => 'N'
3594 ,p_msg_context => 'BUDG'
3595 ,p_attribute1 => x_project_number
3596 ,p_attribute2 => ''
3597 ,p_attribute3 => l_context_info
3598 ,p_attribute4 => ''
3599 ,p_attribute5 => '');
3600 END IF;
3601 x_return_status := FND_API.G_RET_STS_ERROR;
3602 l_any_error_occurred_flag := 'Y';
3603 IF l_debug_mode = 'Y' THEN
3604 pa_debug.g_err_stage:= 'Invalid Change Reason code ';
3605 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3606 END IF;
3607
3608 ELSE
3609 CLOSE l_budget_change_reason_csr;
3610 END IF;
3611 END IF;--p_change_reason_code IS NOT NULL
3612
3613
3614 -- Call the api that performs the autobaseline checks
3615 PA_FIN_PLAN_UTILS.PERFORM_AUTOBASLINE_CHECKS (
3616 p_budget_version_id => x_budget_version_id
3617 ,x_result => l_result
3618 ,x_return_status => x_return_status
3619 ,x_msg_count => x_msg_count
3620 ,x_msg_data => x_msg_data );
3621
3622 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3623 IF(l_debug_mode='Y') THEN
3624 pa_debug.g_err_stage := 'Auto baseline API falied';
3625 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3626 END IF;
3627 RAISE FND_API.G_EXC_ERROR;
3628 END IF;
3629
3630 IF l_result = 'F' THEN
3631 IF(l_debug_mode='Y') THEN
3632 pa_debug.g_err_stage := 'Auto baselining enabled for the project';
3633 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3634 END IF;
3635
3636 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
3637 PA_UTILS.ADD_MESSAGE(
3638 p_app_short_name => 'PA'
3639 ,p_msg_name => 'PA_FP_AB_AR_VER_NON_EDITABLE'
3640 ,p_token1 => 'PROJECT'
3641 ,p_value1 => x_project_number);
3642 END IF;
3643
3644 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3645 END IF;
3646
3647 --Check if the Budget version has any processing errors.
3648 PA_FIN_PLAN_UTILS.return_and_vldt_plan_prc_code
3649 (p_add_msg_to_stack => 'Y'
3650 ,p_calling_context => 'BUDGET'
3651 ,p_budget_version_id => x_budget_version_id
3652 ,x_final_plan_prc_code => l_plan_processing_code
3653 ,x_targ_request_id => l_targ_request_id
3654 ,x_return_status => x_return_status
3655 ,x_msg_count => x_msg_count
3656 ,x_msg_data => x_msg_data);
3657
3658 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3659 IF(l_debug_mode='Y') THEN
3660 pa_debug.g_err_stage := 'return_and_vldt_plan_prc_code API falied';
3661 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3662 END IF;
3663 RAISE FND_API.G_EXC_ERROR;
3664 END IF;
3665
3666 /* Plan Amount Entry flags validations start : bug 6408139 */
3667 IF px_budget_type_code IS NULL THEN -- for plan versions only, we are checking the flags
3668
3669 px_raw_cost_flag := NVL (px_raw_cost_flag,'N');
3670 px_burdened_cost_flag := NVL (px_burdened_cost_flag,'N');
3671 px_revenue_flag := NVL (px_revenue_flag,'N');
3672 px_cost_qty_flag := NVL (px_cost_qty_flag,'N');
3673 px_revenue_qty_flag := NVL (px_revenue_qty_flag,'N');
3674 px_all_qty_flag := NVL (px_all_qty_flag,'N');
3675 px_bill_rate_flag := NVL (px_bill_rate_flag,'N');
3676 px_cost_rate_flag := NVL (px_cost_rate_flag,'N');
3677 px_burden_rate_flag := NVL (px_burden_rate_flag,'N');
3678
3679 /* Skip the validations if all are passed as G_PA_MISS_CHAR */
3680 IF (( px_raw_cost_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3681 ( px_burdened_cost_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3682 ( px_revenue_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3683 ( px_cost_qty_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3684 ( px_revenue_qty_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3685 ( px_all_qty_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3686 ( px_bill_rate_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3687 ( px_cost_rate_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) OR
3688 ( px_burden_rate_flag <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) ) THEN
3689
3690 /*Get the existing plan amount entry flags for the plan version*/
3691 l_amount_set_id := PA_FIN_PLAN_UTILS.get_amount_set_id(x_budget_version_id);
3692
3693 PA_FIN_PLAN_UTILS.GET_PLAN_AMOUNT_FLAGS(
3694 P_AMOUNT_SET_ID => l_amount_set_id
3695 ,X_RAW_COST_FLAG => lx_raw_cost_flag
3696 ,X_BURDENED_FLAG => lx_burdened_cost_flag
3697 ,X_REVENUE_FLAG => lx_revenue_flag
3698 ,X_COST_QUANTITY_FLAG => lx_cost_qty_flag
3699 ,X_REV_QUANTITY_FLAG => lx_revenue_qty_flag
3700 ,X_ALL_QUANTITY_FLAG => lx_all_qty_flag
3701 ,X_BILL_RATE_FLAG => lx_bill_rate_flag
3702 ,X_COST_RATE_FLAG => lx_cost_rate_flag
3703 ,X_BURDEN_RATE_FLAG => lx_burden_rate_flag
3704 ,x_message_count => x_msg_count
3705 ,x_return_status => x_return_status
3706 ,x_message_data => x_msg_data) ;
3707
3708 IF x_return_status <> FND_API.G_RET_STS_SUCCESS
3709 THEN
3710 -- RAISE FND_API.G_EXC_ERROR;
3711 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3712 END IF;
3713
3714 IF ( px_raw_cost_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3715 px_raw_cost_flag := lx_raw_cost_flag;
3716 END IF ;
3717
3718 IF ( px_burdened_cost_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3719 px_burdened_cost_flag := lx_burdened_cost_flag;
3720 END IF ;
3721
3722 IF ( px_revenue_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3723 px_revenue_flag := lx_revenue_flag;
3724 END IF ;
3725
3726 IF ( px_cost_qty_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3727 px_cost_qty_flag := lx_cost_qty_flag;
3728 END IF ;
3729
3730 IF ( px_revenue_qty_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3731 px_revenue_qty_flag := lx_revenue_qty_flag;
3732 END IF ;
3733
3734 IF ( px_all_qty_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3735 px_all_qty_flag := lx_all_qty_flag;
3736 END IF ;
3737
3738 IF ( px_bill_rate_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3739 px_bill_rate_flag := lx_bill_rate_flag;
3740 END IF ;
3741
3742 IF ( px_cost_rate_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3743 px_cost_rate_flag := lx_cost_rate_flag;
3744 END IF ;
3745
3746 IF ( px_burden_rate_flag = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR) THEN
3747 px_burden_rate_flag := lx_burden_rate_flag;
3748 END IF ;
3749
3750
3751 IF( px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST) THEN
3752
3753 IF( px_raw_cost_flag NOT IN ('Y','N')) OR
3754 ( px_burdened_cost_flag NOT IN ('Y','N')) OR
3755 ( px_cost_qty_flag NOT IN ('Y','N')) OR
3756 ( px_bill_rate_flag <> 'N' ) OR
3757 ( px_cost_rate_flag NOT IN ('Y','N')) OR
3758 ( px_burden_rate_flag NOT IN ('Y','N')) THEN
3759
3760 PA_UTILS.ADD_MESSAGE
3761 (p_app_short_name => 'PA',
3762 p_msg_name => 'PA_FP_INVALID_AMT_FLAGS',
3763 p_token1 => 'PROJECT',
3764 p_value1 => x_project_number,
3765 p_token2 => 'PLAN_TYPE',
3766 p_value2 => px_fin_plan_type_name);
3767 x_return_status := FND_API.G_RET_STS_ERROR;
3768 l_any_error_occurred_flag := 'Y';
3769
3770 IF l_debug_mode = 'Y' THEN
3771 pa_debug.g_err_stage:= 'Invalid values for amount flags ';
3772 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3773 END IF;
3774 END IF;
3775
3776
3777 IF( px_raw_cost_flag = 'N') AND
3778 ( px_burdened_cost_flag = 'N') AND
3779 ( px_cost_qty_flag = 'N') THEN
3780
3781 PA_UTILS.ADD_MESSAGE
3782 (p_app_short_name => 'PA',
3783 p_msg_name => 'PA_FP_NO_PLAN_AMT_CHECKED');
3784 x_return_status := FND_API.G_RET_STS_ERROR;
3785 l_any_error_occurred_flag := 'Y';
3786 IF l_debug_mode = 'Y' THEN
3787 pa_debug.g_err_stage:= 'None of the amount flags are Y ';
3788 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
3789 END IF;
3790 END IF;
3791
3792 ELSIF( px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE ) THEN
3793
3794 IF( px_revenue_flag NOT IN ('Y','N')) OR
3795 ( px_revenue_qty_flag NOT IN ('Y','N')) OR
3796 ( px_bill_rate_flag NOT IN ('Y','N')) OR
3797 ( px_cost_rate_flag <> 'N') OR
3798 ( px_burden_rate_flag <> 'N')THEN
3799
3800 PA_UTILS.ADD_MESSAGE
3801 (p_app_short_name => 'PA',
3802 p_msg_name => 'PA_FP_INVALID_AMT_FLAGS',
3803 p_token1 => 'PROJECT',
3804 p_value1 => x_project_number,
3805 p_token2 => 'PLAN_TYPE',
3806 p_value2 => px_fin_plan_type_name);
3807 x_return_status := FND_API.G_RET_STS_ERROR;
3808 l_any_error_occurred_flag := 'Y';
3809 IF l_debug_mode = 'Y' THEN
3810 pa_debug.g_err_stage:= 'Invalid value for the amount flags ';
3811 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
3812 END IF;
3813
3814 END IF;
3815
3816
3817 IF( px_revenue_flag ='N') AND
3818 ( px_revenue_qty_flag ='N') THEN
3819
3820 PA_UTILS.ADD_MESSAGE
3821 (p_app_short_name => 'PA',
3822 p_msg_name => 'PA_FP_NO_PLAN_AMT_CHECKED');
3823 x_return_status := FND_API.G_RET_STS_ERROR;
3824 l_any_error_occurred_flag := 'Y';
3825 IF l_debug_mode = 'Y' THEN
3826 pa_debug.g_err_stage:= 'None of the amount flags are Y ';
3827 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
3828 END IF;
3829
3830 END IF;
3831
3832 ELSIF( px_version_type = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_ALL ) THEN
3833
3834 IF( px_raw_cost_flag NOT IN ('Y','N')) OR
3835 ( px_burdened_cost_flag NOT IN ('Y','N')) OR
3836 ( px_revenue_flag NOT IN ('Y','N')) OR
3837 ( px_all_qty_flag NOT IN ('Y','N')) OR
3838 ( px_bill_rate_flag NOT IN ('Y','N')) OR
3839 ( px_cost_rate_flag NOT IN ('Y','N')) OR
3840 ( px_burden_rate_flag NOT IN ('Y','N')) THEN
3841
3842 PA_UTILS.ADD_MESSAGE
3843 (p_app_short_name => 'PA',
3844 p_msg_name => 'PA_FP_INVALID_AMT_FLAGS',
3845 p_token1 => 'PROJECT',
3846 p_value1 => x_project_number,
3847 p_token2 => 'PLAN_TYPE',
3848 p_value2 => px_fin_plan_type_name);
3849 x_return_status := FND_API.G_RET_STS_ERROR;
3850 l_any_error_occurred_flag := 'Y';
3851 IF l_debug_mode = 'Y' THEN
3852 pa_debug.g_err_stage:= 'Invalid value for the amount flags ';
3853 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
3854 END IF;
3855
3856 END IF;
3857
3858 IF( px_raw_cost_flag ='N') AND
3859 ( px_burdened_cost_flag='N') AND
3860 ( px_revenue_flag ='N') AND
3861 ( px_cost_qty_flag = 'N') AND --Fix for 7172129
3862 ( px_revenue_qty_flag ='N') AND
3863 ( px_all_qty_flag ='N') THEN
3864
3865 PA_UTILS.ADD_MESSAGE
3866 (p_app_short_name => 'PA',
3867 p_msg_name => 'PA_FP_NO_PLAN_AMT_CHECKED');
3868 x_return_status := FND_API.G_RET_STS_ERROR;
3869 l_any_error_occurred_flag := 'Y';
3870 IF l_debug_mode = 'Y' THEN
3871 pa_debug.g_err_stage:= 'None of the amount flags are Y ';
3872 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
3873 END IF;
3874
3875 END IF;
3876
3877 END IF; -- px_version_type checks
3878
3879 END IF ; -- G_PA_MISS_CHAR condition
3880
3881 END IF ; --IF px_budget_type_code IS NULL
3882
3883 /* Plan Amount Entry flags validations end : bug 6408139*/
3884
3885 -- Stop further processing if any errors are reported
3886 IF(l_any_error_occurred_flag='Y') THEN
3887 IF(l_debug_mode='Y') THEN
3888 pa_debug.g_err_stage := 'About to display all the messages';
3889 pa_debug.write( l_module_name,pa_debug.g_err_stage,l_debug_level5);
3890 END IF;
3891 x_return_status := FND_API.G_RET_STS_ERROR;
3892 l_any_error_occurred_flag := 'Y';
3893 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
3894 END IF;
3895
3896 IF(l_debug_mode='Y') THEN
3897 pa_debug.g_err_stage := 'Leaving validate_header_info';
3898 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
3899 END IF;
3900
3901 IF l_debug_mode = 'Y' THEN
3902 pa_debug.reset_curr_function;
3903 END IF;
3904
3905 EXCEPTION
3906
3907 WHEN PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc THEN
3908 IF x_return_status IS NULL
3909 OR x_return_status = FND_API.G_RET_STS_SUCCESS THEN
3910 x_return_status := FND_API.G_RET_STS_ERROR;
3911 END IF;
3912
3913 x_msg_count := FND_MSG_PUB.count_msg;
3914
3915 IF x_msg_count = 1 AND x_msg_data IS NULL THEN
3916 PA_INTERFACE_UTILS_PUB.get_messages
3917 (p_encoded => FND_API.G_TRUE,
3918 p_msg_index => 1,
3919 p_msg_count => x_msg_count,
3920 p_msg_data => x_msg_data,
3921 p_data => l_data,
3922 p_msg_index_out => l_msg_index_out);
3923 x_msg_count := l_msg_index_out;
3924 x_msg_data := l_data;
3925 END IF;
3926
3927 IF l_debug_mode = 'Y' THEN
3928 pa_debug.reset_curr_function;
3929 END IF;
3930
3931 RETURN;
3932
3933 WHEN FND_API.G_EXC_ERROR
3934 THEN
3935
3936 x_return_status := FND_API.G_RET_STS_ERROR;
3937
3938 FND_MSG_PUB.count_and_get
3939 ( p_count => x_msg_count ,
3940 p_data => x_msg_data );
3941
3942 IF ( l_debug_mode = 'Y' ) THEN
3943 pa_debug.reset_curr_function;
3944 END IF;
3945
3946 WHEN FND_API.G_EXC_UNEXPECTED_ERROR
3947 THEN
3948
3949 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3950
3951 FND_MSG_PUB.count_and_get
3952 ( p_count => x_msg_count ,
3953 p_data => x_msg_data );
3954
3955 IF ( l_debug_mode = 'Y' ) THEN
3956 pa_debug.reset_curr_function;
3957 END IF;
3958
3959 WHEN OTHERS THEN
3960 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
3961 x_msg_count := 1;
3962 x_msg_data := SQLERRM;
3963
3964 FND_MSG_PUB.add_exc_msg
3965 ( p_pkg_name => 'PA_BUDGET_PVT'
3966 ,p_procedure_name => 'VALIDATE_HEADER_INFO'
3967 ,p_error_text => sqlerrm);
3968
3969 IF l_debug_mode = 'Y' THEN
3970 pa_debug.G_Err_Stack := SQLERRM;
3971 pa_debug.reset_curr_function;
3972 END IF;
3973 RAISE;
3974
3975 END Validate_Header_Info;
3976
3977
3978 ----------------------------------------------------------------------------------------
3979 --Name: insert_budget_line
3980 --Type: Procedure
3981 --Description: This procedure can be used to insert a budgetline for
3982 -- an existing WORKING budget. Used by create_draft_budget
3983 -- and add_budget_line.
3984 --
3985 --Called subprograms:
3986 -- pa_budget_utils.create_line
3987 --
3988 --
3989 --
3990 --History:
3991 -- 18-NOV-1996 L. de Werker Created
3992 --
3993 -- 11-Feb-2002 Srikanth Modified as part of the changes for AMG in finplan model
3994 -- 10-AUG-2003 bvarnasi Bug 3062294 : rectified many bugs. See bug for more details.
3995 -- 22-OCT-2003 Rajagopal bug 2998221 : Included call to validate_budget_lines api
3996 -- for validations. l_budget_lines_in_tbl is a in/out plsql table
3997 -- which stamps task_id derived from task_reference etc. So, use
3998 -- values from l_budget_lines_in_tbl while calling create_line api
3999 -- 29-APR-2005 rishukla Bug 4224464: FP M Changes: Added parameter p_change_reason_code
4000 -- to insert_budget_line API.
4001
4002 PROCEDURE insert_budget_line
4003 ( p_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
4004 ,p_pa_project_id IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4005 ,p_budget_type_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4006 ,p_pa_task_id IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4007 ,p_pm_task_reference IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4008 ,p_resource_alias IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4009 ,p_member_id IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4010 ,p_cbs_element_id IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM --Bug 16604257 : CBS RBS Phase 2 API changes
4011 ,p_budget_start_date IN DATE := PA_INTERFACE_UTILS_PUB.G_PA_MISS_DATE
4012 ,p_budget_end_date IN DATE := PA_INTERFACE_UTILS_PUB.G_PA_MISS_DATE
4013 ,p_period_name IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4014 ,p_description IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4015 ,p_raw_cost IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4016 ,p_burdened_cost IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4017 ,p_revenue IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4018 ,p_quantity IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4019 ,p_pm_product_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4020 ,p_pm_budget_line_reference IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4021 ,p_attribute_category IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4022 ,p_attribute1 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4023 ,p_attribute2 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4024 ,p_attribute3 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4025 ,p_attribute4 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4026 ,p_attribute5 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4027 ,p_attribute6 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4028 ,p_attribute7 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4029 ,p_attribute8 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4030 ,p_attribute9 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4031 ,p_attribute10 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4032 ,p_attribute11 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4033 ,p_attribute12 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4034 ,p_attribute13 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4035 ,p_attribute14 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4036 ,p_attribute15 IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4037 ,p_resource_list_id IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4038 ,p_time_phased_type_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4039 ,p_entry_level_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4040 ,p_budget_amount_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4041 ,p_budget_entry_method_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4042 ,p_categorization_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4043 ,p_budget_version_id IN NUMBER := PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4044 ,p_change_reason_code IN VARCHAR2 := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR )--Bug 4224464
4045
4046 IS
4047
4048 l_return_status VARCHAR2(1);
4049 l_api_name CONSTANT VARCHAR2(30) := 'insert_budget_line';
4050 l_resource_assignment_id NUMBER;
4051 l_unit_of_measure VARCHAR2(30);
4052 l_track_as_labor_flag VARCHAR2(1);
4053 l_attribute_category VARCHAR2(30);
4054 l_attribute1 VARCHAR2(150);
4055 l_attribute2 VARCHAR2(150);
4056 l_attribute3 VARCHAR2(150);
4057 l_attribute4 VARCHAR2(150);
4058 l_attribute5 VARCHAR2(150);
4059 l_attribute6 VARCHAR2(150);
4060 l_attribute7 VARCHAR2(150);
4061 l_attribute8 VARCHAR2(150);
4062 l_attribute9 VARCHAR2(150);
4063 l_attribute10 VARCHAR2(150);
4064 l_attribute11 VARCHAR2(150);
4065 l_attribute12 VARCHAR2(150);
4066 l_attribute13 VARCHAR2(150);
4067 l_attribute14 VARCHAR2(150);
4068 l_attribute15 VARCHAR2(150);
4069 l_err_code NUMBER;
4070 l_err_stage VARCHAR2(120);
4071 l_err_stack VARCHAR2(630);
4072 l_amg_segment1 VARCHAR2(25);
4073 l_amg_task_number VARCHAR2(50);
4074 l_quantity NUMBER;
4075 l_raw_cost NUMBER;
4076 l_burdened_cost NUMBER;
4077 l_revenue NUMBER;
4078 -- Following local variables added as part of bug 3062294
4079 l_pa_task_id pa_resource_assignments.task_id%TYPE;
4080 l_pm_task_ref pa_tasks.pm_task_reference%TYPE;
4081 l_resource_alias pa_resource_list_members.alias%TYPE; -- bug 3711693
4082 l_rlm_id pa_resource_list_members.resource_list_member_id%TYPE;
4083 l_cbs_element_id pa_resource_assignments.cbs_element_id%TYPE;--Bug 16604257 : CBS RBS Phase 2 API changes
4084 l_budget_start_date pa_budget_lines.start_date%TYPE;
4085 l_budget_end_date pa_budget_lines.start_date%TYPE;
4086 l_period_name pa_budget_lines.period_name%TYPE;
4087 l_description pa_budget_lines.description%TYPE;
4088 l_pm_budget_line_reference pa_budget_lines.pm_budget_line_reference%TYPE;
4089 l_change_reason_code pa_budget_lines.change_reason_code%TYPE;
4090
4091 l_budget_lines_in_tbl PA_BUDGET_PUB.G_BUDGET_LINES_IN_TBL%TYPE; /* bug 2998221 */
4092 l_budget_lines_out_tbl PA_BUDGET_PUB.G_BUDGET_LINES_OUT_TBL%TYPE;
4093 i NUMBER;
4094 l_msg_data VARCHAR2(2000);
4095 l_msg_count NUMBER;
4096 l_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'),'N');
4097 l_module_name VARCHAR2(80) := 'add_budget_line: ' || g_module_name;
4098 -- l_fp_type_id pa_budget_versions.fin_plan_type_id%TYPE; --3569883
4099 -- l_old_model VARCHAR2(1):=null; --3569883
4100
4101 -- added for bug Bug 3986129: FP.M Web ADI Dev changes
4102 l_mfc_cost_type_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
4103 l_etc_method_code_tbl SYSTEM.pa_varchar2_30_tbl_type := SYSTEM.pa_varchar2_30_tbl_type();
4104 l_spread_curve_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
4105
4106 l_version_info_rec pa_fp_gen_amount_utils.fp_cols;
4107 l_pm_product_code VARCHAR2(30);
4108 l_task_id NUMBER;
4109
4110 --needed to get the field values associated to a AMG message
4111
4112 CURSOR l_amg_project_csr
4113 (p_pa_project_id pa_projects.project_id%type)
4114 IS
4115 SELECT segment1
4116 FROM pa_projects p
4117 WHERE p.project_id = p_pa_project_id;
4118
4119 --needed to get the unit_of_measure and track_as_labor_flag for this resource_list_member
4120 --and check for valid resource_list / member combination
4121
4122 CURSOR l_resource_csr
4123 (c_resource_list_member_id NUMBER
4124 ,c_resource_list_id NUMBER)
4125 IS
4126 SELECT pr.unit_of_measure
4127 ,prlm.track_as_labor_flag
4128 FROM pa_resources pr
4129 ,pa_resource_lists prl
4130 ,pa_resource_list_members prlm
4131 WHERE prl.resource_list_id = c_resource_list_id
4132 AND pr.resource_id = prlm.resource_id
4133 AND prl.resource_list_id = prlm.resource_list_id
4134 AND prlm.resource_list_member_id = c_resource_list_member_id;
4135
4136 BEGIN
4137 --Standard begin of API savepoint
4138
4139 SAVEPOINT insert_budget_line_pvt;
4140
4141 --Set API return status to success
4142
4143 p_return_status := FND_API.G_RET_STS_SUCCESS;
4144
4145 --get unit_of_measure and track_as_labor_flag associated to
4146 --the resource member and check whether this is a valid member for this list
4147 OPEN l_resource_csr( p_member_id
4148 ,p_resource_list_id );
4149 FETCH l_resource_csr INTO l_unit_of_measure, l_track_as_labor_flag;
4150 IF l_resource_csr%NOTFOUND
4151 THEN
4152 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4153 THEN
4154 pa_interface_utils_pub.map_new_amg_msg
4155 ( p_old_message_code => 'PA_LIST_MEMBER_INVALID'
4156 ,p_msg_attribute => 'CHANGE'
4157 ,p_resize_flag => 'N'
4158 ,p_msg_context => 'BUDG'
4159 ,p_attribute1 => l_amg_segment1
4160 ,p_attribute2 => l_amg_task_number
4161 ,p_attribute3 => p_budget_type_code
4162 ,p_attribute4 => ''
4163 ,p_attribute5 => to_char(p_budget_start_date));
4164 END IF;
4165
4166 CLOSE l_resource_csr;
4167 p_return_status := FND_API.G_RET_STS_ERROR;
4168 RAISE FND_API.G_EXC_ERROR;
4169
4170 ELSE
4171 CLOSE l_resource_csr;
4172
4173 END IF;
4174
4175 /*****************************
4176 Bug 3218822 - PM_PRODUCT_CODE could be Null. We need valid it if it is NOT NULL.
4177 This will be done in validate_budget_lines.
4178
4179 -- bug 3062294
4180 --product_code is mandatory : this validation was missing altogether
4181 IF p_pm_product_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4182 OR p_pm_product_code IS NULL
4183 THEN
4184 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4185 THEN
4186 pa_interface_utils_pub.map_new_amg_msg
4187 ( p_old_message_code => 'PA_PRODUCT_CODE_IS_MISSING'
4188 ,p_msg_attribute => 'CHANGE'
4189 ,p_resize_flag => 'N'
4190 ,p_msg_context => 'GENERAL'
4191 ,p_attribute1 => ''
4192 ,p_attribute2 => ''
4193 ,p_attribute3 => ''
4194 ,p_attribute4 => ''
4195 ,p_attribute5 => '');
4196 dbms_output.put_line('MSG count in the stack ' || FND_MSG_PUB.count_msg);
4197 dbms_output.put_line('added msg to stack');
4198 dbms_output.put_line('MSG count in the stack 2 ' || FND_MSG_PUB.count_msg);
4199 END IF;
4200 p_return_status := FND_API.G_RET_STS_ERROR;
4201 END IF;
4202 -- bug 3062294
4203
4204 Bug 3218822 - PM_PRODUCT_CODE could be Null. We need valid it if it is NOT NULL
4205 *****************************/
4206
4207 --Get the segment1 of the project so that it can be used later
4208 OPEN l_amg_project_csr(p_pa_project_id);
4209 FETCH l_amg_project_csr INTO l_amg_segment1;
4210 CLOSE l_amg_project_csr;
4211
4212 --Get the task number
4213
4214 --Fixed for bug 5060391
4215 IF (p_pa_task_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM) THEN
4216 l_task_id := NULL;
4217 ELSE
4218 l_task_id := p_pa_task_id;
4219 END IF;
4220 l_amg_task_number := pa_interface_utils_pub.get_task_number_amg
4221 ( p_task_number=> ''
4222 ,p_task_reference => p_pm_task_reference
4223 ,p_task_id => l_task_id);
4224
4225 --When descriptive flex fields are not passed set them to NULL
4226 IF p_attribute_category = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4227 THEN
4228 l_attribute_category := NULL;
4229 ELSE
4230 l_attribute_category := p_attribute_category;
4231 END IF;
4232
4233 IF p_attribute1 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4234 THEN
4235 l_attribute1 := NULL;
4236 ELSE
4237 l_attribute1 := p_attribute1;
4238 END IF;
4239
4240 IF p_attribute2 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4241 THEN
4242 l_attribute2 := NULL;
4243 ELSE
4244 l_attribute2 := p_attribute2;
4245 END IF;
4246
4247 IF p_attribute3 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4248 THEN
4249 l_attribute3 := NULL;
4250 ELSE
4251 l_attribute3 := p_attribute3;
4252 END IF;
4253
4254 IF p_attribute4 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4255 THEN
4256 l_attribute4 := NULL;
4257 ELSE
4258 l_attribute4 := p_attribute4;
4259 END IF;
4260
4261 IF p_attribute5 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4262 THEN
4263 l_attribute5 := NULL;
4264 ELSE
4265 l_attribute5 := p_attribute5;
4266 END IF;
4267
4268 IF p_attribute6 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4269 THEN
4270 l_attribute6 := NULL;
4271 ELSE
4272 l_attribute6 := p_attribute6;
4273 END IF;
4274
4275 IF p_attribute7 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4276 THEN
4277 l_attribute7 := NULL;
4278 ELSE
4279 l_attribute7 := p_attribute7;
4280 END IF;
4281
4282 IF p_attribute8 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4283 THEN
4284 l_attribute8 := NULL;
4285 ELSE
4286 l_attribute8 := p_attribute8;
4287 END IF;
4288
4289 IF p_attribute9 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4290 THEN
4291 l_attribute9 := NULL;
4292 ELSE
4293 l_attribute9 := p_attribute9;
4294 END IF;
4295
4296 IF p_attribute10 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4297 THEN
4298 l_attribute10 := NULL;
4299 ELSE
4300 l_attribute10 := p_attribute10;
4301 END IF;
4302
4303 IF p_attribute11 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4304 THEN
4305 l_attribute11 := NULL;
4306 ELSE
4307 l_attribute11 := p_attribute11;
4308 END IF;
4309
4310 IF p_attribute12 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4311 THEN
4312 l_attribute12 := NULL;
4313 ELSE
4314 l_attribute12 := p_attribute12;
4315 END IF;
4316
4317 IF p_attribute13 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4318 THEN
4319 l_attribute13 := NULL;
4320 ELSE
4321 l_attribute13 := p_attribute13;
4322 END IF;
4323
4324 IF p_attribute14 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4325 THEN
4326 l_attribute14:= NULL;
4327 ELSE
4328 l_attribute14:= p_attribute14;
4329 END IF;
4330
4331 IF p_attribute15 = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4332 THEN
4333 l_attribute15 := NULL;
4334 ELSE
4335 l_attribute15 := p_attribute15;
4336 END IF;
4337
4338
4339 --Remove big numbers in case parameters were not passed, default to NULL; Assign Valid
4340 --Values to local variables.
4341
4342 IF p_quantity = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4343 THEN
4344 l_quantity := null;
4345 ELSE
4346 l_quantity := p_quantity;
4347 END IF;
4348
4349 IF p_raw_cost = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4350 THEN
4351 l_raw_cost := null;
4352 ELSE
4353 l_raw_cost := p_raw_cost;
4354 END IF;
4355
4356 IF p_burdened_cost = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4357 THEN
4358 l_burdened_cost := null;
4359 ELSE
4360 l_burdened_cost := p_burdened_cost;
4361 END IF;
4362
4363 IF p_revenue = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4364 THEN
4365 l_revenue := null;
4366 ELSE
4367 l_revenue := p_revenue;
4368 END IF;
4369 -- extending this null assignment to all other parameters passed as part
4370 -- of p_budget_lines_rec (as defined in pa_budget_pub)
4371 -- Added for bug 3062294 :
4372
4373 IF p_pa_task_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4374 THEN
4375 l_pa_task_id := null;
4376 ELSE
4377 l_pa_task_id := p_pa_task_id;
4378 END IF;
4379
4380 IF p_pm_task_reference = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4381 THEN
4382 l_pm_task_ref := null;
4383 ELSE
4384 l_pm_task_ref := p_pm_task_reference;
4385 END IF;
4386
4387 IF p_resource_alias = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4388 THEN
4389 l_resource_alias := null;
4390 ELSE
4391 l_resource_alias := p_resource_alias;
4392 END IF;
4393
4394 IF p_member_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4395 THEN
4396 l_rlm_id := null;
4397 ELSE
4398 l_rlm_id := p_member_id;
4399 END IF;
4400
4401
4402 IF p_cbs_element_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
4403 THEN
4404 l_cbs_element_id := null;
4405 ELSE
4406 l_cbs_element_id := p_cbs_element_id;
4407 END IF;
4408
4409 IF p_budget_start_date = PA_INTERFACE_UTILS_PUB.G_PA_MISS_DATE
4410 THEN
4411 l_budget_start_date := null;
4412 ELSE
4413 l_budget_start_date := p_budget_start_date;
4414 END IF;
4415
4416 IF p_budget_end_date = PA_INTERFACE_UTILS_PUB.G_PA_MISS_DATE
4417 THEN
4418 l_budget_end_date := null;
4419 ELSE
4420 l_budget_end_date := p_budget_end_date;
4421 END IF;
4422
4423 IF p_period_name = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4424 THEN
4425 l_period_name := null;
4426 ELSE
4427 l_period_name := p_period_name;
4428 END IF;
4429
4430 IF p_description = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4431 THEN
4432 l_description := null;
4433 ELSE
4434 l_description := p_description;
4435 END IF;
4436
4437 IF p_pm_budget_line_reference = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4438 THEN
4439 l_pm_budget_line_reference := null;
4440 ELSE
4441 l_pm_budget_line_reference := p_pm_budget_line_reference;
4442 END IF;
4443
4444 --Bug 4224464
4445 IF p_change_reason_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4446 THEN
4447 l_change_reason_code := NULL;
4448 ELSE
4449 l_change_reason_code := p_change_reason_code;
4450 END IF;
4451
4452 IF p_pm_product_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
4453 THEN
4454 l_pm_product_code := NULL;
4455 ELSE
4456 l_pm_product_code := p_pm_product_code;
4457 END IF;
4458
4459 IF (l_quantity IS NULL AND l_raw_cost IS NULL AND l_burdened_cost IS NULL AND p_budget_amount_code = 'C')
4460 OR (l_quantity IS NULL AND l_revenue IS NULL AND p_budget_amount_code = 'R')
4461 THEN
4462 NULL; --we don't insert budget lines with all zero's
4463
4464 ELSE
4465
4466 /**** Validation checks introduced for the bug 2998221 starts here ****/
4467
4468 -- Initialize l_budget_lines_tbl with the budget line details
4469 -- The table would contain only one record
4470
4471 i := 1;
4472
4473 l_budget_lines_in_tbl(i).pa_task_id := l_pa_task_id;
4474 l_budget_lines_in_tbl(i).pm_task_reference := l_pm_task_ref;
4475 l_budget_lines_in_tbl(i).resource_alias := l_resource_alias;
4476 l_budget_lines_in_tbl(i).resource_list_member_id := l_rlm_id;
4477 --Bug 16604257 : CBS RBS Phase 2 API changes
4478 l_budget_lines_in_tbl(i).CBS_ELEMENT_ID := L_CBS_ELEMENT_ID;
4479 l_budget_lines_in_tbl(i).budget_start_date := l_budget_start_date ;
4480 l_budget_lines_in_tbl(i).budget_end_date := l_budget_end_date ;
4481 l_budget_lines_in_tbl(i).period_name := l_period_name;
4482 l_budget_lines_in_tbl(i).description := l_description ;
4483 l_budget_lines_in_tbl(i).raw_cost := l_raw_cost;
4484 l_budget_lines_in_tbl(i).burdened_cost := l_burdened_cost;
4485 l_budget_lines_in_tbl(i).revenue := l_revenue;
4486 l_budget_lines_in_tbl(i).quantity := l_quantity;
4487 l_budget_lines_in_tbl(i).pm_product_code := l_pm_product_code;
4488 l_budget_lines_in_tbl(i).pm_budget_line_reference := l_pm_budget_line_reference;
4489 l_budget_lines_in_tbl(i).attribute_category := l_attribute_category ;
4490 l_budget_lines_in_tbl(i).attribute1 := l_attribute1 ;
4491 l_budget_lines_in_tbl(i).attribute2 := l_attribute2 ;
4492 l_budget_lines_in_tbl(i).attribute3 := l_attribute3 ;
4493 l_budget_lines_in_tbl(i).attribute4 := l_attribute4 ;
4494 l_budget_lines_in_tbl(i).attribute5 := l_attribute5 ;
4495 l_budget_lines_in_tbl(i).attribute6 := l_attribute6 ;
4496 l_budget_lines_in_tbl(i).attribute7 := l_attribute7 ;
4497 l_budget_lines_in_tbl(i).attribute8 := l_attribute8 ;
4498 l_budget_lines_in_tbl(i).attribute9 := l_attribute9 ;
4499 l_budget_lines_in_tbl(i).attribute10 := l_attribute10;
4500 l_budget_lines_in_tbl(i).attribute11 := l_attribute11;
4501 l_budget_lines_in_tbl(i).attribute12 := l_attribute12;
4502 l_budget_lines_in_tbl(i).attribute13 := l_attribute13;
4503 l_budget_lines_in_tbl(i).attribute14 := l_attribute14;
4504 l_budget_lines_in_tbl(i).attribute15 := l_attribute15;
4505 l_budget_lines_in_tbl(i).txn_currency_code := null;
4506 l_budget_lines_in_tbl(i).projfunc_cost_rate_type := null;
4507 l_budget_lines_in_tbl(i).projfunc_cost_rate_date_type := null;
4508 l_budget_lines_in_tbl(i).projfunc_cost_rate_date := null;
4509 l_budget_lines_in_tbl(i).projfunc_cost_exchange_rate := null;
4510 l_budget_lines_in_tbl(i).projfunc_rev_rate_type := null;
4511 l_budget_lines_in_tbl(i).projfunc_rev_rate_date_type := null;
4512 l_budget_lines_in_tbl(i).projfunc_rev_rate_date := null;
4513 l_budget_lines_in_tbl(i).projfunc_rev_exchange_rate := null;
4514 l_budget_lines_in_tbl(i).project_cost_rate_type := null;
4515 l_budget_lines_in_tbl(i).project_cost_rate_date_type := null;
4516 l_budget_lines_in_tbl(i).project_cost_rate_date := null;
4517 l_budget_lines_in_tbl(i).project_cost_exchange_rate := null;
4518 l_budget_lines_in_tbl(i).project_rev_rate_type := null;
4519 l_budget_lines_in_tbl(i).project_rev_rate_date_type := null;
4520 l_budget_lines_in_tbl(i).project_rev_rate_date := null;
4521 l_budget_lines_in_tbl(i).project_rev_exchange_rate := null;
4522 l_budget_lines_in_tbl(i).change_reason_code := l_change_reason_code;--Bug 4224464
4523
4524 --3569883 start
4525 -- select fin_plan_type_id
4526 -- into l_fp_type_id
4527 -- from pa_budget_versions
4528 -- where budget_version_id = p_budget_version_id;
4529 --
4530 -- select DECODE(l_fp_type_id, null, 'Y','N') into l_old_model from dual;
4531 ----3569883 end
4532
4533 --Bug 4224464: FP.M Changes for Validate_Budget_Lines
4534 --Send the budget version id to validate_budget_lines API for
4535 --actuals on FORECAST check
4536 IF p_budget_version_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
4537 l_version_info_rec.x_budget_version_id := null;
4538 ELSE
4539 l_version_info_rec.x_budget_version_id := p_budget_version_id;
4540 END IF;
4541
4542 -- Call validate_budget_lines api
4543 pa_budget_pvt.Validate_Budget_Lines
4544 ( p_pa_project_id => p_pa_project_id
4545 ,p_budget_type_code => p_budget_type_code
4546 ,p_fin_plan_type_id => NULL
4547 ,p_version_type => NULL
4548 ,p_resource_list_id => p_resource_list_id
4549 ,p_time_phased_code => p_time_phased_type_code
4550 ,p_budget_entry_method_code => p_budget_entry_method_code
4551 ,p_entry_level_code => p_entry_level_code
4552 ,p_allow_qty_flag => NULL
4553 ,p_allow_raw_cost_flag => NULL
4554 ,p_allow_burdened_cost_flag => NULL
4555 ,p_allow_revenue_flag => NULL
4556 ,p_multi_currency_flag => NULL
4557 ,p_project_cost_rate_type => NULL
4558 ,p_project_cost_rate_date_typ => NULL
4559 ,p_project_cost_rate_date => NULL
4560 ,p_project_cost_exchange_rate => NULL
4561 ,p_projfunc_cost_rate_type => NULL
4562 ,p_projfunc_cost_rate_date_typ => NULL
4563 ,p_projfunc_cost_rate_date => NULL
4564 ,p_projfunc_cost_exchange_rate => NULL
4565 ,p_project_rev_rate_type => NULL
4566 ,p_project_rev_rate_date_typ => NULL
4567 ,p_project_rev_rate_date => NULL
4568 ,p_project_rev_exchange_rate => NULL
4569 ,p_projfunc_rev_rate_type => NULL
4570 ,p_projfunc_rev_rate_date_typ => NULL
4571 ,p_projfunc_rev_rate_date => NULL
4572 ,p_projfunc_rev_exchange_rate => NULL
4573 ,p_version_info_rec => l_version_info_rec
4574 ,px_budget_lines_in => l_budget_lines_in_tbl
4575 ,x_budget_lines_out => l_budget_lines_out_tbl
4576 -- ,x_old_model => l_old_model --3569883
4577 ,x_mfc_cost_type_id_tbl => l_mfc_cost_type_id_tbl
4578 ,x_etc_method_code_tbl => l_etc_method_code_tbl
4579 ,x_spread_curve_id_tbl => l_spread_curve_id_tbl
4580 ,x_msg_count => l_msg_count
4581 ,x_msg_data => l_msg_data
4582 ,x_return_status => l_return_status);
4583
4584 IF(l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
4585 RAISE FND_API.G_EXC_ERROR;
4586 END IF;
4587
4588 IF l_debug_mode = 'Y' THEN
4589 pa_debug.g_err_stage := 'Validate Budget Lines got executed successfully';
4590 pa_debug.write(l_module_name,pa_debug.g_err_stage,3);
4591 END IF;
4592
4593 /**** Validation checks introduced for the bug 2998221 starts here ****/
4594
4595 --create budget line
4596 -- dbms_output.put_line('before create_line revenue = '|| l_revenue || ' raw cost '||l_raw_cost || 'l_burdened_cost '||l_burdened_cost||' l_quantity ' || l_quantity);
4597
4598 pa_budget_utils.create_line
4599 (x_budget_version_id => p_budget_version_id
4600 ,x_project_id => p_pa_project_id
4601 ,x_task_id => l_budget_lines_in_tbl(i).pa_task_id --bug 2998221 l_pa_task_id
4602 ,x_resource_list_member_id => l_budget_lines_in_tbl(i).resource_list_member_id --bug 2998221 l_rlm_id
4603 ,X_CBS_ELEMENT_ID => l_budget_lines_in_tbl(i).CBS_ELEMENT_ID --bug 2998221 l_rlm_id
4604 ,x_description => l_description
4605 ,x_start_date => l_budget_lines_in_tbl(i).budget_start_date --bug 2998221 l_budget_start_date
4606 ,x_end_date => l_budget_lines_in_tbl(i).budget_end_date --bug 2998221 l_budget_end_date
4607 ,x_period_name => l_budget_lines_in_tbl(i).period_name --bug 2998221 l_period_name
4608 ,x_quantity => l_quantity
4609 ,x_unit_of_measure => l_unit_of_measure
4610 ,x_track_as_labor_flag => l_track_as_labor_flag
4611 ,x_raw_cost => l_raw_cost
4612 ,x_burdened_cost => l_burdened_cost
4613 ,x_revenue => l_revenue
4614 ,x_change_reason_code => l_change_reason_code --Bug 4224464
4615 ,x_attribute_category => l_attribute_category
4616 ,x_attribute1 => l_attribute1
4617 ,x_attribute2 => l_attribute2
4618 ,x_attribute3 => l_attribute3
4619 ,x_attribute4 => l_attribute4
4620 ,x_attribute5 => l_attribute5
4621 ,x_attribute6 => l_attribute6
4622 ,x_attribute7 => l_attribute7
4623 ,x_attribute8 => l_attribute8
4624 ,x_attribute9 => l_attribute9
4625 ,x_attribute10 => l_attribute10
4626 ,x_attribute11 => l_attribute11
4627 ,x_attribute12 => l_attribute12
4628 ,x_attribute13 => l_attribute13
4629 ,x_attribute14 => l_attribute14
4630 ,x_attribute15 => l_attribute15
4631 -- Bug Fix: 4569365. Removed MRC code.
4632 -- ,x_mrc_flag => 'Y' /* FPB2: MRC */
4633 ,x_resource_assignment_id => l_resource_assignment_id
4634 ,x_err_code => l_err_code
4635 ,x_err_stage => l_err_stage
4636 ,x_err_stack => l_err_stack
4637 ,x_pm_product_code => l_pm_product_code
4638 ,x_pm_budget_line_reference => l_budget_lines_in_tbl(i).pm_budget_line_reference --bug 2998221 l_pm_budget_line_reference
4639 ,x_quantity_source => 'I'
4640 ,x_raw_cost_source => 'I'
4641 ,x_burdened_cost_source => 'I'
4642 ,x_revenue_source => 'I' );
4643
4644 --dbms_output.put_line('After create_line');
4645 --dbms_output.put_line('Error code: '||l_err_code);
4646 --dbms_output.put_line('Error Stage: '||l_err_stage);
4647 --dbms_output.put_line('Error Stack: '||l_err_stack);
4648
4649 IF l_err_code > 0
4650 then
4651
4652 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4653 THEN
4654
4655 IF NOT pa_project_pvt.check_valid_message(l_err_stage)
4656 THEN
4657 pa_interface_utils_pub.map_new_amg_msg
4658 ( p_old_message_code => 'PA_CREATE_LINE_FAILED'
4659 ,p_msg_attribute => 'CHANGE'
4660 ,p_resize_flag => 'N'
4661 ,p_msg_context => 'BUDG'
4662 ,p_attribute1 => l_amg_segment1
4663 ,p_attribute2 => l_amg_task_number
4664 ,p_attribute3 => p_budget_type_code
4665 ,p_attribute4 => ''
4666 ,p_attribute5 => to_char(p_budget_start_date));
4667 ELSE
4668 pa_interface_utils_pub.map_new_amg_msg
4669 ( p_old_message_code => l_err_stage
4670 ,p_msg_attribute => 'CHANGE'
4671 ,p_resize_flag => 'N'
4672 ,p_msg_context => 'BUDG'
4673 ,p_attribute1 => l_amg_segment1
4674 ,p_attribute2 => l_amg_task_number
4675 ,p_attribute3 => p_budget_type_code
4676 ,p_attribute4 => ''
4677 ,p_attribute5 => to_char(p_budget_start_date));
4678 END IF;
4679
4680 END IF;
4681
4682 RAISE FND_API.G_EXC_ERROR;
4683
4684 ELSIF l_err_code < 0
4685 THEN
4686
4687 IF l_err_code = -1 --special handling of duplicate line error
4688 THEN
4689 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
4690 THEN
4691 pa_interface_utils_pub.map_new_amg_msg
4692 ( p_old_message_code => 'PA_BUDGET_LINE_ALREADY_EXISTS'
4693 ,p_msg_attribute => 'CHANGE'
4694 ,p_resize_flag => 'Y'
4695 ,p_msg_context => 'BUDG'
4696 ,p_attribute1 => l_amg_segment1
4697 ,p_attribute2 => l_amg_task_number
4698 ,p_attribute3 => p_budget_type_code
4699 ,p_attribute4 => ''
4700 ,p_attribute5 => to_char(p_budget_start_date));
4701 END IF;
4702 RAISE FND_API.G_EXC_ERROR;
4703 ELSE
4704
4705 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4706 THEN
4707
4708 FND_MSG_PUB.add_exc_msg
4709 ( p_pkg_name => 'PA_BUDGET_UTILS'
4710 , p_procedure_name => 'CREATE_LINE'
4711 , p_error_text => 'ORA-'||LPAD(substr(l_err_code,2),5,'0') );
4712
4713 END IF;
4714 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
4715 END IF;
4716
4717 END IF;
4718 END IF; --all zero's
4719
4720 EXCEPTION
4721
4722 WHEN FND_API.G_EXC_ERROR
4723 THEN
4724
4725 ROLLBACK TO insert_budget_line_pvt;
4726
4727 p_return_status := FND_API.G_RET_STS_ERROR;
4728
4729 WHEN FND_API.G_EXC_UNEXPECTED_ERROR
4730 THEN
4731
4732 ROLLBACK TO insert_budget_line_pvt;
4733
4734 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4735
4736 WHEN OTHERS THEN
4737
4738 ROLLBACK TO insert_budget_line_pvt;
4739
4740 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
4741
4742 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
4743 THEN
4744 FND_MSG_PUB.add_exc_msg
4745 ( p_pkg_name => G_PKG_NAME
4746 , p_procedure_name => l_api_name );
4747
4748 END IF;
4749
4750 END insert_budget_line;
4751
4752
4753 ----------------------------------------------------------------------------------------
4754 --Name: update_budget_line_sql
4755 --Type: Procedure
4756 --Description: This procedure is be build a update statement for a budgetline.
4757 --
4758 --
4759 --Called subprograms: PA_BUDGET_PVT.check_entry_method_flags
4760 --
4761 --
4762 --
4763 --
4764 --History:
4765 -- 19-NOV-1996 L. de Werker Created
4766 --
4767 -- 04-FEB-2003 gjain Bug 2756050: Modified the code which generates
4768 -- the dynamic sql to append additional quotes before
4769 -- and after the numeric columns like raw_cost,
4770 -- burdened_cost,revenue,quantity
4771 -- 10-MAY-2005 Ritesh Shukla Bug 4224464- This procedure has been modified extensively
4772 -- during FP.M changes for AMG. If you do not want to update
4773 -- a parameter then either do not pass it or pass its value
4774 -- as NULL, and if you want to null out a parameter then
4775 -- pass it as FND_API.G_MISS_XXX
4776 -- 13-MAY-2005 Ritesh Shukla Bug 4224464-Removed parameter p_budget_amount_code from
4777 -- procedure update_budget_line_sql since it has become redundant.
4778
4779 PROCEDURE update_budget_line_sql
4780 ( p_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
4781 ,p_budget_entry_method_code IN VARCHAR2
4782 ,p_resource_assignment_id IN NUMBER
4783 ,p_start_date IN DATE
4784 ,p_time_phased_type_code IN VARCHAR2
4785 ,p_description IN VARCHAR2
4786 ,p_quantity IN NUMBER
4787 ,p_raw_cost IN NUMBER
4788 ,p_burdened_cost IN NUMBER
4789 ,p_revenue IN NUMBER
4790 ,p_change_reason_code IN VARCHAR2
4791 ,p_attribute_category IN VARCHAR2
4792 ,p_attribute1 IN VARCHAR2
4793 ,p_attribute2 IN VARCHAR2
4794 ,p_attribute3 IN VARCHAR2
4795 ,p_attribute4 IN VARCHAR2
4796 ,p_attribute5 IN VARCHAR2
4797 ,p_attribute6 IN VARCHAR2
4798 ,p_attribute7 IN VARCHAR2
4799 ,p_attribute8 IN VARCHAR2
4800 ,p_attribute9 IN VARCHAR2
4801 ,p_attribute10 IN VARCHAR2
4802 ,p_attribute11 IN VARCHAR2
4803 ,p_attribute12 IN VARCHAR2
4804 ,p_attribute13 IN VARCHAR2
4805 ,p_attribute14 IN VARCHAR2
4806 ,p_attribute15 IN VARCHAR2
4807 )
4808
4809 IS
4810
4811 --needed to get the current data of a budget line
4812
4813 CURSOR l_budget_line_csr
4814 (p_resource_assigment_id NUMBER
4815 ,p_budget_start_date DATE )
4816 IS
4817 SELECT pa_budget_lines.*, rowid
4818 FROM pa_budget_lines
4819 WHERE resource_assignment_id = p_resource_assigment_id
4820 AND start_date = p_budget_start_date;
4821
4822 --cursor added as part of fix for Bug#1406799 to check the burdened_cost_flag
4823
4824 CURSOR l_budget_entry_method_csr
4825 (p_budget_entry_method_code pa_budget_entry_methods.budget_entry_method_code%type)
4826 IS
4827 SELECT burdened_cost_flag
4828 FROM pa_budget_entry_methods
4829 WHERE budget_entry_method_code = p_budget_entry_method_code
4830 AND trunc(sysdate)
4831 BETWEEN trunc(start_date_active) and trunc(nvl(end_date_active,sysdate));
4832
4833
4834 l_return_status VARCHAR2(1);
4835 l_api_name CONSTANT VARCHAR2(30) := 'update_budget_line_sql';
4836 l_budget_line_rec l_budget_line_csr%rowtype;
4837
4838 --used by dynamic SQL
4839 l_statement VARCHAR2(2000);
4840 l_update_yes_flag VARCHAR2(1) := 'N';
4841 l_rows NUMBER;
4842 l_cursor_id NUMBER;
4843 -- added as part of fix for Bug#1406799 to check for burdened_cost_flag
4844 l_burdened_cost_flag VARCHAR2(1) := 'Y';
4845
4846 /* FPB2: MRC */
4847 l_budget_line_id PA_BUDGET_LINES.BUDGET_LINE_ID%type;
4848 l_budget_version_id PA_BUDGET_LINES.BUDGET_VERSION_ID%type;
4849 l_txn_currency_code PA_BUDGET_LINES.TXN_CURRENCY_CODE%type;
4850 l_msg_count NUMBER := 0;
4851 l_msg_data VARCHAR2(2000);
4852
4853
4854 BEGIN
4855
4856 -- Standard begin of API savepoint
4857
4858 SAVEPOINT update_budget_line_sql_pvt;
4859
4860 -- Set API return status to success
4861
4862 p_return_status := FND_API.G_RET_STS_SUCCESS;
4863
4864 --get the current values for this budget line
4865
4866 OPEN l_budget_line_csr( p_resource_assignment_id, p_start_date );
4867 FETCH l_budget_line_csr INTO l_budget_line_rec;
4868 CLOSE l_budget_line_csr;
4869
4870 --dbms_output.put_line('Building the dynamic SQL statement');
4871
4872 --building the dynamic SQL statement
4873 -- Changes made by Xin Liu for using of SQL BIND VARIABLE 12-MAY-2003
4874
4875 l_statement := ' UPDATE PA_BUDGET_LINES SET ';
4876
4877 --dbms_output.put_line('p_description : '||p_description);
4878 --dbms_output.put_line('l_budget_line_rec.description: '||l_budget_line_rec.description);
4879
4880 IF p_description IS NOT NULL
4881 AND p_description <> nvl(l_budget_line_rec.description,FND_API.G_MISS_CHAR)
4882 THEN
4883 l_statement := l_statement ||
4884 ' DESCRIPTION = :xDescription'||',';
4885 l_update_yes_flag := 'Y';
4886 END IF;
4887
4888 --dbms_output.put_line('New Raw cost: '||nvl(to_char(p_raw_cost),'NULL'));
4889 --dbms_output.put_line('Old Raw cost: '||nvl(to_char(l_budget_line_rec.raw_cost),'NULL'));
4890
4891 IF p_raw_cost IS NOT NULL
4892 AND p_raw_cost <> nvl(l_budget_line_rec.raw_cost,FND_API.G_MISS_NUM)
4893 THEN
4894 l_statement := l_statement ||
4895 ' RAW_COST = :xRawCost'||',';
4896
4897 l_update_yes_flag := 'Y';
4898 END IF;
4899
4900 -- code added as part of fix for Bug#1406799. To check for burdened_cost_flag.
4901 OPEN l_budget_entry_method_csr( p_budget_entry_method_code );
4902 FETCH l_budget_entry_method_csr INTO l_burdened_cost_flag;
4903 CLOSE l_budget_entry_method_csr;
4904
4905 IF l_burdened_cost_flag = 'N' -- added for burden_distributed_cost ='N'
4906 THEN
4907 /* Bug 2864086 - Added this check for p_raw_cost before updating burdened cost with the p_raw_cost */
4908
4909 IF p_raw_cost IS NOT NULL
4910 AND p_raw_cost <> nvl(l_budget_line_rec.burdened_cost,FND_API.G_MISS_NUM)
4911 THEN
4912 l_statement := l_statement ||
4913 ' BURDENED_COST = :xRawCostForB'||',';
4914
4915 l_update_yes_flag := 'Y';
4916 END If;
4917 ELSE
4918
4919 IF p_burdened_cost IS NOT NULL
4920 AND p_burdened_cost <> nvl(l_budget_line_rec.burdened_cost,FND_API.G_MISS_NUM)
4921 THEN
4922 l_statement := l_statement ||
4923 ' BURDENED_COST = :xBurdenedCost'||',';
4924
4925 l_update_yes_flag := 'Y';
4926 END IF;
4927 END IF;--l_burdened_cost_flag = 'N'
4928
4929 IF p_revenue IS NOT NULL
4930 AND p_revenue <> nvl(l_budget_line_rec.revenue,FND_API.G_MISS_NUM)
4931 THEN
4932 l_statement := l_statement ||
4933 ' REVENUE = :xRevenue'||',';
4934
4935 l_update_yes_flag := 'Y';
4936 END IF;
4937
4938 IF p_quantity IS NOT NULL
4939 AND p_quantity <> nvl(l_budget_line_rec.quantity,FND_API.G_MISS_NUM)
4940 THEN
4941 l_statement := l_statement ||
4942 ' QUANTITY = :xQuantity'||',';
4943
4944 l_update_yes_flag := 'Y';
4945 END IF;
4946
4947 IF p_change_reason_code IS NOT NULL
4948 AND p_change_reason_code <> nvl(l_budget_line_rec.change_reason_code,FND_API.G_MISS_CHAR)
4949 THEN
4950 l_statement := l_statement ||
4951 ' CHANGE_REASON_CODE = :xChangeReasonCode'||',';
4952 l_update_yes_flag := 'Y';
4953 END IF;
4954
4955 IF p_attribute_category IS NOT NULL
4956 AND p_attribute_category <> nvl(l_budget_line_rec.attribute_category,FND_API.G_MISS_CHAR)
4957 THEN
4958 l_statement := l_statement ||
4959 ' ATTRIBUTE_CATEGORY = :xAttributeCategory'||',';
4960 l_update_yes_flag := 'Y';
4961 END IF;
4962
4963 IF p_attribute1 IS NOT NULL
4964 AND p_attribute1 <> nvl(l_budget_line_rec.attribute1,FND_API.G_MISS_CHAR)
4965 THEN
4966 l_statement := l_statement ||
4967 ' ATTRIBUTE1 = :xAttribute1'||',';
4968 l_update_yes_flag := 'Y';
4969 END IF;
4970
4971 IF p_attribute2 IS NOT NULL
4972 AND p_attribute2 <> nvl(l_budget_line_rec.attribute2,FND_API.G_MISS_CHAR)
4973 THEN
4974 l_statement := l_statement ||
4975 ' ATTRIBUTE2 = :xAttribute2'||',';
4976 l_update_yes_flag := 'Y';
4977 END IF;
4978
4979 IF p_attribute3 IS NOT NULL
4980 AND p_attribute3 <> nvl(l_budget_line_rec.attribute3,FND_API.G_MISS_CHAR)
4981 THEN
4982 l_statement := l_statement ||
4983 ' ATTRIBUTE3 = :xAttribute3'||',';
4984 l_update_yes_flag := 'Y';
4985 END IF;
4986
4987 IF p_attribute4 IS NOT NULL
4988 AND p_attribute4 <> nvl(l_budget_line_rec.attribute4,FND_API.G_MISS_CHAR)
4989 THEN
4990 l_statement := l_statement ||
4991 ' ATTRIBUTE4 = :xAttribute4'||',';
4992 l_update_yes_flag := 'Y';
4993 END IF;
4994
4995 IF p_attribute5 IS NOT NULL
4996 AND p_attribute5 <> nvl(l_budget_line_rec.attribute5,FND_API.G_MISS_CHAR)
4997 THEN
4998 l_statement := l_statement ||
4999 ' ATTRIBUTE5 = :xAttribute5'||',';
5000 l_update_yes_flag := 'Y';
5001 END IF;
5002
5003 IF p_attribute6 IS NOT NULL
5004 AND p_attribute6 <> nvl(l_budget_line_rec.attribute6,FND_API.G_MISS_CHAR)
5005 THEN
5006 l_statement := l_statement ||
5007 ' ATTRIBUTE6 = :xAttribute6'||',';
5008 l_update_yes_flag := 'Y';
5009 END IF;
5010
5011 IF p_attribute7 IS NOT NULL
5012 AND p_attribute7 <> nvl(l_budget_line_rec.attribute7,FND_API.G_MISS_CHAR)
5013 THEN
5014 l_statement := l_statement ||
5015 ' ATTRIBUTE7 = :xAttribute7'||',';
5016 l_update_yes_flag := 'Y';
5017 END IF;
5018
5019 IF p_attribute8 IS NOT NULL
5020 AND p_attribute8 <> nvl(l_budget_line_rec.attribute8,FND_API.G_MISS_CHAR)
5021 THEN
5022 l_statement := l_statement ||
5023 ' ATTRIBUTE8 = :xAttribute8'||',';
5024 l_update_yes_flag := 'Y';
5025 END IF;
5026
5027 IF p_attribute9 IS NOT NULL
5028 AND p_attribute9 <> nvl(l_budget_line_rec.attribute9,FND_API.G_MISS_CHAR)
5029 THEN
5030 l_statement := l_statement ||
5031 ' ATTRIBUTE9 = :xAttribute9'||',';
5032 l_update_yes_flag := 'Y';
5033 END IF;
5034
5035 IF p_attribute10 IS NOT NULL
5036 AND p_attribute10 <> nvl(l_budget_line_rec.attribute10,FND_API.G_MISS_CHAR)
5037 THEN
5038 l_statement := l_statement ||
5039 ' ATTRIBUTE10 = :xAttribute10'||',';
5040 l_update_yes_flag := 'Y';
5041 END IF;
5042
5043 IF p_attribute11 IS NOT NULL
5044 AND p_attribute11 <> nvl(l_budget_line_rec.attribute11,FND_API.G_MISS_CHAR)
5045 THEN
5046 l_statement := l_statement ||
5047 ' ATTRIBUTE11 = :xAttribute11'||',';
5048 l_update_yes_flag := 'Y';
5049 END IF;
5050
5051 IF p_attribute12 IS NOT NULL
5052 AND p_attribute12 <> nvl(l_budget_line_rec.attribute12,FND_API.G_MISS_CHAR)
5053 THEN
5054 l_statement := l_statement ||
5055 ' ATTRIBUTE12 = :xAttribute12'||',';
5056 l_update_yes_flag := 'Y';
5057 END IF;
5058
5059 IF p_attribute13 IS NOT NULL
5060 AND p_attribute13 <> nvl(l_budget_line_rec.attribute13,FND_API.G_MISS_CHAR)
5061 THEN
5062 l_statement := l_statement ||
5063 ' ATTRIBUTE13 = :xAttribute13'||',';
5064 l_update_yes_flag := 'Y';
5065 END IF;
5066
5067 IF p_attribute14 IS NOT NULL
5068 AND p_attribute14 <> nvl(l_budget_line_rec.attribute14,FND_API.G_MISS_CHAR)
5069 THEN
5070 l_statement := l_statement ||
5071 ' ATTRIBUTE14 = :xAttribute14'||',';
5072 l_update_yes_flag := 'Y';
5073 END IF;
5074
5075 IF p_attribute15 IS NOT NULL
5076 AND p_attribute15 <> nvl(l_budget_line_rec.attribute15,FND_API.G_MISS_CHAR)
5077 THEN
5078 l_statement := l_statement ||
5079 ' ATTRIBUTE15 = :xAttribute15'||',';
5080 l_update_yes_flag := 'Y';
5081 END IF;
5082
5083
5084 /* FPB2: MRC
5085 - This code is used only in the old model
5086 - Txn_currency_code will always be the projfunc_currency_code
5087 - Adding txn_currency_code in update for more clarity to indicate the update will
5088 always update just one record. We get the budget_line_id of the updated record
5089 and pass to mrc api */
5090
5091 BEGIN
5092 SELECT projfunc_currency_code
5093 INTO l_txn_currency_code
5094 FROM pa_projects_all a, pa_budget_versions b, pa_resource_Assignments c
5095 WHERE a.project_id = b.project_id
5096 AND b.budget_version_id = c.budget_version_id
5097 AND c.resource_assignment_id = p_resource_assignment_id
5098 AND b.ci_id IS NULL; -- <Patchset M:B and F impact changes : AMG:> -- Added an extra clause b.ci_id IS NULL --Bug # 3507156
5099
5100 EXCEPTION
5101 WHEN OTHERS THEN
5102 /* May the resource assignment id passed is not correct ! */
5103 l_txn_currency_code := null;
5104 END;
5105
5106 IF l_update_yes_flag = 'Y'
5107 THEN
5108 l_statement := l_statement ||
5109 ' LAST_UPDATE_DATE = :xLastUpdateDate'||',';
5110
5111 l_statement := l_statement ||
5112 ' LAST_UPDATED_BY = '||G_USER_ID||',';
5113
5114 l_statement := l_statement ||
5115 ' LAST_UPDATE_LOGIN = '||G_LOGIN_ID||',';
5116
5117 l_statement := SUBSTR(l_statement,1,LENGTH(l_statement)-1);
5118
5119 l_statement := l_statement ||
5120 ' WHERE RESOURCE_ASSIGNMENT_ID = '||TO_CHAR(p_resource_assignment_id) ||
5121 ' AND START_DATE = :xStartDate' ||
5122 ' AND TXN_CURRENCY_CODE = ' || '''' || l_txn_currency_code || ''''; /* FPB2: MRC */
5123
5124 --dbms_output.put_line('Opening the cursor');
5125 --dbms_output.put_line(to_char(length(l_statement)));
5126 --dbms_output.put_line('Statement: '||substr(l_statement,1,100));
5127 --dbms_output.put_line('Statement: '||substr(l_statement,101,100));
5128 --dbms_output.put_line('Statement: '||substr(l_statement,201,100));
5129
5130 l_cursor_id := DBMS_SQL.open_cursor;
5131 DBMS_SQL.parse(l_cursor_id, l_statement, DBMS_SQL.native);
5132
5133 IF p_description IS NOT NULL
5134 AND p_description <> nvl(l_budget_line_rec.description,FND_API.G_MISS_CHAR)
5135 THEN
5136 IF p_description = FND_API.G_MISS_CHAR THEN
5137 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xDescription', TO_CHAR(NULL));
5138 ELSE
5139 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xDescription', p_description);
5140 END IF;
5141 END IF;
5142
5143 IF p_raw_cost IS NOT NULL
5144 AND p_raw_cost <> nvl(l_budget_line_rec.raw_cost,FND_API.G_MISS_NUM)
5145 THEN
5146 IF p_raw_cost = FND_API.G_MISS_NUM THEN
5147 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xRawCost', TO_NUMBER(NULL));
5148 ELSE
5149 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xRawCost', p_raw_cost);
5150 END IF;
5151 END IF;
5152
5153 IF l_burdened_cost_flag = 'N' -- added for burden_distributed_cost ='N'
5154 THEN
5155
5156 IF p_raw_cost IS NOT NULL
5157 AND p_raw_cost <> nvl(l_budget_line_rec.burdened_cost,FND_API.G_MISS_NUM)
5158 THEN
5159 IF p_raw_cost = FND_API.G_MISS_NUM THEN
5160 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xRawCostForB', TO_NUMBER(NULL));
5161 ELSE
5162 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xRawCostForB', p_raw_cost);
5163 END IF;
5164 END IF;
5165
5166 ELSE
5167
5168 IF p_burdened_cost IS NOT NULL
5169 AND p_burdened_cost <> nvl(l_budget_line_rec.burdened_cost,FND_API.G_MISS_NUM)
5170 THEN
5171 IF p_burdened_cost = FND_API.G_MISS_NUM THEN
5172 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xBurdenedCost', TO_NUMBER(NULL));
5173 ELSE
5174 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xBurdenedCost', p_burdened_cost);
5175 END IF;
5176 END IF;
5177
5178 END IF;--l_burdened_cost_flag = 'N'
5179
5180 IF p_revenue IS NOT NULL
5181 AND p_revenue <> nvl(l_budget_line_rec.revenue,FND_API.G_MISS_NUM)
5182 THEN
5183 IF p_revenue = FND_API.G_MISS_NUM THEN
5184 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xRevenue',TO_NUMBER(NULL));
5185 ELSE
5186 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xRevenue',p_revenue);
5187 END IF;
5188 END IF;
5189
5190 IF p_quantity IS NOT NULL
5191 AND p_quantity <> nvl(l_budget_line_rec.quantity,FND_API.G_MISS_NUM)
5192 THEN
5193 IF p_quantity = FND_API.G_MISS_NUM THEN
5194 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xQuantity',TO_NUMBER(NULL));
5195 ELSE
5196 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xQuantity',p_quantity);
5197 END IF;
5198 END IF;
5199
5200 IF p_change_reason_code IS NOT NULL
5201 AND p_change_reason_code <> nvl(l_budget_line_rec.change_reason_code,FND_API.G_MISS_CHAR)
5202 THEN
5203 IF p_change_reason_code = FND_API.G_MISS_CHAR THEN
5204 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xChangeReasonCode', TO_CHAR(NULL));
5205 ELSE
5206 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xChangeReasonCode', p_change_reason_code);
5207 END IF;
5208 END IF;
5209
5210 IF p_attribute_category IS NOT NULL
5211 AND p_attribute_category <> nvl(l_budget_line_rec.attribute_category,FND_API.G_MISS_CHAR)
5212 THEN
5213 IF p_attribute_category = FND_API.G_MISS_CHAR THEN
5214 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttributeCategory', TO_CHAR(NULL));
5215 ELSE
5216 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttributeCategory', p_attribute_category);
5217 END IF;
5218 END IF;
5219
5220 IF p_attribute1 IS NOT NULL
5221 AND p_attribute1 <> nvl(l_budget_line_rec.attribute1,FND_API.G_MISS_CHAR)
5222 THEN
5223 IF p_attribute1 = FND_API.G_MISS_CHAR THEN
5224 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute1', TO_CHAR(NULL));
5225 ELSE
5226 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute1', p_attribute1);
5227 END IF;
5228 END IF;
5229
5230 IF p_attribute2 IS NOT NULL
5231 AND p_attribute2 <> nvl(l_budget_line_rec.attribute2,FND_API.G_MISS_CHAR)
5232 THEN
5233 IF p_attribute2 = FND_API.G_MISS_CHAR THEN
5234 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute2', TO_CHAR(NULL));
5235 ELSE
5236 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute2', p_attribute2);
5237 END IF;
5238 END IF;
5239
5240 IF p_attribute3 IS NOT NULL
5241 AND p_attribute3 <> nvl(l_budget_line_rec.attribute3,FND_API.G_MISS_CHAR)
5242 THEN
5243 IF p_attribute3 = FND_API.G_MISS_CHAR THEN
5244 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute3', TO_CHAR(NULL));
5245 ELSE
5246 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute3', p_attribute3);
5247 END IF;
5248 END IF;
5249
5250 IF p_attribute4 IS NOT NULL
5251 AND p_attribute4 <> nvl(l_budget_line_rec.attribute4,FND_API.G_MISS_CHAR)
5252 THEN
5253 IF p_attribute4 = FND_API.G_MISS_CHAR THEN
5254 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute4', TO_CHAR(NULL));
5255 ELSE
5256 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute4', p_attribute4);
5257 END IF;
5258 END IF;
5259
5260 IF p_attribute5 IS NOT NULL
5261 AND p_attribute5 <> nvl(l_budget_line_rec.attribute5,FND_API.G_MISS_CHAR)
5262 THEN
5263 IF p_attribute5 = FND_API.G_MISS_CHAR THEN
5264 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute5', TO_CHAR(NULL));
5265 ELSE
5266 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute5', p_attribute5);
5267 END IF;
5268 END IF;
5269
5270 IF p_attribute6 IS NOT NULL
5271 AND p_attribute6 <> nvl(l_budget_line_rec.attribute6,FND_API.G_MISS_CHAR)
5272 THEN
5273 IF p_attribute6 = FND_API.G_MISS_CHAR THEN
5274 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute6', TO_CHAR(NULL));
5275 ELSE
5276 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute6', p_attribute6);
5277 END IF;
5278 END IF;
5279
5280 IF p_attribute7 IS NOT NULL
5281 AND p_attribute7 <> nvl(l_budget_line_rec.attribute7,FND_API.G_MISS_CHAR)
5282 THEN
5283 IF p_attribute7 = FND_API.G_MISS_CHAR THEN
5284 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute7', TO_CHAR(NULL));
5285 ELSE
5286 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute7', p_attribute7);
5287 END IF;
5288 END IF;
5289
5290 IF p_attribute8 IS NOT NULL
5291 AND p_attribute8 <> nvl(l_budget_line_rec.attribute8,FND_API.G_MISS_CHAR)
5292 THEN
5293 IF p_attribute8 = FND_API.G_MISS_CHAR THEN
5294 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute8', TO_CHAR(NULL));
5295 ELSE
5296 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute8', p_attribute8);
5297 END IF;
5298 END IF;
5299
5300 IF p_attribute9 IS NOT NULL
5301 AND p_attribute9 <> nvl(l_budget_line_rec.attribute9,FND_API.G_MISS_CHAR)
5302 THEN
5303 IF p_attribute9 = FND_API.G_MISS_CHAR THEN
5304 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute9', TO_CHAR(NULL));
5305 ELSE
5306 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute9', p_attribute9);
5307 END IF;
5308 END IF;
5309
5310 IF p_attribute10 IS NOT NULL
5311 AND p_attribute10 <> nvl(l_budget_line_rec.attribute10,FND_API.G_MISS_CHAR)
5312 THEN
5313 IF p_attribute10 = FND_API.G_MISS_CHAR THEN
5314 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute10', TO_CHAR(NULL));
5315 ELSE
5316 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute10', p_attribute10);
5317 END IF;
5318 END IF;
5319
5320 IF p_attribute11 IS NOT NULL
5321 AND p_attribute11 <> nvl(l_budget_line_rec.attribute11,FND_API.G_MISS_CHAR)
5322 THEN
5323 IF p_attribute11 = FND_API.G_MISS_CHAR THEN
5324 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute11', TO_CHAR(NULL));
5325 ELSE
5326 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute11', p_attribute11);
5327 END IF;
5328 END IF;
5329
5330 IF p_attribute12 IS NOT NULL
5331 AND p_attribute12 <> nvl(l_budget_line_rec.attribute12,FND_API.G_MISS_CHAR)
5332 THEN
5333 IF p_attribute12 = FND_API.G_MISS_CHAR THEN
5334 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute12', TO_CHAR(NULL));
5335 ELSE
5336 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute12', p_attribute12);
5337 END IF;
5338 END IF;
5339
5340 IF p_attribute13 IS NOT NULL
5341 AND p_attribute13 <> nvl(l_budget_line_rec.attribute13,FND_API.G_MISS_CHAR)
5342 THEN
5343 IF p_attribute13 = FND_API.G_MISS_CHAR THEN
5344 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute13', TO_CHAR(NULL));
5345 ELSE
5346 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute13', p_attribute13);
5347 END IF;
5348 END IF;
5349
5350 IF p_attribute14 IS NOT NULL
5351 AND p_attribute14 <> nvl(l_budget_line_rec.attribute14,FND_API.G_MISS_CHAR)
5352 THEN
5353 IF p_attribute14 = FND_API.G_MISS_CHAR THEN
5354 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute14', TO_CHAR(NULL));
5355 ELSE
5356 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute14', p_attribute14);
5357 END IF;
5358 END IF;
5359
5360 IF p_attribute15 IS NOT NULL
5361 AND p_attribute15 <> nvl(l_budget_line_rec.attribute15,FND_API.G_MISS_CHAR)
5362 THEN
5363 IF p_attribute15 = FND_API.G_MISS_CHAR THEN
5364 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute15', TO_CHAR(NULL));
5365 ELSE
5366 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xAttribute15', p_attribute15);
5367 END IF;
5368 END IF;
5369
5370 --Dates should always be bound instead of concatenating them as strings to
5371 --avoid conversion problems.
5372 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xLastUpdateDate', SYSDATE);
5373 DBMS_SQL.BIND_VARIABLE(l_cursor_id, ':xStartDate', p_start_date);
5374
5375
5376 l_rows := DBMS_SQL.execute(l_cursor_id);
5377
5378 --dbms_output.put_line('# rows processed: '||l_rows);
5379
5380 IF DBMS_SQL.is_open (l_cursor_id)
5381 THEN
5382 DBMS_SQL.close_cursor (l_cursor_id);
5383 END IF;
5384
5385 /* FPB2: MRC */
5386 BEGIN
5387 SELECT budget_line_id, budget_version_id --Bug 4224464
5388 INTO l_budget_line_id, l_budget_version_id
5389 FROM pa_budget_lines
5390 WHERE resource_assignment_id = p_resource_assignment_id
5391 AND start_date = p_start_date
5392 AND txn_currency_code = l_txn_currency_code;
5393 EXCEPTION
5394 WHEN no_data_found THEN
5395 l_budget_line_id := null; /* No budget line was updated */
5396 END;
5397 -- Bug Fix: 4569365. Removed MRC code.
5398
5399 /* FPB2: Proceed with MRC only if a budget line was update */
5400 --Bug 4224464: changed IF condition to determine whether update has happened or not
5401 /*
5402 IF nvl(l_rows,0) > 0 THEN
5403
5404 IF PA_MRC_FINPLAN.G_MRC_ENABLED_FOR_BUDGETS IS NULL THEN
5405 PA_MRC_FINPLAN.CHECK_MRC_INSTALL
5406 (x_return_status => l_return_status,
5407 x_msg_count => l_msg_count,
5408 x_msg_data => l_msg_data);
5409 END IF;
5410
5411 IF PA_MRC_FINPLAN.G_MRC_ENABLED_FOR_BUDGETS AND
5412 PA_MRC_FINPLAN.G_FINPLAN_MRC_OPTION_CODE = 'A' THEN
5413 PA_MRC_FINPLAN.MAINTAIN_ONE_MC_BUDGET_LINE
5414 (p_budget_line_id => l_budget_line_id,
5415 p_budget_version_id => l_budget_version_id,
5416 p_action => PA_MRC_FINPLAN.G_ACTION_UPDATE,
5417 x_return_status => l_return_status,
5418 x_msg_count => l_msg_count,
5419 x_msg_data => l_msg_data);
5420 END IF;
5421
5422 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5423 RAISE g_mrc_exception;
5424 END IF;
5425
5426 END IF;--nvl(l_rows,0) > 0
5427 */
5428 --need to check for zero or null values in the case of a PA or GL phased budget
5429 --if so budget line needs to be deleted.
5430
5431 --dbms_output.put_line('raw cost: '||NVL(to_char(l_budget_line_rec.raw_cost),'NULL'));
5432 --dbms_output.put_line('burdened cost: '||NVL(to_char(l_budget_line_rec.burdened_cost),'NULL'));
5433 --dbms_output.put_line('revenue: '||NVL(to_char(l_budget_line_rec.revenue),'NULL'));
5434 --dbms_output.put_line('quantity: '||NVL(to_char(l_budget_line_rec.quantity),'NULL'));
5435
5436 IF p_time_phased_type_code IN ('G','P')
5437 THEN
5438
5439 OPEN l_budget_line_csr( p_resource_assignment_id
5440 ,p_start_date );
5441
5442 FETCH l_budget_line_csr INTO l_budget_line_rec;
5443 CLOSE l_budget_line_csr;
5444
5445 --dbms_output.put_line('raw cost: '||NVL(to_char(l_budget_line_rec.raw_cost),'NULL'));
5446 --dbms_output.put_line('burdened cost: '||NVL(to_char(l_budget_line_rec.burdened_cost),'NULL'));
5447 --dbms_output.put_line('revenue: '||NVL(to_char(l_budget_line_rec.revenue),'NULL'));
5448 --dbms_output.put_line('quantity: '||NVL(to_char(l_budget_line_rec.quantity),'NULL'));
5449
5450 IF NVL(l_budget_line_rec.raw_cost,0) = 0
5451 AND NVL(l_budget_line_rec.burdened_cost,0) = 0
5452 AND NVL(l_budget_line_rec.revenue,0) = 0
5453 AND NVL(l_budget_line_rec.quantity,0) = 0
5454 THEN
5455
5456 BEGIN
5457 --dbms_output.put_line('About to delete the budget line because of zero values');
5458 PA_BUDGET_LINES_V_PKG.delete_row
5459 ( x_rowid => l_budget_line_rec.rowid );
5460 -- Bug Fix: 4569365. Removed MRC code.
5461 -- ,x_mrc_flag => 'Y'); /* FPB2: MRC */
5462
5463 -- Bug Fix: 4569365. Removed MRC code.
5464 /* FPB2: MRC */
5465 /*
5466 IF nvl(l_rows,0) > 0 THEN--Calling MRC APIs only if a budget line was updated
5467
5468 IF PA_MRC_FINPLAN.G_MRC_ENABLED_FOR_BUDGETS IS NULL THEN
5469 PA_MRC_FINPLAN.CHECK_MRC_INSTALL
5470 (x_return_status => l_return_status,
5471 x_msg_count => l_msg_count,
5472 x_msg_data => l_msg_data);
5473 END IF;
5474
5475 IF PA_MRC_FINPLAN.G_MRC_ENABLED_FOR_BUDGETS AND
5476 PA_MRC_FINPLAN.G_FINPLAN_MRC_OPTION_CODE = 'A' THEN
5477 PA_MRC_FINPLAN.MAINTAIN_ONE_MC_BUDGET_LINE
5478 (p_budget_line_id => l_budget_line_rec.budget_line_id,
5479 p_budget_version_id => l_budget_line_rec.budget_version_id,
5480 p_action => PA_MRC_FINPLAN.G_ACTION_DELETE,
5481 x_return_status => l_return_status,
5482 x_msg_count => l_msg_count,
5483 x_msg_data => l_msg_data);
5484 END IF;
5485
5486 IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
5487 RAISE g_mrc_exception;
5488 END IF;
5489 END IF; --nvl(l_rows,0) > 0
5490 */
5491 --this exception part is here because this procedure doesn't handle the exceptions itself.
5492 EXCEPTION
5493 WHEN OTHERS
5494 THEN
5495
5496 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5497 THEN
5498 FND_MSG_PUB.add_exc_msg
5499 ( p_pkg_name => 'PA_BUDGET_LINES_V_PKG'
5500 , p_procedure_name => 'DELETE_ROW'
5501 , p_error_text => SQLCODE );
5502 END IF;
5503 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
5504 END;
5505
5506 END IF;
5507 END IF; --time phased by PA or GL period
5508 END IF;--l_update_yes_flag = 'Y'
5509
5510 EXCEPTION
5511
5512 WHEN FND_API.G_EXC_ERROR
5513 THEN
5514
5515 ROLLBACK TO update_budget_line_sql_pvt;
5516
5517 p_return_status := FND_API.G_RET_STS_ERROR;
5518
5519 WHEN FND_API.G_EXC_UNEXPECTED_ERROR
5520 THEN
5521
5522 ROLLBACK TO update_budget_line_sql_pvt;
5523
5524 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5525
5526 WHEN OTHERS THEN
5527
5528 ROLLBACK TO update_budget_line_sql_pvt;
5529
5530 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
5531
5532 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
5533 THEN
5534 FND_MSG_PUB.add_exc_msg
5535 ( p_pkg_name => G_PKG_NAME
5536 , p_procedure_name => l_api_name );
5537
5538 END IF;
5539
5540
5541 END update_budget_line_sql;
5542
5543
5544 ----------------------------------------------------------------------------------------
5545 --Name: get_valid_period_dates
5546 --Type: Procedure
5547 --Description: This procedure can be used to get the valid begin and end date
5548 -- for a budget line
5549 --
5550 --
5551 --Called subprograms:
5552 --
5553 --
5554 --
5555 --History:
5556 -- 10-OCT-1996 L. de Werker Created
5557 -- 17-OCT-1996 L. de Werker Parameter p_period_name_out added, to enable the translation
5558 -- of begin and end date to a period name.
5559 -- 09-Nov-2004 dbora Bug 3986129: FP.M Web ADI Dev changes
5560 -- Modified to take care of the spec changes
5561 -- of pa_budget_check_pvt.get_valid_period_dates_Pvt
5562
5563 PROCEDURE get_valid_period_dates
5564 ( p_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5565 ,p_project_id IN NUMBER
5566 ,p_task_id IN NUMBER
5567 ,p_time_phased_type_code IN VARCHAR2
5568 ,p_entry_level_code IN VARCHAR2
5569 ,p_period_name_in IN VARCHAR2
5570 ,p_budget_start_date_in IN DATE
5571 ,p_budget_end_date_in IN DATE
5572 ,p_period_name_out OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5573 ,p_budget_start_date_out OUT NOCOPY DATE --File.Sql.39 bug 4440895
5574 ,p_budget_end_date_out OUT NOCOPY DATE --File.Sql.39 bug 4440895
5575
5576 -- Bug 3986129: FP.M Web ADI Dev changes
5577 ,p_context IN VARCHAR2
5578 ,p_calling_model_context IN VARCHAR2
5579 ,x_error_code OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5580 )
5581 IS
5582
5583 BEGIN
5584
5585 pa_budget_check_pvt.get_valid_period_dates_Pvt
5586 (p_return_status => p_return_status
5587 ,p_project_id => p_project_id
5588 ,p_task_id => p_task_id
5589 ,p_time_phased_type_code => p_time_phased_type_code
5590 ,p_entry_level_code => p_entry_level_code
5591 ,p_period_name_in => p_period_name_in
5592 ,p_budget_start_date_in => p_budget_start_date_in
5593 ,p_budget_end_date_in => p_budget_end_date_in
5594 ,p_period_name_out => p_period_name_out
5595 ,p_budget_start_date_out => p_budget_start_date_out
5596 ,p_budget_end_date_out => p_budget_end_date_out
5597
5598 -- Bug 3986129: FP.M Web ADI Dev changes
5599 ,p_context => p_context
5600 ,p_calling_model_context => p_calling_model_context
5601 ,x_error_code => x_error_code);
5602
5603 END get_valid_period_dates;
5604
5605
5606 ----------------------------------------------------------------------------------------
5607 --Name: check_entry_method_flags
5608 --Type: Procedure
5609 --Description: This procedure can be used to check whether it is allowed to pass
5610 -- cost quantity, raw_cost, burdened_cost, revenue and revenue quantity.
5611 --
5612 --
5613 --Called subprograms:
5614 --
5615 --
5616 --
5617 --History:
5618 -- 15-OCT-1996 L. de Werker Created
5619 -- 08-Nov-2004 dbora Bug 3986129: FP.M Web ADI Dev changes
5620 -- Modified to take care of the spec changes
5621 -- of pa_budget_check_pvt.check_entry_method_flags_pvt
5622
5623 PROCEDURE check_entry_method_flags
5624 ( p_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5625 ,p_budget_amount_code IN VARCHAR2
5626 ,p_budget_entry_method_code IN VARCHAR2
5627 ,p_quantity IN NUMBER
5628 ,p_raw_cost IN NUMBER
5629 ,p_burdened_cost IN NUMBER
5630 ,p_revenue IN NUMBER
5631 ,p_version_type IN VARCHAR2
5632 ,p_allow_qty_flag IN VARCHAR2
5633 ,p_allow_raw_cost_flag IN VARCHAR2
5634 ,p_allow_burdened_cost_flag IN VARCHAR2
5635 ,p_allow_revenue_flag IN VARCHAR2
5636
5637 -- Bug 3986129: FP.M Web ADI Dev changes, new parameters
5638 ,p_context IN VARCHAR2
5639 ,p_raw_cost_rate IN NUMBER
5640 ,p_burdened_cost_rate IN NUMBER
5641 ,p_bill_rate IN NUMBER
5642 ,p_allow_raw_cost_rate_flag IN VARCHAR2
5643 ,p_allow_burd_cost_rate_flag IN VARCHAR2
5644 ,p_allow_bill_rate_flag IN VARCHAR2
5645 ,x_webadi_error_code OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5646 )
5647 IS
5648
5649 BEGIN
5650
5651 pa_budget_check_pvt.check_entry_method_flags_pvt
5652 (p_return_status => p_return_status
5653 ,p_budget_amount_code => p_budget_amount_code
5654 ,p_budget_entry_method_code => p_budget_entry_method_code
5655 ,p_quantity => p_quantity
5656 ,p_raw_cost => p_raw_cost
5657 ,p_burdened_cost => p_burdened_cost
5658 ,p_revenue => p_revenue
5659 ,p_version_type => p_version_type
5660 ,p_allow_qty_flag => p_allow_qty_flag
5661 ,p_allow_raw_cost_flag => p_allow_raw_cost_flag
5662 ,p_allow_burdened_cost_flag => p_allow_burdened_cost_flag
5663 ,p_allow_revenue_flag => p_allow_revenue_flag
5664
5665 --Bug 3986129: FP.M Web ADI Dev changes
5666 ,p_context => p_context
5667 ,p_raw_cost_rate => p_raw_cost_rate
5668 ,p_burdened_cost_rate => p_burdened_cost_rate
5669 ,p_bill_rate => p_bill_rate
5670 ,p_allow_raw_cost_rate_flag => p_allow_raw_cost_rate_flag
5671 ,p_allow_burd_cost_rate_flag => p_allow_burd_cost_rate_flag
5672 ,p_allow_bill_rate_flag => p_allow_bill_rate_flag
5673 ,x_webadi_error_code => x_webadi_error_code);
5674
5675
5676 END check_entry_method_flags;
5677
5678
5679 --This procedure is created as part of FinPlan Development. All the validations
5680 --are shifted from insert_budget_line to this procedure. This procedure handles the
5681 --validations for both budget and finplan models
5682
5683 -- sgoteti 14-Feb-03 Created
5684 -- rravipat 24-Jun-04 Bug 3717093 Commented out the validation put
5685 -- included by hari on 11th may. The api is called
5686 -- with the same context for both old budgets model
5687 -- versions and nee budgets model versions.
5688 -- rishukla 09-May-05 Bug 4224464: FP M Changes - Added validation for
5689 -- actual amounts on Forecast lines.
5690 -- sgoteti 11-May-05 Added p_run_id parameter. This parameter will be used in web ADI flow only
5691 PROCEDURE Validate_Budget_Lines
5692 ( p_calling_context IN VARCHAR2 DEFAULT 'BUDGET_LINE_LEVEL_VALIDATION'
5693 ,p_run_id IN pa_fp_webadi_upload_inf.run_id%TYPE
5694 ,p_pa_project_id IN pa_projects_all.project_id%TYPE
5695 ,p_budget_type_code IN pa_budget_types.budget_type_code%TYPE
5696 ,p_fin_plan_type_id IN pa_fin_plan_types_b.fin_plan_type_id%TYPE
5697 ,p_version_type IN pa_budget_versions.version_type%TYPE
5698 ,p_resource_list_id IN pa_resource_lists_all_bg.resource_list_id%TYPE
5699 ,p_time_phased_code IN pa_proj_fp_options.cost_time_phased_code%TYPE
5700 ,p_budget_entry_method_code IN pa_budget_entry_methods.budget_entry_method_code%TYPE
5701 ,p_entry_level_code IN pa_proj_fp_options.cost_fin_plan_level_code%TYPE
5702 ,p_allow_qty_flag IN VARCHAR2
5703 ,p_allow_raw_cost_flag IN VARCHAR2
5704 ,p_allow_burdened_cost_flag IN VARCHAR2
5705 ,p_allow_revenue_flag IN VARCHAR2
5706 ,p_multi_currency_flag IN pa_proj_fp_options.plan_in_multi_curr_flag%TYPE
5707 ,p_project_cost_rate_type IN pa_proj_fp_options.project_cost_rate_type%TYPE
5708 ,p_project_cost_rate_date_typ IN pa_proj_fp_options.project_cost_rate_date_type%TYPE
5709 ,p_project_cost_rate_date IN pa_proj_fp_options.project_cost_rate_date%TYPE
5710 ,p_project_cost_exchange_rate IN pa_budget_lines.project_cost_exchange_rate%TYPE
5711 ,p_projfunc_cost_rate_type IN pa_proj_fp_options.projfunc_cost_rate_type%TYPE
5712 ,p_projfunc_cost_rate_date_typ IN pa_proj_fp_options.projfunc_cost_rate_date_type%TYPE
5713 ,p_projfunc_cost_rate_date IN pa_proj_fp_options.projfunc_cost_rate_date%TYPE
5714 ,p_projfunc_cost_exchange_rate IN pa_budget_lines.projfunc_cost_exchange_rate%TYPE
5715 ,p_project_rev_rate_type IN pa_proj_fp_options.project_rev_rate_type%TYPE
5716 ,p_project_rev_rate_date_typ IN pa_proj_fp_options.project_rev_rate_date_type%TYPE
5717 ,p_project_rev_rate_date IN pa_proj_fp_options.project_rev_rate_date%TYPE
5718 ,p_project_rev_exchange_rate IN pa_budget_lines.project_rev_exchange_rate%TYPE
5719 ,p_projfunc_rev_rate_type IN pa_proj_fp_options.projfunc_rev_rate_type%TYPE
5720 ,p_projfunc_rev_rate_date_typ IN pa_proj_fp_options.projfunc_rev_rate_date_type%TYPE
5721 ,p_projfunc_rev_rate_date IN pa_proj_fp_options.projfunc_rev_rate_date%TYPE
5722 ,p_projfunc_rev_exchange_rate IN pa_budget_lines.project_rev_exchange_rate%TYPE
5723
5724 /* Bug 3986129: FP.M Web ADI Dev changes: New parameters added */
5725 ,p_version_info_rec IN pa_fp_gen_amount_utils.fp_cols
5726 ,p_allow_raw_cost_rate_flag IN VARCHAR2
5727 ,p_allow_burd_cost_rate_flag IN VARCHAR2
5728 ,p_allow_bill_rate_flag IN VARCHAR2
5729 ,p_raw_cost_rate_tbl IN SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type()
5730 ,p_burd_cost_rate_tbl IN SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type()
5731 ,p_bill_rate_tbl IN SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type()
5732 ,p_uom_tbl IN SYSTEM.pa_varchar2_80_tbl_type := SYSTEM.pa_varchar2_80_tbl_type()
5733 ,p_planning_start_date_tbl IN SYSTEM.pa_date_tbl_type := SYSTEM.pa_date_tbl_type()
5734 ,p_planning_end_date_tbl IN SYSTEM.pa_date_tbl_type := SYSTEM.pa_date_tbl_type()
5735 ,p_delete_flag_tbl IN SYSTEM.pa_varchar2_1_tbl_type := SYSTEM.pa_varchar2_1_tbl_type()
5736 ,p_mfc_cost_type_tbl IN SYSTEM.PA_VARCHAR2_15_TBL_TYPE := SYSTEM.PA_VARCHAR2_15_TBL_TYPE()
5737 ,p_spread_curve_name_tbl IN SYSTEM.PA_VARCHAR2_240_TBL_TYPE := SYSTEM.PA_VARCHAR2_240_TBL_TYPE()
5738 ,p_sp_fixed_date_tbl IN SYSTEM.PA_DATE_TBL_TYPE := SYSTEM.PA_DATE_TBL_TYPE()
5739 ,p_etc_method_name_tbl IN SYSTEM.PA_VARCHAR2_80_TBL_TYPE := SYSTEM.PA_VARCHAR2_80_TBL_TYPE()
5740 ,p_spread_curve_id_tbl IN SYSTEM.PA_NUM_TBL_TYPE := SYSTEM.PA_NUM_TBL_TYPE()
5741 ,p_amount_type_tbl IN SYSTEM.PA_VARCHAR2_30_TBL_TYPE := SYSTEM.PA_VARCHAR2_30_TBL_TYPE()
5742 /* Bug 3986129: end*/
5743
5744 ,px_budget_lines_in IN OUT NOCOPY PA_BUDGET_PUB.G_BUDGET_LINES_IN_TBL%TYPE --File.Sql.39 bug 4440895
5745 /* Bug 3133930- a new output variable is introduced to return the error status */
5746 ,x_budget_lines_out OUT NOCOPY PA_BUDGET_PUB.G_BUDGET_LINES_OUT_TBL%TYPE --File.Sql.39 bug 4440895
5747 /* Bug 3986129: FP.M Web ADI Dev changes: New parameters added */
5748 ,x_mfc_cost_type_id_tbl OUT NOCOPY SYSTEM.pa_num_tbl_type --File.Sql.39 bug 4440895
5749 ,x_etc_method_code_tbl OUT NOCOPY SYSTEM.pa_varchar2_30_tbl_type --File.Sql.39 bug 4440895
5750 ,x_spread_curve_id_tbl OUT NOCOPY SYSTEM.pa_num_tbl_type --File.Sql.39 bug 4440895
5751 ,x_msg_count OUT NOCOPY NUMBER --File.Sql.39 bug 4440895
5752 ,x_msg_data OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5753 ,x_return_status OUT NOCOPY VARCHAR2 --File.Sql.39 bug 4440895
5754 )
5755 IS
5756
5757 --Declare a pl/sql table for storing the txn currencies of the plan type
5758
5759 --l_valid_txn_currencies_tbl pa_fp_webadi_pkg.l_txn_currency_code_tbl_typ; Bug 2871603
5760 --Bug 2871603 - Created a package pvt defn for l_txn_currency_code_tbl_typ and using it.
5761 l_valid_txn_currencies_tbl l_txn_currency_code_tbl_typ;
5762
5763 --following table will contain the top task planning levels.
5764 l_top_tasks_tbl key_value_rec_tbl_type;
5765 l_temp NUMBER;
5766
5767
5768 --This cursor is used to fetch the txn currencies of the plan type
5769 CURSOR l_plan_type_txn_curr_csr
5770 ( c_proj_fp_options_id pa_fp_txn_currencies.proj_fp_options_id%TYPE
5771 ,c_project_id pa_fp_txn_currencies.project_id%TYPE)
5772 IS
5773 SELECT txn_currency_code
5774 FROM pa_fp_txn_currencies ptxn
5775 ,pa_projects_all p
5776 WHERE p.project_id=c_project_id
5777 AND ptxn.project_id = p.project_id
5778 AND ptxn.txn_currency_code NOT IN (p.project_currency_code, p.projfunc_currency_code)
5779 AND ptxn.proj_fp_options_id = c_proj_fp_options_id; --made changes to the sql for bug 4886319 (performance)
5780
5781
5782 -- this cursor is used to fetch the txn currencies of the plan version for web adi context
5783 CURSOR l_plan_ver_txn_curr_csr
5784 ( c_fin_plan_type_id pa_fp_txn_currencies.fin_plan_type_id%TYPE
5785 ,c_project_id pa_fp_txn_currencies.project_id%TYPE
5786 ,c_fin_plan_version_id pa_fp_txn_currencies.fin_plan_version_id%TYPE)
5787 IS
5788 SELECT txn_currency_code
5789 FROM pa_fp_txn_currencies ptxn
5790 ,pa_projects_all p
5791 WHERE p.project_id = c_project_id
5792 AND ptxn.project_id = p.project_id
5793 AND ptxn.fin_plan_type_id = c_fin_plan_type_id
5794 AND ptxn.txn_currency_code NOT IN (p.project_currency_code, p.projfunc_currency_code)
5795 AND ptxn.fin_plan_version_id = c_fin_plan_version_id;
5796
5797 --cursor to get the unit_of_measure and track_as_labor_flag for this resource_list_member
5798 --and check for valid resource_list / member combination
5799 CURSOR l_resource_csr
5800 (c_resource_list_member_id NUMBER
5801 ,c_resource_list_id NUMBER)
5802 IS
5803 SELECT pr.unit_of_measure
5804 ,prlm.track_as_labor_flag
5805 ,prlm.migration_code
5806 FROM pa_resources pr
5807 ,pa_resource_lists prl
5808 ,pa_resource_list_members prlm
5809 WHERE prl.resource_list_id = c_resource_list_id
5810 AND pr.resource_id = prlm.resource_id
5811 AND prl.resource_list_id = prlm.resource_list_id
5812 AND prlm.resource_list_member_id = c_resource_list_member_id;
5813
5814 --cursor to get the unit_of_measure for FINPLAN Model - 3801891
5815 CURSOR l_resource_csr_fp
5816 (c_resource_list_member_id NUMBER)
5817 IS
5818 SELECT prlm.unit_of_measure,
5819 prlm.migration_code
5820 FROM pa_resource_list_members prlm
5821 WHERE prlm.resource_list_member_id = c_resource_list_member_id;
5822
5823 --cursor to get the field values associated to a AMG message
5824 CURSOR l_amg_project_csr
5825 (c_pa_project_id pa_projects.project_id%type)
5826 IS
5827 SELECT segment1
5828 FROM pa_projects p
5829 WHERE p.project_id = c_pa_project_id;
5830
5831 l_amg_project_rec l_amg_project_csr%ROWTYPE;
5832
5833 CURSOR l_amg_task_csr
5834 (c_pa_task_id pa_tasks.task_id%type)
5835 IS
5836 SELECT task_number
5837 FROM pa_tasks p
5838 WHERE p.task_id = c_pa_task_id;
5839
5840 --This cursor is used to get the approved rev plan type flag of the plan type
5841 --Added as part of the changes for fin plan model in FP L
5842 CURSOR l_approved_revenue_flag_csr
5843 ( c_fin_plan_type_id pa_fin_plan_types_b.fin_plan_type_id%TYPE
5844 ,c_project_id pa_projects_all.project_id%TYPE)
5845 IS
5846 SELECT approved_rev_plan_type_flag,
5847 proj_fp_options_id
5848 FROM pa_proj_fp_options
5849 WHERE project_id=c_project_id
5850 AND fin_plan_type_id=c_fin_plan_type_id
5851 AND fin_plan_option_level_code=PA_FP_CONSTANTS_PKG.G_OPTION_LEVEL_PLAN_TYPE;
5852
5853 /* Bug 4224464: FP M Changes Start */
5854 --Cursor to derive plan_class_code and etc_start_date for a budget version
5855 CURSOR budget_version_info_cur (c_budget_version_id IN NUMBER)
5856 IS
5857 SELECT pt.plan_class_code
5858 ,bv.etc_start_date
5859 FROM pa_budget_versions bv,
5860 pa_fin_plan_types_b pt
5861 WHERE bv.budget_version_id = c_budget_version_id
5862 AND pt.fin_plan_type_id = bv.fin_plan_type_id;
5863
5864 l_plan_class_code pa_fin_plan_types_b.plan_class_code%TYPE;
5865 l_etc_start_date pa_budget_versions.etc_start_date%TYPE;
5866 /* Bug 4224464: FP M Changes End */
5867
5868 l_app_rev_plan_type_flag pa_proj_fp_options.approved_rev_plan_type_flag%TYPE;
5869
5870 l_msg_count NUMBER := 0;
5871 l_data VARCHAR2(2000);
5872 l_msg_data VARCHAR2(2000);
5873 l_msg_index_out NUMBER;
5874 l_debug_mode VARCHAR2(1);
5875
5876 l_debug_level2 CONSTANT NUMBER := 2;
5877 l_debug_level3 CONSTANT NUMBER := 3;
5878 l_debug_level4 CONSTANT NUMBER := 4;
5879 l_debug_level5 CONSTANT NUMBER := 5;
5880
5881 l_return_status VARCHAR2(1);
5882 l_return_status_task NUMBER;
5883 l_unit_of_measure VARCHAR2(30);
5884 l_track_as_labor_flag VARCHAR2(1);
5885 l_err_code NUMBER;
5886 l_err_stage VARCHAR2(120);
5887 l_err_stack VARCHAR2(630);
5888 l_amg_segment1 VARCHAR2(25);
5889 l_amg_task_number VARCHAR2(50);
5890 l_amg_top_task_number VARCHAR2(50);
5891 l_any_error_occurred_flag VARCHAR2(1) :='N';
5892 l_budget_lines_tbl_index NUMBER;
5893 l_budget_amount_code pa_budget_types.budget_amount_code%TYPE;
5894 l_txn_tbl_index NUMBER;
5895 i NUMBER;
5896 l_valid_txn_curr BOOLEAN;
5897 l_txn_curr_code pa_fp_txn_currencies.txn_currency_code%TYPE;
5898 l_parent_member_id pa_resource_list_members.parent_member_id%TYPE;
5899 l_conv_attrs_to_be_validated VARCHAR2(10);
5900 l_module_name VARCHAR2(80);
5901 l_top_task_id pa_tasks.top_task_id%TYPE;
5902 l_dummy VARCHAR2(1);
5903 l_txn_currency_code pa_fp_txn_currencies.txn_currency_code%TYPE;
5904 l_multi_currency_billing_flag pa_projects_all.multi_currency_billing_flag%TYPE;
5905 l_project_currency_code pa_projects_all.project_currency_code%TYPE ;
5906 l_projfunc_currency_code pa_projects_all.projfunc_currency_code%TYPE ;
5907 l_project_cost_rate_type pa_projects_all.project_rate_type%TYPE ;
5908 l_projfunc_cost_rate_type pa_projects_all.projfunc_cost_rate_type%TYPE ;
5909 l_project_bil_rate_type pa_projects_all.project_bil_rate_type%TYPE ;
5910 l_projfunc_bil_rate_type pa_projects_all.projfunc_bil_rate_type%TYPE ;
5911 l_top_task_planning_level pa_fp_elements.top_task_planning_level%TYPE;
5912 l_res_planning_level pa_fp_elements.resource_planning_level%TYPE;
5913 l_uncategorized_res_list_id pa_resource_list_members.resource_list_id%TYPE;
5914 l_uncategorized_rlmid pa_resource_list_members.resource_list_member_id%TYPE;
5915 l_uncategorized_resid pa_resource_list_members.resource_id%TYPE;
5916 l_res_group_name pa_resource_list_members.alias%TYPE;
5917 l_valid_rlmid VARCHAR2(1);
5918 l_fin_plan_type_name pa_fin_plan_types_tl.name%TYPE;
5919 l_resource_type_code pa_resource_list_members.resource_type_code%TYPE;
5920 l_context_info pa_fin_plan_types_tl.name%TYPE;
5921 l_pm_product_code pa_budget_lines.pm_product_code%TYPE;
5922
5923 -- Cursor used in validating the product code
5924 Cursor p_product_code_csr (c_pm_product_code IN VARCHAR2)
5925 Is
5926 Select 'X'
5927 from pa_lookups
5928 where lookup_type='PM_PRODUCT_CODE'
5929 and lookup_code = c_pm_product_code;
5930
5931 -- Bug 3986129: FP.M Web ADI Dev changes
5932 l_spread_curve_id pa_spread_curves_b.spread_curve_id%TYPE;
5933 l_valid_spread_curve VARCHAR2(1) := 'Y';
5934 l_etc_method_code pa_lookups.lookup_code%TYPE;
5935 l_valid_etc_method VARCHAR2(1) := 'Y';
5936 l_mfc_cost_type_id CST_COST_TYPES_V.cost_type_id%TYPE;
5937 l_valid_mfc_cost_type VARCHAR2(1) := 'Y';
5938
5939 l_webadi_sp_fix_date DATE;
5940 l_webadi_err_code_tbl SYSTEM.pa_varchar2_30_tbl_type := SYSTEM.pa_varchar2_30_tbl_type();
5941 l_new_error_code pa_lookups.lookup_code%TYPE;
5942 l_webadi_err_task_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
5943 l_webadi_err_rlm_id_tbl SYSTEM.pa_num_tbl_type := SYSTEM.pa_num_tbl_type();
5944 l_webadi_err_txn_curr_tbl SYSTEM.pa_varchar2_30_tbl_type := SYSTEM.pa_varchar2_30_tbl_type();
5945 l_webadi_err_amt_type_tbl SYSTEM.pa_varchar2_30_tbl_type := SYSTEM.pa_varchar2_30_tbl_type();
5946 l_webadi_err_prd_flag VARCHAR2(1) := 'N';
5947 l_webadi_cont_proc_flag VARCHAR2(1):= 'Y';
5948
5949 TYPE web_adi_err_code_lookup IS TABLE OF VARCHAR2(30) INDEX BY VARCHAR2(30);
5950 l_wa_error_code_lookup web_adi_err_code_lookup;
5951
5952 -- for bug 3954329
5953 l_rlm_migration_code pa_resource_lists_all_bg.migration_code%TYPE;
5954
5955 l_wa_project_cost_rate_typ pa_proj_fp_options.project_cost_rate_type%TYPE;
5956 l_wa_project_cost_rate_dt_typ pa_proj_fp_options.project_cost_rate_date_type%TYPE;
5957 l_wa_project_cost_rate_date pa_proj_fp_options.project_cost_rate_date%TYPE;
5958 l_wa_project_cost_exc_rate pa_budget_lines.project_cost_exchange_rate%TYPE;
5959 l_wa_projfunc_cost_rate_typ pa_proj_fp_options.projfunc_cost_rate_type%TYPE;
5960 l_wa_projfunc_cost_rate_dt_typ pa_proj_fp_options.projfunc_cost_rate_date_type%TYPE;
5961 l_wa_projfunc_cost_rate_date pa_proj_fp_options.projfunc_cost_rate_date%TYPE;
5962 l_wa_projfunc_cost_exc_rate pa_budget_lines.projfunc_cost_exchange_rate%TYPE;
5963 l_wa_project_rev_rate_typ pa_proj_fp_options.project_rev_rate_type%TYPE;
5964 l_wa_project_rev_rate_dt_typ pa_proj_fp_options.project_rev_rate_date_type%TYPE;
5965 l_wa_project_rev_rate_date pa_proj_fp_options.project_rev_rate_date%TYPE;
5966 l_wa_project_rev_exc_rate pa_budget_lines.project_rev_exchange_rate%TYPE;
5967 l_wa_projfunc_rev_rate_typ pa_proj_fp_options.projfunc_rev_rate_type%TYPE;
5968 l_wa_projfunc_rev_rate_dt_typ pa_proj_fp_options.projfunc_rev_rate_date_type%TYPE;
5969 l_wa_projfunc_rev_rate_date pa_proj_fp_options.projfunc_rev_rate_date%TYPE;
5970 l_wa_projfunc_rev_exc_rate pa_budget_lines.project_rev_exchange_rate%TYPE;
5971 l_wa_val_conv_attr_flag VARCHAR2(1);
5972 l_calling_model_context VARCHAR(30);
5973
5974
5975 -- Added for the bug 4414062
5976 l_period_time_phased_code VARCHAR(1);
5977 l_period_plan_start_date DATE;
5978 l_period_plan_end_date DATE;
5979
5980 -- bug 4462614: add the following cursor to be executed for Web ADI flow
5981 -- to check if the budget lines passed belongs to a CI version
5982 CURSOR check_and_return_ci_version (c_budget_version_id pa_budget_versions.budget_version_id%TYPE)
5983 IS
5984 SELECT pbv.ci_id,
5985 agr.agreement_currency_code
5986 FROM pa_budget_versions pbv,
5987 pa_agreements_all agr
5988 WHERE pbv.budget_version_id = c_budget_version_id
5989 AND pbv.agreement_id = agr.agreement_id;
5990
5991 l_webadi_agr_curr_code pa_agreements_all.agreement_currency_code%TYPE;
5992 l_webadi_ci_id pa_budget_versions.ci_id%TYPE;
5993
5994 l_period_start_date DATE;
5995 l_period_end_date DATE;
5996 l_plan_start_date pa_resource_assignments.planning_start_date%type;
5997 l_plan_end_date pa_resource_assignments.planning_end_date%type;
5998
5999 TYPE varchr_32_index_date_tbl_typ IS TABLE OF DATE INDEX BY VARCHAR2(32);
6000 TYPE varchr_32_index_varchr_tbl_typ IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(32);
6001
6002 l_plan_start_date_tbl varchr_32_index_date_tbl_typ;
6003 l_plan_end_date_tbl varchr_32_index_date_tbl_typ;
6004 l_task_name_tbl varchr_32_index_varchr_tbl_typ;
6005 l_resource_alias_tbl varchr_32_index_varchr_tbl_typ;
6006 l_distinct_taskid_rlmid_index VARCHAR2(32); --Index to store task id and rlm id comnination.
6007 l_resource_alias pa_resource_list_members.alias%type;
6008
6009 TYPE varchr_120_index_num_tbl_typ IS TABLE OF NUMBER(15) INDEX BY VARCHAR2(120);
6010 l_distinct_rlmid_idx VARCHAR2(120); --Index to store rlm id and resource alias
6011 l_rlm_id_tbl varchr_120_index_num_tbl_typ;
6012
6013 TYPE varchr_30_index_num_tbl_typ IS TABLE OF NUMBER(15) INDEX BY VARCHAR2(30);
6014 l_distinct_tskid_idx VARCHAR2(30); --Index to store task id and task name
6015 l_tsk_id_tbl varchr_30_index_num_tbl_typ;
6016
6017 --Added thses date tables for bug#4488926.
6018 TYPE date_tbl_type IS TABLE OF DATE INDEX BY VARCHAR2(20);
6019 l_period_start_date_tbl date_tbl_type;
6020 l_period_end_date_tbl date_tbl_type;
6021 l_period_plan_start_date_tbl date_tbl_type;
6022 l_period_plan_end_date_tbl date_tbl_type;
6023 l_proj_fp_options_id pa_proj_fp_options.proj_fp_options_id%TYPE;
6024
6025 l_fixed_date_sp_id number;
6026 l_resource_assignment_id number;
6027 l_planning_start_date date;
6028 l_planning_end_date date;
6029 l_sp_fixed_date date;
6030 l_invalid_plandates_flag varchar2(1);
6031 l_invalid_resassgn_flag varchar2(1);
6032 l_project_number varchar2(25);
6033 l_raid_hash_table res_assign_tbl_type1;
6034
6035 l_cbs_enabled_project varchar2(1) :='N'; -- Added for CBS 16604257
6036
6037 BEGIN
6038 x_msg_count :=0;
6039 x_return_status := FND_API.G_RET_STS_SUCCESS;
6040 l_debug_mode := NVL(FND_PROFILE.value('PA_DEBUG_MODE'),'N');
6041 l_module_name := 'Validate_Budget_Lines: ' || g_module_name;
6042
6043 IF l_debug_mode = 'Y' THEN
6044 pa_debug.set_curr_function( p_function => 'Validate_Budget_Lines',
6045 p_debug_mode => l_debug_mode );
6046
6047 --dbms_output.put_line('----- Entering into validate_budget_lines-------');
6048 pa_debug.g_err_stage:= 'Validating input parameters';
6049 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6050 END IF;
6051
6052 /* Bug 3717093 This api is called both for new and old budgets model versions
6053 -- hari 11th may
6054 IF ( p_calling_context = 'BUDGET_LINE_LEVEL_VALIDATION' AND p_budget_type_code IS NULL )
6055 THEN
6056 PA_UTILS.ADD_MESSAGE
6057 (p_app_short_name => 'PA',
6058 p_msg_name => 'PA_FP_INV_PARAM_PASSED');
6059 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6060 END IF;
6061 Bug 3717093 */
6062
6063 /*============================================================+
6064 | Bug 3717093 : Replaced the above check with the following. |
6065 +============================================================*/
6066 IF ( p_calling_context in('RES_ASSGNMT_LEVEL_VALIDATION','UPDATE_PLANNING_ELEMENT_ATTR') AND p_budget_type_code IS NOT NULL )
6067 THEN
6068 PA_UTILS.ADD_MESSAGE
6069 (p_app_short_name => 'PA',
6070 p_msg_name => 'PA_FP_INV_PARAM_PASSED');
6071 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6072 END IF;
6073
6074 IF(p_fin_plan_type_id IS NULL) AND (p_budget_type_code IS NOT NULL) THEN
6075
6076 IF(p_pa_project_id IS NULL OR
6077 p_resource_list_id IS NULL OR
6078 p_budget_entry_method_code IS NULL OR
6079 p_entry_level_code IS NULL ) THEN
6080
6081 IF l_debug_mode = 'Y' THEN
6082
6083 pa_debug.g_err_stage:= 'p_pa_project_id is ' || p_pa_project_id;
6084 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6085
6086 pa_debug.g_err_stage:= 'p_budget_type_code is ' || p_budget_type_code;
6087 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6088
6089 pa_debug.g_err_stage:= 'p_resource_list_id is ' || p_resource_list_id;
6090 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6091
6092 pa_debug.g_err_stage:= 'p_budget_entry_method_code is ' ||
6093 p_budget_entry_method_code;
6094 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6095
6096 pa_debug.g_err_stage:= 'p_entry_level_code is ' || p_entry_level_code;
6097 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6098
6099 END IF;
6100
6101 PA_UTILS.ADD_MESSAGE
6102 (p_app_short_name => 'PA',
6103 p_msg_name => 'PA_FP_INV_PARAM_PASSED');
6104 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6105
6106 END IF;
6107 END IF;
6108
6109 --<Patchset M: B and F impact changes : AMG:> -- Bug # 3507156
6110 --Added a check to error out budget lines with time phased code as 'R'(Date Range) and p_entry_level_code as 'M'
6111 -- as it is not supported in FP M model.
6112
6113 IF(p_fin_plan_type_id IS NOT NULL) AND (p_budget_type_code IS NULL) THEN
6114
6115 IF(p_pa_project_id IS NULL OR
6116 p_version_type IS NULL OR
6117 p_resource_list_id IS NULL OR
6118 p_time_phased_code IS NULL OR
6119 p_entry_level_code IS NULL OR
6120 p_multi_currency_flag IS NULL OR
6121 p_time_phased_code = 'R' OR
6122 p_entry_level_code = 'M')THEN
6123
6124 IF l_debug_mode = 'Y' THEN
6125 pa_debug.g_err_stage:= 'p_pa_project_id is ' || p_pa_project_id;
6126 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6127
6128 pa_debug.g_err_stage:= 'p_fin_plan_type_id is ' || p_fin_plan_type_id;
6129 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6130
6131 pa_debug.g_err_stage:= 'p_version_type is ' || p_version_type;
6132 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6133
6134 pa_debug.g_err_stage:= 'p_resource_list_id is ' || p_resource_list_id;
6135 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6136
6137 pa_debug.g_err_stage:= 'p_time_phased_code is ' || p_time_phased_code;
6138 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6139
6140 pa_debug.g_err_stage:= 'p_entry_level_code is ' || p_entry_level_code;
6141 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6142
6143 pa_debug.g_err_stage:= 'p_multi_currency_flag is ' || p_multi_currency_flag;
6144 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6145
6146 END IF;
6147 PA_UTILS.ADD_MESSAGE
6148 (p_app_short_name => 'PA',
6149 p_msg_name => 'PA_FP_INV_PARAM_PASSED');
6150 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6151
6152 END IF;
6153 END IF;
6154
6155 --Get the CBS flag 16604257
6156 l_cbs_enabled_project := PA_ALTERNATE_TASK_PVT.Is_Cbs_Enabled(p_Project_Id => p_pa_project_id);
6157 IF p_budget_type_code is not null and l_cbs_enabled_project ='Y' THEN --Form based project are not supported for CBS
6158 PA_UTILS.ADD_MESSAGE( p_app_short_name => 'PA'
6159 ,p_msg_name => 'PA_FP_CBS_ENABLED'
6160 );
6161 l_return_status := FND_API.G_RET_STS_ERROR;
6162 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6163 END IF;
6164
6165 -- Bug 3986129: FP.M Web ADI Dev changes:
6166 IF p_calling_context = 'WEBADI' THEN
6167 IF p_version_info_rec.x_plan_in_multi_curr_flag IS NULL THEN
6168 IF l_debug_mode = 'Y' THEN
6169 pa_debug.g_err_stage:= 'For Web ADI context the version info rec is null';
6170 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6171 END IF;
6172 PA_UTILS.ADD_MESSAGE
6173 (p_app_short_name => 'PA',
6174 p_msg_name => 'PA_FP_INV_PARAM_PASSED',
6175 p_token1 => 'PROCEDURENAME',
6176 p_value1 => l_module_name);
6177 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6178 END IF;
6179 IF px_budget_lines_in.COUNT <> p_raw_cost_rate_tbl.COUNT OR
6180 px_budget_lines_in.COUNT <> p_burd_cost_rate_tbl.COUNT OR
6181 px_budget_lines_in.COUNT <> p_bill_rate_tbl.COUNT OR
6182 px_budget_lines_in.COUNT <> p_uom_tbl.COUNT OR
6183 px_budget_lines_in.COUNT <> p_planning_start_date_tbl.COUNT OR
6184 px_budget_lines_in.COUNT <> p_planning_end_date_tbl.COUNT OR
6185 px_budget_lines_in.COUNT <> p_delete_flag_tbl.COUNT OR
6186 px_budget_lines_in.COUNT <> p_mfc_cost_type_tbl.COUNT OR
6187 px_budget_lines_in.COUNT <> p_spread_curve_name_tbl.COUNT OR
6188 px_budget_lines_in.COUNT <> p_sp_fixed_date_tbl.COUNT OR
6189 px_budget_lines_in.COUNT <> p_etc_method_name_tbl.COUNT THEN
6190 IF l_debug_mode = 'Y' THEN
6191 pa_debug.g_err_stage:= 'For Web ADI context the input tables are not equal';
6192 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6193 END IF;
6194 PA_UTILS.ADD_MESSAGE
6195 (p_app_short_name => 'PA',
6196 p_msg_name => 'PA_FP_INV_PARAM_PASSED',
6197 p_token1 => 'PROCEDURENAME',
6198 p_value1 => l_module_name);
6199 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6200 END IF;
6201
6202 -- initializing the out table type parameters
6203 x_mfc_cost_type_id_tbl := SYSTEM.pa_num_tbl_type();
6204 x_etc_method_code_tbl := SYSTEM.pa_varchar2_30_tbl_type();
6205 x_spread_curve_id_tbl := SYSTEM.pa_num_tbl_type();
6206
6207 -- initializing the web adi error code lookup table:
6208 -- this is required to get the validation failure context, so that appropriate lookup code
6209 -- for web adi context can be used to stamp the interface table corresponding the error
6210 -- code returned from the currency conversion validating api.
6211 l_wa_error_code_lookup ('PA_FP_INVALID_RATE_TYPE') := 'PA_FP_WA_INV_RATE_TYPE';
6212 l_wa_error_code_lookup ('PA_FP_INVALID_RATE_DATE_TYPE') := 'PA_FP_WA_INV_RATE_DATE_TYPE';
6213 l_wa_error_code_lookup ('PA_FP_INVALID_RATE_DATE') := 'PA_FP_WA_INV_RATE_DATE';
6214 l_wa_error_code_lookup ('PA_FP_USER_EXCH_RATE_REQ') := 'PA_FP_WA_USER_EXCH_RATE_REQ';
6215 l_wa_error_code_lookup ('PA_FP_RATE_TYPE_REQ') := 'PA_FP_WA_INV_RATE_TYPE';
6216
6217 END IF;
6218
6219
6220 IF p_calling_context = 'UPDATE_PLANNING_ELEMENT_ATTR' THEN
6221 IF px_budget_lines_in.COUNT <> p_uom_tbl.COUNT OR
6222 px_budget_lines_in.COUNT <> p_planning_start_date_tbl.COUNT OR
6223 px_budget_lines_in.COUNT <> p_planning_end_date_tbl.COUNT OR
6224 px_budget_lines_in.COUNT <> p_mfc_cost_type_tbl.COUNT OR
6225 px_budget_lines_in.COUNT <> p_spread_curve_name_tbl.COUNT OR
6226 px_budget_lines_in.COUNT <> p_sp_fixed_date_tbl.COUNT OR
6227 px_budget_lines_in.COUNT <> p_etc_method_name_tbl.COUNT THEN
6228 IF l_debug_mode = 'Y' THEN
6229 pa_debug.g_err_stage:= 'For UPDATE_PLANNING_ELEMENT_ATTR context the input tables are not equal';
6230 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6231 END IF;
6232 PA_UTILS.ADD_MESSAGE
6233 (p_app_short_name => 'PA',
6234 p_msg_name => 'PA_FP_INV_PARAM_PASSED',
6235 p_token1 => 'PROCEDURENAME',
6236 p_value1 => l_module_name);
6237 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6238 END IF;
6239
6240 -- initializing the out table type parameters
6241 x_mfc_cost_type_id_tbl := SYSTEM.pa_num_tbl_type();
6242 x_etc_method_code_tbl := SYSTEM.pa_varchar2_30_tbl_type();
6243 x_spread_curve_id_tbl := SYSTEM.pa_num_tbl_type();
6244
6245 Select spread_curve_id
6246 into l_fixed_date_sp_id
6247 from pa_spread_curves_b
6248 where spread_curve_code = 'FIXED_DATE';
6249
6250 select segment1
6251 into l_project_number
6252 from pa_projects_all
6253 where project_id=p_pa_project_id;
6254
6255 END IF; -- Bug 5509192
6256
6257 --Set API return status to success
6258 x_return_status := FND_API.G_RET_STS_SUCCESS;
6259
6260 -- Get segment1 for AMG messages
6261 OPEN l_amg_project_csr( p_pa_project_id );
6262 FETCH l_amg_project_csr INTO l_amg_project_rec;
6263 CLOSE l_amg_project_csr;
6264
6265 --AMG UT2. Moved this piece of code from if plan_type_id <> null to here.
6266 --Get the uncategorized resource list info.If the resource is uncategorized
6267 --resource list member id should be set to uncategorized resource list member id
6268 pa_get_resource.Get_Uncateg_Resource_Info
6269 (p_resource_list_id => l_uncategorized_res_list_id,
6270 p_resource_list_member_id => l_uncategorized_rlmid,
6271 p_resource_id => l_uncategorized_resid,
6272 p_track_as_labor_flag => l_track_as_labor_flag,
6273 p_err_code => l_err_code,
6274 p_err_stage => l_err_stage,
6275 p_err_stack => l_err_stack );
6276
6277 IF l_err_code <> 0 THEN
6278 IF NOT pa_project_pvt.check_valid_message(l_err_stage) THEN
6279 pa_interface_utils_pub.map_new_amg_msg
6280 ( p_old_message_code => 'PA_NO_UNCATEGORIZED_LIST'
6281 ,p_msg_attribute => 'CHANGE'
6282 ,p_resize_flag => 'N'
6283 ,p_msg_context => 'BUDG'
6284 ,p_attribute1 => l_amg_project_rec.segment1
6285 ,p_attribute2 => ''
6286 ,p_attribute3 => p_budget_type_code
6287 ,p_attribute4 => ''
6288 ,p_attribute5 => '');
6289 ELSE
6290 pa_interface_utils_pub.map_new_amg_msg
6291 ( p_old_message_code => l_err_stage
6292 ,p_msg_attribute => 'CHANGE'
6293 ,p_resize_flag => 'N'
6294 ,p_msg_context => 'BUDG'
6295 ,p_attribute1 => l_amg_project_rec.segment1
6296 ,p_attribute2 => ''
6297 ,p_attribute3 => p_budget_type_code
6298 ,p_attribute4 => ''
6299 ,p_attribute5 => '');
6300 END IF;
6301
6302 IF l_debug_mode = 'Y' THEN
6303 pa_debug.g_err_stage:= 'Could not obtain uncategorized resource list info';
6304 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level5);
6305 END IF;
6306 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc; --AMG UT2
6307 END IF; -- IF l_err_code <> 0 THEN
6308
6309
6310 -- Get the budget amount code so that it can be used later
6311 IF (p_budget_type_code IS NOT NULL) THEN
6312
6313 /*Get the budget amount code. Check whether the project type allows the
6314 creation of plan versions with obtained budget amounT code.
6315 */
6316 OPEN l_budget_amount_code_csr( p_budget_type_code );
6317 FETCH l_budget_amount_code_csr
6318 INTO l_budget_amount_code; --will be used later on during validation of Budget lines.
6319 CLOSE l_budget_amount_code_csr;
6320 END IF;
6321
6322
6323 --Get the approved revenue plan type flag and txn currencies for the plan type so that the
6324 --txn currencies for the plan version can be validated later.
6325 IF(p_fin_plan_type_id IS NOT NULL) THEN
6326 OPEN l_approved_revenue_flag_csr( p_fin_plan_type_id
6327 ,p_pa_project_id);
6328 FETCH l_approved_revenue_flag_csr INTO l_app_rev_plan_type_flag , l_proj_fp_options_id; --for bug 4886319
6329 CLOSE l_approved_revenue_flag_csr;
6330
6331 --Bug 4290310. Changed the if condition to read the txn currency for budget version level when the
6332 --budget version id is passed.
6333 IF (p_calling_context = 'WEBADI' OR p_version_info_rec.x_budget_version_id is not null) THEN
6334 OPEN l_plan_ver_txn_curr_csr( p_fin_plan_type_id
6335 ,p_pa_project_id
6336 ,p_version_info_rec.x_budget_version_id);
6337 FETCH l_plan_ver_txn_curr_csr BULK COLLECT
6338 INTO l_valid_txn_currencies_tbl;
6339
6340 CLOSE l_plan_ver_txn_curr_csr;
6341 ELSE
6342 OPEN l_plan_type_txn_curr_csr( l_proj_fp_options_id
6343 ,p_pa_project_id);
6344 FETCH l_plan_type_txn_curr_csr BULK COLLECT
6345 INTO l_valid_txn_currencies_tbl;
6346
6347 CLOSE l_plan_type_txn_curr_csr;
6348 END IF;
6349
6350 --Get the project and project functional currencies so that they can be used later
6351 pa_fin_plan_utils.Get_Project_Curr_Attributes
6352 ( p_project_id => p_pa_project_id
6353 ,x_multi_currency_billing_flag => l_multi_currency_billing_flag
6354 ,x_project_currency_code => l_project_currency_code
6355 ,x_projfunc_currency_code => l_projfunc_currency_code
6356 ,x_project_cost_rate_type => l_project_cost_rate_type
6357 ,x_projfunc_cost_rate_type => l_projfunc_cost_rate_type
6358 ,x_project_bil_rate_type => l_project_bil_rate_type
6359 ,x_projfunc_bil_rate_type => l_projfunc_bil_rate_type
6360 ,x_return_status => x_return_status
6361 ,x_msg_count => x_msg_count
6362 ,x_msg_data => x_msg_data);
6363
6364 IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
6365
6366 IF l_debug_mode = 'Y' THEN
6367 pa_debug.g_err_stage:= 'pa_fin_plan_utils.Get_Project_Curr_Attributes errored out for project' ||p_pa_project_id;
6368 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6369
6370 END IF;
6371 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6372
6373 END IF;
6374
6375 -- Get the plan type name
6376 SELECT name
6377 INTO l_fin_plan_type_name
6378 FROM pa_fin_plan_types_vl
6379 WHERE fin_plan_type_id = p_fin_plan_type_id;
6380
6381
6382 -- bug 4462614: added the following check for CI version for webadi context
6383 IF (p_calling_context = 'WEBADI' AND
6384 Nvl(l_app_rev_plan_type_flag, 'N') = 'Y') THEN
6385 -- open the cursor to get the ci_id and agr_curr_code
6386 OPEN check_and_return_ci_version(p_version_info_rec.x_budget_version_id);
6387 FETCH check_and_return_ci_version
6388 INTO l_webadi_ci_id,
6389 l_webadi_agr_curr_code;
6390 CLOSE check_and_return_ci_version;
6391 END IF;
6392
6393 END IF; --IF(p_fin_plan_type_id IS NOT NULL) THEN
6394
6395 --Bug 4488926.Deriving the l_period_time_phased_code only once for passed budget version id.
6396 l_period_time_phased_code := p_time_phased_code; --Use the i/p parameter to get this value.
6397 --if p_time_phased_code was passed as null we try to derive the time phase code.
6398 IF(l_period_time_phased_code is null)
6399 THEN
6400 l_period_time_phased_code := PA_FIN_PLAN_UTILS.Get_Time_Phased_code(p_version_info_rec.x_budget_version_id);
6401 END IF;
6402
6403
6404 IF px_budget_lines_in.exists(px_budget_lines_in.first) THEN
6405 --Loop thru the pl/sql table and validate each budget line
6406 FOR i IN px_budget_lines_in.first..px_budget_lines_in.last LOOP
6407 /* Bug 3133930 */
6408 x_budget_lines_out(i).return_status := FND_API.G_RET_STS_SUCCESS;
6409 --Initialise all the global variables to null
6410 pa_budget_pvt.g_Task_number := NULL;
6411 pa_budget_pvt.g_start_date := NULL;
6412 pa_budget_pvt.g_resource_alias := NULL;
6413
6414
6415 /* Bug 3218822 - PM_PRODUCT_CODE could be Null. We need valid it if it is NOT NULL */
6416
6417 IF px_budget_lines_in(i).pm_product_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
6418 OR px_budget_lines_in(i).pm_product_code IS NOT NULL
6419 THEN
6420
6421 /* Validating as done in bug# 2413400 */
6422 OPEN p_product_code_csr (px_budget_lines_in(i).pm_product_code);
6423 FETCH p_product_code_csr INTO l_pm_product_code;
6424 CLOSE p_product_code_csr;
6425 IF l_pm_product_code <> 'X'
6426 THEN
6427 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
6428 THEN
6429 pa_interface_utils_pub.map_new_amg_msg
6430 ( p_old_message_code => 'PA_PRODUCT_CODE_IS_INVALID'
6431 ,p_msg_attribute => 'CHANGE'
6432 ,p_resize_flag => 'N'
6433 ,p_msg_context => 'GENERAL'
6434 ,p_attribute1 => ''
6435 ,p_attribute2 => ''
6436 ,p_attribute3 => ''
6437 ,p_attribute4 => ''
6438 ,p_attribute5 => '');
6439 END IF;
6440 IF l_debug_mode = 'Y' THEN
6441 pa_debug.g_err_stage:= 'PM Product code is invalid';
6442 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6443 END IF;
6444 x_return_status := FND_API.G_RET_STS_ERROR;
6445 x_budget_lines_out(i).return_status := FND_API.G_RET_STS_ERROR;
6446 l_any_error_occurred_flag:='Y';
6447 END IF;
6448
6449 END IF;
6450
6451
6452
6453 /* End of bug fix for Bug 3218822 */
6454
6455 -- checking if for project level planning, tasks ids are passed as 0 or not for web adi context
6456 IF p_calling_context = 'WEBADI' THEN -- Bug 3986129: FP.M Web ADI Dev changes
6457 IF p_entry_level_code = 'P' THEN
6458 IF px_budget_lines_in(i).pa_task_id <> 0 THEN
6459 l_webadi_err_code_tbl.extend(1);
6460 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_TASK_IS_NOT_PROJECT';
6461 l_webadi_err_task_id_tbl.extend(1);
6462 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
6463 l_webadi_err_rlm_id_tbl.extend(1);
6464 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
6465 l_webadi_err_txn_curr_tbl.extend(1);
6466 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
6467 l_webadi_err_amt_type_tbl.extend(1);
6468 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
6469 END IF;
6470 END IF;
6471 END IF; -- p_context = WEBADI
6472 -- convert pm_task_reference to pa_task_id
6473 -- if both task id and reference are NULL or not passed, we will assume that budgetting is
6474 -- done at the project level and that requires l_task_id to be '0'
6475 -- if budgeting at the project level,then ignore all tasks
6476 IF p_entry_level_code = 'P' THEN
6477 px_budget_lines_in(i).pa_task_id := 0;
6478
6479 ELSIF p_entry_level_code in ('T','L','M') THEN
6480 --Added a null check in the if below for the bug#4479835. The API pa_project_pvt.Convert_pm_taskref_to_id
6481 --should be called to derive the pa_task_id if pa_task_id is null
6482 IF (px_budget_lines_in(i).pa_task_id is null OR px_budget_lines_in(i).pa_task_id <> 0) THEN
6483
6484 --Selecting the index if it will be based on pa_task_id or pm_ask_reference. This index is decided on the
6485 --basis of whther this (pa_project_pvt.Convert_pm_taskref_to_id ) API call would honour the
6486 --pa_task_id or pm_task_reference. The rule is pa_task_id is honoured if both are passed to the API
6487 --otherwise whichever value is passed that value is honoured by the API.
6488 --Also note while preparing the index we are prepending 'TSKID' or 'TSKREF' before the actual values.
6489 --The index would always be in this format.
6490 IF(px_budget_lines_in(i).pa_task_id <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM AND
6491 px_budget_lines_in(i).pa_task_id is not null)
6492 THEN
6493 --Prepending the word 'TSKID' before the pa_task_id value while preparing the index.
6494 l_distinct_tskid_idx := 'TSKID' || px_budget_lines_in(i).pa_task_id;
6495 ELSIF( px_budget_lines_in(i).pm_task_reference <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR AND
6496 px_budget_lines_in(i).pm_task_reference is not null)
6497 THEN
6498 --Prepending the word 'TSKREF' before the pm_task_reference value while preparing the index.
6499 l_distinct_tskid_idx := 'TSKREF' || px_budget_lines_in(i).pm_task_reference;
6500 END IF;
6501
6502 --l_tsk_id_tbl table would be used to cache the pa_task_id for the pa_task_id/pm_task_reference passed.
6503 -- This table would store the value for pa_task_id everytime a new task_id or pm_task_reference is passed.
6504 --The table is indexed by index 'l_distinct_tskid_idx' which could be either pm_task_reference or
6505 --pa_task_id.
6506 --Check in the table if the value is already present for this index(which is one of
6507 --pa_task_id/pm_task_reference). If present then read the task_id from the table for this index
6508 --else call the api.
6509 IF( NOT(l_tsk_id_tbl.exists(l_distinct_tskid_idx) ) )
6510 THEN
6511 pa_project_pvt.Convert_pm_taskref_to_id
6512 ( p_pa_project_id => p_pa_project_id,
6513 p_pa_task_id => px_budget_lines_in(i).pa_task_id,
6514 p_pm_task_reference => px_budget_lines_in(i).pm_task_reference,
6515 p_out_task_id => px_budget_lines_in(i).pa_task_id,
6516 p_return_status => x_return_status );
6517
6518 IF l_debug_mode = 'Y' THEN
6519 pa_debug.g_err_stage:= 'Converted Task Id is ' || px_budget_lines_in(i).pa_task_id;
6520 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
6521 END IF;
6522
6523 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
6524 /* Bug 3133930- set the return status to the new output variable */
6525 x_budget_lines_out(i).return_status := x_return_status;
6526
6527 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
6528 ELSIF x_return_status = FND_API.G_RET_STS_ERROR THEN
6529 -- exception is raised here because we cannot go ahead and do further validations
6530 -- as other validations depend upon task id to be correct.
6531 --RAISE FND_API.G_EXC_ERROR; AMG UT2
6532 x_budget_lines_out(i).return_status := x_return_status;
6533 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
6534 --Changed the elsif below for bug#4488926.
6535 ELSIF (px_budget_lines_in(i).pa_task_id IS NOT NULL) THEN /*if the API above executes successfully
6536 then pa_task_id would never be null*/
6537 --If the API completes successfully then store the task_id in the l_tsk_id_tbl at the location
6538 --indexed by l_distinct_tskid_idx.
6539 l_tsk_id_tbl(l_distinct_tskid_idx) := px_budget_lines_in(i).pa_task_id;
6540 --Also if the index was based on task_reference then we derive task_id for this, but next time
6541 --possibly task_id could be passed which has been derived from this task_reference. So we
6542 --should store this derived task_id also in the table.
6543 --More importantly this task_id should be stored at the location indexed by
6544 --'TSKID' || px_budget_lines_in(i).pa_task_id. Here prepending the TSKID and the value
6545 --px_budget_lines_in(i).pa_task_id was derived in the above API call as o/p parameter.
6546 IF(l_distinct_tskid_idx = 'TSKREF' || px_budget_lines_in(i).pm_task_reference)
6547 THEN
6548 IF(l_tsk_id_tbl.exists('TSKID' || px_budget_lines_in(i).pa_task_id))
6549 THEN
6550 --If the task_id derived from this task_reference is already present then dont store
6551 --it again.
6552 null;
6553 ELSE
6554 --Derived task_id should be stored at the location indexed by
6555 --'TSKID' || px_budget_lines_in(i).pa_task_id. Here prepending the TSKID and the value
6556 --px_budget_lines_in(i).pa_task_id was derived in the above API call as o/p parameter.
6557 --Storing this value would ensure that next time if this task_id is passed we dont
6558 --call the API.
6559 l_tsk_id_tbl('TSKID' || px_budget_lines_in(i).pa_task_id) :=
6560 px_budget_lines_in(i).pa_task_id;
6561 END IF;
6562 END IF;
6563 END IF;
6564 ELSE --IF( NOT(l_tsk_id_tbl.exists(l_distinct_tskid_idx) ) )
6565 --If the value is already there in the table for this index(task_id/task_ref) then read it from table
6566 --for this index.
6567 px_budget_lines_in(i).pa_task_id := l_tsk_id_tbl(l_distinct_tskid_idx) ;
6568 END IF;--IF( NOT(l_tsk_id_tbl.exists(l_distinct_tskid_idx) ) )
6569
6570 END IF;
6571 END IF;
6572
6573
6574 -- get the task number. This task number is required as input to map_new_amg_msg API.
6575
6576 IF px_budget_lines_in(i).pa_task_id <> 0 THEN
6577
6578 l_amg_task_number := pa_interface_utils_pub.get_task_number_amg
6579 ( p_task_number=> ''
6580 ,p_task_reference => px_budget_lines_in(i).pm_task_reference
6581 ,p_task_id => px_budget_lines_in(i).pa_task_id);
6582 /* Bug 3124283: Added substr below */
6583 pa_budget_pvt.g_task_number := substrb(l_amg_task_number,1,25);
6584 ELSE
6585 pa_budget_pvt.g_task_number := substrb(l_amg_project_rec.segment1,1,25); --Added for the bug 4421602.
6586 END IF;
6587
6588 -- <Patchset M:B and F impact changes : AMG:> -- Bug # 3507156
6589 -- Added a check for old model(p_budget_type_code) or new model(p_fin_plan_type_id) as the processing
6590 -- of the parameter p_entry_level_code is different for both.
6591
6592 IF(p_budget_type_code IS NOT NULL) THEN --Budget Model
6593
6594 IF p_entry_level_code = 'T' THEN -- then check whether it is top task
6595 IF px_budget_lines_in(i).pa_task_id <> pa_task_utils.get_top_task_id( px_budget_lines_in(i).pa_task_id ) THEN
6596 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6597 pa_interface_utils_pub.map_new_amg_msg
6598 ( p_old_message_code => 'PA_TASK_IS_NOT_TOP'
6599 ,p_msg_attribute => 'CHANGE'
6600 ,p_resize_flag => 'N'
6601 ,p_msg_context => 'TASK'
6602 ,p_attribute1 => l_amg_project_rec.segment1
6603 ,p_attribute2 => l_amg_task_number
6604 ,p_attribute3 => ''
6605 ,p_attribute4 => ''
6606 ,p_attribute5 => '');
6607 END IF;
6608 -- RAISE FND_API.G_EXC_ERROR;
6609 x_return_status := FND_API.G_RET_STS_ERROR;
6610 /* Bug 3133930- set the return status to the new output variable */
6611 x_budget_lines_out(i).return_status := FND_API.G_RET_STS_ERROR;
6612
6613 l_any_error_occurred_flag:='Y';
6614 END IF;
6615 ELSIF p_entry_level_code = 'L' -- then check whether it is lowest task
6616 THEN
6617 pa_tasks_pkg.verify_lowest_level_task( l_return_status_task,
6618 px_budget_lines_in(i).pa_task_id);
6619 IF l_return_status_task <> 0 THEN
6620 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
6621 THEN
6622 pa_interface_utils_pub.map_new_amg_msg
6623 ( p_old_message_code => 'PA_TASK_IS_NOT_LOWEST'
6624 ,p_msg_attribute => 'CHANGE'
6625 ,p_resize_flag => 'N'
6626 ,p_msg_context => 'TASK'
6627 ,p_attribute1 => l_amg_project_rec.segment1
6628 ,p_attribute2 => l_amg_task_number
6629 ,p_attribute3 => ''
6630 ,p_attribute4 => ''
6631 ,p_attribute5 => '');
6632 END IF;
6633 --RAISE FND_API.G_EXC_ERROR;
6634 x_return_status := FND_API.G_RET_STS_ERROR;
6635 /* Bug 3133930- set the return status to the new output variable */
6636 x_budget_lines_out(i).return_status := x_return_status;
6637
6638 l_any_error_occurred_flag:='Y';
6639 END IF;
6640
6641 ELSIF p_entry_level_code = 'M' -- then check whether it is a top or
6642 -- lowest level tasks
6643 THEN
6644 --Added check to prevent the user from entering the amounts for both
6645 --top task and one of its sub tasks.
6646 l_top_task_id := pa_task_utils.get_top_task_id( px_budget_lines_in(i).pa_task_id );
6647
6648 l_top_task_planning_level := NULL;
6649
6650 IF px_budget_lines_in(i).pa_task_id = nvl(l_top_task_id,-99) THEN
6651
6652 l_top_task_planning_level := PA_FP_CONSTANTS_PKG.G_TASK_PLAN_LEVEL_TOP;
6653
6654 ELSE
6655 pa_tasks_pkg.verify_lowest_level_task( l_return_status_task
6656 , px_budget_lines_in(i).pa_task_id);
6657 IF l_return_status_task <> 0 THEN
6658 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
6659 THEN
6660 pa_interface_utils_pub.map_new_amg_msg
6661 ( p_old_message_code => 'PA_TASK_IS_NOT_TOP_OR_LOWEST'
6662 ,p_msg_attribute => 'CHANGE'
6663 ,p_resize_flag => 'Y'
6664 ,p_msg_context => 'TASK'
6665 ,p_attribute1 => l_amg_project_rec.segment1
6666 ,p_attribute2 => l_amg_task_number
6667 ,p_attribute3 => ''
6668 ,p_attribute4 => ''
6669 ,p_attribute5 => '');
6670 END IF;
6671 --RAISE FND_API.G_EXC_ERROR;
6672 x_return_status := FND_API.G_RET_STS_ERROR;
6673 /* Bug 3133930- set the return status to the new output variable */
6674 x_budget_lines_out(i).return_status := x_return_status;
6675
6676 l_any_error_occurred_flag:='Y';
6677 ELSE--The task passed is a lowest task
6678 l_top_task_planning_level := PA_FP_CONSTANTS_PKG.G_TASK_PLAN_LEVEL_LOWEST;
6679 END IF;
6680
6681
6682 END IF;--iF px_budget_lines_in(i).pa_task_id = nvl(l_top_task_id,-99) THEN
6683
6684 -- Check the planning level only if the task entered is valid.
6685 IF l_top_task_planning_level IS NOT NULL THEN
6686
6687 --See whether the planning level is already cached in l_top_tasks_tbl. If it is
6688 --cached then that can be used. For bug 3678314
6689 l_temp:=NULL;
6690 FOR kk IN 1..l_top_tasks_tbl.COUNT LOOP
6691
6692 IF l_top_tasks_tbl(kk).key=l_top_task_id THEN
6693 l_temp:=kk;
6694 EXIT;
6695 END IF;
6696
6697 END LOOP;
6698
6699 IF (l_temp IS NOT NULL) THEN
6700 IF l_top_task_planning_level <> l_top_tasks_tbl(l_temp).value THEN
6701
6702 l_amg_top_task_number := pa_interface_utils_pub.get_task_number_amg
6703 ( p_task_number=> ''
6704 ,p_task_reference => NULL
6705 ,p_task_id => l_top_task_id);
6706
6707
6708 PA_UTILS.ADD_MESSAGE
6709 ( p_app_short_name => 'PA',
6710 p_msg_name => 'PA_FP_AMTS_FOR_BOTH_TOP_LOWEST',
6711 p_token1 => 'PROJECT',
6712 p_value1 => l_amg_project_rec.segment1,
6713 p_token2 => 'TASK',
6714 p_value2 => l_amg_top_task_number);
6715
6716
6717 x_return_status := FND_API.G_RET_STS_ERROR;
6718 /* Bug 3133930- set the return status to the new output variable */
6719 x_budget_lines_out(i).return_status := x_return_status;
6720
6721 l_any_error_occurred_flag := 'Y';
6722 END IF;
6723 ELSE
6724 --Cache the values derived so that they can be used again. Bug 3678314
6725 l_temp := l_top_tasks_tbl.COUNT + 1;
6726 l_top_tasks_tbl(l_temp).key := l_top_task_id;
6727 l_top_tasks_tbl(l_temp).value := l_top_task_planning_level;
6728
6729 END IF;
6730 END IF;
6731
6732 END IF; -- IF p_entry_level_code = T THEN
6733
6734 ELSIF (p_fin_plan_type_id IS NOT NULL) THEN --FinPlan Model
6735 -- <Patchset M:B and F impact changes : AMG:> -- Bug # 3507156
6736 -- If Planning level is Top, then only top task or project level planning is allowed.
6737
6738 IF p_entry_level_code = 'T' THEN -- then check whether it is a task at top level or project level
6739 IF (px_budget_lines_in(i).pa_task_id <> 0)
6740 AND (px_budget_lines_in(i).pa_task_id <> pa_task_utils.get_top_task_id( px_budget_lines_in(i).pa_task_id )) THEN
6741 IF p_calling_context = 'WEBADI' THEN -- Bug 3986129: FP.M Web ADI Dev changes
6742 l_webadi_err_code_tbl.extend(1);
6743 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_TASK_IS_NOT_TOP';
6744 l_webadi_err_task_id_tbl.extend(1);
6745 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
6746 l_webadi_err_rlm_id_tbl.extend(1);
6747 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
6748 l_webadi_err_txn_curr_tbl.extend(1);
6749 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
6750 l_webadi_err_amt_type_tbl.extend(1);
6751 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
6752 ELSE
6753 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
6754 pa_interface_utils_pub.map_new_amg_msg
6755 ( p_old_message_code => 'PA_TASK_IS_NOT_TOP'
6756 ,p_msg_attribute => 'CHANGE'
6757 ,p_resize_flag => 'N'
6758 ,p_msg_context => 'TASK'
6759 ,p_attribute1 => l_amg_project_rec.segment1
6760 ,p_attribute2 => l_amg_task_number
6761 ,p_attribute3 => ''
6762 ,p_attribute4 => ''
6763 ,p_attribute5 => '');
6764 END IF;
6765 -- RAISE FND_API.G_EXC_ERROR;
6766 x_return_status := FND_API.G_RET_STS_ERROR;
6767 /* Bug 3133930- set the return status to the new output variable */
6768 x_budget_lines_out(i).return_status := FND_API.G_RET_STS_ERROR;
6769 END IF;
6770 l_any_error_occurred_flag:='Y';
6771 END IF;
6772
6773 -- <Patchset M:B and F impact changes : AMG:> --Bug # 3507156
6774 --If Planning level is lowest, then no validations - any task can be planned
6775 --As there is already a check for p_entry_level_code = 'M' we do not need to check it again.
6776
6777 END IF; -- if p_entry_level_code = 'T'
6778
6779 END IF ; -- If fin_plan_type_id is NOT NULL
6780
6781
6782 --Bug 16604257 : CBS RBS Phase 2 API changes
6783 IF l_cbs_enabled_project = 'Y' THEN
6784
6785 IF px_budget_lines_in(i).cbs_element_id IS NULL OR
6786 px_budget_lines_in(i).cbs_element_id = PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
6787
6788 px_budget_lines_in(i).cbs_element_id := PA_ALTERNATE_TASK_PVT.convert_cost_code_to_id(
6789 px_budget_lines_in(i).cost_code ,p_pa_project_id );
6790 END IF;
6791
6792 IF px_budget_lines_in(i).cbs_element_id IS NOT NULL AND
6793 px_budget_lines_in(i).cbs_element_id <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM THEN
6794
6795 PA_ALTERNATE_TASK_PVT.Is_Cost_Element_Valid(
6796 p_Cbs_Element_Id =>px_budget_lines_in(i).cbs_element_id,
6797 p_Task_Id =>px_budget_lines_in(i).pa_task_id,
6798 p_Project_Id =>p_pa_project_id,
6799 x_return_status => x_return_status,
6800 x_msg_count => x_msg_count,
6801 x_msg_data => x_msg_data
6802 );
6803
6804 IF x_return_status <> 'S' THEN
6805 PA_UTILS.ADD_MESSAGE( p_app_short_name => 'PA'
6806 ,p_msg_name => x_msg_data
6807 );
6808 x_return_status := FND_API.G_RET_STS_ERROR;
6809 x_budget_lines_out(i).return_status := x_return_status;
6810
6811 END IF;
6812
6813 ELSE
6814 PA_UTILS.ADD_MESSAGE( p_app_short_name => 'PA'
6815 ,p_msg_name => 'PA_CBS_WP__COST_CODE_MNDTR'
6816 ,p_token1 => 'RES_NAME'
6817 ,p_value1 => PA_TASK_UTILS.get_resource_name(px_budget_lines_in(i).resource_list_member_id)
6818 );
6819 x_return_status := FND_API.G_RET_STS_ERROR;
6820 x_budget_lines_out(i).return_status := x_return_status;
6821 --RAISE FND_API.G_EXC_ERROR;
6822
6823
6824 END IF;
6825
6826 END IF; -- 16604257
6827
6828
6829 -- check the validity of the period_name,budget_start_date and
6830 -- budget_end_date for budget lines and return values of budget_start_date
6831 -- and budget_end_date for given period_name
6832 -- hari 11th may
6833 IF ( p_calling_context not in ('RES_ASSGNMT_LEVEL_VALIDATION','UPDATE_PLANNING_ELEMENT_ATTR') )
6834 THEN
6835 IF p_calling_context = 'WEBADI' THEN -- Bug 3986129: FP.M Web ADI Dev changes
6836 -- checking if the planning start date/end date has been explcitely nulled ou
6837 IF p_planning_start_date_tbl(i) = FND_API.G_MISS_DATE OR
6838 p_planning_end_date_tbl(i) = FND_API.G_MISS_DATE THEN
6839 l_webadi_err_code_tbl.extend(1);
6840 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_PLAN_DATES_NULLED_OUT';
6841 l_webadi_err_task_id_tbl.extend(1);
6842 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
6843 l_webadi_err_rlm_id_tbl.extend(1);
6844 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
6845 l_webadi_err_txn_curr_tbl.extend(1);
6846 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
6847 l_webadi_err_amt_type_tbl.extend(1);
6848 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
6849 l_any_error_occurred_flag:='Y';
6850 END IF;
6851
6852 -- before calling get_valid_periods_dates validating the followings
6853 IF (px_budget_lines_in(i).budget_start_date IS NOT NULL OR
6854 px_budget_lines_in(i).budget_start_date <> FND_API.G_MISS_DATE) AND
6855 (px_budget_lines_in(i).budget_end_date IS NOT NULL OR
6856 px_budget_lines_in(i).budget_end_date <> FND_API.G_MISS_DATE) THEN
6857
6858 -- checking if the budget line start date/ end date falls between
6859 -- the planning start date/ end date
6860 -- Added for the bug 4414062
6861
6862 --After the derivation of l_period_time_phased_code, if l_period_time_phased_code = N
6863 --then it means its a non periodic finplan case
6864 IF ( l_period_time_phased_code <> 'N')
6865 THEN
6866 ---Added this code for bug#4488926. Caching the values of l_period_plan_start_date and
6867 --l_period_plan_end_date
6868 IF ( NOT(l_period_plan_start_date_tbl.exists(to_char(p_planning_start_date_tbl(i)))
6869 AND l_period_plan_end_date_tbl.exists(to_char(p_planning_end_date_tbl(i)))))
6870 THEN
6871 --For periodic case get the start and end dates.
6872 l_period_plan_start_date := PA_FIN_PLAN_UTILS.get_period_start_date(p_planning_start_date_tbl(i),l_period_time_phased_code);
6873 l_period_plan_end_date := PA_FIN_PLAN_UTILS.get_period_end_date (p_planning_end_date_tbl(i) , l_period_time_phased_code);
6874 l_period_plan_start_date_tbl(to_char(p_planning_start_date_tbl(i))) := l_period_plan_start_date;
6875 l_period_plan_end_date_tbl(to_char(p_planning_end_date_tbl(i))) := l_period_plan_end_date;
6876 ELSE
6877 l_period_plan_start_date := l_period_plan_start_date_tbl(to_char(p_planning_start_date_tbl(i)));
6878 l_period_plan_end_date := l_period_plan_end_date_tbl(to_char(p_planning_end_date_tbl(i)));
6879 END IF;
6880 ELSE
6881 --Its a non periodic case.
6882 l_period_plan_start_date := p_planning_start_date_tbl(i);
6883 l_period_plan_end_date := p_planning_end_date_tbl(i);
6884 END IF;
6885
6886
6887
6888
6889 IF px_budget_lines_in(i).budget_start_date < l_period_plan_start_date OR
6890 px_budget_lines_in(i).budget_end_date > l_period_plan_end_date THEN
6891 -- throwing error
6892 l_webadi_err_code_tbl.extend(1);
6893 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_BL_OUT_OF_PLAN_RANGE';
6894 l_webadi_err_task_id_tbl.extend(1);
6895 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
6896 l_webadi_err_rlm_id_tbl.extend(1);
6897 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
6898 l_webadi_err_txn_curr_tbl.extend(1);
6899 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
6900 l_webadi_err_amt_type_tbl.extend(1);
6901 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
6902 l_any_error_occurred_flag:='Y';
6903 END IF;
6904 END IF;
6905
6906 IF p_budget_type_code IS NOT NULL THEN
6907 l_calling_model_context := 'BUDGETSMODEL';
6908 ELSIF p_fin_plan_type_id IS NOT NULL THEN
6909 l_calling_model_context := 'FINPLANMODEL';
6910 END IF;
6911
6912 get_valid_period_dates
6913 ( p_project_id => p_pa_project_id
6914 ,p_task_id => px_budget_lines_in(i).pa_task_id
6915 ,p_time_phased_type_code => p_time_phased_code
6916 ,p_entry_level_code => p_entry_level_code
6917 ,p_period_name_in => px_budget_lines_in(i).period_name
6918 ,p_budget_start_date_in => px_budget_lines_in(i).budget_start_date
6919 ,p_budget_end_date_in => px_budget_lines_in(i).budget_end_date
6920 ,p_period_name_out => px_budget_lines_in(i).period_name
6921 ,p_budget_start_date_out => px_budget_lines_in(i).budget_start_date
6922 ,p_budget_end_date_out => px_budget_lines_in(i).budget_end_date
6923 ,p_calling_model_context => l_calling_model_context
6924 ,p_context => 'WEBADI'
6925 ,p_return_status => x_return_status
6926 ,x_error_code => l_new_error_code);
6927
6928 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
6929 -- populationg the error tbl variables to call process_errors at the end
6930 l_webadi_err_code_tbl.extend(1);
6931 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := l_new_error_code;
6932 l_webadi_err_task_id_tbl.extend(1);
6933 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
6934 l_webadi_err_rlm_id_tbl.extend(1);
6935 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
6936 l_webadi_err_txn_curr_tbl.extend(1);
6937 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
6938 l_webadi_err_amt_type_tbl.extend(1);
6939 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
6940 END IF;
6941 ELSE -- p_context <> 'WEBADI'
6942
6943 IF p_budget_type_code IS NOT NULL THEN
6944 l_calling_model_context := 'BUDGETSMODEL';
6945 ELSIF p_fin_plan_type_id IS NOT NULL THEN
6946 l_calling_model_context := 'FINPLANMODEL';
6947 END IF;
6948
6949 IF (l_calling_model_context = 'BUDGETSMODEL') or (NOT(p_time_phased_code = 'N' AND -- Bug no 5846942
6950 (px_budget_lines_in(i).budget_start_date IS NULL
6951 OR px_budget_lines_in(i).budget_start_date = FND_API.G_MISS_DATE )
6952 AND (px_budget_lines_in(i).budget_end_date IS NULL
6953 OR px_budget_lines_in(i).budget_end_date = FND_API.G_MISS_DATE )) )THEN
6954
6955
6956 get_valid_period_dates
6957 ( p_project_id => p_pa_project_id
6958 ,p_task_id => px_budget_lines_in(i).pa_task_id
6959 ,p_time_phased_type_code => p_time_phased_code
6960 ,p_entry_level_code => p_entry_level_code
6961 ,p_period_name_in => px_budget_lines_in(i).period_name
6962 ,p_budget_start_date_in => px_budget_lines_in(i).budget_start_date
6963 ,p_budget_end_date_in => px_budget_lines_in(i).budget_end_date
6964 ,p_period_name_out => px_budget_lines_in(i).period_name
6965 ,p_budget_start_date_out => px_budget_lines_in(i).budget_start_date
6966 ,p_budget_end_date_out => px_budget_lines_in(i).budget_end_date
6967 ,p_return_status => x_return_status
6968 ,p_calling_model_context => l_calling_model_context
6969 ,x_error_code => l_new_error_code);
6970 END IF;
6971 END IF; -- Bug 3986129
6972
6973 pa_budget_pvt.g_start_date := px_budget_lines_in(i).budget_start_date;
6974 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
6975 -- RAISE FND_API.G_EXC_ERROR;
6976 -- as the API get_valid_period_dates adds the error msg to the stack hence we
6977 -- do not need to add the error msg in this API.
6978 /* Bug 3133930- set the return status to the new output variable */
6979 x_budget_lines_out(i).return_status := x_return_status;
6980 l_any_error_occurred_flag:='Y';
6981 END IF;
6982 END IF; --p_calling_context <> 'RES_ASSGNMT_LEVEL_VALIDATION','UPDATE_PLANNING_ELEMENT_ATTR'
6983
6984 IF p_calling_context <> 'UPDATE_PLANNING_ELEMENT_ATTR' then -- Bug 5509192
6985 --every budget line need to be checked for it's amount values.
6986 IF p_fin_plan_type_id IS NULL THEN
6987 --Budget Model.Do not pass version type and amount flags
6988
6989 pa_budget_pvt.check_entry_method_flags
6990 ( p_budget_amount_code => l_budget_amount_code
6991 ,p_budget_entry_method_code => p_budget_entry_method_code
6992 ,p_quantity => px_budget_lines_in(i).quantity
6993 ,p_raw_cost => px_budget_lines_in(i).raw_cost
6994 ,p_burdened_cost => px_budget_lines_in(i).burdened_cost
6995 ,p_revenue => px_budget_lines_in(i).revenue
6996 ,p_return_status => x_return_status
6997
6998 -- Bug 3986129: FP.M Web ADI Dev changes
6999 ,x_webadi_error_code => l_new_error_code);
7000
7001 ELSE
7002 --Finplan model.Pass version type and other amount flags
7003 IF p_calling_context = 'WEBADI' THEN -- Bug 3986129: FP.M Web ADI Dev changes
7004 pa_budget_pvt.check_entry_method_flags
7005 ( p_budget_amount_code => NULL
7006 ,p_budget_entry_method_code => p_budget_entry_method_code
7007 ,p_quantity => px_budget_lines_in(i).quantity
7008 ,p_raw_cost => px_budget_lines_in(i).raw_cost
7009 ,p_burdened_cost => px_budget_lines_in(i).burdened_cost
7010 ,p_revenue => px_budget_lines_in(i).revenue
7011 ,p_return_status => x_return_status
7012 ,p_version_type => p_version_type
7013 ,p_allow_qty_flag => p_allow_qty_flag
7014 ,p_allow_raw_cost_flag => p_allow_raw_cost_flag
7015 ,p_allow_burdened_cost_flag => p_allow_burdened_cost_flag
7016 ,p_allow_revenue_flag => p_allow_revenue_flag
7017 ,p_context => 'WEBADI'
7018 ,p_raw_cost_rate => p_raw_cost_rate_tbl(i)
7019 ,p_burdened_cost_rate => p_burd_cost_rate_tbl(i)
7020 ,p_bill_rate => p_bill_rate_tbl(i)
7021 ,p_allow_raw_cost_rate_flag => p_allow_raw_cost_rate_flag
7022 ,p_allow_burd_cost_rate_flag => p_allow_burd_cost_rate_flag
7023 ,p_allow_bill_rate_flag => p_allow_bill_rate_flag
7024 ,x_webadi_error_code => l_new_error_code);
7025
7026 IF x_return_status = FND_API.G_RET_STS_ERROR THEN
7027 l_webadi_err_code_tbl.extend(1);
7028 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := l_new_error_code;
7029 l_webadi_err_task_id_tbl.extend(1);
7030 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7031 l_webadi_err_rlm_id_tbl.extend(1);
7032 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7033 l_webadi_err_txn_curr_tbl.extend(1);
7034 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7035 l_webadi_err_amt_type_tbl.extend(1);
7036 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7037 END IF;
7038 ELSE -- p_calling_context <> 'WEBADI'
7039 pa_budget_pvt.check_entry_method_flags
7040 ( p_budget_amount_code => NULL
7041 ,p_budget_entry_method_code => p_budget_entry_method_code
7042 ,p_quantity => px_budget_lines_in(i).quantity
7043 ,p_raw_cost => px_budget_lines_in(i).raw_cost
7044 ,p_burdened_cost => px_budget_lines_in(i).burdened_cost
7045 ,p_revenue => px_budget_lines_in(i).revenue
7046 ,p_return_status => x_return_status
7047 ,p_version_type => p_version_type
7048 ,p_allow_qty_flag => p_allow_qty_flag
7049 ,p_allow_raw_cost_flag => p_allow_raw_cost_flag
7050 ,p_allow_burdened_cost_flag => p_allow_burdened_cost_flag
7051 ,p_allow_revenue_flag => p_allow_revenue_flag
7052 ,x_webadi_error_code => l_new_error_code);
7053 END IF; -- Bug 3986129
7054 END IF;
7055 IF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
7056 THEN
7057 /* Bug 3133930- set the return status to the new output variable */
7058 x_budget_lines_out(i).return_status := x_return_status;
7059
7060 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7061
7062 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
7063 THEN
7064 --RAISE FND_API.G_EXC_ERROR;
7065 -- as the called api adds msg to stack hence no need to add err msg here.
7066
7067 /* Bug 3133930- set the return status to the new output variable */
7068 x_budget_lines_out(i).return_status := x_return_status;
7069
7070 l_any_error_occurred_flag:='Y';
7071 END IF;
7072 END IF; --p_clalling_context <> 'UPDATE_PLANNING_ELEMENT_ATTR' Bug 5509192
7073
7074 l_res_planning_level := NULL;
7075
7076 --Manipulation of resource alias should be done only when the resource list passed
7077 --is not uncategorized
7078 IF (nvl(l_uncategorized_res_list_id,-99) = p_resource_list_id) THEN
7079
7080 px_budget_lines_in(i).resource_list_member_id :=l_uncategorized_rlmid;
7081 px_budget_lines_in(i).resource_alias := PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR;
7082
7083 IF p_calling_context = 'UPDATE_PLANNING_ELEMENT_ATTR' then
7084 l_valid_rlmid := 'Y';
7085 END IF ;
7086
7087
7088 ELSE -- not uncategorized RL
7089 -- convert resource alias to (resource) member id
7090 -- if resource alias is (passed and not NULL)
7091 -- and resource member is (passed and not NULL)
7092 -- then we convert the alias to the id
7093 -- else we default to the uncategorized resource member
7094
7095 IF (px_budget_lines_in(i).resource_alias <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR
7096 AND px_budget_lines_in(i).resource_alias IS NOT NULL)
7097 OR (px_budget_lines_in(i).resource_list_member_id <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM
7098 AND px_budget_lines_in(i).resource_list_member_id IS NOT NULL)
7099 THEN
7100
7101 --Selecting the index if it will be based on rlm_id or resource_alias. This index is decided on the
7102 --basis of whther this (pa_resource_pub.Convert_alias_to_id ) API call would honour the
7103 --rlm_id or resource_alias. The rule is rlm_id is honoured if both are passed to the API
7104 --otherwise whichever value is passed that value is honoured by the API.
7105 --Also note while preparing the index we are prepending 'RLMID' or 'RALIAS' before the actual values.
7106 --The index would always be in this format.
7107
7108 --Also didnt included the null check in below if's to decide the index because it has already been
7109 --taken care of in the last if before this. See above. We wont reach here if any one of rlm_id or
7110 --resource_alias is null
7111 IF(px_budget_lines_in(i).resource_list_member_id <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_NUM )
7112 THEN
7113 --Prepending the word 'RLMID' before the rlm_id value while preparing the index.
7114 l_distinct_rlmid_idx := 'RLMID' || px_budget_lines_in(i).resource_list_member_id;
7115 ELSIF( px_budget_lines_in(i).resource_alias <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR)
7116 THEN
7117 --Prepending the word 'RALIAS' before the reasource_alias value while preparing the index.
7118 l_distinct_rlmid_idx := 'RALIAS' || px_budget_lines_in(i).resource_alias;
7119 END IF;
7120
7121 --l_rlm_id_tbl table would be used to cache the rlm_id for the rlm_id/resource_alias passed.
7122 -- This table would store the value for rlm_id everytime a new rlm_id or resource_alias is passed.
7123 --The table is indexed by index 'l_distinct_rlmid_idx' which could be either resource_alias or
7124 --rlm_id.
7125 --Check in the table if the value is already present for this index(which is one of
7126 --rlm_id/resource_alias). If present then read the rlm_id from the table for this index
7127 --else call the api.
7128 IF( NOT(l_rlm_id_tbl.exists(l_distinct_rlmid_idx) ) )
7129 THEN
7130 pa_resource_pub.Convert_alias_to_id
7131 ( p_project_id => p_pa_project_id
7132 ,p_resource_list_id => p_resource_list_id
7133 ,p_alias => px_budget_lines_in(i).resource_alias
7134 ,p_resource_list_member_id => px_budget_lines_in(i).resource_list_member_id
7135 ,p_out_resource_list_member_id => px_budget_lines_in(i).resource_list_member_id
7136 ,p_return_status => x_return_status );
7137
7138 --dbms_output.put_line('----- p_out_resource_list_member_id: -----' || p_out_resource_list_member_id);
7139 IF x_return_status = FND_API.G_RET_STS_SUCCESS
7140 THEN
7141 -- Initialise valid rlmid variable to Y
7142 l_valid_rlmid := 'Y';
7143 IF((p_budget_type_code IS NOT NULL) AND
7144 (p_budget_type_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR)) THEN -- Old Bugdets Model -- Bug 3801891
7145 --get unit_of_measure and track_as_labor_flag associated to
7146 --the resource member and check whether this is a valid member for this list
7147 OPEN l_resource_csr( px_budget_lines_in(i).resource_list_member_id
7148 ,p_resource_list_id );
7149 FETCH l_resource_csr INTO l_unit_of_measure, l_track_as_labor_flag, l_rlm_migration_code;
7150 IF l_resource_csr%NOTFOUND THEN
7151 l_context_info := p_budget_type_code;
7152 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
7153 THEN
7154 pa_interface_utils_pub.map_new_amg_msg
7155 ( p_old_message_code => 'PA_LIST_MEMBER_INVALID'
7156 ,p_msg_attribute => 'CHANGE'
7157 ,p_resize_flag => 'N'
7158 ,p_msg_context => 'BUDG'
7159 ,p_attribute1 => l_amg_project_rec.segment1
7160 ,p_attribute2 => l_amg_task_number
7161 ,p_attribute3 => l_context_info
7162 ,p_attribute4 => ''
7163 ,p_attribute5 => to_char(px_budget_lines_in(i).budget_start_date));
7164 END IF;
7165 x_return_status := FND_API.G_RET_STS_ERROR;
7166 /* Bug 3133930- set the return status to the new output variable */
7167 x_budget_lines_out(i).return_status := x_return_status;
7168 CLOSE l_resource_csr;
7169
7170 l_any_error_occurred_flag:='Y';
7171 l_valid_rlmid := 'N';
7172 --RAISE FND_API.G_EXC_ERROR;
7173 ELSE
7174 CLOSE l_resource_csr;
7175 END IF;
7176
7177 /* bug 3954329: included the following check */
7178 IF l_rlm_migration_code = 'N' THEN
7179 l_any_error_occurred_flag:='Y';
7180 l_valid_rlmid := 'N';
7181 x_return_status := FND_API.G_RET_STS_ERROR;
7182 x_budget_lines_out(i).return_status := x_return_status;
7183 PA_UTILS.ADD_MESSAGE
7184 ( p_app_short_name => 'PA',
7185 p_msg_name => 'PA_FP_OLD_MOD_NEW_RLM_PASSED');
7186 END IF;
7187 /* bug 3954329 end */
7188
7189 ELSE -- New Bugdets Model -- Bug 3801891
7190 OPEN l_resource_csr_fp(px_budget_lines_in(i).resource_list_member_id);
7191 FETCH l_resource_csr_fp INTO l_unit_of_measure, l_rlm_migration_code;
7192 IF l_resource_csr_fp%NOTFOUND THEN
7193 l_context_info := l_fin_plan_type_name;
7194 IF p_calling_context = 'WEBADI' THEN -- Bug 3986129: FP.M Web ADI Dev changes
7195 l_webadi_err_code_tbl.extend(1);
7196 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_LIST_MEMBER_INVALID';
7197 l_webadi_err_task_id_tbl.extend(1);
7198 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7199 l_webadi_err_rlm_id_tbl.extend(1);
7200 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7201 l_webadi_err_txn_curr_tbl.extend(1);
7202 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7203 l_webadi_err_amt_type_tbl.extend(1);
7204 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7205 ELSE
7206 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7207 pa_interface_utils_pub.map_new_amg_msg
7208 ( p_old_message_code => 'PA_LIST_MEMBER_INVALID'
7209 ,p_msg_attribute => 'CHANGE'
7210 ,p_resize_flag => 'N'
7211 ,p_msg_context => 'BUDG'
7212 ,p_attribute1 => l_amg_project_rec.segment1
7213 ,p_attribute2 => l_amg_task_number
7214 ,p_attribute3 => l_context_info
7215 ,p_attribute4 => ''
7216 ,p_attribute5 => to_char(px_budget_lines_in(i).budget_start_date));
7217 END IF;
7218 x_return_status := FND_API.G_RET_STS_ERROR;
7219 x_budget_lines_out(i).return_status := x_return_status;
7220 END IF;
7221 CLOSE l_resource_csr_fp;
7222
7223 l_any_error_occurred_flag:='Y';
7224 l_valid_rlmid := 'N';
7225 ELSE
7226 CLOSE l_resource_csr_fp;
7227 END IF;
7228 /* bug 3954329: included the following check */
7229 IF l_rlm_migration_code IS NULL THEN
7230 IF p_calling_context = 'WEBADI' THEN -- Bug 3986129: FP.M Web ADI Dev changes
7231 l_webadi_err_code_tbl.extend(1);
7232 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_OLD_RLM_PASSED';
7233 l_webadi_err_task_id_tbl.extend(1);
7234 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7235 l_webadi_err_rlm_id_tbl.extend(1);
7236 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7237 l_webadi_err_txn_curr_tbl.extend(1);
7238 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7239 l_webadi_err_amt_type_tbl.extend(1);
7240 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7241 ELSE
7242 x_return_status := FND_API.G_RET_STS_ERROR;
7243 x_budget_lines_out(i).return_status := x_return_status;
7244 PA_UTILS.ADD_MESSAGE
7245 ( p_app_short_name => 'PA',
7246 p_msg_name => 'PA_FP_NEW_MOD_OLD_RLM_PASSED');
7247 END IF;
7248
7249 l_any_error_occurred_flag:='Y';
7250 l_valid_rlmid := 'N';
7251 END IF;
7252 /* bug 3954329 end */
7253
7254 END IF; -- Bug 3801891
7255
7256 IF((p_budget_type_code IS NOT NULL) AND
7257 (p_budget_type_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR)) THEN -- 4504585 For old budget model only
7258
7259 IF l_valid_rlmid='Y' THEN
7260
7261 SELECT parent_member_id
7262 ,resource_type_code
7263 ,alias
7264 INTO l_parent_member_id
7265 ,l_resource_type_code
7266 ,pa_budget_pvt.g_resource_alias
7267 FROM pa_resource_list_members
7268 WHERE resource_list_member_id = px_budget_lines_in(i).resource_list_member_id;
7269
7270 IF l_resource_type_code = 'UNCLASSIFIED' THEN
7271
7272 l_any_error_occurred_flag:='Y';
7273 l_valid_rlmid := 'N';
7274 x_return_status := FND_API.G_RET_STS_ERROR;
7275 /* Bug 3133930- set the return status to the new output variable */
7276 x_budget_lines_out(i).return_status := x_return_status;
7277
7278 PA_UTILS.ADD_MESSAGE
7279 ( p_app_short_name => 'PA',
7280 p_msg_name => 'PA_FP_AMT_FOR_UNCLASSIFIED_RES',
7281 p_token1 => 'PROJECT',
7282 p_value1 => l_amg_project_rec.segment1,
7283 p_token2 => 'TASK',
7284 p_value2 => l_amg_task_number);
7285 l_valid_rlmid:='N';
7286
7287 ELSE
7288
7289 IF l_parent_member_id IS NULL THEN
7290 l_res_planning_level := PA_FP_CONSTANTS_PKG.G_RESOURCE_PLANNING_LEVEL_G;
7291 ELSE
7292 l_res_planning_level := PA_FP_CONSTANTS_PKG.G_RESOURCE_PLANNING_LEVEL_R;
7293 END IF;
7294
7295 END IF;
7296 END IF;
7297 END IF;
7298 --Changed the if below for bug#4488926.
7299 IF (l_valid_rlmid = 'Y') THEN /*l_valid_rlmid equal to Y would ensure that no error
7300 occurred after the API call pa_resource_pub.Convert_alias_to_id made above till this
7301 point in code*/
7302 --If the API completes and above validations completes successfully then store the rlm_id in the
7303 --l_rlm_id_tbl at the location indexed by l_distinct_rlmid_idx.
7304 l_rlm_id_tbl(l_distinct_rlmid_idx) := px_budget_lines_in(i).resource_list_member_id;
7305 --Also if the index was based on resource_alias then we derive rlm_id for this, but next time
7306 --possibly rlm_id could be passed which has been derived from this resource_alias. So we
7307 --should store this derived rlm_id also in the table.
7308 --More importantly this rlm_id should be stored at the location indexed by
7309 --'RLMID' || px_budget_lines_in(i).rlm_id. Here prepending the RLMID and the value
7310 --px_budget_lines_in(i).resource_list_member_id was derived in the above API call as o/p
7311 --parameter.
7312 IF(l_distinct_rlmid_idx = 'RALIAS' || px_budget_lines_in(i).resource_alias)
7313 THEN
7314 IF(l_rlm_id_tbl.exists('RLMID' || px_budget_lines_in(i).resource_list_member_id))
7315 THEN
7316 --If the rlm_id derived from this resource_alias is already present then dont
7317 --store it again.
7318 null;
7319 ELSE
7320 --Derived rlm_id should be stored at the location indexed by
7321 --'RLMID' || px_budget_lines_in(i).resource_list_member_id Here prepending the
7322 --RLMID and the value px_budget_lines_in(i).resource_list_member_id was derived in
7323 --the above API call as o/p parameter.
7324 --Storing this value would ensure that next time if this rlm_id is passed we dont
7325 --call the API.
7326 l_rlm_id_tbl('RLMID' || px_budget_lines_in(i).resource_list_member_id) :=
7327 px_budget_lines_in(i).resource_list_member_id;
7328 END IF;
7329 END IF;
7330 END IF; --x_return_status = FND_API.G_RET_STS_SUCCESS THEN
7331
7332 ELSIF x_return_status = FND_API.G_RET_STS_UNEXP_ERROR
7333 THEN
7334 /* Bug 3133930- set the return status to the new output variable */
7335 x_budget_lines_out(i).return_status := x_return_status;
7336 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
7337
7338 ELSIF x_return_status = FND_API.G_RET_STS_ERROR
7339 THEN
7340 /* Bug 3133930- set the return status to the new output variable */
7341 x_budget_lines_out(i).return_status := x_return_status;
7342 --RAISE FND_API.G_EXC_ERROR;
7343 -- error message is added by the called API. Hence no error msg need to be added here.
7344 l_any_error_occurred_flag:='Y';
7345 END IF;
7346 ELSE --IF( NOT(l_rlm_id_tbl.exists(l_distinct_rlmid_idx) ) )
7347 --If the value is already there in the table for this index(task_id/task_ref) then read it from table
7348 --for this index.
7349 px_budget_lines_in(i).resource_list_member_id := l_rlm_id_tbl(l_distinct_rlmid_idx) ;
7350 END IF; --IF( NOT(l_rlm_id_tbl.exists(l_distinct_rlmid_idx) ) )
7351
7352 ELSE
7353 IF (p_budget_type_code IS NULL OR
7354 p_budget_type_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR ) THEN
7355 l_context_info := l_fin_plan_type_name;
7356 ELSE
7357 l_context_info := p_budget_type_code;
7358 END IF;
7359
7360 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7361 pa_interface_utils_pub.map_new_amg_msg
7362 ( p_old_message_code => 'PA_RESOURCE_IS_MISSING'
7363 ,p_msg_attribute => 'CHANGE'
7364 ,p_resize_flag => 'N'
7365 ,p_msg_context => 'BUDG'
7366 ,p_attribute1 => l_amg_project_rec.segment1
7367 ,p_attribute2 => l_amg_task_number
7368 ,p_attribute3 => l_context_info
7369 ,p_attribute4 => ''
7370 ,p_attribute5 => to_char(px_budget_lines_in(i).budget_start_date));
7371 --RAISE FND_API.G_EXC_ERROR;
7372 END IF;
7373 x_return_status := FND_API.G_RET_STS_ERROR;
7374 /* Bug 3133930- set the return status to the new output variable */
7375 x_budget_lines_out(i).return_status := x_return_status;
7376 l_any_error_occurred_flag:='Y';
7377 END IF;
7378
7379 END IF;--IF (nvl(l_uncategorized_res_list_id,-99) = p_resource_list_id) THEN
7380
7381 IF p_calling_context= 'UPDATE_PLANNING_ELEMENT_ATTR' then
7382 IF l_valid_rlmid ='Y' then
7383 SELECT ALIAS
7384 INTO px_budget_lines_in(i).resource_alias
7385 FROM pa_resource_list_members
7386 WHERE resource_list_member_id = px_budget_lines_in(i).resource_list_member_id;
7387 END IF;
7388 -- DBMS_OUTPUT.PUT_LINE('resource alias '||i||' '||px_budget_lines_in(i).resource_alias);
7389 END IF;
7390
7391
7392 -- Bug 3986129: FP.M Web ADI Dev changes
7393 IF p_calling_context = 'WEBADI' or
7394 (p_calling_context='UPDATE_PLANNING_ELEMENT_ATTR' and l_valid_rlmid ='Y') THEN --Bug 5509192
7395
7396 -- validating resource level attributes
7397 IF p_uom_tbl(i) IS NOT NULL AND
7398 p_uom_tbl(i) = FND_API.G_MISS_CHAR THEN
7399 -- UOM has been nulled out
7400 l_webadi_err_code_tbl.extend(1);
7401 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_UOM_NULLED_OUT';
7402 l_webadi_err_task_id_tbl.extend(1);
7403 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7404 l_webadi_err_rlm_id_tbl.extend(1);
7405 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7406 l_webadi_err_txn_curr_tbl.extend(1);
7407 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7408 l_webadi_err_amt_type_tbl.extend(1);
7409 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7410 l_any_error_occurred_flag := 'Y';
7411 ELSIF p_uom_tbl(i) IS NOT NULL AND
7412 p_uom_tbl(i) <> FND_API.G_MISS_CHAR THEN
7413 -- value for UOM has been passed
7414 -- calling an api to validate the UOM passed
7415 PA_BUDGET_CHECK_PVT.validate_uom_passed
7416 (p_res_list_mem_id => px_budget_lines_in(i).resource_list_member_id,
7417 p_uom_passed => p_uom_tbl(i),
7418 x_error_code => l_new_error_code,
7419 x_return_status => x_return_status,
7420 x_msg_data => x_msg_data,
7421 x_msg_count => x_msg_count);
7422
7423 IF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
7424 IF l_new_error_code IS NOT NULL THEN
7425 l_webadi_err_code_tbl.extend(1);
7426 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := l_new_error_code;
7427 l_webadi_err_task_id_tbl.extend(1);
7428 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7429 l_webadi_err_rlm_id_tbl.extend(1);
7430 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7431 l_webadi_err_txn_curr_tbl.extend(1);
7432 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7433 l_webadi_err_amt_type_tbl.extend(1);
7434 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7435 l_any_error_occurred_flag := 'Y';
7436 END IF;
7437 ELSE
7438 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
7439 END IF;
7440 END IF; -- uom validation
7441
7442 --etc method validation starts
7443 l_valid_etc_method:='Y';
7444 l_etc_method_code :=null;
7445
7446 IF p_etc_method_name_tbl(i) IS NOT NULL AND
7447 (p_calling_context = 'UPDATE_PLANNING_ELEMENT_ATTR' or
7448 p_etc_method_name_tbl(i) <> FND_API.G_MISS_CHAR) THEN
7449 BEGIN
7450 SELECT lookup_code
7451 INTO l_etc_method_code
7452 FROM pa_lookups
7453 WHERE lookup_type = 'PA_FP_ETC_METHOD'
7454 AND meaning = p_etc_method_name_tbl(i);
7455 EXCEPTION
7456 WHEN NO_DATA_FOUND THEN
7457 l_valid_etc_method := 'N';
7458 END;
7459
7460 IF l_valid_etc_method = 'N' THEN
7461 -- throwing error
7462 IF p_calling_context = 'UPDATE_PLANNING_ELEMENT_ATTR' then
7463 IF px_budget_lines_in(i).pa_task_id <> 0 then
7464 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7465 p_msg_name => 'INVALID_ETC_METHOD_AMG',
7466 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7467 p_value1 => l_amg_task_number,
7468 p_token2 => 'RESOURCE',
7469 p_value2 => px_budget_lines_in(i).resource_alias);
7470 ELSE
7471 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7472 p_msg_name => 'INVALID_ETC_METHOD_AMG',
7473 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7474 p_value1 => l_project_number,
7475 p_token2 => 'RESOURCE',
7476 p_value2 => px_budget_lines_in(i).resource_alias);
7477 END IF;
7478 l_any_error_occurred_flag := 'Y';
7479 ELSE
7480 l_webadi_err_code_tbl.extend(1);
7481 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_INV_ETC_PASSED';
7482 l_webadi_err_task_id_tbl.extend(1);
7483 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7484 l_webadi_err_rlm_id_tbl.extend(1);
7485 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7486 l_webadi_err_txn_curr_tbl.extend(1);
7487 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7488 l_webadi_err_amt_type_tbl.extend(1);
7489 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7490 l_any_error_occurred_flag := 'Y';
7491 END IF;
7492 ELSE
7493 x_etc_method_code_tbl.EXTEND(1);
7494 x_etc_method_code_tbl(x_etc_method_code_tbl.COUNT) := l_etc_method_code;
7495 END IF;
7496 ELSIF p_etc_method_name_tbl(i) IS NULL THEN
7497 -- this need not be validated as the column is hidden
7498 x_etc_method_code_tbl.EXTEND(1);
7499 x_etc_method_code_tbl(x_etc_method_code_tbl.COUNT) := null;
7500 END IF; -- etc validation
7501
7502
7503
7504 IF p_mfc_cost_type_tbl(i) IS NOT NULL AND
7505 p_mfc_cost_type_tbl(i) <> FND_API.G_MISS_CHAR THEN
7506 BEGIN
7507 SELECT cost_type_id
7508 INTO l_mfc_cost_type_id
7509 FROM CST_COST_TYPES_V
7510 WHERE multi_org_flag = 1
7511 AND cost_type = p_mfc_cost_type_tbl(i);
7512 EXCEPTION
7513 WHEN NO_DATA_FOUND THEN
7514 l_valid_mfc_cost_type := 'N';
7515 END;
7516
7517 IF l_valid_mfc_cost_type = 'N' THEN
7518 -- throwing error
7519 l_webadi_err_code_tbl.extend(1);
7520 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_INV_MFC_PASSED';
7521 l_webadi_err_task_id_tbl.extend(1);
7522 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7523 l_webadi_err_rlm_id_tbl.extend(1);
7524 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7525 l_webadi_err_txn_curr_tbl.extend(1);
7526 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7527 l_webadi_err_amt_type_tbl.extend(1);
7528 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7529 l_any_error_occurred_flag := 'Y';
7530 ELSE
7531 x_mfc_cost_type_id_tbl.EXTEND(1);
7532 x_mfc_cost_type_id_tbl(x_mfc_cost_type_id_tbl.COUNT) := l_mfc_cost_type_id;
7533 END IF;
7534 ELSIF p_mfc_cost_type_tbl(i) IS NULL THEN
7535 -- this need not be validated as the column is hidden
7536 x_mfc_cost_type_id_tbl.EXTEND(1);
7537 x_mfc_cost_type_id_tbl(x_mfc_cost_type_id_tbl.COUNT) := null;
7538 END IF; -- MFC validation\
7539
7540 l_valid_spread_curve := 'Y';
7541 l_spread_curve_id :=null;
7542
7543 -- validating spread curve
7544 IF p_calling_context='WEBADI' and p_spread_curve_id_tbl.EXISTS(i) AND
7545 (p_spread_curve_id_tbl(i) IS NULL OR p_spread_curve_id_tbl(i) <> FND_API.G_MISS_NUM) THEN
7546 x_spread_curve_id_tbl.EXTEND(1);
7547 x_spread_curve_id_tbl(x_spread_curve_id_tbl.COUNT) := p_spread_curve_id_tbl(i);
7548 ELSE
7549 IF p_spread_curve_name_tbl(i) IS NOT NULL AND
7550 p_spread_curve_name_tbl(i) = FND_API.G_MISS_CHAR AND
7551 p_calling_context <> 'UPDATE_PLANNING_ELEMENT_ATTR' THEN
7552
7553 l_webadi_err_code_tbl.extend(1);
7554 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_SC_NULLED_OUT';
7555 l_webadi_err_task_id_tbl.extend(1);
7556 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7557 l_webadi_err_rlm_id_tbl.extend(1);
7558 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7559 l_webadi_err_txn_curr_tbl.extend(1);
7560 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7561 l_webadi_err_amt_type_tbl.extend(1);
7562 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7563 l_any_error_occurred_flag := 'Y';
7564 ELSIF p_spread_curve_name_tbl(i) IS NOT NULL AND
7565 (p_calling_context = 'UPDATE_PLANNING_ELEMENT_ATTR' or
7566 p_spread_curve_name_tbl(i) <> FND_API.G_MISS_CHAR) THEN
7567
7568 BEGIN
7569 SELECT spread_curve_id
7570 INTO l_spread_curve_id
7571 FROM pa_spread_curves_vl
7572 WHERE name = p_spread_curve_name_tbl(i);
7573 EXCEPTION
7574 WHEN NO_DATA_FOUND THEN
7575 l_valid_spread_curve := 'N';
7576 END;
7577 IF l_valid_spread_curve = 'N' THEN
7578 -- throwing error
7579 IF p_calling_context = 'UPDATE_PLANNING_ELEMENT_ATTR' then
7580 IF px_budget_lines_in(i).pa_task_id <> 0 then
7581 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7582 p_msg_name => 'INVALID_SPREAD_CURVE_AMG',
7583 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7584 p_value1 => l_amg_task_number,
7585 p_token2 => 'RESOURCE',
7586 p_value2 => px_budget_lines_in(i).resource_alias);
7587 ELSE
7588 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7589 p_msg_name => 'INVALID_SPREAD_CURVE_AMG',
7590 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7591 p_value1 => l_project_number,
7592 p_token2 => 'RESOURCE',
7593 p_value2 => px_budget_lines_in(i).resource_alias);
7594 END IF;
7595
7596 l_any_error_occurred_flag := 'Y';
7597 ELSE
7598
7599 l_webadi_err_code_tbl.extend(1);
7600 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_INV_SC_PASSED';
7601 l_webadi_err_task_id_tbl.extend(1);
7602 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7603 l_webadi_err_rlm_id_tbl.extend(1);
7604 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7605 l_webadi_err_txn_curr_tbl.extend(1);
7606 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7607 l_webadi_err_amt_type_tbl.extend(1);
7608 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7609 l_any_error_occurred_flag := 'Y';
7610 END IF;
7611 ELSE
7612 x_spread_curve_id_tbl.EXTEND(1);
7613 x_spread_curve_id_tbl(x_spread_curve_id_tbl.COUNT) := l_spread_curve_id;
7614 END IF;
7615 ELSIF p_spread_curve_name_tbl(i) IS NULL then
7616 x_spread_curve_id_tbl.EXTEND(1);
7617 x_spread_curve_id_tbl(x_spread_curve_id_tbl.COUNT) := null;
7618 END IF;
7619 END IF; -- spread curve validation ends
7620
7621 if p_calling_context ='UPDATE_PLANNING_ELEMENT_ATTR' then
7622 l_invalid_resassgn_flag :='N';
7623 l_resource_assignment_id:=null;
7624 l_planning_start_date :=null;
7625 l_planning_end_date :=null;
7626 l_sp_fixed_date :=null;
7627 begin
7628 SELECT resource_assignment_id,planning_start_date,
7629 planning_end_date,nvl(l_spread_curve_id,spread_curve_id),sp_fixed_date
7630 INTO l_resource_assignment_id,l_planning_start_date,
7631 l_planning_end_date,l_spread_curve_id,l_sp_fixed_date
7632 FROM pa_resource_assignments
7633 WHERE budget_version_id=p_version_info_rec.x_budget_version_id
7634 AND task_id=px_budget_lines_in(i).pa_task_id
7635 AND resource_list_member_id=px_budget_lines_in(i).resource_list_member_id
7636 AND NVL(cbs_element_id,-1)=NVL(px_budget_lines_in(i).cbs_element_id,-1) --16604257
7637 AND project_id=p_pa_project_id
7638 AND PROJECT_ASSIGNMENT_ID =-1;
7639 exception when no_data_found then
7640 if px_budget_lines_in(i).pa_task_id <> 0 then
7641 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7642 p_msg_name => 'RES_ASSGN_DOESNT_EXIST_AMG',
7643 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7644 p_value1 => l_amg_task_number,
7645 p_token2 => 'RESOURCE',
7646 p_value2 => px_budget_lines_in(i).resource_alias);
7647 else
7648 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7649 p_msg_name => 'RES_ASSGN_DOESNT_EXIST_AMG',
7650 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7651 p_value1 => l_project_number,
7652 p_token2 => 'RESOURCE',
7653 p_value2 => px_budget_lines_in(i).resource_alias);
7654 end if;
7655 l_any_error_occurred_flag := 'Y';
7656 l_invalid_resassgn_flag:='Y';
7657 end;
7658
7659 G_res_assign_tbl(i).resource_assignment_id:=l_resource_assignment_id;
7660
7661 if l_invalid_resassgn_flag <> 'Y' then
7662 if l_raid_hash_table.exists('RA'||l_resource_assignment_id) then
7663 if px_budget_lines_in(i).pa_task_id <> 0 then
7664 PA_UTILS.ADD_MESSAGE
7665 (p_app_short_name => 'PA',
7666 p_msg_name => 'PA_ATTR_DUP_SRCH_ERR',
7667 p_token1 => 'ATTR_NAME',
7668 p_value1 => 'Task '||l_amg_task_number||' Resource '||px_budget_lines_in(i).resource_alias
7669
7670 );
7671 else
7672 PA_UTILS.ADD_MESSAGE
7673 (p_app_short_name => 'PA',
7674 p_msg_name => 'PA_ATTR_DUP_SRCH_ERR',
7675 p_token1 => 'ATTR_NAME',
7676 p_value1 => 'Project '||l_project_number||' Resource '||px_budget_lines_in(i).resource_alias
7677
7678 );
7679 end if;
7680 l_any_error_occurred_flag := 'Y';
7681 else
7682 l_raid_hash_table('RA'||l_resource_assignment_id).resource_assignment_id:=l_resource_assignment_id;
7683 end if;
7684 end if;
7685
7686 l_invalid_plandates_flag :='N';
7687
7688 if p_planning_start_date_tbl(i) = FND_API.G_MISS_DATE or
7689 p_planning_end_date_tbl(i) = FND_API.G_MISS_DATE then
7690 if px_budget_lines_in(i).pa_task_id <> 0 then
7691 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7692 p_msg_name => 'INVALID_PLANNING_DATES_AMG',
7693 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7694 p_value1 => l_amg_task_number,
7695 p_token2 => 'RESOURCE',
7696 p_value2 => px_budget_lines_in(i).resource_alias);
7697 else
7698 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7699 p_msg_name => 'INVALID_PLANNING_DATES_AMG',
7700 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7701 p_value1 => l_project_number,
7702 p_token2 => 'RESOURCE',
7703 p_value2 => px_budget_lines_in(i).resource_alias);
7704 end if;
7705 l_any_error_occurred_flag := 'Y';
7706 l_invalid_plandates_flag := 'Y';
7707
7708 end if;
7709
7710 if (l_invalid_plandates_flag <> 'Y' and
7711 ((p_planning_start_date_tbl(i) is null and
7712 p_planning_end_date_tbl(i) is not null) or
7713 (p_planning_start_date_tbl(i) is not null and
7714 p_planning_end_date_tbl(i) is null) or
7715 (nvl(p_planning_end_date_tbl(i),FND_API.G_MISS_DATE) <
7716 nvl(p_planning_start_date_tbl(i),FND_API.G_MISS_DATE)))) then
7717
7718 if px_budget_lines_in(i).pa_task_id <> 0 then
7719 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7720 p_msg_name => 'INVALID_PLANNING_DATES_AMG',
7721 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7722 p_value1 => l_amg_task_number,
7723 p_token2 => 'RESOURCE',
7724 p_value2 => px_budget_lines_in(i).resource_alias);
7725 else
7726 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7727 p_msg_name => 'INVALID_PLANNING_DATES_AMG',
7728 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7729 p_value1 => l_project_number,
7730 p_token2 => 'RESOURCE',
7731 p_value2 => px_budget_lines_in(i).resource_alias);
7732 end if;
7733 l_any_error_occurred_flag := 'Y';
7734 l_invalid_plandates_flag := 'Y';
7735
7736 end if;
7737
7738 IF l_spread_curve_id = l_fixed_date_sp_id THEN
7739 if (l_sp_fixed_date is null and (p_sp_fixed_date_tbl(i) is null or p_sp_fixed_date_tbl(i)= FND_API.G_MISS_DATE )) or
7740 (l_sp_fixed_date is not null and p_sp_fixed_date_tbl(i)= FND_API.G_MISS_DATE)
7741 then
7742 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7743 p_msg_name => 'PA_FP_SP_FIXED_DATE_NULL');
7744 l_any_error_occurred_flag := 'Y';
7745 l_invalid_plandates_flag := 'Y';
7746 end if;
7747
7748 if l_invalid_plandates_flag <> 'Y' then
7749 if ((nvl(p_sp_fixed_date_tbl(i),l_sp_fixed_date) <
7750 nvl(p_planning_start_date_tbl(i),l_planning_start_date)) or
7751 (nvl(p_sp_fixed_date_tbl(i),l_sp_fixed_date) >
7752 nvl(p_planning_end_date_tbl(i),l_planning_end_date))) then
7753
7754 if px_budget_lines_in(i).pa_task_id <> 0 then
7755 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7756 p_msg_name => 'INVALID_FIXED_DATE_AMG',
7757 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7758 p_value1 => l_amg_task_number,
7759 p_token2 => 'RESOURCE',
7760 p_value2 => px_budget_lines_in(i).resource_alias);
7761 else
7762 PA_UTILS.ADD_MESSAGE(p_app_short_name => 'PA',
7763 p_msg_name => 'INVALID_FIXED_DATE_AMG',
7764 p_token1 => 'PROJECT_OR_TASK_NUMBER',
7765 p_value1 => l_project_number,
7766 p_token2 => 'RESOURCE',
7767 p_value2 => px_budget_lines_in(i).resource_alias);
7768 end if;
7769 l_any_error_occurred_flag := 'Y';
7770
7771 end if;
7772
7773 end if;
7774
7775
7776
7777 END IF;
7778 end if; -- end of newly introduced checks for UPDATE_PLANNING_ELEMENT_ATTR
7779 END IF; -- Bug 3986129: FP.M Web ADI ,UPDATE_PLANNING_ELEMENT_ATTR
7780
7781 -- hari 11th may
7782 IF ( p_calling_context NOT IN( 'RES_ASSGNMT_LEVEL_VALIDATION','WEBADI','UPDATE_PLANNING_ELEMENT_ATTR') OR --Bug 5509192
7783 (p_calling_context = 'WEBADI' AND ((NOT (p_delete_flag_tbl.exists(i))) OR
7784 Nvl(p_delete_flag_tbl(i), 'N') <> 'Y')))
7785 THEN
7786 --Validate the change reason code. This validation is added for Fin plan model in FP L
7787 IF (px_budget_lines_in(i).change_reason_code IS NOT NULL AND
7788 ((p_calling_context = 'WEBADI' AND px_budget_lines_in(i).change_reason_code <> FND_API.G_MISS_CHAR) OR
7789 (p_calling_context <> 'WEBADI' AND px_budget_lines_in(i).change_reason_code <> PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR))) THEN
7790
7791 OPEN l_budget_change_reason_csr( px_budget_lines_in(i).change_reason_code );
7792 FETCH l_budget_change_reason_csr INTO l_dummy;
7793 IF l_budget_change_reason_csr%NOTFOUND THEN
7794 CLOSE l_budget_change_reason_csr;
7795
7796 IF p_calling_context <> 'WEBADI' THEN
7797 IF (p_budget_type_code IS NULL OR
7798 p_budget_type_code = PA_INTERFACE_UTILS_PUB.G_PA_MISS_CHAR ) THEN
7799
7800 l_context_info := l_fin_plan_type_name;
7801 /* Bug 3133930- set the return status to the new output variable */
7802 x_budget_lines_out(i).return_status := x_return_status;
7803 ELSE
7804
7805 l_context_info := p_budget_type_code;
7806 END IF;
7807 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
7808 PA_UTILS.add_message
7809 (p_app_short_name => 'PA',
7810 p_msg_name => 'PA_CHANGE_REASON_INVALID_AMG',
7811 p_token1 => 'PROJECT',
7812 p_value1 => l_amg_project_rec.segment1,
7813 p_token2 => 'TASK',
7814 p_value2 => l_amg_task_number,
7815 p_token3 => 'BUDGET_TYPE',
7816 p_value3 => l_context_info ,
7817 p_token4 => 'START_DATE',
7818 p_value4 => to_char(px_budget_lines_in(i).budget_start_date));
7819 END IF;
7820 x_return_status := FND_API.G_RET_STS_ERROR;
7821 /* Bug 3133930- set the return status to the new output variable */
7822 x_budget_lines_out(i).return_status := x_return_status;
7823 --RAISE FND_API.G_EXC_ERROR;
7824 ELSE --p_calling_context <> 'WEBADI' THEN
7825 -- populate the error code specific to webadi context
7826 l_webadi_err_code_tbl.extend(1);
7827 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_INV_RESN_CODE_PASSED';
7828 l_webadi_err_task_id_tbl.extend(1);
7829 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
7830 l_webadi_err_rlm_id_tbl.extend(1);
7831 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
7832 l_webadi_err_txn_curr_tbl.extend(1);
7833 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
7834 l_webadi_err_amt_type_tbl.extend(1);
7835 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
7836 END IF; -- calling context WEBADI
7837
7838
7839 l_any_error_occurred_flag:='Y';
7840 ELSE
7841 CLOSE l_budget_change_reason_csr;
7842 END IF;
7843 END IF;--IF (px_budget_lines_in(i).change_reason_code IS NOT NULL AND
7844 END IF; --p_calling_context <> 'RES_ASSGNMT_LEVEL_VALIDATION','UPDATE_PLANNING_ELEMENT_ATTR'
7845
7846 IF p_fin_plan_type_id IS NOT NULL and p_calling_context <> 'UPDATE_PLANNING_ELEMENT_ATTR' THEN -- Bug 5509192
7847
7848 --Bug#4457546:Added code to throw an error when amounts are entered for a period which
7849 --does not fall within the planning start/end dates of resource assignment
7850 --This API validate_budget_lines is being called from the following API's
7851 --CREATE_DRAFT_BUDGET (PACKAGE PA_BUDGET_PUB)
7852 --ADD_BUDGET_LINE (PACKAGE PA_BUDGET_PUB)
7853 --UPDATE_BUDGET (PACKAGE PA_BUDGET_PUB)
7854 --UPDATE_BUDGET_LINE (PACKAGE PA_BUDGET_PUB)
7855 --CREATE_DRAFT_FINPLAN (PACKAGE PA_BUDGET_PUB)
7856 --INSERT_BUDGET_LINE (PACKAGE PA_BUDGET_PVT)
7857 -- Of all the above places the below if condition would only be satisfied by ADD_BUDGET_LINE, UPDATE_BUDGET,
7858 --UPDATE_BUDGET_LINE for finplan model only which is what is required here. This validation should only be done
7859 --only from these calling places and only for finplan model.
7860
7861 IF ( p_calling_context = 'BUDGET_LINE_LEVEL_VALIDATION' and p_version_info_rec.x_budget_version_id is not null)
7862 THEN
7863 -- Start of Bug 8854015
7864 IF (px_budget_lines_in(i).budget_start_date IS NOT NULL AND
7865 px_budget_lines_in(i).budget_start_date <> FND_API.G_MISS_DATE) AND
7866 (px_budget_lines_in(i).budget_end_date IS NOT NULL AND
7867 px_budget_lines_in(i).budget_end_date <> FND_API.G_MISS_DATE) AND
7868 l_period_time_phased_code = 'N'
7869 THEN
7870 IF (px_budget_lines_in(i).budget_end_date < px_budget_lines_in(i).budget_start_date)
7871 THEN
7872 x_return_status := FND_API.G_RET_STS_ERROR;
7873 x_budget_lines_out(i).return_status := x_return_status;
7874 PA_UTILS.add_message
7875 (p_app_short_name => 'PA',
7876 p_msg_name => 'PA_INVALID_END_DATE');
7877 l_any_error_occurred_flag:='Y';
7878 ELSE
7879 l_plan_start_date := px_budget_lines_in(i).budget_start_date;
7880 l_plan_end_date := px_budget_lines_in(i).budget_end_date;
7881
7882 IF (px_budget_lines_in(i).resource_alias IS NOT NULL AND
7883 px_budget_lines_in(i).resource_alias <> FND_API.G_MISS_CHAR)
7884 THEN
7885
7886 l_resource_alias := px_budget_lines_in(i).resource_alias;
7887
7888 ELSE
7889
7890 SELECT alias
7891 INTO px_budget_lines_in(i).resource_alias
7892 FROM pa_resource_list_members
7893 WHERE resource_list_member_id = px_budget_lines_in(i).resource_list_member_id;
7894
7895 l_resource_alias := px_budget_lines_in(i).resource_alias;
7896
7897 END IF;
7898 END IF;
7899
7900 ELSE
7901 -- End of Bug 8854015
7902
7903 --Prepare the index in this form for each budget line.
7904 l_distinct_taskid_rlmid_index := 'T'||px_budget_lines_in(i).pa_task_id||'R'||px_budget_lines_in(i).resource_list_member_id;
7905
7906 --Checking if the values are already present in the tables(l_plan_start_date_tbl, l_plan_end_date_tbl,
7907 --l_task_name_tbl, l_resource_alias_tbl) for the index which we just prepared above. If the values are persent
7908 --in these tables then done fire the below select
7909 IF ( NOT(l_plan_start_date_tbl.exists(l_distinct_taskid_rlmid_index)
7910 AND l_plan_end_date_tbl.exists(l_distinct_taskid_rlmid_index)
7911 AND l_resource_alias_tbl.exists(l_distinct_taskid_rlmid_index) ) )
7912 THEN
7913 --Fire this select only if the values are not present in the above tables for any of the four values
7914 --that we are reading in the below query.
7915 BEGIN
7916 -- We have to handle the no_data_found exception for this select because this select could be fired for
7917 -- caselike from add_budget_line, the budget_line is being added for first time so there wont be any
7918 --record in pa_resource_assignments when line is added for first time.
7919 SELECT pra.planning_start_date,
7920 pra.planning_end_date,
7921 prlm.alias
7922 INTO l_plan_start_date,
7923 l_plan_end_date,
7924 l_resource_alias
7925 FROM pa_resource_assignments pra,
7926 pa_resource_list_members prlm
7927 WHERE pra.budget_version_id = p_version_info_rec.x_budget_version_id
7928 AND pra.resource_list_member_id = px_budget_lines_in(i).resource_list_member_id
7929 AND pra.task_id = px_budget_lines_in(i).pa_task_id
7930 AND NVL(pra.CBS_ELEMENT_ID,-1) = NVL(px_budget_lines_in(i).cbs_element_id,-1) --16604257
7931 AND prlm.resource_list_member_id = pra.resource_list_member_id;
7932 EXCEPTION
7933 WHEN NO_DATA_FOUND THEN
7934 l_plan_start_date := null;
7935 l_plan_end_date := null;
7936 l_resource_alias := null;
7937 END;
7938
7939 --Store the values just read in the tables for caching purpose
7940 l_plan_start_date_tbl(l_distinct_taskid_rlmid_index) := l_plan_start_date;
7941 l_plan_end_date_tbl(l_distinct_taskid_rlmid_index) := l_plan_end_date;
7942 l_resource_alias_tbl(l_distinct_taskid_rlmid_index) := l_resource_alias;
7943
7944 ELSE
7945 --The tables already contain the values so read the values from the tables.
7946 l_plan_start_date := l_plan_start_date_tbl(l_distinct_taskid_rlmid_index);
7947 l_plan_end_date := l_plan_end_date_tbl(l_distinct_taskid_rlmid_index);
7948 l_resource_alias := l_resource_alias_tbl(l_distinct_taskid_rlmid_index);
7949 END IF;
7950 END IF; -- Bug 8854015
7951 --Added this if condition below for the bug#4479835
7952 --We should do these validations only when the above query returned a record.
7953 IF (l_plan_start_date is not null)
7954 THEN
7955 IF (px_budget_lines_in(i).budget_start_date IS NOT NULL AND
7956 px_budget_lines_in(i).budget_start_date <> FND_API.G_MISS_DATE) AND
7957 (px_budget_lines_in(i).budget_end_date IS NOT NULL AND
7958 px_budget_lines_in(i).budget_end_date <> FND_API.G_MISS_DATE) THEN
7959
7960 -- checking if the budget line start date/ end date falls between
7961 -- the planning start date/ end date
7962
7963 --After the above of l_period_time_phased_code, if l_period_time_phased_code = N
7964 --then it means its a non periodic finplan case
7965 IF ( l_period_time_phased_code <> 'N')
7966 THEN
7967 ---Added this code for bug#4488926. Caching the values of l_period_start_date and
7968 --l_period_end_date
7969 IF ( NOT(l_period_start_date_tbl.exists(to_char(l_plan_start_date))
7970 AND l_period_end_date_tbl.exists(to_char(l_plan_end_date))))
7971 THEN
7972 --For periodic case get the start and end dates.
7973 l_period_start_date := PA_FIN_PLAN_UTILS.get_period_start_date(l_plan_start_date,l_period_time_phased_code);
7974 l_period_end_date := PA_FIN_PLAN_UTILS.get_period_end_date (l_plan_end_date , l_period_time_phased_code);
7975 l_period_start_date_tbl(to_char(l_plan_start_date)) := l_period_start_date;
7976 l_period_end_date_tbl(to_char(l_plan_end_date)) := l_period_end_date;
7977 ELSE
7978 l_period_start_date := l_period_start_date_tbl(to_char(l_plan_start_date));
7979 l_period_end_date := l_period_end_date_tbl(to_char(l_plan_end_date));
7980 END IF;
7981 ELSE
7982 --Its a non periodic case.
7983 l_period_start_date := l_plan_start_date;
7984 l_period_end_date := l_plan_end_date;
7985 END IF;
7986
7987 IF (px_budget_lines_in(i).budget_start_date < l_period_start_date OR
7988 px_budget_lines_in(i).budget_end_date > l_period_end_date)
7989 THEN
7990 x_return_status := FND_API.G_RET_STS_ERROR;
7991 x_budget_lines_out(i).return_status := x_return_status;
7992 PA_UTILS.add_message
7993 (p_app_short_name => 'PA',
7994 p_msg_name => 'PA_FP_START_END_DATE_NOT_VALID',
7995 p_token1 => 'TASK',
7996 p_value1 => l_amg_task_number,
7997 p_token2 => 'RESOURCE',
7998 p_value2 => l_resource_alias,
7999 p_token3 => 'CURRENCY',
8000 p_value3 => px_budget_lines_in(i).txn_currency_code,
8001 p_token4 => 'START_DATE',
8002 p_value4 => to_char(px_budget_lines_in(i).budget_start_date) );
8003 l_any_error_occurred_flag:='Y';
8004 END IF;
8005 ELSIF ( p_time_phased_code = 'N' and
8006 (px_budget_lines_in(i).budget_start_date IS NULL
8007 OR px_budget_lines_in(i).budget_start_date = FND_API.G_MISS_DATE )
8008 AND (px_budget_lines_in(i).budget_end_date IS NULL
8009 OR px_budget_lines_in(i).budget_end_date = FND_API.G_MISS_DATE ) )THEN
8010
8011 px_budget_lines_in(i).budget_start_date := l_plan_start_date;
8012 px_budget_lines_in(i).budget_end_date := l_period_end_date;
8013
8014 END IF; --px_budget_lines_in(i).budget_start_date IS NOT NULL AND
8015 END IF; --IF (l_plan_start_date is not null)
8016 END IF;-- p_calling_context='BUDGET_LINE_LEVEL_VALIDATION' and p_version_info_rec.x_budget_version_id is not null
8017
8018
8019 --Validate the txn currency code provided by the user. The follwing checks are made.
8020 --1.If the version is an approved revenue version then the txn curr code should be PFC.
8021 --else If the version is MC enabled then txn curr code should be among the txn
8022 --currencies provided at the plan type level option
8023 --else if the version is not MC enabled then the txn curr code should be PC
8024
8025
8026 -- check for approved rev plan type flag is made here because in case plan type is at
8027 -- cost and revenue separately then version can have currencies other than PFC.
8028 l_valid_txn_curr := FALSE;
8029 IF(l_app_rev_plan_type_flag = 'Y' AND
8030 p_version_type <> PA_FP_CONSTANTS_PKG.G_VERSION_TYPE_COST) THEN
8031
8032 --Bug 4382980:Issue#19 - Currency Defaulting when txn_currency_code
8033 --is null done as suggested by Venkatesh Jayeraman
8034 IF (px_budget_lines_in(i).txn_currency_code IS NULL ) THEN
8035 -- bug 4462614: added the following check for webadi context
8036 IF p_calling_context = 'WEBADI' THEN
8037 IF l_webadi_ci_id IS NULL THEN
8038 px_budget_lines_in(i).txn_currency_code:=l_projfunc_currency_code;
8039 ELSE
8040 px_budget_lines_in(i).txn_currency_code:=l_webadi_agr_curr_code;
8041 END IF;
8042 ELSE
8043 px_budget_lines_in(i).txn_currency_code:=l_projfunc_currency_code;
8044 END IF;
8045
8046 END IF; -- if currency passed is null
8047
8048 IF l_debug_mode = 'Y' THEN
8049 pa_debug.g_err_stage:= 'Plan Version is approved for revenue';
8050 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
8051 END IF;
8052
8053 IF l_webadi_ci_id IS NULL THEN
8054 -- non ci version for both web adi and other contexts
8055 IF(nvl(px_budget_lines_in(i).txn_currency_code,'-99') <>
8056 l_projfunc_currency_code) THEN
8057 IF p_calling_context <> 'WEBADI' THEN
8058 PA_UTILS.ADD_MESSAGE
8059 ( p_app_short_name => 'PA',
8060 p_msg_name => 'PA_FP_TXN_NOT_PFC_FOR_APP_REV',
8061 p_token1 => 'PROJECT',
8062 p_value1 => l_amg_project_rec.segment1,
8063 p_token2 => 'PLAN_TYPE',
8064 p_value2 => l_fin_plan_type_name,
8065 p_token3 => 'CURRENCY',
8066 p_value3 => px_budget_lines_in(i).txn_currency_code);
8067
8068
8069 x_return_status := FND_API.G_RET_STS_ERROR;
8070 /* Bug 3133930- set the return status to the new output variable */
8071 x_budget_lines_out(i).return_status := x_return_status;
8072
8073 ELSE
8074 -- populate the error code specific to webadi context
8075 l_webadi_err_code_tbl.extend(1);
8076 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_TXN_CURR_NOT_PFC_AR';
8077 l_webadi_err_task_id_tbl.extend(1);
8078 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
8079 l_webadi_err_rlm_id_tbl.extend(1);
8080 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
8081 l_webadi_err_txn_curr_tbl.extend(1);
8082 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
8083 l_webadi_err_amt_type_tbl.extend(1);
8084 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
8085 END IF; -- p_calling_context <> WEBADI
8086
8087 l_any_error_occurred_flag:='Y';
8088 ELSE
8089 l_valid_txn_curr := TRUE;
8090 END IF;
8091 ELSE -- bug 4462614:
8092 -- ci versions, webadi context only.
8093 IF(nvl(px_budget_lines_in(i).txn_currency_code,'-99') <>
8094 l_webadi_agr_curr_code) THEN
8095 -- txn curr code passed is not agreement currency
8096 l_webadi_err_code_tbl.extend(1);
8097 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_TXN_CURR_NOT_AGR_CUR';
8098 l_webadi_err_task_id_tbl.extend(1);
8099 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
8100 l_webadi_err_rlm_id_tbl.extend(1);
8101 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
8102 l_webadi_err_txn_curr_tbl.extend(1);
8103 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
8104 l_webadi_err_amt_type_tbl.extend(1);
8105 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
8106
8107 l_any_error_occurred_flag:='Y';
8108 ELSE
8109 l_valid_txn_curr := TRUE;
8110 END IF;
8111 END IF; -- l_ci_id null
8112
8113 -- Version is not approved for revenue. The txn curr must be available in fp txn curr table
8114 ELSE
8115
8116 --Bug 4382980:Issue#19 - Currency Defaulting when txn_currency_code
8117 --is null done as suggested by Venkatesh Jayeraman
8118 IF (px_budget_lines_in(i).txn_currency_code IS NULL
8119 AND p_multi_currency_flag='N')
8120 THEN
8121
8122 px_budget_lines_in(i).txn_currency_code:=l_project_currency_code;
8123
8124 END IF; -- if currency passed is null
8125
8126 IF( nvl(px_budget_lines_in(i).txn_currency_code,'-99') <>
8127 l_project_currency_code
8128 AND nvl(px_budget_lines_in(i).txn_currency_code,'-99') <>
8129 l_projfunc_currency_code ) THEN
8130
8131 IF(p_multi_currency_flag = 'Y') THEN --Added for bug 4290310.
8132 IF l_valid_txn_currencies_tbl.exists(l_valid_txn_currencies_tbl.first) THEN
8133
8134 FOR l_txn_tbl_index in l_valid_txn_currencies_tbl.first..l_valid_txn_currencies_tbl.last LOOP
8135
8136 IF( nvl(px_budget_lines_in(i).txn_currency_code,'-99')= l_valid_txn_currencies_tbl(l_txn_tbl_index)) THEN
8137
8138 l_valid_txn_curr := TRUE;
8139
8140 EXIT;
8141
8142 END IF;
8143
8144 END LOOP;
8145
8146 END IF;
8147 ELSE
8148 l_valid_txn_curr := FALSE;
8149 END IF;
8150 ELSE --The Txn curr code is either PC or PFC
8151
8152 l_valid_txn_curr := TRUE;
8153
8154 END IF;--IF(l_app_rev_plan_type_flag = 'Y') THEN
8155
8156 --The txn currency code passed is not valid
8157 IF NOT l_valid_txn_curr THEN
8158 IF p_calling_context <> 'WEBADI' THEN
8159 --Add a message to the stack since the txn curr code is not valid
8160 PA_UTILS.ADD_MESSAGE
8161 ( p_app_short_name => 'PA',
8162 p_msg_name => 'PA_FP_TXN_NOT_ADDED_FOR_PT',
8163 p_token1 => 'PROJECT',
8164 p_value1 => l_amg_project_rec.segment1,
8165 p_token2 => 'PLAN_TYPE',
8166 p_value2 => l_fin_plan_type_name,
8167 p_token3 => 'CURRENCY',
8168 p_value3 => px_budget_lines_in(i).txn_currency_code);
8169
8170 x_return_status := FND_API.G_RET_STS_ERROR;
8171 /* Bug 3133930- set the return status to the new output variable */
8172 x_budget_lines_out(i).return_status := x_return_status;
8173
8174 IF l_debug_mode = 'Y' THEN
8175 pa_debug.g_err_stage:= 'Txn Curreny Code Entered is '|| l_txn_curr_code ;
8176 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
8177 END IF;
8178 ELSE
8179 -- populate the error code specific to webadi context
8180 l_webadi_err_code_tbl.extend(1);
8181 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := 'PA_FP_WA_TXN_CURR_NOT_AVL_PT';
8182 l_webadi_err_task_id_tbl.extend(1);
8183 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
8184 l_webadi_err_rlm_id_tbl.extend(1);
8185 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
8186 l_webadi_err_txn_curr_tbl.extend(1);
8187 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
8188 l_webadi_err_amt_type_tbl.extend(1);
8189 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
8190
8191 END IF; -- WEBADI context
8192
8193 l_any_error_occurred_flag:='Y';
8194 END IF;
8195
8196 END IF;
8197
8198 -- deriving the value of a flag to continue the following processing
8199 l_webadi_cont_proc_flag:='Y';
8200 IF p_calling_context = 'WEBADI' THEN
8201 IF (p_delete_flag_tbl.exists(i) AND
8202 Nvl(p_delete_flag_tbl(i), 'N') = 'Y')THEN
8203 l_webadi_cont_proc_flag := 'N';
8204 END IF;
8205 END IF;
8206 -- validation of curr attributes is done only if the currency passed is a valid currency.
8207 IF l_valid_txn_curr THEN
8208 IF l_webadi_cont_proc_flag = 'Y' THEN -- Bug 3986129: FP.M Web ADI Dev changes
8209 l_wa_val_conv_attr_flag := 'Y';
8210 --TXN Currency is valid . validate the currency attributes
8211 IF (px_budget_lines_in(i).project_cost_rate_type IS NULL AND
8212 px_budget_lines_in(i).project_cost_rate_date_type IS NULL AND
8213 px_budget_lines_in(i).project_cost_rate_date IS NULL AND
8214 px_budget_lines_in(i).projfunc_cost_rate_type IS NULL AND
8215 px_budget_lines_in(i).projfunc_cost_rate_date_type IS NULL AND
8216 px_budget_lines_in(i).projfunc_cost_rate_date IS NULL AND
8217 px_budget_lines_in(i).project_rev_rate_type IS NULL AND
8218 px_budget_lines_in(i).project_rev_rate_date_type IS NULL AND
8219 px_budget_lines_in(i).project_rev_rate_date IS NULL AND
8220 px_budget_lines_in(i).projfunc_rev_rate_type IS NULL AND
8221 px_budget_lines_in(i).projfunc_rev_rate_date_type IS NULL AND
8222 px_budget_lines_in(i).projfunc_rev_rate_date IS NULL ) THEN
8223
8224 IF l_debug_mode = 'Y' THEN
8225 pa_debug.g_err_stage := 'Deriving the conversion attrs from plan Version option';
8226 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
8227 END IF;
8228
8229 -- Bug 3986129: FP.M Web ADI Dev changes: included the following check
8230 IF p_calling_context <> 'WEBADI' THEN
8231 px_budget_lines_in(i).project_cost_rate_type := p_project_cost_rate_type ;
8232 px_budget_lines_in(i).project_cost_rate_date_type := p_project_cost_rate_date_typ ;
8233 px_budget_lines_in(i).project_cost_rate_date := p_project_cost_rate_date ;
8234 px_budget_lines_in(i).projfunc_cost_rate_type := p_projfunc_cost_rate_type ;
8235 px_budget_lines_in(i).projfunc_cost_rate_date_type:= p_projfunc_cost_rate_date_typ ;
8236 px_budget_lines_in(i).projfunc_cost_rate_date := p_projfunc_cost_rate_date ;
8237 px_budget_lines_in(i).project_rev_rate_type := p_project_rev_rate_type ;
8238 px_budget_lines_in(i).project_rev_rate_date_type := p_project_rev_rate_date_typ ;
8239 px_budget_lines_in(i).project_rev_rate_date := p_project_rev_rate_date ;
8240 px_budget_lines_in(i).projfunc_rev_rate_type := p_projfunc_rev_rate_type ;
8241 px_budget_lines_in(i).projfunc_rev_rate_date_type := p_projfunc_rev_rate_date_typ ;
8242 px_budget_lines_in(i).projfunc_rev_rate_date := p_projfunc_rev_rate_date ;
8243 END IF;
8244
8245 l_wa_val_conv_attr_flag := 'N';
8246
8247 -- Conversion attributes are passed. Validate them
8248 ELSE
8249 -- Depending on p_version_type initialise l_conv_attrs_to_be_validated
8250 IF (p_version_type <> PA_FP_CONSTANTS_PKG.G_VERSION_TYPE_ALL) THEN
8251 l_conv_attrs_to_be_validated := p_version_type;
8252 ELSE
8253 l_conv_attrs_to_be_validated := PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_BOTH;
8254 END IF;
8255
8256 -- Null out the cost attributes for revenue version and vice versa
8257 IF l_conv_attrs_to_be_validated = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_COST THEN
8258
8259 px_budget_lines_in(i).project_rev_rate_type :=NULL;
8260 px_budget_lines_in(i).project_rev_rate_date_type :=NULL;
8261 px_budget_lines_in(i).project_rev_rate_date :=NULL;
8262 px_budget_lines_in(i).project_rev_exchange_rate :=NULL;
8263
8264 px_budget_lines_in(i).projfunc_rev_rate_type :=NULL;
8265 px_budget_lines_in(i).projfunc_rev_rate_date_type :=NULL;
8266 px_budget_lines_in(i).projfunc_rev_rate_date :=NULL;
8267 px_budget_lines_in(i).projfunc_rev_exchange_rate :=NULL;
8268
8269 ELSIF l_conv_attrs_to_be_validated = PA_FP_CONSTANTS_PKG.G_ELEMENT_TYPE_REVENUE THEN
8270
8271 px_budget_lines_in(i).project_cost_rate_type :=NULL;
8272 px_budget_lines_in(i).project_cost_rate_date_type :=NULL;
8273 px_budget_lines_in(i).project_cost_rate_date :=NULL;
8274 px_budget_lines_in(i).project_cost_exchange_rate :=NULL;
8275
8276 px_budget_lines_in(i).projfunc_cost_rate_type :=NULL;
8277 px_budget_lines_in(i).projfunc_cost_rate_date_type :=NULL;
8278 px_budget_lines_in(i).projfunc_cost_rate_date :=NULL;
8279 px_budget_lines_in(i).projfunc_cost_exchange_rate :=NULL;
8280
8281 END IF;
8282
8283 -- Bug 3986129: FP.M Web ADI Dev changes: included the following check
8284 IF p_calling_context = 'WEBADI' AND
8285 l_wa_val_conv_attr_flag='Y' THEN
8286
8287 IF px_budget_lines_in(i).project_cost_rate_type = FND_API.G_MISS_CHAR THEN
8288 l_wa_project_cost_rate_typ := NULL;
8289 ELSE
8290 l_wa_project_cost_rate_typ := px_budget_lines_in(i).project_cost_rate_type;
8291 END IF;
8292 IF px_budget_lines_in(i).project_cost_rate_date_type = FND_API.G_MISS_CHAR THEN
8293 l_wa_project_cost_rate_dt_typ := NULL;
8294 ELSE
8295 l_wa_project_cost_rate_dt_typ := px_budget_lines_in(i).project_cost_rate_date_type;
8296 END IF;
8297 IF px_budget_lines_in(i).project_cost_rate_date = FND_API.G_MISS_DATE THEN
8298 l_wa_project_cost_rate_date := NULL;
8299 ELSE
8300 l_wa_project_cost_rate_date := px_budget_lines_in(i).project_cost_rate_date;
8301 END IF;
8302 IF px_budget_lines_in(i).project_cost_exchange_rate = FND_API.G_MISS_NUM THEN
8303 l_wa_project_cost_exc_rate := NULL;
8304 ELSE
8305 l_wa_project_cost_exc_rate := px_budget_lines_in(i).project_cost_exchange_rate;
8306 END IF;
8307 IF px_budget_lines_in(i).projfunc_cost_rate_type = FND_API.G_MISS_CHAR THEN
8308 l_wa_projfunc_cost_rate_typ := NULL;
8309 ELSE
8310 l_wa_projfunc_cost_rate_typ := px_budget_lines_in(i).projfunc_cost_rate_type;
8311 END IF;
8312 IF px_budget_lines_in(i).projfunc_cost_rate_date_type = FND_API.G_MISS_CHAR THEN
8313 l_wa_projfunc_cost_rate_dt_typ := NULL;
8314 ELSE
8315 l_wa_projfunc_cost_rate_dt_typ := px_budget_lines_in(i).projfunc_cost_rate_date_type;
8316 END IF;
8317 IF px_budget_lines_in(i).projfunc_cost_rate_date = FND_API.G_MISS_DATE THEN
8318 l_wa_projfunc_cost_rate_date := NULL;
8319 ELSE
8320 l_wa_projfunc_cost_rate_date := px_budget_lines_in(i).projfunc_cost_rate_date;
8321 END IF;
8322 IF px_budget_lines_in(i).projfunc_cost_exchange_rate = FND_API.G_MISS_NUM THEN
8323 l_wa_projfunc_cost_exc_rate := NULL;
8324 ELSE
8325 l_wa_projfunc_cost_exc_rate := px_budget_lines_in(i).projfunc_cost_exchange_rate;
8326 END IF;
8327 IF px_budget_lines_in(i).project_rev_rate_type = FND_API.G_MISS_CHAR THEN
8328 l_wa_project_rev_rate_typ := NULL;
8329 ELSE
8330 l_wa_project_rev_rate_typ := px_budget_lines_in(i).project_rev_rate_type;
8331 END IF;
8332 IF px_budget_lines_in(i).project_rev_rate_date_type = FND_API.G_MISS_CHAR THEN
8333 l_wa_project_rev_rate_dt_typ := NULL;
8334 ELSE
8335 l_wa_project_rev_rate_dt_typ := px_budget_lines_in(i).project_rev_rate_date_type;
8336 END IF;
8337 IF px_budget_lines_in(i).project_rev_rate_date = FND_API.G_MISS_DATE THEN
8338 l_wa_project_rev_rate_date := NULL;
8339 ELSE
8340 l_wa_project_rev_rate_date := px_budget_lines_in(i).project_rev_rate_date;
8341 END IF;
8342 IF px_budget_lines_in(i).project_rev_exchange_rate = FND_API.G_MISS_NUM THEN
8343 l_wa_project_rev_exc_rate := NULL;
8344 ELSE
8345 l_wa_project_rev_exc_rate := px_budget_lines_in(i).project_rev_exchange_rate;
8346 END IF;
8347 IF px_budget_lines_in(i).projfunc_rev_rate_type = FND_API.G_MISS_CHAR THEN
8348 l_wa_projfunc_rev_rate_typ := NULL;
8349 ELSE
8350 l_wa_projfunc_rev_rate_typ := px_budget_lines_in(i).projfunc_rev_rate_type;
8351 END IF;
8352 IF px_budget_lines_in(i).projfunc_rev_rate_date_type = FND_API.G_MISS_CHAR THEN
8353 l_wa_projfunc_rev_rate_dt_typ := NULL;
8354 ELSE
8355 l_wa_projfunc_rev_rate_dt_typ := px_budget_lines_in(i).projfunc_rev_rate_date_type;
8356 END IF;
8357 IF px_budget_lines_in(i).projfunc_rev_rate_date = FND_API.G_MISS_DATE THEN
8358 l_wa_projfunc_rev_rate_date := NULL;
8359 ELSE
8360 l_wa_projfunc_rev_rate_date := px_budget_lines_in(i).projfunc_rev_rate_date;
8361 END IF;
8362 IF px_budget_lines_in(i).projfunc_rev_exchange_rate = FND_API.G_MISS_NUM THEN
8363 l_wa_projfunc_rev_exc_rate := NULL;
8364 ELSE
8365 l_wa_projfunc_rev_exc_rate := px_budget_lines_in(i).projfunc_rev_exchange_rate;
8366 END IF;
8367 END IF; -- p_context = WEBADI
8368
8369 --Validate the conversion attributes passed
8370 IF p_calling_context = 'WEBADI' AND
8371 l_wa_val_conv_attr_flag='Y' THEN
8372 pa_fin_plan_utils.validate_currency_attributes
8373 ( px_project_cost_rate_type => l_wa_project_cost_rate_typ
8374 ,px_project_cost_rate_date_typ => l_wa_project_cost_rate_dt_typ
8375 ,px_project_cost_rate_date => l_wa_project_cost_rate_date
8376 ,px_project_cost_exchange_rate => l_wa_project_cost_exc_rate
8377 ,px_projfunc_cost_rate_type => l_wa_projfunc_cost_rate_typ
8378 ,px_projfunc_cost_rate_date_typ => l_wa_projfunc_cost_rate_dt_typ
8379 ,px_projfunc_cost_rate_date => l_wa_projfunc_cost_rate_date
8380 ,px_projfunc_cost_exchange_rate => l_wa_projfunc_cost_exc_rate
8381 ,px_project_rev_rate_type => l_wa_project_rev_rate_typ
8382 ,px_project_rev_rate_date_typ => l_wa_project_rev_rate_dt_typ
8383 ,px_project_rev_rate_date => l_wa_project_rev_rate_date
8384 ,px_project_rev_exchange_rate => l_wa_project_rev_exc_rate
8385 ,px_projfunc_rev_rate_type => l_wa_projfunc_rev_rate_typ
8386 ,px_projfunc_rev_rate_date_typ => l_wa_projfunc_rev_rate_dt_typ
8387 ,px_projfunc_rev_rate_date => l_wa_projfunc_rev_rate_date
8388 ,px_projfunc_rev_exchange_rate => l_wa_projfunc_rev_exc_rate
8389 ,p_project_currency_code => l_project_currency_code
8390 ,p_projfunc_currency_code => l_projfunc_currency_code
8391 ,p_context => PA_FP_CONSTANTS_PKG.G_WEBADI
8392 ,p_attrs_to_be_validated => l_conv_attrs_to_be_validated
8393 ,x_return_status => x_return_status
8394 ,x_msg_count => x_msg_count
8395 ,x_msg_data => x_msg_data);
8396 ELSE
8397 pa_fin_plan_utils.validate_currency_attributes
8398 ( px_project_cost_rate_type =>px_budget_lines_in(i).project_cost_rate_type
8399 ,px_project_cost_rate_date_typ =>px_budget_lines_in(i).project_cost_rate_date_type
8400 ,px_project_cost_rate_date =>px_budget_lines_in(i).project_cost_rate_date
8401 ,px_project_cost_exchange_rate =>px_budget_lines_in(i).project_cost_exchange_rate
8402 ,px_projfunc_cost_rate_type =>px_budget_lines_in(i).projfunc_cost_rate_type
8403 ,px_projfunc_cost_rate_date_typ =>px_budget_lines_in(i).projfunc_cost_rate_date_type
8404 ,px_projfunc_cost_rate_date =>px_budget_lines_in(i).projfunc_cost_rate_date
8405 ,px_projfunc_cost_exchange_rate =>px_budget_lines_in(i).projfunc_cost_exchange_rate
8406 ,px_project_rev_rate_type =>px_budget_lines_in(i).project_rev_rate_type
8407 ,px_project_rev_rate_date_typ =>px_budget_lines_in(i).project_rev_rate_date_type
8408 ,px_project_rev_rate_date =>px_budget_lines_in(i).project_rev_rate_date
8409 ,px_project_rev_exchange_rate =>px_budget_lines_in(i).project_rev_exchange_rate
8410 ,px_projfunc_rev_rate_type =>px_budget_lines_in(i).projfunc_rev_rate_type
8411 ,px_projfunc_rev_rate_date_typ =>px_budget_lines_in(i).projfunc_rev_rate_date_type
8412 ,px_projfunc_rev_rate_date =>px_budget_lines_in(i).projfunc_rev_rate_date
8413 ,px_projfunc_rev_exchange_rate =>px_budget_lines_in(i).projfunc_rev_exchange_rate
8414 ,p_project_currency_code =>l_project_currency_code
8415 ,p_projfunc_currency_code =>l_projfunc_currency_code
8416 ,p_context =>PA_FP_CONSTANTS_PKG.G_AMG_API_DETAIL
8417 ,p_attrs_to_be_validated =>l_conv_attrs_to_be_validated
8418 ,x_return_status =>x_return_status
8419 ,x_msg_count =>x_msg_count
8420 ,x_msg_data =>x_msg_data);
8421 END IF;
8422 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
8423 IF p_calling_context <> 'WEBADI' THEN
8424 /* Bug 3133930- set the return status to the new output variable */
8425 x_budget_lines_out(i).return_status := x_return_status;
8426
8427 ELSIF l_wa_val_conv_attr_flag='Y' THEN
8428 l_webadi_err_code_tbl.extend(1);
8429 l_webadi_err_code_tbl(l_webadi_err_code_tbl.COUNT) := l_wa_error_code_lookup(PA_FIN_PLAN_UTILS.g_first_error_code);
8430 l_webadi_err_task_id_tbl.extend(1);
8431 l_webadi_err_task_id_tbl(l_webadi_err_task_id_tbl.COUNT) := px_budget_lines_in(i).pa_task_id;
8432 l_webadi_err_rlm_id_tbl.extend(1);
8433 l_webadi_err_rlm_id_tbl(l_webadi_err_rlm_id_tbl.COUNT) := px_budget_lines_in(i).resource_list_member_id;
8434 l_webadi_err_txn_curr_tbl.extend(1);
8435 l_webadi_err_txn_curr_tbl(l_webadi_err_txn_curr_tbl.COUNT) := px_budget_lines_in(i).txn_currency_code;
8436 l_webadi_err_amt_type_tbl.extend(1);
8437 l_webadi_err_amt_type_tbl(l_webadi_err_amt_type_tbl.COUNT) := p_amount_type_tbl(i);
8438 END IF;
8439
8440 l_any_error_occurred_flag:='Y';
8441 ELSIF x_return_status = FND_API.G_RET_STS_SUCCESS THEN
8442 IF p_calling_context = 'WEBADI' THEN --Bug 4382980
8443 -- copying back the validated attribute in the rac type
8444 px_budget_lines_in(i).project_cost_rate_type := l_wa_project_cost_rate_typ;
8445 px_budget_lines_in(i).project_cost_rate_date_type := l_wa_project_cost_rate_dt_typ;
8446 px_budget_lines_in(i).project_cost_rate_date := l_wa_project_cost_rate_date;
8447 px_budget_lines_in(i).project_cost_exchange_rate := l_wa_project_cost_exc_rate;
8448 px_budget_lines_in(i).projfunc_cost_rate_type := l_wa_projfunc_cost_rate_typ;
8449 px_budget_lines_in(i).projfunc_cost_rate_date_type := l_wa_projfunc_cost_rate_dt_typ;
8450 px_budget_lines_in(i).projfunc_cost_rate_date := l_wa_projfunc_cost_rate_date;
8451 px_budget_lines_in(i).projfunc_cost_exchange_rate := l_wa_projfunc_cost_exc_rate;
8452 px_budget_lines_in(i).project_rev_rate_type := l_wa_project_rev_rate_typ;
8453 px_budget_lines_in(i).project_rev_rate_date_type := l_wa_project_rev_rate_dt_typ;
8454 px_budget_lines_in(i).project_rev_rate_date := l_wa_project_rev_rate_date;
8455 px_budget_lines_in(i).project_rev_exchange_rate := l_wa_project_rev_exc_rate;
8456 px_budget_lines_in(i).projfunc_rev_rate_type := l_wa_projfunc_rev_rate_typ;
8457 px_budget_lines_in(i).projfunc_rev_rate_date_type := l_wa_projfunc_rev_rate_dt_typ;
8458 px_budget_lines_in(i).projfunc_rev_rate_date := l_wa_projfunc_rev_rate_date;
8459 px_budget_lines_in(i).projfunc_rev_exchange_rate := l_wa_projfunc_rev_exc_rate;
8460 END IF;
8461 END IF; -- return_status
8462 END IF;--IF all parameters are null
8463 END IF; -- cont_proc_flag
8464 END IF; -- IF l_valid_txn_curr THEN
8465
8466 /* Bug 4224464: FP M Changes Start */
8467 --Check if Actuals have been entered for the FORECAST Line. We perform this
8468 --check only when p_version_info_rec.x_budget_version_id has been passed.
8469 IF p_calling_context <> 'WEBADI' THEN
8470 IF (p_version_info_rec.x_budget_version_id IS NOT NULL)
8471 THEN
8472 OPEN budget_version_info_cur(p_version_info_rec.x_budget_version_id);
8473 FETCH budget_version_info_cur
8474 INTO l_plan_class_code
8475 ,l_etc_start_date;
8476
8477 IF budget_version_info_cur%NOTFOUND
8478 THEN
8479 l_any_error_occurred_flag := 'Y';
8480 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
8481 THEN
8482 PA_UTILS.add_message
8483 (p_app_short_name => 'PA'
8484 ,p_msg_name => 'PA_FP_NO_WORKING_VERSION'
8485 ,p_token1 => 'PROJECT'
8486 ,p_value1 => l_amg_project_rec.segment1
8487 ,p_token2 => 'PLAN_TYPE'
8488 ,p_value2 => l_fin_plan_type_name
8489 ,p_token3 => 'VERSION_NUMBER'
8490 ,p_value3 => '' );
8491 END IF;
8492
8493 IF l_debug_mode = 'Y' THEN
8494 pa_debug.g_err_stage := 'Passed Budget Version Id is invalid';
8495 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
8496 END IF;
8497
8498 END IF; --budget_version_info_cur%NOTFOUND
8499
8500 CLOSE budget_version_info_cur;
8501
8502 IF (l_plan_class_code IS NOT NULL AND
8503 l_plan_class_code = 'FORECAST' AND
8504 l_etc_start_date IS NOT NULL AND
8505 l_etc_start_date > px_budget_lines_in(i).budget_start_date AND
8506 p_time_phased_code IS NOT NULL AND
8507 p_time_phased_code <> 'N')
8508 THEN
8509 l_any_error_occurred_flag := 'Y';
8510 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR)
8511 THEN
8512 PA_UTILS.add_message
8513 (p_app_short_name => 'PA'
8514 ,p_msg_name => 'PA_FP_FCST_ACTUALS_AMG'
8515 ,p_token1 => 'PROJECT'
8516 ,p_value1 => l_amg_project_rec.segment1
8517 ,p_token2 => 'PLAN_TYPE'
8518 ,p_value2 => l_fin_plan_type_name
8519 ,p_token3 => 'TASK'
8520 ,p_value3 => l_amg_task_number
8521 ,p_token4 => 'CURRENCY'
8522 ,p_value4 => px_budget_lines_in(i).txn_currency_code
8523 ,p_token5 => 'START_DATE'
8524 ,p_value5 => to_char(px_budget_lines_in(i).budget_start_date) );
8525 END IF;
8526
8527 IF l_debug_mode = 'Y' THEN
8528 pa_debug.g_err_stage := 'Forecast Line has actuals and hence cannot be edited';
8529 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
8530 END IF;
8531
8532 END IF;--end of actuals-on-FORECAST check
8533
8534 END IF; --budget_version_id IS NOT NULL
8535 END IF; -- p_calling_context
8536 /* Bug 4224464: FP M Changes End */
8537
8538 END IF; -- IF p_fin_plan_type_id IS NOT NULL THEN
8539
8540 END LOOP; -- ;For Loop
8541
8542 END IF;--Check for the existence of budget lines
8543
8544 -- Bug 3986129: FP.M Web ADI Dev changes
8545 IF p_calling_context = 'WEBADI' THEN
8546 IF l_webadi_err_code_tbl.COUNT > 0 THEN
8547 -- call an api to populate the error code in the excel sheet
8548 pa_fp_webadi_pkg.process_errors
8549 ( p_run_id => p_run_id,
8550 p_error_code_tbl => l_webadi_err_code_tbl,
8551 p_task_id_tbl => l_webadi_err_task_id_tbl,
8552 p_rlm_id_tbl => l_webadi_err_rlm_id_tbl,
8553 p_txn_curr_tbl => l_webadi_err_txn_curr_tbl,
8554 p_amount_type_tbl => l_webadi_err_amt_type_tbl,
8555 x_return_status => x_return_status,
8556 x_msg_data => x_msg_data,
8557 x_msg_count => x_msg_count);
8558
8559 IF x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
8560 IF l_debug_mode = 'Y' THEN
8561 pa_debug.g_err_stage := 'Call to process_errors returned with error';
8562 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
8563 END IF;
8564
8565 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
8566 END IF;
8567 END IF; -- error tbl count > 0
8568 END IF; -- Bug 3986129
8569
8570 --Raise an error if any errors are reported till this poing
8571 IF l_any_error_occurred_flag = 'Y' THEN
8572 IF p_calling_context <> 'WEBADI' THEN
8573 IF l_debug_mode = 'Y' THEN
8574 pa_debug.g_err_stage := 'Reporting the errors occured while validating budget lines';
8575 pa_debug.write(l_module_name,pa_debug.g_err_stage,l_debug_level3);
8576 END IF;
8577
8578 RAISE PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc;
8579 END IF; -- non webadi context
8580 END IF;
8581
8582 -- Null out the global variables.
8583 pa_budget_pvt.g_Task_number := NULL;
8584 pa_budget_pvt.g_start_date := NULL;
8585 pa_budget_pvt.g_resource_alias := NULL;
8586
8587
8588 IF l_debug_mode = 'Y' THEN
8589 pa_debug.g_err_stage:= 'Exiting Validate Budget Lines';
8590 pa_debug.write(g_module_name,pa_debug.g_err_stage,
8591 l_debug_level3);
8592 pa_debug.reset_curr_function;
8593 END IF;
8594 EXCEPTION
8595 WHEN PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc THEN
8596
8597 IF x_return_status IS NULL OR
8598 x_return_status = FND_API.G_RET_STS_SUCCESS THEN
8599 x_return_status := FND_API.G_RET_STS_ERROR;
8600
8601 END IF;
8602
8603 l_msg_count := FND_MSG_PUB.count_msg;
8604
8605 IF l_msg_count = 1 and x_msg_data IS NULL THEN
8606 PA_INTERFACE_UTILS_PUB.get_messages
8607 (p_encoded => FND_API.G_TRUE
8608 ,p_msg_index => 1
8609 ,p_msg_count => l_msg_count
8610 ,p_msg_data => l_msg_data
8611 ,p_data => l_data
8612 ,p_msg_index_out => l_msg_index_out);
8613 x_msg_data := l_data;
8614 x_msg_count := l_msg_count;
8615 ELSE
8616 x_msg_count := l_msg_count;
8617 END IF;
8618 IF l_debug_mode = 'Y' THEN
8619 pa_debug.reset_curr_function;
8620 END IF;
8621 RETURN;
8622
8623 WHEN OTHERS THEN
8624
8625 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8626
8627 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
8628
8629 THEN
8630 FND_MSG_PUB.add_exc_msg
8631 ( p_pkg_name => G_PKG_NAME
8632 , p_procedure_name => 'Validate_Budget_Lines' );
8633
8634 END IF;
8635 IF l_debug_mode = 'Y' THEN
8636 pa_debug.reset_curr_function;
8637 END IF;
8638 END validate_budget_lines;
8639
8640
8641
8642 PROCEDURE GET_FIN_PLAN_LINES_STATUS
8643 (p_calling_context IN VARCHAR2 DEFAULT NULL
8644 ,p_fin_plan_version_id IN pa_budget_versions.budget_version_id%TYPE
8645 ,p_budget_lines_in IN PA_BUDGET_PUB.budget_line_in_tbl_type
8646 ,x_fp_lines_retn_status_tab OUT NOCOPY PA_BUDGET_PUB.budget_line_out_tbl_type
8647 ,x_return_status OUT NOCOPY VARCHAR2
8648 ,x_msg_count OUT NOCOPY NUMBER
8649 ,x_msg_data OUT NOCOPY VARCHAR2)
8650
8651 IS
8652
8653 l_cost_rejection_data_tab PA_PLSQL_DATATYPES.Char2000TabTyp;
8654 l_burden_rejection_data_tab PA_PLSQL_DATATYPES.Char2000TabTyp;
8655 l_revenue_rejection_data_tab PA_PLSQL_DATATYPES.Char2000TabTyp;
8656 l_pc_conv_rejection_data_tab PA_PLSQL_DATATYPES.Char2000TabTyp;
8657 l_pfc_conv_rejection_data_tab PA_PLSQL_DATATYPES.Char2000TabTyp;
8658 l_other_rejection_data_tab PA_PLSQL_DATATYPES.Char2000TabTyp;
8659 l_return_status VARCHAR2(1);
8660 l_fin_plan_line_id_tab PA_PLSQL_DATATYPES.IDTABTYP;
8661 l_fp_lines_retn_status_tab PA_BUDGET_PUB.budget_line_out_tbl_type;
8662 l_debug_mode VARCHAR2(1);
8663 l_module_name VARCHAR2(80);
8664 l_tmp_return_status VARCHAR2(1);
8665 I NUMBER;
8666 l_count NUMBER;
8667 l_time_phased_code pa_proj_fp_options.all_time_phased_code%TYPE; -- Added for BUG 6847497
8668 l_uncategorized_flag pa_resource_lists_all_bg.uncategorized_flag%TYPE; -- Added for BUG 6847497
8669 l_budget_type_code pa_budget_versions.budget_type_code%TYPE; -- Added for BUG 6653796
8670
8671 CURSOR get_primary_key_csr IS
8672 SELECT ra.task_id,
8673 ra.resource_list_member_id,
8674 bl.txn_currency_code,
8675 bl.start_date,
8676 DECODE(bl.cost_rejection_code,NULL,
8677 DECODE(bl.revenue_rejection_code,NULL,
8678 DECODE(bl.burden_rejection_code,NULL,
8679 DECODE(bl.other_rejection_code,NULL,
8680 DECODE(bl.pfc_cur_conv_rejection_code,NULL,
8681 DECODE(bl.pc_cur_conv_rejection_code,NULL,NULL,'E')
8682 ,'E'),'E'),'E'),'E'),'E') return_status
8683 FROM pa_resource_assignments ra , pa_budget_lines bl
8684 where ra.budget_version_id = p_fin_plan_version_id
8685 and ra.resource_assignment_id = bl.resource_assignment_id;
8686
8687 BEGIN
8688
8689 x_msg_count := 0;
8690 x_return_status := FND_API.G_RET_STS_SUCCESS;
8691 l_debug_mode := NVL(FND_PROFILE.value('PA_DEBUG_MODE'),'N');
8692 l_module_name := 'PA_BUDGET_PVT.GET_FIN_PLAN_LINES_STATUS ';
8693
8694 IF l_debug_mode = 'Y' THEN
8695 pa_debug.set_curr_function( p_function => l_module_name,
8696 p_debug_mode => l_debug_mode );
8697 END IF;
8698
8699
8700 PA_FIN_PLAN_UTILS2.Get_AMG_BdgtLineRejctions
8701 (p_budget_version_id => p_fin_plan_version_id
8702 ,x_budget_line_id_tab => l_fin_plan_line_id_tab
8703 ,x_cost_rejection_data_tab => l_cost_rejection_data_tab
8704 ,x_burden_rejection_data_tab => l_burden_rejection_data_tab
8705 ,x_revenue_rejection_data_tab => l_revenue_rejection_data_tab
8706 ,x_pc_conv_rejection_data_tab => l_pc_conv_rejection_data_tab
8707 ,x_pfc_conv_rejection_data_tab => l_pfc_conv_rejection_data_tab
8708 ,x_other_rejection_data_tab => l_other_rejection_data_tab
8709 ,x_return_status => l_return_status ) ;
8710
8711 IF l_return_status ='U' THEN
8712
8713 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
8714
8715 FND_MSG_PUB.add_exc_msg
8716 ( p_pkg_name => 'PA_BUDGET_PVT'
8717 ,p_procedure_name => 'GET_FIN_PLAN_LINES_STATUS' );
8718
8719 END IF;
8720
8721 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8722
8723 END IF;
8724
8725 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
8726
8727 IF nvl(l_fin_plan_line_id_tab.LAST,0) > 0 THEN /* Bug # 3588604 */
8728
8729 FOR I in l_fin_plan_line_id_tab.FIRST .. l_fin_plan_line_id_tab.LAST LOOP
8730
8731 IF L_cost_rejection_data_tab(I) IS NOT NULL THEN
8732
8733 pa_utils.Add_Message( p_app_short_name => 'PA'
8734 ,p_msg_name =>l_cost_rejection_data_tab(i));
8735
8736 END IF;
8737
8738 IF l_burden_rejection_data_tab(I) IS NOT NULL THEN
8739
8740 pa_utils.Add_Message( p_app_short_name => 'PA'
8741 ,p_msg_name =>l_burden_rejection_data_tab(i));
8742
8743 END IF;
8744 IF l_revenue_rejection_data_tab(I) IS NOT NULL THEN
8745
8746 pa_utils.Add_Message( p_app_short_name => 'PA'
8747 ,p_msg_name =>l_revenue_rejection_data_tab(i));
8748
8749 END IF;
8750 IF l_pc_conv_rejection_data_tab(I) IS NOT NULL THEN
8751
8752 pa_utils.Add_Message( p_app_short_name => 'PA'
8753 ,p_msg_name =>l_pc_conv_rejection_data_tab(i));
8754
8755 END IF;
8756 IF l_pfc_conv_rejection_data_tab(I) IS NOT NULL THEN
8757
8758 pa_utils.Add_Message( p_app_short_name => 'PA'
8759 ,p_msg_name =>l_pfc_conv_rejection_data_tab(i));
8760
8761 END IF;
8762
8763 IF l_other_rejection_data_tab(I) IS NOT NULL THEN
8764 pa_utils.Add_Message( p_app_short_name => 'PA'
8765 ,p_msg_name => l_other_rejection_data_tab(i));
8766
8767 END IF;
8768
8769 END LOOP;
8770
8771 END IF; --IF nvl(l_fin_plan_line_id_tab.LAST,0) > 0
8772
8773 END IF;
8774
8775 -- Bug 8318068 Tring to get budget type code to find if its old model budget to avoid processing being done as
8776 -- per code fix for bug 6653796.
8777 BEGIN
8778 SELECT budget_type_code
8779 INTO l_budget_type_code
8780 FROM pa_budget_versions
8781 WHERE budget_version_id = p_fin_plan_version_id;
8782
8783 EXCEPTION
8784 WHEN NO_DATA_FOUND THEN
8785 l_budget_type_code := NULL;
8786 END;
8787
8788 IF l_budget_type_code IS NULL THEN
8789 BEGIN /* Added for bug 7611462 */
8790
8791 SELECT nvl(cost_time_phased_code,NVL(revenue_time_phased_code,all_time_phased_code)), -- Added for BUG 6847497
8792 prl.uncategorized_flag
8793 INTO l_time_phased_code, l_uncategorized_flag
8794 FROM pa_proj_fp_options , pa_resource_lists_all_bg prl
8795 WHERE fin_plan_version_id=p_fin_plan_version_id
8796 AND nvl(cost_resource_list_id,nvl(revenue_resource_list_id,all_resource_list_id))=
8797 prl.resource_list_id;
8798
8799 /* Added below logic for bug 7611462 */
8800 EXCEPTION
8801 WHEN NO_DATA_FOUND THEN
8802 l_time_phased_code := NULL;
8803 l_uncategorized_flag := NULL;
8804 END;/* Ends added for bug 7611462 */
8805 END IF; --IF l_budget_type_code IS NULL THEN
8806
8807 /*===========================================================================+
8808 | The amg api pa_budgets_pub.CREATE_DRAFT_FINPLAN need to know if |
8809 | any of budget lines in the budget version had any rejections. |
8810 | And that's all it need to know. x_return_status is being reused for this. |
8811 +===========================================================================*/
8812 IF ( p_calling_context = 'CREATE_DRAFT_FINPLAN')
8813 THEN
8814 IF ( NVL(l_fin_plan_line_id_tab.LAST,0) > 0 )
8815 THEN
8816 x_return_status := 'R';
8817 END IF;
8818
8819 END IF; --p_calling_context <> 'CREATE_DRAFT_FINPLAN'
8820
8821 /*=========================================================================+
8822 | pa_budgets_pub.CREATE_DRAFT_FINPLAN is AMG api. When this api is called |
8823 | from CREATE_DRAFT_FINPLAN, p_budget_lines_in is not passed in. |
8824 | Rejections at the budget line level need not be returned back. Hence |
8825 | the following code not executed for when it is calling from the AMG api.|
8826 +=========================================================================*/
8827 IF ( NVL(p_calling_context,'-99') <> 'CREATE_DRAFT_FINPLAN')
8828 THEN
8829 FOR l_primary_key_tab IN get_primary_key_csr LOOP
8830
8831 l_count := 0;
8832
8833 IF nvl(p_budget_lines_in.LAST,0) > 0 THEN /* Bug # 3588604 */
8834
8835 FOR k in p_budget_lines_in.FIRST .. p_budget_lines_in.LAST LOOP
8836
8837 IF l_budget_type_code IS NULL THEN --Bug 8318068
8838 /* Added null handing for l_time_phased_code for bug 7611462 */
8839 IF ( p_budget_lines_in(k).pa_task_id = l_primary_key_tab.task_id) AND -- Modified for BUG 6847497
8840 (((NVL(l_uncategorized_flag,'N')<>'Y') AND (p_budget_lines_in(k).resource_list_member_id = l_primary_key_tab.resource_list_member_id)) OR l_uncategorized_flag = 'Y') AND
8841 (((nvl(l_time_phased_code, 'Y') <> 'N') AND (nvl(p_budget_lines_in(k).budget_start_date, l_primary_key_tab.start_date) = l_primary_key_tab.start_date)) OR l_time_phased_code = 'N') AND
8842 (nvl(p_budget_lines_in(k).txn_currency_code,l_primary_key_tab.txn_currency_code) = l_primary_key_tab.txn_currency_code) THEN
8843
8844 l_count := 1;
8845 l_fp_lines_retn_status_tab(k).return_status := l_primary_key_tab.return_status;
8846
8847 END IF;
8848 ELSE
8849 IF (p_budget_lines_in(k).pa_task_id = l_primary_key_tab.task_id) AND
8850 (p_budget_lines_in(k).resource_list_member_id = l_primary_key_tab.resource_list_member_id ) AND
8851 (nvl(p_budget_lines_in(k).budget_start_date,l_primary_key_tab.start_date) = l_primary_key_tab.start_date) AND
8852 (nvl(p_budget_lines_in(k).txn_currency_code,l_primary_key_tab.txn_currency_code) = l_primary_key_tab.txn_currency_code) THEN
8853
8854 l_count := 1;
8855 l_fp_lines_retn_status_tab(k).return_status := l_primary_key_tab.return_status;
8856
8857 END IF;
8858 END IF; -- IF l_budget_type_code IS NULL THEN
8859
8860 EXIT WHEN (l_count = 1);
8861
8862 END LOOP;
8863
8864 END IF ; --IF nvl(p_budget_lines_in.LAST,0) > 0
8865
8866
8867 IF (l_count = 0) THEN
8868 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
8869 END IF;
8870
8871 END LOOP;
8872
8873 x_fp_lines_retn_status_tab := l_fp_lines_retn_status_tab ;
8874 END IF; -- p_calling_context <> 'CREATE_DRAFT_FINPLAN'
8875 -- bug 7813303
8876 IF l_debug_mode = 'Y' THEN
8877 pa_debug.reset_curr_function;
8878 END IF;
8879
8880 EXCEPTION
8881
8882 WHEN PA_FP_CONSTANTS_PKG.Invalid_Arg_Exc THEN
8883
8884 x_return_status := FND_API.G_RET_STS_ERROR;
8885 IF l_debug_mode = 'Y' THEN
8886 pa_debug.g_err_stage:= 'Invalid Arguments Passed';
8887 pa_debug.write('GET_FIN_PLAN_LINES_STATUS: ' || g_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL5);
8888 -- bug 7813303 - replaced reset_err_stack with reset_curr_function
8889 -- pa_debug.reset_err_stack;
8890 pa_debug.reset_curr_function;
8891
8892 END IF;
8893 RETURN;
8894
8895 WHEN OTHERS THEN
8896
8897 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
8898 x_msg_count := 1;
8899 x_msg_data := SQLERRM;
8900
8901 FND_MSG_PUB.add_exc_msg( p_pkg_name => 'pa_budget_pvt'
8902 ,p_procedure_name => 'GET_FIN_PLAN_LINES_STATUS');
8903
8904 IF l_debug_mode = 'Y' THEN
8905 pa_debug.g_err_stage:= 'Unexpected Error'||SQLERRM;
8906 pa_debug.write('GET_FIN_PLAN_LINES_STATUS: ' || g_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL5);
8907 -- bug 7813303 - replaced reset_err_stack with reset_curr_function
8908 -- pa_debug.reset_err_stack;
8909 pa_debug.reset_curr_function;
8910
8911 END IF;
8912 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count
8913 ,p_data => x_msg_data );
8914 RAISE;
8915
8916
8917 END GET_FIN_PLAN_LINES_STATUS;
8918
8919
8920 -- Function : Is_bc_enabled_for_budget
8921 -- Purpose : This functions returns true if a record exists in
8922 -- PA_BC_BALANCES table for the given budget version id
8923 -- Parameters : Budget Version Id.
8924 --
8925
8926 FUNCTION Is_bc_enabled_for_budget
8927 ( p_budget_version_id IN NUMBER )
8928 RETURN BOOLEAN
8929 IS
8930
8931 CURSOR bc_enabled_for_budg_ver_csr
8932 IS
8933 SELECT 'Y'
8934 FROM pa_bc_balances
8935 WHERE budget_version_id = p_budget_version_id;
8936
8937 l_return_value VARCHAR2(2) := 'N';
8938
8939 BEGIN
8940
8941 OPEN bc_enabled_for_budg_ver_csr;
8942 FETCH bc_enabled_for_budg_ver_csr into l_return_value;
8943 CLOSE bc_enabled_for_budg_ver_csr;
8944
8945 IF ( l_return_value = 'Y' ) THEN
8946 RETURN true;
8947 ELSE
8948 RETURN false;
8949 END IF;
8950
8951 END Is_bc_enabled_for_budget;
8952
8953
8954
8955
8956 --Name: Get_Latest_BC_Year
8957 --Type: Procedure
8958 --Description: For budgetary control projects, this procedure fetches the
8959 -- latest encumbrance year for the project's set-of-books.
8960 --
8961 --
8962 --
8963 --History:
8964 -- 27-SEP-2005 jwhite Created per bug 4588279
8965
8966
8967 PROCEDURE Get_Latest_BC_Year
8968 ( p_pa_project_id IN pa_projects_all.project_id%TYPE
8969 ,x_latest_encumbrance_year OUT NOCOPY gl_ledgers.Latest_Encumbrance_Year%TYPE
8970 ,x_return_status OUT NOCOPY VARCHAR2
8971 ,x_msg_count OUT NOCOPY NUMBER
8972 ,x_msg_data OUT NOCOPY VARCHAR2
8973 )
8974
8975 IS
8976
8977 l_debug_mode VARCHAR2(1) := NULL;
8978 l_module_name VARCHAR2(80) :=NULL;
8979
8980 BEGIN
8981
8982 x_msg_count := 0;
8983 x_return_status := FND_API.G_RET_STS_SUCCESS;
8984
8985 l_debug_mode := NVL(FND_PROFILE.value('PA_DEBUG_MODE'),'N');
8986 l_module_name := 'PA_BUDGET_PVT.GET_FIN_PLAN_LINES_STATUS ';
8987
8988 IF l_debug_mode = 'Y' THEN
8989 pa_debug.set_curr_function( p_function => l_module_name,
8990 p_debug_mode => l_debug_mode );
8991 END IF;
8992
8993
8994
8995 SELECT l.Latest_Encumbrance_Year
8996 INTO x_latest_encumbrance_year
8997 FROM GL_ledgers l
8998 , pa_implementations_all i
8999 , pa_projects_all p
9000 WHERE l.LEDGER_ID = i.set_of_books_id
9001 AND i.org_id = p.org_id
9002 AND p.project_id = p_pa_project_id;
9003
9004
9005
9006 EXCEPTION
9007
9008 WHEN OTHERS THEN
9009
9010 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
9011 x_msg_count := 1;
9012 x_msg_data := SQLERRM;
9013
9014 FND_MSG_PUB.add_exc_msg( p_pkg_name => 'pa_budget_pvt'
9015 ,p_procedure_name => 'GET_LATEST_BC_YEAR');
9016 IF l_debug_mode = 'Y' THEN
9017 pa_debug.g_err_stage:= 'Unexpected Error'||SQLERRM;
9018 pa_debug.write('GET_LATEST_BC_YEAR: ' || g_module_name,pa_debug.g_err_stage,PA_FP_CONSTANTS_PKG.G_DEBUG_LEVEL5);
9019 pa_debug.reset_err_stack;
9020 END IF;
9021 FND_MSG_PUB.Count_And_Get (p_count => x_msg_count
9022 ,p_data => x_msg_data );
9023 RAISE;
9024
9025
9026 END Get_Latest_BC_Year;
9027
9028
9029
9030
9031
9032
9033 end PA_BUDGET_PVT;