Sei sulla pagina 1di 46

Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

1. You need to list out all Internal Requisitions that do not have an associated Internal Sales
order.
---used to list all Internal Requisitions that do not have an
associated Internal Sales order
SELECT rqh.segment1 req_num, rql.line_num, rql.requisition_header_id,
rql.requisition_line_id, rql.item_id,
rql.unit_meas_lookup_code,
rql.unit_price, rql.quantity, rql.quantity_cancelled,
rql.quantity_delivered, rql.cancel_flag, rql.source_type_code,
rql.source_organization_id, rql.destination_organization_id,
rqh.transferred_to_oe_flag
FROM po_requisition_lines_all rql, po_requisition_headers_all rqh
WHERE rql.requisition_header_id = rqh.requisition_header_id
AND rql.source_type_code = 'INVENTORY'
AND rql.source_organization_id IS NOT NULL
AND NOT EXISTS (
SELECT 'existing internal order'
FROM oe_order_lines_all lin
WHERE lin.source_document_line_id = rql.requisition_line_id
AND lin.source_document_type_id = 10)
ORDER BY rqh.requisition_header_id, rql.line_num;

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

2. You want to display what requisition and PO are linked(Relation with Requisition and PO )
-----Relation with Requistion and PO
SELECT r.segment1 "Req Num", p.segment1 "PO Num"
FROM po_headers_all p,
po_distributions_all d,
po_req_distributions_all rd,
po_requisition_lines_all rl,
po_requisition_headers_all r
WHERE p.po_header_id = d.po_header_id
AND d.req_distribution_id = rd.distribution_id
AND rd.requisition_line_id = rl.requisition_line_id
AND rl.requisition_header_id = r.requisition_header_id

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

3. You need to list out all cancel Requisitions


-----list My cancel Requistion
select prh.REQUISITION_HEADER_ID,
prh.PREPARER_ID ,
prh.SEGMENT1 "REQ NUM",
trunc(prh.CREATION_DATE),
prh.DESCRIPTION,
prh.NOTE_TO_AUTHORIZER
from apps.Po_Requisition_headers_all prh,
apps.po_action_history pah
where Action_code='CANCEL'
and pah.object_type_code='REQUISITION'
and pah.object_id=prh.REQUISITION_HEADER_ID

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

4. You need to list those PR which havn't auto created to PO.(Purchase Requisition without a
Purchase Order)
-----list all Purchase Requisition without a Purchase Order that means
a PR has not been autocreated to PO.
select
prh.segment1 "PR NUM",
trunc(prh.creation_date) "CREATED ON",
trunc(prl.creation_date) "Line Creation Date" ,
prl.line_num "Seq #",
msi.segment1 "Item Num",
prl.item_description "Description",
prl.quantity "Qty",
trunc(prl.need_by_date) "Required By",
ppf1.full_name "REQUESTOR",
ppf2.agent_name "BUYER"
from
po.po_requisition_headers_all prh,
po.po_requisition_lines_all prl,
apps.per_people_f ppf1,
(select distinct agent_id,agent_name from apps.po_agents_v ) ppf2,
po.po_req_distributions_all prd,
inv.mtl_system_items_b msi,
po.po_line_locations_all pll,
po.po_lines_all pl,
po.po_headers_all ph
WHERE
prh.requisition_header_id = prl.requisition_header_id
and prl.requisition_line_id = prd.requisition_line_id
and ppf1.person_id = prh.preparer_id
and prh.creation_date between ppf1.effective_start_date and
ppf1.effective_end_date
and ppf2.agent_id(+) = msi.buyer_id
and msi.inventory_item_id = prl.item_id
and msi.organization_id = prl.destination_organization_id
and pll.line_location_id(+) = prl.line_location_id
and pll.po_header_id = ph.po_header_id(+)
AND PLL.PO_LINE_ID = PL.PO_LINE_ID(+)
AND PRH.AUTHORIZATION_STATUS = 'APPROVED'
AND PLL.LINE_LOCATION_ID IS NULL
AND PRL.CLOSED_CODE IS NULL
AND NVL(PRL.CANCEL_FLAG,'N') <> 'Y'
ORDER BY 1,2

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

5. You need to list all information form PR to PO ...as a requisition moved from different stages
till converting into PR. This query capture all details related to that PR to PO.
----- List and all data entry from PR till PO
SELECT DISTINCT u.description "Requestor", porh.segment1 AS "Req
Number",
TRUNC (porh.creation_date) "Created On",
pord.last_updated_by,
porh.authorization_status "Status",
porh.description "Description", poh.segment1 "PO
Number",
TRUNC (poh.creation_date) "PO Creation Date",
poh.authorization_status "PO Status",
TRUNC (poh.approved_date) "Approved Date"
FROM apps.po_headers_all poh,
apps.po_distributions_all pod,
apps.po_req_distributions_all pord,
apps.po_requisition_lines_all porl,
apps.po_requisition_headers_all porh,
apps.fnd_user u
WHERE porh.requisition_header_id = porl.requisition_header_id
AND porl.requisition_line_id = pord.requisition_line_id
AND pord.distribution_id = pod.req_distribution_id(+)
AND pod.po_header_id = poh.po_header_id(+)
AND porh.created_by = u.user_id
ORDER BY 2

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

6.Identifying all PO's which does not have any PR's


---list all Purchase Requisition without a Purchase Order that means a
PR has not been autocreated to PO.
SELECT prh.segment1 "PR NUM", TRUNC (prh.creation_date) "CREATED ON",
TRUNC (prl.creation_date) "Line Creation Date", prl.line_num
"Seq #",
msi.segment1 "Item Num", prl.item_description "Description",
prl.quantity "Qty", TRUNC (prl.need_by_date) "Required By",
ppf1.full_name "REQUESTOR", ppf2.agent_name "BUYER"
FROM po.po_requisition_headers_all prh,
po.po_requisition_lines_all prl,
apps.per_people_f ppf1,
(SELECT DISTINCT agent_id, agent_name
FROM apps.po_agents_v) ppf2,
po.po_req_distributions_all prd,
inv.mtl_system_items_b msi,
po.po_line_locations_all pll,
po.po_lines_all pl,
po.po_headers_all ph
WHERE prh.requisition_header_id = prl.requisition_header_id
AND prl.requisition_line_id = prd.requisition_line_id
AND ppf1.person_id = prh.preparer_id
AND prh.creation_date BETWEEN ppf1.effective_start_date
AND ppf1.effective_end_date
AND ppf2.agent_id(+) = msi.buyer_id
AND msi.inventory_item_id = prl.item_id
AND msi.organization_id = prl.destination_organization_id
AND pll.line_location_id(+) = prl.line_location_id
AND pll.po_header_id = ph.po_header_id(+)
AND pll.po_line_id = pl.po_line_id(+)
AND prh.authorization_status = 'APPROVED'
AND pll.line_location_id IS NULL
AND prl.closed_code IS NULL
AND NVL (prl.cancel_flag, 'N') <> 'Y'
ORDER BY 1, 2

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

7. List all the PO's with there approval ,invoice and Payment Details
----- List and PO With there approval , invoice and payment details
SELECT a.org_id "ORG ID", e.segment1 "VENDOR NUM",
e.vendor_name "SUPPLIER NAME",
UPPER (e.vendor_type_lookup_code) "VENDOR TYPE",
f.vendor_site_code "VENDOR SITE CODE", f.address_line1 "ADDRESS",
f.city "CITY", f.country "COUNTRY",
TO_CHAR (TRUNC (d.creation_date)) "PO Date", d.segment1 "PO NUM",
d.type_lookup_code "PO Type", c.quantity_ordered "QTY ORDERED",
c.quantity_cancelled "QTY CANCELLED", g.item_id "ITEM ID",
g.item_description "ITEM DESCRIPTION", g.unit_price "UNIT PRICE",
(NVL (c.quantity_ordered, 0) - NVL (c.quantity_cancelled, 0)
)
* NVL (g.unit_price, 0) "PO Line Amount",
(SELECT DECODE (ph.approved_flag, 'Y', 'Approved')
FROM po.po_headers_all ph
WHERE ph.po_header_id = d.po_header_id) "PO Approved?",
a.invoice_type_lookup_code "INVOICE TYPE",
a.invoice_amount "INVOICE AMOUNT",
TO_CHAR (TRUNC (a.invoice_date)) "INVOICE DATE",
a.invoice_num "INVOICE NUMBER",
(SELECT DECODE (x.match_status_flag,
'A', 'Approved'
)
FROM ap.ap_invoice_distributions_all x
WHERE x.invoice_distribution_id = b.invoice_distribution_id)
"Invoice
Approved?",
a.amount_paid, h.amount, h.check_id, h.invoice_payment_id
"Payment Id",
i.check_number "Cheque Number",
TO_CHAR (TRUNC (i.check_date)) "PAYMENT DATE"
FROM ap.ap_invoices_all a,
ap.ap_invoice_distributions_all b,
po.po_distributions_all c,
po.po_headers_all d,
po.po_vendors e,
po.po_vendor_sites_all f,
po.po_lines_all g,
ap.ap_invoice_payments_all h,
ap.ap_checks_all i
WHERE a.invoice_id = b.invoice_id
AND b.po_distribution_id = c.po_distribution_id(+)
AND c.po_header_id = d.po_header_id(+)
AND e.vendor_id(+) = d.vendor_id
AND f.vendor_site_id(+) = d.vendor_site_id
AND d.po_header_id = g.po_header_id
AND c.po_line_id = g.po_line_id

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

AND a.invoice_id = h.invoice_id


AND h.check_id = i.check_id
AND f.vendor_site_id = i.vendor_site_id
AND c.po_header_id IS NOT NULL
AND a.payment_status_flag = 'Y'
AND d.type_lookup_code != 'BLANKET'

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

8.You need to know the link to GL_JE_LINES table for purchasing accrual and budgetary
control actions..
The budgetary (encumbrance) and accrual actions in the purchasing module generate records that
will be imported into GL for the corresponding accrual and budgetary journals.
The following reference fields are used to capture and keep PO information in the GL_JE_LINES
table.
These reference fields are populated when the Journal source (JE_SOURCE in GL_JE_HEADERS)
is Purchasing.
Budgetary Records from PO (These include reservations, reversals and cancellations):
 REFERENCE_1- Source (PO or REQ)
 REFERENCE_2- PO Header ID or Requisition Header ID (from
po_headers_all.po_header_id or
po_requisition_headers_all.requisition_header_id)
 REFERENCE_3- Distribution ID (from po_distributions_all.po_distribution_id or
po_req_distributions_all.distribution_id)
 REFERENCE_4- Purchase Order or Requisition number (from po_headers_all.segment1 or
po_requisition_headers_all.segment1)
 REFERENCE_5- (Autocreated Purchase Orders only) Backing requisition number (from
po_requisition_headers_all.segment1)

Accrual Records from PO:


 REFERENCE_1- Source (PO)
 REFERENCE_2- PO Header ID (from po_headers_all.po_header_id)
 REFERENCE_3- Distribution ID (from po_distributions_all.po_distribution_id
 REFERENCE_4- Purchase Order number (from po_headers_all.segment1)
 REFERENCE_5- (ON LINE ACCRUALS ONLY) Receiving Transaction ID (from
rcv_receiving_sub_ledger.rcv_transaction_id)

Take a note for Period end accruals, the REFERENCE_5 column is not used.

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

9. List me all open PO's


----- List all open PO'S
select
h.segment1 "PO NUM",
h.authorization_status "STATUS",
l.line_num "SEQ NUM",
ll.line_location_id,
d.po_distribution_id ,
h.type_lookup_code "TYPE"
from
po.po_headers_all h,
po.po_lines_all l,
po.po_line_locations_all ll,
po.po_distributions_all d
where h.po_header_id = l.po_header_id
and ll.po_line_id = l.po_Line_id
and ll.line_location_id = d.line_location_id
and h.closed_date is null
and h.type_lookup_code not in ('QUOTATION')

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

10.There are different authorization_status can a requisition have.


 Approved
 Cancelled
 In Process
 Incomplete
 Pre-Approved
 Rejected

and you should note: When we finally close the requisition from Requisition Summary form the
authorization_status of the requisition does not change. Instead it's closed_code becomes
'FINALLY CLOSED'.

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Below are the some of useful queries/scripts…..


List Purchase Requisitions with out PO
---list all Purchase Requisition without a Purchase Order that means a
PR has not been autocreated to PO.
SELECT prh.segment1 "PR NUM", TRUNC (prh.creation_date) "CREATED ON",
TRUNC (prl.creation_date) "Line Creation Date", prl.line_num
"Seq #",
msi.segment1 "Item Num", prl.item_description "Description",
prl.quantity "Qty", TRUNC (prl.need_by_date) "Required By",
ppf1.full_name "REQUESTOR", ppf2.agent_name "BUYER"
FROM po.po_requisition_headers_all prh,
po.po_requisition_lines_all prl,
apps.per_people_f ppf1,
(SELECT DISTINCT agent_id, agent_name
FROM apps.po_agents_v) ppf2,
po.po_req_distributions_all prd,
inv.mtl_system_items_b msi,
po.po_line_locations_all pll,
po.po_lines_all pl,
po.po_headers_all ph
WHERE prh.requisition_header_id = prl.requisition_header_id
AND prl.requisition_line_id = prd.requisition_line_id
AND ppf1.person_id = prh.preparer_id
AND prh.creation_date BETWEEN ppf1.effective_start_date
AND ppf1.effective_end_date
AND ppf2.agent_id(+) = msi.buyer_id
AND msi.inventory_item_id = prl.item_id
AND msi.organization_id = prl.destination_organization_id
AND pll.line_location_id(+) = prl.line_location_id
AND pll.po_header_id = ph.po_header_id(+)
AND pll.po_line_id = pl.po_line_id(+)
AND prh.authorization_status = 'APPROVED'
AND pll.line_location_id IS NULL
AND prl.closed_code IS NULL
AND NVL (prl.cancel_flag, 'N') <> 'Y'
ORDER BY 1, 2

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

List all information form PR to PO


-- List and all data entry from PR till PO
SELECT DISTINCT u.description "Requestor", porh.segment1 AS "Req
Number",
TRUNC (porh.creation_date) "Created On",
pord.last_updated_by,
porh.authorization_status "Status",
porh.description "Description", poh.segment1 "PO
Number",
TRUNC (poh.creation_date) "PO Creation Date",
poh.authorization_status "PO Status",
TRUNC (poh.approved_date) "Approved Date"
FROM apps.po_headers_all poh,
apps.po_distributions_all pod,
apps.po_req_distributions_all pord,
apps.po_requisition_lines_all porl,
apps.po_requisition_headers_all porh,
apps.fnd_user u
WHERE porh.requisition_header_id = porl.requisition_header_id
AND porl.requisition_line_id = pord.requisition_line_id
AND pord.distribution_id = pod.req_distribution_id(+)
AND pod.po_header_id = poh.po_header_id(+)
AND porh.created_by = u.user_id
ORDER BY 2

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

List out all cancel Requisitions


--list My cancel Requistion
select prh.REQUISITION_HEADER_ID,
prh.PREPARER_ID ,
prh.SEGMENT1 "REQ NUM",
trunc(prh.CREATION_DATE),
prh.DESCRIPTION,
prh.NOTE_TO_AUTHORIZER
from apps.Po_Requisition_headers_all prh,
apps.po_action_history pah
where Action_code='CANCEL'
and pah.object_type_code='REQUISITION'

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Oracle Procure to Pay Cycle (P2P) Useful queries


Following queries can be very helpful if you are working in Purchasing module and need to
know the details of a P2P transaction.

Stage 1: SQL Queries To See The Details Of a PO After It's Creation :


--PO_HEADERS_ALL
select po_header_id from po_headers_all where segment1 =<po_number>;
select * from po_headers_all where po_header_id =<po_header_id>;

--po_lines_all
select * from po_lines_all where po_header_id =<po_header_id>;

--po_line_locations_all
select * from po_line_locations_all where po_header_id =<po_header_id>;

--po_distributions_all
select * from po_distributions_all where po_header_id =<po_header_id>;

--po_releases_all
SELECT * FROM po_releases_all WHERE po_header_id =<po_header_id>;

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Stage 2: Once PO is received data is moved to respective receving tables and inventory tables
--RCV_SHIPMENT_HEADERS
select * from rcv_shipment_headers where shipment_header_id in
(select shipment_header_id from rcv_shipment_lines
where po_header_id =<po_header_id>);

--RCV_SHIPMENT_LINES
select * from rcv_shipment_lines where po_header_id =<po_header_id>;

--RCV_TRANSACTIONS
select * from rcv_transactions where po_header_id =<po_header_id>;

--RCV_ACCOUNTING_EVENTS
SELECT * FROM rcv_Accounting_Events WHERE rcv_transaction_id IN
(select transaction_id from rcv_transactions
where po_header_id =<po_header_id>);

--RCV_RECEIVING_SUB_LEDGER
select * from rcv_receiving_sub_ledger where rcv_transaction_id in
(select transaction_id from rcv_transactions where po_header_id
=<po_header_id>);

--RCV_SUB_LEDGER_DETAILS
select * from rcv_sub_ledger_details
where rcv_transaction_id in (select transaction_id from rcv_transactions
where po_header_id =<po_header_id>);

--MTL_MATERIAL_TRANSACTIONS
select * from mtl_material_transactions where transaction_source_id
=<po_header_id>;

--MTL_TRANSACTION_ACCOUNTS
select * from mtl_transaction_accounts where transaction_id in ( select
transaction_id from mtl_material_transactions where
transaction_source_id = =<po_header_id>);

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Stage 3: Invoicing details


--AP_INVOICE_DISTRIBUTIONS_ALL
select * from ap_invoice_distributions_all where po_distribution_id in (
select po_distribution_id from po_distributions_all where po_header_id
=<po_header_id>);

--AP_INVOICES_ALL
select * from ap_invoices_all where invoice_id in
(select invoice_id from ap_invoice_distributions_all where
po_distribution_id in
( select po_distribution_id from po_distributions_all where po_header_id
=<po_header_id>));

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Stage 4 : Many Time there is tie up with Project related PO


--PA_EXPENDITURE_ITEMS_ALL
select * from pa_expenditure_items_all peia where
peia.orig_transaction_reference in
( select to_char(transaction_id) from mtl_material_transactions
where transaction_source_id = <po_header_id> );

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Stage 5 : General Ledger


GL_BC_PACKETS ..This is for encumbrances
SELECT * FROM gl_bc_packets WHERE reference2 IN ('<po_header_id>');

--GL_INTERFACE
SELECT *
FROM GL_INTERFACE GLI
WHERE user_je_source_name ='Purchasing'
AND gl_sl_link_table ='RSL'
AND reference21='PO'
AND EXISTS
( SELECT 1
FROM rcv_receiving_sub_ledger RRSL
WHERE GLI.reference22 =RRSL.reference2
AND GLI.reference23 =RRSL.reference3
AND GLI.reference24 =RRSL.reference4
AND RRSL.rcv_transaction_id in
(select transaction_id from rcv_transactions
where po_header_id <po_header_id>));

--GL_IMPORT_REFERENCES
SELECT *
FROM gl_import_references GLIR
WHERE reference_1='PO'
AND gl_sl_link_table ='RSL'
AND EXISTS
( SELECT 1
FROM rcv_receiving_sub_ledger RRSL
WHERE GLIR.reference_2 =RRSL.reference2
AND GLIR.reference_3 =RRSL.reference3
AND GLIR.reference_4 =RRSL.reference4
AND RRSL.rcv_transaction_id in
(select transaction_id from rcv_transactions
where po_header_id =<po_header_id>))

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

A single Query covering P2P life Cycle


In real business world, many time when system is running external/internal auditor are more
interested in scrutiny of:
 Goods received / invoices received
 Inaccurate or duplicate vendor & material master records
 Discrepancies in payment terms
 Delays / long processing times
 Detect duplicate vendor
 Unusually large or small payments
 Unauthorized changes made to invoices
 Detect Duplicate invoice
 Detect Duplicate payment
 Approval status

Therefore thought to share this query, hope this would be great help who have such kind of adhoc
requirement from daily life.
SELECT a.org_id "ORG ID", e.vendor_name "VENDOR NAME",
UPPER (e.vendor_type_lookup_code) "VENDOR TYPE",
f.vendor_site_code "VENDOR SITE", f.address_line1 "ADDRESS",
f.city "CITY", f.country "COUNTRY",
TO_CHAR (TRUNC (d.creation_date)) "PO DATE", d.segment1 "PO
NUMBER",
d.type_lookup_code "PO TYPE", c.quantity_ordered "QTY ORDERED",
c.quantity_cancelled "QTY CANCALLED",
g.item_description "ITEM DESCRIPTION", g.unit_price "UNIT PRICE",
(NVL (c.quantity_ordered, 0) - NVL (c.quantity_cancelled, 0)
)
* NVL (g.unit_price, 0) "PO Line Amount",
(SELECT DECODE (ph.approved_flag, 'Y', 'Approved')
FROM po.po_headers_all ph
WHERE ph.po_header_id = d.po_header_id) "PO STATUS",
a.invoice_type_lookup_code "INVOICE TYPE",
a.invoice_amount "INVOICE AMOUNT",
TO_CHAR (TRUNC (a.invoice_date)) "INVOICE DATE",
a.invoice_num "INVOICE NUMBER",
(SELECT DECODE (x.match_status_flag,
'A', 'Approved'
)
FROM ap.ap_invoice_distributions_all x
WHERE x.invoice_distribution_id = b.invoice_distribution_id)
"Invoice
Approved?",
a.amount_paid, h.amount, i.check_number "CHEQUE NUMBER",
TO_CHAR (TRUNC (i.check_date)) "PAYMENT DATE"
FROM ap.ap_invoices_all a,
ap.ap_invoice_distributions_all b,
po.po_distributions_all c,

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

po.po_headers_all d,
po.po_vendors e,
po.po_vendor_sites_all f,
po.po_lines_all g,
ap.ap_invoice_payments_all h,
ap.ap_checks_all i
WHERE a.invoice_id = b.invoice_id
AND b.po_distribution_id = c.po_distribution_id(+)
AND c.po_header_id = d.po_header_id(+)
AND e.vendor_id(+) = d.vendor_id
AND f.vendor_site_id(+) = d.vendor_site_id
AND d.po_header_id = g.po_header_id
AND c.po_line_id = g.po_line_id
AND a.invoice_id = h.invoice_id
AND h.check_id = i.check_id
AND f.vendor_site_id = i.vendor_site_id
AND c.po_header_id IS NOT NULL
AND a.payment_status_flag = 'Y'
AND d.type_lookup_code != 'BLANKET';

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

P2P(Procure-to-Pay) Cycle Tables with Joins


1.Item Creation:
2.Supplier Creation:
3.Buyer Creation:
-------------------------------------------------

1.Item Creation:
1)Attach the Responsibility called "Inventory Vision Operations (USA)"
2)Open the Items form
Items=>Master Item
3)Select the Organization name - Vision Operations
4)Enter the Item Name , Item Description
goto Inventory tab check the checkbox called Inventory
goto purchasing tab check the check box called Purchasing
5)Save
6)Goto Tools Menu => Organization Assignment option to assign for the multiple organizations.

SELECT * FROM MTL_SYSTEM_ITEMS_B WHERE SEGMENT1='APACHE' --


INVENTORY_ITEM_ID=20817

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

2.Supplier Creation:
1)Attach the Responsibility called "Purchasing Vision Operations (USA)"
2)Goto the Supplier Form
Supply Base=>Suppliers
3)Enter the Supplier Name . Save supplier number will be created automatically.
4)Select the Sites button enter the supplier site address and other details
5)Goto the Contacts tab enter the Contact details
Name
Phno
Postion and so on.....

SELECT * FROM PO_VENDORS WHERE SEGMENT1='20067' --VENDOR_ID=7930


SELECT * FROM PO_VENDOR_SITES_ALL WHERE VENDOR_ID=7930 --VENDOR_SITE_ID
IN (4638,4639)
SELECT * FROM PO_VENDOR_CONTACTS WHERE VENDOR_SITE_ID IN (4638,4639)

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

3.Buyer Creation:
1)attach the Responsibility called "US HRMS Manager"
2)Create Employee
People => Enter and Maintain=>Select New button
3)Enter Emp name
select action option select "create Employement" select the optiona s "Buyer"
4)enter Data of Birth
save => Ok = > Empoyee number will be generated.
5)Goto System Administrator open the User form create or query user
select the Person field attach the emp name (Which we have created)
6)Save.
7)Goto Purchasing Responsibility
open the Buyers form
enter the employee name and save the transactions.
Setup => Personnal =>Buyers

SELECT * FROM PER_ALL_PEOPLE_F --WHERE --PERSON_ID='25'--


EMPLOYEE_NUMBER='1289' --PERSON_ID=13496

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Purchase Order Flow:


1.Requisition
2.RFQ(Request for Quatation)

1.REQUISITION:
Requisition: is one of the purchasing document will be prepared by the employee whenever he
required the materials or Services or Training and so on.
we have two types of Requisitions
1)Internal
2)Purchase

Internal requisition will be created if materials are receiving from another Inventory
inside of the organization.
Purchase requisition will be created while purchasing the materials from the Suppliers.
Requisitions=>Requisitions
We will enter the Requisition at three level 1)Header
2)Line
3)Distributions.

Open the Requisition form enter the Reqno and select the type at Header level
Enter the Items information at line level like Item name,qty,unitprice,tax and so on select
Distributions button enter the Distributions details.
Save
Select the Button called Approve button to go for approving the Requisition Document Open the
Requisition summary form.
Enter the Reqno select find button we can find the Requisition status wether it is approved or not.

select Tools menu => View Action History to find the history details
Select Tools Menu =>Control option to Cancel the requisition.
SELECT * FROM PO_REQUISITION_HEADERS_ALL WHERE SEGMENT1='5716' --
REQUISITION_HEADER_ID=56885
SELECT * FROM PO_REQUISITION_LINES_ALL WHERE REQUISITION_HEADER_ID=56885
--REQUISITION_LINE_ID=60797
SELECT * FROM PO_REQ_DISTRIBUTIONS_ALL WHERE REQUISITION_LINE_ID=60797

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

2.RFQ(REQUEST FOR QUOTATION)


Once the Requisition is Approved Buyer will prepare thre RFQ document which will be delivered
to the supplier. Supplier will respond for that with quotation. we have Three types of RFQ
documents
BID RFQ:This will be prepared for the secific fixed quantity and there won't be
anyvPriceBraeaks(Discounts) catalog

RFQ: This will be create for te materials which we will purchase from the suppliers regularley ,
and large number of quantity. Here we can specify the Price Breaks.

Standard RFQ: This will be prepared for the Items which we will purchase only once not very
often,Here we can include the Discounts information at different auantity levels.

RFQ Information will be entered at 3 Level


1)Headers
2)Lines
3)Price Breaks(CATALOG,STANDARD) or Shipments (Only for Bid RFQ)

Terms And Conditions:


While creation of the RFQ documents we will select the Terms button and we will enter the terms
abd condition details.
Payment Terms: When Organization is going to make the payment and Interest rates
Fright Terms: Who is going to Bear the Transportation chargers whether Buyer or Supplier
FOB(Free Onboard): If any materials damage or any missing quantity is there then the
responsibility of those materials.

Carrier : In which Transportation Company Organization Required Materials Transportation


company Name.
Open the RFQ Form
RFQ and Quotations=>RFQ's
select TYpe and Dates and so on
enter the Items details at line level
select terms button enter the Terms and Condition Details
Select the Price Braks button enter the Price break details
Save
Select the suppliers button enter the suplier details (Who are receiving this Document)
Select the Button called Add from List to Include the supplier list automatically.
SELECT * FROM PO_HEADERS_ALL WHERE SEGMENT1='347' AND
TYPE_LOOKUP_CODE='RFQ' --PO_HEADER_ID=32876
SELECT * FROM PO_LINES_ALL WHERE PO_HEADER_ID=32876 -- PO_LINE_ID=38063
SELECT * FROM PO_LINE_LOCATIONS_ALL WHERE PO_LINE_ID=38063 --
LINE_LOCATION_ID=72425

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

3.QUOTATION:
Quotation is another purchasing document we will receive from the Supplier which contains the
supplier quote details , Price, Payment terms and so on.
Whatever the quotations we have received from the supplier we will enter in the system through
form.
We have three types of Quotations 1)Bid 2)Catalog 3)Standard
For Bid RFQ we will receive Bid quotation from the Supplier
For Catalog RFQ we will receive Catalog quotation from the Supplier
For Standard RFQ we will receive Standard quotation from the Supplier.
After enter all the quotations in the system management will do quote analysis as per that one
best quotation will be elected as Purchase Order.

Quotation Report
Item Name (Table Value set MTL_SYSTEM_ITEMS_B Segment1)
QuoteNo Type Cdate Supplier Site ContactPerson Buyer Created(UserName)

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

4.PURCHASE ORDER:
PO is one of the Main document which will be prepared and approved by the buyer and send it to
the supplier. which contains the following information terms and Conditions
Items deails
Qty,Price
Distiribution and Shipment Details and so on.

We have four types of Purchase Order


1)STANDARD
2)PLANNED
3)BLANKET
4)CONTRACT

Purchase Orders=> Purchase Orders


Open the PO form enter the Inforamtion at header level select line level information enter the
items and quantity,price details
select shippments button enter the shippment details select the Distributions button enter the
Distribution Details.
Save
Select the Button called Approve (Uncheck Email Check Box) , Document will be submitted for
approval.
open the Purchase Order summary form enter PO number Select Find button we can find the
status of the Purchase order.
Goto Tools menu
Action History => We can find who hs submitted for Approve /Reject /Cancel details
Copy Document => To Create Another PO based on this PO
Control => To Close the Purchase Order or to cancel the Purchase Order.

Types of Purchase Order: -


Standard Planned Blanket
ContractP.O
P.O P.O P.O
Yes Yes Yes Yes
Terms and Conditions
Yes Yes Yes No
Goods or Service Known
Yes Yes May be No
Pricing Known
Yes Yes No No
Quantity known
Yes Yes No No
Account Distributions Known
Yes May be No No
Delivery Schedule Known
Yes Yes No No
Can be Encumbered
N/A Yes Yes N/A
Can Encumber releases

SELECT * FROM PO_HEADERS_ALL WHERE SEGMENT1='4514' AND


TYPE_LOOKUP_CODE='STANDARD' --PO_HEADER_ID =32878
--TYPE_LOOKUP_CODE
SELECT * FROM PO_LINES_ALL WHERE PO_HEADER_ID =32879 --PO_LINE_ID=38065

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

SELECT * FROM PO_LINE_LOCATIONS_ALL WHERE PO_LINE_ID=38066 --


LINE_LOCATION_ID=72427
SELECT * FROM PO_DISTRIBUTIONS_ALL WHERE LINE_LOCATION_ID=72428
SELECT * FROM PO_LOOKUP_CODES --LOOKUP_CODE

AUTO CREATE:
It is one of the Purchasing feature to create the RFQ and PO documents automatically
by using requisition lines.
1)Create Requisition and approve
2)Open the AutoCreate form
3)Select Clear button enter the RequisitionNO
4)Select find button which will shows all the requisition lines
select the lines whatever we want to include into the RFQ
5)select Action = Create to create new RFQ
AddTo to add lines to exisiting to RFQ
6)Select DocumentType = RFQ
7)select Automatic button which will create RFQ document automatically .

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

5.RECEIPTS:
Receipts are one of the documents it will be used to find out how much quantity Supplier
has supplied. We will find out Purchase Order status if it is successfully approved then we will
create the Receipt. We will give the PO Number select Find button check the PO lines right mark
and save. It will create the Receipt number select Header button it will shows the receipt number

and date.
SELECT * FROM RCV_SHIPMENT_HEADERS WHERE RECEIPT_NUM=7472 --
SHIPMENT_HEADER_ID=61421
SELECT * FROM RCV_SHIPMENT_LINES WHERE SHIPMENT_HEADER_ID=61421 --
SHIPMENT_LINE_ID=68368
SELECT * FROM RCV_TRANSACTIONS WHERE SHIPMENT_HEADER_ID=61421

Once Receipt will created go Inventory module and check whether the requested items are
received or not by using these tables.
SELECT * FROM MTL_SYSTEM_ITEMS_B WHERE SEGMENT1='APACHE'
SELECT * FROM MTL_ONHAND_QUANTITIES WHERE INVENTORY_ITEM_ID=20817 AND
ORGANIZATION_ID=204
SELECT SEGMENT1 FROM PO_HEADERS_ALL WHERE PO_HEADER_ID=32881 AND
TYPE_LOOKUP_CODE='STANDARD'

Match Approval Level :- While creating the Purchase Order we will mention the Match Approval
Level at Shipments we will have 3 types they are

2-way:- Purchase Order and Invoice Quantities must match within tolerance before the
corresponding invoice can be paid.
3-way:- Purchase Order, Receipts and Invoice Quantities must match with in tolerance before the
corresponding invoice can be paid.
4-way:- Purchase Order, Receipts, Inspection and Invoice Quantities must match with in tolerance
before the corresponding invoice can be paid.

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Account Payables (A.P) Module:-


Account payables will be used to do the payment transactions. A.P Module is integrated
with both P.O and G.L Modules. In Account Payables we will create the invoices and we will
approve once invoice is approved successfully we will make the payment. Once payment is over
we will move the transactions from A.P to G.l.

1. Without supplier we cannot create Invoice.


2. Without invoice we cannot make Payment.

From the company point of view a person or Organization who is going to receive amount we
will call as Supplier.
Types of Invoices:-
1. Standard
2. Credit Memo
3. Debit Memo
4. With Holding Tax
5. Po Default
6. Mixed
7. Pre Payment
8. Expense Report
9. Recurring Invoices
10. Quick Match

Standard Invoice:- We will create the Standard Invoice to particular Supplier and Supplier site
we will enter the invoice amount, invoice date and soon……..

Credit Memo & Debit Memo Invoices:- Both Invoices has got negative (-ve) amount and adjusted
against Standard Invoice. Credit Memo will be created whenever Supplier is giving discount.
Debit Memo will be created if buyer is going to deduct the amount.

With Holding Tax Invoice:- If supplier is not registered supplier then buyer will make the
Income Tax to the government on behalf of supplier.

Po Default Invoice:- Here we will create the Invoice as per Purchase Order amount. We will
give the Po number system will retrieve PO amount and Invoice will be created as per PO details.

Prepayment Invoice:- When ever we want make payment to supplier in advance that tome we
will create this Prepayment Invoice and we make the Payment.

Expense Reports Invoice:- It will be created for employee expenses as per the employee grade,
position this Invoices will be calculated.

Recurring Invoice:- For some of the Invoices we will not be having supplier invoice that time
we will create Recurring Invoices.

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Ex:- For rent account we will be creating Invoice which has got fixed amount and fixed rate (duration).
Quick Match Invoice:- While creating Purchase Order we will be giving the match approval
option as per that match approval we will create the Invoice and the Invoice type is Quick Match
Invoice.

Mixed Invoice:- Mixed Invoices will be created for miscellaneous expenses. Once we create the
invoice you have to do following 3 activities.
1. Validate Invoice
2. Approve the Invoice
3. Create Accounting entries for Invoice

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

INVOICES
Here we will select the Invoice type and we will give the Supplier number, name, site invoice
date, invoice number, invoice currencies, and amount. Select Distributions button to distribute the
Invoice amount into different accounts.
1. Invoice total should be equal to the distributions total then we will call it as Invoice validated
successfully.
2. Select Actions…1 button chooses approve check box press OK then system will approve the
Invoice.
3. Select Actions…1 button choose create accounting check box press OK button it will create
the accounting entries we can see all this accounting transactions from tools view accounting
option.
SELECT * FROM AP_INVOICES_ALL WHERE INVOICE_NUM='INV4516' --
INVOICE_ID=63379 ,--VENDOR_ID(LINK B/WAP INVOICE AND PO_VENDORS

SELECT * FROM AP_INVOICE_DISTRIBUTIONS_ALL WHERE INVOICE_ID=63379

Invoice Holds:- If invoice is not approved then that invoice will be keeping under hold status.
By selecting holds button in invoice form we can see the holds details.

For view Invoice holds details:


Select * from ap_holds_all

For view release the Invoice holds names:


Select * from ap_holds_release_name_v;

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

PAYMENTS:
Payments:- Once the Invoice is approved then we can go for payments. The Payments are or 3
types. They were
1. Manual
2. Quick
3. Refund

Manual:- Here we will issue the checks manually to the supplier and we will capture that
information in the payment scheme by using manual payment option.

Quick:- Through the Quick Payment type we can generate checks through the system and we
can have the transactions directly in the system.

Refund:- When ever company is going to give advance back to the customer that time we will
select payment type as Refund.

Navigation steps for Payments:-


payments ==> payments

For view list of payments:


Select * from ap_invoice_payments_all;
Select * from ap_payment_schedules_all;

For check’s information:


Select * from ap_checks_all;

For check format:


Select * from ap_check_formats;
Select * from ap_checkrun_conc_processes_all;

Distribution Set:- It is one of the option is available in Invoices Screen. While creating the
Invoice we will attach distribution set. System will automatically create the transactions in
distributions forms as per the distribution set.
Navigation:

set-up =>invoice=> distribution set

To view Distribution sets at header level:


Select * from ap_distribution_sets_all;

To view Distribution sets at lines level:


Select * from ap_distribution_set_lines_all;

Transferring Transactions from AP to GL:-

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

We will execute the concurrent program from SRS Window. This program will transfer all
the payment transactions into the G.L Module. It will take following parameters.

Program Name:- Payables Transfer to General Ledger


Parameters:-
Set of Books Name
Transfer Reporting Book(s)
From Date
To Date
Journal Category

Validate Accounts
Transfer To GL Interface
Submit Journal Import : yes (It should be always YES)

To view from AP to GL:


Select * from gl_interface;

To view journal import details:


Select * from gl_je_headers à for Headers
Select * from gl_je_lines à for Lines
Select * from gl_je_batches à for Batches

To view posting:
Select * from gl_balances;

After submitting the request select viewà output button. It will shows number of transactions has
been transferred to G.L. then select G.L Module (General Ledger, Vision Operations (USA)).
SELECT * FROM GL_JE_HEADERS
SELECT * FROM GL_JE_LINES
SELECT * FROM GL_JE_BATCHES
SELECT * FROM GL_BALANCES

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

PO Approval History Query in Oracle apps


Action History of PO
SELECT prha.segment1 req, pha.segment1 po, gcc.segment3 acct,
acct_desc.description acct_desc, gcc.segment4 ctr,
ctr_desc.description ctr_desc, papf.full_name req_raised_by,
reqah.full_name req_last_approver, poah.full_name
po_last_approver,
pv.vendor_name supplier, pvsa.vendor_site_code site
FROM po.po_requisition_headers_all prha,
po.po_requisition_lines_all prla,
po.po_line_locations_all plla,
po.po_lines_all pla,
po.po_headers_all pha,
po.po_distributions_all pda,
gl.gl_code_combinations gcc,
apps.po_vendors pv,
apps.po_vendor_sites_all pvsa,
apps.fnd_flex_values_vl acct_desc,
apps.fnd_flex_values_vl ctr_desc,
hr.per_all_people_f papf,
(SELECT papf.full_name, pah.action_code, pah.object_id
FROM po.po_action_history pah,
po.po_requisition_headers_all prha,
applsys.fnd_user fu,
hr.per_all_people_f papf
WHERE object_id = prha.requisition_header_id
AND pah.employee_id = fu.employee_id
AND fu.employee_id = papf.person_id
AND SYSDATE BETWEEN papf.effective_start_date
AND papf.effective_end_date
AND pah.object_type_code = 'REQUISITION'
AND pah.action_code = 'APPROVE'
AND pah.sequence_num =
(SELECT MAX (sequence_num)
FROM po.po_action_history pah1
WHERE pah1.object_id = pah.object_id
AND pah1.object_type_code = 'REQUISITION'
AND pah1.action_code = 'APPROVE')) reqah,
(SELECT papf.full_name, pah.action_code, pah.object_id
FROM po.po_action_history pah,
po.po_headers_all pha,
applsys.fnd_user fu,
hr.per_all_people_f papf
WHERE object_id = pha.po_header_id
AND pah.employee_id = fu.employee_id
AND fu.employee_id = papf.person_id
AND SYSDATE BETWEEN papf.effective_start_date
AND papf.effective_end_date

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

AND pah.object_type_code = 'PO'


AND pah.action_code = 'APPROVE'
AND pah.sequence_num =
(SELECT MAX (sequence_num)
FROM po.po_action_history pah1
WHERE pah1.object_id = pah.object_id
AND pah1.object_type_code = 'PO'
AND pah1.action_code = 'APPROVE')) poah
WHERE prha.requisition_header_id = prla.requisition_header_id
AND prla.line_location_id = plla.line_location_id
AND plla.po_header_id = pla.po_header_id
AND pla.po_header_id = pha.po_header_id
AND pla.po_line_id = pda.po_line_id
AND pda.code_combination_id = gcc.code_combination_id
AND reqah.object_id = prha.requisition_header_id
AND poah.object_id = pha.po_header_id
AND prha.preparer_id = papf.person_id
AND gcc.segment3 = acct_desc.flex_value
AND gcc.segment4 = ctr_desc.flex_value
AND pha.vendor_id = pv.vendor_id
AND pha.vendor_site_id = pvsa.vendor_site_id
AND pv.vendor_id = pvsa.vendor_id
AND SYSDATE BETWEEN papf.effective_start_date AND
papf.effective_end_date
AND prha.creation_date >= '01-APR-2009'
AND prha.creation_date <= '03-APR-2009'
ORDER BY prha.segment1, gcc.segment4

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

PO to GL query
SELECT prh.segment1 req_number,
prd.distribution_id,
poh.segment1 po_num,
poh.org_id,
rsh.receipt_num,
api.invoice_num,
apl.line_number,
aps.vendor_name
FROM
-- Purchase Requisition --
po_requisition_headers_all prh,
po_requisition_lines_all prl,
po_req_distributions_all prd,

-- Purchase Order --
po_distributions_all pod,
po_headers_all poh,
po_lines_all pol,

-- Receipt --
rcv_transactions rct,
rcv_shipment_lines rsl,
rcv_shipment_headers rsh,

-- AP Invoice --
ap_invoice_distributions_all apd,
ap_invoice_lines_all apl,
ap_invoices_all api,

-- Subledger Accounting--
xla_distribution_links xldl,
apps.xla_ae_lines al,
xla_ae_headers ah,
apps.xla_events e,
apps.xla_transaction_entities te,

-- GL --
gl_import_references gir,
apps.gl_je_lines jl,
gl_je_headers glh,
apps.gl_code_combinations glcc,

-- Supplier Detail --
ap_suppliers aps
WHERE 1 = 1
-- Purchase Requisition --
AND prh.requisition_header_id = prl.requisition_header_id

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

AND prl.requisition_line_id = prd.requisition_line_id

-- Purchase Requisition TO Purchase Order --


AND prd.distribution_id = pod.req_distribution_id
-- Purchase Order --
AND pol.po_line_id = pod.po_line_id
AND poh.po_header_id = pol.po_header_id

-- Purchase Order TO Receipt --


AND pod.po_distribution_id = rct.po_distribution_id
-- Receipt --
AND rct.shipment_line_id = rsl.shipment_line_id
AND rsh.shipment_header_id = rsl.shipment_header_id

-- Receipt TO Invoice --
AND apd.po_distribution_id = rct.po_distribution_id
-- AP Invoice --
AND api.invoice_id = apd.invoice_id
AND api.invoice_id = apl.invoice_id

-- AP Invoice TO Sub ledger Accounting --


AND xldl.applied_to_source_id_num_1 = api.invoice_id
AND xldl.source_distribution_id_num_1 =
apd.invoice_distribution_id
-- Sub ledger Accounting --
AND xldl.ae_line_num = al.ae_line_num
AND xldl.ae_header_id = al.ae_header_id
AND al.ae_header_id = ah.ae_header_id
AND al.application_id = ah.application_id
AND ah.event_id = e.event_id
AND e.entity_id = te.entity_id(+)
AND e.application_id = te.application_id(+)
-- Subledger Accounting TO GL --
AND al.gl_sl_link_id = gir.gl_sl_link_id
-- GL ---
AND gir.je_header_id = jl.je_header_id
AND gir.je_line_num = jl.je_line_num
AND jl.je_header_id = glh.je_header_id
AND jl.code_combination_id = glcc.code_combination_id
-- Supplier Detail --
AND api.vendor_id = aps.vendor_id
AND ah.je_category_name = 'Purchase Invoices'
AND ah.gl_transfer_status_code= 'Y'
AND glh.STATUS='P'
-- AND api.invoice_num = 'BABU_TEST_INVOICE'
-- AND apl.line_number = 1

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Query to List all Purchase Orders with India Localization Tax attached
SELECT distinct pha.segment1 "Po Number",
pha.creation_date "Date",
pha.approved_date "Approved Date",
(pla.unit_price* pla.quantity) "Amount w/o Tax",
jpt.tax_amount "Tax Amount",
jpll.total_amount "Total Amount",
pla.line_num "Line Num",
pv.vendor_name"Vendor Name",
jrt.tax_name"Tax Name",
DECODE(NVL(PLLA.CLOSED_CODE,'OPEN'),'OPEN', NULL,
POLC1.DISPLAYED_FIELD)||
DECODE(PLLA.CANCEL_FLAG,'Y',','||''|| POLC2.DISPLAYED_FIELD,
NULL) "Po Line Status",
hou.name "Organization Name"
FROM po_headers_all pha,
po_lines_all pla,
po_line_locations_all plla,
po_vendors pv,
JAI_PO_LINE_LOCATIONS jpll,
hr_operating_units hou,
JAI_RCV_TAX_V jrt,
jai_po_taxes jpt,
PO_LOOKUP_CODES POLC1,
PO_LOOKUP_CODES POLC2
WHERE pha.po_header_id=pla.po_header_id
AND plla.po_header_id=pha.po_header_id
AND pv.vendor_id=pha.vendor_id
AND plla.po_line_id=pla.po_line_id
AND pha.segment1=:P_PONUM --'2012102020109'
AND jpll.po_header_id=pha.po_header_id
AND jpll.po_line_id=plla.po_line_id
AND pha.org_id= hou.organization_id
AND jrt.vendor_id=pha.vendor_id
AND jrt.tax_id= jpt.tax_id
AND jpt.po_header_id=pha.po_header_id
AND jpt.po_line_id=pla.po_line_id
AND PLLA.SHIPMENT_TYPE IN ('STANDARD', 'PLANNED', 'PRICE
BREAK','RFQ', 'QUOTATION')
AND POLC1.LOOKUP_TYPE(+) = 'DOCUMENT STATE'
AND POLC1.LOOKUP_CODE(+) = NVL(PLLA.CLOSED_CODE, 'OPEN')
AND POLC2.LOOKUP_TYPE (+) = 'DOCUMENT STATE'
AND POLC2.LOOKUP_CODE (+) = 'CANCELLED'
AND pha.po_header_id=plla.po_header_id
--AND jrt.tax_type=jpt.tax_type
--AND jpll.tax_category_id=jpt.tax_category_id
/*GROUP BY pha.segment1,
pha.creation_date,

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

pha.approved_date,
jpt.tax_amount ,
jpll.total_amount,
pla.line_num ,
pv.vendor_name,
jrt.tax_name,
DECODE(NVL(PLLA.CLOSED_CODE,'OPEN'),'OPEN', NULL,
POLC1.DISPLAYED_FIELD)||
DECODE(PLLA.CANCEL_FLAG,'Y',','||''|| POLC2.DISPLAYED_FIELD,
NULL),
hou.name*/

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Query to fetch Supplier Information


SELECT asp.vendor_name supplier_name,
asp.segment1 supplier_number,
ass.vendor_site_code supplier_site,
hou.name operating_unit,
decode(ass.pay_on_code,'RECEIPT',ass.pay_on_code,'')
pay_on_receipt_flag,
ass.pay_on_receipt_summary_code invoice_summary_level,
ieppm.payment_method_code
FROM ap_suppliers asp,
ap_supplier_sites_all ass,
hr_operating_units hou,
IBY_EXTERNAL_PAYEES_ALL iepa,
iby_ext_party_pmt_mthds ieppm
WHERE asp.vendor_id=ass.vendor_id
AND ass.org_id=hou.organization_id
AND iepa.supplier_site_id=ass.vendor_site_id
AND iepa.org_id=ass.org_id
AND iepa.ext_payee_id = ieppm.ext_pmt_party_id
AND ass.org_id in(81,82,83,155);

hope this will help to you.... keep watching this site for more updates or bookmark this site.

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Query to fetch requisition and PO are linked(Relation with Requisition and PO )


--Relation with Requistion and PO
select r.segment1 "Req Num",
p.segment1 "PO Num"
from po_headers_all p,
po_distributions_all d,
po_req_distributions_all rd,
po_requisition_lines_all rl,
po_requisition_headers_all r
where p.po_header_id = d.po_header_id
and d.req_distribution_id = rd.distribution_id
and rd.requisition_line_id = rl.requisition_line_id
and rl.requisition_header_id = r.requisition_header_id

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Query to list out all Internal Requisitions that do not have an associated Internal Sales order.
SELECT rqh.segment1 req_num, rql.line_num, rql.requisition_header_id,
rql.requisition_line_id, rql.item_id,
rql.unit_meas_lookup_code,
rql.unit_price, rql.quantity, rql.quantity_cancelled,
rql.quantity_delivered, rql.cancel_flag, rql.source_type_code,
rql.source_organization_id, rql.destination_organization_id,
rqh.transferred_to_oe_flag
FROM po_requisition_lines_all rql, po_requisition_headers_all rqh
WHERE rql.requisition_header_id = rqh.requisition_header_id
AND rql.source_type_code = 'INVENTORY'
AND rql.source_organization_id IS NOT NULL
AND NOT EXISTS (
SELECT 'existing internal order'
FROM oe_order_lines_all lin
WHERE lin.source_document_line_id = rql.requisition_line_id
AND lin.source_document_type_id = 10)
ORDER BY rqh.requisition_header_id, rql.line_num;

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Relation between Purchasing Requisition and PO tables


Relation between Requisition and PO tables,Here is link:
PO_DISTRIBUTIONS_ALL =>PO_HEADER_ID, REQ_DISTRIBUTION_ID
PO_HEADERS_ALL=>PO_HEADER_ID, SEGMENT1
PO_REQ_DISTRIBUTIONS_ALL =>DISTRIBUTION_ID, REQUISITION_LINE_ID
PO_REQUISITION_LINES_ALL =>REQUISITION_LINE_ID
PO_REQUISITION_HEADERS_ALL =>REQUISITION_HEADER_ID, REQUISITION_LINE_ID,
SEGMENT1

What you have to make a join on PO_DISTRIBUTIONS_ALL (REQ_DISTRIBUTION_ID) and


PO_REQ_DISTRIBUTIONS_ALL (DISTRIBUTION_ID) to see if there is a PO for the req.

RAJU CHINTHAPATLA
Oracle Purchasing, Payables and P2P Queries and Scripts Scripts

Checking Requisition Approval History for a specific member of staff


SELECT pah.action_code
, pah.object_id
, pah.action_date
, pah.sequence_num step
, pah.creation_date
, prha.segment1 req_num
, prha.wf_item_key
, prha.authorization_status
, fu.description
, papf.full_name hr_full_name
, papf.employee_number emp_no
, pj.NAME job
FROM po.po_action_history pah
, po.po_requisition_headers_all prha
, applsys.fnd_user fu
, hr.per_all_people_f papf
, hr.per_all_assignments_f paaf
, hr.per_jobs pj
WHERE object_id = prha.requisition_header_id
AND pah.employee_id = fu.employee_id
AND fu.employee_id = papf.person_id
AND papf.person_id = paaf.person_id
AND paaf.job_id = pj.job_id
AND paaf.primary_flag = 'Y'
AND SYSDATE BETWEEN papf.effective_start_date
ANDpapf.effective_end_date
AND SYSDATE BETWEEN paaf.effective_start_date
ANDpaaf.effective_end_date
AND pah.object_type_code = 'REQUISITION'
AND pah.action_code = 'APPROVE'
AND papf.full_name = :pn
ORDER BY pah.creation_date desc;

RAJU CHINTHAPATLA

Potrebbero piacerti anche