100% found this document useful (1 vote)
471 views

Untitled

This document contains the code for a package in Oracle Applications that is used to inactivate contacts for KI (Kingdom of Saudi Arabia). The package contains procedures for inactivating customer account roles, organization contacts, email contact points, phone contact points, and other contact information. The procedures update the relevant records and tables in the database to set the contact status to inactive.

Uploaded by

eddulavk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
471 views

Untitled

This document contains the code for a package in Oracle Applications that is used to inactivate contacts for KI (Kingdom of Saudi Arabia). The package contains procedures for inactivating customer account roles, organization contacts, email contact points, phone contact points, and other contact information. The procedures update the relevant records and tables in the database to set the contact status to inactive.

Uploaded by

eddulavk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 19

CREATE OR REPLACE PACKAGE APPS.tk_ki_ar_inactive_contact_pkg AS /**************************************************************************** ** Revision: $Revision: $ ** ** Program: tk_ki_ar_inactive_contact_pkg.pk.cr.

sql ** ** Date Last Modified: $Date: $ ** ** Last Modified By: $Author: $ ** ** Description: This script creates the package to inactive the contacts for KI ** ** Modification History ** $Log: $ *****************************************************************************/ /***************************************************************** ** Procedure Name: inactive_contact_prc * ** * ** Access: Public Procedure * ** * ** Description: * ** * ** * ** Parameters: * ** * ** Name DataType IN/OUT Required * ** ---------------------------------------* ** retcode NUMBER OUT Yes * ** errbuf VARCHAR2 OUT Yes * ** p_set_of_books_code VARCHAR2 IN Yes * ** p_country VARCHAR2 IN Yes * ** p_level_contact VARCHAR2 IN Yes * *****************************************************************/ PROCEDURE inactive_contact_prc(errbuf OUT VARCHAR2 ,retcode OUT NUMBER ,p_set_of_books_code I N VARCHAR2 ,p_country IN VARCHAR2 ,p_level_contact IN VA RCHAR2);

PROCEDURE update_cust_account_role_prc (p_cust_acct_role_id IN NUMBER ,p_cont_cust_acct_id IN NUMBER ,p_cont_p arty_id IN NUMBER ,p_role_type IN VARCHAR2);

PROCEDURE update_org_contact_prc(p_org_contact_id IN NUMBER); PROCEDURE update_email_contact_point_prc(p_contact_point_id IN NUMBER); PROCEDURE update_phone_contact_point_prc(p_contact_point_id IN NUMBER); PROCEDURE update_telex_contact_point_prc(p_contact_point_id IN NUMBER);

PROCEDURE update_web_contact_point_prc (p_contact_point_id IN NUMBER); g_k1_customer_no cp_si_interface.attribute1%TYPE; g_k1_site_no cp_si_interface.attribute3%TYPE; g_k1_contact_no cp_si_interface.vt_transaction_ref%TYPE; END tk_ki_ar_inactive_contact_pkg; / SHOW ERRORS; CREATE OR REPLACE PACKAGE BODY APPS.tk_ki_ar_inactive_contact_pkg AS --Inactivate cust acct role PROCEDURE update_cust_account_role_prc (p_cust_acct_role_id IN NUMBER ,p_cont_cust_acct_id IN NUMBER ,p_cont_p arty_id AS v_role_obj_num v_msg_count v_msg_data v_return_status v_cust_account_role_rec_type rec_type; BEGIN BEGIN SELECT object_version_number INTO v_role_obj_num FROM hz_cust_account_roles WHERE cust_account_role_id = p_cust_acct_role_id; EXCEPTION WHEN OTHERS THEN v_role_obj_num := NULL; fnd_file.put_line(fnd_file.log, 'Error while getting the objec t version for cust acct role '|| SQLERRM); END; v_cust_account_role_rec_type.cust_account_role_id := p_cust_acct_role_id; v_cust_account_role_rec_type.cust_account_id := p_cont_cust_acct_id ; v_cust_account_role_rec_type.party_id := p_cont_party_id; v_cust_account_role_rec_type.role_type := p_role_type; v_cust_account_role_rec_type.status := 'I'; --Inactivate acct role API hz_cust_account_role_v2pub.update_cust_account_role(p_init_msg_list => fnd_api.g_false ,p_cust_account_r ole_rec => v_cust_account_role_rec_type ,p_object_version_number => v_role_obj_num ,x_return_status ,x_msg_count => v_return_status => v_msg_count NUMBER :=NULL; NUMBER :=NULL; VARCHAR2(2000) :=NULL; VARCHAR2(1000) :=NULL; hz_cust_account_role_v2pub.cust_account_role_ IN NUMBER ,p_role_type IN VARCHAR2)

,x_msg_data => v_msg_data); COMMIT; fnd_file.put_line(fnd_file.log, 'Inactivate cust acct role '); fnd_file.put_line(fnd_file.log, 'v_return_status '|| v_return_status) ; fnd_file.put_line(fnd_file.log, 'v_msg_count fnd_file.put_line(fnd_file.log, 'v_msg_data IF v_return_status <> 'S' THEN fnd_file.put_line(fnd_file.log, 'Failure to update the record cust account role '|| SQLERRM); FOR k IN 1 .. v_msg_count LOOP v_msg_data := fnd_msg_pub.get(p_msg_index => k ,p_encoded => 'F') ; fnd_file.put_line(fnd_file.log,'Error:' || v_msg_data); END LOOP; ELSE fnd_file.put_line(fnd_file.log, 'Successfully inactived the cust acct role '|| p_cust_acct_role_id); fnd_file.put_line (fnd_file.output,RPAD (g_k1_customer_no, 30, ' ') || RPAD (NVL(g_k1_site_no,' '), 30, ' ') || R PAD (g_k1_contact_no, 30, ' ') || R PAD ('OMAR Contact Acct Role Update', 40, ' ') || R PAD (p_cust_acct_role_id, 30, ' ')); END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line(fnd_file.log, 'Error in proc update_cust_account_role_p rc'|| SQLERRM); END update_cust_account_role_prc; --Inactivate org contacts PROCEDURE update_org_contact_prc(p_org_contact_id IN NUMBER) AS v_msg_count NUMBER :=NULL; v_msg_data VARCHAR2(2000) :=NULL; v_return_status VARCHAR2(1000) :=NULL; v_cont_object_version_number NUMBER :=NULL; v_party_object_version_number NUMBER :=NULL; v_rel_object_version_number NUMBER :=NULL; v_party_relationship_id NUMBER :=NULL; v_org_contact_rec_type hz_party_contact_v2pub.org_contact_rec_ty pe ; v_party_rel_rec hz_relationship_v2pub.relationship_rec_ty pe ; BEGIN BEGIN SELECT DISTINCT oc.object_version_number , p.object_version_number , r.object_version_number , party_relationship_id INTO v_cont_object_version_number, '|| v_msg_count); '|| v_msg_data);

v_party_object_version_number, v_rel_object_version_number, v_party_relationship_id FROM hz_parties p, hz_relationships r, hz_org_contacts oc WHERE oc.party_relationship_id = r.relationship_id AND r.party_id = p.party_id AND oc.org_contact_id = p_org_contact_id; EXCEPTION WHEN OTHERS THEN v_cont_object_version_number := NULL; v_party_object_version_number:= NULL; v_rel_object_version_number := NULL; fnd_file.put_line(fnd_file.log, 'Error while getting the obj _numers for update_org_contact '|| SQLERRM); END; v_org_contact_rec_type.org_contact_id ntact_id ; v_org_contact_rec_type.party_rel_rec.status := 'I'; v_org_contact_rec_type.party_rel_rec.relationship_id := v_party_ relationship_id; v_org_contact_rec_type.party_rel_rec.status := 'I'; hz_party_contact_v2pub.update_org_contact(p_init_msg_list => fnd_api.g_false ,p_org_contact_rec => v_org_contact_rec_type ,p_cont_object_version_number => v_cont_object_version_number ,p_rel_object_version_number => v_rel_object_version_number := p_org_co

,p_party_object_version_number => v_party_object_version_number ,x_return_status ,x_msg_count ,x_msg_data => v_return_status => v_msg_count => v_msg_data); COMMIT; fnd_file.put_line(fnd_file.log, 'Inactivate Org Contacts '); fnd_file.put_line(fnd_file.log, 'v_return_status '|| v_return fnd_file.put_line(fnd_file.log, 'v_msg_count unt); fnd_file.put_line(fnd_file.log, 'v_msg_data ta); IF v_return_status <> 'S' THEN fnd_file.put_line(fnd_file.log, 'Failure to update the record h z_party_contact_v2pub.update_org_contact '|| SQLERRM); FOR k IN 1 .. v_msg_count LOOP v_msg_data := fnd_msg_pub.get(p_msg_index => k ,p_encoded => 'F') ; fnd_file.put_line(fnd_file.log,'Error:' || v_msg_data) ; END LOOP; '|| v_msg_da '|| v_msg_co

_status);

ELSE fnd_file.put_line(fnd_file.log, 'Successfully inactived the Or g Contacts '|| p_org_contact_id); fnd_file.put_line (fnd_file.output,RPAD (g_k1_customer_no, 30, ' ') || RPAD (NVL(g_k1_site_no,' ') , 30, ' ') || RPAD (g_k1_contact_no, 30, ' ') || RPAD ('OMAR Org Contact Update', 40, ' ') || RPAD (p_org_contact_id, 30, ' ')); END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line(fnd_file.log, 'Error in proc update_org_contact_prc'|| SQLERRM); END update_org_contact_prc; --Inactivate email contact type PROCEDURE update_email_contact_point_prc(p_contact_point_id IN NUMBER) AS v_obj_num_email NUMBER :=NULL; v_msg_count NUMBER :=NULL; v_msg_data VARCHAR2(2000) :=NULL; v_return_status VARCHAR2(1000) :=NULL; v_contact_point_rec hz_contact_point_v2pub.contact_point_rec_type; BEGIN BEGIN SELECT INTO FROM WHERE EXCEPTION object_version_number v_obj_num_email hz_contact_points contact_point_id = p_contact_point_id;

WHEN OTHERS THEN v_obj_num_email := NULL; fnd_file.put_line(fnd_file.log, 'Error while getting the v_obj_num for email contact point '|| SQLERRM); END; v_contact_point_rec.status :='I'; v_contact_point_rec.contact_point_id := p_contact_point_id ; hz_contact_point_v2pub.update_email_contact_point(p_init_msg_list fnd_api.g_false , p_contact_point_rec => v_contact_point_rec, =>

p_object_version_number => v_obj_num_email , x_return_status x_msg_count => v_return_status, => v_msg_count ,

x_msg_data => v_msg_data); COMMIT; IF v_return_status <> 'S' THEN fnd_file.put_line(fnd_file.log, 'Failure to update the record for email contact point'|| SQLERRM);

FOR k IN 1 .. v_msg_count LOOP v_msg_data := fnd_msg_pub.get(p_msg_index => k ,p_encoded => 'F'); fnd_file.put_line(fnd_file.log,'Error:' || v_msg_data) ; END LOOP; ELSE fnd_file.put_line(fnd_file.log, 'Successfully inactived the emai l contact point '|| p_contact_point_id); fnd_file.put_line (fnd_file.output, RPAD (g_k1_customer_no, 30, ' ') || RPAD (NVL(g_k1_site_no,' ') , 30, ' ') || RPAD (g_k1_contact_no, 30, ' ') || RPAD ('OMAR Email Contact Type Update', 40, ' ') || RPAD (p_contact_point_id, 30, ' ')); END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line(fnd_file.log, 'Error in proc update_email_contact_point _prc'|| SQLERRM); END update_email_contact_point_prc; --Inactivate phone contact type PROCEDURE update_phone_contact_point_prc(p_contact_point_id IN NUMBER) AS v_obj_num_phone NUMBER :=NULL; v_msg_count NUMBER :=NULL; v_msg_data VARCHAR2(2000) :=NULL; v_return_status VARCHAR2(1000) :=NULL; v_contact_point_rec hz_contact_point_v2pub.contact_point_rec_type; BEGIN BEGIN SELECT object_version_number INTO v_obj_num_phone FROM hz_contact_points WHERE contact_point_id = p_contact_point_id; EXCEPTION WHEN OTHERS THEN v_obj_num_phone := NULL; fnd_file.put_line(fnd_file.log, 'Error while getting the v_obj_n um for update phone contact point '|| SQLERRM); END; v_contact_point_rec.status := 'I'; v_contact_point_rec.contact_point_id := p_contact_point_id ; hz_contact_point_v2pub.update_phone_contact_point( p_init_msg_list > fnd_api.g_false ,p_contact_point_rec > v_contact_point_rec ,p_object_version_number => v_obj_num_phone ,x_return_status ,x_msg_count => v_return_status => v_msg_count = =

=> v_msg_data); COMMIT; IF v_return_status <> 'S' THEN fnd_file.put_line(fnd_file.log, 'Failure to update the record '| | SQLERRM); FOR k IN 1 .. v_msg_count LOOP v_msg_data := fnd_msg_pub.get( p_msg_index => k ,p_encoded => 'F') ; fnd_file.put_line(fnd_file.log,'Error:' || v_msg_data); END LOOP; ELSE fnd_file.put_line(fnd_file.log, 'Successfully inactived the phone cont act point '|| p_contact_point_id); fnd_file.put_line (fnd_file.output, RPAD (g_k1_customer_no, 30, ' ') || RPAD (NVL(g_k1_site_no,' ') , 30,' ') || RPAD (g_k1_contact_no, 30, ' ') || RPAD ('OMAR Phone Contact Type Update', 40, ' ') || RPAD (p_contact_point_id, 30, ' ')); END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line(fnd_file.log, 'Error in proc update_phone_contact_point _prc'|| SQLERRM); END update_phone_contact_point_prc; --Inactivate telex contact type PROCEDURE update_telex_contact_point_prc(p_contact_point_id IN NUMBER) AS v_obj_num_telex NUMBER :=NULL; v_msg_count NUMBER :=NULL; v_msg_data VARCHAR2(2000) :=NULL; v_return_status VARCHAR2(1000) :=NULL; v_contact_point_rec hz_contact_point_v2pub.contact_point_rec_type; BEGIN BEGIN SELECT object_version_number INTO v_obj_num_telex FROM hz_contact_points WHERE contact_point_id = p_contact_point_id; EXCEPTION WHEN OTHERS THEN v_obj_num_telex := NULL; fnd_file.put_line(fnd_file.log, 'Error while getting the v_ob j_num for telex contact point '|| SQLERRM); END; v_contact_point_rec.status :='I'; v_contact_point_rec.contact_point_id := p_contact_point_id ; hz_contact_point_v2pub.update_telex_contact_point(p_init_msg_list => fnd_api.g_false , p_contact_point_rec => v_contact_point_rec

,x_msg_data

, p_object_version_number => v_obj_num_telex , x_return_status , x_msg_count , x_msg_data => v_return_status => v_msg_count

=> v_msg_data); COMMIT; IF v_return_status <> 'S' THEN fnd_file.put_line(fnd_file.log, 'Failure to update the record '| | SQLERRM); FOR k IN 1 .. v_msg_count LOOP v_msg_data := fnd_msg_pub.get(p_msg_index => k ,p_encoded => 'F') ; fnd_file.put_line(fnd_file.log,'Error:' || v_msg_data); END LOOP; ELSE fnd_file.put_line(fnd_file.log, 'Successfully inactived the te lex contact point '|| p_contact_point_id); fnd_file.put_line (fnd_file.output, RPAD (g_k1_customer_no, 3 0, ' ') || RPAD (NVL(g_k1_site_no,' ') , 30, ' ') || RPAD (g_k1_contact_no, 30, ' ') || RPAD ('OMAR Telex Contact Type Update', 40, ' ') || RPAD (p_contact_point_id, 30, ' ')); END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line(fnd_file.log, 'Error in proc update_telex_contact_point _prc'|| SQLERRM); END update_telex_contact_point_prc; --Inactivate web contact type PROCEDURE update_web_contact_point_prc( p_contact_point_id IN NUMBER) AS v_obj_num_web NUMBER :=NULL; v_msg_count NUMBER :=NULL; v_msg_data VARCHAR2(2000) :=NULL; v_return_status VARCHAR2(1000) :=NULL; v_contact_point_rec hz_contact_point_v2pub.contact_point_rec_type; BEGIN BEGIN SELECT object_version_number INTO v_obj_num_web FROM hz_contact_points WHERE contact_point_id = p_contact_point_id; EXCEPTION WHEN OTHERS THEN v_obj_num_web := NULL; fnd_file.put_line(fnd_file.log, 'Error while getting the v_obj_num for web contact point '|| SQLERRM); END; v_contact_point_rec.status :='I'; v_contact_point_rec.contact_point_id := p_contact_point_id ;

hz_contact_point_v2pub.update_web_contact_point(p_init_msg_list nd_api.g_false ,p_contact_point_rec _contact_point_rec ,p_object_version_number => v_obj_num_web ,x_return_status ,x_msg_count => v_return_status => v_msg_count

=> f => v

,x_msg_data => v_msg_data); COMMIT; IF v_return_status <> 'S' THEN fnd_file.put_line(fnd_file.log, 'Failure to update the web contact point r ecord '|| SQLERRM); FOR k IN 1 .. v_msg_count LOOP v_msg_data := fnd_msg_pub.get( p_msg_index => k , p_encoded => 'F') ; fnd_file.put_line(fnd_file.log,'Error:' || v_msg_data); END LOOP; ELSE fnd_file.put_line(fnd_file.log, 'Successfully inactived the web contac t point '|| p_contact_point_id); fnd_file.put_line (fnd_file.output, RPAD (g_k1_customer_no, 30, ' ') || RPAD (NVL(g_k1_site_no,' ') , 30, ' ') || RPAD (g_k1_contact_no, 30, ' ') || RPAD ('OMAR Web Contact Type Update', 40, ' ') || RPAD (p_contact_point_id, 30, ' ')); END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line(fnd_file.log, 'Error in proc update_web_contact_point_p rc'|| SQLERRM); END update_web_contact_point_prc; PROCEDURE inactive_contact_prc(errbuf OUT VARCHAR2, retcode OUT NUMBER , p_set_of_books_code IN VARCHA R2, p_country IN VARCHAR2, p_level_contact IN VARCHAR2) AS /***************************************************************** ** Procedure Name: inactive_contact_prc * ** * ** Access: Public Procedure * ** * ** Description: * ** * ** * ** Parameters: * ** * ** Name DataType IN/OUT Required *

** ---------------------------------------* ** retcode NUMBER OUT Yes * ** errbuf VARCHAR2 OUT Yes * ** * *****************************************************************/ --Getting customer party and org details at header level CURSOR cust_cont IS SELECT DISTINCT attribute1 k1_customer_no , attribute5 header_level_contact , attribute3 k1_site_no , vt_transaction_ref k1_contact_no FROM cp_si_interface c2 WHERE c2.vt_transaction_table = 'CONTACTS' AND c2.vt_status = 'SUCCESSFUL' AND c2.attribute5 = 'CUSTOMER' AND c2.attribute11 = p_set_of_books_code AND c2.attribute1 IN (SELECT DISTINCT c.attribute15 FROM cp_si_interface c WHERE c.vt_results_att ribute11 IN (SELECT DISTINCT territory_code FROM fnd_terr itories_tl WHERE territor y_code = DECODE(p_country,'ALL',territory_code,p_country)) AND c.attribute2 = p_set_of_books_code AND vt_transaction_table LIKE 'CUSTOMER CONV%' AND vt_status = 'SUCCESSFUL' ) --AND attribute1 = 1804 --Hard coded the value to disble only one rec ord--while delivering the code, need to remove this line --AND vt_transaction_ref =1179; --Hard coded the value to disble only one record --while delivering the code, need to remove this line AND rownum < 5;--Added by RSOMASUN --Getting address party and org details at address level CURSOR addr_cont IS SELECT DISTINCT attribute1 k1_customer_no , attribute3 k1_site_no , attribute5 addr_level_contact , vt_transaction_ref k1_contact_no FROM cp_si_interface c2 WHERE c2.vt_transaction_table = 'CONTACTS' AND c2.vt_status = 'SUCCESSFUL' AND c2.attribute5 = 'ADDRESS' AND c2.attribute11 = p_set_of_books_code AND c2.attribute3 IN (SELECT DISTINCT c.vt_transaction_ref FROM cp_si_interface c WHERE c.vt_results_attribute11 IN (SELECT DISTINCT territory_code FROM fnd_terr itories_tl WHERE territor y_code = DECODE(p_country,'ALL',territory_code,p_country)) AND c.attribute2 = p_set_of_books_code AND vt_transaction_table LIKE 'CUSTOMER CONV%' AND vt_status = 'SUCCESSFUL'

) --AND attribute1 = 1804 --Hard coded the value to disble only one rec ord--while delivering the code, need to remove this line --AND attribute3 = 17521 ;--Hard coded the value to disble only one r ecord --while delivering the code, need to remove this line --AND vt_transaction_ref=389265; AND rownum < 5; --Getting OMAR cust account role,contact,contact points based on the KI customer number and KI contact number CURSOR omar_customer_contact(k1_customer_no VARCHAR2,k1_contact_no VARCHAR2) IS SELECT org_cont.org_contact_id org_contact_id , acct_role.cust_account_role_id cust_account_role_id , acct_role.party_id cont_party_id , acct_role.cust_account_id cont_cust_acct_id , acct_role.role_type role_type , rel_party.party_id rel_party_id , org_cont.contact_number contact_number , role_acct.account_number omar_customer_number FROM hz_cust_account_roles acct_role , hz_parties party , hz_parties rel_party , hz_relationships rel , hz_org_contacts org_cont , hz_cust_accounts role_acct , tk_customer_xref ki_cust , tk_customer_xref tk_cust , (SELECT name FROM v$database) tk_instance WHERE acct_role.party_id = rel.party_id AND acct_role.role_type = 'CONTACT' AND org_cont.party_relationship_id = rel.relationship_id AND rel.subject_id = party.party_id AND rel_party.party_id = rel.party_id AND acct_role.cust_account_id = role_acct.cust_account_id AND role_acct.party_id = rel.object_id AND acct_role.status = 'A' AND rel.status = 'A' AND party.status = 'A' AND rel_party.status = 'A' AND tk_cust.global_customer_id = ki_cust.global_customer_id AND ki_cust.status = 'A' AND tk_cust.status = 'A' AND (SYSDATE BETWEEN ki_cust.start_date_active AND NVL (ki_cust.end_d ate_active, SYSDATE + 1)) AND TO_CHAR(acct_role.cust_account_id ) = tk_cust.source_sys_cust_id AND ki_cust.set_of_books_code = 'K1' AND tk_cust.set_of_books_code = DECODE (tk_instance.name ,'OMARCSDV ','MD' ,'OMARCSTS ','MD' ,'OMARCSOR ','MT' ,'OMARCSPD ','MP') AND ki_cust.source_sys_cust_number = TO_CHAR(k1_customer_no) AND acct_role.attribute2 = TO_CHAR(k1_contact_no); --Getting OMAR cust account role,contact,contact points based on the KI customer number ,KI party number and KI contact number

CURSOR omar_address_contact(k1_customer_no VARCHAR2,k1_site_no VARCHAR2, k1_contact_no VARCHAR2) IS SELECT org_cont.org_contact_id org_contact_id , acct_role.cust_account_role_id cust_account_role_id , acct_role.party_id cont_party_id , acct_role.cust_account_id cont_cust_acct_id , acct_role.role_type role_type , rel_party.party_id rel_party_id , org_cont.contact_number contact_number , acct_role.cust_acct_site_id , org_cont.party_site_id , role_acct.account_number , ki_addr.global_address_id FROM hz_cust_account_roles acct_role , hz_parties party , hz_parties rel_party , hz_relationships rel , hz_org_contacts org_cont , hz_cust_accounts role_acct , tk_address_xref ki_addr , tk_address_xref tk_addr , tk_customer_xref ki_cust , tk_customer_xref tk_cust , (SELECT name FROM v$database) tk_instance WHERE acct_role.party_id = rel.party_id AND acct_role.role_type = 'CONTACT' AND org_cont.party_relationship_id = rel.relationship_id AND rel.subject_id = party.party_id AND rel_party.party_id = rel.party_id AND acct_role.cust_account_id = role_acct.cust_account_id AND role_acct.party_id = rel.object_id AND acct_role.status = 'A' AND rel.status = 'A' AND party.status = 'A' AND rel_party.status = 'A' AND ki_addr.global_address_id = tk_addr.global_address_id AND ki_addr.status = 'A' AND tk_addr.status = 'A' AND ki_addr.set_of_books_code = 'K1' AND (SYSDATE BETWEEN ki_addr.start_date_active AND NVL (ki_addr.end_date_ active, SYSDATE + 1)) AND TO_CHAR(acct_role.cust_acct_site_id) = tk_addr.source_sys_addr_id AND tk_addr.set_of_books_code = DECODE (tk_instance.name ,'OMARCSDV ','MD' ,'OMARCSTS ','MD' ,'OMARCSOR ','MT' ,'OMARCSPD ','MP') AND tk_cust.global_customer_id = ki_cust.global_customer_id AND ki_cust.status = 'A' AND tk_cust.status = 'A' AND ki_cust.set_of_books_code = 'K1' AND tk_cust.set_of_books_code = DECODE (tk_instance.name ,'OMARCSDV ','MD' ,'OMARCSTS ','MD' ,'OMARCSOR

','MT' ,'OMARCSPD ','MP') AND ki_cust.source_sys_cust_number = TO_CHAR(k1_customer_no) AND ki_addr.source_sys_orig_sys_ref = TO_CHAR(k1_site_no) and acct_role.attribute2 = TO_CHAR(k1_contact_no); --Getting contact point id,contact point type based on the rel party id CURSOR omar_contact_type(p_rel_party_id NUMBER) IS SELECT cont_point.contact_point_id , cont_point.contact_point_type FROM hz_contact_points cont_point WHERE cont_point.owner_table_id = p_rel_party_id AND cont_point.status = 'A'; BEGIN IF p_level_contact='CUSTOMER' THEN fnd_file.put_line (fnd_file.output,'Keithley Customer Contacts Inactive at level '||p_level_contact); fnd_file.put_line (fnd_file.output,'-------------------------------------------------------------'); fnd_file.put_line (fnd_file.output,' '); fnd_file.put_line (fnd_file.output, RPAD ('Keithley_Customer_number', 30 , ' ') ||RPAD ('Keithley_Site_number', 30, ' ') ||RPAD ('Keithley_Contact_number', 30, ' ') ||RPAD ('OMAR Contact Level Update', 40, ' ') ||RPAD ('OMAR Contact ID', 30, ' ')); fnd_file.put_line (fnd_file.output,'--------------------------------------------------------------------------------------------------------------------------------------------'); g_k1_customer_no :=NULL; g_k1_site_no :=NULL; g_k1_contact_no :=NULL; FOR rec_cust_cont IN cust_cont LOOP g_k1_customer_no :=rec_cust_cont.k1_customer_no; g_k1_site_no :=NULL; g_k1_contact_no :=rec_cust_cont.k1_contact_no; fnd_file.put_line(fnd_file.log, 'K1 Customer Number Cust '|| rec_cust_cont.k1_customer_no); fnd_file.put_line(fnd_file.log, 'K1 Site Number Cust '|| rec_cust_cont.k1_site_no); fnd_file.put_line(fnd_file.log, 'K1 Contact Number Cust '|| rec_cust_cont.k1_contact_no); FOR rec_omar_customer_contact IN omar_customer_contact(rec_cust_cont .k1_customer_no ,rec_cust_ cont.k1_contact_no) LOOP

fnd_file.put_line(fnd_file.log, 'OMAR Customer Number '|| rec_omar_customer_contact.omar_customer_number); fnd_file.put_line(fnd_file.log, 'OMAR Customer Cust Account Role Id '|| rec_omar_customer_contact.cust_account_role_id); fnd_file.put_line(fnd_file.log, 'OMAR Customer Org Contact Id '|| rec_omar_customer_contact.org_contact_id); fnd_file.put_line(fnd_file.log, 'OMAR Customer Contact Number '|| rec_omar_customer_contact.contact_number); fnd_file.put_line(fnd_file.log, 'OMAR Customer Contact Party Id '|| rec_omar_customer_contact.cont_party_id); fnd_file.put_line(fnd_file.log, 'Keithley Customer '|| rec_omar_customer_contact.cont_party_id); fnd_file.put_line(fnd_file.log, 'OMAR Customer Contact Party Id '|| rec_omar_customer_contact.cont_party_id); update_cust_account_role_prc(rec_omar_customer_contact.cust_acco unt_role_id ,rec_omar_customer_contact.cont_cust_acc t_id ,rec_oma r_customer_contact.cont_party_id ,rec_omar_customer_contact.role_type); update_org_contact_prc(rec_omar_customer_contact.org_contact_id) ; FOR rec_omar_contact_type IN omar_contact_type(rec_omar_ customer_contact.rel_party_id) LOOP int Id fnd_file.put_line(fnd_file.log, 'OMAR Contact Po '|| rec_omar_contact_type.contact_point_id ); fnd_file.put_line(fnd_file.log, 'OMAR Contact Point Type '|| rec_omar_contact_type.contact_point_type);

IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='EMAIL' THEN update_email_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='PHONE' THEN update_phone_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='TLX' THEN update_telex_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='WEB' THEN update_web_contact_point_prc(rec_omar_contact_ty pe.contact_point_id); END IF; END LOOP; END LOOP; END LOOP; ELSIF p_level_contact='ADDRESS' THEN

fnd_file.put_line (fnd_file.output,'Keithley Address Contacts Inactive at Le vel '||p_level_contact); fnd_file.put_line (fnd_file.output,'------------------------------------------------------------'); fnd_file.put_line (fnd_file.output,' '); fnd_file.put_line (fnd_file.output, RPAD ('Keithley_Customer_number', 3 0, ' ') || RPAD ('Keithley_Site_number', 30, ' ') || RPA D ('Keithley_Contact_number', 30, ' ') || RPA D ('OMAR Contact Level Update', 40, ' ') || RPA D ('OMAR Contact ID', 30, ' ')); fnd_file.put_line (fnd_file.output,'-------------------------------------------------------------------------------------------------------------------------------'); g_k1_customer_no :=NULL; g_k1_site_no :=NULL; g_k1_contact_no :=NULL; FOR rec_addr_cont IN addr_cont LOOP g_k1_customer_no :=rec_addr_cont.k1_customer_no; g_k1_site_no :=rec_addr_cont.k1_site_no; g_k1_contact_no :=rec_addr_cont.k1_contact_no; fnd_file.put_line(fnd_file.log, 'K1 Customer Number Addr '|| rec_addr_cont.k1_customer_no); fnd_file.put_line(fnd_file.log, 'K1 Site Number Addr '|| rec_addr_cont.k1_site_no); fnd_file.put_line(fnd_file.log, 'K1 Contact Number Addr '|| rec_addr_cont.k1_contact_no); FOR rec_omar_address_contact IN omar_address_contact(rec_addr_cont.k 1_customer_no,rec_addr_cont.k1_site_no,rec_addr_cont.k1_contact_no) LOOP fnd_file.put_line(fnd_file.log, 'OMAR Address Id '|| rec_omar_address_contact.cust_account_role_id); fnd_file.put_line(fnd_file.log, 'OMAR Address '|| rec_omar_address_contact.org_contact_id); fnd_file.put_line(fnd_file.log, 'OMAR Address '|| rec_omar_address_contact.contact_number); fnd_file.put_line(fnd_file.log, 'OMAR Address '|| rec_omar_address_contact.cont_party_id); Cust Account Role Org Contact Id Contact Number Contact Party Id

update_cust_account_role_prc(rec_omar_address_contact.cust_accou nt_role_id ,rec_omar_address_contact.cont_cust_acct _id ,rec_oma r_address_contact.cont_party_id ,rec_omar_address_contact.role_type); --update_org_contact_prc(rec_omar_address_contact.org_contact_id ); update_org_contact_prc(rec_omar_address_contact.org_contact_id);

FOR rec_omar_contact_type IN omar_contact_type(rec_omar_ address_contact.rel_party_id) LOOP int Id fnd_file.put_line(fnd_file.log, 'OMAR Contact Po '|| rec_omar_contact_type.contact_point_id ); fnd_file.put_line(fnd_file.log, 'OMAR Contact Point Type '|| rec_omar_contact_type.contact_point_type);

IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='EMAIL' THEN update_email_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='PHONE' THEN update_phone_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='TLX' THEN update_telex_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='WEB' THEN update_web_contact_point_prc(rec_omar_contact_ty pe.contact_point_id); END IF; END LOOP; END LOOP; END LOOP; ELSIF p_level_contact='BOTH' THEN fnd_file.put_line (fnd_file.output,'Keithley Customer/Address Contacts Inact ive at level '||p_level_contact); fnd_file.put_line (fnd_file.output,'---------------------------------------------------------------------'); fnd_file.put_line (fnd_file.output,' '); fnd_file.put_line (fnd_file.output, RPAD ('Keithley_Customer_number', 3 0, ' ') || RPAD ('Keithley_Site_number', 30, ' ') || RPA D ('Keithley_Contact_number', 30, ' ') || RPA D ('OMAR Contact Level Update', 40, ' ') || RPA D ('OMAR Contact ID', 30, ' ')); fnd_file.put_line (fnd_file.output,'---------------------------------------------------------------------------------------------------------------------------------------------------'); g_k1_customer_no :=NULL; g_k1_site_no :=NULL; g_k1_contact_no :=NULL; FOR rec_cust_cont IN cust_cont LOOP

g_k1_customer_no :=rec_cust_cont.k1_customer_no; g_k1_site_no :=NULL; g_k1_contact_no :=rec_cust_cont.k1_contact_no; fnd_file.put_line(fnd_file.log, 'K1 Customer Number Cust Both '|| rec_cust_cont.k1_customer_no); fnd_file.put_line(fnd_file.log, 'K1 Site Number Cust Both '|| rec_cust_cont.k1_site_no); fnd_file.put_line(fnd_file.log, 'K1 Contact Number Cust Both '|| rec_cust_cont.k1_contact_no); FOR rec_omar_customer_contact IN omar_customer_contact(rec_cust_cont .k1_customer_no,rec_cust_cont.k1_contact_no) LOOP fnd_file.put_line(fnd_file.log, 'OMAR Customer Cust Account Role Id at BOTH '|| rec_omar_customer_contact.cust_account_role_id); fnd_file.put_line(fnd_file.log, 'OMAR Customer Org Contact Id a t BOTH '|| rec_omar_customer_contact.org_contact_id); fnd_file.put_line(fnd_file.log, 'OMAR Customer Contact Number at BOTH '|| rec_omar_customer_contact.contact_number); fnd_file.put_line(fnd_file.log, 'OMAR Customer Contact Party Id at BOTH '|| rec_omar_customer_contact.cont_party_id);

update_cust_account_role_prc(rec_omar_customer_contact.cust_acco unt_role_id ,rec_omar_customer_contact.cont_cust_acc t_id ,rec_oma r_customer_contact.cont_party_id ,rec_omar_customer_contact.role_type); --update_org_contact_prc(rec_omar_customer_contact.org_contact_i d); update_org_contact_prc(rec_omar_customer_contact.org_contact_id) ; FOR rec_omar_contact_type IN omar_contact_type(rec_omar_ customer_contact.rel_party_id) LOOP int Id at BOTH at BOTH fnd_file.put_line(fnd_file.log, 'OMAR Contact Po '|| rec_omar_contact_type.contact_point_id ); fnd_file.put_line(fnd_file.log, 'OMAR Contact Point Type '|| rec_omar_contact_type.contact_point_type);

IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='EMAIL' THEN update_email_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='PHONE' THEN update_phone_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='TLX' THEN update_telex_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF;

IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='WEB' THEN update_web_contact_point_prc(rec_omar_contact_ty pe.contact_point_id); END IF; END LOOP; END LOOP; END LOOP; FOR rec_addr_cont IN addr_cont LOOP g_k1_customer_no :=rec_addr_cont.k1_customer_no; g_k1_site_no :=rec_addr_cont.k1_site_no; g_k1_contact_no :=rec_addr_cont.k1_contact_no; fnd_file.put_line(fnd_file.log, 'K1 Customer Number Addr Both '|| rec_addr_cont.k1_customer_no); fnd_file.put_line(fnd_file.log, 'K1 Site Number Addr Both '|| rec_addr_cont.k1_site_no); fnd_file.put_line(fnd_file.log, 'K1 Contact Number Addr Both '|| rec_addr_cont.k1_contact_no); FOR rec_omar_address_contact IN omar_address_contact(rec_addr_cont.k 1_customer_no,rec_addr_cont.k1_site_no,rec_addr_cont.k1_contact_no) LOOP fnd_file.put_line(fnd_file.log, 'OMAR Address Cust Account Role Id at BOTH '|| rec_omar_address_contact.cust_account_role_id); fnd_file.put_line(fnd_file.log, 'OMAR Address Org Contact Id at BOTH '|| rec_omar_address_contact.org_contact_id); fnd_file.put_line(fnd_file.log, 'OMAR Address Contact Number at BOTH '|| rec_omar_address_contact.contact_number); fnd_file.put_line(fnd_file.log, 'OMAR Address Contact Party Id at BOTH '|| rec_omar_address_contact.cont_party_id); update_cust_account_role_prc(rec_omar_address_contact.cust_accou nt_role_id ,rec_omar_address_contact.cont_cust_acct _id ,rec_oma r_address_contact.cont_party_id ,rec_omar_address_contact.role_type); --update_org_contact_prc(rec_omar_address_contact.org_contact_id ); update_org_contact_prc(rec_omar_address_contact.org_contact_id); FOR rec_omar_contact_type IN omar_contact_type(rec_omar_ address_contact.rel_party_id) LOOP int Id at BOTH at BOTH fnd_file.put_line(fnd_file.log, 'OMAR Contact Po '|| rec_omar_contact_type.contact_point_id ); fnd_file.put_line(fnd_file.log, 'OMAR Contact Point Type '|| rec_omar_contact_type.contact_point_type);

IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='EMAIL' THEN update_email_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='PHONE' THEN

update_phone_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='TLX' THEN update_telex_contact_point_prc(rec_omar_contact_ type.contact_point_id); END IF; IF rec_omar_contact_type.contact_point_id IS NOT NUL L AND rec_omar_contact_type.contact_point_type ='WEB' THEN update_web_contact_point_prc(rec_omar_contact_ty pe.contact_point_id); END IF; END LOOP; END LOOP; END LOOP; END IF; EXCEPTION WHEN OTHERS THEN fnd_file.put_line (fnd_file.LOG, (SQLCODE || '-' || SQLERRM)); retcode := 2; END inactive_contact_prc; END tk_ki_ar_inactive_contact_pkg; / SHOW ERRORS;

You might also like