What is considered more haram, masturbation for men or men having friendship with a woman??

Both of them are haraam because it is disobedience to Allah’s command. There is no such thing as more or less haraam.