Many thanks,
Jeff
Check all grounds first, then test the alternator and internal voltage regulator because system voltage drops from about 14 to 12 volts. Inspect plug wires that may have been loosened during the battery replacement, and replace the MAF if the P0171 lean code continues. Clear codes by pulling the main under-hood fuse for about a minute. A dealer ECU idle reprogram is not required; the computer should relearn unless a sensor is sending bad data.
After a mechanic replaced the battery on a 2001 Audi A4, the car set P0300, P0301, and P0302 misfire codes and sometimes died until restarted, then idled roughly before smoothing out. The owner also had a P0171 code and had cleaned the MAF and ordered a new one. The expert suspected disturbed plug wires, stressed checking grounds and the alternator because of the voltage drop, and said the ECU relearns idle on its own without a dealership reset unless a sensor is faulty.