CREATE OR REPLACE PACKAGE BODY APPS.xx_item_related_data
IS
/* p_bussiness is nothing but business lines acording to your organization eg: two wheeler, fourwheeler,..... */
PROCEDURE main (errbuff OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY NUMBER,
p_business IN VARCHAR2)
IS
CURSOR cur_main
IS
SELECT * FROM xxhmi_item_related;
BEGIN
BEGIN
DELETE FROM xxhmi_item_related;
COMMIT;
END;
INSERT INTO xxhmi_item_related (related_items)
(SELECT k.segment1 || '|' || K.description || '|'
|| (SELECT RTRIM (
XMLAGG(XMLELEMENT (
e,
(SELECT DISTINCT segment1
FROM mtl_system_items_b
WHERE inventory_item_id =
a.related_item_id)
|| '|'
|| (SELECT DISTINCT
description
FROM mtl_system_items_b
WHERE inventory_item_id =
a.related_item_id)
|| '|'
)).EXTRACT ('//text()'),
'|'
)
|| '|'
supersession
FROM mtl_related_items a
WHERE organization_id = 86
AND inventory_item_id = k.inventory_item_id)
related_items
FROM mtl_system_items_b k,
(SELECT /*+ INDEX(FFSV FND_ID_FLEX_STRUCTURES_U1)*/
*
FROM apps.mtl_categories_b mc,
apps.fnd_id_flex_structures ffsv,
apps.mtl_item_categories mic
WHERE ffsv.id_flex_num = mc.structure_id
AND mic.category_id = mc.category_id
-- AND mic.inventory_item_id = 65354
-- msi.inventory_item_id
AND mic.organization_id = 86
-- AND ffsv.id_flex_structure_code =
-- 'INV_CATEGORY'
) c
WHERE 1 = 1
-- and inventory_item_id = 8990
AND K.organization_id = 86
AND K.inventory_item_id IN (SELECT inventory_item_id
FROM mtl_related_items
WHERE organization_id = 86)
-- AND mri.organization_id = 86
AND K.inventory_item_id = c.inventory_item_id
AND K.organization_id = c.organization_id
AND c.segment10 = p_business -- as per your bussiness lines
) -- ;
COMMIT;
NULL;
BEGIN
fnd_file.put_line (
fnd_file.output,
'Part No'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN1'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN2'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN3'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN4'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN5'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN6'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN7'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN8'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN9'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN10'
|| '|'
|| 'DESCRIPTION'
);
FOR i IN cur_main
LOOP
fnd_file.put_line (fnd_file.output, i.related_items);
-- DBMS_OUTPUT.put_line (i.RELATED_ITEMS);
END LOOP;
END;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put ('Invalid item' || SQLERRM || SQLCODE);
END;
END xxhmi_item_related_data;
/
IS
/* p_bussiness is nothing but business lines acording to your organization eg: two wheeler, fourwheeler,..... */
PROCEDURE main (errbuff OUT NOCOPY VARCHAR2,
retcode OUT NOCOPY NUMBER,
p_business IN VARCHAR2)
IS
CURSOR cur_main
IS
SELECT * FROM xxhmi_item_related;
BEGIN
BEGIN
DELETE FROM xxhmi_item_related;
COMMIT;
END;
INSERT INTO xxhmi_item_related (related_items)
(SELECT k.segment1 || '|' || K.description || '|'
|| (SELECT RTRIM (
XMLAGG(XMLELEMENT (
e,
(SELECT DISTINCT segment1
FROM mtl_system_items_b
WHERE inventory_item_id =
a.related_item_id)
|| '|'
|| (SELECT DISTINCT
description
FROM mtl_system_items_b
WHERE inventory_item_id =
a.related_item_id)
|| '|'
)).EXTRACT ('//text()'),
'|'
)
|| '|'
supersession
FROM mtl_related_items a
WHERE organization_id = 86
AND inventory_item_id = k.inventory_item_id)
related_items
FROM mtl_system_items_b k,
(SELECT /*+ INDEX(FFSV FND_ID_FLEX_STRUCTURES_U1)*/
*
FROM apps.mtl_categories_b mc,
apps.fnd_id_flex_structures ffsv,
apps.mtl_item_categories mic
WHERE ffsv.id_flex_num = mc.structure_id
AND mic.category_id = mc.category_id
-- AND mic.inventory_item_id = 65354
-- msi.inventory_item_id
AND mic.organization_id = 86
-- AND ffsv.id_flex_structure_code =
-- 'INV_CATEGORY'
) c
WHERE 1 = 1
-- and inventory_item_id = 8990
AND K.organization_id = 86
AND K.inventory_item_id IN (SELECT inventory_item_id
FROM mtl_related_items
WHERE organization_id = 86)
-- AND mri.organization_id = 86
AND K.inventory_item_id = c.inventory_item_id
AND K.organization_id = c.organization_id
AND c.segment10 = p_business -- as per your bussiness lines
) -- ;
COMMIT;
NULL;
BEGIN
fnd_file.put_line (
fnd_file.output,
'Part No'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN1'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN2'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN3'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN4'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN5'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN6'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN7'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN8'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN9'
|| '|'
|| 'DESCRIPTION'
|| '|'
|| 'SUPERCESSION PN10'
|| '|'
|| 'DESCRIPTION'
);
FOR i IN cur_main
LOOP
fnd_file.put_line (fnd_file.output, i.related_items);
-- DBMS_OUTPUT.put_line (i.RELATED_ITEMS);
END LOOP;
END;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put ('Invalid item' || SQLERRM || SQLCODE);
END;
END xxhmi_item_related_data;
/
No comments:
Post a Comment