CREATE OR REPLACE FUNCTION XXTTK_ITEM_COST (P_INV_ITEM_ID IN MTL_SYSTEM_ITEMS_B.INVENTORY_ITEM_ID%TYPE,
P_INV_ORG_ID IN MTL_SYSTEM_ITEMS_B.ORGANIZATION_ID%TYPE )
RETURN NUMBER
AS
L_PERIOD gmf_period_statuses.PERIOD_CODE%TYPE;
L_COST NUMBER;
BEGIN
BEGIN
select max(c.period_code)INTO L_PERIOD FROM cm_cmpt_dtl_vw a,
mtl_system_items b,
gmf_period_statuses c,mtl_lot_numbers mln
WHERE 1 = 1 --a.organization_id = :org_id
-- AND b.organization_id >= in ( 250,178)
AND a.inventory_item_id = b.inventory_item_id
AND a.period_id = c.period_id
AND a.inventory_item_id = mln.inventory_item_id
AND a.organization_id = mln.organization_id
AND a.inventory_item_id=P_INV_ITEM_ID;
dbms_output.put_line('L_PERIOD '||L_PERIOD);
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'No Data Found While Capturing the item Cost Period');
dbms_output.put_line('No Data Found While Capturing the item Cost Period');
end;
IF L_PERIOD IS NOT NULL THEN
BEGIN
SELECT SUM (cmpnt_cost) INTO L_COST
FROM cm_cmpt_dtl_vw a,
mtl_system_items b,
gmf_period_statuses c
--mtl_lot_numbers mln
WHERE 1 = 1 --a.organization_id = :org_id
AND b.organization_id = P_INV_ORG_ID --1238
AND a.inventory_item_id = b.inventory_item_id
AND a.period_id = c.period_id
-- AND a.inventory_item_id = mln.inventory_item_id
--AND a.organization_id = mln.organization_id
AND c.period_code =L_PERIOD
AND b.inventory_item_id=P_INV_ITEM_ID
GROUP BY a.inventory_item_id,
segment1,
a.period_id,
b.description,
primary_uom_code;
dbms_output.put_line('L_COST '||L_COST);
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'No Data Found While Capturing the item Cost Period');
dbms_output.put_line('No Data Found While Capturing the item Cost Period');
end;
end if;
Return L_COST;
EXCEPTION WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'Error IN Main XXTTK_ITEM_COST function');
dbms_output.put_line('Error IN Main XXTTK_ITEM_COST function');
Return NULL;
end;
P_INV_ORG_ID IN MTL_SYSTEM_ITEMS_B.ORGANIZATION_ID%TYPE )
RETURN NUMBER
AS
L_PERIOD gmf_period_statuses.PERIOD_CODE%TYPE;
L_COST NUMBER;
BEGIN
BEGIN
select max(c.period_code)INTO L_PERIOD FROM cm_cmpt_dtl_vw a,
mtl_system_items b,
gmf_period_statuses c,mtl_lot_numbers mln
WHERE 1 = 1 --a.organization_id = :org_id
-- AND b.organization_id >= in ( 250,178)
AND a.inventory_item_id = b.inventory_item_id
AND a.period_id = c.period_id
AND a.inventory_item_id = mln.inventory_item_id
AND a.organization_id = mln.organization_id
AND a.inventory_item_id=P_INV_ITEM_ID;
dbms_output.put_line('L_PERIOD '||L_PERIOD);
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'No Data Found While Capturing the item Cost Period');
dbms_output.put_line('No Data Found While Capturing the item Cost Period');
end;
IF L_PERIOD IS NOT NULL THEN
BEGIN
SELECT SUM (cmpnt_cost) INTO L_COST
FROM cm_cmpt_dtl_vw a,
mtl_system_items b,
gmf_period_statuses c
--mtl_lot_numbers mln
WHERE 1 = 1 --a.organization_id = :org_id
AND b.organization_id = P_INV_ORG_ID --1238
AND a.inventory_item_id = b.inventory_item_id
AND a.period_id = c.period_id
-- AND a.inventory_item_id = mln.inventory_item_id
--AND a.organization_id = mln.organization_id
AND c.period_code =L_PERIOD
AND b.inventory_item_id=P_INV_ITEM_ID
GROUP BY a.inventory_item_id,
segment1,
a.period_id,
b.description,
primary_uom_code;
dbms_output.put_line('L_COST '||L_COST);
EXCEPTION
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'No Data Found While Capturing the item Cost Period');
dbms_output.put_line('No Data Found While Capturing the item Cost Period');
end;
end if;
Return L_COST;
EXCEPTION WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'Error IN Main XXTTK_ITEM_COST function');
dbms_output.put_line('Error IN Main XXTTK_ITEM_COST function');
Return NULL;
end;
Such a nice blog, I really like what you write in this blog, I also have some relevant Information about Best HR Training In Hyderabad | Hr training institute in Hyderabad! if you want more information.
ReplyDeleteOracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
Oracle Fusion Financials Online Training
Big Data and Hadoop Training In Hyderabad
hello, you know your article is amazing and this article is helping for me and everyone and thanks for sharing information tq
ReplyDeleteOracle Training in Delhi
Thanks for sharing this unique useful information content with us.
ReplyDeleteOracle DBA Training