Blog Archives

Stock Locator API creation in Oracle Apps – Error

A requirement has been given to create Stock Locator by the below navigation

Warehouse Manager Responsibility –> Setup –> Warehouse Configuration –> Warehouses –> Stock Locators

For this requirement I have searched and got the document ID(Doc ID 1905843.1, Doc ID 297598.1) for Sample Script from Oracle and I have started to create. Below is the code

DECLARE
l_msg_data VARCHAR2 (100);
l_msg_count NUMBER;
l_return_status VARCHAR2 (1);
l_locator_id NUMBER;
l_locator_exists VARCHAR2 (1);
-- l_org_id NUMBER := 1884;
l_org_id NUMBER := 221;
-- l_organization_code VARCHAR2(10) := 'W1';
l_organization_code VARCHAR2 (10) := 'A01';
l_sub_code VARCHAR2 (10) := 'A01-WMSDIP';
l_concatenated_segments VARCHAR2 (100) := 'P02-01-001--';
l_user_id NUMBER := 0;
l_resp_id NUMBER := 52436;
l_resp_appl_id NUMBER := 385;
BEGIN
/*
* APPS_INITIALIZE needed because Project/Task Valuesets indirectly use
* profile options
*/
FND_GLOBAL.APPS_INITIALIZE (l_user_id, l_resp_id, l_resp_appl_id);

/*
* Create 5 Project Locators Stor.41.1...to BULK.46.5 in Organization 'P1' (id 607)
* and subinventory 'Stores' for the Project 'Pacific Pumps' with Project id 1716
*
*/

FOR i IN 1 .. 2
LOOP
    /*
    * p_concatenated_segments should always be the value that you see in the desktop forms
    * not internal ids
    * If the desktop form shows 'Stor.1.1.Pacific Pumps.' -- the same should be passed to
    * the API
    *
    */
    l_concatenated_segments := 'P02-01-001--';
    FND_MSG_PUB.INITIALIZE;

    /*
    * First create physical locators first and use the returned value of x_inventory_location_id'
    * in the next call
    *
    */

    DBMS_OUTPUT.PUT_LINE ('Trying to create ' || l_concatenated_segments);

    INV_LOC_WMS_PUB.CREATE_LOCATOR (
        x_return_status              => l_return_status,
        x_msg_count                  => l_msg_count,
        x_msg_data                   => l_msg_data,
        x_inventory_location_id      => l_locator_id,
        x_locator_exists             => l_locator_exists,
        p_organization_id            => l_org_id,
        p_organization_code          => l_organization_code,
        p_concatenated_segments      => l_concatenated_segments,
        p_description                => 'Created by Script',
        p_inventory_location_type    => 3,              -- Storage locator
        p_picking_order              => NULL,
        p_location_maximum_units     => NULL,
        p_subinventory_code          => l_sub_code,
        p_location_weight_uom_code   => NULL,
        p_max_weight                 => NULL,
        p_volume_uom_code            => NULL,
        p_max_cubic_area             => NULL,
        p_x_coordinate               => NULL,
        p_y_coordinate               => NULL,
        p_z_coordinate               => NULL,
        p_physical_location_id       => NULL,
        p_pick_uom_code              => NULL,
        p_dimension_uom_code         => NULL,
        p_length                     => NULL,
        p_width                      => NULL,
        p_height                     => NULL,
        p_status_id                  => 1,      -- Default status 'Active'
        p_dropping_order             => NULL);

    DBMS_OUTPUT.PUT_LINE ('Return Status ' || l_return_status);

    IF l_return_status IN ('E', 'U')
    THEN
        DBMS_OUTPUT.PUT_LINE ('# of Errors ' || l_msg_count);

        IF l_msg_count = 1
        THEN
            DBMS_OUTPUT.PUT_LINE ('Error ' || l_msg_data);
        ELSE
            FOR i IN 1 .. l_msg_count
            LOOP
                DBMS_OUTPUT.PUT_LINE (
                    'Error ' || FND_MSG_PUB.GET (i, 'F'));
            END LOOP;
        END IF;
    ELSE
        DBMS_OUTPUT.PUT_LINE ('Locator Id is ' || l_locator_id);
    END IF;
END LOOP;
END;

When executing I was getting the below Error

Trying to create P02-01-001–
Return Status U
# of Errors 1
Error Could not create locator.

After Searching the Error I found the fix in Oracle Document(Doc ID 1600311.1). So now I have included the fnd_profile.put(‘MFG_ORGANIZATION_ID’,ORGID) ; in my code and when executed the error was not coming.

Below is the full code

DECLARE
l_msg_data VARCHAR2 (100);
l_msg_count NUMBER;
l_return_status VARCHAR2 (1);
l_locator_id NUMBER;
l_locator_exists VARCHAR2 (1);
-- l_org_id NUMBER := 1884;
l_org_id NUMBER := 221;
-- l_organization_code VARCHAR2(10) := 'W1';
l_organization_code VARCHAR2 (10) := 'A01';
l_sub_code VARCHAR2 (10) := 'A01-WMSDIP';
l_concatenated_segments VARCHAR2 (100) := 'P02-01-001--';
l_user_id NUMBER := 0;
l_resp_id NUMBER := 52436;
l_resp_appl_id NUMBER := 385;
BEGIN
/*
* APPS_INITIALIZE needed because Project/Task Valuesets indirectly use
* profile options
*/
FND_GLOBAL.APPS_INITIALIZE (l_user_id, l_resp_id, l_resp_appl_id);

/*
* Create 5 Project Locators Stor.41.1...to BULK.46.5 in Organization 'P1' (id 607)
* and subinventory 'Stores' for the Project 'Pacific Pumps' with Project id 1716
*
*/

FOR i IN 1 .. 2
LOOP
    /*
    * p_concatenated_segments should always be the value that you see in the desktop forms
    * not internal ids
    * If the desktop form shows 'Stor.1.1.Pacific Pumps.' -- the same should be passed to
    * the API
    *
    */
    l_concatenated_segments := 'P02-01-001--';
    FND_MSG_PUB.INITIALIZE;
    fnd_profile.put ('MFG_ORGANIZATION_ID', l_org_id); -- Code to Resolve the Error
    /*
    * First create physical locators first and use the returned value of x_inventory_location_id'
    * in the next call
    *
    */

    DBMS_OUTPUT.PUT_LINE ('Trying to create ' || l_concatenated_segments);

    INV_LOC_WMS_PUB.CREATE_LOCATOR (
        x_return_status              => l_return_status,
        x_msg_count                  => l_msg_count,
        x_msg_data                   => l_msg_data,
        x_inventory_location_id      => l_locator_id,
        x_locator_exists             => l_locator_exists,
        p_organization_id            => l_org_id,
        p_organization_code          => l_organization_code,
        p_concatenated_segments      => l_concatenated_segments,
        p_description                => 'Created by Script',
        p_inventory_location_type    => 3,              -- Storage locator
        p_picking_order              => NULL,
        p_location_maximum_units     => NULL,
        p_subinventory_code          => l_sub_code,
        p_location_weight_uom_code   => NULL,
        p_max_weight                 => NULL,
        p_volume_uom_code            => NULL,
        p_max_cubic_area             => NULL,
        p_x_coordinate               => NULL,
        p_y_coordinate               => NULL,
        p_z_coordinate               => NULL,
        p_physical_location_id       => NULL,
        p_pick_uom_code              => NULL,
        p_dimension_uom_code         => NULL,
        p_length                     => NULL,
        p_width                      => NULL,
        p_height                     => NULL,
        p_status_id                  => 1,      -- Default status 'Active'
        p_dropping_order             => NULL);

    DBMS_OUTPUT.PUT_LINE ('Return Status ' || l_return_status);

    IF l_return_status IN ('E', 'U')
    THEN
        DBMS_OUTPUT.PUT_LINE ('# of Errors ' || l_msg_count);

        IF l_msg_count = 1
        THEN
            DBMS_OUTPUT.PUT_LINE ('Error ' || l_msg_data);
        ELSE
            FOR i IN 1 .. l_msg_count
            LOOP
                DBMS_OUTPUT.PUT_LINE (
                    'Error ' || FND_MSG_PUB.GET (i, 'F'));
            END LOOP;
        END IF;
    ELSE
        DBMS_OUTPUT.PUT_LINE ('Locator Id is ' || l_locator_id);
    commit;
    END IF;

END LOOP;
END;

Design a site like this with WordPress.com
Get started