We consider codes defined over an affine algebra A = R[X1, . . . , Xr]/ t1(X1), . . . , tr(Xr) , where ti(Xi) is a monic univariate polynomial over a finite commutative chain ring R. Namely, we study the A−submodules of A l (l ∈ 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.