DBA Data[Home] [Help]

APPS.CSP_PART_SEARCH_PVT SQL Statements

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

Line: 38

  select capt.organization_id,
         capt.subinventory_code,
         capt.required_item_id,
         sum(nvl(supplied_quantity,0)) supplied_quantity,
         crpt.quantity required_quantity
  from   csp_available_parts_temp capt,csp_required_parts_temp crpt
  where  crpt.inventory_item_id = capt.required_item_id
  and    item_type = 'BASE'
  group by capt.organization_id,
         capt.subinventory_code,
         capt.required_item_id,
         crpt.quantity;
Line: 60

          delete from csp_available_parts_temp
          where organization_id = cr.organization_id
          and   nvl(subinventory_code,'-1') = nvl(cr.subinventory_code,'-1');
Line: 63

          log('ship_set','Records deleted:'||sql%rowcount);
Line: 72

      SELECT organization_id,
        subinventory_code,
        source_type_code,
        required_item_id,
        required_item_rev,
        required_quantity,
        supplied_item_id,
        supplied_item_rev,
        supplied_quantity,
        supplied_item_type,
        shipping_date,
        shipping_method,
        shipping_cost,
        arrival_date,
        distance,
        open_or_closed,
        geometry
      from csp_available_parts_temp;
Line: 155

    delete from csp_available_parts_temp
    where nvl(supplied_quantity,-1) <= 0;
Line: 157

    log('clean_up','Records deleted:'||sql%rowcount);
Line: 161

  procedure update_shipping_info as

  l_shipping_method   varchar2(60);
Line: 169

  select distinct organization_id, subinventory_code,
      decode(l_distance_uom_code,'MILE',distance,'KM',distance/1.609344) distance
  from   csp_available_parts_temp
  where  source_type_code not in ('DEDICATED','MYSELF','UNMANNED','TECHNICIAN');
Line: 176

  select shipping_method,
         shipping_cost,
         arrival_date,
         decode(distance_uom,'MILE',distance,'KM',distance/1.609344) distance
  from   csp_shipping_details_v
  where  organization_id = p_organization_id
  and    to_location_id = nvl(p_search_params.to_location_id,
                              p_search_params.to_hz_location_id)
  and    location_source = decode(p_search_params.to_location_id,null,'HZ','HR')
  order by shipping_cost,arrival_date;
Line: 188

    log('update_shipping_info','Begin');
Line: 189

    log('update_shipping_info','p_search_params.need_by_date:'||
         to_char(p_search_params.need_by_date,'ddmmyy hh24:MI'));
Line: 196

    log('update_shipping_info','l_distance_uom_code:'||l_distance_uom_code);
Line: 200

      insert into csp_available_parts_temp(
             organization_id,
             subinventory_code,
             source_type_code,
             required_item_id,
             required_item_rev,
             required_quantity,
             supplied_item_id,
             supplied_item_rev,
             supplied_quantity,
             supplied_item_type,
             shipping_date,
             shipping_method,
             shipping_cost,
             arrival_date,
             distance,
             open_or_closed,
             geometry)
      select capt.organization_id,
             capt.subinventory_code,
             capt.source_type_code,
             capt.required_item_id,
             capt.required_item_rev,
             capt.required_quantity,
             capt.supplied_item_id,
             capt.supplied_item_rev,
             capt.supplied_quantity,
             capt.supplied_item_type,
             capt.shipping_date,
             csdv.shipping_method,
             csdv.shipping_cost,
             csdv.arrival_date,
             capt.distance,
             capt.open_or_closed,
             capt.geometry
      from   csp_shipping_details_v csdv,
             csp_available_parts_temp capt
      where  csdv.organization_id = capt.organization_id
      and    to_location_id = nvl(p_search_params.to_location_id,
                                  p_search_params.to_hz_location_id)
      and    location_source = decode(p_search_params.to_location_id,
                                      null,'HZ','HR')
      and    nvl(decode(l_distance_uom_code,'MILE',capt.distance,
                                            'KM',capt.distance/1.609344),0) <=
             nvl(decode(csdv.distance_uom,'MILE',csdv.distance,
                                          'KM',csdv.distance/1.609344),
               nvl(decode(l_distance_uom_code,'MILE',capt.distance,
                                            'KM',capt.distance/1.609344),0))
      order by csdv.shipping_cost,csdv.arrival_date;
Line: 249

      log('update_shipping_info','Records inserted:'||sql%rowcount);
Line: 259

        log('update_shipping_info','looping c_sources');
Line: 260

        log('update_shipping_info','cr.organization_id:'||cr.organization_id);
Line: 261

        log('update_shipping_info','cr.subinventory_code:'||
             cr.subinventory_code);
Line: 263

        log('update_shipping_info','p_search_params.to_location_id:'||
             p_search_params.to_location_id);
Line: 265

        log('update_shipping_info','p_search_params.to_hz_location_id:'||
             p_search_params.to_hz_location_id);
Line: 270

          log('update_shipping_info','csinfo.distance:'||csinfo.distance);
Line: 271

          log('update_shipping_info','cr.distance:'||cr.distance);
Line: 272

          log('update_shipping_info','p_search_params.called_from:'||
               p_search_params.called_from);
Line: 279

            log('update_shipping_info','looping csinfo');
Line: 281

            log('update_shipping_info','l_shipping_method:'||l_shipping_method);
Line: 282

            log('update_shipping_info','csinfo.arrival_date:'||
                 csinfo.arrival_date);
Line: 284

            log('update_shipping_info','csinfo.shipping_cost:'||
                 csinfo.shipping_cost);
Line: 289

              log('update_shipping_info','update csp_available_parts_temp');
Line: 291

              update csp_available_parts_temp
              set    shipping_method = csinfo.shipping_method,
                     shipping_cost = csinfo.shipping_cost,
                     arrival_date = csinfo.arrival_date
              where  organization_id = cr.organization_id
              and    nvl(subinventory_code,'-1') = nvl(cr.subinventory_code,'-1');
Line: 297

              log('update_shipping_info','Records updated:'||sql%rowcount);
Line: 299

              log('update_shipping_info','l_shipping_method:'||l_shipping_method);
Line: 304

        log('update_shipping_info','l_shipping_method:'||l_shipping_method);
Line: 306

            log('update_shipping_info','delete from csp_available_parts_temp');
Line: 307

          delete from csp_available_parts_temp
          where  organization_id = cr.organization_id
          and    nvl(subinventory_code,'-1') = nvl(cr.subinventory_code,'-1');
Line: 310

          log('update_shipping_info','Records deleted:'||sql%rowcount);
Line: 316

      log('update_shipping_info','search method SPARES deleting 1');
Line: 317

      delete from csp_available_parts_temp capt
      where  not exists (select 'x' from mtl_interorg_parameters mip
                         where  mip.from_organization_id = capt.organization_id
                         and    mip.to_organization_id = l_organization_id)
      and    capt.organization_id <> l_organization_id
      and    source_type_code not in ('DEDICATED','MYSELF');
Line: 323

      log('update_shipping_info','Records deleted:'||sql%rowcount);
Line: 324

      log('update_shipping_info','search method SPARES deleting 2');
Line: 326

    delete from csp_available_parts_temp
    where  shipping_method is null
    and    source_type_code not in ('DEDICATED','MYSELF','UNMANNED','TECHNICIAN');
Line: 329

    log('update_shipping_info','Records deleted:'||sql%rowcount);
Line: 330

    log('update_shipping_info','End');
Line: 335

  select  cpp.organization_id,
          cpp.secondary_inventory,
          hl.geometry
  from    csp_planning_parameters cpp,
          csp_dedicated_sites cds,
          jtf_tasks_b jtb,
          csp_requirement_headers crh,
          hz_party_sites hps,
          hz_locations hl
  where   cds.planning_parameters_id = cpp.planning_parameters_id
  and     nvl(cpp.stocking_site_excl,'N') = 'N'
  and     cpp.stocking_site_type = 'DEDICATED'
  and     jtb.address_id = cds.party_site_id
  and     jtb.task_id = crh.task_id
  and     hps.party_site_id = jtb.address_id
  and     hl.location_id = hps.location_id
  and     crh.requirement_header_id = p_search_params.requirement_header_id;
Line: 354

  select sum(capt.supplied_quantity)-min(crpt.quantity)
  from csp_required_parts_temp crpt,
       csp_available_parts_temp capt
  where crpt.item_type = 'BASE'
  and   capt.source_type_code = 'DEDICATED'
  and   capt.required_item_id = crpt.inventory_item_id
  order by 1 asc;
Line: 366

      log('site_dedicated_spares','Inserting into csp_available_parts_temp');
Line: 367

      insert into csp_available_parts_temp(
        organization_id,
        subinventory_code,
        source_type_code,
        required_item_id,
        required_item_rev,
        required_quantity,
        supplied_item_id,
        supplied_item_rev,
        supplied_quantity,
        supplied_item_type,
        shipping_date,
        shipping_method,
        shipping_cost,
        arrival_date,
        distance,
        geometry,
        open_or_closed)
      select
        csites.organization_id,
        csites.secondary_inventory,
        'DEDICATED',
        crpt.inventory_item_id,
        crpt.revision,
        crpt.quantity,
        crpt.alternate_item_id,
        null supplied_item_rev,
        csp_part_search_pvt.get_avail_qty(csites.organization_id,
                                          csites.secondary_inventory,
                                          crpt.alternate_item_id,
                                          crpt.revision,
                                          p_search_params.quantity_type),
        crpt.item_type,
        null shipping_date,
        null shipping_method,
        0 shipping_cost,
        sysdate arrival_date,
        0 distance,
        csites.geometry,
        'OPEN'
      from  csp_required_parts_temp crpt;
Line: 408

      log('site_dedicated_spares','Records inserted:'||sql%rowcount);
Line: 422

      log('my_inventory','insert into csp_available_parts');
Line: 423

      insert into csp_available_parts_temp(
        organization_id,
        subinventory_code,
        source_type_code,
        required_item_id,
        required_item_rev,
        required_quantity,
        supplied_item_id,
        supplied_item_rev,
        supplied_quantity,
        supplied_item_type,
        shipping_date,
        shipping_method,
        shipping_cost,
        arrival_date,
        distance,
        geometry,
        open_or_closed)
      select
        l_organization_id,
        l_subinventory_code,
        'MYSELF',
        crpt.inventory_item_id,
        crpt.revision,
        crpt.quantity,
        crpt.alternate_item_id,
        null supplied_item_rev,
        csp_part_search_pvt.get_avail_qty(l_organization_id,
                                          l_subinventory_code,
                                          crpt.alternate_item_id,
                                          crpt.revision,
                                          p_search_params.quantity_type),
        crpt.item_type,
        null shipping_date,
        null shipping_method,
        0 shipping_cost,
        sysdate arrival_date,
        0 distance,
        l_my_location,
        'OPEN'
      from  csp_required_parts_temp crpt;
Line: 464

      log('my_inventory','inserted records:'||sql%rowcount);
Line: 470

  select hl.geometry geometry,
         csf_gps_pub.get_location(
           null,csi.owner_resource_id,csi.owner_resource_type,sysdate) point,
         cpp.organization_id,
         cpp.secondary_inventory,
         csi.condition_type,
         csi.owner_resource_type,
         csi.owner_resource_id
  from   csp_sec_inventories csi,
         csp_planning_parameters cpp,
         hz_locations hl
  where  cpp.organization_id = csi.organization_id
  and   cpp.secondary_inventory = csi.secondary_inventory_name
  and   cpp.stocking_site_type = 'TECHNICIAN'
  and   hl.location_id(+) = cpp.hz_location_id
  and   (csi.organization_id <> l_organization_id
      or nvl(csi.secondary_inventory_name,'-1') <> l_subinventory_code)
  and   csi.condition_type = 'G'
  and exists
  (select 'x'
   from   mtl_onhand_quantities moq,
          csp_required_parts_temp crpt
   where  moq.organization_id = csi.organization_id
   and    moq.subinventory_code = csi.secondary_inventory_name
   and    moq.inventory_item_id = crpt.alternate_item_id);
Line: 500

  select 1 from dual
  where  l_point <> nvl(p_point,l_point);
Line: 519

        log('technicians','insert into CAPT');
Line: 520

        insert into csp_available_parts_temp(
          organization_id,
          subinventory_code,
          source_type_code,
          required_item_id,
          required_item_rev,
          required_quantity,
          supplied_item_id,
          supplied_item_rev,
          supplied_quantity,
          supplied_item_type,
          shipping_date,
          shipping_method,
          shipping_cost,
          arrival_date,
          distance,
          geometry,
          open_or_closed)
        select
          cr.organization_id,
          cr.secondary_inventory,
          'TECHNICIAN',
          crpt.inventory_item_id,
          crpt.revision,
          crpt.quantity,
          crpt.alternate_item_id,
          null supplied_item_rev,
          csp_part_search_pvt.get_avail_qty(cr.organization_id,
                                            cr.secondary_inventory,
                                            crpt.alternate_item_id,
                                            crpt.revision,
                                            p_search_params.quantity_type),
          crpt.item_type,
          null shipping_date,
          null shipping_method,
          0 shipping_cost,
          sysdate arrival_date,
          round(sdo_geom.sdo_distance(l_my_location,l_geometry,
                                1000,l_distance_uom),1) distance,
          l_geometry,
          case nvl(csoc.object_type,'CLOSED')
            when 'CLOSED' then 'CLOSED'
            else 'OPEN'
          end
        from
          csp_required_parts_temp crpt,
          cac_sr_object_capacity csoc,
          csp_sec_inventories csi
        where (cr.organization_id <> l_organization_id
            or nvl(cr.secondary_inventory,'-1') <> l_subinventory_code)
        and   csi.organization_id = cr.organization_id
        and   csi.secondary_inventory_name = cr.secondary_inventory
        and   cr.condition_type = 'G'
        and   decode(p_search_params.distance,null,-1,
              round(sdo_geom.sdo_distance(
                l_my_location,
                l_geometry,
                1000,
                l_distance_uom),1)) <= nvl(p_search_params.distance,-1)
        and   csoc.object_type(+) = csi.owner_resource_type
        and   csoc.object_id(+) = csi.owner_resource_id
        and   sysdate between csoc.start_date_time(+) and csoc.end_date_time(+)
        and   decode(csoc.object_type,null,'CLOSED','OPEN')
               in ('OPEN',l_open_or_closed);
Line: 584

        log('technicians','Records inserted:'||sql%rowcount);
Line: 594

      log('unmanned_warehouses','insert into CAPT');
Line: 595

      insert into csp_available_parts_temp(
        organization_id,
        subinventory_code,
        source_type_code,
        required_item_id,
        required_item_rev,
        required_quantity,
        supplied_item_id,
        supplied_item_rev,
        supplied_quantity,
        supplied_item_type,
        shipping_date,
        shipping_method,
        shipping_cost,
        arrival_date,
        distance,
        geometry,
        open_or_closed)
      select
        cpp.organization_id,
        cpp.secondary_inventory,
        cpp.stocking_site_type,
        crpt.inventory_item_id,
        crpt.revision,
        crpt.quantity,
        crpt.alternate_item_id,
        null supplied_item_rev,
        csp_part_search_pvt.get_avail_qty(cpp.organization_id,
                                          cpp.secondary_inventory,
                                          crpt.alternate_item_id,
                                          crpt.revision,
                                          p_search_params.quantity_type),
        crpt.item_type,
        null shipping_date,
        null shipping_method,
        0 shipping_cost,
        sysdate arrival_date,
        round(sdo_geom.sdo_distance(l_my_location,hl.geometry,
                              1000,l_distance_uom),1) distance,
        hl.geometry,
        decode(sign(hz_timezone_pub.convert_datetime(
                                      l_server_timezone_id,
                                      cpp.timezone_id,
                                      sysdate)-nvl(cocv.start_time,sysdate-1))+
             sign(nvl(cocv.end_time,sysdate+1)-hz_timezone_pub.convert_datetime(
                                      l_server_timezone_id,
                                      cpp.timezone_id,
                                      sysdate)),2,'OPEN','CLOSED')
      from
        csp_required_parts_temp crpt,
        csp_planning_parameters cpp,
        csp_open_closed_v cocv,
        hz_locations hl
      where cpp.stocking_site_type = 'UNMANNED'
      and   nvl(cpp.stocking_site_excl,'N') = 'N'
      and   decode(p_search_params.distance,null,-1,
            round(sdo_geom.sdo_distance(
              l_my_location,
              hl.geometry,
              1000,
              l_distance_uom),1)) <= nvl(p_search_params.distance,-1)
      and   hl.location_id (+) = cpp.hz_location_id
      and   (cpp.organization_id <> l_organization_id
          or nvl(cpp.secondary_inventory,'-1') <> l_subinventory_code)
      and   cocv.calendar_id(+) = cpp.calendar_id
      and   decode(sign(hz_timezone_pub.convert_datetime(
                                       l_server_timezone_id,
                                       cpp.timezone_id,
                                       sysdate)-nvl(cocv.start_time,sysdate-1))+
             sign(nvl(cocv.end_time,sysdate+1)-hz_timezone_pub.convert_datetime(
                                       l_server_timezone_id,
                                       cpp.timezone_id,
                                       sysdate)),2,'OPEN','CLOSED')
             in ('OPEN',l_open_or_closed);
Line: 669

      log('unmanned_warehouses','Records inserted:'||sql%rowcount);
Line: 681

  select distinct organization_id
  from   csp_shipping_details_v
  where  ((to_location_id = p_search_params.to_location_id
      and location_source = 'HR')
  or     (to_location_id = p_search_params.to_hz_location_id
      and location_source = 'HZ'));
Line: 691

        log('manned_warehouses','insert into CAPT');
Line: 692

        insert into csp_available_parts_temp(
          organization_id,
          subinventory_code,
          source_type_code,
          required_item_id,
          required_item_rev,
          required_quantity,
          supplied_item_id,
          supplied_item_rev,
          supplied_quantity,
          supplied_item_type,
          shipping_date,
          shipping_method,
          shipping_cost,
          arrival_date,
          distance,
          geometry,
          open_or_closed)
        select
          cpp.organization_id,
          cpp.secondary_inventory,
          cpp.stocking_site_type,
          crpt.inventory_item_id,
          crpt.revision,
          crpt.quantity,
          crpt.alternate_item_id,
          null supplied_item_rev,
          csp_part_search_pvt.get_avail_qty(cpp.organization_id,
                                            cpp.secondary_inventory,
                                            crpt.alternate_item_id,
                                            crpt.revision,
                                            p_search_params.quantity_type),
          crpt.item_type,
          null shipping_date,
          null shipping_method,
          null shipping_cost,
          null arrival_date,
          round(sdo_geom.sdo_distance(l_my_location,hl.geometry,
                                      1000,l_distance_uom),1),
          hl.geometry,
          decode(sign(hz_timezone_pub.convert_datetime(
                                        l_server_timezone_id,
                                        cpp.timezone_id,
                                        sysdate)-nvl(cocv.start_time,sysdate-1))+
               sign(nvl(cocv.end_time,sysdate+1)-hz_timezone_pub.convert_datetime(
                                        l_server_timezone_id,
                                        cpp.timezone_id,
                                        sysdate)),2,'OPEN','CLOSED')
        from
          csp_required_parts_temp crpt,
          csp_planning_parameters cpp,
          csp_open_closed_v cocv,
          hz_locations hl
        where cpp.stocking_site_type = 'MANNED'
        and   cpp.organization_id = cr.organization_id
        and   nvl(cpp.stocking_site_excl,'N') = 'N'
        and   hl.location_id (+) = cpp.hz_location_id
        and   decode(p_search_params.distance,null,-1,
              round(sdo_geom.sdo_distance(
                l_my_location,
                hl.geometry,
                1000,
                l_distance_uom),1)) <= nvl(p_search_params.distance,-1)
        and   (cpp.organization_id <> nvl(l_organization_id, -999)
            or nvl(cpp.secondary_inventory,'-1') <> l_subinventory_code)
        and   cocv.calendar_id(+) = cpp.calendar_id
        and   exists (select 'x'
               from   mtl_onhand_quantities moq
               where  moq.organization_id = cpp.organization_id
               and    moq.subinventory_code = nvl(cpp.secondary_inventory,
                                                  moq.subinventory_code)
               and    moq.inventory_item_id = crpt.alternate_item_id)
        and   decode(sign(hz_timezone_pub.convert_datetime(
                                         l_server_timezone_id,
                                         cpp.timezone_id,
                                         sysdate)-nvl(cocv.start_time,sysdate-1))+
               sign(nvl(cocv.end_time,sysdate+1)-hz_timezone_pub.convert_datetime(
                                         l_server_timezone_id,
                                         cpp.timezone_id,
                                         sysdate)),2,'OPEN','CLOSED')
               in ('OPEN',l_open_or_closed);
Line: 773

        log('manned_warehouses','Inserted records:'||sql%rowcount);
Line: 787

    insert into csp_available_parts_temp(
        organization_id,
        subinventory_code,
        source_type_code,
        required_item_id,
        required_item_rev,
        required_quantity,
        supplied_item_id,
        supplied_item_rev,
        supplied_quantity,
        supplied_item_type,
        shipping_date,
        shipping_method,
        shipping_cost,
        arrival_date,
        distance,
        geometry,
        open_or_closed)
    select
        cpp.organization_id,
        cpp.secondary_inventory,
        cpp.stocking_site_type,
        crpt.inventory_item_id,
        crpt.revision,
        crpt.quantity,
        crpt.alternate_item_id,
        null supplied_item_rev,
        csp_part_search_pvt.get_avail_qty(cpp.organization_id,
                                          cpp.secondary_inventory,
                                          crpt.alternate_item_id,
                                          crpt.revision,
                                          p_search_params.quantity_type),
        crpt.item_type,
        null shipping_date,
        null shipping_method,
        null shipping_cost,
        null arrival_date,
        round(sdo_geom.sdo_distance(l_my_location,hl.geometry,
              1000,l_distance_uom),1),
        hl.geometry,
        decode(sign(hz_timezone_pub.convert_datetime(
                                      l_server_timezone_id,
                                      cpp.timezone_id,
                                      sysdate)-nvl(cocv.start_time,sysdate-1))+
             sign(nvl(cocv.end_time,sysdate+1)-hz_timezone_pub.convert_datetime(
                                      l_server_timezone_id,
                                      cpp.timezone_id,
                                      sysdate)),2,'OPEN','CLOSED')
      from
        csp_required_parts_temp crpt,
        csp_planning_parameters cpp,
        csp_open_closed_v cocv,
        hz_locations hl
      where cpp.organization_id = p_search_params.source_organization_id
      and   nvl(cpp.stocking_site_excl,'N') = 'N'
      and   hl.location_id (+) = cpp.hz_location_id
      and   decode(p_search_params.distance,null,-1,
            round(sdo_geom.sdo_distance(
              l_my_location,
              hl.geometry,
              1000,
              l_distance_uom),1)) <= nvl(p_search_params.distance,-1)
      and   nvl(cpp.secondary_inventory,'-1') =
            nvl(p_search_params.source_subinventory,'-1')
      and   cocv.calendar_id(+) = cpp.calendar_id
      and   decode(sign(hz_timezone_pub.convert_datetime(
                                       l_server_timezone_id,
                                       cpp.timezone_id,
                                       sysdate)-nvl(cocv.start_time,sysdate-1))+
             sign(nvl(cocv.end_time,sysdate+1)-hz_timezone_pub.convert_datetime(
                                       l_server_timezone_id,
                                       cpp.timezone_id,
                                       sysdate)),2,'OPEN','CLOSED')
             in ('OPEN',l_open_or_closed);
Line: 861

    log('specific_warehouse','Records inserted:'||sql%rowcount);
Line: 868

    select crpt.inventory_item_id,
           crpt.alternate_item_id,
           crpt.item_type item_type,
           crpt.revision,
           crpt.quantity
    from   csp_required_parts_temp crpt;
Line: 892

        log('replenishment_source','inserting into CAPT');
Line: 893

        insert into csp_available_parts_temp(
          organization_id,
          subinventory_code,
          source_type_code,
          required_item_id,
          required_item_rev,
          required_quantity,
          supplied_item_id,
          supplied_item_rev,
          supplied_quantity,
          supplied_item_type,
          shipping_date,
          shipping_method,
          shipping_cost,
          arrival_date,
          distance,
          geometry,
          open_or_closed)
        select
          l_repl_org,
          l_repl_sub,
          'MANNED',
          cr.inventory_item_id,
          cr.revision,
          cr.quantity,
          cr.alternate_item_id,
          null supplied_item_rev,
          csp_part_search_pvt.get_avail_qty(l_repl_org,
                                            l_repl_sub,
                                            cr.alternate_item_id,
                                            cr.revision,
                                            p_search_params.quantity_type),
          cr.item_type,
          null shipping_date,
          null shipping_method,
          null shipping_cost,
          null arrival_date,
          null distance,
          null geometry,
          'OPEN'
        from dual;
Line: 934

        log('replenishment_source','Inserted records:'||sql%rowcount);
Line: 942

    select crl.requirement_line_id,
           crl.inventory_item_id,
           crl.revision,
           crl.uom_code,
           crl.required_quantity,
           crl.ship_complete_flag,
           crh.destination_organization_id,
           crh.destination_subinventory,
           crh.need_by_date,
           crh.timezone_id,
           crh.ship_to_location_id
    from   csp_requirement_lines crl,
           csp_requirement_headers crh
    where  crh.requirement_header_id = p_search_params.requirement_header_id
    and    crl.requirement_header_id = crh.requirement_header_id;
Line: 1017

      log('atp','insert into CAPT');
Line: 1018

      insert into csp_available_parts_temp(
        organization_id,
        subinventory_code,
        source_type_code,
        required_item_id,
        required_item_rev,
        required_quantity,
        supplied_item_id,
        supplied_item_rev,
        supplied_quantity,
        supplied_item_type,
        shipping_date,
        shipping_method,
        shipping_cost,
        arrival_date,
        distance,
        open_or_closed,
        geometry)
      select
        l_avail_list_tbl(i).source_org_id,
        l_avail_list_tbl(i).sub_inventory_code,
        'MANNED',
        l_avail_list_tbl(i).item_id,
        l_avail_list_tbl(i).revision,
        l_avail_list_tbl(i).ordered_quantity,  -- replaced required_quantity with ordered_quantity
        l_avail_list_tbl(i).item_id,
        l_avail_list_tbl(i).revision,
        l_avail_list_tbl(i).available_quantity,
        decode(l_avail_list_tbl(i).item_type, 2, 'SUBSTITUTE', 8, 'SUPERSEDED', 'BASE'),  -- used decode as item_type here is a number
        null,
        l_avail_list_tbl(i).shipping_methode,
        null,
        l_avail_list_tbl(i).arraival_date,
        null,
        'OPEN',
        null
      from dual;
Line: 1055

      log('atp','Inserted records:'||sql%rowcount);
Line: 1066

    select hl.geometry
    from   hz_locations hl,
           csp_planning_parameters cpp
    where  cpp.organization_id = l_organization_id
    and    cpp.secondary_inventory = l_subinventory_code
    and    hl.location_id = cpp.hz_location_id;
Line: 1074

    select geometry
    from   hz_locations
    where  location_id = l_to_hz_location_id;
Line: 1079

    select hl.address1,hl.address2,hl.address3,hl.address4,
           hl.city,hl.postal_code,hl.state,ftt.territory_short_name,
           hl.province,hl.county
    from   hz_locations hl, fnd_territories_tl ftt
    where  hl.location_id = l_to_hz_location_id
    and    ftt.territory_code = hl.country
    and    ftt.language = 'US';
Line: 1088

    select hps.location_id
    from   hz_cust_site_uses_all hcsua,
           po_location_associations_all plaa,
           hz_cust_acct_sites_all hcasa,
           hz_party_sites hps
    where  plaa.location_id = p_search_params.to_location_id
    and    hcsua.site_use_id = plaa.site_use_id
    and    hcsua.site_use_code = 'SHIP_TO'
    and    hcsua.status = 'A'
    and    hcasa.cust_acct_site_id = hcsua.cust_acct_site_id
    and    hps.party_site_id = hcasa.party_site_id;
Line: 1216

    select organization_id, subinventory_code
    from   csp_inv_loc_assignments
    where  resource_type = p_search_params.resource_type
    and    resource_id   = p_search_params.resource_id
    and    default_code  = 'IN';
Line: 1242

  procedure insert_parts as
    i number :=0;
Line: 1250

    select inventory_item_id,revision,required_quantity, requirement_line_id
    from   csp_requirement_lines crl
    where  requirement_header_id = p_search_params.requirement_header_id;
Line: 1255

    select source_type, source_id
    from   csp_req_line_details
    where  requirement_line_id = p_requirement_line_id;
Line: 1260

    select reservation_quantity
    from   mtl_reservations
    where  reservation_id = p_reservation_id;
Line: 1265

    select quantity
    from mtl_txn_request_lines
    where  line_id = p_mo_line_id;
Line: 1270

    select ordered_quantity
    from oe_order_lines_all
    where  line_id = p_io_line_id;
Line: 1275

    select quantity
    from   po_lines_all
    where  po_line_id = p_po_line_id;
Line: 1281

    select inventory_item_id, revision, quantity
    from csp_required_parts_temp;
Line: 1285

    l_insert_rec_c number;
Line: 1288

    select master_organization_id
    from mtl_parameters
    where organization_id = l_organization_id;
Line: 1293

    SELECT related_item_id
    FROM mtl_related_items
    WHERE organization_id = v_organization_id
    AND TRUNC(sysdate) BETWEEN TRUNC(NVL(start_date,sysdate)) AND TRUNC(NVL(end_date,sysdate))
    AND relationship_type_id           = v_rel_type
      start with inventory_item_id     = v_inventory_item_id
      CONNECT BY nocycle prior related_item_id = inventory_item_id
    UNION
    SELECT inventory_item_id    AS related_item_id
    FROM mtl_related_items
    WHERE organization_id    = v_organization_id
    AND relationship_type_id = v_rel_type
    AND TRUNC(sysdate) BETWEEN TRUNC(NVL(start_date,sysdate)) AND TRUNC(NVL(end_date,sysdate))
      START WITH related_item_id         = v_inventory_item_id
    and reciprocal_flag                  = 'Y'
      CONNECT BY nocycle prior inventory_item_id||prior reciprocal_flag = related_item_id||reciprocal_flag;
Line: 1311

    log('insert_parts','Begin');
Line: 1313

      log('insert_parts',
          'p_search_params.requirement_header_id:'||
           p_search_params.requirement_header_id);
Line: 1317

        log('insert_parts','in c_requirement loop');
Line: 1319

          log('insert_parts','in c_req_line_details loop');
Line: 1320

          log('insert_parts','cr.requirement_line_id:'||cr.requirement_line_id);
Line: 1325

            log('insert_parts','RES l_quantity:'||l_quantity);
Line: 1327

            log('insert_parts','RES l_total_quantity:'||l_total_quantity);
Line: 1332

            log('insert_parts','MO l_quantity:'||l_quantity);
Line: 1334

            log('insert_parts','MO l_total_quantity:'||l_total_quantity);
Line: 1339

            log('insert_parts','IO l_quantity:'||l_quantity);
Line: 1341

            log('insert_parts','IO l_total_quantity:'||l_total_quantity);
Line: 1346

            log('insert_parts','POREQ l_quantity:'||l_quantity);
Line: 1348

            log('insert_parts','POREQ l_total_quantity:'||l_total_quantity);
Line: 1352

        log('insert_parts','cr.required_quantity:'||cr.required_quantity);
Line: 1358

          log('insert_parts',
              'l_required_parts.inventory_item_id:'||
              l_required_parts(i).inventory_item_id);
Line: 1361

          log('insert_parts',
              'l_required_parts.revision:'||l_required_parts(i).revision);
Line: 1363

          log('insert_parts',
              'l_required_parts.quantity:'||l_required_parts(i).quantity);
Line: 1370

      log('insert_parts','p_search_params.requirement_header_id is null');
Line: 1374

      log('insert_parts','In l_required_parts.count loop i:'||i);
Line: 1375

      log('insert_parts','Insert into csp_required_parts_temp');
Line: 1376

      insert into csp_required_parts_temp(inventory_item_id,
                                          revision,
                                          alternate_item_id,
                                          quantity,item_type)
      values (l_required_parts(i).inventory_item_id,
              l_required_parts(i).revision,
              l_required_parts(i).inventory_item_id,
              l_required_parts(i).quantity,
              'BASE');
Line: 1385

      log('insert_parts','Inserted records:'||sql%rowcount);
Line: 1389

      log('insert_parts','insert supersessions into CRPT');
Line: 1394

      l_insert_rec_c := 0;
Line: 1400

                insert into csp_required_parts_temp(inventory_item_id,
                                                  revision,
                                                  alternate_item_id,
                                                  quantity,
                                                  item_type)
                values (r_req_items.inventory_item_id,
                    r_req_items.revision,
                    r_rel_item.related_item_id,
                    r_req_items.quantity,
                    'SUPERSEDED');
Line: 1410

                l_insert_rec_c := l_insert_rec_c + 1;
Line: 1415

      log('insert_parts','Inserted records:' || l_insert_rec_c);
Line: 1418

      log('insert_parts','insert substitutes into CRPT');
Line: 1419

      insert into csp_required_parts_temp(inventory_item_id,
                                          revision,
                                          alternate_item_id,
                                          quantity,item_type)
      select crpt.inventory_item_id,
             crpt.revision,
             mriv.related_item_id,
             crpt.quantity,
             'SUBSTITUTE'
      from mtl_related_items_view mriv,
           mtl_parameters mp,
           csp_required_parts_temp crpt
      where mp.organization_id = l_organization_id
      and   mriv.organization_id =  mp.master_organization_id
      and   mriv.inventory_item_id = crpt.inventory_item_id
      and   mriv.relationship_type_id = 2
      and   crpt.item_type = 'BASE'
      and   trunc(sysdate) between trunc(nvl(mriv.start_date,sysdate))
                               and trunc(nvl(mriv.end_date,sysdate))
      and   not exists(
        select 'x'
        from   csp_required_parts_temp
        where  alternate_item_id = mriv.related_item_id);
Line: 1443

    log('insert_parts','Inserted records:'||sql%rowcount);
Line: 1448

      l_insert_rec_c := 0;
Line: 1454

                insert into csp_required_parts_temp(inventory_item_id,
                                                  revision,
                                                  alternate_item_id,
                                                  quantity,
                                                  item_type)
                values (r_req_items.inventory_item_id,
                    r_req_items.revision,
                    r_rel_item.related_item_id,
                    r_req_items.quantity,
                    'SUBSTITUTE');
Line: 1464

                l_insert_rec_c := l_insert_rec_c + 1;
Line: 1469

      log('insert_parts','Inserted records:'||l_insert_rec_c);
Line: 1472

    log('insert_parts','End');
Line: 1477

      delete from csp_required_parts_temp;
Line: 1478

      delete from csp_available_parts_temp;
Line: 1526

      log('main','calling insert_parts');
Line: 1527

      insert_parts;
Line: 1549

      log('main','calling insert_parts');
Line: 1550

      insert_parts;
Line: 1567

        log('main','calling update_shipping_info');
Line: 1568

        update_shipping_info;
Line: 1584

      log('main','calling insert_parts');
Line: 1585

      insert_parts;
Line: 1613

        log('main','calling update_shipping_info');
Line: 1614

        update_shipping_info;
Line: 1653

  select revision
  from   mtl_item_revisions
  where  organization_id = p_organization_id
  and    inventory_item_id = p_inventory_item_id
  and    revision = nvl(p_revision,revision);
Line: 1660

  select sum(nvl(excess_quantity,0) - nvl(returned_quantity,0))
  from   csp_excess_lists
  where  organization_id = p_organization_id
  and    nvl(subinventory_code,'-1') = nvl(p_subinventory_code,'-1')
  and    inventory_item_id = p_inventory_item_id;
Line: 1667

  select serial_number_control_code,
         revision_qty_control_code
  from   mtl_system_items
  where  organization_id   = p_organization_id
  and    inventory_item_id = p_inventory_item_id;
Line: 1674

  select secondary_inventory_name
  from   csp_sec_inventories
  where  organization_id = p_organization_id
  and    condition_type = 'B';
Line: 1692

        select nvl(MTL_TRANSACTIONS_ENABLED_FLAG, 'N')
        into l_TRANSACTIONS_ENABLED
        from mtl_system_items_b
        where inventory_item_id = p_inventory_item_id
        and organization_id = p_organization_id;
Line: 1877

      select trunc(sysdate+flvv.lookup_code) bd_arrival_date
      FROM jtf_cal_shift_constructs jcsc,
        jtf_cal_shifts_b jcsb,
        jtf_cal_shift_assign jcsa,
        jtf_calendars_b jcb,
        fnd_lookup_values_vl flvv,
        csp_planning_parameters cpp
      WHERE jcsa.calendar_id = jcb.calendar_id
      AND jcsb.shift_id      = jcsa.shift_id
      AND jcsc.shift_id      = jcsa.shift_id
      and flvv.lookup_type   = 'NUMBERS'
      AND to_number(flvv.lookup_code) BETWEEN 0 AND 15
      and trunc(sysdate+flvv.lookup_code)
          between trunc(nvl(jcb.start_date_active,sysdate+flvv.lookup_code))
          AND     TRUNC(NVL(jcb.end_date_active,sysdate+flvv.lookup_code))
      and trunc(sysdate+flvv.lookup_code)
          between trunc(nvl(jcsa.shift_start_date,sysdate+flvv.lookup_code))
          AND     TRUNC(NVL(jcsa.shift_end_date,sysdate+flvv.lookup_code))
      and trunc(sysdate+flvv.lookup_code)
          between trunc(nvl(jcsb.start_date_active,sysdate+flvv.lookup_code))
          AND     TRUNC(NVL(jcsb.end_date_active,sysdate+flvv.lookup_code))
      and trunc(sysdate+flvv.lookup_code)
          between trunc(nvl(jcsc.start_date_active,sysdate+flvv.lookup_code))
          AND     TRUNC(NVL(jcsc.end_date_active,sysdate+flvv.lookup_code))
      and jcsc.unit_of_time_value = to_char(sysdate+flvv.lookup_code,'D')
      and not exists
        (SELECT 'x'
        FROM jtf_cal_exception_assign jcea,
          jtf_cal_exceptions_b jceb
        where jcea.calendar_id = jcb.calendar_id
        and sysdate+flvv.lookup_code
            between trunc(jceb.start_date_time) and trunc(jceb.end_date_time+1)
        and sysdate+flvv.lookup_code
            BETWEEN trunc(jcea.start_date_active) AND trunc(jcea.end_date_active+1)
        and jcea.exception_id = jceb.exception_id
        )
    and jcb.calendar_id = cpp.calendar_id
    and cpp.organization_id = p_organization_id
    and nvl(cpp.secondary_inventory,-1) = nvl(p_subinventory_code,-1)
    order by to_number(flvv.lookup_code);
Line: 2013

  select postal_code,city,decode(COUNTRY, 'CA', nvl(PROVINCE, STATE), STATE),country,nvl(timezone_id, -9999)
  from   hz_locations
  where  location_id = p_location_id
  and    p_location_source = 'HZ'
  union all
  select postal_code,town_or_city,upper(region_1),country,-9999
  from   hr_locations
  where  location_id = p_location_id
  and    p_location_source = 'HR';
Line: 2024

  SELECT hl.postal_code,
    hl.city,
    decode(hl.COUNTRY, 'CA', nvl(hl.PROVINCE, hl.STATE), hl.STATE),
    hl.country,
    hl.location_id,
    nvl(hl.timezone_id, -9999)
  FROM hz_locations hl,
    hz_party_sites hps,
    HZ_CUST_ACCT_SITES_ALL hcas,
    PO_LOCATION_ASSOCIATIONS_ALL pol
  WHERE hl.location_id   = hps.location_id
  AND hcas.party_site_id = hps.party_site_id
  AND pol.org_id         = hcas.org_id
  AND pol.address_id     = hcas.cust_acct_site_id
  AND pol.location_id    = p_location_id
  AND rownum             = 1;
Line: 2103

    SELECT GEOMETRY
    INTO l_src_geo
    FROM HZ_LOCATIONS
    WHERE location_id =
      ( SELECT DISTINCT hz_location_id
      FROM csp_planning_parameters
      WHERE organization_id                = p_src_org_id
      AND NVL(SECONDARY_INVENTORY, 'NULL') = NVL(p_src_subinv, 'NULL')
      );
Line: 2114

    SELECT hloc.GEOMETRY
    INTO l_dest_geo
    FROM hz_locations hloc,
      hz_party_sites hps
    WHERE hloc.location_id = hps.location_id
    AND hps.party_site_id  =
      ( SELECT DISTINCT party_site_id
      FROM po_location_associations_all ploc,
        hz_cust_acct_sites_all hcsa,
        csp_requirement_headers crh
      WHERE crh.requirement_header_id = p_req_header_id
      AND ploc.location_id            = crh.ship_to_location_id
      --AND ploc.customer_id            = hcsa.cust_account_id
      AND ploc.address_id             = hcsa.cust_acct_site_id
      AND ploc.org_id                 = hcsa.org_id
      );
Line: 2143

    SELECT ROUND(sdo_geom.sdo_distance(l_src_geo, l_dest_geo, 1000, l_distance_uom),1)
    INTO l_distance
    FROM dual;
Line: 2149

      SELECT meaning
      INTO l_distance_uom_meaning
      FROM fnd_lookups
      WHERE lookup_type='CSFW_DISTANCE_UNIT'
      AND lookup_code  = l_distance_uom_code;