Method for updating a control program of an automation system with data migration of a program state of the control program, wherein a controller of the automation system comprises a first control program and a second control program, wherein the first control program is executed for controlling the automation system, wherein the second control program is an update of the first control program, wherein the first control program comprises a first data element of a first data type, which describes a program state of the first control program and is stored in a first memory area of the controller, wherein the first data element comprises a plurality of first data sub-elements required for executing the first control program, wherein the second control program comprises a second data element of a second data type, which describes a program state of the second control program and is stored in a second memory area, and wherein the second data element comprises a plurality of second data sub-elements required for executing the second control program, comprising: initializing the second data element in an initialization step, wherein the initializing comprises setting a value of the second data element to a predetermined initial value, and wherein initializing the second data element comprises initializing all second data sub-elements of the second data element; generating a first migration function for mapping the first data element to the second data element in a first generation step, interrupting the execution of the first control program in an interruption step, determining a value of the first data element in a first determination step, wherein the determined value of the first data element describes a program state of the first control program at the time of the interruption, and mapping the value of the first data element to the second data element and writing values of first data sub-elements to second data sub-elements, which are initiated with an initial value, by executing the first migration function in a migration step, characterized in that the control program is executed cyclically, and in that the initialization step is executed at a time before the migration step. initializing the second data element in an initialization step, wherein the initializing comprises setting a value of the second data element to a predetermined initial value, and wherein initializing the second data element comprises initializing all second data sub-elements of the second data element; generating a first migration function for mapping the first data element to the second data element in a first generation step, interrupting the execution of the first control program in an interruption step, determining a value of the first data element in a first determination step, wherein the determined value of the first data element describes a program state of the first control program at the time of the interruption, and mapping the value of the first data element to the second data element and writing values of first data sub-elements to second data sub-elements, which are initiated with an initial value, by executing the first migration function in a migration step, characterized in that the control program is executed cyclically, and in that the initialization step is executed at a time before the migration step.