Mahela Jayawardene was batting on 101 and Angelo Mathews was on 48.
South Africa won the opening Test in Galle to go 1-0 up in the two-Test series.