Monday, December 17, 2018

Creating Lookup and Lookup Values through API

DECLARE
   err_code    VARCHAR2 (50);
   err_msg     VARCHAR2 (1000);
   ln_rowid    ROWID;
   ln_rowid1   ROWID;

   CURSOR C
   IS
        SELECT   CODE, NAMES
          FROM   XX_TABLE_NAME
         WHERE   LINE_STATUS <> 'INSERTED' OR LINE_STATUS IS NULL
      ORDER BY   1;
BEGIN
   fnd_lookup_types_pkg.insert_row (
      x_rowid                 => ln_rowid,
      x_lookup_type           => 'XX_TYPE',                      --Lookup Type
      x_security_group_id     => 0,                        --Security Group Id
      x_view_application_id   => 3,                  -- Application Id (0-AOL)
      x_application_id        => 50000,              -- Application Id (0-AOL)
      x_customization_level   => 'U',                                   --User
      x_meaning               => 'XX_MEANING',            --Meaning for Lookup
      x_description           => 'XX_DESCRIPTION',    --Description for Lookup
      x_creation_date         => SYSDATE,
      x_created_by            => -1,
      x_last_update_date      => SYSDATE,
      x_last_updated_by       => -1,
      x_last_update_login     => -1
   );


   FOR REC IN C
   LOOP
      BEGIN
         fnd_lookup_values_pkg.insert_row (
            x_rowid                 => ln_rowid1,
            x_lookup_type           => 'XX_TYPE',
            x_security_group_id     => 0,
            x_view_application_id   => 3,
            x_lookup_code           => rec.code,
            x_tag                   => NULL,
            x_attribute_category    => NULL,
            x_attribute1            => NULL,
            x_attribute2            => NULL,
            x_attribute3            => NULL,
            x_attribute4            => NULL,
            x_enabled_flag          => 'Y',
            x_start_date_active     => TO_DATE ('01-DEC-2015', 'DD-MON-YYYY'),
            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               => REC.NAMES,             --Lookup Meaning
            x_description           => REC.NAMES,
            x_creation_date         => SYSDATE,
            x_created_by            => -1,
            x_last_update_date      => SYSDATE,
            x_last_updated_by       => -1,
            x_last_update_login     => -1
         );

         UPDATE   XX_TABLE_NAME
            SET   LINE_STATUS = 'INSERTED', ERROR_TEXT = ''
          WHERE   CODE = rec.CODE;

         COMMIT;
      EXCEPTION
         WHEN OTHERS
         THEN
            ROLLBACK;

            err_code := SQLCODE;
            err_msg := SUBSTR (SQLERRM, 1, 200);

            UPDATE   XX_TABLE_NAME
               SET   LINE_STATUS = 'ERROR',
                     ERROR_TEXT = err_code || ':' || err_msg
             WHERE   CODE = rec.CODE;

            COMMIT;

            DBMS_OUTPUT.put_line (SQLERRM);
      END;
   END LOOP;
END;
Previous Post
Next Post

Overall 5+ Years Hands-on Experience in RICE COMPONENTS i.e. Reports, Interfaces, Conversions and Enhancements of screens/reports (using Oracle FORMS/Oracle REPORT/ XML Publisher) for standard and customize Oracle Applications. Write, debug, database packages, procedures/Function/Triggers in RDBMS using Oracle Technologies i.e. (SQL, PL/SQL) as per business requirement with SQL/PLSQL Tuning, Code Review, Testing, Training and providing Technical support to Clients.

0 comments: