Item Interface/Conversion Using API Item conversion through Api

Item Interface/Conversion Using API



DECLARE
   l_item_table          EGO_Item_PUB.Item_Tbl_Type;
   x_item_table          EGO_Item_PUB.Item_Tbl_Type;
   x_Inventory_Item_Id   mtl_system_items_b.inventory_item_id%TYPE;
   x_Organization_Id     mtl_system_items_b.organization_id%TYPE;
   x_return_status       VARCHAR2(1);
   x_msg_count           NUMBER(10);
   x_msg_data            VARCHAR2(1000);
   x_message_list        Error_Handler.Error_Tbl_Type;
BEGIN

   --Setting FND global variables.
   --Replace MFG user name with appropriate user name.

   FND_GLOBAL.APPS_INITIALIZE(USER_ID=>&userid,
                              RESP_ID=>NULL,
                              RESP_APPL_ID=>NULL
                              );

   --FIRST Item definition
   l_item_table(1).Transaction_Type            := 'CREATE'; -- Replace this with 'UPDATE' for update transaction.
   l_item_table(1).Segment1                        := 'TEST1';
   l_item_table(1).Description                 := 'TEST ITEM';
   l_item_table(1).Organization_Code           := '&masterorg';
   l_item_table(1).Template_Name               := 
'&template';
   l_item_table(1).Inventory_Item_Status_Code  := 'Active';
   l_item_table(1).Long_Description            := 'Create test item';


   DBMS_OUTPUT.PUT_LINE('=====================================');
   DBMS_OUTPUT.PUT_LINE('Calling EGO_ITEM_PUB.Process_Items API');

   EGO_ITEM_PUB.Process_Items(
         p_api_version           => 1.0
         ,p_init_msg_list         => FND_API.g_TRUE
         ,p_commit                => FND_API.g_TRUE
         ,p_Item_Tbl              => l_item_table
         ,x_Item_Tbl              => x_item_table
         ,x_return_status         => x_return_status
         ,x_msg_count             => x_msg_count);

   DBMS_OUTPUT.PUT_LINE('==================================');
   DBMS_OUTPUT.PUT_LINE('Return Status ==>'||x_return_status);

   IF (x_return_status = FND_API.G_RET_STS_SUCCESS) THEN
      FOR i IN 1..x_item_table.COUNT LOOP
         DBMS_OUTPUT.PUT_LINE('Inventory Item Id :'||to_char(x_item_table(i).Inventory_Item_Id));
  DBMS_OUTPUT.PUT_LINE('Organization Id   :'||to_char(x_item_table(i).Organization_Id));
      END LOOP;
   ELSE
      DBMS_OUTPUT.PUT_LINE('Error Messages :');
      Error_Handler.GET_MESSAGE_LIST(x_message_list=>x_message_list);
      FOR i IN 1..x_message_list.COUNT LOOP
         DBMS_OUTPUT.PUT_LINE(x_message_list(i).message_text);
      END LOOP;
   END IF;
   DBMS_OUTPUT.PUT_LINE('==================================');
EXCEPTION
   WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE('Exception Occured :');
      DBMS_OUTPUT.PUT_LINE(SQLCODE ||':'||SQLERRM);
      DBMS_OUTPUT.PUT_LINE('=====================================');
END;

Post a Comment