  We consider codes defined over an affine algebra $\mathcal
A=R[X_1,\dots,X_r]/\left\langle t_1(X_1),\dots,t_r(X_r)\right\rangle$, where
$t_i(X_i)$ is a monic univariate polynomial over a finite commutative chain
ring $R$. Namely, we study the $\mathcal A-$submodules of $\mathcal A^l$ ($l\in
\mathbb{N}$). These codes generalize both the codes over finite quotients of
polynomial rings and the multivariable codes over finite chain rings. {Some
codes over Frobenius local rings that are not chain rings are also of this
type}. A canonical generator matrix for these codes is introduced with the help
of the Canonical Generating System. Duality of the codes is also considered.
