I’ve just finished getting to the bottom of the same code however my roof and boot all worked fine. I replaced the two hall sensors on the underside of the right hand ram. It still gave random bongs. I then replaced the two microswitches either side in the boot.
This is from the post I used.
Hall sensor: £15 Part No. 54 34 7 190 735 bought directly from BMW (just pretend you have a 1 series convertible to get to checkout).
Connector pins: £2.50 Part No. 61131393723 I bought them from ebay but I'm sure you can get them from elsewhere.
Connector block: £3? Part No. 8373575-02 I personally reused the one that came off the old part, but one can be bought from aliexpress with a pretty long delivery time, however it means you can just do a straight swap when the part arrives.
After that you just need cut the wires to the correct length, strip the cable, crimp the connector pins to the cable, put the pins into the connector block, then put the part back into the car. It's fiddly, but I found it could be done in place without having to remove anything.
https://www.sytnerstevenagebmwparts.co.uk/p/Bmw__/Hall-sensor/132266649/54347190735.html
https://www.sytnerstevenagebmwparts.co.uk/p/132285109/61131393723.html
Micro switch
54377228585
54377228586