A steel parallelepiped with a square cross-section fits exactly into the cavity. it's loaded from the top surface(see picture). how can I calculate the stress in X- and Y-direction if the strain in X- and Y-direction is zero.
Depending on the structural properties of the surrounding material, you will have transfer of stress and strain between the two.
But let's assume there is no side strain for now.
Then you have to superpose two cases.
1- the vertical loading
2- assuming 1/3 strain along X and Z axis, calculate the pressure that would deflect them back to zero and apply that as lateral loading.
You can do this by a couple of iterations, and I guess some FEM programs allow for setting this up as a support constrain.