0% found this document useful (0 votes)
131 views2 pages

Asset Number API PKG

This PL/SQL block declares variables and cursors to loop through asset data and insert corresponding asset records. It handles exceptions when item, department, or location details are not found. For each asset, it calls an API to insert an asset number record, passing parameter values from the asset data. Error messages are output.

Uploaded by

rohit01234567890
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
131 views2 pages

Asset Number API PKG

This PL/SQL block declares variables and cursors to loop through asset data and insert corresponding asset records. It handles exceptions when item, department, or location details are not found. For each asset, it calls an API to insert an asset number record, passing parameter values from the asset data. Error messages are output.

Uploaded by

rohit01234567890
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

DECLARE

g_return_status VARCHAR2(1 BYTE);


g_msg_count NUMBER;
g_msg_data VARCHAR2(2000 BYTE);
g_object_id NUMBER;
--------
v_org_id NUMBER := 152;
v_loc_id NUMBER;
v_item_id NUMBER;
v_dep_id NUMBER;
msg VARCHAR2(32000);

CURSOR asset_cur IS
SELECT *
FROM xxbml.xx_asset_num
WHERE 1 = 1
-- and ASSET_NUMBER <> 'MD-CCR-40HP Motor-1'
and OWNING_DEPT = 'KD_PP_DEPT'
AND status_flag IS NULL;
BEGIN
fnd_global.apps_initialize(user_id => 1195, resp_id => 50778, resp_appl_id =>
426);

FOR i IN asset_cur LOOP


msg := NULL;

BEGIN
SELECT msi.inventory_item_id
INTO v_item_id
FROM mtl_system_items_b msi
WHERE msi.segment1 = i.asset_group
AND msi.organization_id = v_org_id;
EXCEPTION
WHEN OTHERS THEN
msg := msg || ' Item Not Found ';
dbms_output.put_line('Item Not Found' || ' ' ||
g_return_status);
END;

BEGIN
SELECT bd.department_id
INTO v_dep_id
FROM bom_departments bd
WHERE bd.department_code = i.owning_dept
AND organization_id = v_org_id;
EXCEPTION
WHEN OTHERS THEN
msg := msg || ' Owning Department Not Found ';
dbms_output.put_line('Owning Department Not Found' || ' ' ||
g_return_status);
END;

BEGIN
SELECT location_id
INTO v_loc_id
FROM apps.mtl_eam_locations
WHERE location_codes = i.area
AND organization_id = v_org_id;
EXCEPTION
WHEN OTHERS THEN
msg := msg || 'Location Not Found ';
dbms_output.put_line('Location Not Found' || ' ' ||
g_return_status);
END;

IF msg IS NULL THEN


dbms_output.put_line('Api Starts' || ' ' || g_return_status);
eam_assetnumber_pub.insert_asset_number(p_api_version => 1.0,
p_init_msg_list =>
fnd_api.g_false,
p_commit => fnd_api.g_false,
p_validation_level =>
fnd_api.g_valid_level_full,
x_return_status =>
g_return_status,
x_msg_count => g_msg_count,
x_msg_data => g_msg_data,
x_object_id => g_object_id,
p_inventory_item_id =>
v_item_id,
p_serial_number =>
SUBSTR(i.asset_number, 1, 28),
p_current_status => 3,
p_descriptive_text =>
i.asset_desc,
p_current_organization_id =>
v_org_id,
p_wip_accounting_class_code =>
NULL,
p_maintainable_flag => 'Y',
p_owning_department_id =>
v_dep_id,
p_eam_location_id => v_loc_id);
dbms_output.put_line('Asset Number Status' || ' ' ||
g_return_status);
dbms_output.put_line('Error Message' || g_msg_data);
dbms_output.put_line('Message' || g_msg_count);

IF g_msg_count > 0 THEN


FOR i IN 1 .. g_msg_count LOOP
dbms_output.put_line(i || '. ' ||
SUBSTR(fnd_msg_pub.get(p_encoded => fnd_api.g_false), 1, 255));
END LOOP;
END IF;
END IF;
END LOOP;

-- update xxbml.xx_ASSET_num AST


-- set AST.STATUS_FLAG = 'Y'
-- where AST.ASSET_NUMBER = i.ASSET_NUMBER ;
COMMIT;
END;

You might also like