Search This Blog

Sunday, October 8, 2017

API to upload data into FND_LOOKUP_VALUES in R12

DECLARE
   V_ERROR  VARCHAR2(4000);
   CURSOR get_lookup_details
   IS
  
      SELECT ltype.application_id,
             ltype.customization_level,
             ltype.creation_date,
             ltype.created_by,
             ltype.last_update_date,
             ltype.last_updated_by,
             ltype.last_update_login,
             tl.lookup_type,
             tl.security_group_id,
             tl.view_application_id,
             tl.description,
             tl.meaning
        FROM fnd_lookup_types_tl tl, fnd_lookup_types ltype
       WHERE     ltype.lookup_type = 'FUJ_ARRIVAL_AIRPORT'
             AND ltype.lookup_type = tl.lookup_type
             AND language = 'US';

   CURSOR get_country
   IS
  
      SELECT distinct LOOKUP_CODE,MEANING , DESCRIPTION
      FROM XX_LOOKUP_VALUES
      --WHERE LOOKUP_CODE = '1'
     -- WHERE upload_status <> 'DONE'
      ;
     
   l_rowid   VARCHAR2 (100) := 0;
BEGIN
   FOR i IN get_lookup_details
   LOOP
      FOR j IN get_country
      LOOP
         l_rowid := NULL;
         BEGIN
            fnd_lookup_values_pkg.insert_row (
               x_rowid                 => l_rowid,
               x_lookup_type           => i.lookup_type,
               x_security_group_id     => i.security_group_id,
               x_view_application_id   => i.view_application_id,
               x_lookup_code           => j.LOOKUP_CODE,
               x_tag                   => '',
               x_attribute_category    => NULL,
               x_attribute1            => NULL,
               x_attribute2            => NULL,
               x_attribute3            => NULL,
               x_attribute4            => NULL,
               x_enabled_flag          => 'Y',
               x_start_date_active     =>NULL,
               x_end_date_active       => NULL,
               x_territory_code        => NULL,
               x_attribute5            => NULL,
               x_attribute6            => NULL,
               x_attribute7            => NULL,
               x_attribute8            => NULL,
               x_attribute9            => NULL,
               x_attribute10           => NULL,
               x_attribute11           => NULL,
               x_attribute12           => NULL,
               x_attribute13           => NULL,
               x_attribute14           => NULL,
               x_attribute15           => NULL,
               x_meaning               => j.MEANING,
               x_description           => j.DESCRIPTION,
               x_creation_date         => SYSDATE,
               x_created_by            => i.created_by,
               x_last_update_date      => i.last_update_date,
               x_last_updated_by       => i.last_updated_by,
               x_last_update_login     => i.last_update_login);

            COMMIT;

           update XX_LOOKUP_VALUES set upload_status= 'DONE' WHERE LOOKUP_CODE=J.LOOKUP_CODE;
         EXCEPTION
            WHEN OTHERS
            THEN
             V_ERROR := (SQLERRM);
                 update XX_LOOKUP_VALUES set upload_status= 'Inner Exception: ' || V_ERROR WHERE LOOKUP_CODE=J.LOOKUP_CODE;
         END;
      END LOOP;
   END LOOP;
--EXCEPTION
--   WHEN OTHERS
--   THEN
--      update XX_COUNTRY set upload_status='Main Exception: ' || V_ERROR  WHERE LOOKUP_CODE=J.LOOKUP_CODE;
END;


SELECT count(*) FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'FUJ_ARRIVAL_AIRPORT'
AND LANGUAGE = 'US'


-------------------------------custom table create------------------------------

--drop table XX_LOOKUP_VALUES

CREATE TABLE XX_LOOKUP_VALUES
(
  LOOKUP_CODE    VARCHAR2(50 BYTE),
  MEANING        VARCHAR2(200 BYTE),
  DESCRIPTION    VARCHAR2(200 BYTE),
  UPLOAD_STATUS  VARCHAR2(2000 BYTE)
)

No comments:

Post a Comment