Hartmann then moved to the BdU as a staff officer, and in November 1940 became commander of the 2nd ULD (U-boat Training Division). A year later he took command of the 27th U-boat Flotilla in Gotenhafen. In November 1942 he took command of the large Type IXD U-198 for a patrol to the Indian Ocean lasting 200 days, the third longest patrol ever undertaken, and sank 7 ships totalling 36,778 GRT.