Wednesday, 4 October 2017

Error In Payables Open Interface Import : PA Flexbuild Failed

https://aporaclepayables.blogspot.com/2017/10/error-in-payables-open-interface-import.html

ERROR

(v_check_line_project_info 4) Call pa_flexbuild
(PA Flexbuild 1) Check for PA installation and Project Info
(PA Flexbuild 1) Get User Id


(PA Flexbuild 1) PA_TRANSACTIONS_PUB.VALIDATE_TRANSACTION
(PA Flexbuild 1) PA_TRANSACTIONS_PUB.VALIDATE_TRANSACTION Failed :Insert Rejecti
on
PA_PROJECT_NOT_VALID
(Insert Rejections 1) Insert into AP_INTERFACE_REJECTIONS, REJECT CODE:PA FLEXBU
ILD FAILED


SOLUTION

To implement the solution, please perform the below steps in a TEST instance:

Step 1. Validate the record in the interface table before running the import program

Step 2. Remove any records in the interface that are related to end dated/invalid Projects

Step 3. Re-run Payables Open Interface Import

Step 4. If the issue is resolved, migrate the solution to the required instance

Wednesday, 19 July 2017

How to run any concurrent request through Tools

https://aporaclepayables.blogspot.com/2017/07/how-to-run-concurrent-request-through.html

CREATE OR REPLACE PACKAGE XX_CONC_REQ_SUBMIT_PKG
IS
v_request_id fnd_concurrent_requests.request_id%type;
PROCEDURE XX_SUBMIT_INV_VOUCHER
(
p_org_id IN NUMBER,
--p_resp_name IN VARCHAR2,
p_inv_no IN VARCHAR2,
--p_invoice_date IN DATE,
p_doc_seq_value NUMBER,
p_created_by IN NUMBER
)
;
PROCEDURE XX_SUBMIT_PAYMENT_VOUCHER
(
p_org_id IN number,
p_created_by IN NUMBER,
p_vouch_no_v IN number,
p_check_no IN number

)
;
FUNCTION  XX_RET_REQUEST_ID
RETURN NUMBER;

END XX_CONC_REQ_SUBMIT_PKG;

--------------------------------------------------------------------------------------------------------------------------

CREATE OR REPLACE PACKAGE BODY XX_CONC_REQ_SUBMIT_PKG
IS

----*****************-- Procedure for calling Invoice Voucher

PROCEDURE XX_SUBMIT_INV_VOUCHER
(
p_org_id IN NUMBER,
p_inv_no IN VARCHAR2,
p_doc_seq_value IN NUMBER,
p_created_by IN NUMBER

)
IS

x_user_id    NUMBER;
x_appl_id    NUMBER;
x_resp_id    NUMBER;
X_LEDGER_ID   NUMBER;

x_pos varchar2(50):='XXX';
V_LAYOUT BOOLEAN;
v_print_option boolean;
V_RDF_FILE VARCHAR2(200); -- ADDED ON 11-DEC-15
BEGIN
x_pos:='BEFORE USER';
SELECT user_id
INTO x_user_id
FROM FND_USER
WHERE user_id = p_created_by ;
x_pos:='AFTER USER';


 select  OU.set_of_books_id 
 into   X_LEDGER_ID 
 from   hr_operating_units  OU  
 where OU.organization_id =  p_org_id ; 


SELECT application_id
INTO x_appl_id
FROM FND_APPLICATION
WHERE application_short_name = 'SQLAP';

x_pos:='AFTER APPLICATION';

FND_GLOBAL.APPS_INITIALIZE(x_user_id, x_resp_id, x_appl_id);

x_pos:= 'BEFORE API';

V_LAYOUT:= FND_SUBMIT.add_layout(template_appl_name => 'SQLAP'
,template_code => 'COAPN2'
,template_language => 'en'
,template_territory => 'US'
,output_format => 'PDF');
--commit;
IF V_LAYOUT = TRUE THEN 

IF p_org_id=8 THEN
      V_RDF_FILE:='APAPNB';
ELSIF p_org_id=85 THEN
      V_RDF_FILE:='APAPNB';
ELSIF p_org_id=36 THEN
      V_RDF_FILE:='APAPNB';
ELSIF p_org_id=29 THEN
      V_RDF_FILE:='APAPNB';
ELSIF p_org_id=47 THEN
      V_RDF_FILE:='APAPNB';      

END IF;

v_print_option := fnd_request.set_print_options(printer => 'cheque'
--,style => 'A4'
,copies => 1
,save_output => TRUE
,print_together => 'N');

v_request_id := fnd_request.submit_request(application => 'SQLAP'
, program     => V_RDF_FILE --'APAPNB'
, description => NULL
,start_time   => SYSDATE
,sub_request  => FALSE
, argument1   => p_org_id
, argument2   => NULL--p_invoice_date
, argument3   => NULL--p_invoice_date
, argument4   => p_doc_seq_value
, argument5   => p_doc_seq_value
, argument6   => NULL --p_inv_no
, argument7  =>  NULL --p_inv_no
, argument8   => NULL
, argument9   => NULL --
, argument10  =>  NULL --
, argument11   => NULL
, argument12   => X_LEDGER_ID --Ledger ID

); 

--FND_REQUEST.add_layout(template_appl_name => 'SQLAP');
END IF;
x_pos:='AFTER API';



commit;

EXCEPTION
WHEN OTHERS THEN 
dbms_output.put_line(x_pos);
dbms_output.put_line(SQLERRM);
END;


---*****************-- Procedure for calling Payment Register

PROCEDURE XX_SUBMIT_PAYMENT_VOUCHER(
p_org_id IN number,
p_created_by IN number,
p_vouch_no_v IN number,
p_check_no IN number
)
IS

x_user_id    NUMBER;
x_appl_id    NUMBER;
x_resp_id    NUMBER;
x_pos varchar2(50):='XXX';
--req_id NUMBER;
v_print_option boolean;
V_RDF_FILE VARCHAR2(200); -- ADDED ON 11-DEC-15
BEGIN
x_pos:='BEFORE USER';


SELECT user_id
INTO x_user_id
FROM FND_USER
WHERE user_id = p_created_by;
x_pos:='AFTER USER';

SELECT application_id
INTO x_appl_id
FROM FND_APPLICATION
WHERE application_short_name = 'SQLAP';

x_pos:='AFTER APPLICATION';

SELECT responsibility_id
INTO x_resp_id
FROM FND_APPLICATION fa, FND_RESPONSIBILITY_TL fr
WHERE fa.application_short_name = 'SQLAP' AND
fa.application_id = fr.application_id AND
fr.responsibility_name = 'AP Super User';


x_pos:='AFTER RESPONSIBILITY';

FND_GLOBAL.APPS_INITIALIZE(x_user_id, x_resp_id, x_appl_id);

x_pos:= 'BEFORE API';

IF p_org_id=82 THEN
      V_RDF_FILE:='APAPV';
ELSIF p_org_id=185 THEN
      V_RDF_FILE:='APAPV';
END IF;

v_print_option := fnd_request.set_print_options(printer => 'cheque'
,style => 'A4'
,copies => 1
,save_output => TRUE
,print_together => 'N');

v_request_id := fnd_request.submit_request(application => 'SQLAP'
, program     => V_RDF_FILE -- 'PAPV'
, description => NULL
,start_time   => NULL
,sub_request  => FALSE
--
, argument1   => null
, argument2   => NULL
, argument3   => NULL
, argument4   => NULL
--
, argument5   => p_vouch_no_v
, argument6   => p_vouch_no_v
, argument7   => p_check_no
, argument8   => p_check_no
); 


x_pos:='AFTER API';
commit;

EXCEPTION
WHEN OTHERS THEN 
NULL;
END;



FUNCTION  XX_RET_REQUEST_ID 
RETURN NUMBER AS
BEGIN
RETURN v_request_id;
END XX_RET_REQUEST_ID;


END XX_CONC_REQ_SUBMIT_PKG;

----------------------------------------------------------------------------------------------------------------------







='
   begin
     XX_CONC_REQ_SUBMIT_PKG.XX_SUBMIT_INV_VOUCHER('''||:INV_SUM_FOLDER.ORG_ID||''', '''||:INV_SUM_FOLDER.INVOICE_NUM||''','''||:INV_SUM_FOLDER.DOC_SEQUENCE_VALUE||''','''||:PARAMETER.USER_ID||'''
);
   end'










Wednesday, 5 July 2017

How to Disable Delete Button on AP Invoice Headers

https://aporaclepayables.blogspot.com/2017/07/how-to-disable-delete-button-on-ap.html

How to Disable Delete Button on AP Invoice Headers

-----------------------------------

WHEN-NEW-RECORD-INSTANCE
INV_SUM_FOLDER

Type: Property
Block
INV_SUM_FOLDER
DELETE_ALLOWED
FALSE

Personalization to Popup Error Message on Exchange Rate field on Foreign Invoices if null

https://aporaclepayables.blogspot.com/2017/07/personalization-to-popup-error-message.html

Personalization to Popup Error Message on Exchange Rate field on Foreign Invoices if null

WHEN-VALIDATE-RECORD
INV_SUM_FOLDER

:INV_SUM_FOLDER.INVOICE_CURRENCY_CODE <> 'PKR'
and :INV_SUM_FOLDER.RATE_DSP is null

Message:
Error: Please Enter Exchange Rate Information

How to change the Cancelled Date of Invoice in AP. If Invoice has got no distributions and does not require any Accounting

https://aporaclepayables.blogspot.com/2017/07/how-to-change-cancelled-date-of-invoice.html

User has cancelled the Invoice on 01-JUL-2017. We required to change the Cancelled Date to 30-JUN-2017. 

Please Note that Invoice has got no distributions and does not require any Accounting.

---------------------------------------

You can use following script to update the canceled_date. If Invoice has got no distributions and does not require any Accounting.

update ap_invoices_all
set cancelled_date = ''
where invoice_id = <invoice id >;

Tuesday, 20 June 2017

AP Invoice Distributions PLSQL QUERY (Item Line with WHT Deduction)

http://aporaclepayables.blogspot.com/2017/06/select-g.html

select g.DOC_SEQUENCE_VALUE APN_No,
       g.GL_DATE HEADER_GL_DATE,
       d.ACCOUNTING_DATE Distribution_GL_DATE,
       b.VENDOR_NAME,
       d.DESCRIPTION,
       d.line_type_lookup_code,
       -- d.invoice_distribution_id,
       -- d.awt_related_id,
       NVL(d.base_amount, d.amount) Amount,
       --  d.awt_group_id,
       -- d.awt_tax_rate_id,
       --  L.PAY_AWT_GROUP_ID,
       --  L.AWT_GROUP_ID,
       (select SUM(NVL(d2.base_amount, d2.amount))
          from ap_invoice_distributions_all d2
         where d2.awt_related_id = d.invoice_distribution_id
           and d2.line_type_lookup_code = 'AWT'
           and d2.invoice_id = d.invoice_id) WHT,
       /*    (select tr.tax_rate
                 from ap_awt_tax_rates_all tr
                where tr.tax_rate_id = d.awt_tax_rate_id) TAX_RATE,*/
       /*     (select tr.Tax_Name
                 from ap_awt_tax_rates_all tr
                where tr.tax_rate_id = d.awt_tax_rate_id) TAX_name,*/
       (select GRP.NAME
          from AP_AWT_GROUPS GRP
         where GRP.GROUP_ID = D.AWT_ORIGIN_GROUP_ID) AWT_GROUP,
     
       (select grp2.name
          from AP_AWT_GROUPS GRP2
         where grp2.group_id = d.pay_awt_group_id) ITEM_GROUP
     
 /*    ,  (select nvl(d2.BASE_AMOUNT, d2.amount)
          from ap_invoice_distributions_all d2
         where d2.invoice_distribution_id = d.awt_related_id
           and d2.line_type_lookup_code = 'ITEM'
           and d2.invoice_id = d.invoice_id) ACTUAL_AMOUNT*/
  from ap_invoice_distributions_All d,
       AP_INVOICE_LINES_All         L,
       ap_invoices_all              g,
       ap_suppliers                 b
 WHERE D.INVOICE_ID = L.INVOICE_ID
   AND D.INVOICE_LINE_NUMBER = L.LINE_NUMBER
   and g.INVOICE_ID = L.INVOICE_ID
   and g.INVOICE_ID = d.INVOICE_ID
   and g.ORG_ID = L.org_id
   and L.org_id = d.Org_id
   and b.VENDOR_ID = g.VENDOR_ID
   and g.org_id = 376
--and d.invoice_id = 94273 -- 3511993--3547454

/*    select sum(NVL(base_amount,amount)) from ap_invoice_distributions_all --4308
   where org_id=376
   and line_type_lookup_code = 'AWT'
*/

--------------------------------------------------------------------------------------------------------------------------

select --distinct g.invoice_id, g.AMOUNT_PAID     --4473  --706556268    8834072
 g.AMOUNT_PAID,
 g.DOC_SEQUENCE_VALUE APN_No,
 g.GL_DATE HEADER_GL_DATE,
 d.ACCOUNTING_DATE Distribution_GL_DATE,
 b.VENDOR_NAME,
 d.DESCRIPTION,
 d.line_type_lookup_code,
 gc.SEGMENT1||'-'||gc.SEGMENT2||'-'||gc.SEGMENT3||'-'||gc.SEGMENT4||'-'||gc.SEGMENT5||'-'||gc.SEGMENT6||'-'||gc.SEGMENT7||'-'||gc.SEGMENT8 Account,
 -- d.invoice_distribution_id,
 -- d.awt_related_id,
 NVL(d.base_amount, d.amount) Amount,
 --  d.awt_group_id,
 -- d.awt_tax_rate_id,
 --  L.PAY_AWT_GROUP_ID,
 --  L.AWT_GROUP_ID,
 (select SUM(NVL(d2.base_amount, d2.amount))
    from ap_invoice_distributions_all d2
   where d2.awt_related_id = d.invoice_distribution_id
     and d2.line_type_lookup_code = 'AWT'
     and d2.invoice_id = d.invoice_id) WHT,
 /*    (select tr.tax_rate
                  from ap_awt_tax_rates_all tr
                 where tr.tax_rate_id = d.awt_tax_rate_id) TAX_RATE,*/
 /*     (select tr.Tax_Name
                  from ap_awt_tax_rates_all tr
                 where tr.tax_rate_id = d.awt_tax_rate_id) TAX_name,*/
 (select GRP.NAME
    from AP_AWT_GROUPS GRP
   where GRP.GROUP_ID = D.AWT_ORIGIN_GROUP_ID) AWT_GROUP,

 (select grp2.name
    from AP_AWT_GROUPS GRP2
   where grp2.group_id = d.pay_awt_group_id) ITEM_GROUP

/*    ,  (select nvl(d2.BASE_AMOUNT, d2.amount)
          from ap_invoice_distributions_all d2
         where d2.invoice_distribution_id = d.awt_related_id
           and d2.line_type_lookup_code = 'ITEM'
           and d2.invoice_id = d.invoice_id) ACTUAL_AMOUNT*/

  from ap_invoice_distributions_All d,
       AP_INVOICE_LINES_All         L,
       ap_invoices_all              g,
       ap_suppliers                 b,
       AP_INVOICE_PAYMENTS_ALL      c,
       ap_checks_all                e,
       gl_code_combinations         gc
 WHERE D.INVOICE_ID = L.INVOICE_ID
   AND D.INVOICE_LINE_NUMBER = L.LINE_NUMBER
   and g.INVOICE_ID = L.INVOICE_ID
   and g.INVOICE_ID = d.INVOICE_ID
   and g.INVOICE_ID = c.INVOICE_ID
   and l.INVOICE_ID = c.INVOICE_ID
   and d.INVOICE_ID = c.INVOICE_ID
   and e.CHECK_ID = c.CHECK_ID
   and gc.CODE_COMBINATION_ID = d.DIST_CODE_COMBINATION_ID
      -- and d.ACCOUNTING_EVENT_ID = c.ACCOUNTING_EVENT_ID
   and g.ORG_ID = L.org_id
   and L.org_id = d.Org_id
   and l.ORG_ID = c.ORG_ID
   and c.ORG_ID = g.org_id
   and e.ORG_ID = c.ORG_ID
   and b.VENDOR_ID = g.VENDOR_ID
   and g.org_id = 376
   and c.REVERSAL_FLAG = 'N'
   and trunc(e.CLEARED_DATE) between '01-DEC-2016' and '31-DEC-2017'
--and g.INVOICE_ID=115693
--  and g.GL_DATE between '01-JUN-2017' and '30-JUN-2017'
--and d.invoice_id = 94273 -- 3511993--3547454

/*    select sum(NVL(base_amount,amount)) from ap_invoice_distributions_all --4308
   where org_id=376
   and line_type_lookup_code = 'AWT'
*/

--------------------------------------------------------------------------------------------------------------------------

  select NVL(n.base_amount, n.amount) Amount
          from AP_INVOICE_PAYMENTS_ALL      k,
         ap_invoice_distributions_all n --778
        ,
         ap_checks_all                x
         where k.INVOICE_ID = n.INVOICE_ID
           and k.CHECK_ID = x.CHECK_ID
           and k.org_id = x.org_id
           and k.org_id = n.org_id
           and k.ORG_ID = 376 --108478
           and k.REVERSAL_FLAG = 'N'
             
           and x.CLEARED_DATE between '01-DEC-2016' and '31-DEC-2017'
              --and k.INVOICE_ID = 115693
           and n.line_type_lookup_code = 'AWT'

Thursday, 8 June 2017

What is the difference between 'Apply' check box" and 'Prepayment On Invoice' check box?

http://aporaclepayables.blogspot.com/2017/06/what-is-difference-between-apply-check.html

Let us discuss the issue with the help of an example.

Prepayment Invoice -> amount=1000
Standard Invoice -> amount=10000

Apply check box: this is checked when the Prepayment amount has been paid and Supplier sends a Standard Invoice for 10000 (not deducting the Prepayment amount). Then when trying to apply the Prepayment invoice, check the 'Apply' check box.
Using the example:
Invoice Header will be 10000
Invoice Line line will be 10000
Invoice Distributions will be 10000
On applying prepayment: the prepay line for 1000 is created.

Prepayment On Invoice check box: checked when the Prepayment has been paid and Supplier sends a Standard Invoice for 9000 (deducting the Prepayment amount ). Then when trying to apply the Prepayment to Standard Invoice, check the 'Prepayment On Invoice' check box.
Using the example:
Invoice Header is 9000
Invoice Line is for 10000
Invoice Distributions are for 10000