Ab-initio calculation of K shell absorption spectra in transition metal compounds