Thursday 27 June 2013

API to Update a Customer Site Use TCA R12 (hz_cust_account_site_v2pub.update_cust_site_use)

CREATE OR REPLACE procedure APPS.xxaj_site_use_status
is

                    x_return_status     varchar2(10);          
                    x_msg_count         number(10);              
                    x_msg_data          varchar2(1200);
                    p_object_version_number number(10):=4;
                    P_CUST_SITE_USE_REC hz_cust_account_site_v2pub.CUST_SITE_USE_REC_TYPE;

begin
       --Apps Initialization
       
         FND_GLOBAL.APPS_INITIALIZE (
                                            USER_ID => 1318,
                                            RESP_ID => 50583,
                                            RESP_APPL_ID => 401  
                                            );
                 
         P_CUST_SITE_USE_REC.site_use_id:=4126;
         P_CUST_SITE_USE_REC.status:= 'A';
         P_CUST_SITE_USE_REC.cust_acct_site_id :=3995;
         P_CUST_SITE_USE_REC.SITE_USE_CODE := 'BILL_TO';
         P_CUST_SITE_USE_REC.CREATED_BY_MODULE := 'TCA_V2_API';                    
                                           
         hz_cust_account_site_v2pub.update_cust_site_use
         (
                   p_init_msg_list             =>    'T',        
                   P_CUST_SITE_USE_REC        => P_CUST_SITE_USE_REC,
                   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 = 'S' THEN
                dbms_output.put_line(' Now site use is active' );  
            ELSE
                IF NVL (x_msg_count, 0) > 1 THEN
                    FOR i IN 1 .. x_msg_count LOOP
             
                        dbms_output.put_line(' Error Status ' ||x_return_status);
                        dbms_output.put_line(' Error message ' ||x_msg_data);
                    END LOOP;
                ELSE
                    dbms_output.put_line(' Error message ' ||x_msg_data);
                END IF;
            END IF;
         commit;                              
exception when others then
    dbms_output.put_line(' Error Here'||sqlcode||sqlerrm);
end;
/

SQL> EXEC xxaj_site_use_status;


Ur's
AmarAlam

8 comments:

Anil said...

Can we update Primary_Flag in APPS.HZ_CUST_SITE_USES_ALL table using this API?

陳小岐 said...

Hi,

It can work when I update one record first time. But it return "This record in table &TABLE cannot be locked as it has been updated by another user." message when I do the script again.

It seem cause by below, what is this?

Locking Mechanism
The TCA public APIs provide a new locking mechanism for update procedures, based on the new OBJECT_VERSION_NUMBER column, which has been included in all HZ tables. For this reason, OBJECT_VERSION_NUMBER is a mandatory attribute for all update APIs.
The locking mechanism works as follows:
Whenever a new record is created, the value in the OBJECT_VERSION_NUMBER column is set to 1.
Whenever a record is updated, the value in the OBJECT_VERSION_NUMBER column is reset to OBJECT_VERSION_NUMBER plus 1.
For records that existed in the HZ tables prior to introduction of this locking mechanism, the API sets the value in the OBJECT_VERSION_NUMBER column to null.

Ricky

Oracle Apps For You said...

Hello Seridevi,

REPLY FOR RELATED API. DON'T SEND UNRELATED THINGS.

dinesh said...

Error message This record in table hz_cust_site_uses cannot be locked as it has been updated by another user.

object version number resolution didnot work
thanks,
dinesh

Ajay Raj said...

Thank you for sharing

Genuine Astrologer in Chennai

Astrologer in Chennai

Best Astrologer in Chennai

Alshaimaa said...

I tried it and gave the error No customer site use was found for ID, the solution is in Doc ID 800729.1
FND_GLOBAL.APPS_INITIALIZE(,,);
MO_GLOBAL.INIT('AR');
MO_GLOBAL.SET_POLICY_CONTEXT('S', );

Unknown said...
This comment has been removed by the author.
Unknown said...

@Dinesh
This happens when a party site is shared between multiple cust account sites. When the cust acct site is updated/disabled the API will update the corresponding party site. I faced the same issue so i used the hz_party_site_v2pub.update_party_site API instead.

Post a Comment