|
Re: 求forecast的接口程序,急用,谢谢
最初由 smail6102 发布
[B]哪位大虾有写forecast的接口程序,现在急用,不胜感激. [/B]
TEM_FORECAST_HISTORY is a temporary table for storing source data,
please refer to script as below :
DECLARE
L_INV_ORG TEM_FORECAST_HISTORY.INV_ORG%TYPE;
L_FORECAST_SET TEM_FORECAST_HISTORY.FORECAST_SET%TYPE;
L_FORECAST TEM_FORECAST_HISTORY.FORECAST%TYPE;
L_ITEM TEM_FORECAST_HISTORY.ITEM%TYPE;
L_PERIOD_BUCKET TEM_FORECAST_HISTORY.PERIOD_BUCKET%TYPE;
L_PERIOD_START_DATE TEM_FORECAST_HISTORY.PERIOD_START_DATE%TYPE;
L_NO_OF_BUCKETS TEM_FORECAST_HISTORY.NO_OF_BUCKETS%TYPE;
L_QUANTITY TEM_FORECAST_HISTORY.QUANTITY%TYPE;
L_COUNT_ITEM NUMBER;
L_ITEM_ID NUMBER;
L_ORGANIZATION_ID NUMBER;
L_rec_count NUMBER := 0;
CURSOR c_fh_line is
select INV_ORG,FORECAST_SET,FORECAST,ITEM,PERIOD_BUCKET,
to_date(PERIOD_START_DATE,'dd/mm/yy') PERIOD_START_DATE,
NO_OF_BUCKETS,QUANTITY
from TEM_FORECAST_HISTORY
where process_flag is null ;
--where item = 'NTM510RSS' ;
CURSOR c_item_count is
select count(*)
from mtl_system_items
where segment1 = L_item
and ORGANIZATION_ID = 103;
CURSOR c_item is
select INVENTORY_ITEM_ID
from mtl_system_items
where segment1 = L_item
and ORGANIZATION_ID = 103;
CURSOR c_org_id is
select ORGANIZATION_ID
from MRP_FORECAST_DSGN_SN
where FORECAST_SET = L_FORECAST_SET
and FORECAST_DESIGNATOR = L_FORECAST;
t_forecast_interface_tab MRP_FORECAST_INTERFACE_PK.t_forecast_interface;
t_forecast_designator_tab MRP_FORECAST_INTERFACE_PK.t_forecast_designator;
var_bool BOOLEAN;
BEGIN
FOR fhrec IN c_fh_line LOOP
L_rec_count := L_rec_count + 1;
L_INV_ORG := fhrec.INV_ORG;
L_FORECAST_SET := fhrec.FORECAST_SET;
L_FORECAST := fhrec.FORECAST;
L_ITEM := fhrec.ITEM;
L_PERIOD_BUCKET := fhrec.PERIOD_BUCKET;
L_PERIOD_START_DATE := fhrec.PERIOD_START_DATE;
L_NO_OF_BUCKETS := fhrec.NO_OF_BUCKETS;
L_QUANTITY := fhrec.QUANTITY;
open c_org_id;
fetch c_org_id into L_ORGANIZATION_ID;
close c_org_id;
open c_item_count;
fetch c_item_count into L_COUNT_ITEM;
close c_item_count;
if L_COUNT_ITEM > 0 then
open c_item;
fetch c_item into L_ITEM_ID;
close c_item;
else
L_ITEM_ID := NULL;
end if;
/*dbms_output.put_line('inventory_item_id = '||L_ITEM_ID);
dbms_output.put_line('forecast_designator = '||L_FORECAST);
dbms_output.put_line('organization_id = '||L_ORGANIZATION_ID);
dbms_output.put_line('forecast_date = '||L_PERIOD_START_DATE);
dbms_output.put_line('bucket_type = '||L_NO_OF_BUCKETS);
dbms_output.put_line('quantity = '||L_QUANTITY); */
if L_ITEM_ID is not null then
t_forecast_interface_tab(L_rec_count).inventory_item_id := L_ITEM_ID;
t_forecast_interface_tab(L_rec_count).forecast_designator := L_FORECAST;
t_forecast_interface_tab(L_rec_count).organization_id := L_ORGANIZATION_ID;
t_forecast_interface_tab(L_rec_count).forecast_date := L_PERIOD_START_DATE;
t_forecast_interface_tab(L_rec_count).bucket_type := 3; --L_NO_OF_BUCKETS
t_forecast_interface_tab(L_rec_count).quantity := L_QUANTITY;
t_forecast_interface_tab(L_rec_count).process_status := 2;
t_forecast_interface_tab(L_rec_count).confidence_percentage := 100;
t_forecast_designator_tab(L_rec_count).organization_id := L_ORGANIZATION_ID;
t_forecast_designator_tab(L_rec_count).forecast_designator := L_FORECAST;
--dbms_output.put_line('Return Status = '||t_forecast_interface_tab(1).process_status);
--dbms_output.put_line('Error Message = '||t_forecast_interface_tab(1).error_message);
update TEM_FORECAST_HISTORY
set process_flag = 'Y'
where ITEM = L_ITEM and FORECAST = L_FORECAST
and to_date(PERIOD_START_DATE,'dd/mm/yy') = L_PERIOD_START_DATE ;
else
update TEM_FORECAST_HISTORY
set process_flag = 'N'
where ITEM = L_ITEM and FORECAST = L_FORECAST
and to_date(PERIOD_START_DATE,'dd/mm/yy') = L_PERIOD_START_DATE ;
end if;
END LOOP;
var_bool := MRP_FORECAST_INTERFACE_PK.MRP_FORECAST_INTERFACE (t_forecast_interface_tab,
t_forecast_designator_tab);
commit;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SQLERRM || L_ITEM);
rollback;
END;
/ |
|