Credit Memo API in R12
CREATE OR REPLACE PROCEDURE APPS.xxlspCreate_CreditMemo_ar (
v_user_id NUMBER,
v_resp_id NUMBER,
v_org_id NUMBER,
v_customer_trx_id NUMBER,
v_amount NUMBER,
v_request_id OUT NUMBER
)
AS
v_msg_count NUMBER;
v_msg_data VARCHAR2 (2000);
v_return_status VARCHAR2 (1);
BEGIN
--We need to initialize the following in R12
fnd_global.apps_initialize (user_id => v_user_id,
resp_id => v_resp_id,
resp_appl_id => 222
);
mo_global.init ('AR');
mo_global.set_policy_context ('S', v_org_id);
ar_credit_memo_api_pub.create_request
(
-- standard api parameters
p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => v_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data,
-- credit memo request parameters
p_customer_trx_id => v_customer_trx_id,
p_line_credit_flag => 'N',
p_line_amount => v_amount,
p_tax_amount => 0,
p_cm_reason_code => 'RETURN',
p_skip_workflow_flag => 'Y',
p_batch_source_name => 'INVOICE Manual',
p_credit_method_installments => NULL,
p_credit_method_rules => NULL,
x_request_id => v_request_id
);
IF v_return_status = fnd_api.g_ret_sts_unexp_error
OR v_return_status = fnd_api.g_ret_sts_error
THEN
DBMS_OUTPUT.put_line (v_msg_data);
END IF;
IF v_msg_count > 1
THEN
v_msg_count := 0;
LOOP
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 (v_msg_data);
END LOOP;
END IF;
IF v_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line (v_msg_data);
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error in Crea_cm:' || SQLERRM);
END;
/
-------------Tested flow for creating manual credit memo----
credit memo API:
ARP_PROCESS_HEADER_INSRT_COVER.insert_header_cover
ARP_INSERT_LINE_COVER.INSERT_LINE_COVER
arp_process_header.post_commit
ARP_PROCESS_HEADER_UPDTE_COVER.update_header_cover
CREATE OR REPLACE PROCEDURE APPS.xxlspCreate_CreditMemo_ar (
v_user_id NUMBER,
v_resp_id NUMBER,
v_org_id NUMBER,
v_customer_trx_id NUMBER,
v_amount NUMBER,
v_request_id OUT NUMBER
)
AS
v_msg_count NUMBER;
v_msg_data VARCHAR2 (2000);
v_return_status VARCHAR2 (1);
BEGIN
--We need to initialize the following in R12
fnd_global.apps_initialize (user_id => v_user_id,
resp_id => v_resp_id,
resp_appl_id => 222
);
mo_global.init ('AR');
mo_global.set_policy_context ('S', v_org_id);
ar_credit_memo_api_pub.create_request
(
-- standard api parameters
p_api_version => 1.0,
p_init_msg_list => fnd_api.g_true,
p_commit => fnd_api.g_true,
x_return_status => v_return_status,
x_msg_count => v_msg_count,
x_msg_data => v_msg_data,
-- credit memo request parameters
p_customer_trx_id => v_customer_trx_id,
p_line_credit_flag => 'N',
p_line_amount => v_amount,
p_tax_amount => 0,
p_cm_reason_code => 'RETURN',
p_skip_workflow_flag => 'Y',
p_batch_source_name => 'INVOICE Manual',
p_credit_method_installments => NULL,
p_credit_method_rules => NULL,
x_request_id => v_request_id
);
IF v_return_status = fnd_api.g_ret_sts_unexp_error
OR v_return_status = fnd_api.g_ret_sts_error
THEN
DBMS_OUTPUT.put_line (v_msg_data);
END IF;
IF v_msg_count > 1
THEN
v_msg_count := 0;
LOOP
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 (v_msg_data);
END LOOP;
END IF;
IF v_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line (v_msg_data);
END IF;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('Error in Crea_cm:' || SQLERRM);
END;
/
-------------Tested flow for creating manual credit memo----
credit memo API:
ARP_PROCESS_HEADER_INSRT_COVER.insert_header_cover
ARP_INSERT_LINE_COVER.INSERT_LINE_COVER
arp_process_header.post_commit
ARP_PROCESS_HEADER_UPDTE_COVER.update_header_cover
No comments:
Post a Comment