mes.spGetAssetProductionEvents
Description
Retrieves production mode events for a given asset over a date range. Optionally filters by mode, work order, or current mode. Calculates production-related metrics like counts and OEE components when applicable.Syntax
mes.spGetAssetProductionEvents @assetId, @rangeStart, @rangeEnd, @modeId, @workOrderId, @activeModeOnly, @strictDatesParameters:
@assetId (int): ID of the asset to retrieve data for.
@rangeStart (datetime): Start date of the time range (nullable).
@rangeEnd (datetime): End date of the time range (nullable).
@modeId (int): Optional filter by mode ID.
@workOrderId (int): Optional filter by work order ID.
@activeModeOnly (bit): If 1, only retrieves currently active production mode.
@strictDates (bit): If 1, trims event times to fall strictly within the given range.
Returns:
Table of production events, enriched with:
- Shift-adjusted start and end times
- Counts, durations, OEE breakdowns (availability, performance, quality)
- Related item and work order metadata
Code Example
-- Retrieve production events for asset 4021, filtering by work order
EXEC mes.spGetAssetProductionEvents
@assetId = 4021,
@rangeStart = '2025-07-01',
@rangeEnd = '2025-07-30',
@modeId = NULL,
@workOrderId = 8001,
@activeModeOnly = 0,
@strictDates = 1;