How to notify production batch variances to group members

Query to identify production batch variances (Actual VS WIP Planned)

Below query will identify variances for ingredients/by-products/products

Batch variance details will be electronically sent to distribution list members

Set periodic alert - frequency- everyday and set timings

Under actions -> set action type is message

Link distribution list members and set message text

In action sets -> set all the actions you have created

Query
select itemcode
       ,plan_qty
       ,wip_plan_qty
       ,actual_qty
       ,ROUND(diff, 2) diff
       ,ptype
       ,batchno
       ,(select user_name from fnd_user where user_id = qry.created_by ) created_by_name
       ,(select user_name from fnd_user where user_id = qry.last_updated_by ) updated_by_name
       ,batchstatus
       into &itemcode, &plan_qty, &wip_plan_qty, &actual_qty, &diff, &ptype, &batchno, &created_by, &updated_by, &batch_status
from      
(select (select segment1
         from mtl_system_items_b mi
         where inventory_item_id = gmd.inventory_item_id
         and organization_id = gmd.organization_id ) itemcode
, plan_qty
,wip_plan_qty,actual_qty
, (abs(actual_qty - wip_plan_qty)/actual_qty) *100 diff
, 'Ingredient' ptype
, (select batch_no from gme_batch_header where batch_id = gmd.batch_id ) batchno
, (select batch_status from gme_batch_header where batch_id = gmd.batch_id ) batchstatus
, created_by
, last_updated_by
from gme_material_details  gmd
where trunc(creation_date) = trunc(sysdate)
 and line_type = -1
 and actual_qty <> 0
 union all

select (select segment1
         from mtl_system_items_b mi
         where inventory_item_id = gmd.inventory_item_id
         and organization_id = gmd.organization_id ) itemcode
, plan_qty
,wip_plan_qty,actual_qty
, (abs(actual_qty - wip_plan_qty)/actual_qty) *100 diff
, 'Product'
, (select batch_no from gme_batch_header where batch_id = gmd.batch_id ) batchno
, (select batch_status from gme_batch_header where batch_id = gmd.batch_id ) batchstatus
, created_by
, last_updated_by
from gme_material_details  gmd
where trunc(creation_date) = trunc(sysdate)
 and line_type = 1
 and actual_qty <> 0
 ) qry
 where diff > 2
  and batchstatus in (3,4)

Comments

Popular posts from this blog

Query to get FSG report details with row/column set

How to use lexical parameters in Data template (XML document) R12

Sub Inventory Transfer API.