DECLARE
p_transaction_type VARCHAR2(50);
p_instance_id NUMBER;
p_new_instance_id NUMBER;
p_vld_org_id NUMBER;
p_quantity NUMBER;
p_party_account_id1 NUMBER;
p_party_account_id2 NUMBER;
p_transaction_date DATE;
p_source_transaction_date DATE;
p_transaction_id NUMBER;
p_grp_call_contracts VARCHAR2(1);
p_txn_type_id NUMBER;
p_system_id NUMBER;
p_order_line_id NUMBER;
p_call_from_bom_expl VARCHAR2(1);
lp_oks_txn_inst_tbl oks_ibint_pub.txn_instance_tbl;
lx_return_status VARCHAR2(1);
lx_msg_count NUMBER;
lx_msg_data VARCHAR2(500);
l_msg_index_out NUMBER;
l_return_msg VARCHAR2(32600);
k_rpl_tbl oks_extwarprgm_pvt.contract_tbl;
CURSOR get_k_for_rpl_csr
IS
SELECT tmp.old_customer_product_id instance_id
, tmp.termination_date
, tmp.installation_date
, tmp.transaction_date
, tmp.old_customer_acct_id
, tmp.new_customer_acct_id
, tmp.system_id
, tmp.old_quantity
, tmp.new_quantity
, tmp.new_customer_product_id
, ki.cle_id subline_id
, ki.dnz_chr_id
, kh.start_date hdr_sdt
, kh.end_date hdr_edt
, kh.sts_code hdr_sts
, kl.cle_id
, kl.price_negotiated
, kl.start_date
, kl.end_date
, kl.sts_code prod_sts
, kl.cust_acct_id
, tl.start_date srv_sdt
, tl.end_date srv_edt
, kh.sts_code
, kh.contract_number
, ki.number_of_items
, tl.price_negotiated
, kl.date_terminated
, tmp.old_inventory_item_id
, kh.authoring_org_id
, kh.inv_organization_id
, kl.lse_id
, kh.scs_code
, tmp.new_customer_product_id
, kis.object1_id1
, tl.currency_code
, tmp.old_unit_of_measure
, kl.line_renewal_type_code
, tmp.raise_credit
, NULL
, okl.tax_amount
, kl.price_unit
, kl.name
, kl.item_description
, kl.upg_orig_system_ref
, kl.upg_orig_system_ref_id
, tmp.new_inventory_item_id
, tmp.return_reason_code
, tmp.order_line_id
, okl.price_uom
, okl.toplvl_uom_code
, okl.toplvl_price_qty
FROM okc_k_items ki
, okc_k_headers_all_b kh
, okc_k_lines_v kl
, okc_statuses_b st
, oks_instance_temp tmp
, okc_k_lines_b tl
, okc_k_items kis
, oks_k_lines_b okl
WHERE tmp.rpl = 'Y'
AND ki.object1_id1 = TO_CHAR( tmp.old_customer_product_id)
AND ki.jtot_object1_code = 'OKX_CUSTPROD'
AND ki.dnz_chr_id = kh.id
AND kh.scs_code IN ('WARRANTY', 'SERVICE', 'SUBSCRIPTION')
AND ki.cle_id = kl.id
AND tl.id = kl.cle_id
AND kis.cle_id = tl.id
AND kis.dnz_chr_id = tl.dnz_chr_id
AND kl.sts_code = st.code
AND st.ste_code NOT IN ('TERMINATED', 'CANCELLED', 'HOLD')
AND kl.date_terminated IS NULL
AND okl.cle_id = kl.id
AND kh.template_yn = 'N'
AND ((TRUNC( tmp.transaction_date) <= TRUNC( kl.end_date)
AND TRUNC( tmp.transaction_date) >= TRUNC( kl.start_date))
OR (TRUNC( tmp.transaction_date) <= TRUNC( kl.start_date)))
ORDER BY tmp.old_customer_product_id
, kh.creation_date;
BEGIN
-- lp_oks_txn_inst_tbl( 1).old_customer_product_id := 4367640;
apps.csi_item_instance_pvt.call_to_contracts(
p_transaction_type => 'RPL'
, p_instance_id => 4367640
, p_new_instance_id => 5302910
, p_vld_org_id => 103
, p_quantity => NULL
, p_party_account_id1 => NULL
, p_party_account_id2 => NULL
, p_transaction_date => SYSDATE
, p_source_transaction_date => SYSDATE
, p_grp_call_contracts => fnd_api.g_false
, p_oks_txn_inst_tbl => lp_oks_txn_inst_tbl
, x_return_status => lx_return_status
, x_msg_count => lx_msg_count
, x_msg_data => lx_msg_data);
IF lx_return_status = fnd_api.g_ret_sts_success
THEN
FORALL i IN lp_oks_txn_inst_tbl.FIRST .. lp_oks_txn_inst_tbl.LAST
INSERT INTO oks_instance_temp
VALUES lp_oks_txn_inst_tbl( i);
fnd_global.apps_initialize(12247
, 50305
, 515);
OPEN get_k_for_rpl_csr;
FETCH get_k_for_rpl_csr BULK COLLECT INTO k_rpl_tbl;
CLOSE get_k_for_rpl_csr;
apps.oks_extwarprgm_pvt.update_contract_ibreplace(
k_rpl_tbl
, lx_return_status
, lx_msg_count
, lx_msg_data);
IF lx_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line( 'Swapped syccessfully.');
COMMIT;
ELSE
IF lx_msg_count > 0
THEN
FOR i IN 1 .. lx_msg_count
LOOP
fnd_msg_pub.get(p_msg_index => i
, p_encoded => fnd_api.g_false
, p_data => lx_msg_data
, p_msg_index_out=> l_msg_index_out);
IF l_return_msg IS NULL
THEN
l_return_msg :=
l_msg_index_out
|| ':'
|| lx_msg_data;
ELSE
l_return_msg :=
l_return_msg
|| '/'
|| l_msg_index_out
|| ':'
|| lx_msg_data;
END IF;
END LOOP;
END IF;
DBMS_OUTPUT.put_line( 'Swaping of Service contract for IB failed : '
|| NVL(lx_msg_data, l_return_msg));
END IF;
ELSE
IF lx_msg_count > 0
THEN
FOR i IN 1 .. lx_msg_count
LOOP
fnd_msg_pub.get(p_msg_index => i
, p_encoded => fnd_api.g_false
, p_data => lx_msg_data
, p_msg_index_out=> l_msg_index_out);
IF l_return_msg IS NULL
THEN
l_return_msg :=
l_msg_index_out
|| ':'
|| lx_msg_data;
ELSE
l_return_msg :=
l_return_msg
|| '/'
|| l_msg_index_out
|| ':'
|| lx_msg_data;
END IF;
END LOOP;
END IF;
DBMS_OUTPUT.put_line( 'call to contract failure : '
|| NVL(lx_msg_data, l_return_msg));
END IF;
END;
p_transaction_type VARCHAR2(50);
p_instance_id NUMBER;
p_new_instance_id NUMBER;
p_vld_org_id NUMBER;
p_quantity NUMBER;
p_party_account_id1 NUMBER;
p_party_account_id2 NUMBER;
p_transaction_date DATE;
p_source_transaction_date DATE;
p_transaction_id NUMBER;
p_grp_call_contracts VARCHAR2(1);
p_txn_type_id NUMBER;
p_system_id NUMBER;
p_order_line_id NUMBER;
p_call_from_bom_expl VARCHAR2(1);
lp_oks_txn_inst_tbl oks_ibint_pub.txn_instance_tbl;
lx_return_status VARCHAR2(1);
lx_msg_count NUMBER;
lx_msg_data VARCHAR2(500);
l_msg_index_out NUMBER;
l_return_msg VARCHAR2(32600);
k_rpl_tbl oks_extwarprgm_pvt.contract_tbl;
CURSOR get_k_for_rpl_csr
IS
SELECT tmp.old_customer_product_id instance_id
, tmp.termination_date
, tmp.installation_date
, tmp.transaction_date
, tmp.old_customer_acct_id
, tmp.new_customer_acct_id
, tmp.system_id
, tmp.old_quantity
, tmp.new_quantity
, tmp.new_customer_product_id
, ki.cle_id subline_id
, ki.dnz_chr_id
, kh.start_date hdr_sdt
, kh.end_date hdr_edt
, kh.sts_code hdr_sts
, kl.cle_id
, kl.price_negotiated
, kl.start_date
, kl.end_date
, kl.sts_code prod_sts
, kl.cust_acct_id
, tl.start_date srv_sdt
, tl.end_date srv_edt
, kh.sts_code
, kh.contract_number
, ki.number_of_items
, tl.price_negotiated
, kl.date_terminated
, tmp.old_inventory_item_id
, kh.authoring_org_id
, kh.inv_organization_id
, kl.lse_id
, kh.scs_code
, tmp.new_customer_product_id
, kis.object1_id1
, tl.currency_code
, tmp.old_unit_of_measure
, kl.line_renewal_type_code
, tmp.raise_credit
, NULL
, okl.tax_amount
, kl.price_unit
, kl.name
, kl.item_description
, kl.upg_orig_system_ref
, kl.upg_orig_system_ref_id
, tmp.new_inventory_item_id
, tmp.return_reason_code
, tmp.order_line_id
, okl.price_uom
, okl.toplvl_uom_code
, okl.toplvl_price_qty
FROM okc_k_items ki
, okc_k_headers_all_b kh
, okc_k_lines_v kl
, okc_statuses_b st
, oks_instance_temp tmp
, okc_k_lines_b tl
, okc_k_items kis
, oks_k_lines_b okl
WHERE tmp.rpl = 'Y'
AND ki.object1_id1 = TO_CHAR( tmp.old_customer_product_id)
AND ki.jtot_object1_code = 'OKX_CUSTPROD'
AND ki.dnz_chr_id = kh.id
AND kh.scs_code IN ('WARRANTY', 'SERVICE', 'SUBSCRIPTION')
AND ki.cle_id = kl.id
AND tl.id = kl.cle_id
AND kis.cle_id = tl.id
AND kis.dnz_chr_id = tl.dnz_chr_id
AND kl.sts_code = st.code
AND st.ste_code NOT IN ('TERMINATED', 'CANCELLED', 'HOLD')
AND kl.date_terminated IS NULL
AND okl.cle_id = kl.id
AND kh.template_yn = 'N'
AND ((TRUNC( tmp.transaction_date) <= TRUNC( kl.end_date)
AND TRUNC( tmp.transaction_date) >= TRUNC( kl.start_date))
OR (TRUNC( tmp.transaction_date) <= TRUNC( kl.start_date)))
ORDER BY tmp.old_customer_product_id
, kh.creation_date;
BEGIN
-- lp_oks_txn_inst_tbl( 1).old_customer_product_id := 4367640;
apps.csi_item_instance_pvt.call_to_contracts(
p_transaction_type => 'RPL'
, p_instance_id => 4367640
, p_new_instance_id => 5302910
, p_vld_org_id => 103
, p_quantity => NULL
, p_party_account_id1 => NULL
, p_party_account_id2 => NULL
, p_transaction_date => SYSDATE
, p_source_transaction_date => SYSDATE
, p_grp_call_contracts => fnd_api.g_false
, p_oks_txn_inst_tbl => lp_oks_txn_inst_tbl
, x_return_status => lx_return_status
, x_msg_count => lx_msg_count
, x_msg_data => lx_msg_data);
IF lx_return_status = fnd_api.g_ret_sts_success
THEN
FORALL i IN lp_oks_txn_inst_tbl.FIRST .. lp_oks_txn_inst_tbl.LAST
INSERT INTO oks_instance_temp
VALUES lp_oks_txn_inst_tbl( i);
fnd_global.apps_initialize(12247
, 50305
, 515);
OPEN get_k_for_rpl_csr;
FETCH get_k_for_rpl_csr BULK COLLECT INTO k_rpl_tbl;
CLOSE get_k_for_rpl_csr;
apps.oks_extwarprgm_pvt.update_contract_ibreplace(
k_rpl_tbl
, lx_return_status
, lx_msg_count
, lx_msg_data);
IF lx_return_status = fnd_api.g_ret_sts_success
THEN
DBMS_OUTPUT.put_line( 'Swapped syccessfully.');
COMMIT;
ELSE
IF lx_msg_count > 0
THEN
FOR i IN 1 .. lx_msg_count
LOOP
fnd_msg_pub.get(p_msg_index => i
, p_encoded => fnd_api.g_false
, p_data => lx_msg_data
, p_msg_index_out=> l_msg_index_out);
IF l_return_msg IS NULL
THEN
l_return_msg :=
l_msg_index_out
|| ':'
|| lx_msg_data;
ELSE
l_return_msg :=
l_return_msg
|| '/'
|| l_msg_index_out
|| ':'
|| lx_msg_data;
END IF;
END LOOP;
END IF;
DBMS_OUTPUT.put_line( 'Swaping of Service contract for IB failed : '
|| NVL(lx_msg_data, l_return_msg));
END IF;
ELSE
IF lx_msg_count > 0
THEN
FOR i IN 1 .. lx_msg_count
LOOP
fnd_msg_pub.get(p_msg_index => i
, p_encoded => fnd_api.g_false
, p_data => lx_msg_data
, p_msg_index_out=> l_msg_index_out);
IF l_return_msg IS NULL
THEN
l_return_msg :=
l_msg_index_out
|| ':'
|| lx_msg_data;
ELSE
l_return_msg :=
l_return_msg
|| '/'
|| l_msg_index_out
|| ':'
|| lx_msg_data;
END IF;
END LOOP;
END IF;
DBMS_OUTPUT.put_line( 'call to contract failure : '
|| NVL(lx_msg_data, l_return_msg));
END IF;
END;
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.