Beruflich Dokumente
Kultur Dokumente
Version 1.0
How to Create Custom Invoice Charges Matching Validations for LCM
Disclaimer
The following is intended to outline our general product direction. It is intended for information purposes
only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code,
or functionality, and should not be relied upon in making purchasing decisions. The development, release,
and timing of any features or functionality described for Oracle’s products remains at the sole discretion
of Oracle.
How to Create Custom Invoice Charges Matching Validations for LCM
Introduction
The goal of this document is to guide technical users on how to create Custom Invoice Charges
Matching Validations for LCM.
LCM provides public APIs that are called during AP invoice matching to receipt and also during
invoice validations. Customers are expected to write their own logic within those public APIs, if they
need to validate the matches of Freight/Miscellaneous invoices to receipt lines, under LCM
perspective.
The following are supported by those APIs:
Validate a match to an individual receipt line, under LCM perspective, and decide it the match
should be allowed or not, depending on the validation results
Validate the whole invoice, under LCM perspective, and decide if the if the invoice should be put on
hold or not, depending on the validation results
Technical Information
Public APIs List
Customers can use the following public APIs to write their LCM-oriented validation logic:
1. INL_CUSTOM_PUB.Validate_APMatching:
This API receives the transaction id of the receipt line being matched, along with other input
parameters useful for validation, like cost factor and supplier. Based on those received parameters,
customers can write their own logic to derive other pieces of information, validate the receipt line
under LCM point of view, and then return output parameters that will determine whether the match
will be accepted or not, along with messages explaining the reasons.
2. INL_CUSTOM_PUB.Validate_APInvoice:
This API receives the id of the invoice being validated, along with other input parameters useful for
validation, like invoice date, currency conversion and supplier. Based on those received parameters,
customers can write their own logic to derive other pieces of information, validate the invoice under
LCM point of view, and then return output parameters that will determine whether the invoice will
be put on hold or not.
APIs Signatures
This section provides the signatures of the public APIs described in the section above.
2
How to Create Custom Invoice Charges Matching Validations for LCM
PROCEDURE Validate_APMatching (
p_calling_mode IN VARCHAR2,
p_rcv_transaction_id IN NUMBER,
p_cost_factor_id IN NUMBER,
p_vendor_id IN NUMBER,
p_vendor_site_id IN NUMBER,
x_msg_names OUT NOCOPY INL_MATCH_GRP.inl_msg_names_tbl_tp,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
);
PROCEDURE Validate_APInvoice (
p_invoice_id IN NUMBER,
p_invoice_num IN VARCHAR2,
p_invoice_date IN DATE,
p_curr_conv_rate IN NUMBER,
p_vendor_id IN NUMBER,
p_calling_sequence IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
);
3
How to Create Custom Invoice Charges Matching Validations for LCM
Please notice that ‘MMMMMMMMMM’ refers to the message name, configured as recommended
on Message Setup section above.
For more details on Application Messages, please review the Message Dictionary APIs for PL/SQL
Procedures chapter of the Oracle Applications Developer’s Guide.
Please see the Sample Code section below, with respect to examples on how to call these APIs.
In case on any unexpected error in the custom code (like a division by zero, for example),
x_return_status will be returned as “U”, which means “Unexpected Error”. Oracle error message
will be automatically returned and the Match checkbox will be automatically unchecked, for those
cases.
Messages Setup
Any message to be issued to the user through the Matching Validation feature below must be
previously configured, through the following steps:
Login to Application Developer responsibility
Navigate to Application -> Messages
Enter the message, by informing the fields Name, Language, Application and Current Message Text
4
How to Create Custom Invoice Charges Matching Validations for LCM
For Application field, please inform “INL” (Landed Cost Management product short name)
Save the entered message, by clicking on the Save icon or clicking on File -> Save
5
How to Create Custom Invoice Charges Matching Validations for LCM
Below are the messages used in the sample code we are providing for Matching Validation.
6
How to Create Custom Invoice Charges Matching Validations for LCM
7
How to Create Custom Invoice Charges Matching Validations for LCM
Sample Code
Example 1: Validate whether estimated amounts exist when matching other charges to LCM-
enabled receipt lines
8
How to Create Custom Invoice Charges Matching Validations for LCM
BEGIN
IF l_estimated_allocated_amt = 0 THEN
END IF;
9
How to Create Custom Invoice Charges Matching Validations for LCM
END Validate_APMatching;
10
How to Create Custom Invoice Charges Matching Validations for LCM
PROCEDURE Validate_APMatching (
p_calling_mode IN VARCHAR2,
p_rcv_transaction_id IN NUMBER,
p_cost_factor_id IN NUMBER,
p_vendor_id IN NUMBER,
p_vendor_site_id IN NUMBER,
x_msg_names OUT NOCOPY INL_MATCH_GRP.inl_msg_names_tbl_tp,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
) IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APMatching';
l_return_status VARCHAR2(1);
BEGIN
11
How to Create Custom Invoice Charges Matching Validations for LCM
IF NVL(l_closed_for_matching_flag,'N')='Y' THEN
END IF;
END Validate_APMatching;
12
How to Create Custom Invoice Charges Matching Validations for LCM
PROCEDURE Validate_APMatching (
p_calling_mode IN VARCHAR2,
p_rcv_transaction_id IN NUMBER,
p_cost_factor_id IN NUMBER,
p_vendor_id IN NUMBER,
p_vendor_site_id IN NUMBER,
x_msg_names OUT NOCOPY INL_MATCH_GRP.inl_msg_names_tbl_tp,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2
) IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APMatching';
l_return_status VARCHAR2(1);
BEGIN
13
How to Create Custom Invoice Charges Matching Validations for LCM
rcv_invoice_matching_sv.get_quantities
(top_transaction_id => p_rcv_transaction_id,
ordered_po_qty => l_dummy,
cancelled_po_qty => l_dummy,
received_po_qty => l_dummy,
corrected_po_qty => l_dummy,
delivered_po_qty => l_dummy,
rtv_po_qty => l_dummy,
billed_po_qty => l_dummy,
accepted_po_qty => l_dummy,
rejected_po_qty => l_dummy,
ordered_txn_qty => l_dummy,
cancelled_txn_qty => l_dummy,
received_txn_qty => l_received_txn_qty,
corrected_txn_qty => l_corrected_txn_qty,
delivered_txn_qty => l_dummy,
rtv_txn_qty => l_rtv_txn_qty,
billed_txn_qty => l_dummy,
accepted_txn_qty => l_dummy,
rejected_txn_qty => l_dummy);
IF (NVL(l_received_txn_qty,0) + NVL(l_corrected_txn_qty,0) -
NVL(l_rtv_txn_qty,0))<0.00001
THEN
FND_MESSAGE.SET_NAME ('INL', 'CUST_INL_MTCH_SL_RETURNED') ;
FND_MESSAGE.SET_TOKEN ('ORG_CODE', l_organization_code) ;
FND_MESSAGE.SET_TOKEN ('SHIP_NUM', l_ship_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_GROUP', l_ship_line_group_num) ;
FND_MESSAGE.SET_TOKEN ('SHIP_LINE', l_ship_line_num) ;
FND_MSG_PUB.ADD;
x_msg_names(NVL(x_msg_names.COUNT,0)+1):='CUST_INL_MTCH_SL_RETURNED';
END Validate_APMatching;
14
How to Create Custom Invoice Charges Matching Validations for LCM
Holds Setup
Any holds to be raised through the Invoice Validation feature below must be previously configured,
through the following steps:
Login to Oracle Payables responsibility
Navigate to Invoices -> Setup -> Invoice -> Hold and Release Names
Enter the hold, by informing the fields Name, Description, Type, Accounting Allowed and Manual
Release Allowed.
Save the entered hold, by clicking on the Save icon or clicking on File -> Save
15
How to Create Custom Invoice Charges Matching Validations for LCM
Below are the holds used in the sample code we are providing for Invoice Validation.
16
How to Create Custom Invoice Charges Matching Validations for LCM
Hold used in Example 5: LCM Shipment Line is “Closed for Matching” (CUST_INL_MTCH_SL_CLOSED)
For more details on Holds, please review the Holds chapter of the Oracle Payables User’s Guide.
17
How to Create Custom Invoice Charges Matching Validations for LCM
Sample Code
Example 4: Check for charge price tolerance between actual amounts and estimated amounts
(Hold)
Database package INL_CUSTOM_PUB (INLPCUSB.pls file)
PROCEDURE Validate_APInvoice (
p_invoice_id IN NUMBER,
p_invoice_num IN VARCHAR2,
p_invoice_date IN DATE,
p_curr_conv_rate IN NUMBER,
p_vendor_id IN NUMBER,
p_calling_sequence IN VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2,
x_msg_count OUT NOCOPY NUMBER,
x_msg_data OUT NOCOPY VARCHAR2)
IS
l_program_name CONSTANT VARCHAR2(30) := 'Validate_APInvoice';
l_return_status VARCHAR2(1);
CURSOR c_inv_lines
IS
SELECT
rt.transaction_id rcv_transaction_id,
rt.po_line_location_id,
l.cost_factor_id,
sh.adjustment_num,
sh.ship_header_id,
NVL(sl.parent_ship_line_id, sl.ship_line_id) parent_ship_line_id,
NVL(SUM(d.amount),0) amount,
NVL(SUM(lc.estimated_allocated_amt),0) estimated_allocated_amt
FROM
rcv_transactions rt,
ap_invoice_distributions_all d,
ap_invoice_lines_all l,
inl_det_landed_costs_v lc,
inl_ship_lines_all sl,
inl_ship_headers_all sh
WHERE d.invoice_id = p_invoice_id
AND d.invoice_id = l.invoice_id
AND d.invoice_line_number = l.line_number
AND l.line_type_lookup_code IN ('MISCELLANEOUS', 'FREIGHT', 'ITEM')
AND rt.lcm_shipment_line_id IS NOT NULL
AND rt.transaction_id = NVL(l.rcv_transaction_id,d.rcv_transaction_id)
AND sl.ship_line_id = rt.lcm_shipment_line_id
AND charge_line_type_id = l.cost_factor_id
AND sl.ship_header_id = sh.ship_header_id
AND NVL(lc.parent_ship_line_id, lc.ship_line_id) = NVL(sl.parent_ship_line_id,
sl.ship_line_id)
AND lc.adjustment_num = sh.adjustment_num
GROUP BY
rt.transaction_id,
rt.po_line_location_id,
l.cost_factor_id,
sl.closed_for_matching_flag,
sh.adjustment_num,
NVL(sl.parent_ship_line_id, sl.ship_line_id),
sh.ship_header_id;
18
How to Create Custom Invoice Charges Matching Validations for LCM
l_inv_lines_list inv_lines_type;
l_holds ap_approval_pkg.holdsarray;
l_holds_count ap_approval_pkg.countarray;
l_release_count ap_approval_pkg.countarray;
l_holds_count_num NUMBER;
l_hold_release_lookup_code VARCHAR2 (25) := 'INVOICE QUICK RELEASED';
l_approval_status_lookup_code VARCHAR2 (25);
l_charge_price_tolerance_error VARCHAR2 (1);
l_actual_allocated_amt NUMBER;
l_matched_amt NUMBER;
l_lcm_lines NUMBER;
-- Sample code END
BEGIN
-- Check for charge price tolerance between actual amounts and estimated
amounts (Hold)
IF
l_inv_lines_list(i).estimated_allocated_amt*(1+l_charge_price_tolerance/100) >
l_inv_lines_list(i).amount
THEN
SELECT
NVL(SUM(alloc.allocation_amt),0)
INTO
l_actual_allocated_amt
FROM
inl_allocations alloc,
inl_ship_lines_all sl,
inl_ship_headers_all sh,
inl_charge_lines cl
WHERE alloc.ship_header_id = l_inv_lines_list(i).ship_header_id
AND alloc.ship_header_id = sh.ship_header_id
AND sl.ship_line_id = alloc.ship_line_id
AND NVL(sl.parent_ship_line_id, sl.ship_line_id) =
l_inv_lines_list(i).parent_ship_line_id
AND alloc.from_parent_table_name = 'INL_CHARGE_LINES'
AND alloc.from_parent_table_id = cl.charge_line_id
AND cl.charge_line_type_id = l_inv_lines_list(i).cost_factor_id
AND cl.adjustment_num > 0
AND alloc.adjustment_num = sh.adjustment_num;
IF
l_inv_lines_list(i).estimated_allocated_amt*(1+l_charge_price_tolerance/100) >
(l_inv_lines_list(i).amount + l_actual_allocated_amt)
THEN
SELECT NVL (SUM (NVL (mi.matched_amt, 0)), 0)
INTO l_matched_amt
FROM inl_matches_int mi
WHERE mi.to_parent_table_name = 'RCV_TRANSACTIONS'
AND mi.to_parent_table_id = l_inv_lines_list(i).rcv_transaction_id
AND mi.match_type_code = 'CHARGE'
AND mi.charge_line_type_id = l_inv_lines_list(i).cost_factor_id
19
How to Create Custom Invoice Charges Matching Validations for LCM
END LOOP;
END IF;
-- Sample code END
END Validate_APInvoice;
20
How to Create Custom Invoice Charges Matching Validations for LCM
CURSOR c_inv_lines
IS
SELECT distinct
rt.transaction_id rcv_transaction_id,
rt.po_line_location_id,
sl.closed_for_matching_flag
FROM
rcv_transactions rt,
ap_invoice_distributions_all d,
ap_invoice_lines_all l,
inl_det_landed_costs_v lc,
inl_ship_lines_all sl,
inl_ship_headers_all sh
WHERE d.invoice_id = p_invoice_id
AND d.invoice_id = l.invoice_id
AND d.invoice_line_number = l.line_number
AND l.line_type_lookup_code IN ('MISCELLANEOUS', 'FREIGHT', 'ITEM')
AND rt.lcm_shipment_line_id IS NOT NULL
AND rt.transaction_id = NVL(l.rcv_transaction_id,d.rcv_transaction_id)
AND sl.ship_line_id = rt.lcm_shipment_line_id
AND charge_line_type_id = l.cost_factor_id
AND sl.ship_header_id = sh.ship_header_id
AND NVL(lc.parent_ship_line_id, lc.ship_line_id) = NVL(sl.parent_ship_line_id,
sl.ship_line_id)
AND lc.adjustment_num = sh.adjustment_num;
l_inv_lines_list inv_lines_type;
l_holds ap_approval_pkg.holdsarray;
l_holds_count ap_approval_pkg.countarray;
l_release_count ap_approval_pkg.countarray;
l_holds_count_num NUMBER;
l_hold_release_lookup_code VARCHAR2 (25) := 'INVOICE QUICK RELEASED';
l_approval_status_lookup_code VARCHAR2 (25);
l_charge_price_tolerance_error VARCHAR2 (1);
l_actual_allocated_amt NUMBER;
l_matched_amt NUMBER;
l_lcm_lines NUMBER;
-- Sample code END
BEGIN
21
How to Create Custom Invoice Charges Matching Validations for LCM
END LOOP;
END IF;
-- Sample code END
END Validate_APInvoice;
22
White Paper Title Copyright © 2013, Oracle and/or its affiliates. All rights reserved.
[Month] 2013
Author: [OPTIONAL] This document is provided for information purposes only, and the contents hereof are subject to change without notice. This
Contributing Authors: [OPTIONAL] document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in
law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any
Oracle Corporation
liability with respect to this document, and no contractual obligations are formed either directly or indirectly by this document. This
World Headquarters
document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our
500 Oracle Parkway
prior written permission.
Redwood Shores, CA 94065
U.S.A.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Worldwide Inquiries:
Phone: +1.650.506.7000 Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and
Fax: +1.650.506.7200 are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are
trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 0113
oracle.com