Monte Carlo simulations have been used to study a vortex-free XY ferromagnet with a random field or a random anisotropy on simple cubic lattices. In the random field case, which can be related to a charge-density wave pinned by random point defects, it is found that long-range order is destroyed even for weak randomness. In the random anisotropy case, which can be related to a randomly pinned spin-density wave, the long-range order is not destroyed and the correlation length is finite. In both cases there are many local minima of the free energy separated by high entropy barriers. Our results for the random field case are consistent with the existence of a Bragg glass phase of the type discussed by Emig, Bogner and Nattermann.