100% found this document useful (2 votes)
2K views3 pages

Query To Get Inventory Valuation After Oracle Update 23C

This SQL query retrieves inventory valuation information such as item code, description, quantity on hand, unit cost, amount, store, and period from various Oracle tables including items, costs, quantities, and organizations. It joins these tables to get the required information for a given period and filters based on store, category, and other parameters. The query returns the results ordered by item code.

Uploaded by

Nader Fanous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
2K views3 pages

Query To Get Inventory Valuation After Oracle Update 23C

This SQL query retrieves inventory valuation information such as item code, description, quantity on hand, unit cost, amount, store, and period from various Oracle tables including items, costs, quantities, and organizations. It joins these tables to get the required information for a given period and filters based on store, category, and other parameters. The query returns the results ordered by item code.

Uploaded by

Nader Fanous
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Query to get Inventory Valuation after Oracle Update 23C

SELECT

ITEMS.item_number Item_Code,
ITEMS.description Item_Description,
ITEMS.Category_Code,
ITEMS.Category_Name,
ITEMS.CAT_Level1,
ITEMS.CAT_Level2,
ITEMS.CAT_Level3,
QTY.total_quantity Quantity,
COST.uom_code UOM,
ROUND (COST.unit_cost,2) Unit_Cost,
ROUND ((QTY.total_quantity * COST.unit_cost),2) Amount,
HRO.name Store,
:P_Period_Name

FROM
(SELECT OP.organization_id,
OP.legal_entity_id legal_entity,
HOU.name
FROM
HR_ALL_ORGANIZATION_UNITS_X HOU,
INV_ORG_PARAMETERS OP
WHERE
OP.organization_id = HOU.organization_id)
HRO,

(SELECT
cost_org_id,
cost_book_id,
val_unit_id,
period_name Period_Name,
inventory_item_id,
cost_element_id,
SUM (amount) onhand_value,
MAX (perp_average_cost) unit_cost,
MAX (uom_code) uom_code,
MAX (currency_code) currency_code,
MAX (cost_method_code) cost_method_code
FROM
cst_attr_onhand_details
WHERE
--(:P_As_Of_Date) BETWEEN snapshot_date AND (eff_to_date -
1)
period_name = :P_Period_Name
--AND cost_org_id = :p_cost_org_id
AND cost_book_id = 300000002539593
GROUP BY
cost_org_id,
cost_book_id,
val_unit_id,
period_name,
inventory_item_id,
cost_element_id)
COST,

(SELECT
cost_org_id,
cost_book_id,
val_unit_id,
inventory_item_id,
inventory_org_id,
period_name Period_Name,
SUM(starting_quantity)
Starting_Quantity,
SUM(new_receipt_quantity)
New_Receipt_Quantity,
SUM(new_issue_quantity)
New_Issue_Quantity,
(SUM(new_receipt_quantity) + SUM(new_issue_quantity))
Period_Activity,
SUM(quantity_onhand)
total_quantity
FROM
CST_ATTR_ONHAND_VALUATIONS ATV
WHERE
--(:P_As_Of_Date) BETWEEN snapshot_date AND (eff_to_date -
1)
period_name = :P_Period_Name
--AND cost_org_id = :p_cost_org_id
AND cost_book_id = 300000002539593
GROUP BY
cost_org_id,
cost_book_id,
val_unit_id,
inventory_item_id,
inventory_org_id,
period_name)
QTY,

(SELECT
ESIT.inventory_item_id,
ESIT.organization_id,
ESIB.item_number,
Replace (ESIT.description,CHR(10),' ') Description,
ECB.category_code Category_Code,
ECT.category_name Category_Name,
SUBSTR(ECT.category_name,1,INSTR(ECT.category_name,'>>',1)-
1) CAT_Level1,
SUBSTR((REGEXP_SUBSTR(ECT.category_name,'>>[^>>]+')),3)
CAT_Level2,
SUBSTR (ECT.category_name, INSTR (ECT.category_name,
'>>',1,2)+2) CAT_Level3
FROM
EGP_SYSTEM_ITEMS_TL ESIT,
EGP_SYSTEM_ITEMS_B ESIB,
EGP_CATEGORIES_B ECB,
EGP_CATEGORIES_TL ECT,
EGP_ITEM_CAT_ASSIGNMENTS EICA
WHERE
1 = 1
AND ESIT.inventory_item_id = ESIB.inventory_item_id
AND ESIT.organization_id = ESIB.organization_id
AND ESIT.LANGUAGE = 'US'
AND ECB.CATEGORY_ID = ECT.CATEGORY_ID
AND ECT.LANGUAGE = 'US'
AND ESIB.INVENTORY_ITEM_ID = EICA.INVENTORY_ITEM_ID
AND EICA.CATEGORY_ID = ECB.CATEGORY_ID)
ITEMS

WHERE
HRO.organization_id = QTY.inventory_org_id
--AND HRO.organization_id = QTY.cost_org_id
--AND HRO.organization_id = COST.cost_org_id
AND HRO.organization_id = ITEMS.organization_id
AND QTY.cost_org_id = COST.cost_org_id
AND QTY.inventory_org_id = ITEMS.organization_id
--AND COST.cost_org_id = ITEMS.organization_id
AND QTY.inventory_item_id = COST.inventory_item_id
AND QTY.inventory_item_id = ITEMS.inventory_item_id
AND COST.inventory_item_id = ITEMS.inventory_item_id
AND QTY.total_quantity <> 0
AND ('ALL' IN (:P_Store || 'ALL') OR HRO.name IN (:P_Store))
AND ('ALL' IN (:P_Category || 'ALL') OR ITEMS.Category_Name IN (:P_Category))
AND ('ALL' IN (:P_Major_Category || 'ALL') OR ITEMS.CAT_Level1 IN
(:P_Major_Category))
AND ('ALL' IN (:P_Minor_Category || 'ALL') OR ITEMS.CAT_Level2 IN
(:P_Minor_Category))
AND ('ALL' IN (:P_Sub_Minor_Category || 'ALL') OR ITEMS.CAT_Level3 IN
(:P_Sub_Minor_Category))

ORDER BY 1

You might also like