For the guarantee of the long-distance transport of the bunches of China Initiative Accelerator Driven System (CIADS), a new scheme is proposed that extra magnetic field is used in the accelerator-target coupling section before the windowless target to minimize the self-modulation (SM) mechanism. Particle-in-cell simulations are carried out to study the influence of the solenoidal magnetic field on the self-modulation mechanism when long proton bunches move in the background plasmas. The long proton bunches used in the simulations are similar to these in the linear accelerator of CIADS. It is found that the presence of the solenoidal magnetic field will significantly inhibit the self-modulation process. For the strong magnetic field, the longitudinal separation and transverse focusing of the long bunches disappear. We attribute these phenomena to the reason that the strong solenoidal magnetic field restricts the transverse movement of plasma electrons. Thus, there are not enough electrons around the bunch to compensate the space charge effect. Moreover, without transverse current, the longitudinal pinched effect disappears, and the long bunch can not be separated into small pulses anymore.