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 2006/09/06 10:51:18 pschandr noship $ */
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 BEGIN
62 /*	x_rbs_element_id :=  3667;
63 	x_wbs_element_id := 2255;
64 	x_rbs_version_di :=714;
65 	x_wbs_version_id :=458;
66 	x_factor_by := 1;
67 	x_curr_budget_cost_version_id := 2383;
68 	x_prior_fcst_cost_version_id := 2398;
69 	x_orig_budget_cost_version_id := 2383;
70 	x_curr_budget_rev_version_id := 2392;
71 	x_prior_fcst_rev_version_id := 2399;
72 	x_orig_budget_rev_version_id := 2392;
73  	x_curr_record_type_id :=8;
74 	x_currency_code :='USD';
75 	x_calendar_type :='A';
76 	x_calendar_id :=24;
77 	x_cost_version_no :=1;
78 	x_cost_version_name := 'Cost Forecast - I Version 1';
79 	x_cost_record_no :=1;
80 	x_rev_version_no :=1;
81 	x_rev_version_name := 'Revenue Forecast - I Version 1';
82 	x_rev_record_no :=1;
83 	x_plan_pref_code := 'COST_AND_REVENUE_SEP';
84 	x_budget_forecast_flag := 'F';
85 	x_context_report := 'COST';
86 	x_context_margin_mask := 'B';
87 	x_context_plan_type := 'Cost Forecast - I';
88 */
89 
90 	IF x_return_status IS NULL THEN
91 		x_msg_count := 0;
92 		x_return_status := Fnd_Api.G_RET_STS_SUCCESS;
93 	END IF;
94 
95 
96 	x_actual_version_id :=  Pji_Rep_Util.get_fin_plan_actual_version(p_project_id);
97 
98 	IF (p_cost_version_id IS NOT NULL) AND (p_cost_version_id <> -99) THEN
99 	   l_valid_version_id := p_cost_version_id;
100 	   l_context_version_type := 'COST';
101 	ELSE
102 	   l_valid_version_id := p_rev_version_id;
103 	   l_context_version_type := 'REVENUE';
104 	END IF;
105 
106 
107 	x_factor_by := Pji_Rep_Util.Derive_Factorby(
108 	p_project_id
109 	, l_valid_version_id -- bug 3793041
110 	, x_return_status
111 	, x_msg_count
112 	, x_msg_data);
113 
114 	Pji_Rep_Util.Derive_Default_RBS_Parameters(p_project_id
115 	, l_valid_version_id
116 	, x_rbs_version_id
117 	, x_rbs_element_id
118 	, x_return_status
119 	, x_msg_count
120 	, x_msg_data);
121 
122 	Pji_Rep_Util.Derive_Default_WBS_Parameters(p_project_id
123 	, l_valid_version_id
124 	, x_wbs_version_id
125 	, x_wbs_element_id
126 	, x_return_status
127 	, x_msg_count
128 	, x_msg_data);
129 
130 	Pji_Rep_Util.Derive_Default_Currency_Info(
131 	p_project_id
132 	, x_curr_record_type_id
133 	, x_currency_code
134 	, l_currency_type
135 	, x_return_status
136 	, x_msg_count
137 	, x_msg_data);
138 
139 
140 	Pji_Rep_Util.Derive_Plan_Type_Parameters(
141 	p_project_id
142 	, p_fin_plan_type_id
143 	, x_plan_pref_code
144 	, x_budget_forecast_flag
145 	, x_context_plan_type
146 	, x_context_report
147 	, x_context_margin_mask
148         , x_cost_app_flag
149         , x_rev_app_flag
150 	, x_return_status
151 	, x_msg_count
152 	, x_msg_data);
153 
154 	--Bug 5469672 Derive the default FBS expansion level
155 	x_fbs_expansion_lvl := pji_rep_util.GET_DEFAULT_EXPANSION_LEVEL(p_project_id, 'FT');
156 
157 	IF x_plan_pref_code = 'COST_AND_REV_SAME' THEN
158 	   l_version_type := 'ALL';
159 	ELSE
160 	   l_version_type := 'COST';
161 	END IF;
162 
163 	IF (p_cost_version_id IS NOT NULL) AND (p_cost_version_id <>-99) THEN
164 		Pji_Rep_Util.Derive_Version_Parameters(
165 		p_cost_version_id
166 		, x_cost_version_name
167 		, x_cost_version_no
168 		, x_cost_record_no
169 		, x_cost_budget_status
170 		, x_return_status
171 		, x_msg_count
172 		, x_msg_data);
173 
174 		Pji_Rep_Util.Derive_Fin_Plan_Versions(p_project_id
175 		,p_cost_version_id
176 		, x_curr_budget_cost_version_id
177 		, x_orig_budget_cost_version_id
178 		, x_prior_fcst_cost_version_id
179 		, x_return_status
180 		, x_msg_count
181 		, x_msg_data);
182 
183 		IF ((x_plan_pref_code = 'COST_AND_REV_SEP') AND ((p_rev_version_id IS NULL) OR (p_rev_version_id =-99))) THEN
184 
185 		   IF (x_cost_budget_status <> 'B') THEN
186 	         Pa_Fin_Plan_Utils.Get_Curr_Working_Version_Info(
187 	         p_project_id           => p_project_id,
188 	         p_fin_plan_type_id     => p_fin_plan_type_id,
189 	         p_version_type         => 'REVENUE',
190 	         x_fp_options_id        => l_fp_options_id,
191 	         x_fin_plan_version_id  => p_rev_version_id,
192 	         x_return_status        => x_return_status,
193 	         x_msg_count            => x_msg_count,
194 	         x_msg_data             => x_msg_data);
195 		   ELSE
196 	         Pa_Fin_Plan_Utils.Get_Baselined_Version_Info(
197 	         p_project_id           => p_project_id,
198 	         p_fin_plan_type_id     => p_fin_plan_type_id,
199 	         p_version_type         => 'REVENUE',
200 	         x_fp_options_id        => l_fp_options_id,
201 	         x_fin_plan_version_id  => p_rev_version_id,
202 	         x_return_status        => x_return_status,
203 	         x_msg_count            => x_msg_count,
204 	         x_msg_data             => x_msg_data);
205 		   END IF;
206 		END IF;
207 
208 	END IF;
209 
210 	IF (p_rev_version_id IS NOT NULL) AND (p_rev_version_id <> -99) THEN
211 
212 		Pji_Rep_Util.Derive_Version_Parameters(
213 		p_rev_version_id
214 		, x_rev_version_name
215 		, x_rev_version_no
216 		, x_rev_record_no
217 		, x_rev_budget_status
218 		, x_return_status
219 		, x_msg_count
220 		, x_msg_data);
221 
222 		Pji_Rep_Util.Derive_Fin_Plan_Versions(p_project_id
223 		,p_rev_version_id
224 		, x_curr_budget_rev_version_id
225 		, x_orig_budget_rev_version_id
226 		, x_prior_fcst_rev_version_id
227 		, x_return_status
228 		, x_msg_count
229 		, x_msg_data);
230 
231 		IF ((x_plan_pref_code = 'COST_AND_REV_SEP') AND ((p_cost_version_id IS NULL) OR (p_cost_version_id =-99))) THEN
232 
233 		   IF (x_rev_budget_status <> 'B') THEN
234 	         Pa_Fin_Plan_Utils.Get_Curr_Working_Version_Info(
235 	         p_project_id           => p_project_id,
236 	         p_fin_plan_type_id     => p_fin_plan_type_id,
237 	         p_version_type         => l_version_type,
238 	         x_fp_options_id        => l_fp_options_id,
239 	         x_fin_plan_version_id  => p_cost_version_id,
240 	         x_return_status        => x_return_status,
241 	         x_msg_count            => x_msg_count,
242 	         x_msg_data             => x_msg_data);
243 		   ELSE
244 	         Pa_Fin_Plan_Utils.Get_Baselined_Version_Info(
245 	         p_project_id           => p_project_id,
246 	         p_fin_plan_type_id     => p_fin_plan_type_id,
247 	         p_version_type         => l_version_type,
248 	         x_fp_options_id        => l_fp_options_id,
249 	         x_fin_plan_version_id  => p_cost_version_id,
250 	         x_return_status        => x_return_status,
251 	         x_msg_count            => x_msg_count,
252 	         x_msg_data             => x_msg_data);
253 		   END IF;
254 
255 			Pji_Rep_Util.Derive_Version_Parameters(
256 			p_cost_version_id
257 			, x_cost_version_name
258 			, x_cost_version_no
259 			, x_cost_record_no
260 			, x_cost_budget_status
261 			, x_return_status
262 			, x_msg_count
263 			, x_msg_data);
264 
265 			Pji_Rep_Util.Derive_Fin_Plan_Versions(p_project_id
266 			,p_cost_version_id
267 			, x_curr_budget_cost_version_id
268 			, x_orig_budget_cost_version_id
269 			, x_prior_fcst_cost_version_id
270 			, x_return_status
271 			, x_msg_count
272 			, x_msg_data);
273 		 END IF;
274 
275 	END IF;
276 
277 	/* At this point, if the plan type is cost_and_rev_sep,
278 	 * the version has already be derived.
279 	 * It is important to call Deriv_Vp_Calendar_Info after calling
280 	 * derive_cur_working_ver_info because only after deriving the plan
281 	 * versions, we can compare whether the two plan versions have the same
282 	 * time phased code. Whatever the plan version is when we enter the page
283 	 * we always use the Cost version's calendar infor if both versions are
284 	 * time phased and they are not the same.
285 	 */
286 	Pji_Rep_Util.Derive_Vp_Calendar_Info(
287 	p_project_id
288 	, p_cost_version_id
289 	, p_rev_version_id
290 	, l_context_version_type
291 	, x_calendar_id
292 	, x_calendar_type
293 	, x_time_phase_valid_flag
294 	, x_return_status
295 	, x_msg_count
296 	, x_msg_data);
297 
298 
299 	Pji_Rep_Util.Derive_Slice_Name(
300 	p_project_id
301 	, x_calendar_id
302 	, x_slice_name
303 	, x_return_status
304 	, x_msg_count
305 	, x_msg_data);
306 
307 
308 	l_plan_version_ids := SYSTEM.PA_NUM_TBL_TYPE(
309 	 p_cost_version_id
310 	, p_rev_version_id
311 	, x_actual_version_id
312 	, x_curr_budget_cost_version_id
313 	, x_prior_fcst_cost_version_id
314 	, x_orig_budget_cost_version_id
315 	, x_curr_budget_rev_version_id
316 	, x_prior_fcst_rev_version_id
317 	, x_orig_budget_rev_version_id);
318 
319 	Pji_Rep_Util.Derive_VP_Period(
320 	p_project_id
321 	, l_plan_version_ids
322 	, x_from_period
323 	, x_to_period
324 	, x_return_status
325 	, x_msg_count
326 	, x_msg_data);
327 
328 
329 	Pa_Fin_Plan_Utils.CHECK_IF_PLAN_TYPE_EDITABLE(
330 	P_PROJECT_ID
331 	,P_FIN_PLAN_TYPE_ID
332 	,l_version_type
333 	,X_COST_EDITABLE_FLAG
334 	, X_RETURN_STATUS
335 	, X_MSG_COUNT
336 	, X_MSG_DATA );
337 
338 	Pa_Fin_Plan_Utils.CHECK_IF_PLAN_TYPE_EDITABLE(
339 	P_PROJECT_ID
340 	,P_FIN_PLAN_TYPE_ID
341 	,'REVENUE'
342 	,X_REV_EDITABLE_FLAG
343 	, X_RETURN_STATUS
344 	, X_MSG_COUNT
345 	, X_MSG_DATA );
346 
347 
348 	Pji_Rep_Util.Check_Cross_Org(
349 	P_PROJECT_ID
350 	,X_CROSS_ORG_FLAG
351 	, X_RETURN_STATUS
352 	, X_MSG_COUNT
353 	, X_MSG_DATA );
354 
355 	IF x_cost_editable_flag = 'Y' THEN
356 	   x_cost_editable_flag := 'T';
357 	ELSE
358 	   x_cost_editable_flag := 'F';
359 	END IF;
360 
361 	IF x_rev_editable_flag = 'Y' THEN
362 	   x_rev_editable_flag := 'T';
363 	ELSE
364 	   x_rev_editable_flag := 'F';
365 	END IF;
366 
367 EXCEPTION
368 	WHEN OTHERS THEN
369 	x_msg_count := 1;
370 	x_return_status := Fnd_Api.G_RET_STS_ERROR;
371 	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');
372 	RAISE;
373 END Derive_Default_Parameters;
374 
375 END Pji_Vp_Rep_Dflt_Params;