Wednesday, 2 August 2017

Update/Disable Customer site using API in Oracle Apps r12


This post will help you to disable customer site using API in Oracle APPS. Here I am disabling the customer account site and if you want to update others values you can do it in the same way as the “status” field is updated.

Script:

 
DECLARE

   l_init_msg_list           VARCHAR2 (1000) := FND_API.G_FALSE;

   l_cust_acct_site_rec      HZ_CUST_ACCOUNT_SITE_V2PUB.cust_acct_site_rec_type;

   l_return_status           VARCHAR2 (1000);

   l_object_version_number   NUMBER;

   l_msg_count               NUMBER;

   l_msg_data                VARCHAR2 (1000);

   L_SITE_USE_ID             NUMBER;

BEGIN

 
   fnd_global.apps_initialize(1110,

                              51292,

                              7000

                              );

  

    select cust_acct_site_id,

    object_version_number

    into l_cust_acct_site_id,

    l_object_version_number

    from hz_cust_acct_sites_all where party_site_id=11452;

 
    l_cust_acct_site_rec.status := 'I';

  

    hz_cust_account_site_v2pub.update_cust_acct_site (fnd_api.g_true,

                                                l_cust_acct_site_rec,

    l_object_version_number,

                                                l_return_status,

                                                l_msg_count,

                                                l_msg_data);

 

   DBMS_OUTPUT.put_line (l_return_status || l_msg_data);

END;

 Note:  The value for l_object_version_number needs to set the current object_version_number. Otherwise you will get the error “The table hz_cust_acct_sites_all cannot be locked as it has been updated by another user”
When you create the record value for object_version_number is set to 1 and after update the value is updated(+1).

No comments:

Post a Comment