So here is my solution:
1. You have to check if In port has any value otherwise empty BO is created and you can not save.
2. Use the logic proposed from Stefan .
3. Add additional check if In port and current BO are different if yes create new BO .
see pictures for details.
1)
2) It is only in default when Inport is not initial.
3)Create and assign
I am not sure if empty comparison is needed probably not but it works that way.
Cheers Ognian