Tuesday, 1 March 2016

custom plsql procedure for Receivable Invoice API


custom plsql procedure for Receivable Invoice API

CREATE OR REPLACE PROCEDURE APPS.xxx_ar_invoice_api (errbuf out varchar2, rectcode out varchar2)
AS
l_org_id hr_operating_units.organization_id%type;
l_sob_id hr_operating_units.set_of_books_id%type;
l_cust_trx_type_id ra_cust_trx_types_all.cust_trx_type_id%type;
l_gl_id_rev ra_cust_trx_types_all.gl_id_rev%type;
l_cust_trx_type_name ra_cust_trx_types_all.name%type;
l_currency_code fnd_currencies.currency_code%type;
l_term_id ra_terms_tl.term_id%type;
l_term_name ra_terms_tl.name%type;
l_address_id hz_cust_acct_sites_all.cust_acct_site_id%type;
l_customer_id hz_cust_accounts.cust_account_id%type;
l_verify_flag char(1);
l_error_message varchar2(2500);
------------------------------------
BEGIN
------------------------------------
BEGIN
SELECT organization_id, SET_OF_BOOKS_ID
INTO l_org_id, l_sob_id
FROM hr_operating_units
WHERE name = 'xxtestoperatingunit' ;    --           'xxx Operating Unit';
EXCEPTION
WHEN OTHERS THEN
l_verify_flag := 'N';
l_error_message := 'Invalide Operating Unit...';
END;
------------------------------------
BEGIN
SELECT cust_trx_type_id,name,gl_id_rev
INTO l_cust_trx_type_id,l_cust_trx_type_name, l_gl_id_rev
FROM ra_cust_trx_types_all
WHERE set_of_books_id = l_sob_id
AND org_id = l_org_id
AND name = 'xxx-Spares-Inv';
EXCEPTION
WHEN OTHERS THEN
l_verify_flag := 'N';
l_error_message := 'Invalide Invoice Type...';
END;
------------------------------------
BEGIN
select currency_code
into l_currency_code
from fnd_currencies
where currency_code = 'BHD';
EXCEPTION
WHEN OTHERS THEN
l_verify_flag := 'N';
l_error_message := 'Invalide Currency Code...';
END;
------------------------------------
BEGIN
SELECT term_id,name
into l_term_id,l_term_name
FROM ra_terms_tl
WHERE upper(name) = upper('IMMEDIATE'); --USE OWN PAYMENT TERM
EXCEPTION
WHEN OTHERS THEN
l_verify_flag := 'N';
l_error_message := 'Invalide Terms Name...';
END;
------------------------------------
BEGIN
SELECT DISTINCT HCAS.cust_acct_site_id,HCA.cust_account_id
INTO l_address_id,l_customer_id
FROM hz_parties HP
,hz_party_sites HPS
,hz_cust_accounts HCA
,hz_cust_acct_sites_all HCAS
,hz_cust_site_uses_all HCSU
WHERE HCA.party_id = HP.party_id
AND HP.party_id = HPS.party_id
AND HCA.cust_account_id = HCAS.cust_account_id
AND HCAS.cust_acct_site_id = HCSU.cust_acct_site_id
AND HCSU.site_use_code = 'BILL_TO'
AND HCSU.primary_flag = 'Y'
AND upper (ltrim (rtrim (HP.party_name))) = upper (ltrim (rtrim ('Customer Name')))
AND HCAs.org_id = l_org_id;
EXCEPTION
WHEN OTHERS THEN
l_verify_flag := 'N';
l_error_message := 'Invalide Customer Name...';
END;
------------------------------------
INSERT INTO ra_interface_lines_all(
INTERFACE_LINE_ID,
BATCH_SOURCE_NAME,
LINE_TYPE,
CUST_TRX_TYPE_ID,
cust_trx_type_name,
TRX_DATE,
GL_DATE,
CURRENCY_CODE,
term_id,
term_name,
orig_system_bill_customer_id,
ORIG_SYSTEM_BILL_CUSTOMER_REF,
orig_system_bill_address_id,
ORIG_SYSTEM_BILL_ADDRESS_REF,
--orig_system_ship_customer_id,
--orig_system_ship_address_id,
orig_system_sold_customer_id,
QUANTITY,
--unit_selling_price
AMOUNT,
DESCRIPTION,
conversion_type,
conversion_rate,
INTERFACE_LINE_CONTEXT,
INTERFACE_LINE_ATTRIBUTE1,
org_id
)
Values
(
RA_CUSTOMER_TRX_LINES_S.NEXTVAL,
'Invoice Migration',
'LINE',
l_cust_trx_type_id,
l_cust_trx_type_name,
sysdate,
sysdate,
l_currency_code,
l_term_id,
l_term_name,
l_customer_id,
l_customer_id,
l_address_id,
l_address_id,
--85222,
--87978,
l_customer_id,
1,
--40000
4000,
'Test Invoice2 12JUN08',
'User',
1,
'Invoice Migration',
'RINV_000000002',
l_org_id
);
------------------------------------
------------------------------------
INSERT INTO ra_interface_distributions_all
(
INTERFACE_LINE_ID
,account_class
,amount
,code_combination_id
,percent
,interface_line_context
,interface_line_attribute1
,org_id
)
VALUES
(
RA_CUSTOMER_TRX_LINES_S.CURRVAL,
'REV'
,4000
,l_gl_id_rev
,100
,'Invoice Migration',
'RINV_000000002',
l_org_id
);
------------------------------------
Commit;
END xxx_ar_invoice_api;
/



custom procedure to submit concurrent program from backend



CREATE OR REPLACE PROCEDURE APPS.xxsubmit_xml_cp_4m_bkend (
   v_template_appl_name    VARCHAR2,
   v_template_code         VARCHAR2,
   v_template_language     VARCHAR2,
   v_template_territory    VARCHAR2,
   v_output_format         VARCHAR2,
   v_application           VARCHAR2,
   v_program               VARCHAR2,
   v_description           VARCHAR2,
   v_start_time            VARCHAR2,
   v_sub_request           BOOLEAN := FALSE,
   v_argument1             VARCHAR2 DEFAULT CHR (0),
   v_argument2             VARCHAR2 DEFAULT CHR (0),
   v_argument3             VARCHAR2 DEFAULT CHR (0),
   v_argument4             VARCHAR2 DEFAULT CHR (0),
   v_argument5             VARCHAR2 DEFAULT CHR (0))
IS
   V_RETURN    BOOLEAN;
   V_REQUEST   NUMBER;
BEGIN
   fnd_global.apps_initialize (user_id        => 2836,
                               resp_id        => 20434,
                               resp_appl_id   => 101); --mpf santosh userid,responcibility,application detail
   V_RETURN :=
      fnd_request.add_layout (template_appl_name   => v_template_appl_name,
                              template_code        => v_template_code,
                              template_language    => v_template_language,
                              template_territory   => v_template_territory,
                              output_format        => v_output_format);
   V_REQUEST :=
      fnd_request.submit_request (application   => v_application,
                                  program       => v_program,
                                  description   => v_description,
                                  start_time    => v_start_time,
                                  sub_request   => v_sub_request,
                                  argument1     => v_argument1,
                                  argument2     => v_argument2,
                                  argument3     => v_argument3,
                                  argument4     => v_argument4,
                                  argument5     => v_argument5);
   DBMS_OUTPUT.PUT_LINE ('Request Number' || V_REQUEST);
END;

/

What Fields in Tables Ap_Invoices_Interface and Ap_Invoice_Lines_Interface Should Be Populated to Import Invoices Matched to Purchasing Order

What Fields in Tables Ap_Invoices_Interface and Ap_Invoice_Lines_Interface Should Be Populated to Import Invoices Matched to Purchasing Order  PO Doc I

 


·         goal: What fields in tables ap_invoices_interface and
·         ap_invoice_lines_interface should be populated to import invoices matched to
·         Purchasing order ( PO )?
·         fact: APXIIMPT - Payables Open Interface Import
·         fact: Oracle Payables 11.5
·         fact: Oracle Payables 11
·         fact: Oracle Payables 10.7
·         fix:

PO MATCHED INVOICES

AP_INVOICES_INTERFACE:

Required Columns
================
INVOICE_ID                (Populated from AP_INVOICES_INTERFACE_S.NEXTVAL)
INVOICE_NUM               (Must be unique to the supplier)
PO_NUMBER                 (An approved, not cancelled, not closed or final
                          closed PO. Validated against PO_HEADERS)
INVOICE_AMOUNT            (Positive Amount)
SOURCE                    (Must be in select lookup_code from ap_lookup_codes
                           where lookup_type='SOURCE')
ORG_ID                    (Required in Multi-Org Environment. Validated against
                           AP_SYSTEM_PARAMETERS_ALL.ORG_ID)

Optional Columns
================
INVOICE_DATE                  (Defaulted to SYSDATE)
INVOICE_TYPE_LOOKUP_CODE      (Defaulted to 'STANDARD')
INVOICE_CURRENCY_CODE         (Defaulted from
                               PO_VENDOR_SITES.INVOICE_CURRENCY_CODE)
EXCHANGE_RATE_TYPE            (Defaulted from
                              AP_SYSTEM_PARAMETERS.DEFAULT_EXCHANGE_RATE_TYPE)
TERMS_ID or TERMS_NAME        (Defaulted from PO_VENDOR_SITES.TERMS_ID)
DOC_CATEGORY_CODE             (Only populated if using automatic voucher number)
   
PAYMENT_METHOD_LOOKUP_CODE    (Defaulted from
                               PO_VENDOR_SITES.PAYMENT_METHOD_LOOKUP_CODE)
PAY_GROUP_LOOKUP_CODE         (Defaulted from
                               PO_VENDOR_SITES.PAY_GROUP_LOOKUP_CODE)
ACCTS_PAY_CODE_COMBINATION_ID (Defaulted from
                               PO_VENDOR_SITES.ACCTS_PAY_CODE_COMBINAITON_ID)
GROUP_ID                      (Group identifier. Suggest to use it)
STATUS                         (DO NOT POPULATE IT) 


AP_INVOICE_LINES_INTERFACE
==========================

Required Columns for PO Matched Lines
=====================================
INVOICE_ID                (Populated from AP_INVOICES_INTERFACE.INVOICE_ID)
INVOICE_LINE_ID           (Populated from AP_INVOICE_LINES_INTERFACE_S.NEXTVAL)
LINE_NUMBER               (A unqiue number to the invoice)
LINE_TYPE_LOOKUP_CODE     ('ITEM')
AMOUNT                    (Should be QUANTITY_INVOICED * UNIT_PRICE)

If MATCH_OPTION is 'P', then populate:
RELEASE_NUM or PO_RELEASE_ID (For Blanket Release only, validated against
                              PO_RELEASES_ALL)
PO_NUMBER or PO_HEADER_ID    (Validated against PO_HEADER_ALL)
PO_LINE_NUMBER or PO_LINE_ID   (Validated against PO_LINES_ALL)
PO_SHIPMENT_NUM or PO_LINE_LOCATION_ID (Validated against PO_LINE_LOCATIONS_ALL)

If MATCH_OPTION is 'R', then populate:
RECEIPT_NUMBER        (Validated against RCV_SHIPMENT_HEADERS.RECEIPT_NUM)
RCV_TRANSACTION_ID or PO_LINE_LOCATION_ID  (Validated against RCV_TRANSACTIONS)

Optional Columns for PO Matched Lines
=====================================
QUANTITY_INVOICED                (Populated if different from PO shipment)
UNIT_PRICE                       (Populated if different from PO shipment)
MATCH_OPTION                     ('P' or 'R' or Defaulted from
                                PO_VENDOR_SITES.MATCH_OPTION)
ACCOUNTING_DATE                 (Defaulted from INVOICE_DATE or SYSDATE)
FINAL_MATCH_FLAG                (Populated 'Y' if it is final matching)
INVENTORY_ITEM_ID               (Validated against PO_LINES.INVENTORY_ITEM_ID)
INVENTORY_DESCRIPTION     (Validated against PO_LINES.
INVENTORY_ITEM_DESCRIPTION)
SHIP_TO_LOCATION_CODE           Populated if different from PO shipment)
PRICE_CORRECTION_FLAG            (Populated 'Y' if it is price correction)

reference :-

What Fields in Tables Ap_Invoices_Interface and Ap_Invoice_Lines_Interface Should Be Populated to Import Invoices Matched to Purchasing Order ( PO )? (Doc ID 209814.1)