Tuesday, March 12, 2013

API to Create the Extensible Attributes in TCA for Organization using API HZ_EXTENSIBILITY_PUB

This Scripts explains how to create the extensible attributes for the Organization In TCA Architecture  using API HZ_EXTENSIBILITY_PUB.

Front End Navigation :-

Oracle Customer Data Librarian Superuser à Administration à Extension à Select the Extensible Attribute Group name form the LOV as shown in Screen shot




DECLARE
   l_org_profile_id                                  NUMBER;
   l_user_attr_data_table                            ego_user_attr_data_table;
   l_user_attr_row_table                             ego_user_attr_row_table;
   l_application_id                                  NUMBER;
   l_attr_group_type                                 VARCHAR2 (40);
   l_attr_group1_name                                VARCHAR2 (30);
   l_start_time                                      DATE;
   l_end_time                                        DATE;
   x_failed_row_id_list                              VARCHAR2 (10000);
   x_return_status                                   VARCHAR2 (1);
   x_errorcode                                       NUMBER;
   x_msg_count                                       NUMBER;
   x_msg_data                                        VARCHAR2 (1000);
BEGIN
   l_org_profile_id                               := 3203;
   l_application_id                               := 222;
   l_attr_group_type                              := 'HZ_ORG_PROFILES_GROUP';
   l_attr_group1_name                             := 'OS_INFO';

   l_user_attr_row_table                          :=
      ego_user_attr_row_table (ego_user_attr_row_obj (1
                                                    , NULL
                                                    , l_application_id
                                                    , l_attr_group_type
                                                    , l_attr_group1_name
                                                    , NULL
                                                    , NULL
                                                    , NULL
                                                    , NULL
                                                    , NULL
                                                    , NULL
                                                    , ego_user_attrs_data_pvt.g_update_mode
                                                     )
                              );

   l_user_attr_data_table                         :=
      ego_user_attr_data_table (ego_user_attr_data_obj (1, 'OS_KEY', NULL, 42787902, NULL, NULL, NULL, NULL)
                              , ego_user_attr_data_obj (1, 'OS_PARENT_KEY', NULL, 517045, NULL, NULL, NULL, NULL)
                              , ego_user_attr_data_obj (1
                                                      , 'OS_PARENT_NAME'
                                                      , 'Century Insurance'
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                       )
                              , ego_user_attr_data_obj (1, 'OS_ULT_PARENT_KEY', NULL, 517045, NULL, NULL, NULL, NULL)
                              , ego_user_attr_data_obj (1
                                                      , 'OS_ULT_PARENT_NAME'
                                                      , 'Century Insurance'
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                       )
                              , ego_user_attr_data_obj (1, 'OS_LATITUDE', 'OS_LATITUDE', NULL, NULL, NULL, NULL, NULL)
                              , ego_user_attr_data_obj (1, 'OS_LONGITUDE', 'OS_LONGITUDE', NULL, NULL, NULL, NULL, NULL)
                              , ego_user_attr_data_obj (1
                                                      , 'OS_BUSINESS_DESC'
                                                      , 'OS_BUSINESS_DESC'
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                      , NULL
                                                       )
                               );


   hz_extensibility_pub.process_organization_record (p_api_version                 => 1.0
                                                   , p_org_profile_id              => l_org_profile_id
                                                   , p_attributes_row_table        => l_user_attr_row_table
                                                   , p_attributes_data_table       => l_user_attr_data_table
                                                   , p_debug_level                 => 3
                                                   , p_commit                      => fnd_api.g_true
                                                   , x_failed_row_id_list          => x_failed_row_id_list
                                                   , x_return_status               => x_return_status
                                                   , x_errorcode                   => x_errorcode
                                                   , x_msg_count                   => x_msg_count
                                                   , x_msg_data                    => x_msg_data
                                                    );

   DBMS_OUTPUT.put_line (   'API Status, Return Status is: '
                         || x_return_status
                         || ', Mesage Count is: '
                         || x_msg_count
                         || ' and Error Message is: '
                         || x_msg_data
                        );

   IF (LENGTH (x_failed_row_id_list) > 0)
   THEN
      DBMS_OUTPUT.put_line (   'Details of rows which failed: '
                            || x_failed_row_id_list);

      DECLARE
         l_errors_tbl                                      error_handler.error_tbl_type;
      BEGIN
         error_handler.get_message_list (l_errors_tbl);

         FOR i IN 1 .. l_errors_tbl.COUNT
         LOOP
            DBMS_OUTPUT.put_line (   'API Error : '
                                  || l_errors_tbl (i).MESSAGE_TEXT);
            DBMS_OUTPUT.put_line (   'Message Type : '
                                  || l_errors_tbl (i).MESSAGE_TYPE);
         END LOOP;
      END;
   END IF;

END;

Tuesday, November 27, 2012

API to Update the Messages in FND_NEW_MESSAGES

DECLARE
   CURSOR c1
   IS
      SELECT *
        FROM fnd_new_messages
       WHERE message_name = &MESSAGE_NAME;
BEGIN
   FOR z IN c1
   LOOP
      fnd_new_messages_pkg.translate_row (x_application_id        => z.application_id
                                        , x_message_name          => z.message_name
                                        , x_message_text          => z.msg_txt
                                        , x_owner                 => NULL
                                        , x_custom_mode           => 'FORCE'
                                        , x_last_update_date      => NULL
                                         );
   END LOOP;
   COMMIT;
END;

API to Delete message from FND_NEW_MESSAGES

DECLARE
   CURSOR c1
   IS
      SELECT *
        FROM fnd_new_messages;
BEGIN
   FOR z IN c1
   LOOP
      fnd_new_messages_pkg.delete_row (x_application_id      => z.application_id
                                     , x_language_code       => z.language_code
                                     , x_message_name        => z.message_name
                                      );
   END LOOP;
   COMMIT;
END;

API to Create New Messages in FND_NEW_MESSAGE

DECLARE
   CURSOR c1
   IS
      SELECT *
        FROM xx_fnd_new_messages_stg;
BEGIN
   FOR z IN c1
   LOOP
      fnd_new_messages_pkg.load_row (x_application_id        => z.application_id
                                   , x_message_name          => z.message_name
                                   , x_message_number        => z.message_number
                                   , x_message_text          => z.MESSAGE_TEXT
                                   , x_description           => z.description
                                   , x_type                  => z.TYPE
                                   , x_max_length            => z.max_length
                                   , x_category              => z.CATEGORY
                                   , x_severity              => z.severity
                                   , x_fnd_log_severity      => z.fnd_log_severity
                                   , x_owner                 => &USER_NAME
                                   , x_custom_mode           => 'FORCE'
                                   , x_last_update_date      => NULL
                                    );
   END LOOP;
   COMMIT;
END;

Friday, November 9, 2012

API to Create/Update/Delete the System Items and Item Attributes


DECLARE
   l_item_tbl_typ                               ego_item_pub.item_tbl_type;
   x_item_tbl_typ                               ego_item_pub.item_tbl_type;
   x_return_status                              VARCHAR2 (100);
   x_msg_count                                  NUMBER;
   x_message_list                               error_handler.error_tbl_type;
BEGIN
   fnd_global.apps_initialize (11224
                             , 20634
                             , 401
                              );
   l_item_tbl_typ (1).transaction_type := ego_item_pub.g_ttype_update;
   l_item_tbl_typ (1).inventory_item_id := 646;
   l_item_tbl_typ (1).organization_id := 103;
   l_item_tbl_typ (1).pick_components_flag := 'Y';
   ego_item_pub.process_items (p_api_version         => 1.0
                             , p_init_msg_list       => fnd_api.g_false
                             , p_commit              => fnd_api.g_true
                             , p_item_tbl            => l_item_tbl_typ
                             , x_item_tbl            => x_item_tbl_typ
                             , p_role_grant_tbl      => ego_item_pub.g_miss_role_grant_tbl
                             , x_return_status       => x_return_status
                             , x_msg_count           => x_msg_count
                              );
   DBMS_OUTPUT.put_line ('x_return_status : ' || x_return_status);
   error_handler.get_message_list (x_message_list);

   FOR i IN 1 .. x_message_list.COUNT
   LOOP
      DBMS_OUTPUT.put_line (x_message_list (i).MESSAGE_TEXT);
   END LOOP;

   COMMIT;
END;
===============================================================
SET SERVEROUTPUT ON

DECLARE
   l_item_tbl_typ                               ego_item_pub.item_tbl_type;
   x_item_table                                 ego_item_pub.item_tbl_type;
   x_inventory_item_id                          mtl_system_items_b.inventory_item_id%TYPE;
   x_organization_id                            mtl_system_items_b.organization_id%TYPE;
   x_return_status                              VARCHAR2 (1);
   x_msg_count                                  NUMBER (10);
   x_msg_data                                   VARCHAR2 (1000);
   x_message_list                               error_handler.error_tbl_type;
BEGIN
   --Setting FND global variables.
   --Replace MFG user name with appropriate user name.
   fnd_global.apps_initialize (11224
                             , 20634
                             , 401
                              );
   --FIRST Item definition
   l_item_tbl_typ (1).transaction_type := 'UPDATE';   -- Replace this with 'UPDATE' for update transaction.
   l_item_tbl_typ (1).inventory_item_id := 646;
   l_item_tbl_typ (1).organization_id := 103;
   l_item_tbl_typ (1).pick_components_flag := 'N';
   DBMS_OUTPUT.put_line ('=====================================');
   DBMS_OUTPUT.put_line ('Calling EGO_ITEM_PUB.Process_Items API');
   ego_item_pub.process_items (p_api_version        => 1.0
                             , p_init_msg_list      => fnd_api.g_true
                             , p_commit             => fnd_api.g_true
                             , p_item_tbl           => l_item_tbl_typ
                             , x_item_tbl           => x_item_table
                             , x_return_status      => x_return_status
                             , x_msg_count          => x_msg_count
                              );
   DBMS_OUTPUT.put_line ('==================================');
   DBMS_OUTPUT.put_line ('Return Status ==>' || x_return_status);

   IF (x_return_status = fnd_api.g_ret_sts_success)
   THEN
      FOR i IN 1 .. x_item_table.COUNT
      LOOP
         DBMS_OUTPUT.put_line ('Inventory Item Id :' || TO_CHAR (x_item_table (i).inventory_item_id));
         DBMS_OUTPUT.put_line ('Organization Id   :' || TO_CHAR (x_item_table (i).organization_id));
      END LOOP;
   ELSE
      DBMS_OUTPUT.put_line ('Error Messages :');
      error_handler.get_message_list (x_message_list      => x_message_list);

      FOR i IN 1 .. x_message_list.COUNT
      LOOP
         DBMS_OUTPUT.put_line (x_message_list (i).MESSAGE_TEXT);
      END LOOP;
   END IF;

   DBMS_OUTPUT.put_line ('==================================');
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Exception Occured :');
      DBMS_OUTPUT.put_line (SQLCODE || ':' || SQLERRM);
      DBMS_OUTPUT.put_line ('=====================================');
END;