Loading

Sunday, March 20, 2011

API to update a Customer Profile TCA R12 (HZ_CUSTOMER_PROFILE_V2PUB.UPDATE_CUSTOMER_PROFILE)


This routine is used to update a Customer Profile.  The API updates a record in the HZ_CUSTOMER_PROFILES table. The profile could be at the party level, the customer level, or the customer site level. If the credit_hold parameter value is Y, then records are inserted into OE_HOLD_SOURCES and OE_ORDER_HOLDS to keep these tables synchronized.
API:   HZ_CUSTOMER_PROFILE_V2PUB.UPDATE_CUSTOMER_PROFILE
BASE TABLES AFFECTED :  HZ_CUSTOMER_PROFILES
TEST INSTANCE : R12.1.3

SCRIPT:
/* Formatted on 2011/03/20 13:45 (Formatter Plus v4.8.8) */
SET SERVEROUTPUT ON;
DECLARE
   p_customer_profile_rec_type   hz_customer_profile_v2pub.customer_profile_rec_type;
   p_cust_account_profile_id     NUMBER;
   p_object_version_number       NUMBER;
   x_return_status               VARCHAR2 (2000);
   x_msg_count                   NUMBER;
   x_msg_data                    VARCHAR2 (2000);
BEGIN
-- Setting the Context --
   mo_global.init ('AR');
   fnd_global.apps_initialize (user_id           => 1318,
                               resp_id           => 50559,
                               resp_appl_id      => 222
                              );
   mo_global.set_policy_context ('S', 204);
   fnd_global.set_nls_context ('AMERICAN');
-- Initializing the Mandatory API parameters
   p_customer_profile_rec_type.cust_account_profile_id := 159869;
   p_customer_profile_rec_type.credit_rating := 'Excellent';
   p_object_version_number := 1;
   DBMS_OUTPUT.put_line
          ('Calling the API hz_customer_profile_v2pub.update_customer_profile');
   hz_customer_profile_v2pub.update_customer_profile
                (p_init_msg_list              => fnd_api.g_true,
                 p_customer_profile_rec       => p_customer_profile_rec_type,
                 p_object_version_number      => p_object_version_number,
                 x_return_status              => x_return_status,
                 x_msg_count                  => x_msg_count,
                 x_msg_data                   => x_msg_data
                );

   IF x_return_status = fnd_api.g_ret_sts_success
   THEN
      COMMIT;
      DBMS_OUTPUT.put_line ('Updation of Customer Profile is Successful ');
      DBMS_OUTPUT.put_line ('Output information ....');
      DBMS_OUTPUT.put_line (   'Object Version Number = '
                            || TO_CHAR (p_object_version_number)
                           );
      DBMS_OUTPUT.put_line (   'Credit Rating = '
                            || p_customer_profile_rec_type.credit_rating
                           );
   ELSE
      DBMS_OUTPUT.put_line (   'Updation of Customer Profile got failed:'
                            || x_msg_data
                           );
      ROLLBACK;

      FOR i IN 1 .. x_msg_count
      LOOP
         x_msg_data := fnd_msg_pub.get (p_msg_index => i, p_encoded => 'F');
         DBMS_OUTPUT.put_line (i || ') ' || x_msg_data);
      END LOOP;
   END IF;

   DBMS_OUTPUT.put_line ('Completion of API');
END;
/

VERFICATION SCRIPT:
SELECT cust_account_profile_id,
       cust_account_id,
       status,
       credit_checking
  FROM hz_customer_profiles
 WHERE cust_account_profile_id = '159869';

0 Responses to “API to update a Customer Profile TCA R12 (HZ_CUSTOMER_PROFILE_V2PUB.UPDATE_CUSTOMER_PROFILE)”

Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.