On Day Two of the Test, Sharma made 119 while Raina hit 135. On Day One, skipper Cheteshwar Pujara had scored 137 to help India gain control in the match.
Sharma and Raina had a 106-run partnership for the fourth wicket, which was broken when Sharma was caught by Temba Bavuma off JP Duminy.
India resumed the innings at 281 for three and declared after scoring 582 for nine as the Proteas were unable to break the last-wicket stand between Shahbaz Nadeem (46) and Jaydev Unadkat (31).
South Africa were 20 for the loss of one wicket in reply as Unadkat got opener Reeza Hendricks (10) caught behind. At stumps, Dean Elgar and Simon Harmer were at the crease.
Kareena Kapoor Khan looks in fab shape after weight loss! See photos
Mumbai food: 9 dishes to try during 9 days of Navratri
Photos: Hrithik Roshan, Nidhhi Agerwal and Adah Sharma walk the ramp
Photos: Shah Rukh Khan spotted with new set of wheels
Photos: Kareena Kapoor Khan, Kangana Ranaut at the Mumbai airport