Sie sind auf Seite 1von 5

­­API Example to Update Master Item

DECLARE
l_inventory_item_id NUMBER;
l_organization_id NUMBER;
­­l_desc                      VARCHAR2(100); 
l_item_num VARCHAR2 (50);
­­l_long_description    VARCHAR2(200);
­­l_so_tran_flag          VARCHAR2 (1);
­­l_attribute5              VARCHAR2 (20);
l_fixed_lead_time Number;
x_inventory_item_id NUMBER;
x_organization_id NUMBER;
x_return_status VARCHAR2 (300);
x_msg_count NUMBER;
x_msg_data VARCHAR2 (4000);
­­Profile
l_user_id NUMBER := 1130; ­­ user id
l_resp_id NUMBER := 50618; ­­ Responsibility id
l_application_id NUMBER := FND_PROFILE.VALUE('RESP_APPL_ID'); ­­ 'Inventory'
­­capture record
cursor lead_time is
select inventory_item_id, organization_id, segment1
from mtl_system_items
where organization_id = 141
and substr(segment1,1,2) = 'PM'
and fixed_lead_time is null
­­and rownum < 28001
order by inventory_item_id;
BEGIN
FND_GLOBAL.APPS_INITIALIZE(l_user_id, l_resp_id, l_application_id);
mo_global.init('INV');
for j in lead_time
loop
l_inventory_item_id := j.inventory_item_id;
l_organization_id := j.organization_id;
l_fixed_lead_time := 1;­­> substr FG = 2, substr PF = 1
­­l_desc                      := 'New Description'; 
l_item_num := j.segment1;
­­l_long_description    :=  'New Long Description';
­­l_so_tran_flag           := 'Y';
­­ l_attribute5               := 'N';
­­
apps.ego_item_pub.process_item
(p_api_version => 1.0,
p_init_msg_list => 'T',
p_commit => 'T',
p_transaction_type => 'UPDATE',
p_inventory_item_id => l_inventory_item_id,
p_organization_id => l_organization_id,
p_fixed_lead_time => l_fixed_lead_time,
p_segment1 => l_item_num,
­­p_description               =>    l_desc,
­­p_long_description       =>    l_long_description,
­­p_so_transactions_flag   => l_so_tran_flag,
­­p_attribute5                   => l_attribute5,
x_inventory_item_id => x_inventory_item_id,
x_organization_id => x_organization_id,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data
);
IF (x_return_status <> apps.fnd_api.g_ret_sts_success)
THEN
DBMS_OUTPUT.PUT_LINE( 'Item Attribute Update API Error'|| x_return_status );
ELSE
DBMS_OUTPUT.PUT_LINE('Item Attribute Update API Success' || x_return_status);
END IF;
End loop;
END;
­­API Example to Assign Item to Inventory Organization
CREATE OR REPLACE PROCEDURE itemassign (p_organization_code IN VARCHAR2, p_organization_id IN Number) AS
l_api_version NUMBER := 1.0;
l_commit VARCHAR2(2) := FND_API.G_FALSE;
l_INIT_MSG_LIST VARCHAR2(2) := FND_API.G_FALSE;
­­x_message_list           Error_Handler.Error_Tbl_Type;
x_return_status VARCHAR2(2);
x_msg_count NUMBER := 0;

l_user_id NUMBER := 1130; ­­ user id


l_resp_id NUMBER := 50618; ­­ Responsibility id
l_application_id NUMBER := FND_PROFILE.VALUE('RESP_APPL_ID'); ­­ 'Inventory'
l_rowcnt NUMBER := 1;
­­capture data to process
CURSOR csr_org_items IS
SELECT inventory_item_id, segment1, primary_uom_code
FROM mtl_system_items
WHERE ORGANIZATION_ID = 122
AND segment1 NOT in (SELECT segment1 FROM MTL_SYSTEM_ITEMS
WHERE ORGANIZATION_ID in (141, 121));
­­
BEGIN
FND_GLOBAL.APPS_INITIALIZE(l_user_id, l_resp_id, l_application_id);
mo_global.init('INV');

FOR j IN csr_org_items LOOP


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 => j.inventory_item_id
, P_ITEM_NUMBER => j.segment1
, P_ORGANIZATION_ID => p_organization_id
, P_ORGANIZATION_CODE => p_organization_code
, P_PRIMARY_UOM_CODE => j.primary_uom_code
, X_RETURN_STATUS => X_RETURN_STATUS
, X_MSG_COUNT => X_MSG_COUNT
);
END LOOP;

IF NVL(x_return_status, 'E') <> 'S' THEN


DBMS_OUTPUT.PUT_LINE('Error Message: '||x_return_status);
ROLLBACK;
ELSE
DBMS_OUTPUT.PUT_LINE('Sukses');
COMMIT;
END IF;

EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Exception Occured :');
DBMS_OUTPUT.PUT_LINE(SQLCODE ||':'||SQLERRM);
END;

Das könnte Ihnen auch gefallen