High-power laser plays an important role in many fields, such as directed energy weapon, optoelectronic contermeasures, inertial confinement fusion, industrial processing and scientific research. The uniform nearfield is the important part of the beam quality for high power lasers, which is conducive to maintaining the high spatial beam quality in propagation. We demonstrate experimentally that the spatial intensity distribution at the output is well compensated in the complex high-power solid-state laser system by using the small-aperture spatial light modulator (SLM) in the front stage. The experimental setup is a hundred-Joule-level Nd:glass laser system operating at three wavelengths at 1053 nm (1ω), 527 nm (2ω) and 351 nm (3ω) with 3 ns pulse duration with the final output beam aperture of 60 mm. While the clear arperture of the electrically addressable SLM is less than 20 mm. In the beam shaping system, the key point is that the front-stage SLM needs to precompensate the gain nonuniform of the laser system. Liquid crystal SLM is an effective active beam shaping device through adjusting each pixel transmittance to improve the spatial beam quality of the output laser, which can also be used as a binary optical element (BOE) with each pixel transmittance 0 or 1 to realize spatial beam shaping for high-power lasers. We present and demonstrate an efficient shaping method of the SLM used as BOE based on diffraction principle. The method can be used to control the output nearfield actively by compensating the spatial nonuniformity of transmission and amplification in the high power laser system. Results show the output nearfield beam quality improves significantly after shaping by using this method with the fluence contrast changing from 22% to 11.3% within only 2 shots in the single-shot operation laser.