Wednesday, 24 October 2018

API To Close Purchase Order

DECLARE
x_return_code VARCHAR2(100);
l_progress VARCHAR2(100);
l_result BOOLEAN;
l_User_Id      Number;
 l_Resp_Id      Number;
 l_Resp_Appl_Id Number;
BEGIN
apps.fnd_client_info.set_org_context('102');
SELECT distinct fnd.user_id ,
  fresp.responsibility_id,
  fresp.application_id
  into
  l_user_id,
  l_resp_id,
  l_resp_appl_id
  FROM fnd_user fnd ,
  FND_RESPONSIBILITY_TL FRESP
where FND.USER_NAME = 'SYSADMIN'
and UPPER(FRESP.RESPONSIBILITY_NAME) like ('PURCHASING SUPER USER');
 Apps.Fnd_Global.Apps_Initialize(User_Id      => l_User_Id,
                                 Resp_Id      => l_Resp_Id,
                                 Resp_Appl_Id => l_Resp_Appl_Id);
l_result := PO_ACTIONS.CLOSE_PO(
                                P_DOCID => 1170,
                                P_DOCTYP => 'PO',
                                P_DOCSUBTYP => 'STANDARD',
                                P_LINEID => 0,--23152,
                                P_SHIPID => 0,--22990,
                                P_ACTION => 'CLOSE',
                                P_REASON => 'Testing',
                                P_CALLING_MODE => 'PO',
                                P_CONC_FLAG => 'N',
                                P_RETURN_CODE => x_return_code,
                                P_AUTO_CLOSE => 'Y',
                                P_ACTION_DATE => SYSDATE,
                                P_ORIGIN_DOC_ID => NULL
                                );
IF l_result then
dbms_output.put_line('The Closure was successful');
ELSE
dbms_output.put_line('The Closure was unsuccessful');
END IF;
END;

Thursday, 4 October 2018

Simple Invoices Purge

Simple Invoices i.e. invoices that are not matched to purchase orders can be purged using form "Purge" (Form name =APXPGSUB.fmx). This form is accessible to responsibility "Payables Purge". This form allows to purge payables data based on Last Activity date. This form does not allow to purge a single invoice to see how invoice purge works. Based on Last Activity data parameters, you can limit the number of invoices selected for Purge. This form can be used for purging
1. Simple Invoices
2. Simple PUrchase Orders
3. Simple Requisitions
4. Suppliers
5. Invoices and Purchase Orders

By default this form queries only those purges that are not in following statuses

COMPLETED-ABORTED
COMPLETED-PURGED

In order to purge simple invoices, do the following

1. Name: Purge batch name ( i normally use org id + Last activity date + some identifier such as A1, A2 to make it unique)
2. Category should be "Simple Invoices"
3.Select Last Activity Date. If invoice has any activity such as payment, cancellation of payment or accounting etc. on or
before this date will not be selected for purge.4
4.Pay Alone only. This parameter is applicable to invoice purge only. If it is 'All' then invoice may be purged irrespective of the
fact that invoice is paid alone or bunched with other invoice(s) for payment.

To start purge process, first click on "Initiate" button. It will start two concurrent program.

Initiate Purge (AP/PO Purge Initiation (Selection) Routine)
Print Purge (Purge Report Listings)

"Initiate Purge" will not start if any other invoice purge is in process i.e. a record in FINANCIALS_PURGES_ALL with status other
than 'COMPLETED-PURGED' or 'COMPLETED-ABORTED'. If you selected a batch for purging and started purge process but cancelled
the concurrent program due to slow performance then a record in FINANCIALS_PURGES_ALL may remain in status 'DELETING'. In
that case you have to update status manually and change it to 'COMPLETED-ABORTED'

All invoices selected for purge are inserted into AP_PURGE_INVOICE_LIST

The program "Print Purge (Purge Report Listings)" waits for Initiate purge to complete. It prints list of invoices that are selected for
purge. This report could be too big.
After completion of above two programs, come back to purge form. It will automatically query the purge in process. At this time you
have option to

1. Abort the purge process
2. Confirm the Deletion of invoices selected
3. Restart. Clicking on Restart after Initiate process will submit concurrent program "Print Purge (Purge Report Listings)" again

After initiate, you may click on "Confirm" Button to start deletion of invoices. It will start concurrent program "Delete Purge (AP/PO
Purge Deletion Routine)". It will start multiple threads of program "Parallel Purge (AP/PO Purge Parallel Routine)" to delete data in
parallel. Number of thread are determined by setting of profile option AP: Purge Worker Count. It will delete selected invoices
and related data such as payments, holds. List of tables from where data is deleted for "Simple Invoices" is given below

1. ap_checks
2. ap_invoice_selection_criteria
3. ap_doc_sequence_audit
4. ap_payment_history
5. ap_invoice_payments
6. ap_payment_schedules
7. ap_trial_balance
8. ap_holds
9. ap_inv_aprvl_hist
10. ap_invoice_distributions
11. ap_invoice_lines
12. ap_invoices
13. ap_batches
14. ap_liability_balance
15. ap_purge_invoice_list
16. ap_encumbrance_lines
17. ap_purge_invoice_list

When you click "Confirm" button, Oracle will verify again if invoices selected are still eligible for purge. This could be time
consuming. If you are deleting selected invoice immediately after "Initiate" run then you may set profile option AP: Purge without
Review to Yes and then oracle will not verify eligibility of purge. it will just go ahead and purge selected invoices.