Marques Ackerman scored 157 off 164 balls in his third Test.
South Africa finished day two on 287/4, trailing Bangladesh by 113 runs.
Ackerman and Zubayr Hamza added 202 runs for the second wicket.
Bangladesh made 400 all out, their highest total against South Africa.
Day three begins on Tuesday, 17 November, with the first ball at 8am GMT.
Apex Sports News
Marques Ackerman scored 157 off 164 balls as South Africa made 287 for four in reply to Bangladesh's 400. The Proteas trail by 113 runs at stumps on day two.