This paper presents a novel direct method called the stress compensation method (SCM) for structural shakedown analysis. Being different from the popular direct method of mathematical programming, the SCM just carries out some iterative calculations. Making full use of static shakedown theorem, the residual stress field is constructed via solving the modified global equilibrium equations. An effective and robust iteration control technique is adopted to generate a sequence of decreasing load multipliers. The numerical procedure is incorporated into the ABAQUS platform via some user subroutines. The shakedown problems for a cantilever beam, a symmetric continuous beam and a practical shell with nozzles are effectively solved and analyzed. These results are compared to the analytical solutions and those found in literatures. Both the incremental collapse mechanism and the alternating plasticity mechanism are revealed to determine the shakedown boundaries. Numerical examples show that the SCM is of numerical stability, good accuracy, high computational efficiency, and can effectively perform shakedown analysis of large-scale practical engineering structures.