\u3cp\u3eIntegrated Emission Management (IEM) is a supervisory control strategy that minimises operational costs (consisting of fuel and AdBlue) for diesel engines with an aftertreatment system, while satisfying emission constraints imposed by legislation. In most work on IEM, a suboptimal heuristic real-time implementable solution is used, which is based on Pontryagin's Minimum Principle (PMP). In this paper, we compute the optimal solution using both PMP and Dynamic Programming (DP). As the emission legislation imposes a terminal state constraint, standard DP algorithms are sensitive to numerical errors that appear close to the boundary of the feasible sets. Therefore, we propose two extensions to existing DP methods, which use an approxi...