标签:des io ar os sp for on art log
PROCEDURE process_cux_to_ap(x_return_status OUT NOCOPY VARCHAR2, x_msg_count OUT NOCOPY NUMBER, x_msg_data OUT NOCOPY VARCHAR2) IS l_api_name CONSTANT VARCHAR2(30) := 'PROCESS_CUX_TO_AP'; x_party_id NUMBER; x_profile_id NUMBER; l_order_number VARCHAR2(240); CURSOR cur_ch IS SELECT ch.header_id, ch.org_id, ch.invoice_type, ch.prepayment_type_code, ch.vendor_id, ch.vendor_site_id, ch.invoice_date, ch.gl_date, ch.invoice_number, ch.currency_code, ch.invoice_amount, ch.exchange_rate, ch.exchange_rate_type, ch.exchange_date, ch.payment_currency_code, ch.payment_rate_type, ch.payment_rate, ch.payment_rate_date, ch.payment_method_lookup_code, ch.pay_schedule_date, ch.terms_id, ch.pay_group_lookup_code, ch.exp_report_id, ch.apply_employee_name, ch.invoice_id, ch.description, ch.source_code, ch.source_line_id, ch.source_reference, ch.process_group_id, ch.process_status, ch.process_date, ch.process_message, ch.object_version_number, ch.creation_date, ch.created_by, ch.last_updated_by, ch.last_update_date, ch.last_update_login, ch.attribute_category, ch.attribute1, ch.attribute2, ch.attribute3, ch.attribute4, ch.attribute5, ch.attribute6, ch.attribute7, ch.attribute8, ch.attribute9, ch.attribute10, ch.attribute11, ch.attribute12, ch.attribute13, ch.attribute14, ch.attribute15 FROM cux_oa_ap_invoice_header ch WHERE (ch.process_status = 'PENDING' OR ch.process_status = 'ERROR') FOR UPDATE NOWAIT; CURSOR cur_cl(p_header_id IN NUMBER) IS SELECT cl.line_id, cl.header_id, cl.line_num, cl.line_type_lookup_code, cl.amount, cl.accounting_date, cl.inventory_item_id, cl.line_description, cl.tax_code, cl.tax_code_id, cl.amount_includes_tax_flag, cl.dist_code_combination_id, cl.exp_item_id, cl.item_id, cl.invoice_id, cl.invoice_line_number, cl.source_code, cl.source_line_id, cl.source_reference, cl.process_group_id, cl.process_status, cl.process_date, cl.process_message, cl.object_version_number, cl.creation_date, cl.created_by, cl.last_updated_by, cl.last_update_date, cl.last_update_login, cl.attribute_category, cl.attribute1, cl.attribute2, cl.attribute3, cl.attribute4, cl.attribute5, cl.attribute6, cl.attribute7, cl.attribute8, cl.attribute9, cl.attribute10, cl.attribute11, cl.attribute12, cl.attribute13, cl.attribute14, cl.attribute15 FROM cux_oa_ap_invoice_line cl WHERE cl.header_id = p_header_id AND (cl.process_status = 'PENDING' OR cl.process_status = 'ERROR') ORDER BY cl.line_num FOR UPDATE NOWAIT; l_rec_invoice_ifc ap_invoices_interface%ROWTYPE; l_rec_invoice_line_ifc ap_invoice_lines_interface%ROWTYPE; l_project_num VARCHAR2(100); l_return_status VARCHAR2(1); l_msg_data VARCHAR2(240); l_msg_count NUMBER; l_group_id NUMBER := cux_doc_sequence_utl.next_seq_number(p_doc_type => 'CUX_OA_AP_IMP', p_init_number => 1); l_line_number NUMBER; l_batch_error_flag VARCHAR2(30); l_invoices_fetched NUMBER; l_invoices_created NUMBER; l_total_invoice_amount NUMBER; l_print_batch VARCHAR2(30); l_ret_bool BOOLEAN; l_ret_status VARCHAR2(1); l_invoice_batch VARCHAR2(30); v_invoice_id NUMBER; BEGIN x_return_status := cux_api.start_activity(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_init_msg_list => fnd_api.g_true); raise_exception(x_return_status); -- INIT BEGIN mo_global.init('SQLAP'); fnd_global.apps_initialize(user_id => 1370, resp_id => 50717, resp_appl_id => 20005); END; FOR rec_ch IN cur_ch LOOP l_line_number := 0; l_rec_invoice_ifc.invoice_id := ap_invoices_interface_s.nextval; l_rec_invoice_ifc.invoice_num := rec_ch.invoice_number; l_rec_invoice_ifc.invoice_type_lookup_code := rec_ch.invoice_type; -- test REDO l_rec_invoice_ifc.invoice_date := rec_ch.invoice_date; l_rec_invoice_ifc.po_number := NULL; l_rec_invoice_ifc.vendor_id := rec_ch.vendor_id; l_rec_invoice_ifc.vendor_num := NULL; l_rec_invoice_ifc.vendor_name := NULL; l_rec_invoice_ifc.vendor_site_id := rec_ch.vendor_site_id; l_rec_invoice_ifc.vendor_site_code := NULL; l_rec_invoice_ifc.invoice_amount := rec_ch.invoice_amount; l_rec_invoice_ifc.invoice_currency_code := rec_ch.currency_code; l_rec_invoice_ifc.exchange_rate := NULL; l_rec_invoice_ifc.exchange_rate_type := NULL; l_rec_invoice_ifc.exchange_date := NULL; l_rec_invoice_ifc.terms_id := NULL; l_rec_invoice_ifc.terms_name := NULL; l_rec_invoice_ifc.description := rec_ch.description; l_rec_invoice_ifc.awt_group_id := NULL; l_rec_invoice_ifc.awt_group_name := NULL; l_rec_invoice_ifc.last_update_date := SYSDATE; l_rec_invoice_ifc.last_updated_by := g_user_id; l_rec_invoice_ifc.last_update_login := g_login_id; l_rec_invoice_ifc.creation_date := SYSDATE; l_rec_invoice_ifc.created_by := g_user_id; l_rec_invoice_ifc.attribute_category := NULL; l_rec_invoice_ifc.attribute1 := 'OA'; l_rec_invoice_ifc.attribute2 := rec_ch.source_line_id; l_rec_invoice_ifc.attribute3 := NULL; l_rec_invoice_ifc.attribute4 := NULL; l_rec_invoice_ifc.attribute5 := NULL; l_rec_invoice_ifc.attribute6 := NULL; l_rec_invoice_ifc.attribute7 := NULL; l_rec_invoice_ifc.attribute8 := NULL; l_rec_invoice_ifc.attribute9 := NULL; l_rec_invoice_ifc.attribute10 := NULL; l_rec_invoice_ifc.attribute11 := NULL; l_rec_invoice_ifc.attribute12 := NULL; l_rec_invoice_ifc.attribute13 := NULL; l_rec_invoice_ifc.attribute14 := NULL; l_rec_invoice_ifc.attribute15 := NULL; l_rec_invoice_ifc.global_attribute_category := NULL; l_rec_invoice_ifc.global_attribute1 := NULL; l_rec_invoice_ifc.global_attribute2 := NULL; l_rec_invoice_ifc.global_attribute3 := NULL; l_rec_invoice_ifc.global_attribute4 := NULL; l_rec_invoice_ifc.global_attribute5 := NULL; l_rec_invoice_ifc.global_attribute6 := NULL; l_rec_invoice_ifc.global_attribute7 := NULL; l_rec_invoice_ifc.global_attribute8 := NULL; l_rec_invoice_ifc.global_attribute9 := NULL; l_rec_invoice_ifc.global_attribute10 := NULL; l_rec_invoice_ifc.global_attribute11 := NULL; l_rec_invoice_ifc.global_attribute12 := NULL; l_rec_invoice_ifc.global_attribute13 := NULL; l_rec_invoice_ifc.global_attribute14 := NULL; l_rec_invoice_ifc.global_attribute15 := NULL; l_rec_invoice_ifc.global_attribute16 := NULL; l_rec_invoice_ifc.global_attribute17 := NULL; l_rec_invoice_ifc.global_attribute18 := NULL; l_rec_invoice_ifc.global_attribute19 := NULL; l_rec_invoice_ifc.global_attribute20 := NULL; l_rec_invoice_ifc.status := NULL; l_rec_invoice_ifc.source := 'OA_IMPORT'; l_rec_invoice_ifc.group_id := 'OA_IMPORT' || l_group_id; l_rec_invoice_ifc.request_id := NULL; l_rec_invoice_ifc.payment_cross_rate_type := NULL; l_rec_invoice_ifc.payment_cross_rate_date := NULL; l_rec_invoice_ifc.payment_cross_rate := NULL; l_rec_invoice_ifc.payment_currency_code := NULL; l_rec_invoice_ifc.workflow_flag := NULL; l_rec_invoice_ifc.doc_category_code := NULL; l_rec_invoice_ifc.voucher_num := NULL; l_rec_invoice_ifc.payment_method_lookup_code := NULL; l_rec_invoice_ifc.pay_group_lookup_code := NULL; l_rec_invoice_ifc.goods_received_date := NULL; l_rec_invoice_ifc.invoice_received_date := NULL; l_rec_invoice_ifc.gl_date := rec_ch.gl_date; l_rec_invoice_ifc.accts_pay_code_combination_id := NULL; l_rec_invoice_ifc.ussgl_transaction_code := NULL; l_rec_invoice_ifc.exclusive_payment_flag := NULL; l_rec_invoice_ifc.org_id := rec_ch.org_id; l_rec_invoice_ifc.amount_applicable_to_discount := NULL; l_rec_invoice_ifc.prepay_num := NULL; l_rec_invoice_ifc.prepay_dist_num := NULL; l_rec_invoice_ifc.prepay_apply_amount := NULL; l_rec_invoice_ifc.prepay_gl_date := NULL; l_rec_invoice_ifc.invoice_includes_prepay_flag := NULL; l_rec_invoice_ifc.no_xrate_base_amount := NULL; l_rec_invoice_ifc.vendor_email_address := NULL; l_rec_invoice_ifc.terms_date := NULL; l_rec_invoice_ifc.requester_id := NULL; l_rec_invoice_ifc.ship_to_location := NULL; l_rec_invoice_ifc.external_doc_ref := NULL; l_rec_invoice_ifc.prepay_line_num := NULL; l_rec_invoice_ifc.requester_first_name := NULL; l_rec_invoice_ifc.requester_last_name := NULL; l_rec_invoice_ifc.application_id := NULL; l_rec_invoice_ifc.product_table := NULL; l_rec_invoice_ifc.reference_key1 := NULL; l_rec_invoice_ifc.reference_key2 := NULL; l_rec_invoice_ifc.reference_key3 := NULL; l_rec_invoice_ifc.reference_key4 := NULL; l_rec_invoice_ifc.reference_key5 := NULL; l_rec_invoice_ifc.apply_advances_flag := NULL; l_rec_invoice_ifc.calc_tax_during_import_flag := NULL; l_rec_invoice_ifc.control_amount := NULL; l_rec_invoice_ifc.add_tax_to_inv_amt_flag := NULL; l_rec_invoice_ifc.tax_related_invoice_id := NULL; l_rec_invoice_ifc.taxation_country := NULL; l_rec_invoice_ifc.document_sub_type := NULL; l_rec_invoice_ifc.supplier_tax_invoice_number := NULL; l_rec_invoice_ifc.supplier_tax_invoice_date := NULL; l_rec_invoice_ifc.supplier_tax_exchange_rate := NULL; l_rec_invoice_ifc.tax_invoice_recording_date := NULL; l_rec_invoice_ifc.tax_invoice_internal_seq := NULL; l_rec_invoice_ifc.legal_entity_id := NULL; l_rec_invoice_ifc.legal_entity_name := NULL; l_rec_invoice_ifc.reference_1 := NULL; l_rec_invoice_ifc.reference_2 := NULL; l_rec_invoice_ifc.operating_unit := NULL; l_rec_invoice_ifc.bank_charge_bearer := NULL; l_rec_invoice_ifc.remittance_message1 := NULL; l_rec_invoice_ifc.remittance_message2 := NULL; l_rec_invoice_ifc.remittance_message3 := NULL; l_rec_invoice_ifc.unique_remittance_identifier := NULL; l_rec_invoice_ifc.uri_check_digit := NULL; l_rec_invoice_ifc.settlement_priority := NULL; l_rec_invoice_ifc.payment_reason_code := NULL; l_rec_invoice_ifc.payment_reason_comments := NULL; l_rec_invoice_ifc.payment_method_code := NULL; l_rec_invoice_ifc.delivery_channel_code := NULL; l_rec_invoice_ifc.paid_on_behalf_employee_id := NULL; l_rec_invoice_ifc.net_of_retainage_flag := NULL; l_rec_invoice_ifc.requester_employee_num := NULL; l_rec_invoice_ifc.cust_registration_code := NULL; l_rec_invoice_ifc.cust_registration_number := NULL; l_rec_invoice_ifc.party_id := NULL; l_rec_invoice_ifc.party_site_id := NULL; l_rec_invoice_ifc.pay_proc_trxn_type_code := NULL; l_rec_invoice_ifc.payment_function := NULL; l_rec_invoice_ifc.payment_priority := NULL; l_rec_invoice_ifc.port_of_entry_code := NULL; l_rec_invoice_ifc.external_bank_account_id := NULL; l_rec_invoice_ifc.accts_pay_code_concatenated := NULL; l_rec_invoice_ifc.pay_awt_group_id := NULL; l_rec_invoice_ifc.pay_awt_group_name := NULL; l_rec_invoice_ifc.original_invoice_amount := NULL; l_rec_invoice_ifc.dispute_reason := NULL; l_rec_invoice_ifc.remit_to_supplier_name := NULL; l_rec_invoice_ifc.remit_to_supplier_id := NULL; l_rec_invoice_ifc.remit_to_supplier_site := NULL; l_rec_invoice_ifc.remit_to_supplier_site_id := NULL; l_rec_invoice_ifc.relationship_id := NULL; l_rec_invoice_ifc.remit_to_supplier_num := NULL; INSERT INTO ap_invoices_interface VALUES l_rec_invoice_ifc; FOR rec_cl IN cur_cl(p_header_id => rec_ch.header_id) LOOP l_line_number := l_line_number + 1; l_rec_invoice_line_ifc.invoice_id := ap_invoices_interface_s.currval; l_rec_invoice_line_ifc.invoice_line_id := ap_invoice_lines_interface_s.nextval; l_rec_invoice_line_ifc.line_number := l_line_number; l_rec_invoice_line_ifc.line_type_lookup_code := rec_cl.line_type_lookup_code; l_rec_invoice_line_ifc.line_group_number := NULL; l_rec_invoice_line_ifc.amount := rec_cl.amount; l_rec_invoice_line_ifc.accounting_date := rec_cl.accounting_date; l_rec_invoice_line_ifc.description := rec_cl.line_description; l_rec_invoice_line_ifc.amount_includes_tax_flag := NULL; l_rec_invoice_line_ifc.prorate_across_flag := NULL; l_rec_invoice_line_ifc.tax_code := NULL; l_rec_invoice_line_ifc.final_match_flag := NULL; l_rec_invoice_line_ifc.po_header_id := NULL; l_rec_invoice_line_ifc.po_number := NULL; l_rec_invoice_line_ifc.po_line_id := NULL; l_rec_invoice_line_ifc.po_line_number := NULL; l_rec_invoice_line_ifc.po_line_location_id := NULL; l_rec_invoice_line_ifc.po_shipment_num := NULL; l_rec_invoice_line_ifc.po_distribution_id := NULL; l_rec_invoice_line_ifc.po_distribution_num := NULL; l_rec_invoice_line_ifc.po_unit_of_measure := NULL; l_rec_invoice_line_ifc.inventory_item_id := NULL; l_rec_invoice_line_ifc.item_description := NULL; l_rec_invoice_line_ifc.quantity_invoiced := NULL; l_rec_invoice_line_ifc.ship_to_location_code := NULL; l_rec_invoice_line_ifc.unit_price := NULL; l_rec_invoice_line_ifc.distribution_set_id := NULL; l_rec_invoice_line_ifc.distribution_set_name := NULL; l_rec_invoice_line_ifc.dist_code_concatenated := NULL; l_rec_invoice_line_ifc.dist_code_combination_id := rec_cl.dist_code_combination_id; l_rec_invoice_line_ifc.awt_group_id := NULL; l_rec_invoice_line_ifc.awt_group_name := NULL; l_rec_invoice_line_ifc.last_updated_by := g_user_id; l_rec_invoice_line_ifc.last_update_date := SYSDATE; l_rec_invoice_line_ifc.last_update_login := g_login_id; l_rec_invoice_line_ifc.created_by := g_user_id; l_rec_invoice_line_ifc.creation_date := SYSDATE; l_rec_invoice_line_ifc.attribute_category := NULL; l_rec_invoice_line_ifc.attribute1 := NULL; l_rec_invoice_line_ifc.attribute2 := NULL; l_rec_invoice_line_ifc.attribute3 := NULL; l_rec_invoice_line_ifc.attribute4 := NULL; l_rec_invoice_line_ifc.attribute5 := NULL; l_rec_invoice_line_ifc.attribute6 := NULL; l_rec_invoice_line_ifc.attribute7 := NULL; l_rec_invoice_line_ifc.attribute8 := NULL; l_rec_invoice_line_ifc.attribute9 := NULL; l_rec_invoice_line_ifc.attribute10 := NULL; l_rec_invoice_line_ifc.attribute11 := NULL; l_rec_invoice_line_ifc.attribute12 := NULL; l_rec_invoice_line_ifc.attribute13 := NULL; l_rec_invoice_line_ifc.attribute14 := NULL; l_rec_invoice_line_ifc.attribute15 := NULL; l_rec_invoice_line_ifc.global_attribute_category := NULL; l_rec_invoice_line_ifc.global_attribute1 := NULL; l_rec_invoice_line_ifc.global_attribute2 := NULL; l_rec_invoice_line_ifc.global_attribute3 := NULL; l_rec_invoice_line_ifc.global_attribute4 := NULL; l_rec_invoice_line_ifc.global_attribute5 := NULL; l_rec_invoice_line_ifc.global_attribute6 := NULL; l_rec_invoice_line_ifc.global_attribute7 := NULL; l_rec_invoice_line_ifc.global_attribute8 := NULL; l_rec_invoice_line_ifc.global_attribute9 := NULL; l_rec_invoice_line_ifc.global_attribute10 := NULL; l_rec_invoice_line_ifc.global_attribute11 := NULL; l_rec_invoice_line_ifc.global_attribute12 := NULL; l_rec_invoice_line_ifc.global_attribute13 := NULL; l_rec_invoice_line_ifc.global_attribute14 := NULL; l_rec_invoice_line_ifc.global_attribute15 := NULL; l_rec_invoice_line_ifc.global_attribute16 := NULL; l_rec_invoice_line_ifc.global_attribute17 := NULL; l_rec_invoice_line_ifc.global_attribute18 := NULL; l_rec_invoice_line_ifc.global_attribute19 := NULL; l_rec_invoice_line_ifc.global_attribute20 := NULL; l_rec_invoice_line_ifc.po_release_id := NULL; l_rec_invoice_line_ifc.release_num := NULL; l_rec_invoice_line_ifc.account_segment := NULL; l_rec_invoice_line_ifc.balancing_segment := NULL; l_rec_invoice_line_ifc.cost_center_segment := NULL; l_rec_invoice_line_ifc.project_id := NULL; l_rec_invoice_line_ifc.task_id := NULL; l_rec_invoice_line_ifc.expenditure_type := NULL; l_rec_invoice_line_ifc.expenditure_item_date := NULL; l_rec_invoice_line_ifc.expenditure_organization_id := NULL; l_rec_invoice_line_ifc.project_accounting_context := NULL; l_rec_invoice_line_ifc.pa_addition_flag := NULL; l_rec_invoice_line_ifc.pa_quantity := NULL; l_rec_invoice_line_ifc.ussgl_transaction_code := NULL; l_rec_invoice_line_ifc.stat_amount := NULL; l_rec_invoice_line_ifc.type_1099 := NULL; l_rec_invoice_line_ifc.income_tax_region := NULL; l_rec_invoice_line_ifc.assets_tracking_flag := NULL; l_rec_invoice_line_ifc.price_correction_flag := NULL; l_rec_invoice_line_ifc.org_id := rec_ch.org_id; l_rec_invoice_line_ifc.receipt_number := NULL; l_rec_invoice_line_ifc.receipt_line_number := NULL; l_rec_invoice_line_ifc.match_option := NULL; l_rec_invoice_line_ifc.packing_slip := NULL; l_rec_invoice_line_ifc.rcv_transaction_id := NULL; l_rec_invoice_line_ifc.pa_cc_ar_invoice_id := NULL; l_rec_invoice_line_ifc.pa_cc_ar_invoice_line_num := NULL; l_rec_invoice_line_ifc.reference_1 := NULL; l_rec_invoice_line_ifc.reference_2 := NULL; l_rec_invoice_line_ifc.pa_cc_processed_code := NULL; l_rec_invoice_line_ifc.tax_recovery_rate := NULL; l_rec_invoice_line_ifc.tax_recovery_override_flag := NULL; l_rec_invoice_line_ifc.tax_recoverable_flag := NULL; l_rec_invoice_line_ifc.tax_code_override_flag := NULL; l_rec_invoice_line_ifc.tax_code_id := NULL; l_rec_invoice_line_ifc.credit_card_trx_id := NULL; l_rec_invoice_line_ifc.award_id := NULL; l_rec_invoice_line_ifc.vendor_item_num := NULL; l_rec_invoice_line_ifc.taxable_flag := NULL; l_rec_invoice_line_ifc.price_correct_inv_num := NULL; l_rec_invoice_line_ifc.external_doc_line_ref := NULL; l_rec_invoice_line_ifc.serial_number := NULL; l_rec_invoice_line_ifc.manufacturer := NULL; l_rec_invoice_line_ifc.model_number := NULL; l_rec_invoice_line_ifc.warranty_number := NULL; l_rec_invoice_line_ifc.deferred_acctg_flag := NULL; l_rec_invoice_line_ifc.def_acctg_start_date := NULL; l_rec_invoice_line_ifc.def_acctg_end_date := NULL; l_rec_invoice_line_ifc.def_acctg_number_of_periods := NULL; l_rec_invoice_line_ifc.def_acctg_period_type := NULL; l_rec_invoice_line_ifc.unit_of_meas_lookup_code := NULL; l_rec_invoice_line_ifc.price_correct_inv_line_num := NULL; l_rec_invoice_line_ifc.asset_book_type_code := NULL; l_rec_invoice_line_ifc.asset_category_id := NULL; l_rec_invoice_line_ifc.requester_id := NULL; l_rec_invoice_line_ifc.requester_first_name := NULL; l_rec_invoice_line_ifc.requester_last_name := NULL; l_rec_invoice_line_ifc.requester_employee_num := NULL; l_rec_invoice_line_ifc.application_id := NULL; l_rec_invoice_line_ifc.product_table := NULL; l_rec_invoice_line_ifc.reference_key1 := NULL; l_rec_invoice_line_ifc.reference_key2 := NULL; l_rec_invoice_line_ifc.reference_key3 := NULL; l_rec_invoice_line_ifc.reference_key4 := NULL; l_rec_invoice_line_ifc.reference_key5 := NULL; l_rec_invoice_line_ifc.purchasing_category := NULL; l_rec_invoice_line_ifc.purchasing_category_id := NULL; l_rec_invoice_line_ifc.cost_factor_id := NULL; l_rec_invoice_line_ifc.cost_factor_name := NULL; l_rec_invoice_line_ifc.control_amount := NULL; l_rec_invoice_line_ifc.assessable_value := NULL; l_rec_invoice_line_ifc.default_dist_ccid := NULL; l_rec_invoice_line_ifc.primary_intended_use := NULL; l_rec_invoice_line_ifc.ship_to_location_id := NULL; l_rec_invoice_line_ifc.product_type := NULL; l_rec_invoice_line_ifc.product_category := NULL; l_rec_invoice_line_ifc.product_fisc_classification := NULL; l_rec_invoice_line_ifc.user_defined_fisc_class := NULL; l_rec_invoice_line_ifc.trx_business_category := NULL; l_rec_invoice_line_ifc.tax_regime_code := NULL; l_rec_invoice_line_ifc.tax := NULL; l_rec_invoice_line_ifc.tax_jurisdiction_code := NULL; l_rec_invoice_line_ifc.tax_status_code := NULL; l_rec_invoice_line_ifc.tax_rate_id := NULL; l_rec_invoice_line_ifc.tax_rate_code := NULL; l_rec_invoice_line_ifc.tax_rate := NULL; l_rec_invoice_line_ifc.incl_in_taxable_line_flag := NULL; l_rec_invoice_line_ifc.source_application_id := NULL; l_rec_invoice_line_ifc.source_entity_code := NULL; l_rec_invoice_line_ifc.source_event_class_code := NULL; l_rec_invoice_line_ifc.source_trx_id := NULL; l_rec_invoice_line_ifc.source_line_id := NULL; l_rec_invoice_line_ifc.source_trx_level_type := NULL; l_rec_invoice_line_ifc.tax_classification_code := NULL; l_rec_invoice_line_ifc.cc_reversal_flag := NULL; l_rec_invoice_line_ifc.company_prepaid_invoice_id := NULL; l_rec_invoice_line_ifc.expense_group := NULL; l_rec_invoice_line_ifc.justification := NULL; l_rec_invoice_line_ifc.merchant_document_number := NULL; l_rec_invoice_line_ifc.merchant_name := NULL; l_rec_invoice_line_ifc.merchant_reference := NULL; l_rec_invoice_line_ifc.merchant_tax_reg_number := NULL; l_rec_invoice_line_ifc.merchant_taxpayer_id := NULL; l_rec_invoice_line_ifc.receipt_currency_code := NULL; l_rec_invoice_line_ifc.receipt_conversion_rate := NULL; l_rec_invoice_line_ifc.receipt_currency_amount := NULL; l_rec_invoice_line_ifc.country_of_supply := NULL; l_rec_invoice_line_ifc.pay_awt_group_id := NULL; l_rec_invoice_line_ifc.pay_awt_group_name := NULL; l_rec_invoice_line_ifc.expense_start_date := NULL; l_rec_invoice_line_ifc.expense_end_date := NULL; INSERT INTO ap_invoice_lines_interface VALUES l_rec_invoice_line_ifc; END LOOP; --FOR REC_CL IN cur_cl (P_HEADER_ID =>REC_CH.HEADER_ID) LOOP --开始导入 BEGIN l_ret_bool := ap_import_invoices_pkg.import_invoices(p_batch_name => l_invoice_batch, p_gl_date => NULL, p_hold_code => NULL, p_hold_reason => NULL, p_commit_cycles => NULL, p_source => 'OA_IMPORT', p_group_id => 'OA_IMPORT' || l_group_id, p_conc_request_id => fnd_global.conc_request_id, p_debug_switch => 'N', p_org_id => NULL, p_batch_error_flag => l_batch_error_flag, --OUT p_invoices_fetched => l_invoices_fetched, --OUT p_invoices_created => l_invoices_created, --OUT p_total_invoice_amount => l_total_invoice_amount, --OUT for bug 989221 p_print_batch => l_print_batch, p_calling_sequence => g_pkg_name || '.' || l_api_name); --获取导入的发票ID SELECT i.invoice_id INTO v_invoice_id FROM ap_invoices_all i WHERE i.attribute1 = rec_ch.source_code AND i.attribute2 = to_char(rec_ch.source_line_id) AND i.invoice_num = rec_ch.invoice_number AND i.invoice_type_lookup_code = rec_ch.invoice_type; UPDATE cux_oa_ap_invoice_header h SET h.process_status = 'COMPLETE', h.invoice_id = v_invoice_id, h.last_updated_by = g_user_id, h.last_update_date = SYSDATE, h.last_update_login = g_login_id WHERE h.header_id = rec_ch.header_id; UPDATE oa_ap_invoices_header h SET h.ebs_process_status = 'COMPLETE' WHERE h.header_id = rec_ch.source_line_id; UPDATE cux_oa_ap_invoice_line l SET l.process_status = 'COMPLETE', l.invoice_id = v_invoice_id, l.last_updated_by = g_user_id, l.last_update_date = SYSDATE, l.last_update_login = g_login_id WHERE l.header_id = rec_ch.header_id; UPDATE oa_ap_invoices_line l SET l.ebs_process_status = 'COMPLETE' WHERE l.header_id = rec_ch.source_line_id; EXCEPTION WHEN no_data_found THEN --没有找到,导入失败 UPDATE cux_oa_ap_invoice_header h SET h.process_message = get_interface_reject(l_rec_invoice_ifc.invoice_id, l_rec_invoice_line_ifc.invoice_line_id), h.process_status = 'ERROR', h.last_updated_by = g_user_id, h.last_update_date = SYSDATE, h.last_update_login = g_login_id WHERE h.header_id = rec_ch.header_id; UPDATE oa_ap_invoices_header h SET h.ebs_process_status = 'ERROR', h.ebs_process_message = get_interface_reject(l_rec_invoice_ifc.invoice_id, l_rec_invoice_line_ifc.invoice_line_id) WHERE h.header_id = rec_ch.source_line_id; UPDATE cux_oa_ap_invoice_line l SET l.process_status = 'ERROR', l.last_updated_by = g_user_id, l.last_update_date = SYSDATE, l.last_update_login = g_login_id, l.process_message = '参考头表错误信息' WHERE l.header_id = rec_ch.header_id; UPDATE oa_ap_invoices_line l SET l.ebs_process_status = 'ERROR', l.ebs_process_message = '参考头表错误信息' WHERE l.header_id = rec_ch.source_line_id; WHEN OTHERS THEN l_msg_data := SQLERRM; UPDATE cux_oa_ap_invoice_header h SET h.process_message = l_msg_data, h.process_status = 'ERROR', h.last_updated_by = g_user_id, h.last_update_date = SYSDATE, h.last_update_login = g_login_id WHERE h.header_id = rec_ch.header_id; UPDATE oa_ap_invoices_header h SET h.ebs_process_status = 'ERROR', h.ebs_process_message = l_msg_data WHERE h.header_id = rec_ch.source_line_id; UPDATE cux_oa_ap_invoice_line l SET l.process_status = 'ERROR', l.last_updated_by = g_user_id, l.last_update_date = SYSDATE, l.last_update_login = g_login_id, l.process_message = '参考头表错误信息' WHERE l.header_id = rec_ch.header_id; UPDATE oa_ap_invoices_line l SET l.ebs_process_status = 'ERROR', l.ebs_process_message = '参考头表错误信息' WHERE l.header_id = rec_ch.source_line_id; END; ----开始导入 END LOOP; --FOR REC_CH IN cur_ch LOOP x_return_status := cux_api.end_activity(p_pkg_name => g_pkg_name, p_api_name => l_api_name, x_msg_count => x_msg_count, x_msg_data => x_msg_data); EXCEPTION WHEN fnd_api.g_exc_error THEN x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_exc_name => cux_api.g_exc_name_error, x_msg_count => x_msg_count, x_msg_data => x_msg_data); WHEN fnd_api.g_exc_unexpected_error THEN x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_exc_name => cux_api.g_exc_name_unexp, x_msg_count => x_msg_count, x_msg_data => x_msg_data); WHEN OTHERS THEN x_return_status := cux_api.handle_exceptions(p_pkg_name => g_pkg_name, p_api_name => l_api_name, p_exc_name => cux_api.g_exc_name_others, x_msg_count => x_msg_count, x_msg_data => x_msg_data); END process_cux_to_ap;
AP INVOICES IMPORT API(NOT request)
标签:des io ar os sp for on art log
原文地址:http://blog.csdn.net/cai_xingyun/article/details/40951225