Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
cust_adi_customer_v3_pkg IS
PROCEDURE cust_vaildate_upload_data(p_validate_or_process_entry VARCHAR2,
---Validation---(1.54)
p_receivables_responsibility VARCHAR2,
---Validation---(1.52)
p_oracle_user_name VARCHAR2,
---Validation---(1.53)
p_new_or_existing_cust VARCHAR2,
---Validation---(1.13)
p_cust_no_if_exists VARCHAR2,
---Validation---(1.14, 1.15)
p_ou_name VARCHAR2,
---Party Level Field--- ---Validation---(1.1)
p_organization_name VARCHAR2,
---Party Level Field--- ---Validation---(1.11)
p_principal_name VARCHAR2,
---Party Level Field---
p_organization_name_phonetic VARCHAR2,
---Party Level Field---
p_tax_reference VARCHAR2,
---Party Level Field---
p_jgzz_fiscal_code VARCHAR2,
---Party Level Field---
p_known_as VARCHAR2,
---Party Level Field---
p_internal_flag VARCHAR2,
---Party Level Field--- ---Validation---(1.2)
p_customer_attribute_category VARCHAR2,
---Party Level Field---
p_customer_attribute1 VARCHAR2,
---Party Level Field---
p_customer_attribute2 VARCHAR2,
---Party Level Field---
p_customer_attribute3 VARCHAR2,
---Party Level Field---
p_customer_attribute4 VARCHAR2,
---Party Level Field---
p_customer_attribute5 VARCHAR2,
---Party Level Field---
p_customer_attribute6 VARCHAR2,
---Party Level Field---
p_customer_attribute7 VARCHAR2,
---Party Level Field---
p_customer_attribute8 VARCHAR2,
---Party Level Field---
p_customer_attribute9 VARCHAR2,
---Party Level Field---
p_customer_attribute10 VARCHAR2,
---Party Level Field---
p_customer_attribute11 VARCHAR2,
---Party Level Field---
p_customer_attribute12 VARCHAR2,
---Party Level Field---
p_customer_attribute13 VARCHAR2,
---Party Level Field---
p_customer_attribute14 VARCHAR2,
---Party Level Field---
p_customer_attribute15 VARCHAR2,
---Party Level Field---
p_new_or_existing_account VARCHAR2,
---Validation---(1.16, 1.17)
p_account_no_if_exists VARCHAR2,
---Validation---(1.18, 1.19, 1.20)
p_account_name VARCHAR2,
---Account Level Field--- ---Validation---(1.12)
p_customer_class_code VARCHAR2,
---Account Level Field--- ---Validation---(1.3)
p_account_price_list_name VARCHAR2,
---Account Level Field--- ---Validation---(1.6)
p_account_tax_code_name VARCHAR2,
---Account Level Field--- ---Validation---(1.7)
p_account_tax_name VARCHAR2,
---Account Level Field--- ---Validation---(1.7)
p_account_tax_regime_name VARCHAR2,
---Account Level Field--- ---Validation---(1.7)
p_account_freight_term VARCHAR2,
---Account Level Field--- ---Validation---(1.8)
p_ship_partial VARCHAR2,
---Account Level Field--- ---Validation---(1.2)
p_account_warehouse_name VARCHAR2,
---Account Level Field--- ---Validation---(1.9)
p_over_shipment_tol VARCHAR2,
---Account Level Field--- ---Validation---(1.10)
p_under_shipment_tol VARCHAR2,
---Account Level Field--- ---Validation---(1.10)
p_over_return_tol VARCHAR2,
---Account Level Field--- ---Validation---(1.10)
p_under_return_tol VARCHAR2,
---Account Level Field--- ---Validation---(1.10)
p_account_attribute_category VARCHAR2,
---Account Level Field---
p_account_attribute1 VARCHAR2,
---Account Level Field---
p_account_attribute2 VARCHAR2,
---Account Level Field---
p_account_attribute3 VARCHAR2,
---Account Level Field---
p_account_attribute4 VARCHAR2,
---Account Level Field---
p_account_attribute5 VARCHAR2,
---Account Level Field---
p_account_attribute6 VARCHAR2,
---Account Level Field---
p_account_attribute7 VARCHAR2,
---Account Level Field---
p_account_attribute8 VARCHAR2,
---Account Level Field---
p_account_attribute9 VARCHAR2,
---Account Level Field---
p_account_attribute10 VARCHAR2,
---Account Level Field---
p_account_attribute11 VARCHAR2,
---Account Level Field---
p_account_attribute12 VARCHAR2,
---Account Level Field---
p_account_attribute13 VARCHAR2,
---Account Level Field---
p_account_attribute14 VARCHAR2,
---Account Level Field---
p_account_attribute15 VARCHAR2,
---Account Level Field---
p_acc_prof_credit_checking VARCHAR2,
---Account Profile Level Field--- ---Validation---(1.2, 1.57, 1.60)
p_acc_prof_currency_code VARCHAR2,
---Account Profile Amount Level Field--- ---Validation---(1.55)
p_acc_prof_trx_credit_limit VARCHAR2,
---Account Profile Amount Level Field--- ---Validation---(1.10)
p_acc_prof_overal_credit_limit VARCHAR2,
---Account Profile Amount Level Field--- ---Validation---(1.10)
p_country VARCHAR2,
---Location Level Field--- ---Validation---(1.21)
p_address1 VARCHAR2,
---Location Level Field--- ---Validation---(1.24)
p_address2 VARCHAR2,
---Location Level Field---
p_address3 VARCHAR2,
---Location Level Field---
p_city VARCHAR2,
---Location Level Field---
p_postal_code VARCHAR2,
---Location Level Field---
p_state VARCHAR2,
---Location Level Field---
p_province VARCHAR2,
---Location Level Field---
p_county VARCHAR2,
---Location Level Field---
p_loc_attribute_category VARCHAR2,
---Location Level Field---
p_loc_attribute1 VARCHAR2,
---Location Level Field---
p_loc_attribute2 VARCHAR2,
---Location Level Field---
p_loc_attribute3 VARCHAR2,
---Location Level Field---
p_loc_attribute4 VARCHAR2,
---Location Level Field---
p_loc_attribute5 VARCHAR2,
---Location Level Field---
p_loc_attribute6 VARCHAR2,
---Location Level Field---
p_loc_attribute7 VARCHAR2,
---Location Level Field---
p_loc_attribute8 VARCHAR2,
---Location Level Field---
p_loc_attribute9 VARCHAR2,
---Location Level Field---
p_loc_attribute10 VARCHAR2,
---Location Level Field---
p_new_or_existing_site VARCHAR2,
---Validation---(1.22, 1.23)
p_site_no_if_exists VARCHAR2,
---Validation---(1.27, 1.28)
p_site_customer_category_code VARCHAR2,
---Account Site Level Field--- ---Validation---(1.25)
p_site_territory VARCHAR2,
---Account Site Level Field--- ---Validation---(1.26)
p_site_attribute_category VARCHAR2,
---Account Site Level Field---
p_site_attribute1 VARCHAR2,
---Account Site Level Field---
p_site_attribute2 VARCHAR2,
---Account Site Level Field---
p_site_attribute3 VARCHAR2,
---Account Site Level Field---
p_site_attribute4 VARCHAR2,
---Account Site Level Field---
p_site_attribute5 VARCHAR2,
---Account Site Level Field---
p_site_attribute6 VARCHAR2,
---Account Site Level Field---
p_site_attribute7 VARCHAR2,
---Account Site Level Field---
p_site_attribute8 VARCHAR2,
---Account Site Level Field---
p_site_attribute9 VARCHAR2,
---Account Site Level Field---
p_site_attribute10 VARCHAR2,
---Account Site Level Field---
p_site_use_site_use_code VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.29)
p_bill_to_site_use_id VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.49)
p_site_use_primary_flag VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.2)
p_site_use_payment_term_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.30)
p_site_use_ship_partial VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.2)
p_site_use_ship_via VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.51)
p_site_use_fob_point VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.47)
p_site_use_order_type_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.31)
p_site_use_price_list_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.32)
p_site_use_freight_term VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.33)
p_site_use_warehouse_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.34)
p_site_use_territory_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.35)
p_site_use_attribute_category VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute1 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute2 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute3 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute4 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute5 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute6 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute7 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute8 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute9 VARCHAR2,
---Account Site Use Level Field---
p_site_use_attribute10 VARCHAR2,
---Account Site Use Level Field---
p_site_use_tax_code_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.45)
p_site_use_tax_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.45)
p_site_use_tax_regime_name VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.45)
p_site_use_primary_salesrep_no VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.46)
p_site_use_over_shipment_tol VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.10)
p_site_use_under_shipment_tol VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.10)
p_site_use_over_return_tol VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.10)
p_site_use_under_return_tol VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.10)
p_site_use_shipset_inc_ln_flag VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.2)
p_site_use_pricing_event VARCHAR2,
---Account Site Use Level Field--- ---Validation---()
p_site_use_gl_code_rec VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.36, 1.50)
p_site_use_gl_code_rev VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.37, 1.50)
p_site_use_gl_code_tax VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.38, 1.50)
p_site_use_gl_code_freight VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.39, 1.50)
p_site_use_gl_code_clearing VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.40, 1.50)
p_site_use_gl_code_unbilled VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.41, 1.50)
p_site_use_gl_code_unearned VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.42, 1.50)
p_site_use_gl_code_unpaid_rec VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.43, 1.50)
p_site_use_gl_code_remittance VARCHAR2,
---Account Site Use Level Field--- ---Validation---(1.44, 1.50)
p_site_prof_credit_checking VARCHAR2,
---Site Profile Level Field--- ---Validation---(1.2, 1.58, 1.59, 1.61)
p_site_prof_currency_code VARCHAR2,
---Site Profile Amount Level Field--- ---Validation---(1.56)
p_site_prof_trx_credit_limit VARCHAR2,
---Site Profile Amount Level Field--- ---Validation---(1.10)
p_site_prof_overal_credit_limt VARCHAR2
---Site Profile Amount Level Field--- ---Validation---(1.10)
) IS
l_error_message VARCHAR2(3000);
l_error_code VARCHAR2(3000);
l_rec_resp_id NUMBER;
l_resp_application_id NUMBER;
l_user_id NUMBER;
l_org_id NUMBER;
l_organization_name VARCHAR2(3000);
l_cust_no_party_name VARCHAR2(3000);
l_account_no_acc_name VARCHAR2(3000);
l_account_no_party_num VARCHAR2(3000);
l_account_name VARCHAR2(3000);
l_customer_class_code VARCHAR2(200);
l_account_price_list_id NUMBER;
l_account_freight_term VARCHAR2(200);
l_account_tax_code VARCHAR2(200);
l_account_warehouse_id NUMBER;
l_numeric_validation VARCHAR2(200);
l_flag_validation VARCHAR2(200);
l_country VARCHAR2(200);
l_site_customer_category_code VARCHAR2(200);
l_site_territory_id NUMBER;
l_site_no_account_no VARCHAR2(200);
l_site_use_payment_term_id NUMBER;
l_site_use_order_type_id NUMBER;
l_site_use_price_list_id NUMBER;
l_site_use_freight_term VARCHAR2(200);
l_site_use_warehouse_id NUMBER;
l_site_use_territory_id NUMBER;
l_site_use_gl_id_rec NUMBER;
l_site_use_gl_id_rev NUMBER;
l_site_use_gl_id_tax NUMBER;
l_site_use_gl_id_freight NUMBER;
l_site_use_gl_id_clearing NUMBER;
l_site_use_gl_id_unbilled NUMBER;
l_site_use_gl_id_unearned NUMBER;
l_site_use_gl_id_unpaid_rec NUMBER;
l_site_use_gl_id_remittance NUMBER;
l_site_use_tax_code VARCHAR2(200);
l_site_use_primary_salesrep_id VARCHAR2(200);
l_site_use_fob_point VARCHAR2(200);
l_gl_ids_validation VARCHAR2(1000);
l_site_use_ship_via VARCHAR2(500);
l_acc_prof_currency_code VARCHAR2(100);
l_site_prof_currency_code VARCHAR2(100);
l_cust_newaccount_profile_id NUMBER;
p_cust_account_rec HZ_CUST_ACCOUNT_V2PUB.CUST_ACCOUNT_REC_TYPE;
p_organization_rec HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
p_customer_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
p_customer_site_profile_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUSTOMER_PROFILE_REC_TYPE;
p_location_rec HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
p_party_site_rec HZ_PARTY_SITE_V2PUB.PARTY_SITE_REC_TYPE;
p_cust_acct_site_rec
hz_cust_account_site_v2pub.cust_acct_site_rec_type;
p_cust_site_use_rec
HZ_CUST_ACCOUNT_SITE_V2PUB.CUST_SITE_USE_REC_TYPE;
p_cust_prof_amt_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUST_PROFILE_AMT_REC_TYPE;
p_cust_site_prof_amt_rec
HZ_CUSTOMER_PROFILE_V2PUB.CUST_PROFILE_AMT_REC_TYPE;
x_site_use_id NUMBER;
x_cust_acct_site_id NUMBER;
x_party_site_id NUMBER;
x_party_site_number VARCHAR2(2000);
x_location_id NUMBER;
x_cust_account_id NUMBER;
x_account_number VARCHAR2(2000);
x_party_id NUMBER;
x_party_number VARCHAR2(2000);
x_profile_id NUMBER;
x_cust_acc_site_profile_id NUMBER;
x_cust_acct_profile_amt_id NUMBER;
x_return_status VARCHAR2(2000);
x_msg_count NUMBER;
x_msg_data VARCHAR2(2000);
BEGIN
-------------------------------------------------------------
----------1.13 New or Existing Customer Flag is Mandatory----
-------------------------------------------------------------
BEGIN
END IF;
END;
-------------------------------------------------------------
----------1.16 New or Existing Account Flag is Mandatory-----
-------------------------------------------------------------
BEGIN
END IF;
END;
-------------------------------------------------------------
----------1.22 New or Existing Site Flag is Mandatory--------
-------------------------------------------------------------
BEGIN
END;
---------------------------------------------------------------
----------1.54 Validate or Process entry field is Mandatory----
---------------------------------------------------------------
BEGIN
END IF;
END;
-----------------------------------------------------------------------------------
------------
----------1.17 p_new_or_existing_cust is 'NEW' and p_new_or_existing_account is
'EXISTING'-----
-----------------------------------------------------------------------------------
------------
BEGIN
END IF;
END;
-----------------------------------------------------------------------------------
------------
----------1.23 p_new_or_existing_account is 'NEW' and p_new_or_existing_site is
'EXISTING'-----
-----------------------------------------------------------------------------------
------------
BEGIN
END IF;
END;
-----------------------------------------------------------------------------------
--------------------
----------1.14 "CUSTOMER_NUMBER_IF_EXISTING" field is Mandatory when entry is
marked as EXISTING-------
-----------------------------------------------------------------------------------
--------------------
BEGIN
END IF;
END;
-----------------------------------------------------------------------------------
---------------------
----------1.18 "ACCOUNT_NUMBER_IF_EXISTING" field is Mandatory when entry is
marked as is EXISTING-----
-----------------------------------------------------------------------------------
---------------------
BEGIN
END IF;
END;
-----------------------------------------------------------------------------------
---------------------
----------1.27 "SITE_NUMBER_IF_EXISTING" field is Mandatory when entry is
marked as is EXISTING--------
-----------------------------------------------------------------------------------
---------------------
BEGIN
END IF;
END;
-----------------------------------------------------------------------------------
----------
----------1.15 Customer Name against Customer Number does not match Customer
Name entered----
-----------------------------------------------------------------------------------
----------
THEN
BEGIN
select hp.party_name
into l_cust_no_party_name
from hz_parties hp
where 1 = 1
and hp.party_number = p_cust_no_if_exists;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a customer number that exists in the
system.';
l_error_code := 'E';
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
----------
----------1.19 Account Name against Account Number does not match Account Name
entered-------
-----------------------------------------------------------------------------------
----------
THEN
BEGIN
select hca.account_name
into l_account_no_acc_name
from hz_cust_accounts_all hca
where 1 = 1
and hca.account_number = p_account_no_if_exists;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter an account number that exists in the
system.';
l_error_code := 'E';
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
------
----------1.20 Ensure Account No provided exists under Customer
Provided-----------------
-----------------------------------------------------------------------------------
------
IF NVL(p_new_or_existing_account, 'A') = 'EXISTING'
THEN
BEGIN
SELECT hp.party_number
INTO l_account_no_party_num
FROM hz_parties hp, hz_cust_accounts_all hca
WHERE 1 = 1
AND hp.party_id = hca.party_id
AND hca.account_number = p_account_no_if_exists;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter an account number that exists in the
system.';
l_error_code := 'E';
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
------
----------1.28 Ensure Site No provided exists under Account
Provided---------------------
-----------------------------------------------------------------------------------
------
IF NVL(p_new_or_existing_site, 'A') = 'EXISTING'
THEN
BEGIN
SELECT hca.account_number
INTO l_site_no_account_no
FROM hz_party_sites hps,
hz_cust_accounts_all hca,
hz_cust_acct_sites_all hcasa
WHERE 1 = 1
AND hca.cust_account_id = hcasa.cust_account_id
AND hcasa.party_site_id = hps.party_site_id
AND hps.party_site_number = p_site_no_if_exists;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a site number that exists in the
system.';
l_error_code := 'E';
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
-----
--------------------1.55 Curreny Code Check Validation (Account
Level)------------------
-----------------------------------------------------------------------------------
-----
THEN
BEGIN
select fct.currency_code
into l_acc_prof_currency_code
from FND_CURRENCIES_TL fct
where 1 = 1
and fct.currency_code = p_acc_prof_currency_code;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a currency code that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--
--------------------1.56 Curreny Code Check Validation (Site
Level)------------------
-----------------------------------------------------------------------------------
--
THEN
BEGIN
select fct.currency_code
into l_site_prof_currency_code
from FND_CURRENCIES_TL fct
where 1 = 1
and fct.currency_code = p_site_prof_currency_code;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a currency code that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------
--------------------1.57 Curreny Code is mandatory if
p_acc_prof_credit_checking is 'Y'------------------
-----------------------------------------------------------------------------------
----------------------
THEN
END IF;
-----------------------------------------------------------------------------------
----------------------
--------------------1.58 Curreny Code is mandatory if
p_site_prof_credit_checking is 'Y'-----------------
-----------------------------------------------------------------------------------
----------------------
THEN
END IF;
-----------------------------------------------------------------------------------
-----------------------------------------
--------------------1.59 p_site_prof_credit_checking cannot be 'Y' if
p_site_use_site_use_code is 'SHIP_TO'-----------------
-----------------------------------------------------------------------------------
-----------------------------------------
THEN
-----------------------------------------------------------------------------------
------------------------------------------
--------------------1.60 p_acc_prof_credit_checking is null or NO and
p_acc_prof_currency_code is not null-------------------
-----------------------------------------------------------------------------------
------------------------------------------
THEN
END IF;
-----------------------------------------------------------------------------------
------------------------------------------
--------------------1.61 p_acc_prof_credit_checking is null or NO and
p_acc_prof_currency_code is not null-------------------
-----------------------------------------------------------------------------------
------------------------------------------
THEN
END IF;
------------------------------------------------------------------------
----------1.11 Organization (Customer) Name is Mandatory----------------
------------------------------------------------------------------------
BEGIN
select p_organization_name
into l_organization_name
from dual
where 1 = 1;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter an organization name.';
l_error_code := 'E';
END;
--------------------------------------------
----------1.1 Select Org ID-----------------
--------------------------------------------
BEGIN
select hou.ORGANIZATION_ID
into l_org_id
from hr_organization_units hou
where hou.NAME = p_ou_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter an operating unit defined in the system.';
l_error_code := 'E';
END;
------------------------------------------------------------------------
----------1.52 Receivables Responsibility ID is Mandatory----------------
------------------------------------------------------------------------
BEGIN
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a receivables responsibility name.';
l_error_code := 'E';
END;
------------------------------------------------------------------------
-----------------------1.53 User ID is Mandatory------------------------
------------------------------------------------------------------------
BEGIN
select fu.USER_ID
into l_user_id
from fnd_user fu
where 1 = 1
and fu.USER_NAME = p_oracle_user_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter an oracle user name.';
l_error_code := 'E';
END;
-----------------------------------------------------------------
----------Set Org ID for Customer Account & Site-----------------
-----------------------------------------------------------------
-- Fnd_client_info.set_org_context(l_org_id);
--------------------------------------------
---------1.2 Validate Flags entered---------
--------------------------------------------
BEGIN
-------------------------------------------------------------
----------1.12 Account Name is Mandatory---------------------
-------------------------------------------------------------
BEGIN
select p_account_name into l_account_name from dual where 1 = 1;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter an account name.';
l_error_code := 'E';
END;
---------------------------------------------------------------------
-----------------1.3 Customer Class Code Validation------------------
---------------------------------------------------------------------
IF p_customer_class_code is not null
THEN
BEGIN
SELECT lookup_code
INTO l_customer_class_code
FROM ar_lookups
WHERE lookup_type = 'CUSTOMER CLASS'
AND enabled_flag = 'Y'
AND lookup_code = p_customer_class_code;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a class lookup code setup in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------1.6 Account level Price List
Validation------------------------
-----------------------------------------------------------------------------------
THEN
BEGIN
SELECT qll.LIST_HEADER_ID
INTO l_account_price_list_id
FROM qp_list_headers_tl qll
WHERE 1 = 1
AND qll.NAME = p_account_price_list_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a price list that is setup in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------1.7 Account level Tax Code
Validation--------------------------
-----------------------------------------------------------------------------------
THEN
BEGIN
select zrb.TAX_RATE_CODE
into l_account_tax_code
from zx_rates_b zrb
where 1 = 1
and zrb.TAX_RATE_CODE = p_account_tax_code_name
and zrb.TAX = p_account_tax_name
and zrb.TAX_REGIME_CODE = p_account_tax_regime_name
and zrb.RATE_TYPE_CODE in ('PERCENTAGE', 'QUANTITY');
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a tax code that is setup in the system
against the provided Tax and Regime.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------1.8 Account level Freight Term
Validation----------------------
-----------------------------------------------------------------------------------
THEN
BEGIN
SELECT ol.lookup_code
INTO l_account_freight_term
FROM oe_lookups ol
WHERE 1 = 1
AND ol.LOOKUP_TYPE = 'FREIGHT_TERMS'
AND ol.lookup_code = p_account_freight_term
AND ol.enabled_flag = 'Y';
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a freight term lookup code that is setup
in the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------1.9 Account level Warehouse
Validation-------------------------
-----------------------------------------------------------------------------------
THEN
BEGIN
SELECT hou.ORGANIZATION_ID
INTO l_account_warehouse_id
FROM hr_organization_units hou
WHERE hou.NAME = p_account_warehouse_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a warehouse that is setup in the
system.';
l_error_code := 'E';
END;
END IF;
------------------------------------------------------
---------1.10 Validate Numeric fields entered---------
------------------------------------------------------
BEGIN
select TRIM(TRANSLATE(NVL(p_over_shipment_tol, 1) ||
--NVL(p_under_shipment_tol,1)||
NVL(p_over_return_tol, 1) ||
NVL(p_under_return_tol, 1) ||
NVL(p_site_use_over_shipment_tol, 1) ||
NVL(p_site_use_under_shipment_tol, 1) ||
NVL(p_site_use_over_return_tol, 1) ||
NVL(p_site_use_under_return_tol, 1) ||
NVL(p_acc_prof_trx_credit_limit, 1) ||
NVL(p_acc_prof_overal_credit_limit, 1) ||
NVL(p_site_prof_trx_credit_limit, 1) ||
NVL(p_site_prof_overal_credit_limt, 1),
'1234567890',
' '))
into l_numeric_validation
from dual;
-----------------------------------------------------------------------------------
-------------------------------1.21 Country Code
Validation------------------------
-----------------------------------------------------------------------------------
IF p_new_or_existing_site = 'NEW'
THEN
BEGIN
SELECT TERRITORY_CODE
INTO l_country
FROM FND_TERRITORIES
WHERE TERRITORY_CODE = p_country;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a correct country code.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
---------------
-------------------------------1.24 Address Line 1 is Mandatory if Site is
NEW--------------------
-----------------------------------------------------------------------------------
---------------
THEN
l_error_message := l_error_message || ',' ||
'Please enter an ADDRESS1 as the site is NEW.';
l_error_code := 'E';
END IF;
-----------------------------------------------------------------------------------
-----------
-------------------------------1.25 Customer Category Code
Validation-------------------------
-----------------------------------------------------------------------------------
-----------
BEGIN
SELECT lookup_code
INTO l_site_customer_category_code
FROM ar_lookups
WHERE lookup_type = 'CUSTOMER_CATEGORY'
AND enabled_flag = 'Y'
AND lookup_code = p_site_customer_category_code;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a customer category code defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
-----------
-------------------------------1.26 Territory ID
Validation-----------------------------------
-----------------------------------------------------------------------------------
-----------
THEN
BEGIN
SELECT rt.territory_id
INTO l_site_territory_id
FROM ra_territories_kfv rt
WHERE 1 = 1
AND rt.CONCATENATED_SEGMENTS = p_site_territory;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a territory defined in the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
-----------
-------------------------------1.29 SITE USE CODE
Validation----------------------------------
-----------------------------------------------------------------------------------
-----------
THEN
l_error_message := l_error_message || ',' ||
'Please enter a site use code as either BILL_TO or
SHIP_TO.';
l_error_code := 'E';
END IF;
--------------------------------------------------------------------------------
------1.48 BILL_TO_SITE_USE_ID Must be entered if Site Use Code is
SHIP_TO------
--------------------------------------------------------------------------------
THEN
l_error_message :=l_error_message
||','||
'Please enter the BILL_TO site use ID in order to
link it to this SHIP_TO entry.';
l_error_code := 'E';
END IF;
*/
--------------------------------------------------------------------------------
------1.49 BILL_TO_SITE_USE_ID cannot be entered if Site Use Code is
BILL_TO----
--------------------------------------------------------------------------------
THEN
l_error_message := l_error_message || ',' ||
'Please remove the BILL_TO site use ID as this is not a
SHIP_TO entry.';
l_error_code := 'E';
END IF;
-----------------------------------------------------------------------------------
----------------------------
-------------------------------1.30 Payment Term ID (Site Use Level)
Validation--------------------------------
-----------------------------------------------------------------------------------
----------------------------
THEN
BEGIN
SELECT rt.term_id
INTO l_site_use_payment_term_id
FROM ra_terms rt
WHERE 1 = 1
AND rt.NAME = p_site_use_payment_term_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Payment Term defined in the system for
the provided Operating Unit.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------------
-------------------------------1.31 Order Type ID Account Site Use
Validation--------------------------------
-----------------------------------------------------------------------------------
--------------------------
THEN
BEGIN
SELECT ott.transaction_type_id
INTO l_site_use_order_type_id
FROM oe_transaction_types_all ott, oe_transaction_types_tl ottl
WHERE 1 = 1
AND ott.TRANSACTION_TYPE_ID = ottl.TRANSACTION_TYPE_ID
AND ottl.NAME = p_site_use_order_type_name
AND ott.ORG_ID = l_org_id;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Order Type defined in the system for
the provided Operating Unit.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------------
-------------------------------1.32 Price List ID Account Site Use
Validation--------------------------------
-----------------------------------------------------------------------------------
--------------------------
THEN
BEGIN
SELECT qll.LIST_HEADER_ID
INTO l_site_use_price_list_id
FROM qp_list_headers_tl qll
WHERE 1 = 1
AND qll.NAME = p_site_use_price_list_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Price List defined in the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------------
-------------------------------1.33 Freight Term Account Site Use
Validation---------------------------------
-----------------------------------------------------------------------------------
--------------------------
THEN
BEGIN
SELECT ol.lookup_code
INTO l_site_use_freight_term
FROM oe_lookups ol
WHERE 1 = 1
AND ol.LOOKUP_TYPE = 'FREIGHT_TERMS'
AND ol.lookup_code = p_site_use_freight_term
AND ol.enabled_flag = 'Y';
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a freight term defined in the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------------
-------------------------------1.34 Warehouse ID Account Site Use
Validation---------------------------------
-----------------------------------------------------------------------------------
--------------------------
THEN
BEGIN
SELECT hou.ORGANIZATION_ID
INTO l_site_use_warehouse_id
FROM hr_organization_units hou
WHERE hou.NAME = p_site_use_warehouse_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Warehouse that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------------
-------------------------------1.35 Territory ID Account Site Use
Validation---------------------------------
-----------------------------------------------------------------------------------
--------------------------
THEN
BEGIN
SELECT rt.territory_id
INTO l_site_use_territory_id
FROM ra_territories_kfv rt
WHERE 1 = 1
AND rt.CONCATENATED_SEGMENTS = p_site_use_territory_name;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Territory that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.36 Receivable Account- Account Site Use
Validation---------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_rec
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_rec;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Receivable Account that is defined in
the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.37 Revenue Account- Account Site Use
Validation------------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_rev
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_rev;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Revenue Account that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.38 Tax Account- Account Site Use
Validation----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_tax
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_tax;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Tax Account that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.39 Freight Account- Account Site Use
Validation------------------------------------
-----------------------------------------------------------------------------------
----------------------------------
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_freight
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_freight;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Freight Account that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.40 Clearing Account- Account Site Use
Validation-----------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_clearing
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_clearing;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Clearing Account that is defined in
the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.41 Unbilled Account- Account Site Use
Validation-----------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_unbilled
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_unbilled;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Unbilled Account that is defined in
the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.42 Unearned Account- Account Site Use
Validation-----------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_unearned
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_unearned;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Unearned Account that is defined in
the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.43 Unpaid Account- Account Site Use
Validation-------------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_unpaid_rec
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_unpaid_rec;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Unpaid Account that is defined in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------
-------------------------------1.44 Remittance Account- Account Site Use
Validation---------------------------------
-----------------------------------------------------------------------------------
----------------------------------
THEN
BEGIN
SELECT gcc.code_combination_id
INTO l_site_use_gl_id_remittance
FROM gl_code_combinations_kfv gcc
WHERE 1 = 1
AND gcc.CONCATENATED_SEGMENTS = p_site_use_gl_code_remittance;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a Remittance Account that is defined in
the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------1.45 Account Use level Tax Code
Validation---------------------
-----------------------------------------------------------------------------------
THEN
BEGIN
select zrb.TAX_RATE_CODE
into l_account_tax_code
from zx_rates_b zrb
where 1 = 1
and zrb.TAX_RATE_CODE = p_site_use_tax_code_name
and zrb.TAX = p_site_use_tax_name
and zrb.TAX_REGIME_CODE = p_site_use_tax_regime_name
and zrb.RATE_TYPE_CODE in ('PERCENTAGE', 'QUANTITY');
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a tax code that is setup in the system
against the provided Tax and Regime.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
--------------------1.46 Account Use level Sales Rep Name
Validation---------------
-----------------------------------------------------------------------------------
THEN
BEGIN
SELECT jsl.SALESREP_ID
INTO l_site_use_primary_salesrep_id
FROM jtf_rs_resource_extns jrr, JTF_RS_SALESREPS jsl
WHERE 1 = 1
AND jrr.RESOURCE_ID = jsl.RESOURCE_ID
AND jsl.ORG_ID = l_org_id
AND jrr.RESOURCE_NUMBER = p_site_use_primary_salesrep_no;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a sales rep that is setup in the
system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
-
--------------------1.47 Account Use level FOB Point
Validation---------------------
-----------------------------------------------------------------------------------
-
THEN
BEGIN
SELECT lookup_code
INTO l_site_use_fob_point
FROM ar_lookups
WHERE 1 = 1
AND lookup_type = 'FOB'
AND enabled_flag = 'Y'
AND lookup_code = p_site_use_fob_point;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter an FOB point that is setup in the
system.';
l_error_code := 'E';
END;
END IF;
--------------------------------------------------------------------------
---------1.50 GL IDs cannot be entered if SITE USE is not BILL_TO---------
--------------------------------------------------------------------------
THEN
BEGIN
END IF;
-----------------------------------------------------------------------------------
--------------------1.51 Account Use level Shipment Method
Validation--------------
-----------------------------------------------------------------------------------
THEN
BEGIN
SELECT lookup_code
INTO l_site_use_ship_via
FROM fnd_lookup_values
WHERE 1 = 1
AND lookup_type = 'SHIP_METHOD'
AND enabled_flag = 'Y'
AND lookup_code = p_site_use_ship_via;
EXCEPTION
WHEN no_data_found THEN
l_error_message := l_error_message || ',' ||
'Please enter a shipment method code (Ship Via) that
is setup in the system.';
l_error_code := 'E';
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------****** PARTY AND ACCOUNT CREATION API BLOCK
******--------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-------- i. Condition to evaluate any error existing at this stage and
stopping the API-----------------------------------
-------- ii. If no error exists, a sub condition will evaluate weather the
party and Account exists------------------------
--------iii. party and Account exists for provided details, the API in this
block will be skipped--------------------------
-------- iv. If party and account doesnt exist for the provided details, a new
customer will be created--------------------
-------- v. If party exists and account doesnt exist for the provided details,
only a new account will be created---------
-----------------------------------------------------------------------------------
----------------------------------------
IF l_error_code = 'E'
THEN
raise_application_error(-20101, l_error_message);
THEN
THEN
BEGIN
END;
THEN
BEGIN
p_organization_rec.organization_name := p_organization_name;
p_organization_rec.principal_name := p_principal_name;
p_organization_rec.organization_name_phonetic :=
p_organization_name_phonetic;
p_organization_rec.tax_reference := p_tax_reference;
p_organization_rec.jgzz_fiscal_code := p_jgzz_fiscal_code;
p_organization_rec.known_as := p_known_as;
p_organization_rec.internal_flag := p_internal_flag;
p_organization_rec.party_rec.attribute_category :=
p_customer_attribute_category;
p_organization_rec.party_rec.attribute1 := p_customer_attribute1;
p_organization_rec.party_rec.attribute2 := p_customer_attribute2;
p_organization_rec.party_rec.attribute3 := p_customer_attribute3;
p_organization_rec.party_rec.attribute4 := p_customer_attribute4;
p_organization_rec.party_rec.attribute5 := p_customer_attribute5;
p_organization_rec.party_rec.attribute6 := p_customer_attribute6;
p_organization_rec.party_rec.attribute7 := p_customer_attribute7;
p_organization_rec.party_rec.attribute8 := p_customer_attribute8;
p_organization_rec.party_rec.attribute9 := p_customer_attribute9;
p_organization_rec.party_rec.attribute10 :=
p_customer_attribute10;
p_organization_rec.party_rec.attribute11 :=
p_customer_attribute11;
p_organization_rec.party_rec.attribute12 :=
p_customer_attribute12;
p_organization_rec.party_rec.attribute13 :=
p_customer_attribute13;
p_organization_rec.party_rec.attribute14 :=
p_customer_attribute14;
p_organization_rec.party_rec.attribute15 :=
p_customer_attribute15;
/* p_organization_rec.attribute_category:=
p_customer_attribute_category;
p_organization_rec.attribute1:= p_customer_attribute1;
p_organization_rec.attribute2:= p_customer_attribute2;
p_organization_rec.attribute3:= p_customer_attribute3;
p_organization_rec.attribute4:= p_customer_attribute4;
p_organization_rec.attribute5:= p_customer_attribute5;
p_organization_rec.attribute6:= p_customer_attribute6;
p_organization_rec.attribute7:= p_customer_attribute7;
p_organization_rec.attribute8:= p_customer_attribute8;
p_organization_rec.attribute9:= p_customer_attribute9;
p_organization_rec.attribute10:= p_customer_attribute10;
p_organization_rec.attribute11:= p_customer_attribute11;
p_organization_rec.attribute12:= p_customer_attribute12;
p_organization_rec.attribute13:= p_customer_attribute13;
p_organization_rec.attribute14:= p_customer_attribute14;
p_organization_rec.attribute15:= p_customer_attribute15; */
p_organization_rec.created_by_module := 'TCA_V2_API';
p_cust_account_rec.account_name := p_account_name;
p_cust_account_rec.customer_class_code := p_customer_class_code;
p_cust_account_rec.price_list_id := l_account_price_list_id;
p_cust_account_rec.tax_code := p_account_tax_code_name;
p_cust_account_rec.freight_term := p_account_freight_term;
p_cust_account_rec.ship_partial := p_ship_partial;
p_cust_account_rec.warehouse_id := l_account_warehouse_id;
-- p_cust_account_rec.over_shipment_tolerance :=
p_over_shipment_tol;
--p_cust_account_rec.under_shipment_tolerance := p_under_shipment_tol;
p_cust_account_rec.account_number := p_under_shipment_tol;
p_cust_account_rec.sales_channel_code := p_account_attribute15;
p_cust_account_rec.over_return_tolerance := p_over_return_tol;
p_cust_account_rec.under_return_tolerance := p_under_return_tol;
p_cust_account_rec.attribute_category :=
p_account_attribute_category;
p_cust_account_rec.attribute1 := p_account_attribute1;
p_cust_account_rec.attribute2 := p_account_attribute2;
p_cust_account_rec.attribute3 := p_account_attribute3;
p_cust_account_rec.attribute4 := p_account_attribute4;
p_cust_account_rec.attribute5 := p_account_attribute5;
p_cust_account_rec.attribute6 := p_account_attribute6;
p_cust_account_rec.attribute7 := p_account_attribute7;
p_cust_account_rec.attribute8 := p_account_attribute8;
p_cust_account_rec.attribute9 := p_account_attribute9;
p_cust_account_rec.attribute10 := p_account_attribute10;
p_cust_account_rec.attribute11 := p_account_attribute11;
p_cust_account_rec.attribute12 := p_account_attribute12;
p_cust_account_rec.attribute13 := p_account_attribute13;
p_cust_account_rec.attribute14 := p_account_attribute14;
p_cust_account_rec.attribute15 := p_account_attribute15;
p_customer_profile_rec.credit_checking := p_acc_prof_credit_checking;
p_cust_account_rec.created_by_module := 'TCA_V2_API';
hz_cust_account_v2pub.create_cust_account('T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_return_status = ' ||
SUBSTR(x_return_status, 1, 255));
dbms_output.put_line('x_msg_count = ' || TO_CHAR(x_msg_count));
dbms_output.put_line('Party Id = ' || TO_CHAR(x_party_id));
dbms_output.put_line('Party Number = ' || x_party_number);
dbms_output.put_line('Profile Id = ' || TO_CHAR(x_profile_id));
dbms_output.put_line('x_msg_data = ' ||
SUBSTR(x_msg_data, 1, 255));
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
THEN
SELECT hp.party_id
INTO x_party_id
FROM hz_parties hp
WHERE 1 = 1
AND hp.party_number = p_cust_no_if_exists;
BEGIN
p_organization_rec.party_rec.party_id := x_party_id;
p_cust_account_rec.account_name := p_account_name;
p_cust_account_rec.account_number := p_under_shipment_tol;
p_cust_account_rec.sales_channel_code := p_account_attribute15;
p_cust_account_rec.customer_class_code := p_customer_class_code;
p_cust_account_rec.price_list_id := l_account_price_list_id;
p_cust_account_rec.tax_code := p_account_tax_code_name;
p_cust_account_rec.freight_term := p_account_freight_term;
p_cust_account_rec.ship_partial := p_ship_partial;
p_cust_account_rec.warehouse_id := l_account_warehouse_id;
-- p_cust_account_rec.over_shipment_tolerance :=
p_over_shipment_tol;
--p_cust_account_rec.under_shipment_tolerance := p_under_shipment_tol;
p_cust_account_rec.over_return_tolerance := p_over_return_tol;
p_cust_account_rec.under_return_tolerance := p_under_return_tol;
p_cust_account_rec.attribute_category :=
p_account_attribute_category;
p_cust_account_rec.attribute1 := p_account_attribute1;
p_cust_account_rec.attribute2 := p_account_attribute2;
p_cust_account_rec.attribute3 := p_account_attribute3;
p_cust_account_rec.attribute4 := p_account_attribute4;
p_cust_account_rec.attribute5 := p_account_attribute5;
p_cust_account_rec.attribute6 := p_account_attribute6;
p_cust_account_rec.attribute7 := p_account_attribute7;
p_cust_account_rec.attribute8 := p_account_attribute8;
p_cust_account_rec.attribute9 := p_account_attribute9;
p_cust_account_rec.attribute10 := p_account_attribute10;
p_cust_account_rec.attribute11 := p_account_attribute11;
p_cust_account_rec.attribute12 := p_account_attribute12;
p_cust_account_rec.attribute13 := p_account_attribute13;
p_cust_account_rec.attribute14 := p_account_attribute14;
p_cust_account_rec.attribute15 := p_account_attribute15;
p_customer_profile_rec.credit_checking := p_acc_prof_credit_checking;
p_cust_account_rec.created_by_module := 'TCA_V2_API';
hz_cust_account_v2pub.create_cust_account('T',
p_cust_account_rec,
p_organization_rec,
p_customer_profile_rec,
'F',
x_cust_account_id,
x_account_number,
x_party_id,
x_party_number,
x_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_return_status = ' ||
SUBSTR(x_return_status, 1, 255));
dbms_output.put_line('x_msg_count = ' || TO_CHAR(x_msg_count));
dbms_output.put_line('Party Id = ' || TO_CHAR(x_party_id));
dbms_output.put_line('Party Number = ' || x_party_number);
dbms_output.put_line('Profile Id = ' || TO_CHAR(x_profile_id));
dbms_output.put_line('x_msg_data = ' ||
SUBSTR(x_msg_data, 1, 255));
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
END IF;
END IF;
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
------------------------------****** ACCOUNT LEVEL PROFILE AMOUNT CREATION API
BLOCK ******--------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-------------------- i. If Account Level Credit Checking is Set to 'Y', then
Credit Limit will be created-----------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
THEN
BEGIN
p_cust_prof_amt_rec.cust_account_id := x_cust_account_id;
p_cust_prof_amt_rec.cust_account_profile_id :=
l_cust_newaccount_profile_id;
--p_cust_prof_amt_rec.site_use_id := xxx;
p_cust_prof_amt_rec.currency_code := p_acc_prof_currency_code;
p_cust_prof_amt_rec.overall_credit_limit := p_acc_prof_overal_credit_limit;
p_cust_prof_amt_rec.trx_credit_limit := p_acc_prof_trx_credit_limit;
p_cust_prof_amt_rec.created_by_module := 'TCA_V2_API';
hz_customer_profile_v2pub.create_cust_profile_amt('T',
'T',
p_cust_prof_amt_rec,
x_cust_acct_profile_amt_id,
x_return_status,
x_msg_count,
x_msg_data);
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
--------------------------------------****** LOCATION CREATION API BLOCK
******--------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-------------------- i. If Party Site to be Created is NEW, the a new location
will be created----------------------------
-------------------- ii. If Party Site to be Created is EXISTING, the API in
this block will be skipped--------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
THEN
BEGIN
p_location_rec.country := p_country;
p_location_rec.address1 := p_address1;
p_location_rec.address2 := p_address2;
p_location_rec.address3 := p_address3;
p_location_rec.city := p_city;
p_location_rec.postal_code := p_postal_code;
p_location_rec.state := p_state;
p_location_rec.province := p_province;
p_location_rec.county := p_county;
p_location_rec.attribute_category := p_loc_attribute_category;
p_location_rec.attribute1 := p_loc_attribute1;
p_location_rec.attribute2 := p_loc_attribute2;
p_location_rec.attribute3 := p_loc_attribute3;
p_location_rec.attribute4 := p_loc_attribute4;
p_location_rec.attribute5 := p_loc_attribute5;
p_location_rec.attribute6 := p_loc_attribute6;
p_location_rec.attribute7 := p_loc_attribute7;
p_location_rec.attribute8 := p_loc_attribute8;
p_location_rec.attribute9 := p_loc_attribute9;
p_location_rec.attribute10 := p_loc_attribute10;
p_location_rec.created_by_module := 'TCA_V2_API';
hz_location_v2pub.create_location('T',
p_location_rec,
x_location_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_return_status = ' ||
SUBSTR(x_return_status, 1, 255));
dbms_output.put_line('x_msg_count = ' || TO_CHAR(x_msg_count));
dbms_output.put_line('Location Id = ' || TO_CHAR(x_location_id));
dbms_output.put_line('Country = ' ||
SUBSTR(p_location_rec.country, 1, 255));
dbms_output.put_line('Address1 = ' ||
SUBSTR(p_location_rec.Address1, 1, 255));
dbms_output.put_line('State = ' ||
SUBSTR(p_location_rec.state, 1, 255));
dbms_output.put_line('Created By = ' ||
SUBSTR(p_location_rec.created_by_module,
1,
255));
dbms_output.put_line('x_msg_data = ' || SUBSTR(x_msg_data, 1, 255));
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
--------------------------------------****** PARTY SITE CREATION API BLOCK
******------------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-------------------- i. If Party Site to be Created is NEW, the a new party
site will be created--------------------------
-------------------- ii. If Party Site to be Created is EXISTING, the API in
this block will be skipped--------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
THEN
BEGIN
p_party_site_rec.party_id := x_party_id;
p_party_site_rec.location_id := x_location_id;
p_party_site_rec.identifying_address_flag := 'Y';
p_party_site_rec.attribute_category := p_site_attribute_category;
p_party_site_rec.attribute1 := p_site_attribute1;
p_party_site_rec.attribute2 := p_site_attribute2;
p_party_site_rec.attribute3 := p_site_attribute3;
p_party_site_rec.attribute4 := p_site_attribute4;
p_party_site_rec.attribute5 := p_site_attribute5;
p_party_site_rec.attribute6 := p_site_attribute6;
p_party_site_rec.attribute7 := p_site_attribute7;
p_party_site_rec.attribute8 := p_site_attribute8;
p_party_site_rec.attribute9 := p_site_attribute9;
p_party_site_rec.attribute10 := p_site_attribute10;
p_party_site_rec.created_by_module := 'TCA_V2_API';
hz_party_site_v2pub.create_party_site('T',
p_party_site_rec,
x_party_site_id,
x_party_site_number,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_return_status = ' ||
SUBSTR(x_return_status, 1, 255));
dbms_output.put_line('x_msg_count = ' || TO_CHAR(x_msg_count));
dbms_output.put_line('Party Site Id = ' ||
TO_CHAR(x_party_site_id));
dbms_output.put_line('Party Site Number = ' ||
SUBSTR(x_party_site_number, 1, 255));
dbms_output.put_line('x_msg_data = ' || SUBSTR(x_msg_data, 1, 255));
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
--------------------------------------****** ACCOUNT SITE CREATION API BLOCK
******----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-------------------- i. If Party Site to be Created is NEW, the a new account
site will be created------------------------
-------------------- ii. If Party Site to be Created is EXISTING, the API in
this block will be skipped--------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
THEN
BEGIN
SELECT hcasa.cust_acct_site_id
INTO x_cust_acct_site_id
FROM hz_cust_acct_sites_all hcasa, hz_party_sites hps
WHERE hcasa.party_site_id = hps.party_site_id
AND hps.party_site_number = p_site_no_if_exists;
END;
THEN
BEGIN
p_cust_acct_site_rec.cust_account_id := x_cust_account_id;
p_cust_acct_site_rec.party_site_id := x_party_site_id;
p_cust_acct_site_rec.customer_category_code :=
p_site_customer_category_code;
p_cust_acct_site_rec.territory_id := l_site_territory_id;
/* p_cust_acct_site_rec.attribute_category := p_site_attribute_category;
p_cust_acct_site_rec.attribute1 := p_site_attribute1;
p_cust_acct_site_rec.attribute2 := p_site_attribute2;
p_cust_acct_site_rec.attribute3 := p_site_attribute3;
p_cust_acct_site_rec.attribute4 := p_site_attribute4;
p_cust_acct_site_rec.attribute5 := p_site_attribute5;
p_cust_acct_site_rec.attribute6 := p_site_attribute6;
p_cust_acct_site_rec.attribute7 := p_site_attribute7;
p_cust_acct_site_rec.attribute8 := p_site_attribute8;
p_cust_acct_site_rec.attribute9 := p_site_attribute9;
p_cust_acct_site_rec.attribute10 := p_site_attribute10; */
p_cust_acct_site_rec.org_id := l_org_id;
p_cust_acct_site_rec.created_by_module := 'TCA_V2_API';
hz_cust_account_site_v2pub.create_cust_acct_site('T',
p_cust_acct_site_rec,
x_cust_acct_site_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_return_status = ' ||
SUBSTR(x_return_status, 1, 255));
dbms_output.put_line('x_msg_count = ' || TO_CHAR(x_msg_count));
dbms_output.put_line('Customer Account Site Id is = ' ||
TO_CHAR(x_cust_acct_site_id));
dbms_output.put_line('x_msg_data = ' || SUBSTR(x_msg_data, 1, 255));
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
--------------------------------------****** ACCOUNT SITE USE CREATION API
BLOCK ******------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-------------------- i. If Party Site to be Created is NEW, the a new account
site will be created------------------------
-------------------- ii. If Party Site to be Created is EXISTING, the API in
this block will be skipped--------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
IF 1 = 1
THEN
BEGIN
p_cust_site_use_rec.cust_acct_site_id := x_cust_acct_site_id;
p_cust_site_use_rec.site_use_code :=
p_site_use_site_use_code;
p_cust_site_use_rec.bill_to_site_use_id := p_bill_to_site_use_id;
p_cust_site_use_rec.primary_flag :=
p_site_use_primary_flag;
p_cust_site_use_rec.payment_term_id :=
l_site_use_payment_term_id;
p_cust_site_use_rec.ship_partial :=
p_site_use_ship_partial;
p_cust_site_use_rec.ship_via := p_site_use_ship_via;
p_cust_site_use_rec.fob_point := p_site_use_fob_point;
p_cust_site_use_rec.order_type_id :=
l_site_use_order_type_id;
p_cust_site_use_rec.price_list_id :=
l_site_use_price_list_id;
p_cust_site_use_rec.freight_term :=
p_site_use_freight_term;
p_cust_site_use_rec.warehouse_id :=
l_site_use_warehouse_id;
p_cust_site_use_rec.territory_id :=
l_site_use_territory_id;
p_cust_site_use_rec.attribute_category :=
p_site_use_attribute_category;
p_cust_site_use_rec.attribute1 := p_site_use_attribute1;
p_cust_site_use_rec.attribute2 := p_site_use_attribute2;
p_cust_site_use_rec.attribute3 := p_site_use_attribute3;
p_cust_site_use_rec.attribute4 := p_site_use_attribute4;
p_cust_site_use_rec.attribute5 := p_site_use_attribute5;
p_cust_site_use_rec.attribute6 := p_site_use_attribute6;
p_cust_site_use_rec.attribute7 := p_site_use_attribute7;
p_cust_site_use_rec.attribute8 := p_site_use_attribute8;
p_cust_site_use_rec.attribute9 := p_site_use_attribute9;
p_cust_site_use_rec.attribute10 := p_site_use_attribute10;
p_cust_site_use_rec.tax_code :=
p_site_use_tax_code_name;
p_cust_site_use_rec.primary_salesrep_id :=
l_site_use_primary_salesrep_id;
p_cust_site_use_rec.over_shipment_tolerance :=
p_site_use_over_shipment_tol;
p_cust_site_use_rec.under_shipment_tolerance :=
p_site_use_under_shipment_tol;
p_cust_site_use_rec.over_return_tolerance :=
p_site_use_over_return_tol;
p_cust_site_use_rec.under_return_tolerance :=
p_site_use_under_return_tol;
p_cust_site_use_rec.ship_sets_include_lines_flag :=
p_site_use_shipset_inc_ln_flag;
p_cust_site_use_rec.pricing_event :=
p_site_use_pricing_event;
p_cust_site_use_rec.gl_id_rec := l_site_use_gl_id_rec;
p_cust_site_use_rec.gl_id_rev := l_site_use_gl_id_rev;
p_cust_site_use_rec.gl_id_tax := l_site_use_gl_id_tax;
p_cust_site_use_rec.gl_id_freight :=
l_site_use_gl_id_freight;
p_cust_site_use_rec.gl_id_clearing :=
l_site_use_gl_id_clearing;
p_cust_site_use_rec.gl_id_unbilled :=
l_site_use_gl_id_unbilled;
p_cust_site_use_rec.gl_id_unearned :=
l_site_use_gl_id_unearned;
p_cust_site_use_rec.gl_id_unpaid_rec :=
l_site_use_gl_id_unpaid_rec;
p_cust_site_use_rec.gl_id_remittance :=
l_site_use_gl_id_remittance;
p_cust_site_use_rec.created_by_module := 'TCA_V2_API';
hz_cust_account_site_v2pub.create_cust_site_use('T',
p_cust_site_use_rec,
p_customer_profile_rec,
'',
'',
x_site_use_id,
x_return_status,
x_msg_count,
x_msg_data);
dbms_output.put_line('x_return_status = ' ||
SUBSTR(x_return_status, 1, 255));
dbms_output.put_line('x_msg_count = ' || TO_CHAR(x_msg_count));
dbms_output.put_line('Site Use Id = ' || TO_CHAR(x_site_use_id));
dbms_output.put_line('Site Use = ' ||
SUBSTR(p_cust_site_use_rec.site_use_code,
1,
255));
dbms_output.put_line('x_msg_data = ' || SUBSTR(x_msg_data, 1, 255));
IF x_msg_count > 0
THEN
IF x_msg_count > 0 THEN
FOR I IN 1 .. x_msg_count LOOP
l_error_message := I || '.' || SUBSTR(FND_MSG_PUB.Get(p_encoded =>
FND_API.G_FALSE),
1,
255);
END LOOP;
END IF;
END IF;
END;
END IF;
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
------------------------------****** SITE LEVEL PROFILE & PROFILE AMOUNT
CREATION API BLOCK ******-------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
-------------------- i. If Site Level Credit Checking is Set to 'Y', then
Credit Limit will be created--------------------
-----------------------------------------------------------------------------------
----------------------------------------
-----------------------------------------------------------------------------------
----------------------------------------
IF p_site_prof_credit_checking = 'Y'
THEN
BEGIN
p_customer_site_profile_rec.site_use_id := x_site_use_id;
p_customer_site_profile_rec.cust_account_id := x_cust_account_id;
p_customer_site_profile_rec.status := 'A';
p_customer_site_profile_rec.credit_checking :=
p_site_prof_credit_checking;
p_customer_site_profile_rec.created_by_module := 'TCA_V2_API';
HZ_CUSTOMER_PROFILE_V2PUB.create_customer_profile('T',
p_customer_site_profile_rec,
'F',
x_cust_acc_site_profile_id,
x_return_status,
x_msg_count,
x_msg_data);
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
END IF;
-----------------------------CREDIT LIMIT
CREATION--------------------------------
IF p_site_prof_credit_checking = 'Y'
THEN
BEGIN
p_cust_site_prof_amt_rec.cust_account_id := x_cust_account_id;
p_cust_site_prof_amt_rec.cust_account_profile_id :=
x_cust_acc_site_profile_id;
p_cust_site_prof_amt_rec.site_use_id := x_site_use_id;
p_cust_site_prof_amt_rec.currency_code :=
p_site_prof_currency_code;
p_cust_site_prof_amt_rec.overall_credit_limit :=
p_site_prof_overal_credit_limt;
p_cust_site_prof_amt_rec.trx_credit_limit :=
p_site_prof_trx_credit_limit;
p_cust_site_prof_amt_rec.created_by_module := 'TCA_V2_API';
hz_customer_profile_v2pub.create_cust_profile_amt('T',
'T',
p_cust_site_prof_amt_rec,
x_cust_acct_profile_amt_id,
x_return_status,
x_msg_count,
x_msg_data);
IF x_msg_count > 0
THEN
raise_application_error(-20101, l_error_message);
END IF;
END;
END IF;
IF p_validate_or_process_entry = 'VALIDATE'
THEN
ROLLBACK;
THEN
COMMIT;
END IF;
END cust_vaildate_upload_data;
END cust_adi_customer_v3_pkg;
/