Tuesday, October 11, 2016

Query to get the Trace File Path of a Concurrent Program in Oracle Apps R12
-----------------------------------------------------------------------------------------------
 SELECT req.request_id, req.logfile_node_name node, req.oracle_process_id,
       req.enable_trace,
          dest.VALUE
       || '/'
       || LOWER (dbnm.VALUE)
       || '_ora_'
       || oracle_process_id
       || '.trc' trace_filename,
       prog.user_concurrent_program_name,
       phase_code, status_code
  FROM apps.fnd_concurrent_requests req,
       v$session ses,
       v$process proc,
       v$parameter dest,
       v$parameter dbnm,
       apps.fnd_concurrent_programs_vl prog,
       apps.fnd_executables execname
 WHERE 1 = 1
   AND req.request_id = 123456789 --Request ID
   AND req.oracle_process_id = proc.spid(+)
   AND proc.addr = ses.paddr(+)
   AND dest.NAME = 'user_dump_dest'
   AND dbnm.NAME = 'db_name'
   AND req.concurrent_program_id = prog.concurrent_program_id
   AND req.program_application_id = prog.application_id
   AND prog.application_id = execname.application_id
   AND prog.executable_id = execname.executable_id

Wednesday, April 16, 2014

Register a Concurrent Program from Back End in Oracle Apps R12

   =============================================
   Register a Concurrent Program Executable
   =============================================
BEGIN
   FND_PROGRAM.EXECUTABLE
                   ('AYAAN_ENTERPRISE_SOL'                       -- executable
                                          ,
                    'Ayaan Custom Application'                  -- application
                                              ,
                    'AYAAN_ENTERPRISE_SOL'                       -- short_name
                                          ,
                    'This is a Concurrent Progrram Executable'  -- description
                                                              ,
                    'PL/SQL Stored Procedure'              -- execution_method
                                             ,
                    'AES_PLSQL_PKG.MAIN'                -- execution_file_name
                                        ,
                    ''                                      -- subroutine_name
                      ,
                    ''                                  -- Execution File Path
                      ,
                    'US'                                      -- language_code
                        ,
                    ''
                   );
   COMMIT;
END;

   =============================================
   Register a Concurrent Program Definition
   =============================================
BEGIN
   FND_PROGRAM.REGISTER
                    ('Ayaan Enterprise Solution Program'            -- program
                                                        ,
                     'Ayaan Custom Application'                 -- application
                                               ,
                     'Y'                                             -- enable
                        ,
                     'AYAAN_ENTERPRISE_SOL'                      -- short_name
                                           ,
                     'This is a Concurrent Program Definition'  -- description
                                                              ,
                     'AYAAN_ENTERPRISE_SOL'           -- executable_short_name
                                           ,
                     'Ayaan  Custom Application'      -- executable_application
                                               ,
                     ''                                   -- execution_options
                       ,
                     ''                                            -- priority
                       ,
                     'Y'                                        -- save_output
                        ,
                     'Y'                                              -- print
                        ,
                     ''                                                -- cols
                       ,
                     ''                                                -- rows
                       ,
                     ''                                               -- style
                       ,
                     'N'                                     -- style_required
                        ,
                     ''                                             -- printer
                       ,
                     ''                                        -- request_type
                       ,
                     ''                            -- request_type_application
                       ,
                     'Y'                                         -- use_in_srs
                        ,
                     'N'                              -- allow_disabled_values
                        ,
                     'N'                                          -- run_alone
                        ,
                     'TEXT'                                     -- output_type
                           ,
                     'N'                                       -- enable_trace
                        ,
                     'Y'                                            -- restart
                        ,
                     'Y'                                      -- nls_compliant
                        ,
                     ''                                           -- icon_name
                       ,
                     'US'                                     -- language_code
                    );
   COMMIT;
END;

   =============================================
  Add a Concurrent Program to Request Group
   =============================================

BEGIN
   FND_PROGRAM.ADD_TO_GROUP
                       ('AYAAN_ENTERPRISE_SOL'           -- program_short_name
                                              ,
                        'Ayaan Custom Application'              -- application
                                                  ,
                        'Ayaan Purchasing Request Group'  -- Report Group Name
                                                        ,
                        'AESPO'                    -- Report Group Application
                       );
   COMMIT;
END;

Saturday, April 5, 2014

Interface Tables/Programs in Oracle Apps R12

=======================================================================
PO Requisition Creation
=======================================================================
## Interface Tables:

PO_REQUISITIONS_INTERFACE_ALL

## Error Table
PO_INTERRFACE_ERRORS

## Base Tables:

PO_REQUISITIONS_HEADERS_ALL                      
PO_REQUISITION_LINES_ALL      
PO_REQ_DISTRIBUTIONS_ALL

## Oracle Seeded Concurrent Program

   Requisition Import
 
=======================================================================
Purchase Orders Creation
=======================================================================
## Interface Tables:

PO_HEADERS_INTERFACE
PO_LINES_INTERFACE
PO_DISTRIBUTIONS_INTERFACE

## Error Table
PO_INTERRFACE_ERRORS

## Base Tables:

PO_HEADERS_ALL
PO_LINES_ALL
PO_DISTRIBUTIONS_ALL

## Oracle Seeded Concurrent Program

Import Standard Purchase Orders

=======================================================================
Sales Orders Creation
=======================================================================
## Interface Tables:

OE_HEADERS_IFACE_ALL
OE_LINES_IFACE_ALL

## Base Tables:

OE_ORDER_HEADERS_ALL
OE_ORDER_LINES_ALL

## Oracle Seeded Concurrent Program

 Order Import

=======================================================================
Price List Creation
=======================================================================
## Interface Tables:

QP_INTERFACE_LIST_HEADERS
QP_INTERFACE_LIST_LINES
QP_INTERFACE_PRICING_ATTRIBS

QP_INTERFACE_ERRORS

## Base Tables:

QP_LIST_HEADERS
QP_LIST_LINES
QP_PRICING_ATTRIBUTES

## Oracle Seeded Concurrent Program

QP: Bulk Import of Price List

=======================================================================
Customers Creation
=======================================================================
## Interface Tables:

RA_CUSTOMERS_INTERFACE_ALL
RA_CUSTOMER_PROFILES_INT_ALL
RA_CONTACT_PHONES_INT_ALL


## Base Tables:

HZ_PARTIES
HZ_PARTY_SITES
HZ_LOCATIONS
HZ_CUST_ACCOUNTS_ALL
HZ_CUST_ACCT_SITES_ALL
HZ_CUST_SITE_USES_ALL
HZ_CUSTOMER_PROFILES
HZ_CUST_PROFILE_CLASSES
HZ_PARTY_RELATIONSHIPS
HZ_CONTACT_POINTS
HZ_ORG_CONTACTS

## Oracle Seeded Concurrent Program

Customer Interface

=======================================================================
Items Creation
=======================================================================
## Interface Tables:

MTL_SYSTEM_ITEMS_INTERFACE
MTL_ITEM_REVISIONS_INTERFACE
MTL_ITEM_CATEGORIES_INTERFACE
MTL_INTERFACE_ERRORS

## Base Tables:

MTL_SYSTEM_ITEMS_B
MTL_ITEM_REVISIONS_B
MTL_CATEGORIES_B
MTL_CATEGORY_SETS_B
MTL_ITEM_STATUS
MTL_ITEM_TEMPLATES
   
## Oracle Seeded Concurrent Program

   Item Import
=======================================================================
Suppliers Creation
=======================================================================
## Interface Tables:

AP_SUPPILERS_INT
AP_SUPPLIER_SITES_INT
AP_SUP_SITE_CONTACTS_INT
AP_SUPPLIER_INT_REJECTIONS

## Base Tables:

AP_SUPPLIERS
AP_SUPPLIER_SITES_ALL
AP_SUPPLIER_CONTACTS

## Oracle Seeded Concurrent Program

Supplier Open Interface Import
Supplier Sites Open Interface Import
Supplier Site Contacts Open Interface Import

Friday, April 4, 2014

Oracle Seeded APIs in Oracle Apps R12

## Price List Creation APIs

QP_PRICE_LIST_PUB.PROCESS_PRICE_LIST
QP_PRICE_FORMULA_PUB.PROCESS_PRICE_FORMULA

## Sales Order Creation APIs

OE_ORDER_PUB.PROCESS_ORDER
OE_HOLD_PUB.APPLY_HOLDS

WSH_DELIVERY_DETAILS_PUB.AUTOCREATE_DELIVERIES
WSH_DELIVERIES_PUB.DELIVERY_ACTION
WSH_DELIVERY_DETAILS_PUB.UPDATE_SHIPPING_ATTRIBUTES
WSH_FREIGHT_COSTS_PUB.CREATE_UPDATE_FREIGHT_COSTS
WSH_CONTAINER_PUB.AUTO_PACK

## Item Creation API

EGO_ITEM_PUB.PROCESS_ITEM

EGO_ITEM_PUB.ASSIGN_ITEM_TO_ORG
INV_ITEM_CATEGORY_PUB.CREATE_CATEGORY
INV_ITEM_CATEGORY_PUB.CREATE_CATEGORY_ASSIGNMENT
INV_LOC_WMS_PUB.CREATE_LOCATOR

## Customer Creation APIs

HZ_CUST_ACCOUNT_V2PUB.CREATE_CUST_ACCOUNT
HZ_LOCATION_V2PUB.CREATE_LOCATION
HZ_PARTY_SITE_V2PUB.CREATE_PARTY_SITE
HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_ACCT_SITE
HZ_CUST_ACCOUNT_SITE_V2PUB.CREATE_CUST_SITE_USE
HZ_CUSTOMER_PROFILE_V2PUB.CREATE_CUST_PROFILE_AMT
HZ_CONTACT_POINT_V2PUB.CREATE_CONTACT_POINT
HZ_PARTY_V2PUB.CREATE_PERSON
HZ_PARTY_CONTACT_V2PUB.CREATE_ORG_CONTACT
HZ_PARTY_V2PUB.CREATE_ORGANIZATION

## Supplier Creation APIs
AP_VENDOR_PUB.CREATE_VENDOR
AP_VENDOR_PUB.CREATE_VENDOR_SITE
AP_VENDOR_PUB.CREATE_VENDOR_CONTACT

## Banks Creation APIs
IBY_EXT_BANKACCT_PUB.CREATE_EXT_BANK
IBY_EXT_BANKACCT_PUB.CREATE_EXT_BANK_BRANCH
IBY_EXT_BANKACCT_PUB.CREATE_EXT_BANK_ACCT
-- IBY_DISBURSEMENT_SETUP_PUB.Create_External_Payee
-- IBY_DISBURSEMENT_SETUP_PUB.Set_Payee_Instr_Assignment

## AR Invoice Creation API

AR_INVOICE_API_PUB.CREATE_INVOICE

## AR CAsh Receipt Creation APIs

AR_RECEIPT_API_PUB.CREATE_CASH
AR_RECEIPT_API_PUB.APPLY
AR_RECEIPT_API_PUB.APPLY_IN_DETAIL
AR_RECEIPT_API_PUB.UNAPPLY
AR_RECEIPT_API_PUB.CREATE_AND_APPLY
AR_RECEIPT_API_PUB.APPLY_ON_ACCOUNT
AR_RECEIPT_API_PUB.UNAPPLY_ON_ACCOUNT
AR_RECEIPT_API_PUB.ACTIVITY_APPLICATION
AR_RECEIPT_API_PUB.ACTIVITY_UNAPPLICATION
AR_RECEIPT_API_PUB.CREATE_MISC
AR_RECEIPT_API_PUB.APPLY_OPEN_RECEIPT
AR_RECEIPT_API_PUB.UNAPPLY_OPEN_RECEIPT

## Employee Creations APIs

HR_EMPLOYEE_API.CREATE_EMPLOYEE
HR_PERSON_API.UPDATE_PERSON
HR_CONTACT_REL_API.CREATE_CONTACT
HR_EMPLOYEE_API.HIRE_INTO_JOB
HR_ASSIGNMENT_API.UPDATE_EMP_ASG
HR_ASSIGNMENT_API.UPDATE_EMP_ASG_CRITERIA
HR_PERSON_ADDRESS_API.CREATE_PERSON_ADDRESS
HR_PERSON_ADDRESS_API.UPDATE_PERSON_ADDRESS
PAY_ELEMENT_ENTRY_API.CREATE_ELEMENT_ENTRY
PAY_ELEMENT_ENTRY_API.DELETE_ELEMENT_ENTRY
HR_EMPLOYEE_API.RE_HIRE_EX_EMPLOYEE
HR_PERSONAL_PAY_METHOD_API.CREATE_PERSONAL_PAY_METHOD
HR_PHONE_API.CREATE_OR_UPDATE_PHONE
HR_MAINTAIN_PROPOSAL_API.CRE_OR_UPD_SALARY_PROPOSAL

## Fnd User Creation APIs
FND_USER_PKG.CREATEUSER
FND_USER_PKG.UPDATEUSER
FND_USER_PKG.ADDRESP
FND_USER_PKG.DELRESP



For POC Scripts, Refer the below blog:
https://blogs.oracle.com/prajkumar/

Sunday, March 30, 2014

Add System Administrator Responsibility to a User from Back end in Oracle Apps R12

BEGIN
   FND_USER_PKG.ADDRESP
                       ('YOUR_USERNAME',
                        'SYSADMIN',
                        'SYSTEM_ADMINISTRATOR',
                        'STANDARD',
                        'Add Sysadmin Responsibility to A user from Backend',
                        SYSDATE - 1,
                        SYSDATE + 99
                       );
   COMMIT;
   DBMS_OUTPUT.PUT_LINE ('Responsibility Added Successfully');
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.PUT_LINE (   ' Sys Admin Resp cannot be added: '
                            || SQLCODE
                            || SUBSTR (SQLERRM, 1, 100)
                           );
END;

Friday, March 28, 2014

Query to get Concurrent Program's Parameters, Value Sets and Default Values in Oracle Apps R12

SELECT fcpl.user_concurrent_program_name
      , fcp.concurrent_program_name
      , fav.APPLICATION_SHORT_NAME
      , fav.APPLICATION_NAME
      , fav.application_id
      , fdfcuv.end_user_column_name
      , fdfcuv.form_left_prompt prompt
      , fdfcuv.enabled_flag
      , fdfcuv.required_flag
      , fdfcuv.display_flag
      , fdfcuv.flex_value_set_id
      , ffvs.flex_value_set_name
      , flv.meaning default_type
      , fdfcuv.DEFAULT_VALUE    
 FROM   apps.fnd_concurrent_programs fcp
      , fnd_concurrent_programs_tl fcpl
      , fnd_descr_flex_col_usage_vl fdfcuv
      , fnd_flex_value_sets ffvs
      , fnd_lookup_values flv
      , fnd_application_vl fav
 WHERE  fcp.concurrent_program_id = fcpl.concurrent_program_id
 AND    fcpl.LANGUAGE = 'US'
 AND    fav.application_id=fcp.application_id
 AND    fdfcuv.descriptive_flexfield_name = '$SRS$.' || fcp.concurrent_program_name
 AND    ffvs.flex_value_set_id = fdfcuv.flex_value_set_id
 AND    flv.lookup_type(+) = 'FLEX_DEFAULT_TYPE'
 AND    flv.lookup_code(+) = fdfcuv.default_type
 AND    flv.LANGUAGE(+) = USERENV ('LANG')
 AND    fcpl.user_concurrent_program_name LIKE 'WIP Value Report'

Monday, March 24, 2014

PO Queries in Oracle Apps

Purchase Requisition details
====================================================
SELECT prh.segment1 "Req #", prh.creation_date, prh.created_by,
       poh.segment1 "PO #", ppx.full_name "Requestor Name",
       prh.description "Req Description", prh.authorization_status,
       prh.note_to_authorizer, prh.type_lookup_code, prl.line_num,
       prl.line_type_id, prl.item_description, prl.unit_meas_lookup_code,
       prl.unit_price, prl.quantity, prl.quantity_delivered, prl.need_by_date,
       prl.note_to_agent, prl.currency_code, prl.rate_type, prl.rate_date,
       prl.quantity_cancelled, prl.cancel_date, prl.cancel_reason
  FROM po_requisition_headers_all prh,
       po_requisition_lines_all prl,
       po_req_distributions_all prd,
       per_people_x ppx,
       po_headers_all poh,
       po_distributions_all pda
 WHERE prh.requisition_header_id = prl.requisition_header_id
   AND ppx.person_id = prh.preparer_id
   AND prh.type_lookup_code = 'PURCHASE'
   AND prd.requisition_line_id = prl.requisition_line_id
   AND pda.req_distribution_id = prd.distribution_id
   AND pda.po_header_id = poh.po_header_id
  -- AND TO_CHAR (prh.creation_date, 'YYYY') IN ('2010', '2011')
 
Internal Requisition details
====================================================
SELECT prh.segment1 "Req #", prh.creation_date, prh.created_by,
       poh.segment1 "PO #", ppx.full_name "Requestor Name",
       prh.description "Req Description", prh.authorization_status,
       prh.note_to_authorizer, prl.line_num, prl.line_type_id,
       prl.source_type_code, prl.item_description, prl.unit_meas_lookup_code,
       prl.unit_price, prl.quantity, prl.quantity_delivered, prl.need_by_date,
       prl.note_to_agent, prl.currency_code, prl.rate_type, prl.rate_date,
       prl.quantity_cancelled, prl.cancel_date, prl.cancel_reason
  FROM po_requisition_headers_all prh,
       po_requisition_lines_all prl,
       po_req_distributions_all prd,
       per_people_x ppx,
       po_headers_all poh,
       po_distributions_all pda
 WHERE prh.requisition_header_id = prl.requisition_header_id
   AND ppx.person_id = prh.preparer_id
   AND prh.type_lookup_code = 'INTERNAL'
   AND prd.requisition_line_id = prl.requisition_line_id
   AND pda.req_distribution_id(+) = prd.distribution_id
   AND pda.po_header_id = poh.po_header_id(+)
   AND TO_CHAR (prh.creation_date, 'YYYY') IN ('2010', '2011')
 
Purchase Order details
====================================================
-- Purchase Orders for non inventory items like service
SELECT ph.segment1 po_num, ph.creation_date, hou.NAME "Operating Unit",
       ppx.full_name "Buyer Name", ph.type_lookup_code "PO Type",
       plc.displayed_field "PO Status", ph.comments, pl.line_num,
       plt.order_type_lookup_code "Line Type", NULL "Item Code",
       pl.item_description, pl.unit_meas_lookup_code "UOM",
       pl.base_unit_price, pl.unit_price, pl.quantity,
       ood.organization_code "Shipment Org Code",
       ood.organization_name "Shipment Org Name", pv.vendor_name supplier,
       pvs.vendor_site_code, (pl.unit_price * pl.quantity) "Line Amount",
       prh.segment1 req_num, prh.type_lookup_code req_method,
       ppx1.full_name "Requisition requestor"
  FROM po_headers_all ph,
       po_lines_all pl,
       po_distributions_all pda,
       po_vendors pv,
       po_vendor_sites_all pvs,
       po_distributions_all pd,
       po_req_distributions_all prd,
       po_requisition_lines_all prl,
       po_requisition_headers_all prh,
       hr_operating_units hou,
       per_people_x ppx,
       po_line_types_b plt,
       org_organization_definitions ood,
       per_people_x ppx1,
       po_lookup_codes plc
 WHERE 1 = 1
   AND TO_CHAR (ph.creation_date, 'YYYY') IN (2010, 2011)
   AND ph.vendor_id = pv.vendor_id
   AND ph.po_header_id = pl.po_header_id
   AND ph.vendor_site_id = pvs.vendor_site_id
   AND ph.po_header_id = pd.po_header_id
   AND pl.po_line_id = pd.po_line_id
   AND pd.req_distribution_id = prd.distribution_id(+)
   AND prd.requisition_line_id = prl.requisition_line_id(+)
   AND prl.requisition_header_id = prh.requisition_header_id(+)
   AND hou.organization_id = ph.org_id
   AND ph.agent_id = ppx.person_id
   AND pda.po_header_id = ph.po_header_id
   AND pda.po_line_id = pl.po_line_id
   AND pl.line_type_id = plt.line_type_id
   AND ood.organization_id = pda.destination_organization_id
   AND ppx1.person_id(+) = prh.preparer_id
   AND plc.lookup_type = 'DOCUMENT STATE'
   AND plc.lookup_code = ph.closed_code
   AND pl.item_id IS NULL
UNION
-- Purchase Orders for inventory items
SELECT ph.segment1 po_num, ph.creation_date, hou.NAME "Operating Unit",
       ppx.full_name "Buyer Name", ph.type_lookup_code "PO Type",
       plc.displayed_field "PO Status", ph.comments, pl.line_num,
       plt.order_type_lookup_code "Line Type", msi.segment1 "Item Code",
       pl.item_description, pl.unit_meas_lookup_code "UOM",
       pl.base_unit_price, pl.unit_price, pl.quantity,
       ood.organization_code "Shipment Org Code",
       ood.organization_name "Shipment Org Name", pv.vendor_name supplier,
       pvs.vendor_site_code, (pl.unit_price * pl.quantity) "Line Amount",
       prh.segment1 req_num, prh.type_lookup_code req_method,
       ppx1.full_name "Requisition requestor"
  FROM po_headers_all ph,
       po_lines_all pl,
       po_distributions_all pda,
       po_vendors pv,
       po_vendor_sites_all pvs,
       po_distributions_all pd,
       po_req_distributions_all prd,
       po_requisition_lines_all prl,
       po_requisition_headers_all prh,
       hr_operating_units hou,
       per_people_x ppx,
       mtl_system_items_b msi,
       po_line_types_b plt,
       org_organization_definitions ood,
       per_people_x ppx1,
       po_lookup_codes plc
 WHERE 1 = 1
   AND TO_CHAR (ph.creation_date, 'YYYY') IN (2010, 2011)
   AND ph.vendor_id = pv.vendor_id
   AND ph.po_header_id = pl.po_header_id
   AND ph.vendor_site_id = pvs.vendor_site_id
   AND ph.po_header_id = pd.po_header_id
   AND pl.po_line_id = pd.po_line_id
   AND pd.req_distribution_id = prd.distribution_id(+)
   AND prd.requisition_line_id = prl.requisition_line_id(+)
   AND prl.requisition_header_id = prh.requisition_header_id(+)
   AND hou.organization_id = ph.org_id
   AND ph.agent_id = ppx.person_id
   AND pda.po_header_id = ph.po_header_id
   AND pda.po_line_id = pl.po_line_id
   AND pl.line_type_id = plt.line_type_id
   AND ood.organization_id = pda.destination_organization_id
   AND ppx1.person_id(+) = prh.preparer_id
   AND pda.destination_organization_id = msi.organization_id(+)
   AND msi.inventory_item_id = NVL (pl.item_id, msi.inventory_item_id)
   AND plc.lookup_type = 'DOCUMENT STATE'
   AND plc.lookup_code = ph.closed_code
   AND pl.item_id IS NOT NULL

Receiving transactions with PO and requisition information
====================================================
SELECT   ph.segment1 po_num, ood.organization_name, pol.po_line_id,
         pll.quantity, rsh.receipt_source_code, rsh.vendor_id,
         rsh.vendor_site_id, rsh.organization_id, rsh.shipment_num,
         rsh.receipt_num, rsh.ship_to_location_id, rsh.bill_of_lading,
         rsl.shipment_line_id, rsl.quantity_shipped, rsl.quantity_received,
         rct.transaction_type, rct.transaction_id,
         NVL (rct.source_doc_quantity, 0) transaction_qty
    FROM rcv_transactions rct,
         rcv_shipment_headers rsh,
         rcv_shipment_lines rsl,
         po_lines_all pol,
         po_line_locations_all pll,
         po_headers_all ph,
         org_organization_definitions ood
   WHERE 1 = 1
     AND TO_CHAR (rct.creation_date, 'YYYY') IN ('2010', '2011')
     AND rct.po_header_id = ph.po_header_id
     AND rct.po_line_location_id = pll.line_location_id
     AND rct.po_line_id = pol.po_line_id
     AND rct.shipment_line_id = rsl.shipment_line_id
     AND rsl.shipment_header_id = rsh.shipment_header_id
     AND rsh.ship_to_org_id = ood.organization_id
ORDER BY rct.transaction_id  


Cancel Requisitions
====================================================

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
 
Internal Requisitions that do not have an associated Internal Sales Order
====================================================
 
   SELECT   rqh.segment1, 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

Relation with Requisition 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
 
Purchase Requisition without a Purchase Order
====================================================

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.pl_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

Requisition moved from different stages till converting into PR
====================================================

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
     
 PO’s which does not have any PR
====================================================
      
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    

All Open Purchase Orders
====================================================

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')
 
All POs with Approval, Invoice & 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
   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'
 
Po Which are not received for a perticular Preparer
====================================================

SELECT p.po_header_id po_header_id, r.segment1 req_number,
       p.segment1 po_number
  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
   AND r.preparer_id = 12345
   AND p.po_header_id NOT IN (
          SELECT po_header_id
            FROM apps.rcv_transactions
           WHERE po_header_id IN (
                    SELECT   p.po_header_id po_header_id
                        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
                         AND r.preparer_id = 12345
                    GROUP BY p.po_header_id))