2. 2- Create PakedgInDatabase
CREATE OR REPLACE PACKAGE APPS.SH_webadi_item_upload_pkg
IS
l_segment1_len NUMBER;
l_segment2_len NUMBER;
PROCEDURE initialize_segment_len;
PROCEDURE cust_import_data_to_interface;
PROCEDURE cust_upload_data_to_staging (
p_segment1 VARCHAR2,
p_segment2 VARCHAR2,
p_organization_id VARCHAR2,
p_organization_name VARCHAR2,
p_description VARCHAR2,
p_inventory_item_status_code VARCHAR2,
p_template_name VARCHAR2,
p_template_id VARCHAR2,
p_primary_uom_code VARCHAR2,
p_attribute1 VARCHAR2
);
END SH_webadi_item_upload_pkg;
CREATE OR REPLACE PACKAGE BODY APPS.SH_webadi_item_upload_pkg
IS
PROCEDURE initialize_segment_len
AS
BEGIN
BEGIN
SELECT ffv.maximum_size
INTO l_segment1_len
FROM fnd_id_flex_segments_vl fifs, fnd_flex_value_sets ffv
WHERE 1 = 1
AND fifs.flex_value_set_id = ffv.flex_value_set_id
AND fifs.id_flex_code = 'MSTK'
AND fifs.enabled_flag = 'Y'
AND fifs.application_column_name = 'SEGMENT1';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_segment1_len := 0;
END;
BEGIN
SELECT ffv.maximum_size
3. INTO l_segment2_len
FROM fnd_id_flex_segments_vl fifs, fnd_flex_value_sets ffv
WHERE 1 = 1
AND fifs.flex_value_set_id = ffv.flex_value_set_id
AND fifs.id_flex_code = 'MSTK'
AND fifs.enabled_flag = 'Y'
AND fifs.application_column_name = 'SEGMENT2';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_segment2_len := 0;
END;
END;
PROCEDURE cust_import_data_to_interface
IS
CURSOR int_trans
IS
SELECT segment1,
segment2,
organization_id,
ORGANIZATION_CODE,
description,
inventory_item_status_code,
template_id,
TEMPLATE_NAME,
primary_uom_code,
attribute1,
transaction_type,
process_flag,
set_process_id
FROM SH_webadi_item_upload;
BEGIN
FOR r_int_trans IN int_trans
LOOP
INSERT INTO MTL_SYSTEM_ITEMS_INTERFACE (segment1,
segment2,
organization_id,
ORGANIZATION_CODE,
description,
inventory_item_status_code,
template_id,
TEMPLATE_NAME,
primary_uom_code,
attribute1,
transaction_type,
5. -----Load Segment Sizes from setup------
----------------------------------------
BEGIN
initialize_segment_len;
END;
----------------------------------------
----------Select Org ID-----------------
----------------------------------------
IF p_organization_name IS NOT NULL
THEN
BEGIN
SELECT hou.ORGANIZATION_ID
INTO l_organization_id
FROM hr_organization_units hou
WHERE hou.NAME = p_organization_name;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_error_message :=
l_error_message
|| ','
|| 'Please enter correct organization';
l_error_code := 'E';
END;
END IF;
IF p_organization_id IS NOT NULL
THEN
BEGIN
SELECT hou.ORGANIZATION_ID
INTO l_organization_id
FROM hr_organization_units hou
WHERE hou.ORGANIZATION_ID = p_organization_id;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_error_message :=
l_error_message
|| ','
|| 'Please enter correct organization';
l_error_code := 'E';
END;
END IF;
----------------------------------------
----------Select Template ID------------
6. ----------------------------------------
IF p_template_name IS NOT NULL
THEN
BEGIN
SELECT mit.TEMPLATE_ID
INTO l_template_id
FROM MTL_ITEM_TEMPLATES mit
WHERE mit.TEMPLATE_NAME = p_template_name;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_error_message :=
l_error_message || ',' || 'Please enter correct template';
l_error_code := 'E';
END;
END IF;
----------------------------------------
------Validate Primary UOM Code---------
----------------------------------------
IF p_primary_uom_code IS NOT NULL
THEN
BEGIN
SELECT 'Valid'
INTO l_uom_validity
FROM MTL_UNITS_OF_MEASURE_VL uom
WHERE uom.UOM_CODE = p_primary_uom_code;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
l_error_message :=
l_error_message
|| ','
|| 'Please enter the correct Primary/Secondary UOM Code';
l_error_code := 'E';
END;
END IF;
----------------------------------------
-----Validate Description entered-------
----------------------------------------
BEGIN
SELECT LENGTH (TRIM (p_description)) INTO l_item_desc_len FROM DUAL;
IF l_item_desc_len > 240
THEN
l_error_message :=
7. l_error_message
|| ','
|| 'Please ensure the description
LENGTH IS lesser THAN 240 CHARACTERS';
l_error_code := 'E';
END IF;
END;
----------------------------------------
--------Validate Item Segments----------
----------------------------------------
BEGIN
IF l_segment1_len > 0 AND LENGTH (P_SEGMENT1) > l_segment1_len
OR l_segment2_len > 0 AND LENGTH (P_SEGMENT2) > l_segment2_len
THEN
l_error_message :=
l_error_message
|| ','
|| 'Please ensure that all Item SEGMENT lengths are as per setup.';
l_error_code := 'E';
END IF;
END;
--------------------------------------------------------------------------------------------------------------
--------Condition to show error if any of the above validation picks up a data entry error--------------------
--------Condition to insert data into custom staging table if the data passes all above validations-----------
IF l_error_code = 'E'
THEN
raise_application_error (-20101, l_error_message);
ELSIF NVL (l_error_code, 'A') <> 'E'
THEN
INSERT INTO apps.SH_webadi_item_upload (segment1,
segment2,
organization_id,
description,
inventory_item_status_code,
template_id,
primary_uom_code,
attribute1,
process_flag,
transaction_type,
set_process_id,
summary_flag,
enabled_flag,
interface_status)
VALUES (TRIM (p_segment1),
8. TRIM (p_segment2),
l_organization_id,
TRIM (p_description),
TRIM (p_inventory_item_status_code),
l_template_id,
TRIM (p_primary_uom_code),
TRIM (p_attribute1),
1,
'CREATE',
1,
'N',
'Y',
'NO');
----------------------------------------------------------------------------------------------------
-----------Insert data into MTL_SYSTEM_ITEMS_INTERFACE after loading into staging table-------------
----------------------------------------------------------------------------------------------------
BEGIN
cust_import_data_to_interface;
END;
END IF;
END cust_upload_data_to_staging;
END SH_webadi_item_upload_pkg;
/
3- Create Viwe
CREATE OR REPLACE VIEW XX_INV_ORG_V
AS
SELECT AA.MASTER_ORG MASTER_ORG_NAME,
AA.ORGANIZATION_ID,
NAME Inv_ORG_Name,
AA.ORGANIZATION_CODE INV_ORG_Code
FROM MTL_PARAMETERS_VIEW aa, HR_ORGANIZATION_UNITs org
WHERE AA.ORGANIZATION_ID = org.ORGANIZATION_ID;
4- Create Integrator
9. Integrator Name: SH-Item
Internal Name: SH_ITEM
Application Inventory
The ‘Display in Create Document Page’ checkbox will be checkedandthe followingfunctionswill be addedbypressingthe highlightedbuttonsabove:
1. DesktopIntegration - Create Document
2. Create Document
DesktopIntegration - Create Document BNE_ADI_CREATE_DOCUMENT
Create Document BNE_CREATE_DOCUMENT
15. You will nowhave tomanuallyfill inall the columndisplaynames.Thesecolumnswill be linkedtoall the parametersof the APIat a laterstage.All the columnswill be
namedas perthe 10 parametersof the APIas follows:
1. SEGMENT1
2. SEGMENT2
3.Organization_ID
4. ORGANIZATION_NAME
5. DESCRIPTION
6. INVENTORY_ITEM_STATUS_CODE
7. Template_ID
8. TEMPLATE_NAME
9. PRIMARY_UOM_CODE
10. Attribute1
In ParameterListAddThe follows:
Parameter List: WebADI: Download"TextFile"Parameters
16. Choose ‘FromTemplate’ and press‘Create’.The followingwill appear.Ensure youruploadersetupisasfollows:
26. Enter the requireddetailsasfollows:
Mapping Name: SH_ITEMS_MAP
Mapping Key: SH_ITEMS_MAP
Numberof Columns 10
Click‘Next’.The followingwillappear:
SelectFromLOV For Both Side To Map The Template LayoutAndIntegrator
27. You will nowenterall the Source andTarget columnson thispage.
All 10 parametersof the APIsetupinthe WebADIwill be associatedwiththe contentcolumnsof the WebADIsheetonthispage.
Aftermappingisdefinedforall the columns,clickon ‘Apply’.
Afterthe completionof thisstep,youare nowreadyto uploaditemsthroughWebADI.