imp queries

33
IMP QUERIES Written by Administrator Thursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16 OM ADVANCE PRICING QUERY SELECT QPSEG.SEGMENT_MAPPING_COLUMN, QPSOUR.USER_SOURCING_TYPE, QPSOUR.USER_VALUE_STRING, QPCON.PRC_CONTEXT_CODE, QPSOUR.ATTRIBUTE_SOURCING_LEVEL, QPSOUR.REQUEST_TYPE_CODE, QPREQ.PTE_CODE, QPCON.PRC_CONTEXT_TYPE, QPSEG.SEGMENT_CODE, QPCON.SEEDED_FLAG CONTEXT_SEEDED_FLAG, QPSEG.SEEDED_FLAG ATTRIBUTE_SEEDED_FLAG FROM QP_SEGMENTS_B QPSEG, QP_ATTRIBUTE_SOURCING QPSOUR, QP_PRC_CONTEXTS_B QPCON, QP_PTE_REQUEST_TYPES_B QPREQ, QP_PTE_SEGMENTS QPPSEG WHERE QPSOUR.SEGMENT_ID = QPSEG.SEGMENT_ID AND QPPSEG.USER_SOURCING_METHOD = ‘ATTRIBUTE MAPPING’ AND QPSOUR.REQUEST_TYPE_CODE = ‘ONT’ AND QPSEG.PRC_CONTEXT_ID = QPCON.PRC_CONTEXT_ID AND QPREQ.REQUEST_TYPE_CODE = QPSOUR.REQUEST_TYPE_CODE AND QPPSEG.PTE_CODE = QPREQ.PTE_CODE AND QPPSEG.SEGMENT_ID = QPSOUR.SEGMENT_ID AND QPPSEG.SOURCING_ENABLED = ‘Y’ AND QPCON.PRC_CONTEXT_TYPE IN (‘PRICING_ATTRIBUTE’, ‘PRODUCT’, ‘QUALIFIER’) OM SALES ORDER REPORT select oha.header_id,bill_ca.cust_account_id, oha.order_number, oha.ordered_date, oha.cust_po_number customer_po, oha.org_id, ott.name order_type, ola.line_number, msi.segment1 item_code, msi.description item_desc, ola.ordered_quantity, ola.order_quantity_uom, oha.transactional_curr_code trx_curr, ola.unit_selling_price, (ola.ordered_quantity*ola.unit_selling_price) line_amt, ola.shipping_quantity, ola.shipping_quantity_uom, (nvl(ola.shipping_quantity,0)*ola.unit_selling_price) shipped_amt, ola.schedule_ship_date, --oha.flow_status_code order_status, ol.meaning order_status, bill_p.party_name, 1 / 33

Upload: u4rishi

Post on 01-Dec-2015

105 views

Category:

Documents


8 download

DESCRIPTION

Queries

TRANSCRIPT

Page 1: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

OM ADVANCE PRICING QUERYSELECT QPSEG.SEGMENT_MAPPING_COLUMN, QPSOUR.USER_SOURCING_TYPE,QPSOUR.USER_VALUE_STRING, QPCON.PRC_CONTEXT_CODE,QPSOUR.ATTRIBUTE_SOURCING_LEVEL, QPSOUR.REQUEST_TYPE_CODE,QPREQ.PTE_CODE, QPCON.PRC_CONTEXT_TYPE, QPSEG.SEGMENT_CODE,QPCON.SEEDED_FLAG CONTEXT_SEEDED_FLAG,QPSEG.SEEDED_FLAG ATTRIBUTE_SEEDED_FLAGFROM QP_SEGMENTS_B QPSEG,QP_ATTRIBUTE_SOURCING QPSOUR,QP_PRC_CONTEXTS_B QPCON,QP_PTE_REQUEST_TYPES_B QPREQ,QP_PTE_SEGMENTS QPPSEGWHERE QPSOUR.SEGMENT_ID = QPSEG.SEGMENT_IDAND QPPSEG.USER_SOURCING_METHOD = ‘ATTRIBUTE MAPPING’AND QPSOUR.REQUEST_TYPE_CODE = ‘ONT’AND QPSEG.PRC_CONTEXT_ID = QPCON.PRC_CONTEXT_IDAND QPREQ.REQUEST_TYPE_CODE = QPSOUR.REQUEST_TYPE_CODEAND QPPSEG.PTE_CODE = QPREQ.PTE_CODEAND QPPSEG.SEGMENT_ID = QPSOUR.SEGMENT_IDAND QPPSEG.SOURCING_ENABLED = ‘Y’AND QPCON.PRC_CONTEXT_TYPE IN(‘PRICING_ATTRIBUTE’, ‘PRODUCT’, ‘QUALIFIER’)OM SALES ORDER REPORTselect oha.header_id,bill_ca.cust_account_id,oha.order_number,oha.ordered_date,oha.cust_po_number customer_po,oha.org_id,ott.name order_type,ola.line_number,msi.segment1 item_code,msi.description item_desc,ola.ordered_quantity,ola.order_quantity_uom,oha.transactional_curr_code trx_curr,ola.unit_selling_price,(ola.ordered_quantity*ola.unit_selling_price) line_amt,ola.shipping_quantity,ola.shipping_quantity_uom,(nvl(ola.shipping_quantity,0)*ola.unit_selling_price) shipped_amt,ola.schedule_ship_date,--oha.flow_status_code order_status,ol.meaning order_status,bill_p.party_name,

1 / 33

Page 2: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

bill_su.LOCATION invoice_to_location,bill_loc.address1 invoice_to_address1,bill_loc.address2 invoice_to_address2,bill_loc.address3 invoice_to_address3,bill_loc.address4 invoice_to_address4,DECODE (bill_loc.city,NULL, NULL,bill_loc.city || ', ')|| DECODE (bill_loc.state,NULL, bill_loc.province || ', ',bill_loc.state || ', ')|| DECODE (bill_loc.postal_code,NULL, NULL,bill_loc.postal_code || ', ')|| DECODE (bill_loc.country, NULL, NULL, bill_loc.country) invoice_to_address5,ship_loc.city ship_city,ship_loc.country ship_country_code,ft.territory_short_name ship_country,(select namefrom ra_salesreps_allwhere salesrep_id = oha.salesrep_idand org_id = oha.org_id) sales_person,--wd.date_scheduled,oha.conversion_type_codefrom oe_order_headers_all oha,oe_order_lines_all ola,oe_transaction_types_tl ott,mtl_system_items_b msi,hz_cust_site_uses_all bill_su,hz_party_sites bill_ps,hz_locations bill_loc,hz_cust_acct_sites_all bill_cas,hz_cust_accounts bill_ca,hz_parties bill_p,hz_cust_site_uses_all ship_su,hz_party_sites ship_ps,hz_locations ship_loc,hz_cust_acct_sites_all ship_cas,--    wsh_deliverables_v wdfnd_territories_tl ft,oe_lookups olwhere oha.org_id = nvl(:p_org_id,oha.org_id)and trunc(oha.ordered_date) between nvl(:p_order_date_from,trunc(oha.ordered_date))

2 / 33

Page 3: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

and nvl(:p_order_date_to,trunc(oha.ordered_date))and bill_ca.cust_account_id between nvl(:p_cust_acc_id_from,trunc(bill_ca.cust_account_id))and nvl(:p_cust_acc_id_to,trunc(bill_ca.cust_account_id))and trunc(NVL(ola.schedule_ship_date,SYSDATE)) betweennvl(:p_delvry_date_from,trunc(NVL(ola.schedule_ship_date,SYSDATE)))and nvl(:p_delvry_date_to,trunc(NVL(ola.schedule_ship_date,SYSDATE)))--and oha.flow_status_code between nvl(:p_order_status_from,oha.flow_status_code)--and nvl(:p_order_status_to,oha.flow_status_code)and ol.meaning between nvl(:p_order_status_from,ol.meaning)and nvl(:p_order_status_to,ol.meaning)and msi.inventory_item_id between nvl(:p_prod_desc_from,msi.inventory_item_id)and nvl(:p_prod_desc_to,msi.inventory_item_id) /*and msi.description between nvl(:p_prod_desc_from,msi.description)and nvl(:p_prod_desc_to,msi.description) */and ship_loc.country between nvl(:p_ship_country_from,ship_loc.country)and nvl(:p_ship_country_to,ship_loc.country)and oha.salesrep_id between nvl(:p_salesrep_id_from,oha.salesrep_id)and nvl(:p_salesrep_id_to,oha.salesrep_id)and oha.header_id = ola.header_idand oha.ORDER_TYPE_ID = ott.transaction_type_idand ott.language = userenv('LANG')and ola.inventory_item_id = msi.inventory_item_idand ola.ship_from_org_id = msi.organization_idand oha.invoice_to_org_id = bill_su.site_use_id(+)and bill_su.cust_acct_site_id = bill_cas.cust_acct_site_id(+)and bill_cas.party_site_id = bill_ps.party_site_id(+)and bill_loc.location_id(+) = bill_ps.location_idand bill_cas.cust_account_id = bill_ca.cust_account_idand bill_ca.party_id = bill_p.party_idand oha.ship_to_org_id = ship_su.site_use_id(+)and ship_su.cust_acct_site_id = ship_cas.cust_acct_site_id(+)and ship_cas.party_site_id = ship_ps.party_site_id(+)and ship_loc.location_id(+) = ship_ps.location_id--   and oha.header_id = wd.source_header_id(+)--   and ola.line_id = wd.source_line_id(+)and ship_loc.country = ft.territory_codeand ft.language = userenv('LANG')and ol.lookup_type = 'FLOW_STATUS'and ol.lookup_code = oha.flow_status_code--and oha.order_number = 21019INV ORGIN REPORTSELECT  msib.inventory_item_id,msib.organization_id              "Warehouse_Code",msib.segment1                     "Item",msib.description                  "Item_Desc",mtln.lot_number

3 / 33

Page 4: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

,msib.primary_uom_code             "UOM",msib.primary_unit_of_measure,msib.inventory_item_status_code,msib.item_type,msib.default_so_source_type,mmt.transaction_id,mmt.subinventory_code,mmt.transfer_subinventory,mmt.attribute1                    "Ship_to_warehouse_id",(select od.organization_name from org_organization_definitions od where od.organization_id=mmt.attribute1 ) ship_to_warehouse,mmt.attribute2 shipment_reference,ood.organization_code,ood.organization_name                     Warehouse,TO_CHAR(TO_DATE(mmt.attribute3 ,'YYYY/MM/DD HH24:MI:SS'),'DD-MON-YYYY')shipment_date,ABS(mmt.transaction_quantity) quantity,mmt.transaction_uom   --,mmt.actual_cost--,mmt.prior_cost--,mmt.new_cost,( hou.address_line_1 ||''||address_line_2||''||address_line_3||''||region_1||''||region_2||''||region_3||''||telephone_number_1||''||telephone_number_2||''||telephone_number_3||''||postal_code||''||town_or_city||''||country)ship_to_adderss--,mmt.locator_id,mmt.currency_codeFROM    mtl_system_items_b              msib,mtl_material_transactions       mmt,mtl_transaction_lot_numbers     mtln,hr_organization_units_v         hou,org_organization_definitions    oodWHERE   msib.inventory_item_id=mmt.inventory_item_idAND     msib.organization_id=mmt.organization_idAND     msib.organization_id=ood.organization_idAND     mmt.attribute1=hou.organization_id(+)--AND     mmt.transaction_id=185011--162022--178029AND     ood.organization_code=:inventory_org--parametors

4 / 33

Page 5: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

--AND     mmt.attribute3 BETWEEN :from_date AND :to_date--parametorsAND     TO_CHAR(TO_DATE(mmt.attribute3 ,'YYYY/MM/DD HH24:MI:SS'),'DD-MON-YYYY') BETWEEN NVL(:from_date,TO_CHAR(TO_DATE(mmt.attribute3 ,'YYYY/MM/DDHH24:MI:SS'),'DD-MON-YYYY') ) AND NVL(:to_date,TO_CHAR(TO_DATE(mmt.attribute3 ,'YYYY/MM/DDHH24:MI:SS'),'DD-MON-YYYY') )AND     mmt.transaction_id=mtln.transaction_idAND     mmt.subinventory_code like 'IWM'AP CHECKS STATUS INFORMATIONSELECT    PVS.Attribute6 "SUPPLIER SITE TYPE",GSOB.NAME "SET OF BOOKS NAME",AC.CHECK_NUMBER,AC.CHECK_DATE,TRUNC(SYSDATE-AC.CHECK_DATE) "AGE OF CHECK",AI.PAYMENT_CURRENCY_CODE "PAYMENT CURRENCY CODE",AC.AMOUNT "CHECK AMOUNT",AIA.INVOICE_NUM "INVOICE NUMBER",AI.INVOICE_CURRENCY_CODE "INVOICE CURRENCY CODE",AI.AMOUNT_PAID "INVOICE AMOUNT PAID",PV.VENDOR_NAME "SUPPLIER NAME",PVS.VENDOR_SITE_CODE "SUPPLIER SITE CODE",AID.DESCRIPTION "DESCRIPTION",PVS.ADDRESS_LINE1 "ADDRESS LINE1",PVS.ADDRESS_LINE2 "ADDRESS LINE2",PVS.ADDRESS_LINE3 "ADDRESS LINE3",PVS.CITY "CITY",PVS.STATE "STATE",PVS.ZIP "ZIP"FROM   PO_VENDOR_SITES PVS,GL_SETS_OF_BOOKS GSOB,AP_CHECKS AC,AP_INVOICES AI,AP_INVOICES_ALL AIA,PO_VENDORS PV,AP_INVOICE_DISTRIBUTIONS AIDSELECT TAX JOURNALSSELECTGLJH.JE_HEADER_ID "HID",GLJH.TAX_STATUS_CODE "TC",GLJL.TAX_CODE_ID "ID",TO_CHAR(GLJH.LAST_UPDATE_DATE,'DD-MON-YYYY') "UPDATE_DATE"FROM GL_JE_HEADERS GLJH,GL_JE_LINES GLJL,GL_CODE_COMBINATIONS GLCC,GL_JE_BATCHES GLJBWHERE

5 / 33

Page 6: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

GLJH.JE_HEADER_ID=GLJL.JE_HEADER_ID ANDGLJL.CODE_COMBINATION_ID=GLCC.CODE_COMBINATION_ID ANDGLJH.JE_BATCH_ID=GLJB.JE_BATCH_ID ANDGLJH.TAX_STATUS_CODE='T'order by GLJH.JE_HEADER_ID;INVOICE PAYMENT CHECKSELECT --PVSA.ADDRESS_LINE1 "SUPPLIER SITE TYPE"GSOBA.NAME "SET OF BOOKS NAME",ACA.CHECK_NUMBER "CHECK NUMBER",ACA.CHECK_DATE "CHECK DATE",TRUNC(SYSDATE-ACA.CHECK_DATE) "AGE OF CHECK",AIA.PAYMENT_CURRENCY_CODE "PAYMENT CURRENCY CODE",ACA.AMOUNT "CHECK AMOUNT",AIA.INVOICE_NUM "INVOICE NUMBER",AIA.INVOICE_CURRENCY_CODE "INVOICE CURRENCY CODE",AIA.AMOUNT_PAID "INVOICE AMOUNT PAID",PV.VENDOR_NAME "SUPPLIER NAME",PVSA.VENDOR_SITE_CODE "SUPPLIER SITE CODE",AIDA.DESCRIPTION "DESCRIPTION",PVSA.ADDRESS_LINE1 "ADDRESS LINE1",PVSA.ADDRESS_LINE2 "ADDRESS LINE2",PVSA.ADDRESS_LINE3 "ADDRESS LINE3",PVSA.CITY "CITY",PVSA.STATE "STATE",PVSA.ZIP "ZIP"FROM AP_INVOICES_ALL AIA,AP_CHECKS_ALL ACA,AP_INVOICE_PAYMENTS_ALL AIPA,AP_INVOICE_DISTRIBUTIONS_ALL AIDA,PO_DISTRIBUTIONS_ALL PDA,PO_VENDOR_SITES_ALL PVSA,PO_VENDORS PV,GL_SETS_OF_BOOKS GSOBAWHERE AIPA.CHECK_ID=ACA.CHECK_IDAND AIA.INVOICE_ID=AIPA.INVOICE_IDAND AIA.INVOICE_ID=AIDA.INVOICE_IDAND PV.VENDOR_ID=PVSA.VENDOR_IDAND AIA.VENDOR_ID=PV.VENDOR_IDAND AIDA.PO_DISTRIBUTION_ID=PDA.PO_DISTRIBUTION_IDAND AIA.SET_OF_BOOKS_ID=GSOBA.SET_OF_BOOKS_IDSales invoiceSELECT hou.NAME operating_unit_name,rct.trx_number sales_invoice_number,ooh.order_number,rc.customer_name,rsa.NAME sales_person_name,

6 / 33

Page 7: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

msi.segment1 item_number,mln.lot_number,msi.primary_unit_of_measure primary_uom,ool.ordered_quantity primary_quantity,msi.secondary_uom_code secondary_uom,ool.ordered_quantity2 secondary_quantity,msi.organization_id inventory_org_id,ool.org_id,rctl.extended_amount amountFROM oe_order_headers_all ooh,oe_order_lines_all ool,hr_operating_units hou,ra_customer_trx_all rct,ra_customer_trx_lines_all rctl,ra_customers rc,ra_salesreps_all rsa,mtl_system_items_b msi,mtl_lot_numbers mlnWHERE ooh.header_id = ool.header_idAND hou.organization_id = ool.org_idAND ool.reference_customer_trx_line_id = rctl.customer_trx_line_idAND rct.sold_to_customer_id = rc.customer_idAND ooh.salesrep_id = rsa.salesrep_idAND mln.inventory_item_id = msi.inventory_item_idAND mln.organization_id = msi.organization_idReceiptSELECT ACR.RECEIPT_NUMBER,ARM.NAME RECEIPT_METHOD,ACR.RECEIPT_DATE,ACRH.GL_DATE,ABB.BANK_NAME,ABA.BANK_ACCOUNT_NUM,HP.PARTY_NAME CUSTOMER_NAMEFROM AR_RECEIPT_METHODS ARM,AR_CASH_RECEIPTS_ALL ACR,AR_CASH_RECEIPT_HISTORY_ALL ACRH,AP_BANK_ACCOUNTS ABA,AP_BANK_BRANCHES ABB,HZ_PARTIES HP,HZ_CUST_ACCOUNTS HCAWHERE ARM.RECEIPT_METHOD_ID=ACR.RECEIPT_METHOD_IDAND ACR.CASH_RECEIPT_ID=ACRH.CASH_RECEIPT_IDAND ACR.REMITTANCE_BANK_ACCOUNT_ID=ABA.BANK_ACCOUNT_ID(+)AND ABA.BANK_ACCOUNT_ID=ABB.BANK_BRANCH_ID(+)AND ACR.PAY_FROM_CUSTOMER=HCA.CUST_ACCOUNT_IDAND HCA.PARTY_ID=HP.PARTY_ID

7 / 33

Page 8: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

AR INVOICEselect rcta.trx_number invoice_num,--sales_order_reference,rct.gl_date,rctl.inventory_item_id,rct.amount,rcta.trx_date invoice_date,rctl.taxable_amount tax_amount-- revenue_account_id,--receivables_account_id,from ra_customer_trx_lines_all rctl,ra_cust_trx_line_gl_dist_all rct,ra_customer_trx_all rctawhere rctcl.customer_trx_line_id=rct.customer_trx_line_idand rctl.customer_trx_id=rcta.customer_trx_idand rcta.customer_trx_id=rct.customer_trx_idAP Internal Item QuerySELECT DISTINCTTO_CHAR(api.invoice_date,'MM/DD/YYYY') Document_Date,(SELECT segment7FROM gl_code_combinations gcWHERE gc.code_combination_id = aid.dist_code_combination_id) Document_type,(SELECT segment5FROM gl_code_combinations gcWHERE gc.code_combination_id = aid.dist_code_combination_id) Company_Code, -- <<FR HBS - 2522 ;FR HPS HFS -2530; FR ECC-2092>>NULL Posting_Date,NULL Fiscal_period,api.invoice_currency_code                Currency_Key,DECODE(api.invoice_currency_code,sob.currency_code,NULL,SUBSTR(api.exchange_rate,1,INSTR(api.exchange_rate,'.',1)-1)||RPAD(SUBSTR(api.exchange_rate,INSTR(api.exchange_rate,'.',1),LENGTH(api.exchange_rate)),6,0)) Exchange_Rate,api.invoice_num                          Document_Num,NULL Header_Text,DECODE(SIGN(api.invoice_amount),1,31,-1,21,0,31,NULL) Posting_Key1,pv.segment1                              Account_or_Matchcode1,ABS(api.invoice_amount) Amount1,apt.name                                     PAYMENT_TERMS,( SELECT TO_CHAR(MAX(due_date),'MM/DD/YYYY')FROM ap_payment_schedules_all

8 / 33

Page 9: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

WHERE invoice_id = api.invoice_id) Baseline_date, -- As per option2 in Mapping doc.SUBSTR(pv.segment1,1,18) Assignment_number1,(SELECT segment2FROM gl_code_combinations gcWHERE gc.code_combination_id = aid.dist_code_combination_id) Item_Text1,DECODE(SIGN(api.invoice_amount),1,40,-1,50,0,40,NULL) Posting_Key2,NULL Account_or_Matchcode2,ABS(NVL((SELECT SUM(apd.amount)FROM ap_invoice_distributions_all apdWHERE apd.invoice_id=api.invoice_id),NULL)) Amount2,NULL Assignment_number2,NULL Item_Text2, --Can concatenate PO#s and populate this if business needs it.(SELECT segment4FROM gl_code_combinations gcWHERE gc.code_combination_id = aid.dist_code_combination_id) Profit_Center, --To be mapped by Finance. For now, leave blankDECODE((SELECT COUNT(1)FROM ap_payment_schedules_allWHERE invoice_id = api.invoice_idAND NVL(hold_flag,'N') = 'Y'),0,'N','Y') Payment_hold,api.vendor_site_id                       Vendor_Site_IDFROMap_invoices_all api,ap_accounting_events_all apae,ap_ae_headers_all apaeh,gl_sets_of_books sob,po_vendors pv,gl_code_combinations gcc,ap_invoice_distributions_all aid,AP_TERMS_TL aptWHERE apae.source_table='AP_INVOICES'AND apae.event_status_code = 'ACCOUNTED'AND apaeh.gl_transfer_flag = 'Y'AND apaeh.gl_transfer_error_code IS NULLAND NVL(api.payment_status_flag,'N')<>'Y'AND api.cancelled_date IS NULLAND api.cancelled_by IS NULLAND api.cancelled_amount IS NULL--AND api.invoice_id=apae.source_idAND aid.accounting_event_id = apae.accounting_event_idAND apae.accounting_event_id = apaeh.accounting_event_idAND sob.set_of_books_id=api.set_of_books_id

9 / 33

Page 10: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

AND api.accts_pay_code_combination_id = gcc.code_combination_idAND api.vendor_id=pv.vendor_idAND apt.term_id= api.terms_idAND api.org_id = 403AND gcc.segment1 = '547L'AND gcc.segment2 LIKE '191%'AND aid.invoice_id = api.invoice_idAND aid.line_type_lookup_code NOT IN ('TAX')AND ABS(api.invoice_amount) !='0'AND api.invoice_id NOT IN (SELECT vouchno FROM ap_expense_report_headers_all)Purchase Order QuerySELECT msi.segment1 Product, msi.description Description, hl.description Ship_to_location-- Modified deliver_to_subinv to display Subinventory Name as part of CCD# 2010-04-1701--, mse.description deliver_to_subinv, mse.secondary_inventory_name deliver_to_subinv, DECODE

SELECT DECODE(d.reservation_type, 1, 'On Demand', 2, 'Reserved') Res_type,SUBSTR(u.user_name, 1, 20) User_name,SUBSTR(i.segment1, 1, 10) Item,c.customer_name cust_name,c.customer_number cust_number,h.order_number Ord_no,substr(l.shipment_priority_code, 1, 10) ship_code,h.date_ordered Date_ordered,r.organization_code Org,d.line_item_quantity demand_qtyFROM so_headers_all h, mtl_demand d, mtl_sales_orders s,mtl_system_items i, org_organization_definitions r,fnd_user u, ra_customers c, so_lines_all lWHERE h.created_by = u.user_idAND d.inventory_item_id = i.inventory_item_idAND d.organization_id = i.organization_idAND h.order_number = s.segment1AND r.organization_id = d.organization_idAND c.customer_id = h.customer_idAND d.demand_source_line = l.line_idAND l.header_id = h.header_id

10 / 33

Page 11: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

AND d.line_item_quantity > 0AND i.segment1 BETWEEN '&&item_from' AND '&&item_to'AND d.demand_id IN(SELECT MAX(d1.demand_id)FROM mtl_demand d1WHERE d1.line_item_quantity > 0AND d1.demand_source_type in (2, 8)AND d1.parent_demand_id IS NOT NULLGROUP BY d1.reservation_type, d1.parent_demand_id)ORDER BY DECODE(d.reservation_type, 1, 'Demand', 2, 'Reserved'),SUBSTR(u.user_name, 1, 20),SUBSTR(i.segment1, 1, 10)/

SELECT l.transaction_reason_code reason_code, c.customer_name cust_name,SUBSTR(s.segment1, 1, 10) item,h.order_number ord_no,t.trx_number inv_no,0 - NVL(l.ordered_quantity, 0) - NVL(l.cancelled_quantity, 0) rma_quantity,NVL(tl.quantity_credited, 0) qty_credited,NVL(tl.quantity_credited, 0) * NVL(unit_selling_price, 0) total_cr,u.user_name creator_name,h.creation_date creation_dateFROM fnd_user u, mtl_system_items s, ra_customers c, ra_customer_trx_all t, ra_customer_trx_lines_all tl,so_headers_all h, so_lines_all lWHERE h.order_category  = 'RMA'AND h.cancelled_flag is nullAND tl.customer_trx_id = t.customer_trx_id(+)AND tl.interface_line_attribute6(+) = l.line_idAND c.customer_id = h.customer_idAND u.user_id = h.created_byAND l.inventory_item_id = s.inventory_item_idAND l.warehouse_id = s.organization_idAND h.header_id = l.header_idAND h.creation_date between to_date('&&from_date', 'DD-MON-RRRR')AND to_date('&&to_date', 'DD-MON-RRRR')ORDER BY 1, 2/

11 / 33

Page 12: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

SELECTo.organization_code Org_name,SUBSTR(msi.segment1, 1, 10) Item,SUBSTR(msi.description, 1, 45) Item_desc,sh.order_number Order_number, sh.date_ordered Date_ordered,SUBSTR(fu.user_name, 1, 12) Created_by,NVL(sl.ordered_quantity, 0) - NVL(sl.cancelled_quantity, 0) Qty_ordered,sl.selling_price*sl.ordered_quantity Ext_amountFROM  so_headers_all sh, mtl_system_items msi,so_lines_all sl, fnd_user fu,org_organization_definitions oWHERE sh.header_id  = sl.header_idAND o.organization_id  = msi.organization_idAND sh.order_category IN ('R', 'RMA')AND  sl.inventory_item_id  = msi.inventory_item_idAND sl.warehouse_id = msi.organization_idAND  sh.created_by  = fu.user_idAND  (sh.s1 = 5 or sh.s1 = 15)AND sh.cancelled_flag is nullAND sh.creation_date BETWEEN TO_DATE('&&from_date, 'DD-MON-RR') AND TO_DATE('&&to_date', 'DD-MON-RR')ORDER BY o.organization_code,SUBSTR(msi.segment1, 1, 10),SUBSTR(msi.description, 1, 45),sh.order_number/CUSTOMER DETAILSSELECT HS.PARTY_NUMBER,HS.PARTY_NAME, HS.PARTY_TYPE,HCA.ACCOUNT_NUMBER,HCA.STATUS,HCAA.PARTY_SITE_ID,HCSU.SITE_USE_CODE,HCSU.LOCATIONFROM HZ_PARTIES HS,HZ_CUST_ACCOUNTS HCA,HZ_CUST_ACCT_SITES_ALL HCAA,HZ_CUST_SITE_USES_ALL HCSUWHERE HS.PARTY_ID = HCA.PARTY_IDAND HCA.CUST_ACCOUNT_ID = HCAA.CUST_ACCOUNT_IDAND HCAA.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_IDCUSTOMER – ORDER DETAILS – ITEM DETAILS

12 / 33

Page 13: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

SELECT DISTINCTRC.CUSTOMER_NAME,RC.CUSTOMER_NUMBER, RC.CUSTOMER_ID,OEH.ORDER_NUMBER, OEH.ORG_ID,OEH.ORDER_SOURCE_ID,OEH.ORIG_SYS_DOCUMENT_REF,OEH.ORDERED_DATE,OEH.PRICE_LIST_ID,OEH.SOLD_FROM_ORG_ID,OEH.SOLD_TO_ORG_ID,OEH.INVOICE_TO_ORG_ID,OEH.FLOW_STATUS_CODE,OEH.BOOKED_DATE,OEL.ORDERED_QUANTITY,OEL.SHIPPED_QUANTITY,OEL.SHIPPED_QUANTITY,OEL.INVENTORY_ITEM_ID,OEL.PRICE_LIST_ID, OEL.UNIT_SELLING_PRICE,HS.PARTY_NAME, HS.PARTY_TYPE, MSI.SEGMENT1--OTT.TRANSACTION_TYPE_CODE,OTT.NAME TRNAMEFROM OE_ORDER_HEADERS_ALL OEH,OE_ORDER_LINES_ALL OEL, RA_CUSTOMERS RC,HZ_PARTIES HS, MTL_SYSTEM_ITEMS_B MSI,OE_TRANSACTION_TYPES OTTWHERE OEH.HEADER_ID = OEL.HEADER_IDAND OEH.SOLD_TO_ORG_ID = RC.CUSTOMER_IDAND RC.PARTY_ID = HS.PARTY_IDAND MSI.INVENTORY_ITEM_ID = OEL.INVENTORY_ITEM_ID--AND OEH.ORDER_TYPE_ID = OTT.TRANSACTION_TYPE_IDAND OEH.ORDER_NUMBER = '10396'SELECT * FROM OE_PRICE_LISTSSELECT * FROM QP_LIST_HEADERS_ALLSELECT * FROM QP_LIST_LINESSELECT * FROM OE_ORDER_LINES_ALL where price_list_id ='1000'SELECT * FROM OE_PRICE_LISTS WHERE NAME = 'Corporate'CUSTOMER – ORDERS – ITEMS - TERMS - PRICELISTSSELECT DISTINCT RC.CUSTOMER_NAME,RC.CUSTOMER_NUMBER, RC.CUSTOMER_ID,OEH.ORDER_NUMBER, OEH.ORG_ID,OEH.ORDER_SOURCE_ID,OEH.ORIG_SYS_DOCUMENT_REF,OEH.ORDERED_DATE,OEH.PRICE_LIST_ID,OEH.SOLD_FROM_ORG_ID,OEH.SOLD_TO_ORG_ID,OEH.INVOICE_TO_ORG_ID, OEH.FLOW_STATUS_CODE,

13 / 33

Page 14: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

OEH.BOOKED_DATE, OEL.ORDERED_QUANTITY,OEL.SHIPPED_QUANTITY,OEL.SHIPPED_QUANTITY,OEL.INVENTORY_ITEM_ID,OEL.PRICE_LIST_ID,OEL.UNIT_SELLING_PRICE,HS.PARTY_NAME, HS.PARTY_TYPE,MSI.SEGMENT1, OEPL.NAME LISTNAME,RT.NAME TERMNAME, RT.DESCRIPTIONFROM OE_ORDER_HEADERS_ALL OEH,OE_ORDER_LINES_ALL OEL, RA_CUSTOMERSRC, HZ_PARTIES HS, MTL_SYSTEM_ITEMS_B MSI,OE_PRICE_LISTS OEPL, RA_TERMS RTWHERE OEH.HEADER_ID = OEL.HEADER_IDAND OEH.SOLD_TO_ORG_ID = RC.CUSTOMER_IDAND RC.PARTY_ID = HS.PARTY_IDAND MSI.INVENTORY_ITEM_ID = OEL.INVENTORY_ITEM_IDAND OEH.ORDER_NUMBER = '10396'AND OEL.PRICE_LIST_ID = OEPL.PRICE_LIST_IDAND OEH.PAYMENT_TERM_ID =RT.TERM_ID

--- find OUT the customer, line item, ordered qty  AND price info OF the ORDER :SELECT h.order_number, org.NAME customer_name, h.ordered_date order_date,ot.NAME order_type, s.NAME sales_rep, l.line_id, l.line_number,l.inventory_item_id, si.segment1, l.ordered_quantity,l.unit_selling_price,NVL (l.ordered_quantity, 0) * NVL (l.unit_selling_price, 0) amount,h.transactional_curr_code currency_codeFROM ra_salesreps s,oe_transaction_types_tl ot,oe_sold_to_orgs_v org,mtl_system_items_vl si,oe_order_lines_all l,oe_order_headers_all hWHERE h.order_number = 14463AND h.org_id = 204AND l.header_id = h.header_idAND h.sold_to_org_id = org.organization_idAND (h.cancelled_flag IS NULL OR h.cancelled_flag = 'N')AND h.open_flag = 'Y'AND l.open_flag = 'Y'AND l.service_reference_line_id IS NULLAND l.inventory_item_id = si.inventory_item_idAND NVL (si.organization_id, 0) = 204 --Item master orgnAND h.order_type_id = ot.transaction_type_idAND h.salesrep_id = s.salesrep_id

14 / 33

Page 15: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

AND h.org_id = s.org_idORDER BY l.line_id/--find customer, ship TO AND bill TO information OF an ORDER :SELECT h.order_number, c.NAME customer_name, lk1.meaning freight_terms,lk2.meaning fob, s.location_code ship_location_code,s.address_line_1 ship_address1, s.address_line_2 ship_address2,s.state ship_state, s.postal_code ship_zip, s.country ship_country,b.location_code bill_location_code, b.address_line_1 bill_address1,b.address_line_2 bill_address2, b.country bill_countryFROM ar_lookups lk2,oe_lookups lk1,oe_sold_to_orgs_v c,oe_invoice_to_orgs_v b,oe_ship_to_orgs_v s,oe_order_headers_all hWHERE h.order_number = '123'AND h.org_id = '204'AND h.ship_to_org_id = s.organization_idAND h.invoice_to_org_id = b.organization_idAND h.sold_to_org_id = c.organization_idAND h.freight_terms_code = lk1.lookup_code(+)AND lk1.lookup_type(+) = 'FREIGHT_TERMS'AND lk2.lookup_code(+) = h.fob_point_codeAND lk2.lookup_type(+) = 'FOB'/-- find OUT ORDER AND line hold information :SELECT ho.NAME hold_name, hs.hold_until_date, hs.hold_comment,h.order_number, oh.header_id, oh.line_id, oh.order_hold_id,l.item_identifier_type, l.inventory_item_id, l.ordered_itemFROM oe_order_holds_all oh,oe_order_lines_all l,oe_order_headers_all h,oe_hold_definitions ho,oe_hold_sources_all hsWHERE h.order_number = '1234'AND oh.header_id = h.header_idAND (h.cancelled_flag IS NULL OR h.cancelled_flag = 'N')AND h.open_flag = 'Y'AND oh.hold_source_id = hs.hold_source_idAND hs.hold_id = ho.hold_idAND h.header_id = l.header_id(+)AND l.open_flag = 'Y'AND l.line_id = NVL (oh.line_id, l.line_id)AND l.service_reference_line_id IS NULLAND oh.hold_release_id IS NULL

15 / 33

Page 16: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

AND NVL (h.org_id, 0) = '204'AND NVL (l.org_id, 0) = NVL (h.org_id, 0)ORDER BY ho.NAME, h.order_number/---find freight related info OF ORDER viz: freight carrier, ship method AND service LEVEL :SELECT h.order_number, h.shipping_method_code, wc.carrier_name,wcsm.service_level, wcsm.freight_codeFROM wsh_carrier_ship_methods_v wcsm,wsh_carriers_v wc,oe_order_headers_all hWHERE h.order_number = 14463AND h.org_id = 204AND h.shipping_method_code = wcsm.ship_method_code(+)AND NVL (wcsm.organization_id(+), 0) = 204 --Master OrganizationAND wcsm.freight_code = wc.freight_code(+)ORDER BY h.order_number/--find  price discounts AND surcharges ON ORDER lines :SELECT h.order_number, l.line_number, pa.list_line_type_code,pa.arithmetic_operator, pa.operand,DECODE (pa.modifier_level_code,'ORDER', l.unit_list_price* l.ordered_quantity* pa.operand* SIGN (pa.adjusted_amount)/ 100,(pa.adjusted_amount * NVL (l.ordered_quantity, 0))) discount_amtFROM qp_list_headers_vl lh,oe_price_adjustments pa,oe_order_lines_all l,oe_order_headers_all hWHERE h.order_number = '12345'AND h.header_id = l.header_idAND h.org_id = l.org_idAND h.header_id = pa.header_idAND l.line_id = pa.line_id(+)AND pa.list_header_id = lh.list_header_idAND ( pa.list_line_type_code = 'DIS'OR pa.list_line_type_code = 'SUR'OR pa.list_line_type_code = 'PBH')AND pa.applied_flag =-- find Customer contacts AND their ROLES :SELECT oc.job_title, oc.party_site_id

16 / 33

Page 17: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

, relationship_id, relationship_type, hp.party_name object_name, object_id, object_type, object_table_name, hr.party_id, relationship_code, subject_id, subject_type, subject_table_name, oc.title, oc.mail_stop, oc.contact_key, ocr.role_type, directional_flagFROM hz_org_contact_roles ocr, hz_org_contacts oc, hz_parties hp, hz_relationships hrWHERE hr.subject_id = '' --Party id of the customerAND hr.object_id = hp.party_idAND hr.relationship_id = oc.party_relationship_idAND oc.org_contact_id = ocr.org_contact_id(+)ORDER BY object_name/-- find communication channels FOR a customer :SELECT contact_point_id, contact_point_type, email_address, phone_number, url,contacts, status, owner_table_name, owner_table_id, primary_flag,orig_system_referenceFROM hz_contact_pointsWHERE owner_table_name = 'HZ_PARTIES'AND owner_table_id = '123' --Party_id for 'Hilman and Associates'/-- find ORGANIZATION TYPE Party info :/* Formatted on 2010/08/24 11:24 (Formatter Plus v4.8.0) */SELECT hp.party_id, hp.party_number, hp.party_name, hca.account_number,hca.cust_account_id, hop.organization_profile_id,hop.effective_start_date, hop.effective_end_date,hop.organization_name, hop.duns_number, hop.enquiry_duns,hop.ceo_name, hop.ceo_title, hop.principal_name, hop.principal_title,hop.legal_status, hop.control_yr, hop.employees_total,hop.hq_branch_ind, hop.branch_flag, hop.oob_ind,hop.line_of_businessFROM hz_organization_profiles hop, hz_cust_accounts hca, hz_parties hpWHERE hp.party_name = 'xxxx'

17 / 33

Page 18: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

AND hp.party_id = hca.party_idAND hp.party_id = hop.party_idAND SYSDATE BETWEEN hop.effective_start_dateAND NVL (hop.effective_end_date, SYSDATE + 1)ORDER BY hca.account_number/--find supplier info :/* Formatted on 2010/08/24 11:25 (Formatter Plus v4.8.0) */SELECT pov.vendor_id, pov.vendor_name supplier, pov.vendor_type_lookup_code,sl.location_code shipto_location, bl.location_code billto_location,pov.customer_num, pov.ship_via_lookup_code, pov.fob_lookup_code,rt.NAME terms, pov.set_of_books_id, pov.credit_status_lookup_code,pov.credit_limitFROM ra_terms rt, hr_locations bl, hr_locations sl, po_vendors povWHERE pov.vendor_name LIKE 'xxx%'AND pov.ship_to_location_id = sl.location_id(+)AND pov.bill_to_location_id = bl.location_id(+)AND pov.terms_id = rt.term_id(+)ORDER BY 1/--find supplier info :SELECT pov.vendor_id, pov.vendor_name supplier, pov.vendor_type_lookup_code,sl.location_code shipto_location, bl.location_code billto_location,pov.customer_num, pov.ship_via_lookup_code, pov.fob_lookup_code,rt.NAME terms, pov.set_of_books_id, pov.credit_status_lookup_code,pov.credit_limitFROM ra_terms rt, hr_locations bl, hr_locations sl, po_vendors povWHERE pov.vendor_name LIKE 'xxx%'AND pov.ship_to_location_id = sl.location_id(+)AND pov.bill_to_location_id = bl.location_id(+)AND pov.terms_id = rt.term_id(+)ORDER BY 1/-- find Supplier sites :SELECT pov.vendor_name supplier, povs.vendor_site_id,povs.vendor_site_code site, povs.address_line1 a1ddress,povs.address_line2 a2ddress, povs.address_line3 a3ddress,povs.city || ', ' || povs.state || ' ' || povs.zip a4ddress,povs.ship_to_location_id, povs.bill_to_location_id,povs.ship_via_lookup_code, povs.freight_terms_lookup_code,povs.fob_lookup_codeFROM po_vendors pov, po_vendor_sites povsWHERE pov.vendor_id = '' AND pov.vendor_id = povs.vendor_idORDER BY 1/-- TO find Supplier contacts :

18 / 33

Page 19: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

SELECT vc.vendor_contact_id, vc.vendor_site_id, vc.first_name,vc.middle_name, vc.last_name, vc.prefix, vc.title, vc.mail_stop,vc.area_code, vc.phone, vc.department, vc.email_address, vc.url,vc.alt_area_code, vc.alt_phone, vc.fax_area_code, vc.inactive_date,vc.faxFROM po_vendor_contacts vcWHERE vc.vendor_site_id = ''ORDER BY 1/SELECT ood.organization_code org_code, a.master_organization_id master_org_id, o1.organization_code master_org_cd, o1.organization_name master_org_nm, a.cost_organization_id cost_org_id, o2.organization_code cost_org_cd, o2.organization_name cost_org_nm, a.source_organization_id source_org_id, o3.organization_code source_org_cd, o3.organization_name source_org_nm, mfg1.meaning primary_cost_method, mfg2.meaning negative_balance, mfg11.meaning gl_update_code, a.calendar_code calendar_code, a.default_demand_class default_demand_class, mfg12.meaning encumbrance_reversal_flag, mfg3.meaning locator_control, mfg4.meaning interorg_transfer_code, DECODE (a.maintain_fifo_qty_stack_type,NULL, '',mfg6.meaning) maintain_fifo_cost, mfg7.meaning serial_number_type, mfg8.meaning lot_number_uniqueness, mfg9.meaning lot_number_generation, DECODE (a.lot_number_zero_padding,NULL, '',mfg10.meaning) lot_number_zero_padding, b.rule_name atp_rule_name, c.picking_rule_name picking_rule_name, a.default_locator_order_value, a.default_subinv_order_value, a.interorg_trnsfr_charge_percent intorg_charge_percent, a.auto_serial_alpha_prefix, a.start_auto_serial_number, a.auto_lot_alpha_prefix

19 / 33

Page 20: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

, a.lot_number_length, mfg13.meaning serial_generation, mfg14.meaning source_type, a.source_subinventory source_subinvFROM mtl_parameters a,mtl_atp_rules b,mtl_picking_rules c,org_organization_definitions ood,org_organization_definitions o1,org_organization_definitions o2,org_organization_definitions o3,mfg_lookups mfg1,mfg_lookups mfg2,mfg_lookups mfg3,mfg_lookups mfg4,mfg_lookups mfg6,mfg_lookups mfg7,mfg_lookups mfg8,mfg_lookups mfg9,mfg_lookups mfg10,mfg_lookups mfg11,mfg_lookups mfg12,mfg_lookups mfg13,mfg_lookups mfg14WHERE a.organization_id = 207AND a.master_organization_id = o1.organization_id(+)AND a.cost_organization_id = o2.organization_id(+)AND a.source_organization_id = o3.organization_id(+)AND a.organization_id = ood.organization_id(+)AND a.default_atp_rule_id = b.rule_id(+)AND a.default_picking_rule_id = c.picking_rule_id(+)AND mfg1.lookup_type(+) = 'MTL_PRIMARY_COST'AND a.primary_cost_method = mfg1.lookup_code(+)AND mfg2.lookup_type(+) = 'SYS_YES_NO'AND a.negative_inv_receipt_code = mfg2.lookup_code(+)AND mfg3.lookup_type(+) = 'MTL_LOCATION_CONTROL'AND a.stock_locator_control_code = mfg3.lookup_code(+)AND mfg4.lookup_type(+) = 'MTL_INTER_INV_TRANSFER'AND a.matl_interorg_transfer_code = mfg4.lookup_code(+)AND mfg6.lookup_type(+) = 'SYS_YES_NO'AND a.maintain_fifo_qty_stack_type = mfg6.lookup_code(+)AND mfg7.lookup_type(+) = 'MTL_SERIAL_NUMBER_TYPE'AND a.serial_number_type = mfg7.lookup_code(+)AND mfg8.lookup_type(+) = 'MTL_LOT_UNIQUENESS'AND a.lot_number_uniqueness = mfg8.lookup_code(+)AND mfg9.lookup_type(+) = 'MTL_LOT_GENERATION'

20 / 33

Page 21: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

AND a.lot_number_generation = mfg9.lookup_code(+)AND mfg10.lookup_type(+) = 'SYS_YES_NO'AND a.lot_number_zero_padding = mfg10.lookup_code(+)AND mfg11.lookup_type(+) = 'SYS_YES_NO'AND a.general_ledger_update_code = mfg11.lookup_code(+)AND mfg12.lookup_type(+) = 'SYS_YES_NO'AND a.encumbrance_reversal_flag = mfg12.lookup_code(+)AND mfg13.lookup_type(+) = 'MTL_SERIAL_GENERATION'AND a.serial_number_generation = mfg13.lookup_code(+)AND mfg14.lookup_type(+) = 'MTL_SOURCE_TYPES'AND a.source_type = mfg14.lookup_code(+)/---Find items RESTRICTED TO a subinventory :SELECT isb.inventory_item_id, isb.organization_id, si.segment1 item, isb.secondary_inventory, isb.primary_subinventory_flag, isb.picking_order, isb.min_minmax_quantity, isb.max_minmax_quantity, isb.inventory_planning_code, isb.fixed_lot_multiple, isb.minimum_order_quantity, isb.maximum_order_quantity, isb.source_type, isb.source_organization_id, isb.source_subinventoryFROM mtl_item_sub_inventories isb, mtl_system_items siWHERE isb.secondary_inventory = 'Stores'AND isb.inventory_item_id = si.inventory_item_idAND isb.organization_id = si.organization_idORDER BY 1/--find locators IN a subinventory:SELECTil.inventory_location_id,il.organization_id,il.subinventory_code,il.description,il.physical_location_id,il.pick_uom_code,il.dimension_uom_code,il.LENGTH,il.width,

21 / 33

Page 22: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

il.height,il.locator_status,il.status_id,l.meaningFROM mfg_lookups l,mtl_item_locations ilWHERE organization_id=207AND subinventory_code='Stores'AND il.inventory_location_type=l.lookup_code(+)AND l.lookup_type (+) = 'MTL_LOCATOR_TYPES'/--find few business GROUPS SET up IN the INSTANCE :SELECT business_group_id, NAMEFROM per_business_groupsWHERE LOWER (NAME) LIKE '%vision corporation%'ORDER BY NAME/-- find legal entities associated WITH a SOBSELECT organization_id legal_entity_id, business_group_id, NAME, date_from, date_to, set_of_books_id, vat_registration_numberFROM hr_legal_entitiesWHERE set_of_books_id = '' AND business_group_id = ''-- find inventory organizations FOR an operating unit :/* Formatted on 2010/08/24 11:13 (Formatter Plus v4.8.0) */SELECT organization_id, organization_code, organization_name,(SELECT location_idFROM hr_all_organization_units ouWHERE od.organization_id = ou.organization_id) location_id, user_definition_enable_date, disable_date, chart_of_accounts_id, inventory_enabled_flag, operating_unit, legal_entity, set_of_books_id, business_group_idFROM org_organization_definitions odWHERE operating_unit = 204ORDER BY organization_code

22 / 33

Page 23: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

/--- get item attributes NOT UNDER status controlSELECT meaning1 attrib_group, user_attribute_name_gui,-- ,control_level, status_control_code,attribute_name,-- attribute_group_id,data_type,-- user_attribute_name,level_updateable_flag,-- validation_code ,lookup_type1,-- lookup_code1,enabled_flag1,lookup_type2,lookup_code2,meaning2 control_level,-- ,enabled_flag2,-- lookup_type3,lookup_code3,meaning3 status_control,-- enabled_flag3,lookup_type4,lookup_code4,meaning4 VALIDATION-- ,enabled_flag4FROM mtl_item_attributes_vWHERE control_level IN (1, 2)AND status_control_code IS NULLAND user_attribute_name_gui IS NOT NULLAND attribute_name IN (SELECT attribute_nameFROM mtl_item_attr_appl_inst_v)ORDER BY attribute_group_id_gui, sequence_gui/-- get item status attribute controlsSELECT ia.attribute_group_id GROUP_ID, ia.user_attribute_name_gui,lk.meaning controlled_at, ia.attribute_name,--   ia.user_attribute_name,ia.status_control_code,ia.validation_codeFROM fnd_lookup_values lk, mtl_item_attributes iaWHERE ia.control_level = lk.lookup_codeAND lk.lookup_type = 'ITEM_CONTROL_LEVEL_GUI'ORDER BY ia.attribute_group_id, 1/-- find item status attributes :SELECT mis.inventory_item_status_code item_status, mis.description,mis.disable_date, av.attribute_name, av.attribute_value VALUEFROM mtl_item_status mis, mtl_status_attribute_values avWHERE mis.inventory_item_status_code = av.inventory_item_status_codeORDER BY 1/-- get item attributes UNDER status control :SELECT meaning1 attrib_group, user_attribute_name_gui,-- ,control_level, status_control_code,attribute_name,-- attribute_group_id,data_type,-- user_attribute_name,level_updateable_flag,

23 / 33

Page 24: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

-- validation_code ,lookup_type1, lookup_code1,enabled_flag1,lookup_type2,lookup_code2,meaning2 control_level,-- ,enabled_flag2,-- lookup_type3,lookup_code3,meaning3 status_control,-- enabled_flag3,lookup_type4,lookup_code4,meaning4 VALIDATION-- ,enabled_flag4FROM mtl_item_attributes_vWHERE control_level IN (1, 2)AND status_control_code IS NOT NULLAND user_attribute_name_gui IS NOT NULLAND attribute_name IN (SELECT attribute_nameFROM mtl_item_attr_appl_inst_v)ORDER BY attribute_group_id_gui, sequence_gui/--- find an Item attribute info :SELECT segment1 item, msi.description, inventory_item_id,ml.meaning item_type,(SELECT ia.user_attribute_name_gui|| '.'|| msi.inventory_item_status_codeFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.inventory_item_status_code')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.purchasing_item_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.purchasing_item_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.shippable_item_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.shippable_item_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.mtl_transactions_enabled_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.mtl_transactions_enabled_flag')

24 / 33

Page 25: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.so_transactions_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.so_transactions_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.internal_order_enabled_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.internal_order_enabled_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.customer_order_enabled_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.customer_order_enabled_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.purchasing_enabled_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.purchasing_enabled_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.inventory_asset_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.inventory_asset_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.eng_item_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) = 'mtl_system_items.eng_item_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.inventory_item_flagFROM mtl_item_attributes_v ia

25 / 33

Page 26: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

WHERE LOWER (ia.attribute_name) ='mtl_system_items.inventory_item_flag')ATTRIBUTE,(SELECT ia.user_attribute_name|| '.'|| msi.service_item_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.service_item_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.internal_order_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.internal_order_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.build_in_wip_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.build_in_wip_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.bom_enabled_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.bom_enabled_flag')ATTRIBUTE,(SELECT ia.user_attribute_name_gui|| '.'|| msi.stock_enabled_flagFROM mtl_item_attributes_v iaWHERE LOWER (ia.attribute_name) ='mtl_system_items.stock_enabled_flag')ATTRIBUTEFROM fnd_lookup_values ml, mtl_system_items msiWHERE msi.segment1 LIKE 'AS18947%'AND msi.organization_id = 204AND msi.item_type = ml.lookup_code(+)AND ml.lookup_type(+) = 'ITEM_TYPE'ORDER BY 1, 2/--- find Item template attribute VALUES :

26 / 33

Page 27: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

SELECT it.template_name, ita.attribute_name, ita.attribute_valueFROM mtl_item_templates it, mtl_item_templ_attributes itaWHERE it.template_name LIKE 'xxx%'AND it.template_id = ita.template_idAND ita.attribute_value IS NOT NULLORDER BY 1, 2/--- find  item cross-REFERENCES :/* Formatted on 2010/08/24 11:27 (Formatter Plus v4.8.0) */SELECT msi.segment1 item, mcr.cross_reference_type reference_type,mcr.cross_reference, mcr.descriptionFROM mtl_cross_references mcr, mtl_system_items msiWHERE mcr.cross_reference_type = 'Vendor'AND mcr.inventory_item_id = msi.inventory_item_idAND mcr.organization_id = msi.organization_idORDER BY 1, 2/-- find Customer items :/* Formatted on 2010/08/24 11:27 (Formatter Plus v4.8.0) */SELECT hp.party_name customer, ci.customer_item_number,ci.customer_item_desc, msi.segment1 item, msi.description item_desc,ci.customer_category_code, ci.item_definition_level,ci.commodity_code_id, ci.address_idFROM hz_parties hp,hz_cust_accounts hca,mtl_system_items msi,mtl_customer_items ci,mtl_customer_item_xrefs ixWHERE ci.customer_item_id = ix.customer_item_idAND ix.inventory_item_id = msi.inventory_item_idAND ix.master_organization_id = msi.organization_idAND ci.customer_id = hca.cust_account_idAND hca.party_id = hp.party_idORDER BY 1, 2/---find Manufacturer items :SELECT mm.manufacturer_name, mp.mfg_part_num, mp.description,msi.segment1 inv_item, msi.description item_descFROM mtl_system_items msi, mtl_mfg_part_numbers mp, mtl_manufacturers mmWHERE mm.manufacturer_id = mp.manufacturer_idAND mp.inventory_item_id = msi.inventory_item_idAND mp.organization_id = msi.organization_idORDER BY 1, 2/--find related items :SELECT ito.segment1 item, ito.description, itr.segment1 related_item,

27 / 33

Page 28: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

itr.description, ml.meaning relation, ri.reciprocal_flagFROM mfg_lookups ml,mtl_system_items itr,mtl_system_items ito,mtl_related_items riWHERE ri.inventory_item_id = ito.inventory_item_idAND ri.organization_id = ito.organization_idAND ri.related_item_id = itr.inventory_item_idAND ri.organization_id = itr.organization_idAND ri.relationship_type_id = ml.lookup_codeAND ml.lookup_type(+) = 'MTL_RELATIONSHIP_TYPES'ORDER BY 1, 2/-- find DEFAULT category FOR a category SET :/* Formatted on 2010/08/24 11:28 (Formatter Plus v4.8.0) */SELECT mcats.category_set_name, mcat.segment1 default_category,mcat.description cat_desc, mcat.category_id, mcats.category_set_idFROM mtl_category_sets mcats, mtl_categories mcatWHERE mcats.category_set_name LIKE '%'AND mcat.category_id = mcats.default_category_idORDER BY 1, 2/-- find ALL items assigned TO categories OF a category SET :SELECT mcats.category_set_name,mcat.segment1 || '.' || mcat.segment2 CATEGORY, msi.segment1 item,msi.description item_descFROM mtl_item_categories micat,mtl_category_sets mcats,mtl_categories mcat,mtl_system_items_vl msiWHERE mcats.category_set_name LIKE 'Inv%'AND micat.category_set_id = mcats.category_set_idAND micat.category_id = mcat.category_idAND mcat.segment1 LIKE 'N%'AND msi.inventory_item_id = micat.inventory_item_idAND msi.organization_id = micat.organization_idAND msi.organization_id = 204ORDER BY 1, 2, 3/FIRST LEVEL COMPONENTS OF AN ASSEMBLY

SELECTbom.assembly_item_id,bic.component_sequence_id ,bic.bill_sequence_id ,

28 / 33

Page 29: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

--parent_bill_seq_id ,bic.operation_seq_num ,bic.component_item_id ,msi.segment1,--bic.bom_item_type ,bic.item_num ,bic.component_quantityFROMbom_inventory_components bic,mtl_system_items msi,bom_bill_of_materials bomWHERE bom.assembly_item_id=149AND bom.organization_id=207AND bom.bill_sequence_id=bic.bill_sequence_idAND bic.component_item_id=msi.inventory_item_idAND msi.organization_id=207ORDER BY 1,2/SELECT(SELECT msi.segment1 from mtl_system_items msi WHEREmsi.inventory_item_id=bom.assembly_item_id AND msi.organization_id=207) parent_item,bom.assembly_item_id,lpad(' ',2*(level-1),' ')||(SELECT msi.segment1 FROM mtl_system_items msi WHEREmsi.inventory_item_id=bic.component_item_id AND msi.organization_id=207) child_item,bic.component_item_id child_item_id,--bic.component_sequence_id ,bic.bill_sequence_id ,--parent_bill_seq_id ,bic.operation_seq_num ,--bic.bom_item_type ,--bic.item_num ,level,bic.component_quantityFROMbom_inventory_components bic,(SELECT * FROM bom_bill_of_materials WHERE organization_id=207) bomWHERE bom.bill_sequence_id=bic.bill_sequence_idSTART WITH  bom.assembly_item_id=149CONNECT BY PRIOR bic.component_item_id=bom.assembly_item_id--ORDER BY LEVEL, bom.assembly_item_id/

BOM OPERATION ROUTING

29 / 33

Page 30: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

SELECT--bor.routing_sequence_id ,bos.operation_sequence_id op_seq_id ,bos.operation_seq_num op_seq ,bos.operation_description ,--bos.standard_operation_id ,bos.department_id ,bos.operation_type ,bor.routing_type ,bso.operation_code operation_code,bor.completion_subinventory comp_subinv,bor.completion_locator_id comp_loc ,bd.department_code department_codeFROMbom_standard_operations bso,bom_departments bd,bom_operation_sequences bos,bom_operational_routings borWHEREe bor.assembly_item_id = 149AND bor.organization_id =207AND bor.routing_sequence_id=bos.routing_sequence_idAND bos.department_id = bd.department_idAND bos.standard_operation_id = bso.standard_operation_id (+)ORDER BY bos.operation_sequence_id/

BOM ROUTING RESOURCES

SELECTbor.routing_sequence_id ,bos.operation_sequence_id op_seq_id,bos.operation_seq_num op_seq,bso.operation_code op_code,bos.operation_description ,bos.standard_operation_id std_op_id,bos.department_id dept,bos.operation_type op_type,boc.resource_seq_num res_seq,boc.resource_id ,boc.activity_id ,boc.basis_type basis,br.resource_code res_code,bor.completion_subinventory comp_subinv,bor.completion_locator_id comp_loc,bor.routing_type rout_type,

30 / 33

Page 31: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

boc.usage_rate_or_amount rateFROMbom_standard_operations bso,bom_resources br,bom_operation_resources boc,bom_operation_sequences bos,bom_operational_routings borWHEREbor.assembly_item_id = 149 AND bor.organization_id =207 AND bor.routing_sequence_id=bos.routing_sequence_id AND bos.operation_sequence_id=boc.operation_sequence_idAND br.resource_id = boc.resource_idAND bos.standard_operation_id = bso.standard_operation_id (+)ORDER BY 1/

FIND ATTACHMENTS FOR BOM

SELECT to_number(AD.PK1_VALUE) operation_sequence_id,TL.DESCRIPTION instruction_code,ST.SHORT_TEXT instruction_descriptionFROM FND_DOCUMENTS D,FND_DOCUMENTS_TL TL,FND_DOCUMENTS_SHORT_TEXT ST,FND_ATTACHED_DOCUMENTS AD,bom_operation_sequences bosWHERE bos.operation_sequence_id =166and bos.operation_sequence_id = to_number(AD.PK1_VALUE)AND D.DOCUMENT_ID = TL.DOCUMENT_IDAND TL.DOCUMENT_ID = AD.DOCUMENT_IDAND TL.MEDIA_ID = ST.MEDIA_IDAND SYSDATE BETWEEN TRUNC(NVL(D.START_DATE_ACTIVE, SYSDATE))AND TRUNC(NVL(D.END_DATE_ACTIVE, SYSDATE))+1AND AD.ENTITY_NAME like 'BOM_OPERATION_SEQUENCES'AND TL.LANGUAGE = userenv('LANG')ORDER BY instruction_code/AR AGING REPORTselect customer_number, customer_name,paymt,Day_030 ,Day_031_060,Day_061_090,

31 / 33

Page 32: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

Day_091_120,Day_121_150,Day_151_180,Day_181,no_ofTrxfrom     (select pay.org_id,pay.customer_id--        ,pay.trx_number, pay.trx_date --   ,pay.AMOUNT_DUE_ORIGINAL, pay.AMOUNT_DUE_REMAINING,to_Date ('asofdate') -trunc(pay.trx_date) , sum((case  when ( to_Date ('&1') - trunc(pay.trx_date)  ) <=30   then  APPS.XX_ar_aging_amtapp(to_Date ('&1'),pay.customer_trx_id)  end ) ) Day_030, sum((case  when ( to_Date ('&1') - trunc(pay.trx_date)  ) between 31  and 60   then  APPS.XX_ar_aging_amtapp(to_Date ('&1'),pay.customer_trx_id) end ) ) Day_031_060      , sum((case  when ( to_Date ('&1') - trunc(pay.trx_date)  ) between 61  and 90   then  APPS.XX_ar_aging_amtapp(to_Date ('&1'),pay.customer_trx_id) end ) ) Day_061_090, sum((case  when ( to_Date ('&1') - trunc(pay.trx_date)  ) between 91  and 120  then  APPS.XX_ar_aging_amtapp(to_Date ('&1'),pay.customer_trx_id) end ) )  Day_091_120      , sum((case  when ( to_Date ('&1') - trunc(pay.trx_date)  ) between 121 and 150  then  APPS.XX_ar_aging_amtapp(to_Date ('&1'),pay.customer_trx_id) end ) )  Day_121_150, sum((case  when ( to_Date ('&1') - trunc(pay.trx_date)  ) between 151 and 180  then  APPS.XX_ar_aging_amtapp(to_Date ('&1'),pay.customer_trx_id) end ) )  Day_151_180      , sum((case  when ( to_Date ('&1') - trunc(pay.trx_date)  ) >= 181               then  APPS.XX_ar_aging_amtapp(to_Date ('&1'),pay.customer_trx_id) end ) ) Day_181,count(*) no_ofTrx,''  from       apps.ar_payment_Schedules_all paywhere  pay.class in ('XX','YY','ZZ') and pay.org_id = &3 and pay.gl_date  <= to_Date ('&1') and pay.GL_DATE_CLOSED >  to_Date ('&1') and exists   ( select 'x' from  apps.gl_code_combinations gl    ,apps.ra_cust_trx_line_gl_dist_all distglwhere  (trim (('&2')) ='0' or gl.segment4 in ('&2'))   --gl.segment4 in ('&2')and gl.CODE_COMBINATION_ID =  distgl.CODE_COMBINATION_IDand distgl.ACCOUNT_CLASS ='REC'and distgl.CUSTOMER_TRX_ID  =pay.CUSTOMER_TRX_ID )              group by pay.org_id,pay.customer_id --   ,pay.AMOUNT_DUE_ORIGINAL, pay.AMOUNT_DUE_REMAINING ,pay.trx_number,pay.trx_date)  invag ,(select  pay.org_id,pay.customer_id, sum(receiptL.AMOUNT_APPLIED) paymtfrom  apps.ar_payment_Schedules_all pay,AR_RECEIVABLE_APPLICATIONS_ALL receiptLwhere  pay.class ='PMT' and receiptl.status in ('ACC','UNAPP') and pay.org_id =&3 and   pay.PAYMENT_SCHEDULE_ID =     receiptL.PAYMENT_SCHEDULE_ID

32 / 33

Page 33: IMP Queries

IMP QUERIES

Written by AdministratorThursday, 11 November 2010 07:17 - Last Updated Friday, 19 August 2011 07:16

and pay.gl_date  <= to_Date ('&1') and pay.GL_DATE_CLOSED >  to_Date ('&1')group by pay.org_id,pay.customer_id     ) payment, apps.ra_customers cust where cust.customer_id =  invag.customer_id (+)and   cust.customer_id =  payment.customer_id (+)  and  (invag.org_id is not null or payment.org_id is not null)    /

33 / 33