DBA Data[Home] [Help]

APPS.MRP_REPORT_INV_TURNS SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 39

    select_on_hand                  EXCEPTION;
Line: 40

    select_wip                      EXCEPTION;
Line: 41

    update_beginning_inv            EXCEPTION;
Line: 42

    update_open_purchase_orders     EXCEPTION;
Line: 43

    update_open_purchase_reqs       EXCEPTION;
Line: 44

    update_mrp_purchase_orders      EXCEPTION;
Line: 45

    update_open_discrete_jobs       EXCEPTION;
Line: 46

    update_mrp_repetitive_scheds    EXCEPTION;
Line: 47

    update_mrp_discrete_jobs        EXCEPTION;
Line: 48

    update_master_sched_discrete    EXCEPTION;
Line: 49

    update_master_sched_repetitive  EXCEPTION;
Line: 50

    select_past_due_mds		    EXCEPTION;
Line: 51

    update_past_due_mds             EXCEPTION;
Line: 52

    select_inventory_values         EXCEPTION;
Line: 53

    update_inventory_values         EXCEPTION;
Line: 59

        SELECT   rowid,
                 date1,
                 date2,
                 number1,
                 number2,
                 number3,
                 number4,
                 number5,
                 number6,
                 number7,
                 number8
        FROM     mrp_form_query
        WHERE    query_id = arg_query_id
        ORDER BY date1;
Line: 75

    |  Select calendar defaults |
    +--------------------------*/
    mrp_calendar.select_calendar_defaults(
        arg_org_id,
        arg_calendar_code,
        arg_exception_set_id);
Line: 86

    update mrp_form_query
    set    char1 = arg_compile_desig,
           char2 = arg_sched_desig,
     	   number12 = arg_org_id
    where  query_id = arg_query_id;
Line: 95

    /*SELECT   NVL(SUM((sys.nettable_inventory_quantity
                    + sys.nonnettable_inventory_quantity)
                      * NVL(cst.item_cost, 0)), 0)
             / 1000*//*2417274*/
 SELECT   NVL(SUM((sys.nettable_inventory_quantity)
                      * NVL(cst.item_cost, 0)), 0)
             / 1000
    INTO     begin_inv
    FROM     cst_item_costs    cst,
             mrp_system_items  sys
    WHERE    cst.organization_id    = sys.organization_id
    AND      cst.inventory_item_id  = sys.inventory_item_id
    AND (  cst.cost_type_id      = arg_cost_type
            OR
           (
               (cst.cost_type_id    = arg_def_cost_type)
              AND
               (NOT EXISTS
                 (SELECT 'Primary Cost Type Row'
                  FROM cst_item_costs cst1
                   WHERE cst1.inventory_item_id = cst.inventory_item_id
                  AND   cst1.organization_id   = arg_org_id
                  AND   cst1.cost_type_id      = arg_cost_type)
                )
             )
         )
    AND      sys.compile_designator = arg_compile_desig
    AND      sys.organization_id    = arg_org_id;
Line: 125

        RAISE select_on_hand;
Line: 130

    SELECT   NVL(SUM(NVL(wip.net_quantity, 0)
                   * NVL(cst.item_cost, 0)), 0)
             / 1000
    INTO     issued_inv
    FROM     cst_item_costs      cst,
             mrp_wip_components  wip
    WHERE    cst.organization_id    = wip.organization_id
    AND      cst.inventory_item_id  = wip.inventory_item_id
    AND (  cst.cost_type_id      = arg_cost_type
            OR
           (
               (cst.cost_type_id    = arg_def_cost_type)
              AND
               (NOT EXISTS
                 (SELECT 'Primary Cost Type Row'
                  FROM cst_item_costs cst1
                   WHERE cst1.inventory_item_id = cst.inventory_item_id
                  AND   cst1.organization_id   = arg_org_id
                  AND   cst1.cost_type_id      = arg_cost_type)
                )
             )
         )
    AND      wip.compile_designator = arg_compile_desig
    AND      wip.organization_id    = arg_org_id
    AND      wip.wip_entity_type   IN (1, 3)
    AND      DECODE(wip.wip_entity_type,
              1, 1, wip.supply_demand_type) =
             DECODE(wip.wip_entity_type, 1, 1, 1);
Line: 160

        RAISE select_wip;
Line: 165

    UPDATE mrp_form_query
    SET    number1 = begin_inv + issued_inv
    WHERE  query_id = arg_query_id
    AND    date2 IS NOT NULL;
Line: 171

        RAISE update_beginning_inv;
Line: 176

    UPDATE  mrp_form_query  query
    SET     number2 =
            (SELECT   NVL(SUM(rec.new_order_quantity
                        * NVL(cst.item_cost, 0)), 0)
                      / 1000
            FROM     cst_item_costs       cst,
                     mrp_recommendations  rec
            WHERE    cst.organization_id          = rec.organization_id
            AND      cst.inventory_item_id        = rec.inventory_item_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      rec.new_schedule_date       >= query.date1
            AND      rec.new_schedule_date        < query.date2
            AND      rec.disposition_status_type  = 1
            AND      rec.order_type              IN (1, 8)
            AND      rec.compile_designator       = arg_compile_desig
            AND      rec.organization_id          = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 208

        RAISE update_open_purchase_orders;
Line: 213

    UPDATE  mrp_form_query  query
    SET     number3 =
            (SELECT   NVL(SUM(rec.new_order_quantity
                        * NVL(cst.item_cost,0)), 0)
                      / 1000
            FROM     cst_item_costs       cst,
                     mrp_recommendations  rec
            WHERE    cst.organization_id         = rec.organization_id
            AND      cst.inventory_item_id       = rec.inventory_item_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      rec.new_schedule_date      >= query.date1
            AND      rec.new_schedule_date       < query.date2
            AND      rec.disposition_status_type = 1
            AND      rec.order_type              = 2
            AND      rec.compile_designator      = arg_compile_desig
            AND      rec.organization_id         = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 245

        RAISE update_open_purchase_reqs;
Line: 250

    UPDATE  mrp_form_query  query
    SET     number4 =
            (SELECT   NVL(SUM(rec.new_order_quantity
                        * NVL(cst.item_cost, 0)), 0)
                      / 1000
            FROM     cst_item_costs       cst,
                     mrp_system_items     sys,
                     mrp_recommendations  rec
            WHERE    cst.organization_id         = sys.organization_id
            AND      cst.inventory_item_id       = sys.inventory_item_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      sys.inventory_item_id       = rec.inventory_item_id
            AND      sys.compile_designator      = rec.compile_designator
            AND      sys.organization_id         = rec.organization_id
            AND      sys.planning_make_buy_code  = 2
            AND      rec.new_schedule_date      >= query.date1
            AND      rec.new_schedule_date       < query.date2
            AND      rec.disposition_status_type = 1
            AND      rec.order_type              = 5
            AND      rec.compile_designator      = arg_compile_desig
            AND      rec.organization_id         = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 287

        RAISE update_mrp_purchase_orders;
Line: 294

    UPDATE  mrp_form_query  query
    SET     number5 =
            (SELECT   NVL(SUM(rec.new_order_quantity
                      * (NVL(cst.tl_resource, 0)
                       + NVL(cst.tl_overhead, 0)
                       + NVL(cst.tl_material_overhead, 0)
                       + NVL(cst.tl_outside_processing, 0))), 0)
                      / 1000
            FROM     cst_item_costs       cst,
                     mrp_recommendations  rec
            WHERE    cst.inventory_item_id       = rec.inventory_item_id
            AND      cst.organization_id         = rec.organization_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      rec.new_wip_start_date     >= query.date1
            AND      rec.new_wip_start_date      < query.date2
            AND      rec.disposition_status_type = 1
            AND      rec.order_type              in (3, 27)
            AND      rec.compile_designator      = arg_compile_desig
            AND      rec.organization_id         = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 329

        RAISE update_open_discrete_jobs;
Line: 335

    UPDATE  mrp_form_query  query
    SET     number6 =
            (SELECT   NVL(SUM(NVL(rec.daily_rate, 0)
                         *  (NVL(cst.tl_resource, 0)
                           + NVL(cst.tl_overhead, 0)
                           + NVL(cst.tl_material_overhead, 0)
                           + NVL(cst.tl_outside_processing, 0))), 0)
                      / 1000
            FROM     cst_item_costs          cst,
                     bom_calendar_dates      cal,
                     mrp_recommendations     rec
            WHERE    cst.inventory_item_id        = rec.inventory_item_id
            AND      cst.organization_id          = rec.organization_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      rec.last_unit_start_date    >= query.date1
            AND      rec.first_unit_start_date    < query.date2
            AND      cal.calendar_date      BETWEEN
                                           GREATEST(rec.first_unit_start_date,
                                                    query.date1)
                                                AND
                                              LEAST(rec.last_unit_start_date,
                                                   (query.date2 - 1))
            AND      cal.calendar_code            = arg_calendar_code
            AND      cal.exception_set_id         = arg_exception_set_id
            AND      cal.seq_num                 IS NOT NULL
            AND      rec.disposition_status_type  = 1
            AND      rec.order_type               = 4
            AND      rec.compile_designator       = arg_compile_desig
            AND      rec.organization_id          = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 380

        RAISE update_mrp_repetitive_scheds;
Line: 385

    UPDATE  mrp_form_query  query
    SET     number7 =
            (SELECT   NVL(SUM(rec.new_order_quantity
                      * (NVL(cst.tl_resource, 0)
                       + NVL(cst.tl_overhead, 0)
                       + NVL(cst.tl_material_overhead, 0)
                       + NVL(cst.tl_outside_processing, 0))), 0)
                      / 1000
            FROM     cst_item_costs               cst,
                     mrp_system_items             sys,
                     mrp_recommendations          rec
            WHERE    cst.inventory_item_id       = sys.inventory_item_id
            AND      cst.organization_id         = sys.organization_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      sys.inventory_item_id       = rec.inventory_item_id
            AND      sys.compile_designator      = rec.compile_designator
            AND      sys.organization_id         = rec.organization_id
            AND      sys.planning_make_buy_code  = 1
            AND      rec.new_schedule_date      >= query.date1
            AND      rec.new_schedule_date       < query.date2
            AND      rec.disposition_status_type = 1
            AND      rec.order_type              = 5
            AND      rec.compile_designator      = arg_compile_desig
            AND      rec.organization_id         = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 425

        RAISE update_mrp_discrete_jobs;
Line: 430

    UPDATE  mrp_form_query  query
    SET     number8 =
            (SELECT   NVL(SUM(dates.schedule_quantity * cst.item_cost), 0)
                      / 1000
            FROM     mrp_schedule_dates  dates,
                     cst_item_costs      cst,
                     mrp_system_items    sys,
		     mrp_schedule_designators sched
            WHERE    cst.organization_id       = sys.organization_id
            AND      cst.inventory_item_id     = sys.inventory_item_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      dates.organization_id     = sys.organization_id
            AND      dates.inventory_item_id   = sys.inventory_item_id
            AND      dates.schedule_date      >= query.date1
            AND      dates.schedule_date       < query.date2
            AND      dates.schedule_level      = 3
            AND      dates.schedule_designator = arg_sched_desig
	    AND	     sched.schedule_designator = arg_sched_desig
	    AND	     sched.organization_id     = arg_org_id
            AND      sys.repetitive_type       = 1
            AND      sys.compile_designator    = arg_compile_desig
            AND      sys.organization_id       = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 468

        RAISE update_master_sched_discrete;
Line: 473

    UPDATE  mrp_form_query  query
    SET     number8 =
            (SELECT  query.number8 +
                     NVL(SUM(cst.item_cost
                      * dates.repetitive_daily_rate), 0)
                     / 1000
            FROM     bom_calendar_dates  cal,
                     mrp_schedule_dates  dates,
                     cst_item_costs      cst,
                     mrp_system_items    sys,
		     mrp_schedule_designators sched
            WHERE    cst.organization_id       = sys.organization_id
            AND      cst.inventory_item_id     = sys.inventory_item_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      dates.organization_id     = sys.organization_id
            AND      dates.inventory_item_id   = sys.inventory_item_id
            AND      dates.rate_end_date      >= query.date1
            AND      dates.schedule_date       < query.date2
            AND      dates.schedule_level      = 3
            AND      dates.schedule_designator = arg_sched_desig
	    AND      sched.schedule_designator = arg_sched_desig
	    AND      sched.organization_id     = arg_org_id
            AND      cal.calendar_date   BETWEEN
                                        GREATEST(dates.schedule_date,
                                                 query.date1)
                                             AND
                                           LEAST(dates.rate_end_date,
                                                (query.date2 - 1))
            AND      cal.calendar_code            = arg_calendar_code
            AND      cal.exception_set_id         = arg_exception_set_id
            AND      cal.seq_num              IS NOT NULL
            AND      sys.repetitive_type       = 2
            AND      sys.compile_designator    = arg_compile_desig
            AND      sys.organization_id       = arg_org_id)
    WHERE   query_id = arg_query_id;
Line: 523

        RAISE update_master_sched_repetitive;
Line: 546

            RAISE select_inventory_values;
Line: 559

            SELECT  NVL(SUM(cst.item_cost
                      * NVL(dates.repetitive_daily_rate,
						dates.schedule_quantity)), 0) / 1000
			INTO	 past_due_master_schedule
            FROM     bom_calendar_dates  cal,
                     mrp_schedule_dates  dates,
                     cst_item_costs      cst,
                     mrp_system_items    sys,
		     mrp_schedule_designators sched
            WHERE    cst.organization_id       = sys.organization_id
            AND      cst.inventory_item_id     = sys.inventory_item_id
            AND ( cst.cost_type_id      = arg_cost_type
                OR
                  (
                   (cst.cost_type_id    = arg_def_cost_type)
                   AND
                   (NOT EXISTS
                      (SELECT 'Primary Cost Type Row'
                       FROM cst_item_costs cst1
                        WHERE cst1.inventory_item_id = cst.inventory_item_id
                       AND   cst1.organization_id   = arg_org_id
                       AND   cst1.cost_type_id      = arg_cost_type)
                   )
                 )
               )
            AND      dates.organization_id     = sys.organization_id
            AND      dates.inventory_item_id   = sys.inventory_item_id
            AND      NVL(dates.rate_end_date, dates.schedule_date)
						< start_date_this_period
            AND      dates.schedule_level      = 3
            AND      dates.schedule_designator = arg_sched_desig
	    AND      sched.schedule_designator = arg_sched_desig
	    AND      sched.organization_id     = arg_org_id
            AND      cal.calendar_date   BETWEEN dates.schedule_date
					 AND NVL(dates.rate_end_date, dates.schedule_date)
            AND      cal.calendar_code            = arg_calendar_code
            AND      cal.exception_set_id         = arg_exception_set_id
            AND      cal.seq_num              IS NOT NULL
            AND      sys.compile_designator    = arg_compile_desig
            AND      sys.organization_id       = arg_org_id;
Line: 600

				RAISE select_past_due_mds;
Line: 603

			UPDATE mrp_form_query
			SET    number8 = master_schedule
			WHERE  rowid = my_rowid;
Line: 607

					RAISE update_past_due_mds;
Line: 616

        | Update cumulative master schedule |
        +----------------------------------*/
        cum_master_schedule := cum_master_schedule + master_schedule;
Line: 656

        UPDATE  mrp_form_query q
        SET     number9 = end_inv_this_period,
                number10 = period_turns,
                number11 = cum_turns
        WHERE   rowid = my_rowid;
Line: 663

            RAISE update_inventory_values;
Line: 669

    WHEN select_on_hand THEN
        raise_application_error(-20000,
            'Cannot select on-hand beginning inventory value');
Line: 673

    WHEN select_wip THEN
        raise_application_error(-20000,
            'Cannot select WIP beginning inventory value');
Line: 677

    WHEN update_beginning_inv THEN
        raise_application_error(-20000,
            'Cannot update beginning inventory value');
Line: 681

    WHEN update_open_purchase_orders THEN
        raise_application_error(-20000,
            'Cannot update open purchase order values');
Line: 685

    WHEN update_open_purchase_reqs THEN
        raise_application_error(-20000,
            'Cannot update open purchase requisition values');
Line: 689

    WHEN update_mrp_purchase_orders THEN
        raise_application_error(-20000,
            'Cannot update MRP planned purchase order values');
Line: 693

    WHEN update_open_discrete_jobs THEN
        raise_application_error(-20000,
            'Cannot update open discrete job values');
Line: 697

    WHEN update_mrp_repetitive_scheds THEN
        raise_application_error(-20000,
            'Cannot update suggested repetitive schedule values');
Line: 701

    WHEN update_mrp_discrete_jobs THEN
        raise_application_error(-20000,
            'Cannot update MRP planned discrete job values');
Line: 705

    WHEN update_master_sched_discrete THEN
        raise_application_error(-20000,
            'Cannot update master schedule, discrete item values');
Line: 709

    WHEN update_master_sched_repetitive THEN
        raise_application_error(-20000,
            'Cannot update master schedule, discrete item values');
Line: 713

    WHEN select_inventory_values THEN
        raise_application_error(-20000,
                'Cannot select inventory values');
Line: 717

    WHEN update_inventory_values THEN
        raise_application_error(-20000,
                'Cannot update inventory values');
Line: 721

	WHEN select_past_due_mds THEN
		raise_application_error(-2000,
				'Cannot select past due MDS');
Line: 724

	WHEN update_past_due_mds THEN
		raise_application_error(-2000,
				'Cannot update past due MDS');