Is there a version of the structure theorem for f.g. abelian groups that applies to homomorphisms? The structure theorem for finitely-generated (f.g.) abelian groups tells us that every f.g. abelian group can be written in a very special form. Suppose I have a group homomorphism $f : X \rightarrow Y$ here $X$ and $Y$ are f.g. abelian groups. Is there a theorem which guarantees that not only can $X$ and $Y$ be decomposed in a very particular way, but in fact we can decompose $f$ somehow as well?
Generalization to modules over a PID is also of interest.
 A: If $X$ and $Y$ are finitely generated $R$-modules for a PID $R$, then the structure theorem tells us that there are isomorphisms $\phi: X\rightarrow R^n\oplus \bigoplus_{i=1}^r R/(p_i^{e_i})$ and $\psi: Y\rightarrow R^m\oplus \bigoplus_{j=1}^s R/(q_j^{f_j})$ where $p_i$ and $q_j$ are prime elements in $R$ and $n,m,e_i,f_j$ are natural numbers (allowed to be zero in case of $n$ and $m$). If $f:X\rightarrow Y$ is a homomorphism, then we consequently get
$$\psi\circ f \circ \phi^{-1}:R^n\oplus\bigoplus_{i=1}^r R/(p_i^{e_i})\rightarrow R^m\oplus\bigoplus_{j=1}^s R/(q_j^{f_j}).$$
But this homomorphism we understand pretty well: In general, if $M=\bigoplus_{k=1}^m M_k$ and $N=\bigoplus N_{l=1}^n N_l$ are $R$-modules, the universal property of direct sums gives us
$$\hom_{R}(M,N)=\bigoplus_{k,l}\hom_R(M_k,N_l).$$
Explicitly, this equality is achieved by precomposition and postcomposition of a homomorphism $M\to N$ by the various inclusions and projections of the direct summands. Each element of the right-hand side can be considered as an $n\times m$-matrix of homomorphisms between the individual direct summands. Specializing this to the homomorphism $\psi\circ f\circ \phi^{-1}$, we can therefore consider this map as an $(m+s)\times (n+r)$-matrix of homomorphism between the various direct summands that occur in the decomposition, which are all cyclic modules. 
As a consequence, we get a decomposition of $f$ into a matrix of homomorphisms that are easily understood, since each homomorphism out of a cyclic module is determined by what a generator is mapped to.
