How was the sun's mass calculated?

Flexi Says:
The Sun's mass can be calculated by rearranging Kepler's third law equation to give M = 4π2a3/Gp2. Here M is the mass of the Sun; p is the orbital period; a is the orbit semi-major axis distance, and G is the gravitation constant. Substituting the values of a, G and, the mass of the Sun is calculated as, M = 1.99 x 1030Kg.