138:
139: v_err_code NUMBER := 0;
140: v_err_stage VARCHAR2(2000);
141:
142: PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N');
143:
144: no_assignments_exist EXCEPTION;
145: unexp_error_in_client_extn EXCEPTION;
146: error_in_client_extn EXCEPTION;
188: p_asset_allocation_method <> 'CE' AND --Do not use cache when the Client Extension is used to determine basis
189: p_line_type = G_line_type THEN
190:
191: IF PG_DEBUG = 'Y' THEN
192: PA_DEBUG.DEBUG('Using cached Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id);
193: END IF;
194:
195: asset_basis_table := G_asset_basis_table;
196: GOTO allocate_line;
198:
199:
200: --Construct the asset basis table
201: IF PG_DEBUG = 'Y' THEN
202: PA_DEBUG.DEBUG('Constructing the Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id);
203: END IF;
204:
205:
206: --Determine if entire project has a 'Common' Asset Assignment
214:
215: IF p_task_id <> 0 THEN
216:
217: IF PG_DEBUG = 'Y' THEN
218: PA_DEBUG.DEBUG('Get top and parent task ids for task id '||p_task_id);
219: END IF;
220:
221: --Get the Top Task ID
222: SELECT top_task_id,
227: WHERE task_id = p_task_id;
228:
229:
230: IF PG_DEBUG = 'Y' THEN
231: PA_DEBUG.DEBUG('Count top task common assignments');
232: END IF;
233:
234: --Determine if top task has a 'Common' Asset Assignment
235: --('Common' Asset Assignments at the Top Task level are allocated across
263: IF v_common_lowest_task = 'Y' THEN
264:
265: --Common Lowest Task Assignment
266: IF PG_DEBUG = 'Y' THEN
267: PA_DEBUG.DEBUG('Lowest Task Common Assignment exists for Project Asset Line ID '||p_project_asset_line_id);
268: END IF;
269:
270: FOR wbs_branch_tasks_rec IN wbs_branch_tasks_cur(v_parent_task_id) LOOP
271:
269:
270: FOR wbs_branch_tasks_rec IN wbs_branch_tasks_cur(v_parent_task_id) LOOP
271:
272: IF PG_DEBUG = 'Y' THEN
273: PA_DEBUG.DEBUG('Task Number '||wbs_branch_tasks_rec.task_number||' exists beneath Parent Task ID '||v_parent_task_id);
274: END IF;
275:
276: --Populate table with all assets in the event assigned to the task
277: OPEN task_asgn_assets_cur(wbs_branch_tasks_rec.task_id, p_line_type);
295: IF (v_common_task = 'Y') OR (v_common_project = 'Y') THEN
296:
297: --Common Assignment
298: IF PG_DEBUG = 'Y' THEN
299: PA_DEBUG.DEBUG('Project or Top Task Common Assignment exists for Project Asset Line ID '||p_project_asset_line_id);
300: END IF;
301:
302: OPEN all_project_assets_cur(p_line_type);
303: LOOP
310: ELSE --Determine the Grouping Level for the current asset line
311:
312:
313: IF PG_DEBUG = 'Y' THEN
314: PA_DEBUG.DEBUG('Count project level asset assignments');
315: END IF;
316:
317: --Check for a project level grouping method
318: SELECT COUNT(*)
325: IF v_assignment_count > 0 THEN
326:
327: --Project Assignment
328: IF PG_DEBUG = 'Y' THEN
329: PA_DEBUG.DEBUG('Project Assignment(s) exist for Project Asset Line ID '||p_project_asset_line_id);
330: END IF;
331:
332:
333: --Populate table with all assets in the event assigned to the project
341:
342: ELSIF p_task_id <> 0 THEN --Check for task level assignments
343:
344: IF PG_DEBUG = 'Y' THEN
345: PA_DEBUG.DEBUG('Count task level asset assignments for task id '||p_task_id);
346: END IF;
347:
348: --Check for a task level grouping method
349: SELECT COUNT(*)
355: IF v_assignment_count > 0 THEN
356:
357: --Task Assignment
358: IF PG_DEBUG = 'Y' THEN
359: PA_DEBUG.DEBUG('Task Assignment(s) exist for Project Asset Line ID '||p_project_asset_line_id);
360: END IF;
361:
362:
363: --Populate table with all assets in the event assigned to the task
371:
372: ELSE --Check for a top task level grouping method
373:
374: IF PG_DEBUG = 'Y' THEN
375: PA_DEBUG.DEBUG('Count top task level asset assignments for top task id '||v_top_task_id);
376: END IF;
377:
378: SELECT COUNT(*)
379: INTO v_assignment_count
384: IF v_assignment_count > 0 THEN
385:
386: --Top Task Assignment
387: IF PG_DEBUG = 'Y' THEN
388: PA_DEBUG.DEBUG('Top Task Assignment(s) exist for Project Asset Line ID '||p_project_asset_line_id);
389: END IF;
390:
391:
392: --Populate table with all assets in the event assigned to the top task
432:
433:
434:
435: IF PG_DEBUG = 'Y' THEN
436: PA_DEBUG.DEBUG('Initial Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id||' Line Type '||p_line_type);
437: PA_DEBUG.DEBUG('Project Asset ID - Asset Basis - Total Basis');
438: END IF;
439:
440: i := asset_basis_table.FIRST;
433:
434:
435: IF PG_DEBUG = 'Y' THEN
436: PA_DEBUG.DEBUG('Initial Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id||' Line Type '||p_line_type);
437: PA_DEBUG.DEBUG('Project Asset ID - Asset Basis - Total Basis');
438: END IF;
439:
440: i := asset_basis_table.FIRST;
441:
445: v_asset_basis_amount := asset_basis_table(i).ASSET_BASIS_AMOUNT;
446: v_total_basis_amount := asset_basis_table(i).TOTAL_BASIS_AMOUNT;
447:
448: IF PG_DEBUG = 'Y' THEN
449: PA_DEBUG.DEBUG(v_project_asset_id||' - '||v_asset_basis_amount||' - '||v_total_basis_amount);
450: END IF;
451:
452:
453: i := asset_basis_table.NEXT(i);
541:
542: i := asset_basis_table.FIRST;
543:
544: IF PG_DEBUG = 'Y' THEN
545: PA_DEBUG.DEBUG('Only one asset in basis table, assigning Project Asset Line ID '||p_project_asset_line_id
546: ||' to Project Asset ID '||asset_basis_table(i).PROJECT_ASSET_ID);
547: END IF;
548:
549:
787:
788: --DBMS_OUTPUT.PUT_LINE('Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id);
789: --DBMS_OUTPUT.PUT_LINE('Project Asset ID - Asset Basis - Total Basis');
790: IF PG_DEBUG = 'Y' THEN
791: PA_DEBUG.DEBUG('Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id);
792: PA_DEBUG.DEBUG('Project Asset ID - Asset Basis - Total Basis');
793: END IF;
794:
795: i := asset_basis_table.FIRST;
788: --DBMS_OUTPUT.PUT_LINE('Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id);
789: --DBMS_OUTPUT.PUT_LINE('Project Asset ID - Asset Basis - Total Basis');
790: IF PG_DEBUG = 'Y' THEN
791: PA_DEBUG.DEBUG('Asset Allocation basis table for Project Asset Line ID '||p_project_asset_line_id);
792: PA_DEBUG.DEBUG('Project Asset ID - Asset Basis - Total Basis');
793: END IF;
794:
795: i := asset_basis_table.FIRST;
796:
802: v_sum_asset_basis_amount := v_sum_asset_basis_amount + v_asset_basis_amount;
803:
804: --DBMS_OUTPUT.PUT_LINE(v_project_asset_id||' - '||v_asset_basis_amount||' - '||v_total_basis_amount);
805: IF PG_DEBUG = 'Y' THEN
806: PA_DEBUG.DEBUG(v_project_asset_id||' - '||v_asset_basis_amount||' - '||v_total_basis_amount);
807: END IF;
808:
809: --Verify that each Asset Basis Amount is NOT NULL and >=0
810: IF v_asset_basis_amount IS NULL THEN
868: v_remaining_cost:= 0;
869:
870:
871: IF PG_DEBUG = 'Y' THEN
872: PA_DEBUG.DEBUG('Allocating project asset line '|| v_project_asset_line_id);
873: END IF;
874:
875: --Allocate the current asset line and assign to each project asset
876: i := asset_basis_table.FIRST;