MES: the details
It sits between the ERP and the machines. The ERP knows what has to be made and by when; the PLCs and SCADA know what each piece of equipment is doing this second. The MES joins the two worlds: it receives the orders, dispatches them, collects output, stops, consumption and quality checks, and reports back to the ERP what was really made. Lot traceability and the OEE calculation come from there.
Not every factory needs a full MES. Many mid-sized plants cover the essentials—a digital production report, meter readings and traceability—with a custom application connected to the ERP. What matters is that the data is captured once and on the spot.