I am trying to understand how from a ring homomorphism we can get a sheaf homomorphism. And eventually a morphism in the affine schemes. I'm having a hard time understanding how from the map localization on the ring homomorphism we get the sheaf homomorphism. I tried to put everything I think I know below. Any explanation you can give would help me. Of course many things I wrote maybe wrong.
Let $\phi :S\to R$ be a ring homomorphism then $\phi$ includes a map $\phi_P$ on the localizations by sending the $[(\frac{g}{f^n},U)]\mapsto [(φ(\frac{g}{f^n}),φ(U))]$.
Then we can construct the structure sheaf from the localizations respectfully and include a ring homomorphism of sheaves aka the pullback $π^{\#}(f):=\phi\circ f$,
for $f\in \mathscr{O}_{{Spec}S}(U)$.
