SCM Queries
Oracle EBS R12 Purchasing, Inventory, Order Management Qureies
To Find Duplicate Item Category Code
SELECT category_set_name, category_concat_segments, COUNT (*)
FROM mtl_category_set_valid_cats_v
WHERE (category_set_id = 1)
GROUP BY category_set_name, category_concat_segments
HAVING COUNT (*) > 1
ORDER BY category_concat_segments
Get Number Of canceled requisition
SELECT a.AUTHORIZATION_STATUS,(a.ORG_ID),(SELECT distinct hr.per_all_people_f.first_name|| ‘ ‘|| hr.per_all_people_f.middle_names|| ‘ ‘|| hr.per_all_people_f.last_name “Employee Name”
FROM hr.per_all_people_f
where hr.per_all_people_f.PERSON_ID in
(select employee_id from fnd_user fu where fu.user_id = a.CREATED_BY)) CREATED_BY,count(SEGMENT1 )
FROM
po_requisition_headers_all a
WHERE
a.creation_date BETWEEN TO_DATE(’01/01/2007’, ‘DD/MM/YYYY’)
and TO_DATE(’30/05/2007′, ‘DD/MM/YYYY’)
and a.AUTHORIZATION_STATUS = ‘CANCELLED’
group by a.AUTHORIZATION_STATUS,a.ORG_ID,a.CREATED_BY
Number of line processed in Order Management
SELECT COUNT (line_id) “Order Line Processed”
FROM oe_order_lines_all
WHERE creation_date BETWEEN TO_DATE (:Fdate, ‘DD/MM/YYYY’)
AND TO_DATE (:tdate, ‘DD/MM/YYYY’)
AND flow_status_code = ‘CLOSED’;
To Check Item Catogry For Inventory master (No Of Segments May Varry)
SELECT ood.organization_name,
segment1|| ‘-‘|| segment2|| ‘-‘|| segment3 catgory
FROM org_organization_definitions ood,
mtl_categories_vl mcv,
mtl_category_sets mcs
WHERE mcs.structure_id = mcv.structure_id
ORDER BY ood.organization_name
Check Locators for inventory Inventory Org Wise(Number of segment may varry)
SELECT mil.segment1 loc_seg1, mil.segment11 loc_seg11, mil.segment2 loc_seg2,
mil.segment3 loc_seg3, mil.segment4 loc_seg4, mil.segment5 loc_seg5,
mil.segment6 loc_seg6,ood.ORGANIZATION_NAME,mil.SUBINVENTORY_CODE
FROM mtl_item_locations mil,org_organization_definitions ood
where mil.ORGANIZATION_ID = ood.ORGANIZATION_ID
Display All Subinventories Setup
select msi.secondary_inventory_name, MSI.SECONDARY_INVENTORY_NAME “Subinventory”, MSI.DESCRIPTION “Description”,
MSI.DISABLE_DATE “Disable Date”, msi.PICKING_ORDER “Picking Order”,
gcc1.concatenated_segments “Material Account”,
gcc2.concatenated_segments “Material Overhead Account”,
gcc3.concatenated_segments “Resource Account”,
gcc4.concatenated_segments “Overhead Account”,
gcc5.concatenated_segments “Outside Processing Account”,
gcc6.concatenated_segments “Expense Account”,
gcc7.concatenated_segments “Encumbrance Account”,
msi.material_overhead_account,
msi.resource_account,
msi.overhead_account,
msi.outside_processing_account,
msi.expense_account,
msi.encumbrance_account
from mtl_secondary_inventories msi,
gl_code_combinations_kfv gcc1,
gl_code_combinations_kfv gcc2,
gl_code_combinations_kfv gcc3,
gl_code_combinations_kfv gcc4,
gl_code_combinations_kfv gcc5,
gl_code_combinations_kfv gcc6,
gl_code_combinations_kfv gcc7
where msi.material_account = gcc1.CODE_COMBINATION_ID(+)
and msi.material_overhead_account = gcc2.CODE_COMBINATION_ID(+)
and msi.resource_account = gcc3.CODE_COMBINATION_ID(+)
and msi.overhead_account = gcc4.CODE_COMBINATION_ID(+)
and msi.outside_processing_account = gcc5.CODE_COMBINATION_ID(+)
and msi.expense_account = gcc6.CODE_COMBINATION_ID(+)
and msi.encumbrance_account = gcc7.CODE_COMBINATION_ID(+)
order by msi.secondary_inventory_name
To Select Unit Of measure exist in ebusiness suite
select uom_code,unit_of_measure
from mtl_units_of_measure
Query to find out Customer Master Information. Customer Name, Account Number, Adress etc.
select p.PARTY_NAME,ca.ACCOUNT_NUMBER,loc.address1,loc.address2,loc.address3,loc.city,loc.postal_code,
loc.country,ca.CUST_ACCOUNT_ID
from apps.ra_customer_trx_all I,
apps.hz_cust_accounts CA,
apps.hz_parties P,
apps.hz_locations Loc,
apps.hz_cust_site_uses_all CSU,
apps.hz_cust_acct_sites_all CAS,
apps.hz_party_sites PS
where I.COMPLETE_FLAG =’Y’
and I.bill_TO_CUSTOMER_ID= CA.CUST_ACCOUNT_ID
and ca.PARTY_ID=p.PARTY_ID
and I.bill_to_site_use_id=csu.site_use_id
and csu.CUST_ACCT_SITE_ID=cas.CUST_ACCT_SITE_ID
and cas.PARTY_SITE_ID=ps.party_site_id
and ps.location_id=loc.LOCATION_ID
Query to find on Hand Quantity
select sum(transaction_quantity) from MTL_ONHAND_QUANTITIES
where inventory_item_id=9
and organization_id=188
Qunatity on order, Expected Deliver
select sum(ordered_quantity),a.SCHEDULE_SHIP_DATE
from oe_order_lines_all a
where inventory_item_id=10
and ship_from_org_id=188
group by a.SCHEDULE_SHIP_DATE
Query to find Item Code, Item Description Oracle Item Master Query
select item, description from mtl_system_items_b
where inventory_item_id=&your_item
and organization_id=&organization_id) item
Query to Find out On Hand Quantity of specific Item Oracle inventory
select sum(transaction_quantity) from mtl_onhand_quantity_details
where inventory_item_id=&your_item
and organization_id=&organization_id
Qty On Order,Expected deivery date(
select sum(ordered_quantity),scheduled_ship_date from oe_order_lines_all
where inventory_item_id=&your_item
and ship_from_org_id=&organization_id
group by scheduled_ship_date) order_info
–Total Received Qty
select sum(transaction_quantity) from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity>0)
Total received Qty in 9 months
select sum(transaction_quantity) from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity>0
and transaction_date between trunc(sysdate) and trunc(sysdate-270))
Total issued quantity in 9 months
select sum(transaction_quantity) from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity<0 and transaction_date between trunc(sysdate) and trunc(sysdate-270)) tot_iss_qty_9mths, –Average monthly consumption
(select sum(transaction_quantity)/30 from mtl_material_transactions
inventory_item_id=&your_item
and organization_id=&organization_id
and transaction_quantity<0) ;
Display all categories that the Item Belongs
SELECTunique micv.CATEGORY_SET_NAME “Category Set”,
micv.CATEGORY_SET_ID “Category Set ID”,
decode( micv.CONTROL_LEVEL,
1, ‘Master’,
2, ‘Org’,
‘Other’) “Control Level”,
micv.CATEGORY_ID “Category ID”,
micv.CATEGORY_CONCAT_SEGS “Category”
FROM
MTL_ITEM_CATEGORIES_V micv
Another Query to Get Onhand Qty With Oranization ID, Item Code, Quantity
SELECT organization_id,
(SELECT ( msib.segment1|| ‘-‘|| msib.segment2|| ‘-‘|| msib.segment3|| ‘-‘|| msib.segment4)
FROM mtl_system_items_b msib
WHERE msib.inventory_item_id = moq.inventory_item_id
AND msib.organization_id = moq.organization_id) “Item Code”,
(SELECT description
FROM mtl_system_items_b msib
WHERE msib.inventory_item_id =
moq.inventory_item_id
AND msib.organization_id = moq.organization_id)
“item Description”,
SUM (moq.transaction_quantity) onhandqty
FROM mtl_onhand_quantities moq
GROUP BY moq.organization_id, (moq.inventory_item_id)
Dear Faisal,
As i spoke to you last knight My self Iam abbas from Riyadh.
Please Help me in this regards.will be very thankfull to you.
For the Below query please find the attached OUT put fileor below
sales rep id, segment1, category type, description, category_type,
mic.category_id, quantity_out ,quantity_in, net,
100000301 ,802010 ,CAN- 355ML- Can Pepsi Regular 24 X 355ml ,1,186.00 ,50,185.00
,20.00 ,0.00 ,20.00
===================================================
SELECT ms.segment1 item_code, ms.description, mc.segment1
category_type,
ms.description, mc.structure_id, mic.category_id,
sum(mtl.transaction_quantity) quantity_out,
(SELECT mmt.transaction_quantity
FROM mtl_material_transactions mmt
WHERE mmt.transaction_date BETWEEN ’27-jan-2010′ AND ’28-JAN-2010′
AND mmt.transaction_type_id = 961
AND mmt.transaction_quantity > 0
AND mmt.source_line_id IN (
SELECT wddI.delivery_detail_id
FROM wsh_delivery_details wddI
WHERE wddI.source_header_id IN (
SELECT oohA.header_id
FROM oe_order_lines_all oolA,
oe_order_headers_all oohA
WHERE oolA.header_id = oohA.header_id
and ool.HEADER_ID = oola.HEADER_ID))) quantity_in
FROM mtl_system_items_b ms,
mtl_material_transactions mtl,
oe_order_lines_all ool,
mtl_txn_request_lines mtr,
ra_salesreps_all rs,
oe_order_headers_all ooh,
mtl_categories mc,
wsh_delivery_details wdd,
mtl_item_categories mic
—
WHERE ms.organization_id = mtl.organization_id
AND ms.inventory_item_id = ool.inventory_item_id
AND ms.inventory_item_id = mtl.inventory_item_id
AND ool.salesrep_id = rs.salesrep_id
AND ool.header_id = ooh.header_id
AND ool.inventory_item_id = mtl.inventory_item_id
AND mtl.source_line_id = mtr.line_id
AND mtl.trx_source_line_id = ool.line_id
AND wdd.move_order_line_id = mtr.line_id
AND wdd.source_line_id = mtl.trx_source_line_id
AND mic.inventory_item_id = ms.inventory_item_id
AND ms.organization_id = mic.organization_id
AND mic.category_id = mc.category_id
AND mic.inventory_item_id = ool.inventory_item_id
AND mtl.transaction_quantity > 0
AND mtl.transaction_type_id = ’52’
AND ms.organization_id = 75
AND mc.structure_id = ‘50185’
AND mtl.transaction_date >= ’27-JAN-2010′
AND mtl.transaction_date 0
AND rs.salesrep_id = ‘100000071’
AND mic.category_id = mc.category_id
AND mic.inventory_item_id = ms.inventory_item_id
AND ms.organization_id = mic.organization_id
AND mic.inventory_item_id = ool.inventory_item_id
AND ms.organization_id = 75
AND mc.structure_id = ‘50185’
–and ms.SEGMENT1 = ‘101011’
AND mtl.transaction_date >= ’01-aug-2009′
AND mtl.transaction_date <= '03-aug-2009'
— AND TRUNC(MTL.TRANSACTION_DATE)BETWEEN :P_FROM_DATE AND:P_TO_DATE
— AND RS.salesrep_id = :p_sale_rep_id
GROUP BY ms.segment1,
ms.description,
mic.category_id,
mc.segment1,
mc.structure_id
ORDER BY ms.segment1
Following query can be use for AR Invoice Details
Select ct.BILL_TO_CUSTOMER_ID,trx_number,trx_Date,substr(tl.description,1,9) description,tl.quantity_invoiced,revenue_amount,sales_order, to_date(Nd.INITIAL_PICKUP_DATE,’DD-MM-RR’) ship_Date,
a.sales_document_name,UOM_CODE,nd.attribute1 disp_no,nd.loading_sequence sdo_no
from apps.ra_customer_trx_lines_all tl,
apps.oe_order_headers_all o,
apps.oe_blanket_headers_all a,
apps.wsh_delivery_details dd,
apps.WSH_DELIVERY_ASSIGNMENTS da,
apps.wsh_new_deliveries nd,
apps.ra_customer_trx_all ct
where tl.SALES_ORDER=o.ORDER_NUMBER
–and to_Date(tl.SALES_ORDER_DATE,’dd-mm-yyyy’)=to_date(o.ORDERED_DATE,’dd-mm-yyyy’)
and o.BLANKET_NUMBER=a.ORDER_NUMBER
and tl.sales_order=dd.source_header_number
and tl.INTERFACE_LINE_ATTRIBUTE6=dd.SOURCE_LINE_ID
and dd.DELIVERY_DETAIL_ID=da.DELIVERY_DETAIL_ID
and da.DELIVERY_ID=nd.DELIVERY_ID
and tl.CUSTOMER_TRX_ID=ct.CUSTOMER_TRX_ID
and trx_date between :P_fdate and :P_Tdate
and dd.inv_interfaced_flag =’Y’
and ct.complete_flag=’Y’
Union all
select ct.BILL_TO_CUSTOMER_ID,trx_number,trx_Date,SUBSTR(tl.description,1,9),tl.quantity_invoiced,revenue_amount,sales_order, to_date(Nd.INITIAL_PICKUP_DATE,’DD-MM-RR’) ship_Date ,
”,UOM_CODE,nd.attribute1 disp_no,nd.loading_sequence sdo_no
from apps.ra_customer_trx_lines_all tl,
apps.oe_order_headers_all o,
apps.wsh_delivery_details dd,
apps.WSH_DELIVERY_ASSIGNMENTS da,
apps.wsh_new_deliveries nd,
apps.ra_customer_trx_all ct
where tl.SALES_ORDER=o.ORDER_NUMBER
–and to_Date(tl.SALES_ORDER_DATE,’dd-mm-yyyy’)=to_date(o.ORDERED_DATE,’dd-mm-yyyy’)
AND O.BLANKET_NUMBER IS NULL
and tl.sales_order=dd.source_header_number
and tl.INTERFACE_LINE_ATTRIBUTE6=dd.SOURCE_LINE_ID
and dd.DELIVERY_DETAIL_ID=da.DELIVERY_DETAIL_ID
and da.DELIVERY_ID=nd.DELIVERY_ID
and tl.CUSTOMER_TRX_ID=ct.CUSTOMER_TRX_ID
and trx_date between :P_fdate and :P_Tdate
and dd.inv_interfaced_flag =’Y’
and ct.complete_flag=’Y’
order by disp_no
AP Invoice Detail Query.
SELECT VENDOR_ID,VENDOR_NO,VENDOR_NAME,INV_TYPE,INVOICE_NUM,INVOICE_DATE,INVOICE_AMOUNT,AMT_PAID AMOUNT_PAID,
INVOICE_AMOUNT-AMT_PAID AMOUNT_REMAINING,CURR,EXCHANGE_RATE,(INVOICE_AMOUNT-AMT_PAID)+NVL(EXCHANGE_RATE,1) AMT_SR,
GL_DATE,DUE_DATE,PAYMENT_METHOD_CODE FROM(
select inv.VENDOR_ID,sup.SEGMENT1 Vendor_no,sup.VENDOR_NAME, inv.INVOICE_TYPE_LOOKUP_CODE inv_type,
inv.INVOICE_NUM,inv.INVOICE_DATE,inv.INVOICE_AMOUNT,
nvl((select sum(ip.AMOUNT) from ap_Invoice_payments_all ip,ap_checks_all ca where ip.CHECK_ID=ca.CHECK_ID
and ip.reversal_flag=’N’ and ca.CHECK_DATE<=:P_asof and ip.INVOICE_ID=inv.INVOICE_ID),0) amt_paid, inv.INVOICE_CURRENCY_CODE curr,inv.EXCHANGE_RATE,inv.GL_DATE,ps.DUE_DATE,ps.PAYMENT_METHOD_CODE from ap_invoices_all inv, ap_payment_schedules_all ps, ap_suppliers sup where inv.INVOICE_ID = ps.INVOICE_ID and inv.VENDOR_ID=sup.VENDOR_ID and inv.VENDOR_ID=NVL(:P_VENDOR_ID,INV.VENDOR_ID) and inv.GL_DATE<=:P_asof order by sup.SEGMENT1,ps.DUE_DATE,inv.GL_DATE ) WHERE (INVOICE_AMOUNT-AMT_PAID)<>0 ORDER BY TO_NUMBER(VENDOR_NO), DUE_DATE