You are on page 1of 10

White Paper

On

How to call credit checking Public APIs From custom code

Content
Functional Overview....3 1. Required Setup 3
1.1 Setup a Credit check rule3 1.2 Payment Terms setup..4 1.3 Customer Standard setup.4

2. Overview:
2.1 Parameters of OE_EXTERNAL_CREDIT_PUB.CHECK_EXTERNAL_CREDIT API5 2.2 Sample wrapper code, which calls OE_EXTERNAL_CREDIT_PUB.CHECK_EXTERNAL_CREDIT API..5 2.3 Parameteres of OE_CREDIT_EXPOSURE_PUB.GET_CUSTOMER_EXPOSURE API.8 2.4 Sample wrapper code, which calls OE_CREDIT_EXPOSURE_PUB.GET_CUSTOMER_EXPOSURE API..9

Functional Overview
This document is intended to help the customers who want to call the OM Credit check public API from any custom code or custom workflow. This document has the sample code and output of the OM credit checking public APIs and illustrates the usage of the same. This OM credit checking API allows the user to determine the credit worthiness of a customer. But at the same time it doesnt apply any hold on the sales order/quote even if the failure happens. The key differences between below explained credit checking and the credit checking functionality in Oracle Order Management (OM) are: Item category limits are not checked in the public credit check API provided. Credit checking is only available at the header level using this public api, while OM credit checking supports both header and line level credit checks. There is no Holds functionality through this public APIs.

1. Required Setup:
1.1 Setup a Credit check rule: Credit check rule is required to calculate the exposure at SITE/CUSTOMER/PARTY levels. For SITE/CUSTOMER levels exposure calculation, Pre-calculated exposure is optional.

For Party level exposure calculation, Pre-calculated exposure is mandatory to get the correct exposure details.

If the Pre-calculated exposure disabled credit check rule is used in calculating the Party level exposure, desired results might not be returned.

1.2 Payment Terms setup: No setup is required when we call the OM public API for credit checking. But it is required for the system triggerred Credit checking functionality. 1.3 Customer Standard setup: Credit check check box at the customer standard account/site level has to be checked to enable the credit checking according to the requirement.

2. Overview: There are two APIs will be discussed here. First OE_EXTERNAL_CREDIT_PUB API does the credit checking and returns the result of the credit checking. But it doesnt apply any hold on the Order/Quote. Additional to the above credit checking public api, section 2.3 and 2.4 explains how to calculate the exposure data at various levels such as Party, Customer and Site.

2.1 Parameters of OE_EXTERNAL_CREDIT_PUB.CHECK_EXTERNAL_CREDIT API Parameter Name P_API_VERSION P_INIT_MSG_LIST X_RETURN_STATUS X_RESULT_OUT X_MSG_DATA X_MSG_COUNT X_CC_HOLD_COMMENT p_bill_to_site_use_id p_functional_currency_code p_transaction_currency_code p_transaction_amount p_credit_check_rule_id p_org_id Type IN IN OUT OUT OUT OUT OUT IN IN IN IN IN IN Meaning Value can be 1.0 Default value is FND_API.G_FALSE Return status of the API Result of credit checking Ex: SUCCESS,FAIL Messages returned by the API Message count returned by the API Detailed Result message of credit checking process Invoice to org id of the header record Currency code used in the Header record. Currency code used in the Header record. Order/Quote amount Credit check rule id Org id in which the order/quote is created.

2.2 Sample wrapper code, which calls OE_EXTERNAL_CREDIT_PUB.CHECK_EXTERNAL_CREDIT API. Below script expects the order/quote header_id and the Org_id in which the order/quote is getting created.
DECLARE P_INIT_MSG_LIST VARCHAR2(100) := FND_API.G_FALSE; X_RETURN_STATUS VARCHAR2(1); X_MSG_COUNT NUMBER(10); X_MSG_DATA VARCHAR2(200); X_RESULT_OUT VARCHAR2(100); X_CC_HOLD_COMMENT VARCHAR2(500); l_functional_currency VARCHAR2(15); l_credit_check_rule_id NUMBER; l_site_use_id NUMBER;

l_transactional_amount ASO_QUOTE_HEADERS_ALL.TOTAL_QUOTE_PRICE%TYPE; l_credit_check_rule_rec OE_CREDIT_CHECK_UTIL.OE_credit_rules_rec_type ; l_system_parameter_rec OE_CREDIT_CHECK_UTIL.OE_systems_param_rec_type ; l_org_id NUMBER; l_header_id NUMBER:=&header_id; l_order_value NUMBER; x_conversion_status OE_CREDIT_CHECK_UTIL.CURR_TBL_TYPE; x_return_status1 VARCHAR2(100); l_file_val varchar2(300); BEGIN mo_global.set_policy_context('S',&Org_id); BEGIN SELECT CREDIT_CHECK_RULE_ID INTO l_credit_check_rule_id FROM oe_credit_check_rules WHERE CREDIT_CHECK_LEVEL_CODE = 'ORDER' AND ROWNUM=1; EXCEPTION WHEN OTHERS THEN Dbms_Output.put_line('Error in retrieving the credit check rule details'); RAISE; END; BEGIN SELECT org_id,invoice_to_org_id,transactional_curr_code INTO l_org_id,l_site_use_id,l_functional_currency FROM oe_order_headers WHERE header_id=l_header_id; EXCEPTION WHEN OTHERS THEN Dbms_Output.put_line('Error in retrieving headaer record details'); RAISE; END; BEGIN OE_CREDIT_CHECK_UTIL.GET_credit_check_rule ( p_credit_check_rule_id => l_credit_check_rule_id , x_credit_check_rules_rec => l_credit_check_rule_rec ); OE_CREDIT_CHECK_UTIL.GET_System_parameters ( x_system_parameter_rec => l_system_parameter_rec ); OE_CREDIT_CHECK_UTIL.GET_transaction_amount ( p_header_id => l_header_id , p_transaction_curr_code => l_functional_currency , p_credit_check_rule_rec => l_credit_check_rule_rec , p_system_parameter_rec => l_system_parameter_rec , p_customer_id => NULL , p_site_use_id => NULL

, p_limit_curr_code => l_functional_currency , x_amount => l_order_value , x_conversion_status => x_conversion_status , x_return_status => x_return_status1 ); EXCEPTION WHEN OTHERS THEN Dbms_Output.put_line('Error in calculating the order amount'); RAISE; END; Dbms_Output.put_line('Order/quote Amount->'||l_order_value); OE_EXTERNAL_CREDIT_PUB.CHECK_EXTERNAL_CREDIT ( P_API_VERSION => 1.0, P_INIT_MSG_LIST => p_init_msg_list, X_RETURN_STATUS => x_return_status, X_RESULT_OUT => x_result_out, X_MSG_DATA => x_msg_data, X_MSG_COUNT => x_msg_count, X_CC_HOLD_COMMENT => x_cc_hold_comment, p_bill_to_site_use_id => l_site_use_id, p_functional_currency_code => l_functional_currency, p_transaction_currency_code => l_functional_currency, p_transaction_amount => l_order_value, p_credit_check_rule_id => l_credit_check_rule_id, p_org_id => l_org_id ); Dbms_Output.put_line('x_return_status->'||x_return_status); Dbms_Output.put_line('x_result_out->'||x_result_out); Dbms_Output.put_line('x_msg_data->'||x_msg_data); Dbms_Output.put_line('x_msg_count->'||x_msg_count); Dbms_Output.put_line('x_cc_hold_comment->'||x_cc_hold_comment); EXCEPTION WHEN OTHERS THEN Dbms_Output.put_line('error->'||SQLCODE||'/'||SQLERRM); END;

Output of the sample wrapper code: Order/quote Amount->20047.063 x_return_status->S x_result_out->FAIL x_msg_data->ONT OE_CC_EXT_OVERALL_SITE x_msg_count->1 x_cc_hold_comment->Credit check failed. Overall Limit exceeded. Using site credit profile. activity has done credit checking using level credit check rule.

2.3 Parameteres of oe_credit_exposure_pub.Get_customer_exposure API

Parameter Name p_party_id p_customer_id p_site_id

Type IN IN IN

p_limit_curr_code p_credit_check_rule_id x_total_exposure x_order_hold_amount x_order_amount x_ar_amount x_external_amount x_return_status

IN IN OUT OUT OUT OUT OUT OUT

Meaning Party id Customer id Site Use id (Invoice to org id of order/Quote header record) Currency code used in Order/quote Credit check rule id Total Exposure Total Order Amount, which is on hold. Order Amount Exposure AR balance External Exposure amount Success/Failure

Pass the Party/customer/Site details according to the level in which the exposure details are required. Public API oe_credit_exposure_pub.Get_customer_exposure can be called from custom.pld or any custom procedure and the exposure amount can be shown in the frontend application. Next section has the sample wrapper code, which explains the usage of get_customer_exposure API.

2.4 Sample wrapper code which calls oe_credit_exposure_pub.Get_customer_exposure API.

declare x_total_exposure NUMBER; x_order_hold_amount NUMBER; x_order_amount NUMBER; x_ar_amount NUMBER;

x_external_amount NUMBER; x_return_status VARCHAR2(100); v_party_id NUMBER:=1006; -- Party id value v_customer_id NUMBER:=1006; -- customer account number v_site_id NUMBER:=1025; -- Customer bill to site use id v_limit_curr_code VARCHAR2(10); v_credit_check_rule_id NUMBER; begin mo_global.set_policy_context('S',204); oe_credit_exposure_pub.Get_customer_exposure (p_party_id=>NULL, p_customer_id=>v_customer_id, p_site_id=>NULL, p_limit_curr_code=> 'USD', p_credit_check_rule_id=>1000, x_total_exposure=> x_total_exposure , x_order_hold_amount=>x_order_hold_amount, x_order_amount=> x_order_amount, x_ar_amount=> x_ar_amount , x_external_amount=>x_external_amount, x_return_status=>x_return_status); dbms_output.put_line(' CUSTOMER Level Exposure '); dbms_output.put_line(' ----------------------- '); dbms_output.put_line('Total Exposure->'||x_total_exposure); dbms_output.put_line('Return status ->'||x_return_status);

oe_credit_exposure_pub.Get_customer_exposure (p_party_id=>v_party_id, p_customer_id=>NULL, p_site_id=>NULL, p_limit_curr_code=> 'USD', p_credit_check_rule_id=>1000, x_total_exposure=> x_total_exposure , x_order_hold_amount=>x_order_hold_amount, x_order_amount=> x_order_amount, x_ar_amount=> x_ar_amount , x_external_amount=>x_external_amount, x_return_status=>x_return_status); dbms_output.put_line(' PARTY Level Exposure '); dbms_output.put_line(' -------------------- '); dbms_output.put_line('Total Exposure->'||x_total_exposure); dbms_output.put_line('Return status ->'||x_return_status); oe_credit_exposure_pub.Get_customer_exposure (p_party_id=>NULL, p_customer_id=>null, p_site_id=>v_site_id,

p_limit_curr_code=> 'USD', p_credit_check_rule_id=>1000, x_total_exposure=> x_total_exposure , x_order_hold_amount=>x_order_hold_amount, x_order_amount=> x_order_amount, x_ar_amount=> x_ar_amount , x_external_amount=>x_external_amount, x_return_status=>x_return_status); dbms_output.put_line(' SITE Level Exposure '); dbms_output.put_line(' ------------------- '); dbms_output.put_line('Total Exposure->'||x_total_exposure); dbms_output.put_line('Return status ->'||x_return_status); exception when others then dbms_output.put_line('Error->'||sqlcode||'/'||sqlerrm); end;

Output of the sample wrapper code: CUSTOMER Level Exposure ----------------------Total Exposure->217660771.726 Return status ->S PARTY Level Exposure -------------------Total Exposure->220344766.165 Return status ->S SITE Level Exposure ------------------Total Exposure->197508546.984 Return status ->S

You might also like