Sheaf associated to a Cartier divisor This question is motivated by a construction, unclear for me, related to Cartier divisors. But, in the end it can be reduced to a question involving only sheaves on topological spaces.  
Let $X$ be a locally Noetherian scheme. Consider a Cartier divisor $D=\{(f_i,U_i)_i\}$ where as usual:


*

*$X=\bigcup_i U_i$ is an open cover

*$f_i\in\mathcal K_X^\times(U_i)$ and $\frac{f_i|_{U_i\cap U_j}}{f_j|_{U_i\cap U_j}}\in\mathcal O_X^\times$. Remember that $\mathcal K_X$ is the sheaf of stalks of meromorphic functions.


We want to define a subsheaf $\mathcal O_X(D)\subset K_X$ associated to $D$. Liu's and Hartshorne's book give the following definition:
$$\mathcal O_X(D)(U_i):=f_i^{-1}\mathcal O_X(U_i)$$
Therefore they define the sheaf only on the open stes $U_i$. Where is the definition of $\mathcal O_X(D)$ on the remaining open sets of $X$?
I'm sure that my question will be solved some argument of the type: "there exists a unique minimal subsheaf $\mathcal G$ of $\mathcal K_X$ such that $\mathcal G(U_i)=\mathcal O_X(D)(U_i)$".
Unfortunately I can't find any reference for this result.
 A: The value of the sheaf $\mathcal O_X(D)$ at an arbitrary open subset $U\subset X$ is the sub- $\mathcal O_U$ -module    $\mathcal O_X(D)(U)\subset K_X(U)$ of $K_X(U)$ characterized by 
$$\mathcal O_X(D)(U)=\{s\in K_X(U) : \forall i,s\vert U_i\cap U\in  (f_i\vert U_i\cap U) ^{-1}\mathcal O_X(U_i\cap U)                \}$$ nothing more and nothing less.
There are no isomorphisms, gluing nor cocycle conditions in this definition.   
A: In order to glue together sheaves defined on an open cover, you need some compatibility data. 
Let $F_i$ be a sheaf on $U_i$, and $F_{ij} = (F_i)_{|U_i\cap U_j}$. You want the $F_i$ to be of the form $F_{|U_i}$ for a sheaf $F$ on $X$. If that were true than clearly $F_{ij} \simeq F_{|U_i\cap U_j} \simeq F_{ji}$.
So the gluing data consists of isomorphisms $f_{ij}: F_{ij}\to F_{ji}$, such that $f_{ii} = Id$, and $f_{ik} = f_{jk}\circ f_{ij}$ on $U_i\cap U_j\cap U_k$ (which is called the cocycle condition).
In your situation you have not only $\mathcal O_X(D)(U_i):=f_i^{-1}\mathcal O_X(U_i)$, but actually $\mathcal O_X(D)_{|U_i}:=f_i^{-1}(\mathcal O_X)_{|U_i}$, so you get a sheaf on each $U_i$ and you can check that there is the necessary gluing data to construct an honest sheaf on $X$.
