As pointed out here:
Call a stored procedure in select query[
^]:
The problem with that call is that there's no guarantee that the stored procedure won't change the state of the database if it's run. Because of this, the SQL server won't allow you to use a procedure inside a function.
As a workaround you should use for example SELECT statements instead of the procedures to insert data in the intermediate table.