When buying a replacement bmw engine you need to buy the exact one you already have, in bmw its part of VIN
E.g. your 2009 740i which is an F01 chassis would be an N54B30 which is also in 335 and 535i,
Twin turbo 3.0 straight six without valvetronic.
There are some variations of it too. To make this confusing, there is a high power version of this engine which is used in 335 and 740 - but not 535 - this is why the exact chassis code is required.
Whats wrong with your old engine? N54 are pretty damn torquey engines, they do have oddball failures like turbos, high pressure fuel pump, vacuum pump leak, valve cover fracturing and even water pump if maintenance is not done on them.