Skip to main content

mes.spGetLotActivity

Description

Returns a history of lot activity, including movements, quantities, lot states, and operation metadata. Useful for material traceability and inventory audits. Includes JOINs on `vwLot` and `vwLotEvent`.

Syntax

mes.spGetLotActivity @lotId, @lotName, @assetId, @assetPath, ...

Parameters:
@lotId (int): Specific lot to trace.
@lotName (nvarchar): Lot name (supports partial matches).
@assetId (int): Filter to a specific asset.
@assetPath (nvarchar): Asset path (supports LIKE).
@hasQty (bit): If 1, only show lots with non-zero net movement.
@startDate, @endDate (datetime): Filter by event timestamps.
@workOrderId, @workOrderName (int/nvarchar): Work order filters.
@itemId, @itemName, @itemPath (int/nvarchar): Item filters.
@assetTransportName (nvarchar): Optional transport association.
@lotStateName, @lotStateReasonName (nvarchar): Optional lot state filters.

Returns:
Summarized lot activity records per lot ID, including:
- Item and unit info
- State and reason
- Asset, transport, and timestamp data
- Work order and quantity summary

Code Example

EXEC mes.spGetLotActivity
@lotName = '%FG%',
@hasQty = 1,
@startDate = '2025-07-01',
@endDate = '2025-07-30';