declare
lv_wait_req_id BOOLEAN;
ln_request_id NUMBER;
lv_phase VARCHAR2(100);
lv_status VARCHAR2(100);
lv_dev_phase VARCHAR2(100);
lv_dev_status VARCHAR2(100);
lv_msg VARCHAR2(1000);
p_batch_id NUMBER;
g_user_id NUMBER := 48866;
g_resp_id NUMBER := 50916;
g_resp_appl_id NUMBER := 200;
ln_invoice_id NUMBER;
l_vendor_id NUMBER;
l_siteid NUMBER;
l_org_id NUMBER;
l_terms_id NUMBER;
l_currencycode VARCHAR2(100);
gv_sysdate VARCHAR2(100) := SYSDATE;
l_cc_id NUMBER;
gv_user_id VARCHAR2(100);
begin
ln_invoice_id := ap_invoices_interface_s.NEXTVAL;
INSERT INTO ap_invoices_interface (invoice_id,
invoice_num,
invoice_type_lookup_code,
vendor_id,
invoice_date,
gl_date,
vendor_site_id,
invoice_amount,
invoice_currency_code,
terms_id,
source,
org_id,
external_bank_account_id,
remit_to_supplier_id,
remit_to_supplier_site_id,
GROUP_ID,
creation_date,
created_by,
last_update_date,
last_updated_by)
VALUES
(ln_invoice_id, -- invoice_id
-- 'CONV' || lrec_dm_data.oracleinvoiceid, -- invoice_num
'INV-'||ln_invoice_id,
'CREDIT', -- invoice_type_lookup_code
l_vendor_id, -- vendor_id
gv_sysdate, -- invoice_date
SYSDATE , -- gl_date
l_siteid, -- vendor_site_id
-123, -- invoice_amount
l_currencycode, -- invoice_currency_code
l_terms_id, -- terms_id
'CREDITMEMO', -- source
l_org_id, -- org_id
NULL, -- external_bank_account_id
NULL, -- remit_to_supplier_id
NULL, -- remit_to_supplier_site_id
p_batch_id, -- group_id
gv_sysdate, -- creation_date
gv_user_id, -- created_by
gv_sysdate, -- last_update_date
gv_user_id -- last_updated_by
);
INSERT INTO ap_invoice_lines_interface
(invoice_id,
line_number,
invoice_line_id,
line_type_lookup_code,
amount,
dist_code_combination_id,
org_id,
description,
accounting_date,
creation_date,
created_by,
last_update_date,
last_updated_by)
VALUES
(ln_invoice_id, -- invoice_id
1, -- line_number
ap_invoice_lines_interface_s.NEXTVAL, -- invoice_line_id
'ITEM', -- line_type_lookup_code
-123, -- amount
l_cc_id, -- dist_code_combination_id
l_org_id, -- org_id
'DM ' || ln_invoice_id, -- description
gv_sysdate, -- accounting_date
gv_sysdate, -- creation_date
fnd_global.user_id, -- created_by
gv_sysdate, -- last_update_date
fnd_global.user_id -- last_updated_by
);
commit;
fnd_global.apps_initialize (user_id => g_user_id,
resp_id => g_resp_id,
resp_appl_id => g_resp_appl_id);
ln_request_id := fnd_request.submit_request (
application => 'SQLAP',
program => 'APXIIMPT',
description => NULL,
start_time => SYSDATE, -- , sub_request => TRUE
argument1 => NULL, -- OU
argument2 => 'CREDITMEMO', -- Source
argument3 => p_batch_id, -- Group
argument4 => 'APINV' || '_' || p_batch_id, -- Batch Name
argument5 => NULL, -- Hold Name
argument6 => NULL, -- Hold Reason
argument7 => NULL, -- GL Date
argument8 => 'N',
argument9 => 'N',
argument10 => 'N',
argument11 => 'N');
COMMIT;
lv_wait_req_id :=
fnd_concurrent.wait_for_request (request_id => ln_request_id,
interval => 10,
max_wait => 0,
phase => lv_phase,
status => lv_status,
dev_phase => lv_dev_phase,
dev_status => lv_dev_status,
MESSAGE => lv_msg);
dbms_output.put_line('Request Id'|| ln_request_id);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Unknown Exception'|| SQLERRM);
END;
No comments:
Post a Comment