Hi,
It seems that the SDT_TO_TOD function is missing a cast. To function properly the .SECOND part of the SDT-structure must be converted to a DINT. The compiler apparently realizes that the other parts must be converted (since they are multiplied by numbers larger than what an INT can hold)...
The correct conversion would be:
SDT_TO_TOD := DINT_TO_TOD(DTI.HOUR * 3600000 + DTI.MINUTE * 60000 + INT_TO_DINT(DTI.SECOND) * 1000 + DTI.MS);