Posts By: Phani Adivi
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Script to create a Debit Memo (AR)
The following script can be used to create a Basic Debit memo. The API that is used to create an AR Invoice is – “ar_invoice_api_pub.create_invoice“. The Cust_trx_type_id decides whether the invoice getting created is a Standard Invoice or a Credit Memo or a Debit memo. Based on this value, the API also checks the sign of the amount on the Line level that is being passed.
--Script to create Debit memo.
DECLARE
l_index NUMBER := 0;
l_line_index NUMBER := 0;
l_dist_index NUMBER := 0;
l_cm_customer_trx_id NUMBER := 0;
--
l_batch_source_rec ar_invoice_api_pub.batch_source_rec_type;
l_trx_header_tbl ar_invoice_api_pub.trx_header_tbl_type;
l_trx_lines_tbl ar_invoice_api_pub.trx_line_tbl_type;
l_trx_line_id NUMBER;
l_return_status VARCHAR2 (1);
l_trx_dist_tbl ar_invoice_api_pub.trx_dist_tbl_type;
l_trx_salescredits_tbl ar_invoice_api_pub.trx_salescredits_tbl_type;
l_msg_data VARCHAR2 (2000);
l_resp_id NUMBER;
l_appl_id NUMBER;
l_user_name VARCHAR2 (200);
g_user_id fnd_user.user_id%TYPE;
l_line_number NUMBER := 0;
l_msg_count NUMBER;
l_ou_id hr_operating_units.organization_id%TYPE;
l_batch_source_id ra_batch_sources_all.batch_source_id%TYPE;
l_cust_trx_type_id ra_cust_trx_types_all.cust_trx_type_id%TYPE;
l_cust_account_id hz_cust_accounts.cust_account_id%TYPE;
l_code_combination_id gl_code_combinations_kfv.code_combination_id%TYPE;
BEGIN
DBMS_OUTPUT.put_line ('Start processing...');
l_user_name := 'Phani Adivi'; --- enter your name here
-- Get User ID
BEGIN
SELECT user_id
INTO g_user_id
FROM fnd_user
WHERE user_name = l_user_name;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving User ID and error is: ' || SQLERRM);
END;
--Get Responsibility ID
BEGIN
SELECT RESPONSIBILITY_ID
INTO l_resp_id
FROM fnd_responsibility
WHERE responsibility_key = 'RECEIVABLES_MANAGER'; --- enter the responsibility name that has access to create Invoices
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Responsibility ID and error is: '
|| SQLERRM);
END;
--Get Application ID
BEGIN
SELECT application_id
INTO l_appl_id
FROM fnd_application
WHERE application_short_name = 'AR';
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving application ID and error is: '
|| SQLERRM);
END;
-- Get Operating Unit ID
BEGIN
SELECT organization_id
INTO l_ou_id
FROM hr_operating_units
WHERE name = 'enter OU Name'; --- enter the OU name in which this invoice is being created in
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Operating Unit ID: ' || SQLERRM);
END;
--Get Batch Source ID
BEGIN
SELECT batch_source_id
INTO l_batch_source_id
FROM ra_batch_sources_all
WHERE name = 'Source Name'; -- enter the Source name
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error while deriving Batch Source ID: ' || SQLERRM);
END;
-- Get Customer Trx Type ID
BEGIN
SELECT cust_trx_type_id
INTO l_cust_trx_type_id
FROM ra_cust_trx_types_all
WHERE name = 'Debit Memo'
AND org_id = l_ou_id;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Customer Transaction Type and error is: '
|| SQLERRM);
END;
-- Get Customer Account ID
BEGIN
SELECT cust_account_id
INTO l_cust_account_id
FROM hz_cust_accounts s
WHERE account_name = 'Account Name'; -- enter the Account name of the Customer for which this invoice is being created for
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Customer Account ID and error is: '
|| SQLERRM);
END;
--Get Code Combination Id
BEGIN
SELECT code_combination_id
INTO l_code_combination_id
FROM gl_code_combinations_kfv
WHERE concatenated_segments = 'concatenated_string'; -- get the concatenated segment information - this will be shown on the distributions screen
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving the code combination id: ' || SQLERRM);
END;
mo_global.init ('AR');
mo_global.set_policy_context ('S', l_ou_id);
fnd_global.apps_initialize (user_id => g_user_id,
resp_id => l_resp_id,
resp_appl_id => l_appl_id);
-- Prepare Credit Memo;
l_batch_source_rec.batch_source_id := l_batch_source_id;
l_cm_customer_trx_id := ra_customer_trx_s.NEXTVAL;
l_index := l_index + 1;
--
l_trx_header_tbl (l_index).org_id := l_ou_id;
l_trx_header_tbl (l_index).trx_header_id := l_cm_customer_trx_id;
--l_trx_header_tbl (l_index).trx_number := 2120191; -- Enter the transaction number if the automatic numbering is not enabled
l_trx_header_tbl (l_index).trx_date := SYSDATE; --TO_DATE('30-NOV-2018', 'DD-MON-RRRR');
l_trx_header_tbl (l_index).gl_date := TO_DATE ('30-NOV-2018', 'DD-MON-RRRR');
l_trx_header_tbl (l_index).trx_currency := 'USD';
l_trx_header_tbl (l_index).cust_trx_type_id := l_cust_trx_type_id;
l_trx_header_tbl (l_index).bill_to_customer_id := l_cust_account_id;
l_trx_header_tbl (l_index).printing_option := 'NOT';
l_trx_header_tbl (l_index).reference_number := 21220191;
-- Prepare Credit Memo Lines
l_trx_line_id := ra_customer_trx_lines_s.NEXTVAL;
l_line_index := l_line_index + 1;
l_line_number := l_line_number + 1;
l_dist_index := l_dist_index + 1;
--
l_trx_lines_tbl (l_line_index).trx_header_id := l_cm_customer_trx_id;
l_trx_lines_tbl (l_line_index).trx_line_id := l_trx_line_id;
l_trx_lines_tbl (l_line_index).line_number := l_line_number;
l_trx_lines_tbl (l_line_index).quantity_invoiced := 1;
l_trx_lines_tbl (l_line_index).unit_selling_price := 12;
l_trx_lines_tbl (l_line_index).line_type := 'LINE';
l_trx_lines_tbl (l_line_index).taxable_flag := 'N';
--
l_trx_dist_tbl (l_dist_index).trx_dist_id := RA_CUST_TRX_LINE_GL_DIST_S.NEXTVAL;
l_trx_dist_tbl (l_dist_index).trx_line_id := l_trx_line_id;
l_trx_dist_tbl (l_dist_index).ACCOUNT_CLASS := 'REV';
l_trx_dist_tbl (l_dist_index).percent := 100;
l_trx_dist_tbl (l_dist_index).code_combination_id := l_code_combination_id;
l_return_status := NULL;
--Standard API call
ar_invoice_api_pub.create_invoice (
p_api_version => 1.0,
p_commit => fnd_api.g_false,
p_batch_source_rec => l_batch_source_rec,
p_trx_header_tbl => l_trx_header_tbl,
p_trx_lines_tbl => l_trx_lines_tbl,
p_trx_dist_tbl => l_trx_dist_tbl,
p_trx_salescredits_tbl => l_trx_salescredits_tbl,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data);
DBMS_OUTPUT.put_line ('l_return_status is: ' || l_return_status);
FOR cr_rec
IN (SELECT trx_header_id,
trx_line_id,
error_message,
invalid_value
FROM ar_trx_errors_gt)
LOOP
l_msg_data := NULL;
l_msg_data :=
'API Create CM/DM:'
|| cr_rec.trx_header_id
|| '-'
|| cr_rec.trx_line_id
|| '-'
|| cr_rec.error_message;
DBMS_OUTPUT.put_line ('Message is: ' || l_msg_data);
END LOOP;
--
COMMIT;
END;
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Script to Create a Credit Memo (AR)
The following script can be used to create a Basic Credit memo. The API that is used to create an AR Invoice is – “ar_invoice_api_pub.create_invoice“. The Cust_trx_type_id decides whether the invoice getting created is a Standard Invoice or a Credit Memo or a Debit memo. Based on this value, the API also checks the sign of the amount on the Line level that is being passed.
--Script to create Credit memo.
DECLARE
l_index NUMBER := 0;
l_line_index NUMBER := 0;
l_dist_index NUMBER := 0;
l_cm_customer_trx_id NUMBER := 0;
--
l_batch_source_rec ar_invoice_api_pub.batch_source_rec_type;
l_trx_header_tbl ar_invoice_api_pub.trx_header_tbl_type;
l_trx_lines_tbl ar_invoice_api_pub.trx_line_tbl_type;
l_trx_line_id NUMBER;
l_return_status VARCHAR2 (1);
l_trx_dist_tbl ar_invoice_api_pub.trx_dist_tbl_type;
l_trx_salescredits_tbl ar_invoice_api_pub.trx_salescredits_tbl_type;
l_msg_data VARCHAR2 (2000);
l_resp_id NUMBER;
l_appl_id NUMBER;
l_user_name VARCHAR2 (200);
g_user_id fnd_user.user_id%TYPE;
l_line_number NUMBER := 0;
l_msg_count NUMBER;
l_ou_id hr_operating_units.organization_id%TYPE;
l_batch_source_id ra_batch_sources_all.batch_source_id%TYPE;
l_cust_trx_type_id ra_cust_trx_types_all.cust_trx_type_id%TYPE;
l_cust_account_id hz_cust_accounts.cust_account_id%TYPE;
l_code_combination_id gl_code_combinations_kfv.code_combination_id%TYPE;
BEGIN
DBMS_OUTPUT.put_line ('Start processing...');
l_user_name := 'Phani Adivi'; --- enter your name here
-- Get User ID
BEGIN
SELECT user_id
INTO g_user_id
FROM fnd_user
WHERE user_name = l_user_name;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving User ID and error is: ' || SQLERRM);
END;
--Get Responsibility ID
BEGIN
SELECT RESPONSIBILITY_ID
INTO l_resp_id
FROM fnd_responsibility
WHERE responsibility_key = 'RECEIVABLES_MANAGER'; --- enter the responsibility name that has access to create Invoices
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Responsibility ID and error is: '
|| SQLERRM);
END;
--Get Application ID
BEGIN
SELECT application_id
INTO l_appl_id
FROM fnd_application
WHERE application_short_name = 'AR';
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving application ID and error is: '
|| SQLERRM);
END;
-- Get Operating Unit ID
BEGIN
SELECT organization_id
INTO l_ou_id
FROM hr_operating_units
WHERE name = 'enter OU Name'; --- enter the OU name in which this invoice is being created in
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Operating Unit ID: ' || SQLERRM);
END;
--Get Batch Source ID
BEGIN
SELECT batch_source_id
INTO l_batch_source_id
FROM ra_batch_sources_all
WHERE name = 'Source Name'; -- enter the Source name
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error while deriving Batch Source ID: ' || SQLERRM);
END;
-- Get Customer Trx Type ID
BEGIN
SELECT cust_trx_type_id
INTO l_cust_trx_type_id
FROM ra_cust_trx_types_all
WHERE name = 'Credit Memo'
AND org_id = l_ou_id;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Customer Transaction Type and error is: '
|| SQLERRM);
END;
-- Get Customer Account ID
BEGIN
SELECT cust_account_id
INTO l_cust_account_id
FROM hz_cust_accounts s
WHERE account_name = 'Account Name'; -- enter the Account name of the Customer for which this invoice is being created for
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving Customer Account ID and error is: '
|| SQLERRM);
END;
--Get Code Combination Id
BEGIN
SELECT code_combination_id
INTO l_code_combination_id
FROM gl_code_combinations_kfv
WHERE concatenated_segments = 'concatenated_string'; -- get the concatenated segment information - this will be shown on the distributions screen
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (
'Error during deriving the code combination id: ' || SQLERRM);
END;
mo_global.init ('AR');
mo_global.set_policy_context ('S', l_ou_id);
fnd_global.apps_initialize (user_id => g_user_id,
resp_id => l_resp_id,
resp_appl_id => l_appl_id);
-- Prepare Credit Memo;
l_batch_source_rec.batch_source_id := l_batch_source_id;
l_cm_customer_trx_id := ra_customer_trx_s.NEXTVAL;
l_index := l_index + 1;
--
l_trx_header_tbl (l_index).org_id := l_ou_id;
l_trx_header_tbl (l_index).trx_header_id := l_cm_customer_trx_id;
--l_trx_header_tbl (l_index).trx_number := 2120191; -- Enter the transaction number if the automatic numbering is not enabled
l_trx_header_tbl (l_index).trx_date := SYSDATE; --TO_DATE('30-NOV-2018', 'DD-MON-RRRR');
l_trx_header_tbl (l_index).gl_date := TO_DATE ('30-NOV-2018', 'DD-MON-RRRR');
l_trx_header_tbl (l_index).trx_currency := 'USD';
l_trx_header_tbl (l_index).cust_trx_type_id := l_cust_trx_type_id;
l_trx_header_tbl (l_index).bill_to_customer_id := l_cust_account_id;
l_trx_header_tbl (l_index).printing_option := 'NOT';
l_trx_header_tbl (l_index).reference_number := 21220191;
-- Prepare Credit Memo Lines
l_trx_line_id := ra_customer_trx_lines_s.NEXTVAL;
l_line_index := l_line_index + 1;
l_line_number := l_line_number + 1;
l_dist_index := l_dist_index + 1;
--
l_trx_lines_tbl (l_line_index).trx_header_id := l_cm_customer_trx_id;
l_trx_lines_tbl (l_line_index).trx_line_id := l_trx_line_id;
l_trx_lines_tbl (l_line_index).line_number := l_line_number;
l_trx_lines_tbl (l_line_index).quantity_invoiced := 1;
l_trx_lines_tbl (l_line_index).unit_selling_price := -12;
l_trx_lines_tbl (l_line_index).line_type := 'LINE';
l_trx_lines_tbl (l_line_index).taxable_flag := 'N';
--
l_trx_dist_tbl (l_dist_index).trx_dist_id := RA_CUST_TRX_LINE_GL_DIST_S.NEXTVAL;
l_trx_dist_tbl (l_dist_index).trx_line_id := l_trx_line_id;
l_trx_dist_tbl (l_dist_index).ACCOUNT_CLASS := 'REV';
l_trx_dist_tbl (l_dist_index).percent := 100;
l_trx_dist_tbl (l_dist_index).code_combination_id := l_code_combination_id;
l_return_status := NULL;
--Standard API call
ar_invoice_api_pub.create_invoice (
p_api_version => 1.0,
p_commit => fnd_api.g_false,
p_batch_source_rec => l_batch_source_rec,
p_trx_header_tbl => l_trx_header_tbl,
p_trx_lines_tbl => l_trx_lines_tbl,
p_trx_dist_tbl => l_trx_dist_tbl,
p_trx_salescredits_tbl => l_trx_salescredits_tbl,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data);
DBMS_OUTPUT.put_line ('l_return_status is: ' || l_return_status);
FOR cr_rec
IN (SELECT trx_header_id,
trx_line_id,
error_message,
invalid_value
FROM ar_trx_errors_gt)
LOOP
l_msg_data := NULL;
l_msg_data :=
'API Create CM/DM:'
|| cr_rec.trx_header_id
|| '-'
|| cr_rec.trx_line_id
|| '-'
|| cr_rec.error_message;
DBMS_OUTPUT.put_line ('Message is: ' || l_msg_data);
END LOOP;
--
COMMIT;
END;
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Query to derive the 4 C’s
The following query can be used to derive the details of the 4 C’s – that is: that have been setup for a particular Ledger.
- Chart of Accounts
- Currency
- Calendar
- Accounting Convention
SELECT gll.name "Legal Entity Name",
gll.short_name "Short Code",
gll.ledger_category_code "Primary/Secondary Ledger",
gll.chart_of_accounts_id,
-- 4 C's details below
fifs.id_flex_structure_name "Chart of Accounts Name",
gll.period_set_name "Calendar",
gll.currency_code "Currency",
gll.sla_accounting_method_code "Subledger Accounting"
FROM gl_ledgers gll, fnd_id_flex_structures_tl fifs
WHERE gll.chart_of_accounts_id = fifs.id_flex_num
AND fifs.id_flex_code = 'GL#'
AND fifs.language = 'US'
AND gll.name = p_legal_entity_name; -- Enter Legal Entity name here
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Oracle Payables Query
Query to identify the various components that a Payables Invoice goes through a P2P process. Below query provides the details like Invoice, Supplier, Supplier Sites, Payment Method codes, terms, Distribution details, Payment schedules, Check details, Internal Bank Payment and Internal Bank details.
SELECT aia.invoice_num "Invoice Number",
aps.vendor_name "Vendor Name" -- get vendor name from ap_suppliers table
,
assa.vendor_site_code "Vendor Site Code",
aia.invoice_id "Invoice ID",
aia.invoice_currency_code "Currency Code",
aia.invoice_amount "Invoice Amount",
aia.amount_paid "Amount Paid",
aia.invoice_type_lookup_code "Invoice Type", -- values are derived from ap_lookup_codes and lookup_type = 'INVOICE TYPE'.
--STANDARD, CREDIT, DEBIT, EXPENSE REPORT, PREPAYMENT, MIXED, RETAINAGE RELEASE are other Invoice Types
aia.description,
aia.payment_method_lookup_code, -- values are derived from ap_lookup_codes table and lookup_type = 'PAYMENT METHOD'
-- Check, Clearing, Electronic, Wire
aia.terms_id "Terms ID", -- get terms name from ap_terms table
aia.pay_group_lookup_code, -- values are derived from the fnd_lookup_values_vl and lookup_type = 'PAY GROUP'
aia.org_id "Operating Unit ID", -- values are derived from hr_operating_units table - organization_id column
aia.gl_date "GL Date",
aia.wfapproval_status,
ail.line_number "Line Number",
ail.line_type_lookup_code "Line Type", -- values are derived from ap_lookup_codes and lookup_type = 'INVOICE LINE TYPE'
-- Item, Freigh, Miscellaneous, Tax
ail.amount "Line Amount",
aid.dist_code_combination_id "Distribution Code Comb ID", -- segment information can be derived from gl_code_combinations_kfv
aid.accounting_event_id "Invoice Accounting Event ID", -- will be used to link to SLA tables
apsa.amount_remaining "Remaining Invoice Amount",
apsa.due_date "Due Date",
aipa.accounting_event_id "Payment Accounting Event ID",
aca.amount "Check Amount",
aca.check_number "Check Number",
aca.checkrun_name "Payment Process Request",
idpa.document_amount "Payment Amount",
idpa.pay_proc_trxn_type_code "Payment Processing Document",
idpa.calling_app_doc_ref_number "Invoice Number",
ipa.paper_document_number "Payment Number",
ipa.payee_name "Paid to Name",
ipa.payee_address1 "Paid to Address",
ipa.payee_city "Paid to City",
ipa.payee_postal_code "Payee Postal Code",
ipa.payee_state "Payee State",
ipa.payee_country "Payee Country",
ipa.payment_profile_acct_name "Payment Process Profile",
ipa.int_bank_name "Payee Bank Name",
ipa.int_bank_number "Payee Bank Number",
ipa.int_bank_account_name "Payee Bank Account Name",
ipa.int_bank_account_number "Payee Bank Account Number"
FROM ap_invoices_all aia,
ap_invoice_lines_all ail,
ap_invoice_distributions_all aid,
ap_suppliers aps,
ap_supplier_sites_all assa,
ap_payment_schedules_all apsa,
ap_invoice_payments_all aipa,
ap_checks_all aca,
iby_docs_payable_all idpa,
iby_payments_all ipa
WHERE 1 = 1
AND aia.invoice_id = ail.invoice_id
AND aia.invoice_id = aid.invoice_id
AND aia.vendor_id = aps.vendor_id
AND aps.vendor_id = assa.vendor_id
AND aia.invoice_id = apsa.invoice_id
AND aia.invoice_id = aipa.invoice_id
AND aipa.check_id = aca.check_id
AND aia.invoice_id = idpa.calling_app_doc_unique_ref2
AND idpa.calling_app_id = 200
AND aps.party_id = idpa.payee_party_id
AND ipa.payment_id = idpa.payment_id
AND aps.segment1 = ipa.payee_supplier_number
-- and assa.vendor_site_id = ipa.supplier_site_id
AND assa.org_id = aia.org_id
AND aca.vendor_site_id = assa.vendor_site_id
AND invoice_num = p_invoice_num; -- Enter Invoice number here.
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Banks in Oracle R12
Understanding Banks in Oracle R12
Bank Details such as Bank Account Name, Bank Account Number etc. are stored in multiple tables in Oracle Apps R12 environment. It may be confusing to see that sometimes the same information such as bank account name is stored in different tables. Here, we shall learn the differences between those tables and their uses.
There are two types of Banks and related bank accounts in R12.
- Internal
- External
The basic difference between an Internal bank/bank account and an External bank/bank account is that an internal bank account is an account that is created from the Cash Management module and the External Bank/bank accounts are the ones that are created from the sub-ledger modules such as the Payables or Receivables. Bank Accounts related to Suppliers or Customers are the externals bank accounts.
The Internal bank accounts and its details are stored in the CE tables like “CE_BANK_ACCOUNTS” and the external bank accounts and its details are stored in IBY tables like “IBY_EXT_BANK_ACCOUNTS”.
Internal banks and Bank Accounts – Technical details:
Steps to create a Bank, Bank Branch and a Bank Account
Navigate to Cash Management Super User -> Setup -> Banks -> Banks. Click Create Button to create a new bank.
Create Bank:
Create Bank Address: In the Step 2 – Click on Create button to create Bank Address and click Apply.
Create Contact: On step 3 – click on Create button to create a contact for the bank.
That’s it – A new Bank with the name Test Bank 4 is created.
Creating a Bank Branch
Navigate to Cash Management Super User -> Setup -> Banks -> Banks – Click on Bank Branches and click Create Button.
First the following oracle page asks to enter the bank name for which the branch is being created for. And Click continue. We get two options here – either to “Create a new Branch” or to “Select an Existing party”. Let’s create a new branch.
Create Branch Address
Create a Contact for the Bank Branch
A bank branch is also created.
Now that a Bank, its Bank Branch, Branch Address and a Contact point is created, lets create a Bank Account and Assign it to the Bank that was created earlier.
Go to the navigation – Cash Management Super User -> Setup -> Banks -> Bank Accounts -> Click Create. The following oracle page asks for the Country, Bank name and Branch name for which the account is being created for. Select the Bank and Branch Name that we created before.
Identify the Bank Account Owner – the corresponding Legal Entity identifier and the Uses of the Bank Account. For which the Bank account will be used for:
Create Bank Account information like Bank Account Name, Account Number and Currency code.
Create the Bank Account Controls that has General control information like Cash Account, Bank Charges, Realized gain, Foreign Exchange charges, Cash Clearing account, Bank Errors, Realized Loss account etc. Click Save and Next and Click Finish.
Add Organization Access – in order to Assign a bank account to an operating unit.
Technical information about Banks and Bank Branches for CE (Cash Management)
SELECT *
FROM CEFV_BANK_BRANCHES
WHERE bank_name = 'Test Bank 4';
SELECT *
FROM ce_bank_accounts
WHERE bank_account_name = 'Test Bank Account 4';
SELECT org_id "Operating Unit ID",
ap_use_enable_flag "Bank Acc used for Payables",
ar_use_enable_flag "Bank Acc used for Receivables",
xtr_use_enable_flag "Bank Acc used for Treasury",
PAY_USE_ENABLE_FLAG "Bank Acc used for Payroll",
bank_account_id,
bank_acct_use_id,
c.*
FROM ce_bank_acct_uses_all c
WHERE bank_account_id = (SELECT bank_account_id
FROM ce_bank_accounts
WHERE bank_account_name = 'Test Bank Account 4');
SELECT hou.name "Operating Unit Name",
xep.name "Legal Entity Name",
cebb.bank_name,
cebb.bank_number,
cebb.bank_branch_name,
cebb.bank_branch_number,
cebb.bank_branch_type, -- Branch type indicates which list the bank routing number is on. Valid types are ABA, CHIPS, SWIFT, OTHER.
cebb.address_line1, -- Branch details - Branch Address details below
cebb.address_line2,
cebb.address_line3,
cebb.address_line4,
cebb.city, -- Branch City
cebb.state, -- Branch State
cebb.zip_code,
cebb.country,
--ceba.bank_account_number,
ceba.asset_code_combination_id,
glcc.concatenated_segments,
cebau.ap_use_enable_flag "Bank Acc used for Payables",
cebau.ar_use_enable_flag "Bank Acc used for Receivables",
cebau.xtr_use_enable_flag "Bank Acc used for Treasury",
cebau.PAY_USE_ENABLE_FLAG "Bank Acc used for Payroll"
FROM cefv_bank_branches cebb,
ce_bank_accounts ceba,
ce_bank_acct_uses_all cebau,
gl_code_combinations_kfv glcc,
hr_operating_units hou,
xle_entity_profiles xep
WHERE 1 = 1
AND cebb.bank_branch_id = ceba.bank_branch_id
AND ceba.asset_code_combination_id = glcc.code_combination_id
AND ceba.bank_account_id = cebau.bank_account_id
AND cebau.org_id = hou.organization_id
AND ceba.account_owner_org_id = xep.legal_entity_id
AND bank_name = 'Test Bank 4';
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Procure to Pay (P2P)
In this article, we shall try to understand the end to end process involved in the P2P process from a functional as well a technical point of view. We shall look at the navigation required during each step and the tables that get affected during that process.
High level Scenario: Consider a car company that buys tires from a third party supplier. And when the Supplier sends in those tires, the company fixes the tires to the cars in their assembly lines and continue their manufacturing process of building the cars. In this scenario, let us suppose the number of tires that this car company has, has fallen below a count of 100. That’s when the company’s procurement team requests the third party seller to replenish the tires inventory by sending out a new batch of tires.
In the above mentioned scenario, from an ERP perspective, the tires count is maintained in Inventory module. Suppliers are maintained in the Accounts Payables (AP) module. Procurement for new tires is made and requested from the Procurement module. And when the Invoice is paid – the Payment accounting is created as journals and printed as reports in the General Ledger module.
Thus, a P2P process flows through the following steps:
- Create / Raise requirement for the item.
- Create Requisition
- Request for Quotation
- Create Quotation
- Quotation Analysis
- Create Purchase Order
- Create Invoice
- Create Accounting (for Invoice)
- Interface to GL
- Journal Import and Create Journals
- Post the Journals
- Create Payment
- Create Accounting (for Payment)
- Interface to GL
- Journal Import and Create Journals
- Post the Journals
Step 1: Requesting for Item
Create an item – VI50000.
In the above image, we can see that for this item – in the General Planning tab –
- Inventory Planning Method is defined as Min-Max.
- Min-Max Quantity section the Minimum quantity is 100 and Maximum quantity is 1000.
- Make or Buy is – Buy
- And the Source Type is – Supplier.
That means, whenever the on-hand quantity of that item falls below a minimum of 100, then the Min-Max Planning report automatically replenishes the quantity of the item upto 1000. The tables affected during this step are:
Query to item details from the Item Master table:
SELECT *
FROM mtl_system_items_b
WHERE segment1 = 'VI50000';
Query to find out the onhand quantity.
SELECT *
FROM mtl_onhand_quantities_detail
WHERE inventory_item_id IN (SELECT inventory_item_id
FROM mtl_system_items_b
WHERE segment1 = 'VI50000');
SELECT *
FROM mtl_onhand_quantities
WHERE inventory_item_id IN (SELECT inventory_item_id
FROM mtl_system_items_b
WHERE segment1 = 'VI50000');
Step 2: Now, run the Min-Max Planning Report.
Inventory Super User -> Planning -> Min-Max Planning Report
Step 3: Upon Running this report – the process of creating a requisition starts. Once this Min-Max Planning report is completed, a record is inserted into the Po Requisitions Interface table. A record is inserted into the PO_REQUISITIONS_INTERFACE_ALL table.
--The record in this table can be identified using the item_id of the item that we are procuring.
SELECT *
FROM PO_REQUISITIONS_INTERFACE_ALL
WHERE ITEM_ID IN (SELECT inventory_item_id
FROM mtl_system_items_b
WHERE segment1 = 'VI50000');
The PO_REQUISITIONS_INTERFACE_ALL table contains requisition information from other applications. Each row includes all the information necessary to create approved or unapproved requisitions in Oracle Purchasing. The Oracle Purchasing Requisition Import feature uses this information to create new requisition headers, lines and distributions.
Step 4 – Create Requisition: Run the “REQUISITION IMPORT” concurrent program to import the requisition from the interface table to the base tables, thereby creating the Requisition in Oracle.
The Requisition Import Concurrent Program validates the data in the PO_REQUISITIONS_INTERFACE_ALL table and derives additional information as required. Upon completion, data is loaded into the PO Requisition Base Tables. The base tables are:
- PO_REQUISITION_HEADERS_ALL
- PO_REQUISITION_LINES_ALL
- PO_REQ_DISTRIBUTIONS_ALL
In order to identify the record in these base table – get the inventory_item_id of the above item
SELECT requisition_header_id
FROM PO_REQUISITION_LINES_ALL
WHERE item_id IN (SELECT inventory_item_id
FROM mtl_system_items_b
WHERE segment1 = 'VI50000')
and org_id = p_org_id; -- get the requisition_header_id and requisition_line_id
SELECT segment1 "REQUISITION NUMBER"
FROM PO_REQUISITION_HEADERS_ALL
WHERE requisition_header_id = p_req_header_id
AND org_id = p_org_id; -- use the requisition_header_id here
SELECT code_combination_id
FROM PO_REQ_DISTRIBUTIONS_ALL
WHERE REQUISITION_LINE_ID = p_req_line_id; -- use the requisition_line_id here
PO_REQ_DISTRIBUTIONS_ALL table contains the information about the accounting distributions associated with each requisition line. Each
requisition line must have at least one accounting distribution.
From the above query – get the code_combination_id value – that can used to get the accounting string.
SELECT *
FROM GL_CODE_COMBINATIONS_KFV
WHERE code_combination_id = p_code_combination_id -- get the accounting string.
SELECT *
FROM GL_CODE_COMBINATIONS
WHERE code_combination_id = p_code_combination_id
Approved Requisitions can be accessed from – PO Super User -> Requisitions -> Requisition Summary.
If there are any errors then, then error records are written into PO_INTERFACE_ERRORS table.
The join is – PO_REQUISITIONS_INTERFACE_ALL.transaction_id = PO_INTERFACE_ERRORS.interface_transaction_id
STEP5 – REQUEST FOR QUOTATION – RFQ
Once the Requisition is created, now we have to Create RFQ – that is Request for Quotation – asking the Suppliers to provide their Quotation. Once we receive their quotations, we can decide which quote from the Suppliers is best for our requirement.
Navigation – Purchasing Super User -> RFQ’s and Quotations -> RFQ’s
Create an RFQ by selecting the following fields:
- Type – Standard RFQ (the other two types are Bid RFQ, Catalog RFQ).
- Status – Active
- Close date – provide a date until when this RFQ is valid
- Item – Item name
- Target Price – provide a target price
- Currency – Provide the currency details.
- Terms – Payment Terms, Freight Terms, FOB.
- Price Break – In the Price Break – you can provide the quantity and a discount.
And click on Save. Tables that get affected when Request for Quotation is created are:
SELECT *
FROM po_headers_all
WHERE segment1 = '1011'
AND org_id = p_org_id
AND type_lookup_code = 'RFQ';
SELECT *
FROM PO_LINES_ALL
WHERE po_header_id = p_header_id; -- use po_header_id from above
Click on Suppliers tab on the RFQ window to assign the RFQ to that particular Supplier. Here you can see that this RFQ has been assigned to a couple of Suppliers.
This information is stored in PO_RFQ_VENDORS table. This table stores the information about the set of suppliers assigned to an RFQ. Each row in this table identifies the Supplier who received this RFQ. In the above example, we would get 2 records.
SELECT *
FROM po_rfq_vendors
WHERE po_header_id = p_header_id; - get the po_header_id from above query
Once the RFQ is completed – run the PRINTED RFQ Report concurrent program that will send the RFQ details to the supplier via email / fax or other methods that have been entered. Once the below program completes, the status on the RFQ changes from ACTIVE to PRINTED.
Step 6 – Quotations
Now that an RFQ is created and sent out to Suppliers, the Suppliers send us their respective Quotes back. We select the required quote and create it in Oracle for record purpose. A Quote can be created from the RFQ screen itself. Open the RFQ -> Tools – Copy Document. Give the following values:
- Action – Entire RFQ
- Type – Standard Quotation
- Supplier – Select one of the two suppliers that we entered above.
- Site – Auto populates.
Once OK is pressed, a note appears that “A new Quotation has been copied from this RFQ. The Quotation document number is – ..
As can be seen above – a Quotation is created for the corresponding RFQ. And the tables affected are:
SELECT *
FROM PO_HEADERS_ALL
WHERE segment1 = '1013' --- quotation number
AND org_id = p_org_id
AND type_lookup_code = 'QUOTATION'
SELECT *
FROM PO_LINES_ALL
WHERE po_header_id = p_header_id; -- po_header_id from above
SELECT *
FROM PO_LINE_LOCATIONS_ALL
WHERE po_header_id = p_header_id
AND po_line_id = p_line_id
AND org_id = p_org_id;
Click on Approve Button.
Step 7 – Quote Analysis
In this step – the Quote that was approved earlier is Analyzed and is approved. Navigation: Purchasing Super User -> RFQ’s and Quotations -> Quote Analysis -> Enter the RFQ Number. Click on Approve Entire Quotation
Step 8 – Create Purchase Order (PO)
Now that the Quote analysis is completed – we are ready to create a Purchase Order. Navigation – Purchasing Super User -> Purchase Orders -> Purchase Orders.
Enter the Supplier Name, Supplier Site, Bill-To, Ship-To, enter the Item information. As soon as we enter the quantity, the price changes to the discounted price on the quotation.
Click on Terms – and we have information about Payment Terms (30 Net or Immediate), Freight (Due), Carrier, FOB, Supplier Note, Receiver Note etc.
Click on Shipments – and we get information about the Ship-To organization Name, UOM, Quantity, Promised Date, Need By Date, Charge Account and Amount.
Click on Shipments – and More – we get information on how the Match Approval Level is defined. Whether it is a 2-way or 3-way or 4-way match approval. And Invoice Match Option – Receipt / PO.
Once the PO Is approved, we can check the PO details from the backend. The tables that get affected are:
SELECT *
FROM PO_HEADERS_ALL
WHERE segment1 = '10428'
AND org_id = p_org_id; -- get po_header_id
SELECT *
FROM PO_LINES_ALL
WHERE po_header_id = p_header_id; -- get po_line_id
SELECT *
FROM PO_LINE_LOCATIONS_ALL
WHERE po_header_id = p_header_id
AND po_line_id = p_line_id
AND org_id = p_org_id; -- get line_location_id
SELECT *
FROM PO_DISTRIBUTIONS_ALL
WHERE po_header_id = p_header_id
AND po_line_id = p_line_id
AND line_location_id = p_line_location_id
AND org_id = p_org_id;
Step 9 – Receiving
Once the PO Is created, the Supplier sends the items to the Ship-To organization specified. And once we get the goods, we receive them in Oracle too. Navigation – Purchasing Super User -> Receiving -> Receipts. Enter the PO Number and click Find to get the receipt details.
Once it is saved, we receive it in EBS. The tables that get affected are:
SELECT *
FROM RCV_SHIPMENT_HEADERS
WHERE receipt_num = '1031'
AND ship_to_org_id = p_ship_to_org_id;
SELECT *
FROM RCV_SHIPMENT_LINES
WHERE shipment_header_id = p_shipment_header_id;
SELECT *
FROM RCV_TRANSACTIONS
WHERE shipment_header_id = p_shipment_header_id;
Step 10 – Create Invoice (Payables Invoice)
Once we received the items, we create a Payables Invoice in order to send it to the Supplier so they can pay out that amount. The Invoice is created for the amount for which the PO was created for. In the PO Number field, enter the PO number that was created earlier. And Distribution Information can be seen by clicking All Distributions.
Click on Actions to Validate the Invoice.
After clicking validation – the status on the Invoice changes to “Validated”
Tables Affected after creating the invoice are:
SELECT *
FROM AP_INVOICES_ALL
WHERE invoice_num = 'Inv_V1';
SELECT *
FROM ap_invoice_lines_all
WHERE invoice_id = p_invoice_id;
SELECT *
FROM ap_invoice_distributions_all
WHERE invoice_id = p_invoice_id;
Step 11 – Create Accounting
After the invoice is validate – Click Actions and Click Create Accounting.
When the Create Accounting program is run, it processes the eligible accounting events to create the subledger journal entries. This program:
- Validates and creates the journal entries.
- Transfers the journal entries in the current batch run to General Ledger and starts the GL posting process.
- Generates the Subledger Accounting Program Report, which has the results of the Create Accounting program.
Before running the Create Accounting program, the Accounting_event_id column in the AP_INVOICE_DISTRIBUTIONS_ALL is NULL. After running the program, the field is populated with the value that can be used in the Subledger Accounting (SLA) tables. The tables affected after running the Create Accounting are as below.
SELECT accounting_event_id
FROM AP_INVOICE_DISTRIBUTIONS_ALL
WHERE invoice_id = p_invoice_id; -- get the accounting_event_id
SELECT *
FROM XLA_AE_HEADERS
WHERE event_id = p_accounting_event_id; -- get the ae_header_id
SELECT *
FROM XLA_AE_LINES
WHERE ae_header_id = p_xla_ae_header_id;
Step 12 – Journal Import
The Journal Import program transfers the data from the GL_INTERFACE table to the GL Base tables. The corresponding JE_Batch_id, JE_Header_ID, JE_LINE_NUM fields are populated. These can be used to check the data in the GL Base tables. The tables getting affected in GL are as below:
-- Get the je_batch_id, je_header_id and je_line_num values from the GL_Interface table.
SELECT *
FROM GL_JE_BATCHES
WHERE je_batch_id = p_je_batch_id;
SELECT *
FROM GL_JE_HEADERS
WHERE je_header_id = p_je_header_id;
SELECT *
FROM GL_JE_LINES
WHERE je_header_id = p_je_header_id
AND je_line_num = p_je_line_num;
Step 13 – Create Payment
Now that the Invoice was sent out to the Supplier and the Supplier pays the Invoice in full, then we record that payment in the EBS. The Navigation to the payment screen is AP Super User -> Payments -> Entry -> Payments. The other way is to go from the AP Invoice Screen. Go to the Invoice – Click Actions and Click – Pay in Full. The Payment screen opens up.
And once all the required fields are populated – click on Save. The following tables are populated with the payment data.
SELECT *
FROM AP_INVOICE_PAYMENTS_ALL
WHERE invoice_id IN (SELECT invoice_id
FROM AP_INVOICES_ALL
WHERE invoice_num = 'Inv_V1');
The AP_Invoice_Payment_Schedules_all table holds data about any pending amount on the invoice. It contains information about scheduled payments for an invoice. The AMOUNT_REMAINING columns holds the data for any amount that is pending on the invoice. The PAYMENT_STATUS_FLAG may be ‘Y’ for fully paid payment schedules, ‘N’ for unpaid scheduled payments, or ‘P’ for partially paid scheduled payments.
SELECT *
FROM ap_payment_schedules_all
WHERE invoice_id IN (SELECT invoice_id
FROM AP_INVOICES_ALL
WHERE invoice_num = 'Inv_V1'); -- get Check_id value
The AP_CHECKS_ALL table stores the information about any payments made to the Supplier or any refund provided to the Supplier. There exists a record for each activity in this table. This table stores the supplier name and bank account name for auditing purposes, in case either one is changed after you create the payment. This table also stores Bank_Account_name, check_date, Check Number, Currency Code, Address Information etc..
SELECT *
FROM ap_checks_all
WHERE check_id = (SELECT check_id
FROM ap_payment_schedules_all
WHERE invoice_id = (SELECT invoice_id
FROM AP_INVOICES_ALL
WHERE invoice_num = 'Inv_V1'));
Step 14 – Create Accounting (for Payment)
Now that the Payment has been recorded in EBS (AP module), the information has to pass through the Subledger Accounting (SLA) and then to GL. In order for this to happen, on the Payments screen – click Action – and Click – Create Accounting.
Once this activity is completed, the Create Accounting Seeded concurrent program starts and initiates the transfer of data from AP to GL via GL interface. The following tables get affected during this process.
--Get the Accounting_event_id value from the Payments table above.
SELECT accounting_event_id
FROM AP_INVOICE_PAYMENTS_ALL
WHERE invoice_id IN (SELECT invoice_id
FROM AP_INVOICES_ALL
WHERE invoice_num = 'Inv_V1');
SELECT *
FROM XLA_EVENTS
WHERE event_id = p_accounting_event_id;
SELECT *
FROM XLA_AE_HEADERS
WHERE event_id = p_accounting_event_id;
SELECT *
FROM XLA_AE_LINES
WHERE ae_header_id = p_xla_ae_header_id;
And once the Journal Import completes the journals can be seen from the GL base tables namely GL_JE_BATCHES,
GL_JE_HEADERS , GL_JE_LINES and upon posting the Journals – the GL data can be seen in the GL_Balances table.
That pretty much sums up the Procure to Pay Cycle in Oracle Apps.
Happy coding.
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Process Flow – P2P
Oracle ERP has two important process flows that define day to day activities across multiple modules.
- Procure to Pay (P2P)
- Order to Cash (OTC)
Procure to Pay Process commonly known as P2P is the process of procuring items based on necessity, paying for the goods or services procured and accounting the monetary transactions that take place during the above mentioned process. More about P2P Process can be found here.
Order to Cash Process commonly known as OTC is the process of selling the goods or services, shipping the aforementioned goods and accounting of the monetary transactions that take place during the above mentioned process. More about OTC process can be found here.
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Script to Reverse an AR Receipt
The following script can be used to reverse an AR Receipt.
DECLARE v_return_status VARCHAR2 (1); p_count NUMBER; v_msg_count NUMBER; v_msg_data VARCHAR2 (2000); v_cash_receipt_id NUMBER DEFAULT 12345678; -- cash receipt id from ar_Cash_Receipts_all table v_gl_date DATE DEFAULT SYSDATE; v_reversal_date DATE DEFAULT SYSDATE; v_context VARCHAR2 (2); g_user_id fnd_user.user_id%TYPE; l_resp_id NUMBER; l_resp_name CONSTANT VARCHAR2 (100) DEFAULT 'AR SUPERUSER'; l_appl_name CONSTANT VARCHAR2 (100) DEFAULT 'Receivables'; l_appl_id NUMBER; x_return_message VARCHAR2 (4000); x_return_status VARCHAR2 (2000); l_ou_name hr_operating_units.name%TYPE DEFAULT 'USXXOUXX'; -- OU NAME l_organization_id hr_operating_units.organization_id%TYPE; g_user_name VARCHAR2 (200); BEGIN g_user_name := 'XX1234'; -- USER NAME FOR WHO COLUMNS BEGIN SELECT user_id INTO g_user_id FROM fnd_user WHERE user_name = g_user_name; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ( 'Error during deriving user_id: ' || SQLERRM); END; l_resp_id := xx_fnd_responsibility_pkg.get_responsibility_id ( p_resp_name => l_resp_name); IF l_resp_id IS NULL THEN x_return_status := 'E'; x_return_message := 'Responsibility id not found for responsibility ' || l_resp_name; ELSE l_appl_id := xx_fnd_application_pkg.get_application_id ( p_appl_name => l_appl_name); IF l_appl_id IS NULL THEN x_return_status := 'E'; x_return_message := 'Application id not found for application name ' || l_appl_name; DBMS_OUTPUT.put_line (x_return_message); END IF; END IF; BEGIN SELECT organization_id INTO l_organization_id FROM hr_operating_units WHERE name = l_ou_name; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ( 'Error during deriving Organization_id: ' || SQLERRM); END; mo_global.init ('AR'); fnd_global.apps_initialize (user_id => g_user_id, resp_id => l_resp_id, resp_appl_id => l_appl_id); DBMS_OUTPUT.PUT_LINE ('Invoking Receipt reversal api'); ar_receipt_api_pub.REVERSE ( p_api_version => 1.0, p_init_msg_list => FND_API.G_FALSE, p_commit => FND_API.G_FALSE, p_validation_level => FND_API.G_VALID_LEVEL_FULL, x_return_status => v_return_status, x_msg_count => v_msg_count, x_msg_data => v_msg_data, p_cash_receipt_id => v_cash_receipt_id, p_receipt_number => NULL, p_reversal_category_code => 'REV', p_reversal_category_name => NULL, p_reversal_gl_date => v_gl_date, p_reversal_date => v_reversal_date, p_reversal_reason_code => 'INCORRECT INVOICE REASON', p_reversal_reason_name => NULL, p_reversal_comments => NULL, p_called_from => NULL, p_cancel_claims_flag => 'Y', p_org_id => l_organization_id); DBMS_OUTPUT.put_line ('Return Status of API is: ' || v_return_status); IF v_return_status = 'S' THEN DBMS_OUTPUT.put_line ( 'Receipt Reversal Successful for Cash Receipt ID: ' || v_cash_receipt_id); ELSE DBMS_OUTPUT.put_line ('Message count ' || v_msg_count); IF v_msg_count = 1 THEN DBMS_OUTPUT.put_line ('l_msg_data ' || v_msg_data); ELSIF v_msg_count > 1 THEN LOOP p_count := p_count + 1; v_msg_data := FND_MSG_PUB.Get (FND_MSG_PUB.G_NEXT, FND_API.G_FALSE); IF v_msg_data IS NULL THEN EXIT; END IF; DBMS_OUTPUT.put_line ( 'Message' || p_count || ' ---' || v_msg_data); END LOOP; END IF; END IF; END;
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
DECODE
Decode function is more like an IF-ELSE-ELSIF-ENDIF kind of condition. The Decode function format has an expression and a search value to search for. If the expression matches with the search value, then a corresponding result is given back by the function.
The format of DECODE function is:
DECODE (expression, search value_1, result1,
search value_2, result2,
search value_3, result3,
….);
It means – the code will check if the result of the expression matches with the search value_1, then gives back result1 as the output, if the result of the expression matches with search value_2, then gives back result2 as the output and so on and so forth.
Example: In order to understand DECODE function, let’s first create the required data. Use the following statements to create table and insert data.
CREATE TABLE xx_decode_test ( emp_name VARCHAR2 (200), emp_id NUMBER, dept_id NUMBER, join_date DATE ); SELECT * FROM XX_DECODE_TEST; INSERT INTO xx_decode_test VALUES ('Adam Smith', 101989, 10, '10-JUN-10'); INSERT INTO xx_decode_test VALUES ('Jason Warne', 101990, 20, '10-AUG-09'); INSERT INTO xx_decode_test VALUES ('Glenn Symonds', 101991, 30, '11-SEP-11'); INSERT INTO xx_decode_test VALUES ('Ricky Manning', 101992, 40, '13-NOV-15'); INSERT INTO xx_decode_test VALUES ('Heath Flower', 101993, 50, '13-NOV-15'); INSERT INTO xx_decode_test VALUES ('George Brady', 101994, 10, '01-APR-03');
Once the table is created, run the following statement.
SELECT EMP_NAME, EMP_ID, DEPT_ID, DECODE (DEPT_ID, 10, 'Marketing', 20, 'Sales', 30, 'Information Technology', 40, 'Shipping') "Department Name" FROM xx_decode_test;
The query generates the following output.
Thus, can be seen that, the query checks for the expression – if the value is 10, the function gives the word “Marketing”, if the value is 20, the function gives back “Sales” and etc..
Also, in the example above, it can be seen that no Department Name is assigned for Dept_ID 50. And thus, it returns a NULL Value.
Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/wp-content/themes/WpPremium/author.php on line 78
Query to retrieve Concurrent Program Details
The following query can be used to retrieve different details related to a Concurrent Program like Name, short name, executable details, parameters and valueset details.
Note: For this query – took the example of the seeded AR program – ‘Autoinvoice Master Program’.
SELECT fcpl.user_concurrent_program_name "Concurrent Program Name", fcp.concurrent_program_name "Short Name", fa.application_short_name "Module", fe.executable_name "Executable", fe.execution_file_name "Executable Short Name", DECODE (fcp.execution_method_code, 'X', 'FlexRpt', 'F', 'FlexSql', 'H', 'Host', 'S', 'Immediate', 'K', 'Java Concurrent Program', 'J', 'Java Stored Procedure', 'M', 'Multi Language Function', 'P', 'Oracle Reports', 'I', 'PL/SQL Stored Procedure', 'E', 'Perl Concurrent Program', 'B', 'Request Set Stage Function', 'L', 'SQL*Loader', 'Q', 'SQL*Plus', 'R', 'SQL*Report', 'Z', 'Shutdown Callback', 'A', 'Spawned') "Execution Method", fcpl.description "Program Description", fdfcuv.column_seq_num "Column Seq Number", fdfcuv.end_user_column_name "Parameter Name", fdfcuv.form_left_prompt "Prompt", fdfcuv.enabled_flag " Enabled Flag", fdfcuv.required_flag "Required Flag", fdfcuv.display_flag "Display Flag", ffvs.flex_value_set_name "Value Set Name" FROM fnd_executables fe, fnd_concurrent_programs_tl fcpl, fnd_application fa, fnd_concurrent_programs fcp, fnd_descr_flex_col_usage_vl fdfcuv, fnd_flex_value_sets ffvs, fnd_lookup_values flv WHERE 1 = 1 AND fe.executable_id = fcp.executable_id AND fcpl.application_id = fa.application_id AND fcpl.concurrent_program_id = fcp.concurrent_program_id AND user_concurrent_program_name = 'Autoinvoice Master Program' -- change Concurrent program name here.. AND fdfcuv.descriptive_flexfield_name = '$SRS$.' || fcp.concurrent_program_name AND ffvs.flex_value_set_id = fdfcuv.flex_value_set_id AND flv.lookup_type(+) = 'FLEX_DEFAULT_TYPE' AND flv.lookup_code(+) = fdfcuv.default_type AND fcpl.LANGUAGE = 'US' AND flv.LANGUAGE(+) = USERENV ('LANG') ORDER BY fdfcuv.column_seq_num;