Tuesday, May 25, 2010
Credit Memo Creation via API ( ar_credit_memo_api_pub.create_request )
Below Script can be used to create a Credit memo against an Invoice. This script was tested in 11i instance.
SET serveroutput ON;
DECLARE
-- This script was tested in 11i instance --
v_return_status VARCHAR2 (1);
p_count NUMBER;
v_msg_count NUMBER;
v_msg_data VARCHAR2 (2000);
v_request_id NUMBER;
v_context VARCHAR2 (2);
FUNCTION set_context( i_user_name IN VARCHAR2
,i_resp_name IN VARCHAR2
,i_org_id IN NUMBER)
RETURN VARCHAR2
IS
BEGIN
NULL;
-- Inorder to reduce the content of the post I moved the implementation part of this function to another post and it is available here
END set_context;
BEGIN
-- Setting the context ----
v_context :=
set_context ('&user', '&responsibility', 2038);
IF v_context = 'F'
THEN
DBMS_OUTPUT.put_line ('Error while setting the context');
END IF;
DBMS_OUTPUT.put_line ('2');
--- context done ------------
DBMS_OUTPUT.put_line ('Invoking Credit Memo Creation api');
ar_credit_memo_api_pub.create_request
(
-- standard api parameters
p_api_version => 1.0,
p_init_msg_list => fnd_api.g_false,
p_commit => fnd_api.g_false,
x_return_status => v_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data,
x_request_id => v_request_id,
-- credit memo request parameters
p_customer_trx_id => &inv_cust_trx_id,
p_line_credit_flag => 'N',
p_line_amount => &return_amount,
p_tax_amount => 0,
p_cm_reason_code => 'RETURN',
p_skip_workflow_flag => 'Y',
p_batch_source_name => '&batch_source_name',
p_credit_method_installments => NULL,
p_credit_method_rules => NULL
);
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
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;
Do you think this Article is useful?
Subscribe to:
Post Comments (Atom)
Disclaimer
The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.
0 Responses to “Credit Memo Creation via API ( ar_credit_memo_api_pub.create_request )”
Post a Comment