1501: CURSOR csi_pm_instance_csr IS
1502: SELECT min(instance_id), max(instance_id)
1503: FROM csi_item_instances csi,
1504: (select me.inventory_item_id
1505: from ahl_mr_effectivities me, ahl_mr_headers_app_v mr
1506: where mr.mr_header_id = me.mr_header_id
1507: and mr.type_code = 'PROGRAM') mre
1508: WHERE trunc(nvl(active_start_date, sysdate)) <= trunc(sysdate) AND
1509: trunc(sysdate) < trunc(nvl(active_end_date, sysdate+1))
7729: curr_mr.mr_header_id preceding_mr_header_id,
7730: apmr.descendent_count,
7731: mr.whichever_first_code,
7732: apmr.repetitive_flag
7733: FROM ahl_mr_headers_app_v mr, ahl_mr_headers_b curr_mr, ahl_applicable_mrs apmr
7734: --fix for bug number 5922149
7735: --WHERE mr.preceding_mr_header_id = curr_mr.mr_header_id AND
7736: WHERE mr.preceding_mr_header_id IN (SELECT t.mr_header_id FROM ahl_mr_headers_b t where t.title = curr_mr.title ) AND
7737: curr_mr.mr_header_id = p_mr_header_id AND
7759: apmr.repetitive_flag,
7760: mr.title,
7761: mr.effective_from,
7762: mr.effective_to
7763: FROM ahl_mr_headers_app_v mr, ahl_applicable_mrs apmr
7764: WHERE mr.preceding_mr_header_id IN (SELECT t.mr_header_id FROM ahl_mr_headers_app_v t where t.title = p_curr_mr_title ) AND
7765: apmr.mr_header_id = mr.mr_header_id AND
7766: trunc(sysdate) >= trunc(nvl(mr.effective_from, sysdate)) AND
7767: --fix for bug# 9263774. Process prior MR versions.
7760: mr.title,
7761: mr.effective_from,
7762: mr.effective_to
7763: FROM ahl_mr_headers_app_v mr, ahl_applicable_mrs apmr
7764: WHERE mr.preceding_mr_header_id IN (SELECT t.mr_header_id FROM ahl_mr_headers_app_v t where t.title = p_curr_mr_title ) AND
7765: apmr.mr_header_id = mr.mr_header_id AND
7766: trunc(sysdate) >= trunc(nvl(mr.effective_from, sysdate)) AND
7767: --fix for bug# 9263774. Process prior MR versions.
7768: --trunc(sysdate) <= trunc(nvl(mr.effective_to, sysdate+1)) AND
8362: -- get all programs which have no schedules.
8363: CURSOR ahl_cont_not_scheduled_csr IS
8364: SELECT DISTINCT appl.program_mr_header_id, mr.whichever_first_code
8365: FROM ahl_applicable_mrs appl, ahl_mr_headers_b mr
8366: -- replaced ahl_mr_headers_app_v with ahl_mr_headers_b as ahl_applicable_mrs has
8367: -- the filter of application_usg_code.
8368: WHERE appl.program_mr_header_id = mr.mr_header_id
8369: AND pm_schedule_exists = 'N';
8370:
9596:
9597: -- Get MR details.
9598: CURSOR ahl_mr_headers_csr (p_mr_header_id IN NUMBER) IS
9599: SELECT whichever_first_code
9600: FROM ahl_mr_headers_app_v
9601: WHERE mr_header_id = p_mr_header_id;
9602:
9603: -- get the configuration structure.(G_config_node_tbl).
9604: CURSOR csi_reln_csr ( p_csi_item_instance_id IN NUMBER) IS
9641: l_mr_header_id NUMBER;
9642: l_uc_header_id NUMBER;
9643: l_calc_due_date DATE;
9644: l_due_date DATE;
9645: l_whichever_first_code ahl_mr_headers_app_v.whichever_first_code%TYPE;
9646: l_inv_master_organization_id number;
9647: l_inventory_item_id number;
9648: l_position_reference VARCHAR2(30);
9649: l_counter_rules_tbl counter_rules_tbl_type;
11793: --check whether the given mr exists
11794: CURSOR check_mr_exists(c_mr_header_id number)
11795: IS
11796: SELECT mr_header_id
11797: FROM ahl_mr_headers_app_v
11798: WHERE mr_header_id = c_mr_header_id;
11799:
11800: --get all the MR effectivity definitions for a given MR
11801: CURSOR get_mr_effect(c_mr_header_id NUMBER)
12301: IS
12302: SELECT cii.instance_id
12303: FROM csi_item_instances cii, ahl_mr_effectivities mre, mtl_system_items_b msi,
12304: (select mr_header_id
12305: from ahl_mr_headers_app_v
12306: where type_code = 'PROGRAM') mr
12307: WHERE cii.inventory_item_id = msi.inventory_item_id
12308: AND cii.inv_master_organization_id = msi.organization_id
12309: AND cii.inventory_item_id = mre.inventory_item_id
12876: -- added nvl conditions above as this seems to force use of index on
12877: -- ahl_mr_headers_b and also brings query cost down.
12878: AND mre.relationship_id is null
12879: AND mre.inventory_item_id = cii.inventory_item_id
12880: AND exists (SELECT 'x' from ahl_mr_headers_app_v MR
12881: WHERE MR.mr_header_id = mre.mr_header_id
12882: AND MR.program_type_code NOT IN ('MO_PROC')
12883: AND MR.version_number in (SELECT max(MRM.version_number)
12884: FROM ahl_mr_headers_app_v MRM
12880: AND exists (SELECT 'x' from ahl_mr_headers_app_v MR
12881: WHERE MR.mr_header_id = mre.mr_header_id
12882: AND MR.program_type_code NOT IN ('MO_PROC')
12883: AND MR.version_number in (SELECT max(MRM.version_number)
12884: FROM ahl_mr_headers_app_v MRM
12885: WHERE mrm.title = mr.title
12886: AND SYSDATE between trunc(MR.effective_from)
12887: AND trunc(nvl(MR.effective_to,SYSDATE+1))
12888: AND mr_status_code='COMPLETE'
12948: ) Root_instance_id
12949:
12950: FROM csi_item_instances cii,
12951: (select distinct me.inventory_item_id
12952: from ahl_mr_headers_app_v mr, ahl_mr_effectivities me
12953: where mr.mr_header_id = me.mr_header_id AND
12954: mr.mr_status_code = 'COMPLETE' AND
12955: MR.program_type_code NOT IN ('MO_PROC') AND -- added in R12
12956: trunc(effective_from) <= trunc(sysdate) AND
13012: CURSOR chk_expire_inst_csr IS
13013: SELECT cii.instance_id
13014: FROM csi_item_instances cii,
13015: (select distinct me.inventory_item_id
13016: from ahl_mr_headers_app_v mr, ahl_mr_effectivities me
13017: where mr.mr_header_id = me.mr_header_id AND
13018: mr.mr_status_code = 'COMPLETE' AND
13019: MR.program_type_code NOT IN ('MO_PROC') AND -- added in R12
13020: trunc(effective_from) <= trunc(sysdate) AND
16232:
16233: -- Get MR details.
16234: CURSOR ahl_mr_headers_csr (p_mr_header_id IN NUMBER) IS
16235: SELECT whichever_first_code
16236: FROM ahl_mr_headers_app_v
16237: WHERE mr_header_id = p_mr_header_id;
16238:
16239: -- get the configuration structure.(G_config_node_tbl).
16240: CURSOR csi_reln_csr ( p_csi_item_instance_id IN NUMBER) IS