The Program is stored in non-volatile ROM, which does not require battery backup and should remain intact in the order of years.
There is a persistent memory area that allows retaining variable values after a power cycle.
This data is stored in the Non-volatile RAM - not requiring a battery.
The variables can be defined in the code with SoMachine / EcoStruxure Machine Expert software.