Join the OracleApps88 Telegram group @OracleApps88to get more information on Oracle EBS R12/Oracle Fusion applications.

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.

Wednesday, July 9, 2014

Oracle Inventory Item Creation With API

-------->>>=========================================================================
DECLARE
   l_inventory_item_id   NUMBER;
   l_organization_id     NUMBER;
   l_return_status       VARCHAR2 (4000);
   l_msg_data            VARCHAR2 (4000);
   l_msg_count           NUMBER;
   l_msg_index           NUMBER;
   API_ERROR             EXCEPTION;
BEGIN
   FND_GLOBAL.APPS_INITIALIZE (USER_ID        => 1318,  --> OPERATIONS
                               RESP_ID        => 50583, --> Inventory, Vision Operations (USA)
                               RESP_APPL_ID   => 401);  --> Inventory

   EGO_ITEM_PUB.PROCESS_ITEM
    (
       p_api_version                  => 1.0
      ,p_init_msg_list                => 'T'
      ,p_commit                       => 'T'
      ,p_Transaction_Type             => 'CREATE'                    -- UPDATE FOR Updating item
      ,p_segment1                     => 'XX_ITEM_ORACLE_APPS-003'   -- ITEM CODE
      ,p_description                  => 'XX Oracle Apps Test Item'  -- ITEM DESCRIPTION
      ,p_long_description             => 'XX Oracle Apps Test Item'  -- ITEM LONG DESCRIPTION
      ,p_organization_id              => 204                         -- Vision Operations
      ,p_template_id                  => 2                           -- Purchased Item -- select * from mtl_item_templates_vl
      ,p_Inventory_Item_Status_Code   => 'Active'
      ,p_approval_status              => 'A'
      ,x_inventory_item_id            => l_inventory_item_id
      ,x_organization_id              => l_organization_id
      ,x_return_status                => l_return_status
      ,x_msg_count                    => l_msg_count
      ,x_msg_data                     => l_msg_data
    );

    IF l_return_status = FND_API.G_RET_STS_SUCCESS
    THEN       
        DBMS_OUTPUT.PUT_LINE ('Item is Created Successfully, Inventory Item ID : '||l_inventory_item_id);
        COMMIT;           
    ELSE
        DBMS_OUTPUT.PUT_LINE ('Item Creation is Failed');
        RAISE API_ERROR;
        ROLLBACK;
    END IF;

-------->>>------------------------------------------------------------------------
--> HANDLE EXCEPTIONS
EXCEPTION
   WHEN API_ERROR
   THEN
      FOR i IN 1 .. l_msg_count
      LOOP
        DBMS_OUTPUT.put_line (SUBSTR (FND_MSG_PUB.Get (p_encoded => FND_API.G_FALSE),1,255));
        DBMS_OUTPUT.PUT_LINE ('message is: ' || l_msg_data);
      END LOOP;
     
   WHEN OTHERS
   THEN
      FOR i IN 1 .. l_msg_count
      LOOP
        DBMS_OUTPUT.put_line (SUBSTR (FND_MSG_PUB.Get (p_encoded => FND_API.G_FALSE),1,255));
        DBMS_OUTPUT.PUT_LINE ('message is: ' || l_msg_data);
      END LOOP;
     
END ;

-------->>>=========================================================================

1 comment:

dinesh said...

Hi Raju , Its a great post i got it worked but why doesnt l_msg_data return any error message
I tried passing the same segment1 2nd time in the same organization , so it errored out but the thing is l_msg_data doesnot output any error message like duplicate item or some error message please help

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect