Upload
olabooye-ayodeji
View
217
Download
0
Embed Size (px)
Citation preview
8/12/2019 Item Creation Script
1/3
Declarel_target_org_code varchar2(3) not null := 'OPL';l_target_org_id number;l_process_id number not null := 2009;l_user_name varchar2(30) not null := 'AOLABOOYE';l_user_id number not null := -1;l_base_org_id number not null := 0;begin begin
select organization_idinto l_target_org_id
from org_organization_definitions where organization_code = l_target_org_code;
select nvl(user_id, -1)into l_user_id
from fnd_user where user_name = l_user_name; exception when others then dbms_output.put_line('Either organization or user doesn''t exist: '|| sqlerrm); end; declare
cursor c1 is select trim(upper(code)) code,trim(description) description,trim(category) category,scn, trim(item_type) item_type,part_num,trim(upper(uom)) uom,round(unit_price, 2) unit_pricefrom li_eam_inventory_items_1
where exist = 'No'; --and trim(upper(code)) not in (select segment1 from mtl_system_items where organization_id = l_base_org_id); --and new = 'Y';
wc1 c1%rowtype; inv_id int; prev_asset_group varchar(50); cat_id number; nNext number; sNext varchar(15); sCreateUpdate varchar2(100); --sSetId int; sTemplate varchar2(100); nTemplate number; sUOM varchar2(10);
begin
open c1; loop begin fetch c1 into wc1; exit when c1%notfound;
if wc1.uom = 'REEL' then sUOM := 'RL'; elsif wc1.uom = 'CN' then sUOM := 'CAN'; elsif wc1.uom = 'PAIL' then sUOM := 'PL'; elsif wc1.uom = '5 EACH' then sUOM := 'EA';
8/12/2019 Item Creation Script
2/3
elsif wc1.uom = 'EACH' then sUOM := 'EA'; elsif wc1.uom = 'P KG' then sUOM := 'PG'; elsif wc1.uom = 'KIT' then sUOM := 'KT'; elsif wc1.uom = '0' then sUOM := 'EA'; elsif wc1.uom = 'SET' then sUOM := 'ST'; elsif wc1.uom = 'BOX' then sUOM := 'BX'; elsif wc1.uom = 'TIN' then sUOM := 'TI'; elsif wc1.uom = 'ROLL' then sUOM := 'RL'; elsif wc1.uom = '(PK)' then sUOM := 'PK'; elsif wc1.uom = 'PACKS' then sUOM := 'PK'; elsif wc1.uom = 'PKG' then sUOM := 'PG'; elsif wc1.uom = 'GL' then sUOM := 'GAL'; elsif wc1.uom = 'COIL' then sUOM := 'RL'; else sUOM := wc1.uom; end if;
if upper(wc1.item_type) = 'STOCKABLE' then sTemplate := 'Spare Parts'; select template_id into nTemplate from mtl_item_templates where template_name = 'Spare Parts'; elsif upper(wc1.item_type) = 'ASSET' then sTemplate := 'Fixed Asset'; select template_id into nTemplate
from mtl_item_templates where template_name = 'Fixed Asset'; elsif upper(wc1.item_type) = 'EXPENSE' then sTemplate := 'Expense'; select template_id into nTemplate from mtl_item_templates where template_name = 'Expense'; else
sTemplate := 'Spare Parts'; select template_id into nTemplate from mtl_item_templates where template_name = 'Spare Parts'; end if;
sCreateUpdate := 'CREATE'; insert into mtl_system_items_interface (/*inventory_item_id,*/ description, segment1,
template_id,transaction_type,set_process_id,
inventory_item_flag,mtl_transactions_enabled_flag,serial_number_control_code,process_flag,organization_id,
item_number,--min_minmax_quantity,--max_minmax_quantity,
attribute_category,attribute1,
attribute2,primary_uom_code,list_price_per_unit)
values(/*mtl_system_items_interface_s.nextval,*/ wc1.description,
8/12/2019 Item Creation Script
3/3
wc1.code,nTemplate,sCreateUpdate,l_process_id,'N','N',null,1,l_base_org_id,wc1.code,
-- wc1.min,-- wc1.max,'', --'eam_items_attribute',
wc1.scn, wc1.part_num,
sUOM,wc1.unit_price);
commit;
exception
when no_data_found then dbms_output.PUT_LINE(sqlerrm);
when others then
dbms_output.PUT_LINE(sqlerrm); end;
end loop; close c1; end; commit;end;
select * from mtl_system_items_interface
select * from li_eam_inventory_items_1