Monday, March 26, 2012

Create Inventory Locator Conversion

/* Formatted on 3/26/2012 3:59:43 PM (QP5 v5.114.809.3010) */
CREATE OR REPLACE PROCEDURE APPS.XX_CREATE_STOCK_LOCATORS
IS
   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 := 107;
   /*ORGANIZATION_ID */
   L_ORGANIZATION_CODE        VARCHAR2 (10) := '221';
   /*ORGANIZATION_CODE */
   L_SUB_CODE                 VARCHAR2 (10);
   /*VARIABLE FOR SUBINVENTORY*/
   L_CONCATENATED_SEGMENTS    VARCHAR2 (100);
   /*VARIABLE FOR LOCATOR SEGMENT*/
   L_PICKING_ORDER            NUMBER;
   l_location_maximum_units   number;

   /*PUTAWAY SEQUENCE NO */
   --L_USER_ID NUMBER := 1262; /* USER ID FROM FND_USERS TABLE */
   --L_RESP_ID NUMBER := 20634; /*RESPONSIBILITY ID*/
   --L_RESP_APPL_ID NUMBER := 401; /* RESPONSIBILITY APPLICATION ID */
   CURSOR C1
   IS
      SELECT   SUBINVENTORY,
               LOCATOR_CONCAT_SEGMENTS,
               PICKING_PRIORITY,
               SUPPLIER,
               CAPACITY
        FROM   XX_STOCK_LOCATOR_STAGING
        /*  CREATE TABLE APPS.XX_STOCK_LOCATOR_STAGING
                (
                SUBINVENTORY             VARCHAR2(12 BYTE),
                LOCATOR_CONCAT_SEGMENTS  VARCHAR2(2000 BYTE),
                PICKING_PRIORITY         NUMBER,
                SUPPLIER                 VARCHAR2(240 BYTE),
                CAPACITY                 NUMBER,
                SRL                        NUMBER,
                STATUS                   VARCHAR2(1 BYTE),
                ORGANIZATION_ID          NUMBER
                )
       
        */
       WHERE   SUBINVENTORY = 'K4FUR';
BEGIN
   /*
         * APPS_INITIALIZE REQUIRED BECAUSE INDIRECTLY USE PROFILE OPTIONS
   -- FND_GLOBAL.APPS_INITIALIZE(L_USER_ID, L_RESP_ID,L_RESP_APPL_ID);
   */
   --FND_GLOBAL.APPS_INITIALIZE(USER_ID IN NUMBER,RESP_ID IN NUMBER, RESP_APPL_ID IN NUMBER SECURITY_GROUP_ID IN NUMBER);
   FND_GLOBAL.APPS_INITIALIZE (1295, 50683, 401);
   FND_MSG_PUB.INITIALIZE;

   FOR I IN C1
   LOOP
      L_CONCATENATED_SEGMENTS := I.LOCATOR_CONCAT_SEGMENTS;
      L_PICKING_ORDER := I.PICKING_PRIORITY;
      l_location_maximum_units := I.CAPACITY;
      L_SUB_CODE := 'K4FUR';
      L_ORG_ID := 107;
      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                => 'WMS-Locator Created By API', /*YOU CAN ALSO USE HERE DESCRIPTION OF YOUR LOCATOR COMBINATION*/
         P_INVENTORY_LOCATION_TYPE    => NULL,
         P_PICKING_ORDER              => L_PICKING_ORDER,
         P_LOCATION_MAXIMUM_UNITS     => NULL, --l_location_maximum_units,      -- capacity
         P_SUBINVENTORY_CODE          => L_SUB_CODE,    /*SUBINVENTORY 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_CONCATENATED_SEGMENTS
                           || ' - '
                           || L_RETURN_STATUS
                           || '-'
                           || L_MSG_DATA);

      IF L_RETURN_STATUS IN ('E', 'U')
      THEN
         -- DBMS_OUTPUT.PUT_LINE ('# of Errors ' || L_MSG_COUNT);
         --  DBMS_OUTPUT.PUT_LINE ('Error ' || L_MSG_DATA);
         UPDATE   XX_STOCK_LOCATOR_STAGING_CHECK
            SET   STATUS = 'N'
          WHERE   LOCATOR_CONCAT_SEGMENTS LIKE L_CONCATENATED_SEGMENTS;
      /*   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
         UPDATE   XX_STOCK_LOCATOR_STAGING
            SET   STATUS = 'Y'
          WHERE   LOCATOR_CONCAT_SEGMENTS = L_CONCATENATED_SEGMENTS;

         COMMIT;
      -- DBMS_OUTPUT.PUT_LINE ('Locator Id is ' || L_LOCATOR_ID);
      END IF;
   -- COMMIT;
   END LOOP;
--  COMMIT;
END;
/

No comments:

Post a Comment