There is an exercise (Exercise 10.25 in Gallian's Contemporary Abstract Algebra 8/e) which asks: How many group homomorphisms are there from $\Bbb{Z}_{20}$ onto $\Bbb{Z}_{10}$? How many are there to $\Bbb{Z}_{10}$?
The answer is $\varphi(10)=4$ and $10$, respectively. It is sufficient to determinet the image of the generator of $\Bbb{Z}_{20}$. But I found an example which seems to be a homomorphism, but it is not. The example is: $\theta:\Bbb{Z}_3\times \Bbb{Z}_2\to S_3$, $\theta(1,0)=(123)$ and $\theta(0,1)=(12)$. This mapping preserve the operation. But it is not well-defined. $$(123)(12) =\theta(1,0)\cdot \theta(0,1) =\theta((1,0)+(0,1)) =\theta(1,1) =\theta((0,1)+(1,0)) =\theta(0,1)\cdot \theta(1,0) =(12)\cdot (123).$$
Is the following statement true? Let $G\cong \Bbb{Z}_{p_1^{r_1}}\times \Bbb{Z}_{p_2^{r_2}}\times \cdots \times \Bbb{Z}_{p_s^{r_s}}$ and $H$ be two finite additive abelian groups. If a mapping $f:G\to H$ satisfy $p_1^{r_1}f(1,0,...,0)=0_{H}$, $p_2^{r_2}f(0,1,0,...,0)=0_{H}$, ..., $p_s^{r_s}f(0,0,..., 0,1)=0_{H}$, then $f$ must be a homomorphism from $G$ to $H$.
Remark. There is an error in my question. I can't just only define $f$ as a ``function''. For example, define $f:\Bbb{Z}_2\to \Bbb{Z}_2$ by $f(0)=f(1)=1$. Which satisfy the condition. But it is not a homomorphism.