Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

/*Formattedon30/11/20165:47:20PM(QP5v5.215.12089.

38647)*/
DECLARE
l_cust_account_rechz_cust_account_v2pub.cust_account_rec_type;
l_customer_profile_rec
hz_customer_profile_v2pub.customer_profile_rec_type;
l_cust_site_use_rechz_cust_account_site_v2pub.cust_site_use_rec_type;
l_prof_class_ovnNUMBER;
l_resp_idNUMBER;
l_appl_idNUMBER;
l_return_statusVARCHAR2(10);
l_msg_countNUMBER;
l_msg_dataVARCHAR2(1000);
l_msgVARCHAR2(1000);
l_msg_index_outNUMBER;
l_error_messageVARCHAR2(1000);
l_error_flagVARCHAR2(1);
l_countPLS_INTEGER:=0;
l_org_idNUMBER:=&ORG_ID;
CURSORcustomer_cur
IS
SELECTp.party_id,party_namecustomer_name,ca.cust_account_id
FROMhz_partiesp,hz_cust_accountsca
WHEREp.party_id=ca.party_id
ANDca.account_numberIN(SELECTt.ACCOUNT_NUMBER
FROMXXX_CUSTOMER_UPDATEDt);
ANDca.account_number='20010'
ORDERBY4
CURSORcust_site_cur(
p_cust_acct_idINNUMBER)
IS
SELECTcas.cust_acct_site_id,
csu.site_use_id,
csu.object_version_number,
(SELECT(SELECTTERM_ID
FROMRA_TERMS
WHEREUPPER(NAME)LIKEUPPER(PAYMENT_TERMS)AND
SEGMENT1='03'
)
PAYMENT_TERMS
FROMXXX_CUSTOMER_UPDATEDt,hz_cust_accountshcaa
WHEREt.ACCOUNT_NUMBER=hcaa.ACCOUNT_NUMBER
ANDhcaa.cust_account_id=cas.cust_account_id)
PAYMENT_TERMS,
(SELECT(SELECTTRANSACTION_TYPE_ID
FROMoe_transaction_types_tl
WHEREUPPER(NAME)LIKEUPPER(WADI_ORDER_TYPE)
ANDLANGUAGE='US')
TRANSACTION_TYPE_ID
FROMXXX_CUSTOMER_UPDATEDt,hz_cust_accountshcaa

WHEREt.ACCOUNT_NUMBER=hcaa.ACCOUNT_NUMBER
ANDhcaa.cust_account_id=cas.cust_account_id)
TRANSACTION_TYPE_ID,

(SELECT(SELECTLIST_HEADER_ID
FROMQP_LIST_HEADERS_TL
WHEREUPPER(NAME)LIKEUPPER(PRICE_LISTS)
ANDLANGUAGE='US')
LIST_HEADER_ID
FROMXXX_CUSTOMER_UPDATEDt,hz_cust_accountshcaa
WHEREt.ACCOUNT_NUMBER=hcaa.ACCOUNT_NUMBER
ANDhcaa.cust_account_id=
cas.cust_account_id)LIST_HEADER_ID

FROMhz_cust_acct_sitescas,hz_cust_site_usescsu
WHEREcas.cust_acct_site_id=csu.cust_acct_site_id
ANDcsu.site_use_code='BILL_TO'
ANDcas.cust_account_id=p_cust_acct_id;
BEGIN
mo_global.init('AR');
mo_global.set_policy_context('S',l_org_id);
fnd_profile.initialize(&USER_ID,50208,222);
fnd_global.apps_initialize(&USER_ID,50208,222);
fnd_global.apps_initialize(1130,20678,222);
FORcustomer_recINcustomer_cur
LOOP
hz_cust_account_v2pub.get_cust_account_rec(
fnd_api.g_true,
customer_rec.cust_account_id,
l_cust_account_rec,
l_customer_profile_rec,
l_return_status,
l_msg_count,
l_msg_data);
l_customer_profile_rec.profile_class_id:='&PROF_CLASS_ID';
SELECTobject_version_number
INTOl_prof_class_ovn
FROMhz_customer_profiles
WHEREcust_account_profile_id=
l_customer_profile_rec.cust_account_profile_id;
hz_customer_profile_v2pub.update_customer_profile(
fnd_api.g_false,
l_customer_profile_rec,
l_prof_class_ovn,
l_return_status,
l_msg_count,
l_msg_data);

IFl_return_status!=fnd_api.g_ret_sts_success
THEN
IF(fnd_msg_pub.count_msg>1)
THEN
FORkIN1..fnd_msg_pub.count_msg
LOOP
fnd_msg_pub.get(p_msg_index=>k,
p_encoded=>'F',
p_data=>l_msg_data,
p_msg_index_out=>l_msg_index_out);
l_error_message:=l_error_message||CHR(10)||l_msg_data;
ENDLOOP;
ELSE
fnd_msg_pub.get(p_msg_index=>1,
p_encoded=>'F',
p_data=>l_msg_data,
p_msg_index_out=>l_msg_index_out);
l_error_message:=l_msg_data;
ENDIF;
DBMS_OUTPUT.put_line(
'Errorinupdatingprofileforcustomer"'
||customer_rec.customer_name
||'":'
||l_error_message);
ROLLBACK;
ELSE
FORcust_site_recINcust_site_cur(customer_rec.cust_account_id)
LOOP
l_cust_site_use_rec.gl_id_rec:=
cust_site_rec.Receivable_Account_ID;

hz_cust_account_site_v2pub.get_cust_site_use_rec(
fnd_api.g_false,
cust_site_rec.site_use_id,
l_cust_site_use_rec,
l_customer_profile_rec,
l_return_status,
l_msg_count,
l_msg_data);
l_cust_site_use_rec.payment_term_id:=5;Immediate

l_cust_site_use_rec.price_list_id:=cust_site_rec.LIST_HEADER_ID;
SSEStandard
l_cust_site_use_rec.payment_term_id:=
cust_site_rec.PAYMENT_TERMS;90DaysRA_TERMS
l_cust_site_use_rec.order_type_id:=
cust_site_rec.TRANSACTION_TYPE_ID;SSEDuabiShowroomCashSales
oe_transaction_types_tl

hz_cust_account_site_v2pub.update_cust_site_use(
fnd_api.g_false,
l_cust_site_use_rec,
cust_site_rec.object_version_number,
l_return_status,
l_msg_count,
l_msg_data);
IFl_return_status!=fnd_api.g_ret_sts_success
THEN
IF(fnd_msg_pub.count_msg>1)
THEN
FORkIN1..fnd_msg_pub.count_msg
LOOP
fnd_msg_pub.get(p_msg_index=>k,
p_encoded=>'F',
p_data=>l_msg_data,
p_msg_index_out=>l_msg_index_out);
l_error_message:=
l_error_message||CHR(10)||l_msg_data;
ENDLOOP;
ELSE
fnd_msg_pub.get(p_msg_index=>1,
p_encoded=>'F',
p_data=>l_msg_data,
p_msg_index_out=>l_msg_index_out);
l_error_message:=l_msg_data;
ENDIF;
DBMS_OUTPUT.put_line(
'Errorinupdatingsiteuseforcustomer"'
||customer_rec.customer_name
||'":'
||l_error_message);
ROLLBACK;
EXIT;
ENDIF;
ENDLOOP;
COMMIT;
ENDIF;
ENDLOOP;
END;

You might also like