One problem related to sun roof has been reported for the 1998 BMW 540. The most recently reported issues are listed below.
Sunroof failed and moving up and down on bumps. Dealer replaced sliding mechanism. Still rattles and doesn't function properly. Dealer declines to fix under warranty. Door seals squeek. Dealer lubricated them. Sill squeek after a few days. All cup holders broken. Dealer replaced them.