A tank in general is suitable for the close fight in general for less then 5km (or we can say line of sight) and a very accurate fire. Because tanks are used in the close fight so they in general fire straight and are protected with heavy armor.
Where is Self propelled artillery is used for the massive bombardment in general in the range of 50 km which is not in general accurate. SPA are in general fire at an angle and away from the battle field which reduces the requirement of heavy armor.