At present, the active power filter(APF) is a device that can effectively suppress harmonics. However, in the traditional control method, APF can only eliminate the harmonic voltage of a single node. This makes it difficult to apply to the harmonic suppression of the power grid with distributed harmonic sources. For that, how to effectively suppress the system-wide harmonics has become a topic worth studying. This paper proposes a control method that uses a single APF to suppress the system-wide harmonics of the grid. The method collects data generated during operation of the power grid, and then uses the neural network to fit the data to obtain a model between the compensation current of the APF and the voltage of each node. Based on this model, the optimal compensation current will be calculated and no grid parameters are required. Finally, the effectiveness of the proposed method is verified by simulation results.