First I replaced a whole headlight unit on my Z4 due to water intrusion, then I swapped projectors. No coding needed at all
I believe there is no special controller for high beam inside the headlight, just a wire to power up the actuator.
I retrofitted bixenon in my e39 and have the actuator connected directly to high beam bulb wires. In fact you can do the same in your headlight to avoid replacing it if you don't find the source of troubles
Retrofitlab offers specific harness to get power for the actuator from high beam bulb for e39, maybe it's the same with Z4, I haven't checked the high beam bulb connector type in the Z4, so I'm not sure.
I'd start with checking the actuator wires inside the headlight, follow those wires where they go and see if there is something wrong with them. You might just be looking for a wire that is broken inside. Try to bend the wires and see if they are broken somewhere.

I believe there is no special controller for high beam inside the headlight, just a wire to power up the actuator.
I retrofitted bixenon in my e39 and have the actuator connected directly to high beam bulb wires. In fact you can do the same in your headlight to avoid replacing it if you don't find the source of troubles

I'd start with checking the actuator wires inside the headlight, follow those wires where they go and see if there is something wrong with them. You might just be looking for a wire that is broken inside. Try to bend the wires and see if they are broken somewhere.