Professional Documents
Culture Documents
Complete AP Interface
Pre-requisites:
a) Vendors and their Sites Should Be Setup
b) Currency and exchange Rates Should Be setup
c) Source and invoice type lookup code must be defined
d) Account Payables Account and Distribution Account must be defined.
e) Payment Terms should be defines and GL Period must be in opened status.
Interface Tables:
AP_INVOICES_INTERFACE
AP_INVOCE_LINES_INTERFACE
BASE TABLES :
AP_INVOICES_ALL
AP_INVOICE_DISTRIBUTIONS_ALL
AP_PAYMENT_SCHEDULES
INTERFACE PROGRAM:
Payables Open Interface Import
Parameters to be passed during the program:
Source
= External
group_id = As Specified in the data file
Batch Name = N/A
Hold Name = null
Hold Reason = null
gl date
= null
Purge
= No
Summarize = No
Error Tables:
AP_INTERFACE_REJECTIONS
AP_INTERFACE_CONTROLS
Main Columns In AP_INVOICES_INTERFACE:
INVOICE_ID,
INVOICE_NUM, INVOICE_DATE ,INVOICE_AMOUNT
VENDOR_ID ,
VENDOR_NUM, VENDOR_NAME ,VENDOR_SITE_CODE, VENDOR_SITE_ID
TERMS_NAME,
TERM_ID,
TERM_DATE, SOURCE,
PAYMENT_METHOD_LOOKUP_CODE,
GL_DATE,
PO_NUMBER, INVOICE_CURRENCE_CODE,
EXCHANGE_RATE_TYPE
VOUCHER_NUMBER, PAYMENT_CURRENCY_CODE, DOC_CATEGPRY_CODE
where process_flag='S';
cursor c2 is select * from ap_inv_head
where process_flag='E';
v_tot_rec number;
v_sus_rec number;
v_err_rec number;
begin
--for total records
select count(*) into v_tot_rec
from ap_inv_head;
-- for success records
select count(*) into v_sus_rec
from ap_inv_head
where process_flag='S';
--for error records
select count(*) into v_err_rec
from ap_inv_head
where process_flag='E';
for info in c1
loop
fnd_file.put_line(fnd_file.output,'---------------------------');
fnd_file.put_line(fnd_file.output,'FOR SUSCESS INFORMATION');
fnd_file.put_line(fnd_file.output,'---------------------------');
fnd_file.put_line(fnd_file.output,'INVOICE NUM =>'||info.invoice_num);
fnd_file.put_line(fnd_file.output,'VENDOR NAME =>'||info.vendor_name);
fnd_file.put_line(fnd_file.output,'TOTAL RECORDS =>'||v_tot_rec);
fnd_file.put_line(fnd_file.output,'TOTAL SUCESS RECORDS =>'||v_sus_rec);
fnd_file.put_line(fnd_file.output,'TOTAL ERROR RECORDS =>'||v_err_rec);
end loop;
for info1 in c2
loop
fnd_file.put_line(fnd_file.output,'---------------------------');
fnd_file.put_line(fnd_file.output,'FOR ERROR INFORMATION');
fnd_file.put_line(fnd_file.output,'---------------------------');
fnd_file.put_line(fnd_file.output,'INVOICE NUM =>'||info1.invoice_num);
fnd_file.put_line(fnd_file.output,'VENDOR NAME =>'||info1.vendor_name);
fnd_file.put_line(fnd_file.output,'TOTAL RECORDS =>'||v_tot_rec);
fnd_file.put_line(fnd_file.output,'TOTAL SUCESS RECORDS =>'||v_sus_rec);
fnd_file.put_line(fnd_file.output,'TOTAL ERROR RECORDS =>'||v_err_rec);
fnd_file.put_line(fnd_file.output,'ERROR MESSAGE =>'||info1.error_message);
end loop;
end ap_record_details;
---arch table information
procedure arch_proc
is
begin
insert into ap_inv_head_arch select * from ap_inv_head;
insert into ap_inv_line_arch select * from ap_inv_line;
delete from ap_inv_head;
delete from ap_inv_line;
commit;
end;
and org_id=v_head.org_id;
if v_count > 0
then
raise v_inv_num_exists;
end if;
-----****source validation****----begin
select lookup_code into v_head.source
from ap_lookup_codes
where lookup_type='SOURCE'
and displayed_field=rec_head.source;
exception
when no_data_found then
v_process_flag:='E';
v_error_message:='INVALID SOURCE =>'||rec_head.source;
v_tot_err_msg:=v_tot_err_msg||' '||v_error_message;
ee_ap_comm_err_procedure(p_interface_name => v_conc_program,
p_table_name => v_head_tab,
p_column_name => 'SOURCE',
p_error_message => v_error_message
);
when others then
v_process_flag:='E';
v_error_message:='EXCEPTION AT SOURCE VALIDATION =>'||rec_head.source||' '||
sqlerrm;
v_tot_err_msg:=v_tot_err_msg||' '||v_error_message;
ee_ap_comm_err_procedure(p_interface_name => v_conc_program,
p_table_name => v_head_tab,
p_column_name => 'SOURCE',
p_error_message => v_error_message
);
end;
---***terms validation ***---begin
select term_id into v_head.terms_id
from ap_terms
where name=rec_head.terms_name;
exception
when no_data_found then
v_process_flag:='E';
v_error_message:='INVALID TERMS NAME =>'||rec_head.terms_name;
v_tot_err_msg:=v_tot_err_msg||' '||v_error_message;
ee_ap_comm_err_procedure(p_interface_name => v_conc_program,
p_table_name => v_head_tab,
p_column_name => 'TERMS_NAME',
p_error_message => v_error_message
);
when others then
v_process_flag:='E';
v_line.invoice_id
:= v_head.invoice_id;
v_line.line_number
:= rec_line.line_number;
--v_line.line_type_lookup_code
:= rec_line.line_type_lookup_code;
v_line.amount
:= rec_line.amount;
v_line.dist_code_concatenated
:= rec_line.dist_code_concatenated;
v_line.created_by
:= g_user_id;
v_line.creation_date
:= g_date;
v_line.last_updated_by
:= g_user_id;
v_line.last_update_date
:= g_date;
v_line.org_id
:= v_head.org_id;
dis_log('PROCESS_FLAG =>'||v_process_flag);
if v_process_flag = 'S' then
insert into ap_invoice_lines_interface values v_line;
end if;
end loop;
dis_log('PROCESS_FLAG =>'||v_process_flag);
if v_process_flag = 'S' then
insert into ap_invoices_interface values v_head;
end if;
update ap_inv_head set process_flag=v_process_flag,
error_message=v_tot_err_msg
where invoice_num=rec_head.invoice_num;
exception
when v_inv_num_exists then
v_process_flag:='E';
dis_log('PROCESS_FLAG =>'||v_process_flag);
v_error_message:='INVOICE NUM ALREADY EXISTS =>'||rec_head.invoice_num;
v_tot_err_msg:=v_tot_err_msg||' '||v_error_message;
ee_ap_comm_err_procedure(p_interface_name => v_conc_program,
p_table_name => v_head_tab,
p_column_name => 'INVOICE NUM',
p_error_message => v_error_message
);
update ap_inv_head set process_flag=v_process_flag,
error_message=v_tot_err_msg
where invoice_num=rec_head.invoice_num;
end;
end loop;
ap_record_details; --for records information
arch_proc ;
--for arch tables information
exception
when others then
dis_log('EXCEPTION AT PACKAGE =>'||sqlerrm);
end main;
end ee_ap_inv_pkg;