The ECU understands the request, but the vehicle is not in a state where it is allowed.
What the response looks like
Request: 31 01 FF 00
Response: 7F 31 22
Erase memory routine started while the engine runs. In a negative response, 7F is the negative response service ID, 31 is the service that was refused (RoutineControl), and 22 is this code.
When ECUs send it
The request is valid, but the vehicle or ECU is not in a state where it is allowed: engine running, vehicle moving, voltage out of range, a previous step not done.
The most common code for routines and writes, because the conditions are ECU-specific and do not have their own code.
Often seen when starting a flash erase or a write of protected data at the wrong time.
What to try
Typical conditions: vehicle stationary, engine off, voltage in range, previous step done. Check preconditions.