528: --
529: -- soft pegged item can also pick from common inventory
530: --
531: IF p_task_id IS NULL THEN
532: l_identifier := inv_sql_binding_pvt.initbindvar(p_project_id);
533: x_where_clause :=' AND '||
534: ' ((base.locator_id IS NOT NULL) AND (EXISTS ( ' || g_line_feed ||
535: ' SELECT inventory_location_id ' || g_line_feed ||
536: ' FROM mtl_item_locations ' || g_line_feed ||
541: ' AND task_id IS NULL))) ';
542: ELSE
543: -- referencing project and task, pick only from those locators or common inventory
544: --
545: l_identifier := inv_sql_binding_pvt.initbindvar(p_project_id);
546: l_id2 := inv_sql_binding_pvt.initbindvar(p_task_id);
547: x_where_clause :=' AND '||
548: ' ((base.locator_id IS NOT NULL) AND (EXISTS ( '|| g_line_feed ||
549: ' SELECT inventory_location_id ' || g_line_feed ||
542: ELSE
543: -- referencing project and task, pick only from those locators or common inventory
544: --
545: l_identifier := inv_sql_binding_pvt.initbindvar(p_project_id);
546: l_id2 := inv_sql_binding_pvt.initbindvar(p_task_id);
547: x_where_clause :=' AND '||
548: ' ((base.locator_id IS NOT NULL) AND (EXISTS ( '|| g_line_feed ||
549: ' SELECT inventory_location_id ' || g_line_feed ||
550: ' FROM mtl_item_locations ' || g_line_feed ||
563: --
564: -- no task referenced, pick from inventory corresponding to this
565: -- project only
566: --
567: l_identifier := inv_sql_binding_pvt.initbindvar(p_project_id);
568: x_where_clause :=' AND '||
569: ' ((base.locator_id IS NOT NULL) AND (EXISTS ( ' || g_line_feed ||
570: ' SELECT inventory_location_id ' || g_line_feed ||
571: ' FROM mtl_item_locations ' || g_line_feed ||
577: --
578: ELSE
579: -- referencing project and task, pick only from those locators
580: --
581: l_identifier := inv_sql_binding_pvt.initbindvar(p_project_id);
582: l_id2 := inv_sql_binding_pvt.initbindvar(p_task_id);
583: x_where_clause :=' AND '||
584: ' ((base.locator_id IS NOT NULL) AND (EXISTS ( '|| g_line_feed ||
585: ' SELECT inventory_location_id ' || g_line_feed ||
578: ELSE
579: -- referencing project and task, pick only from those locators
580: --
581: l_identifier := inv_sql_binding_pvt.initbindvar(p_project_id);
582: l_id2 := inv_sql_binding_pvt.initbindvar(p_task_id);
583: x_where_clause :=' AND '||
584: ' ((base.locator_id IS NOT NULL) AND (EXISTS ( '|| g_line_feed ||
585: ' SELECT inventory_location_id ' || g_line_feed ||
586: ' FROM mtl_item_locations ' || g_line_feed ||
688: l_loc_where := ' ';
689: l_cg_where := ' ';
690: l_stat_where:= ' ';
691: l_from := ' ';
692: inv_sql_binding_pvt.initbindtables;
693: --
694: IF p_rule_id IS NOT NULL THEN
695: OPEN l_rule_csr;
696: FETCH l_rule_csr INTO l_rev_rule, l_lot_rule, l_sub_rule, l_loc_rule;
745: --
746: -- replace some hardcoded bind variables
747: -- Bug 1384720 - performance improvements
748: -- the demand source info no longer in qty tree
749: l_identifier := inv_sql_binding_pvt.initbindvar
750: (p_request_line_rec.organization_id);
751: g_stmt := REPLACE(g_stmt,':organization_id', l_identifier);
752: --
753: l_identifier := inv_sql_binding_pvt.initbindvar
749: l_identifier := inv_sql_binding_pvt.initbindvar
750: (p_request_line_rec.organization_id);
751: g_stmt := REPLACE(g_stmt,':organization_id', l_identifier);
752: --
753: l_identifier := inv_sql_binding_pvt.initbindvar
754: (p_request_line_rec.inventory_item_id);
755: g_stmt := REPLACE(g_stmt,':inventory_item_id', l_identifier);
756: --
757: --demand source line id is in sql only if pjm is enabled
759: /*IF g_unit_eff_enabled IS NULL THEN
760: g_unit_eff_enabled := pjm_unit_eff.enabled;
761: END IF;
762: IF g_unit_eff_enabled = 'Y' THEN
763: l_identifier := Inv_sql_binding_pvt.initbindvar
764: (p_request_context.txn_line_id);
765: g_stmt := REPLACE(g_stmt,':demand_source_line_id', l_identifier);
766: END IF;
767: --
766: END IF;
767: --
768: */
769: /*
770: l_identifier := inv_sql_binding_pvt.initbindvar
771: (p_request_context.transaction_source_type_id);
772: g_stmt := REPLACE(g_stmt,':demand_source_type_id', l_identifier);
773: --
774: l_identifier := inv_sql_binding_pvt.initbindvar
770: l_identifier := inv_sql_binding_pvt.initbindvar
771: (p_request_context.transaction_source_type_id);
772: g_stmt := REPLACE(g_stmt,':demand_source_type_id', l_identifier);
773: --
774: l_identifier := inv_sql_binding_pvt.initbindvar
775: (p_request_context.txn_header_id);
776: g_stmt := REPLACE(g_stmt,':demand_source_header_id',l_identifier);
777: --
778: l_identifier := Inv_sql_binding_pvt.initbindvar
774: l_identifier := inv_sql_binding_pvt.initbindvar
775: (p_request_context.txn_header_id);
776: g_stmt := REPLACE(g_stmt,':demand_source_header_id',l_identifier);
777: --
778: l_identifier := Inv_sql_binding_pvt.initbindvar
779: (p_request_context.txn_line_detail);
780: g_stmt := REPLACE(g_stmt,':demand_source_delivery', l_identifier);
781: --
782: g_stmt := REPLACE(g_stmt,':demand_source_name', 'NULL');
784: */
785: IF p_request_context.item_revision_control = 2 THEN
786: -- if revision is passed, include it
787: IF p_pp_temp_rec.revision IS NOT NULL THEN
788: l_identifier := inv_sql_binding_pvt.initbindvar
789: (p_pp_temp_rec.revision);
790: l_rev_where := g_line_feed
791: || ' AND base.revision = '||l_identifier;
792: END IF;
793: END IF;
794: --
795: IF p_request_context.item_lot_control_code = 2 THEN
796: IF p_pp_temp_rec.lot_number IS NOT NULL THEN
797: l_identifier := inv_sql_binding_pvt.initbindvar
798: (p_pp_temp_rec.lot_number);
799: l_lot_where := l_lot_where
800: || g_line_feed || ' AND base.lot_number = '||l_identifier;
801: END IF;
800: || g_line_feed || ' AND base.lot_number = '||l_identifier;
801: END IF;
802: IF p_pp_temp_rec.lot_expiration_date IS NOT NULL THEN
803: l_identifier :=
804: inv_sql_binding_pvt.initbindvar
805: (p_pp_temp_rec.lot_expiration_date);
806: l_lot_where := l_lot_where || g_line_feed
807: || ' AND (base.lot_expiration_date >= '
808: ||l_identifier
811: END IF;
812: --
813: IF p_pp_temp_rec.from_subinventory_code IS NOT NULL THEN
814: l_identifier :=
815: inv_sql_binding_pvt.initbindvar
816: (p_pp_temp_rec.from_subinventory_code);
817: l_sub_where := g_line_feed || ' AND base.subinventory_code = '
818: ||l_identifier;
819: ELSE
825: ' AND NVL(base.reservable_type,2) = 1';
826: end if;
827: END IF;
828: IF p_pp_temp_rec.from_locator_id IS NOT NULL THEN
829: l_identifier := inv_sql_binding_pvt.initbindvar
830: (p_pp_temp_rec.from_locator_id);
831: l_loc_where := g_line_feed ||' AND base.locator_id = '||l_identifier;
832: END IF;
833: --
831: l_loc_where := g_line_feed ||' AND base.locator_id = '||l_identifier;
832: END IF;
833: --
834: IF p_pp_temp_rec.from_cost_group_id IS NOT NULL THEN
835: l_identifier := inv_sql_binding_pvt.initbindvar
836: (p_pp_temp_rec.from_cost_group_id);
837: l_cg_where := g_line_feed ||' AND base.cost_group_id = '||l_identifier;
838: END IF;
839: --
1026: || l_group_by */
1027: || l_tmp3 || l_order_by;
1028: --
1029: g_stmt := l_temp1 || l_temp2;
1030: -- inv_sql_binding_pvt.showsql('>>'||l_temp1);
1031: -- inv_sql_binding_pvt.showsql('>>'||l_temp2);
1032: -- inv_sql_binding_pvt.showsql(g_stmt);
1033: --inv_pp_debug.send_long_to_pipe(g_stmt);
1034: --
1027: || l_tmp3 || l_order_by;
1028: --
1029: g_stmt := l_temp1 || l_temp2;
1030: -- inv_sql_binding_pvt.showsql('>>'||l_temp1);
1031: -- inv_sql_binding_pvt.showsql('>>'||l_temp2);
1032: -- inv_sql_binding_pvt.showsql(g_stmt);
1033: --inv_pp_debug.send_long_to_pipe(g_stmt);
1034: --
1035: x_return_status := l_return_status;
1028: --
1029: g_stmt := l_temp1 || l_temp2;
1030: -- inv_sql_binding_pvt.showsql('>>'||l_temp1);
1031: -- inv_sql_binding_pvt.showsql('>>'||l_temp2);
1032: -- inv_sql_binding_pvt.showsql(g_stmt);
1033: --inv_pp_debug.send_long_to_pipe(g_stmt);
1034: --
1035: x_return_status := l_return_status;
1036: EXCEPTION
1253:
1254: BEGIN
1255: x_return_status := fnd_api.g_ret_sts_success ;
1256: --
1257: --inv_sql_binding_pvt.showsql(g_stmt);
1258: l_cursor := dbms_sql.open_cursor ;
1259: dbms_sql.parse(l_cursor, g_stmt, dbms_sql.v7);
1260: -- bind input variables
1261: inv_sql_binding_pvt.bindvars(l_cursor);
1257: --inv_sql_binding_pvt.showsql(g_stmt);
1258: l_cursor := dbms_sql.open_cursor ;
1259: dbms_sql.parse(l_cursor, g_stmt, dbms_sql.v7);
1260: -- bind input variables
1261: inv_sql_binding_pvt.bindvars(l_cursor);
1262: -- now define the output variables
1263: dbms_sql.define_column(l_cursor, 1, l_revision, 3);
1264: dbms_sql.define_column(l_cursor, 2, l_lot_number, 30);
1265: dbms_sql.define_column(l_cursor, 3, l_lot_expiration_date);