DBA Data[Home] [Help]

PACKAGE BODY: APPS.PJI_VP_REP_DFLT_PARAMS

Source


1 PACKAGE BODY Pji_Vp_Rep_Dflt_Params AS
2 /* $Header: PJIRX11B.pls 120.2.12020000.3 2013/03/14 06:26:28 krkondur ship $ */
3 
4 
5 PROCEDURE Derive_Default_Parameters
6 (p_project_id NUMBER DEFAULT NULL
7 , p_fin_plan_type_id NUMBER
8 , p_cost_version_id IN OUT NOCOPY  NUMBER
9 , p_rev_version_id IN OUT NOCOPY  NUMBER
10 , x_rbs_version_id OUT NOCOPY NUMBER
11 , x_rbs_element_id OUT NOCOPY NUMBER
12 , x_wbs_version_id OUT NOCOPY NUMBER
13 , x_wbs_element_id OUT NOCOPY NUMBER
14 , x_curr_record_type_id OUT NOCOPY NUMBER
15 , x_currency_code OUT NOCOPY VARCHAR2
16 , x_calendar_type OUT NOCOPY VARCHAR2
17 , x_calendar_id OUT NOCOPY NUMBER
18 , x_factor_by OUT NOCOPY NUMBER
19 , x_actual_version_id OUT NOCOPY NUMBER
20 , x_curr_budget_cost_version_id OUT NOCOPY NUMBER
21 , x_prior_fcst_cost_version_id OUT NOCOPY NUMBER
22 , x_orig_budget_cost_version_id OUT NOCOPY NUMBER
23 , x_curr_budget_rev_version_id OUT NOCOPY NUMBER
24 , x_prior_fcst_rev_version_id OUT NOCOPY NUMBER
25 , x_orig_budget_rev_version_id OUT NOCOPY NUMBER
26 , x_context_plan_type OUT NOCOPY VARCHAR2
27 , x_plan_pref_code OUT NOCOPY VARCHAR2
28 , x_budget_forecast_flag OUT NOCOPY VARCHAR2
29 , x_context_report OUT NOCOPY VARCHAR2
30 , x_context_margin_mask OUT NOCOPY VARCHAR2
31 , x_cost_version_no OUT NOCOPY VARCHAR2
32 , x_cost_version_name OUT NOCOPY VARCHAR2
33 , x_cost_record_no OUT NOCOPY VARCHAR2
34 , x_rev_version_no OUT NOCOPY VARCHAR2
35 , x_rev_version_name OUT NOCOPY VARCHAR2
36 , x_rev_record_no OUT NOCOPY VARCHAR2
37 , x_slice_name OUT NOCOPY VARCHAR2
38 , x_from_period OUT NOCOPY NUMBER
39 , x_to_period OUT NOCOPY NUMBER
40 , x_cost_budget_status OUT NOCOPY VARCHAR2
41 , x_rev_budget_status OUT NOCOPY VARCHAR2
42 , x_cost_editable_flag OUT NOCOPY VARCHAR2
43 , x_rev_editable_flag OUT NOCOPY VARCHAR2
44 , x_cost_app_flag     OUT NOCOPY VARCHAR2
45 , x_rev_app_flag     OUT NOCOPY VARCHAR2
46 , x_time_phase_valid_flag OUT NOCOPY VARCHAR2
47 , x_cross_org_flag OUT NOCOPY VARCHAR2
48 , x_fbs_expansion_lvl OUT NOCOPY NUMBER
49 , x_return_status IN OUT NOCOPY VARCHAR2
50 , x_msg_count IN OUT NOCOPY NUMBER
51 , x_msg_data IN OUT NOCOPY VARCHAR2)
52 IS
53 l_currency_type VARCHAR2(256);
54 l_period_name VARCHAR2(256);
55 l_report_date_julian NUMBER;
56 l_valid_version_id NUMBER;
57 l_version_type VARCHAR2(10);
58 l_fp_options_id NUMBER;
59 l_plan_version_ids	     SYSTEM.PA_NUM_TBL_TYPE;
60 l_context_version_type VARCHAR(10);
61 
62 -- OLAP START
63 
64 	l_pjt_rollup_enabled_flag varchar2(1) ;
65 		-- OLAP END
66 
67 BEGIN
68 /*	x_rbs_element_id :=  3667;
69 	x_wbs_element_id := 2255;
70 	x_rbs_version_di :=714;
71 	x_wbs_version_id :=458;
72 	x_factor_by := 1;
73 	x_curr_budget_cost_version_id := 2383;
74 	x_prior_fcst_cost_version_id := 2398;
75 	x_orig_budget_cost_version_id := 2383;
76 	x_curr_budget_rev_version_id := 2392;
77 	x_prior_fcst_rev_version_id := 2399;
78 	x_orig_budget_rev_version_id := 2392;
79  	x_curr_record_type_id :=8;
80 	x_currency_code :='USD';
81 	x_calendar_type :='A';
82 	x_calendar_id :=24;
83 	x_cost_version_no :=1;
84 	x_cost_version_name := 'Cost Forecast - I Version 1';
85 	x_cost_record_no :=1;
86 	x_rev_version_no :=1;
87 	x_rev_version_name := 'Revenue Forecast - I Version 1';
88 	x_rev_record_no :=1;
89 	x_plan_pref_code := 'COST_AND_REVENUE_SEP';
90 	x_budget_forecast_flag := 'F';
91 	x_context_report := 'COST';
92 	x_context_margin_mask := 'B';
93 	x_context_plan_type := 'Cost Forecast - I';
94 */
95 
96 	IF x_return_status IS NULL THEN
97 		x_msg_count := 0;
98 		x_return_status := Fnd_Api.G_RET_STS_SUCCESS;
99 	END IF;
100 
101 	 -- OLAP START
102 
103 	 select p.pjt_rollup_enabled_flag
104     into l_pjt_rollup_enabled_flag
105 	from  pa_projects_all p
106 	where  p_project_id = p.project_id ;
107 
108 
109 	 -- OLAP END
110 
111 
112 
113 
114 
115 	x_actual_version_id :=  Pji_Rep_Util.get_fin_plan_actual_version(p_project_id);
116 
117 	IF (p_cost_version_id IS NOT NULL) AND (p_cost_version_id <> -99) THEN
118 	   l_valid_version_id := p_cost_version_id;
119 	   l_context_version_type := 'COST';
120 	ELSE
121 	   l_valid_version_id := p_rev_version_id;
122 	   l_context_version_type := 'REVENUE';
123 	END IF;
124 
125 
126 	x_factor_by := Pji_Rep_Util.Derive_Factorby(
127 	p_project_id
128 	, l_valid_version_id -- bug 3793041
129 	, x_return_status
130 	, x_msg_count
131 	, x_msg_data);
132 
133 	Pji_Rep_Util.Derive_Default_RBS_Parameters(p_project_id
134 	, l_valid_version_id
135 	, x_rbs_version_id
136 	, x_rbs_element_id
137 	, x_return_status
138 	, x_msg_count
139 	, x_msg_data);
140 
141 	Pji_Rep_Util.Derive_Default_WBS_Parameters(p_project_id
142 	, l_valid_version_id
143 	, x_wbs_version_id
144 	, x_wbs_element_id
145 	, x_return_status
146 	, x_msg_count
147 	, x_msg_data);
148 
149 	Pji_Rep_Util.Derive_Default_Currency_Info(
150 	p_project_id
151 	, x_curr_record_type_id
152 	, x_currency_code
153 	, l_currency_type
154 	, x_return_status
155 	, x_msg_count
156 	, x_msg_data);
157 
158 
159 	Pji_Rep_Util.Derive_Plan_Type_Parameters(
160 	p_project_id
161 	, p_fin_plan_type_id
162 	, x_plan_pref_code
163 	, x_budget_forecast_flag
164 	, x_context_plan_type
165 	, x_context_report
166 	, x_context_margin_mask
167         , x_cost_app_flag
168         , x_rev_app_flag
169 	, x_return_status
170 	, x_msg_count
171 	, x_msg_data);
172 
173 	--Bug 5469672 Derive the default FBS expansion level
174 	x_fbs_expansion_lvl := pji_rep_util.GET_DEFAULT_EXPANSION_LEVEL(p_project_id, 'FT');
175 
176 	IF x_plan_pref_code = 'COST_AND_REV_SAME' THEN
177 	   l_version_type := 'ALL';
178 	ELSE
179 	   l_version_type := 'COST';
180 	END IF;
181 
182 	IF (p_cost_version_id IS NOT NULL) AND (p_cost_version_id <>-99) THEN
183 		Pji_Rep_Util.Derive_Version_Parameters(
184 		p_cost_version_id
185 		, x_cost_version_name
186 		, x_cost_version_no
187 		, x_cost_record_no
188 		, x_cost_budget_status
189 		, x_return_status
190 		, x_msg_count
191 		, x_msg_data);
192 
193 		Pji_Rep_Util.Derive_Fin_Plan_Versions(p_project_id
194 		,p_cost_version_id
195 		, x_curr_budget_cost_version_id
196 		, x_orig_budget_cost_version_id
197 		, x_prior_fcst_cost_version_id
198 		, x_return_status
199 		, x_msg_count
200 		, x_msg_data);
201 
202 		IF ((x_plan_pref_code = 'COST_AND_REV_SEP') AND ((p_rev_version_id IS NULL) OR (p_rev_version_id =-99))) THEN
203 
204 		   IF (x_cost_budget_status <> 'B') THEN
205 	         Pa_Fin_Plan_Utils.Get_Curr_Working_Version_Info(
206 	         p_project_id           => p_project_id,
207 	         p_fin_plan_type_id     => p_fin_plan_type_id,
208 	         p_version_type         => 'REVENUE',
209 	         x_fp_options_id        => l_fp_options_id,
210 	         x_fin_plan_version_id  => p_rev_version_id,
211 	         x_return_status        => x_return_status,
212 	         x_msg_count            => x_msg_count,
213 	         x_msg_data             => x_msg_data);
214 		   ELSE
215 	         Pa_Fin_Plan_Utils.Get_Baselined_Version_Info(
216 	         p_project_id           => p_project_id,
217 	         p_fin_plan_type_id     => p_fin_plan_type_id,
218 	         p_version_type         => 'REVENUE',
219 	         x_fp_options_id        => l_fp_options_id,
220 	         x_fin_plan_version_id  => p_rev_version_id,
221 	         x_return_status        => x_return_status,
222 	         x_msg_count            => x_msg_count,
223 	         x_msg_data             => x_msg_data);
224 		   END IF;
225 		END IF;
226 
227 	END IF;
228 
229 	IF (p_rev_version_id IS NOT NULL) AND (p_rev_version_id <> -99) THEN
230 
231 		Pji_Rep_Util.Derive_Version_Parameters(
232 		p_rev_version_id
233 		, x_rev_version_name
234 		, x_rev_version_no
235 		, x_rev_record_no
236 		, x_rev_budget_status
237 		, x_return_status
238 		, x_msg_count
239 		, x_msg_data);
240 
241 		Pji_Rep_Util.Derive_Fin_Plan_Versions(p_project_id
242 		,p_rev_version_id
243 		, x_curr_budget_rev_version_id
244 		, x_orig_budget_rev_version_id
245 		, x_prior_fcst_rev_version_id
246 		, x_return_status
247 		, x_msg_count
248 		, x_msg_data);
249 
250 		IF ((x_plan_pref_code = 'COST_AND_REV_SEP') AND ((p_cost_version_id IS NULL) OR (p_cost_version_id =-99))) THEN
251 
252 		   IF (x_rev_budget_status <> 'B') THEN
253 	         Pa_Fin_Plan_Utils.Get_Curr_Working_Version_Info(
254 	         p_project_id           => p_project_id,
255 	         p_fin_plan_type_id     => p_fin_plan_type_id,
256 	         p_version_type         => l_version_type,
257 	         x_fp_options_id        => l_fp_options_id,
258 	         x_fin_plan_version_id  => p_cost_version_id,
259 	         x_return_status        => x_return_status,
260 	         x_msg_count            => x_msg_count,
261 	         x_msg_data             => x_msg_data);
262 		   ELSE
263 	         Pa_Fin_Plan_Utils.Get_Baselined_Version_Info(
264 	         p_project_id           => p_project_id,
265 	         p_fin_plan_type_id     => p_fin_plan_type_id,
266 	         p_version_type         => l_version_type,
267 	         x_fp_options_id        => l_fp_options_id,
268 	         x_fin_plan_version_id  => p_cost_version_id,
269 	         x_return_status        => x_return_status,
270 	         x_msg_count            => x_msg_count,
271 	         x_msg_data             => x_msg_data);
272 		   END IF;
273 
274 			Pji_Rep_Util.Derive_Version_Parameters(
275 			p_cost_version_id
276 			, x_cost_version_name
277 			, x_cost_version_no
278 			, x_cost_record_no
279 			, x_cost_budget_status
280 			, x_return_status
281 			, x_msg_count
282 			, x_msg_data);
283 
284 			Pji_Rep_Util.Derive_Fin_Plan_Versions(p_project_id
285 			,p_cost_version_id
286 			, x_curr_budget_cost_version_id
287 			, x_orig_budget_cost_version_id
288 			, x_prior_fcst_cost_version_id
289 			, x_return_status
290 			, x_msg_count
291 			, x_msg_data);
292 		 END IF;
293 
294 	END IF;
295 
296 	/* At this point, if the plan type is cost_and_rev_sep,
297 	 * the version has already be derived.
298 	 * It is important to call Deriv_Vp_Calendar_Info after calling
299 	 * derive_cur_working_ver_info because only after deriving the plan
300 	 * versions, we can compare whether the two plan versions have the same
301 	 * time phased code. Whatever the plan version is when we enter the page
302 	 * we always use the Cost version's calendar infor if both versions are
303 	 * time phased and they are not the same.
304 	 */
305 	Pji_Rep_Util.Derive_Vp_Calendar_Info(
306 	p_project_id
307 	, p_cost_version_id
308 	, p_rev_version_id
309 	, l_context_version_type
310 	, x_calendar_id
311 	, x_calendar_type
312 	, x_time_phase_valid_flag
313 	, x_return_status
314 	, x_msg_count
315 	, x_msg_data);
316 
317 
318 	Pji_Rep_Util.Derive_Slice_Name(
319 	p_project_id
320 	, x_calendar_id
321 	, x_slice_name
322 	, x_return_status
323 	, x_msg_count
324 	, x_msg_data);
325 
326 
327 	l_plan_version_ids := SYSTEM.PA_NUM_TBL_TYPE(
328 	 p_cost_version_id
329 	, p_rev_version_id
330 	, x_actual_version_id
331 	, x_curr_budget_cost_version_id
332 	, x_prior_fcst_cost_version_id
333 	, x_orig_budget_cost_version_id
334 	, x_curr_budget_rev_version_id
335 	, x_prior_fcst_rev_version_id
336 	, x_orig_budget_rev_version_id);
337 
338 	Pji_Rep_Util.Derive_VP_Period(
339 	p_project_id
340 	, l_plan_version_ids
341 	, x_from_period
342 	, x_to_period
343 	, x_return_status
344 	, x_msg_count
345 	, x_msg_data);
346 
347 
348 	Pa_Fin_Plan_Utils.CHECK_IF_PLAN_TYPE_EDITABLE(
349 	P_PROJECT_ID
350 	,P_FIN_PLAN_TYPE_ID
351 	,l_version_type
352 	,X_COST_EDITABLE_FLAG
353 	, X_RETURN_STATUS
354 	, X_MSG_COUNT
355 	, X_MSG_DATA );
356 
357 	Pa_Fin_Plan_Utils.CHECK_IF_PLAN_TYPE_EDITABLE(
358 	P_PROJECT_ID
359 	,P_FIN_PLAN_TYPE_ID
360 	,'REVENUE'
361 	,X_REV_EDITABLE_FLAG
362 	, X_RETURN_STATUS
363 	, X_MSG_COUNT
364 	, X_MSG_DATA );
365 
366 
367 	Pji_Rep_Util.Check_Cross_Org(
368 	P_PROJECT_ID
369 	,X_CROSS_ORG_FLAG
370 	, X_RETURN_STATUS
371 	, X_MSG_COUNT
372 	, X_MSG_DATA );
373 
374 	IF x_cost_editable_flag = 'Y' THEN
375 	   x_cost_editable_flag := 'T';
376 	ELSE
377 	   x_cost_editable_flag := 'F';
378 	END IF;
379 
380 	IF x_rev_editable_flag = 'Y' THEN
381 	   x_rev_editable_flag := 'T';
382 	ELSE
383 	   x_rev_editable_flag := 'F';
384 	END IF;
385 
386 
387 
388 
389 	-- OLAP START
390 
391 	if ( l_pjt_rollup_enabled_flag = 'Y' )  then
392 
393 	x_rbs_element_id   := -1 ;
394 
398 
395 	end if;
396 
397 	-- OLAP END
399 EXCEPTION
400 	WHEN OTHERS THEN
401 	x_msg_count := 1;
402 	x_return_status := Fnd_Api.G_RET_STS_ERROR;
403 	Pji_Rep_Util.Add_Message(p_app_short_name=> 'PJI',p_msg_name=> 'PJI_REP_GENERIC_MSG',p_msg_type=>Pji_Rep_Util.G_RET_STS_ERROR,p_token1=>'PROC_NAME',p_token1_value=>'Pji_Vp_Rep_Dflt_Params.Derive_Default_Parameters');
404 	RAISE;
405 END Derive_Default_Parameters;
406 
407 END Pji_Vp_Rep_Dflt_Params;