sap mes 15.3 eq库存 盘盈盘亏分摊逻辑
1.取盘盈盘亏条码
with ta as /*取盘盈盘亏条码 1/2 */
(select site, storage_location, item, unit_of_measure, qty, comment9 inventory_id, created_date_time +
8 / 24 created_date_time, 'InventoryBO:' || site || ',' || comment9 inventory_bo
from z_inventory_transaction2 x
where apportion = 'N' and ( /*x.TRANSACTION_REASON_CODE = 'Z01A' or 此处暂时只考虑 盘亏的部分*/
x.transaction_reason_code = 'Z01A')
order by x.storage_location, item)
2.盘盈盘亏条码 串查EQ信息
with ta as /*取盘盈盘亏条码 1/2 */
(select site, storage_location, item, unit_of_measure, qty, comment9 inventory_id, created_date_time +
8 / 24 created_date_time, 'InventoryBO:' || site || ',' || comment9 inventory_bo
from z_inventory_transaction2 x
where apportion = 'N' and ( /*x.TRANSACTION_REASON_CODE = 'Z01A' or 此处暂时只考虑 盘亏的部分*/
x.transaction_reason_code = 'Z01A')
order by x.storage_location, item),
ta1 as /*盘盈盘亏条码 串查EQ信息 2/2 */
(select ta.*, iad.data_attr so_num, iad1.data_attr so_line_num, iad2.data_attr wbs_num
from ta, inventory_assy_data iad, inventory_assy_data iad1, inventory_assy_data iad2
where (ta.inventory_bo = iad.inventory_bo(+) and
iad.data_field(+) = 'SO_NUM') /*串查销售单号*/
and (ta.inventory_bo = iad1.inventory_bo(+) and
iad1.data_field(+) = 'SO_LINE_NUM') /*串查销售行*/
and (ta.inventory_bo = iad2.inventory_bo(+) and
iad2.data_field(+) = 'WBS_NUM') /*串查wbs*/ /*盘盈盘亏条码串查EQ*/
)
3.线边仓匹配产线
with ta as /*取盘盈盘亏条码 1/2 */
(select site, storage_location, item, unit_of_measure, qty, comment9 inventory_id, created_date_time +
8 / 24 created_date_time, 'InventoryBO:' || site || ',' || comment9 inventory_bo
from z_inventory_transaction2 x
where apportion = 'N' and ( /*x.TRANSACTION_REASON_CODE = 'Z01A' or 此处暂时只考虑 盘亏的部分*/
x.transaction_reason_code = 'Z01A')
order by x.storage_location, item),
ta1 as /*盘盈盘亏条码 串查EQ信息 2/2 */
(select ta.*, iad.data_attr so_num, iad1.data_attr so_line_num, iad2.data_attr wbs_num
from ta, inventory_assy_data iad, inventory_assy_data iad1, inventory_assy_data iad2
where (ta.inventory_bo = iad.inventory_bo(+) and
iad.data_field(+) = 'SO_NUM') /*串查销售单号*/
and (ta.inventory_bo = iad1.inventory_bo(+) and
iad1.data_field(+) = 'SO_LINE_NUM') /*串查销售行*/
and (ta.inventory_bo = iad2.inventory_bo(+) and
iad2.data_field(+) = 'WBS_NUM') /*串查wbs*/ /*盘盈盘亏条码串查EQ*/
),
tb as /*线边仓匹配产线 1/2*/
(select distinct sl.storage_location, /*slm.*,*/ wcm.work_center_bo
from storage_location sl, storage_location_member slm, work_center_member wcm
where slm.storage_location_bo = sl.handle and exists
(select 1 from ta where ta.storage_location = sl.storage_location) /*限定只返回涉及盘盈盘亏的仓库*/
and wcm.work_center_or_resource_gbo = slm.work_center_bo)