|
|
发表于 2009/10/16 20:17:40
|
显示全部楼层
本帖最后由 FrankXu 于 2009/10/17 11:08 编辑
SELECT
PARENT/*本层父项物料号,非最顶层父项物料号*/,
COMPONENT /*本层子项物料*/,
oriQty /*本层原用量(未计算)*/,
QTY /*滚加用量,相对于最顶层父项*/,
NLVS /*所在层数*/,
COM_TYP,
FLAG /*排序标志*/,
--ic.TotalRoledCost AS StdCost,
CASE COM_TYP
WHEN 'B' THEN -QTY * ic.TotalRolledCost
WHEN 'N' THEN QTY * ic.AtThisLevelMaterialCost
ELSE 0
END AS MaterialCost /*当前物料的成本,相对于最顶层父项*/,
CASE COM_TYP
WHEN 'R' THEN QTY * ic.AtThisLevelLaborCost
ELSE 0
END AS LaborCost /*当前工时成本,相对于最顶层父项*/
FROM
dbo.udf_BOMQuery ('父项物料号','有效日期',0) a,
FSDBMR.dbo.FS_Item it,
FSDBMR.dbo.FS_ItemCost ic
WHERE
a.Component=it.ItemNumber
AND it.ItemKey=ic.ItemKey
AND ic.CostType='0'
--其它限定条件
1. 查询每层工时成本 AND COMPONENT LIKE 'WC%'
2. 查询每层物料成本 AND COMPONENT NOT LIKE 'WC%'
3. 查询某层成本 AND NLVS=指定层数
以上查询为各层材料/工时的明细记录,需要累计值,可自行按要求进行汇总.
udf_BOMQuery Function Introduce:
first paramater: Parent ItemNumber
second Paramater: BOM effectivity date, null value is no limited
third Parmaterial: value 1 is spread to lowest bottom, whether component_type is P
value 0 only spread 'P' component_type |
|