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

HJGJ

The document contains code to select organization definitions from a database table and assign inventory items to organizations. It declares variables, initializes APIs, loops through a record collection to assign each inventory item to the corresponding organization, and handles exceptions.

Uploaded by

Sayed Batem
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)
18 views2 pages

HJGJ

The document contains code to select organization definitions from a database table and assign inventory items to organizations. It declares variables, initializes APIs, loops through a record collection to assign each inventory item to the corresponding organization, and handles exceptions.

Uploaded by

Sayed Batem
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

select * from org_organization_definitions where organization_name like '%PFIL%'

and organization_id in (726, 311)r

DECLARE
Vorg_id number := 96; --master org id
/*96 is the org id for 002 i.e. from which we want to copy */
g_user_id fnd_user.user_id%TYPE :=NULL;
l_appl_id fnd_application.application_id%TYPE;
l_resp_id fnd_responsibility_tl.responsibility_id%TYPE;
l_api_version NUMBER := 1.0;
l_init_msg_list VARCHAR2(2) := fnd_api.g_false;
l_commit VARCHAR2(2) := FND_API.G_FALSE;
x_message_list error_handler.error_tbl_type;
x_return_status VARCHAR2(2);
x_msg_count NUMBER := 0;
BEGIN
SELECT fa.application_id
INTO l_appl_id
FROM fnd_application fa
WHERE fa.application_short_name = 'INV';
SELECT fr.responsibility_id
INTO l_resp_id
FROM fnd_application fa, fnd_responsibility_tl fr
WHERE fa.application_short_name = 'INV'
AND fa.application_id = fr.application_id
AND UPPER (fr.responsibility_name) = 'INVENTORY';
DBMS_OUTPUT.PUT_LINE('HA HA HI HI');
fnd_global.apps_initialize (g_user_id, l_resp_id, l_appl_id);
for rec1 in(select b.INVENTORY_ORG_CODE org_code, b.INVENTORY_ORG_ID org_id,
a.inventory_item_id ,a.segment1||'.'||a.segment2||'.'||a.segment3||'.'||a.segment4
item_number,
a.primary_uom_code from MTL_SYSTEM_ITEMS a, XX_ITEM_STG_TBLM B
where B.inventory_org_code='900' and a.organization_id=96
and a.segment1=b.item_segment1 and a.segment2=b.item_segment2
and a.segment3=b.item_segment3 and a.segment4=b.item_segment4 ) loop
begin
/* may need this validation . and a.inventory_org_id||a.item_segment1||
a.item_segment2||a.item_segment3
not in(select distinct
organization_id||segment1||segment2||segment3 from MTL_SYSTEM_ITEMS where
organization_id!=84)) */
EGO_ITEM_PUB.ASSIGN_ITEM_TO_ORG(
P_API_VERSION => l_api_version
, P_INIT_MSG_LIST => l_init_msg_list
, P_COMMIT => l_commit
, P_INVENTORY_ITEM_ID => rec1.inventory_item_id
, p_item_number => rec1.item_number
, p_organization_id => rec1.org_id
, P_ORGANIZATION_CODE => rec1.org_code
, P_PRIMARY_UOM_CODE => rec1.primary_uom_code
, X_RETURN_STATUS => x_return_status
, X_MSG_COUNT => x_msg_count
);
DBMS_OUTPUT.PUT_LINE('Status: '||x_return_status);
IF (x_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
DBMS_OUTPUT.PUT_LINE('Error Messages :');
Error_Handler.GET_MESSAGE_LIST(x_message_list=>x_message_list);
FOR j IN 1..x_message_list.COUNT LOOP
DBMS_OUTPUT.PUT_LINE(x_message_list(j).message_text);
END LOOP;
END IF;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Exception Occured :');
DBMS_OUTPUT.PUT_LINE(SQLCODE ||':'||SQLERRM);
end;
end loop;
END;

You might also like