I saw
I'm happy to have you as my friend.
being translated as
Ich freue mich, Sie als meinen Freund zu haben.
But I thought since meinen comes after the preposition als, it should be meinem (i.e. masculine dative form). I think the direct object of haben is Sie, and als meinen Freund being just an adverbial phrase. Am I wrong?