  {\it Ab-initio} studies of the stability of orbital ordering, its coupling to
magnetic structure and its possible origins (electron-phonon and/or
electron-electron interactions) are reported for two perovskite systems,
LaMnO$_3$ and KCuF$_3$. We present a new Average Spin State (ASS) calculational
scheme that allowed us to treat a paramagnetic state. Using this scheme, we
succesfully described the experimental magnetic/orbital phase diagram of both
LaMnO$_3$ and KCuF$_3$ in crystal structures when the Jahn-Teller distortions
are neglected. Hence, we conclude that the orbital ordering in both compounds
is purely electronic in origin.
