Gme Queries
Gme Queries
gbh.*,
'gme_batch_steps',
gbs.*,
'gme_batch_step_activities',
gbsa.*,
'gme_batch_step_resources',
gbsr.*,
'gmp_process_parameters',
gppp.*,
'gme_process_parameters',
gpp.*
FROM gmp_process_parameters gppp,
gme_process_parameters gpp,
gme_batch_step_resources gbsr,
gme_batch_step_activities gbsa,
gme_batch_steps gbs,
gme_batch_header gbh
WHERE gbh.batch_id = gbs.batch_id
AND gbs.batchstep_id = gbsa.batchstep_id
AND gbsa.batchstep_activity_id = gbsr.batchstep_activity_id
AND gbh.batch_id = gpp.batch_id
AND gbs.batchstep_id = gpp.batchstep_id
AND gbsa.batchstep_activity_id = gpp.batchstep_activity_id
AND gbsr.batchstep_resource_id = gpp.batchstep_resource_id
AND gpp.parameter_id = gppp.parameter_id
SELECT gbh.batch_no
,gr.recipe_description
,gbh.recipe_validity_rule_id
,ffm.formula_desc1 formula_name
,gmd.inventory_item_id
,msi.description
,CASE
WHEN gmd.line_type = -1 THEN 'Ingredient'
WHEN gmd.line_type = 1 THEN 'Product'
WHEN gmd.line_type = 0 THEN 'Byproduct'
END
TYPE
,mmt.transaction_date
,mmt.transaction_quantity
-- ,SUM (mmt.transaction_quantity) quantity
FROM apps.gme_batch_header gbh
,apps.gmd_recipes gr
,gmd_recipe_validity_rules grvr
,apps.gme_material_details gmd
,fm_form_mst ffm
,apps.mtl_system_items msi
,apps.mtl_material_transactions mmt
WHERE gbh.formula_id = gr.formula_id
AND gbh.routing_id = gr.routing_id
AND gbh.recipe_validity_rule_id = grvr.recipe_validity_rule_id
AND grvr.recipe_id = gr.recipe_id
AND gbh.batch_id = gmd.batch_id
AND ffm.formula_id = gbh.formula_id
AND gbh.organization_id = gmd.organization_id
AND gmd.inventory_item_id = msi.inventory_item_id
AND gmd.organization_id = msi.organization_id
AND gbh.batch_id = mmt.transaction_source_id
AND gbh.organization_id = mmt.organization_id
AND gmd.inventory_item_id = mmt.inventory_item_id
AND gbh.batch_no = :p_batch_no
--GROUP BY gbh.batch_no
-- ,gr.recipe_description
-- ,gbh.recipe_validity_rule_id
-- ,ffm.formula_desc1
-- ,gmd.inventory_item_id
-- ,msi.description
-- ,gmd.line_type
ORDER BY batch_no, mmt.transaction_date, type;
SELECT ffm.formula_id,
ffm.formula_no,
ffm.formula_desc1 formula_name,
ood.organization_code org,
CASE
WHEN fmd.line_type = -1 THEN 'INGREDIENT'
WHEN fmd.line_type = 1 THEN 'PRODUCT'
WHEN fmd.line_type = 0 THEN 'BYPRODUCT'
END
TYPE,
msi.segment1 item_code,
fmd.qty,
fmd.detail_uom,
CASE WHEN ffm.formula_status = 700 THEN 'Active' ELSE 'New' END status
FROM apps.fm_matl_dtl fmd,
apps.fm_form_mst ffm,
apps.mtl_system_items_b msi,
apps.org_organization_definitions ood
WHERE fmd.formula_id = ffm.formula_id
AND ( fmd.inventory_item_id = msi.inventory_item_id(+)
AND fmd.organization_id = msi.organization_id(+))
AND fmd.organization_id = ood.organization_id
AND ffm.formula_id = 151;