Some time ago, my BMW 530i (E39) dashboard suddenly showed a check engine light. It disappeared and re-appeared several times and eventually stayed on, but without a loss of power (unlike with the faulty crankshaft sensor). INPA reported a tank ventilation error, and a quick search on Google revealed a faulty tank ventilation valve as most likely cause of error.
The original BMW replacement part costs more than €80, but on the German E39 forum users reported good results with the Febi Bilstein equivalent (which might just be the OEM supplier) that is available online for a bit above €50. It arrived quickly and I set on replacing it on a sunny morning.
The tank ventilation valve is located below the intake manifold, right behind the power steering fluid reservoir:
Getting there involves removing the air box and mass airflow meter. Then unclip the connector, wiggle it off the metal bracket, and remove all hoses. Plug the hoses onto the new valve, make sure that the mounting rubber is rotated correctly, then push it onto the bracket. Finally clip on the connector again, and put the air box and airflow back in. Make sure to route all cables correctly and tighten all hose clamps.
All together this shouldn’t take more than 45 minutes, and the only tools required are a ratchet with a 10mm (for the bolt that holds the air box) and 6mm socket (for the hose clamps).