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 (A) and a second control program (B), wherein the first control program (A) is executed for controlling the automation system , wherein the second control program (B) is an update of the first control program (A), wherein the first control program (A) comprises a first data element (GA) of a first data type, which describes a program state of the first control program (A) and is stored in a first memory area (SPA) of the controller , wherein the first data element (GA) comprises a plurality of first data sub-elements (GA1) required for executing the first control program (A), wherein the second control program (B) comprises a second data element (GB) of a second data type, which describes a program state of the second control program (B) and is stored in a second memory area (SPB), and wherein the second data element (GB) comprises a plurality of second data sub-elements (GB1) required for executing the second control program (B), comprising: initializing the second data element (GB) in an initialization step , wherein the initializing comprises setting a value of the second data element (GB) to a predetermined initial value, and wherein initializing the second data element (GB) comprises initializing all second data sub-elements (GB1) of the second data element; generating a first migration function (MIG1) for mapping the first data element (GA) to the second data element (GB) in a first generation step , interrupting the execution of the first control program (A) in an interruption step , determining a value of the first data element (GA) in a first determination step , wherein the determined value of the first data element (GA) describes a program state of the first control program (A) at the time of the interruption, and mapping the value of the first data element (GA) to the second data element (GB) and writing values of first data sub-elements (GA1) to second data sub-elements (GB1), which are initiated with an initial value, by executing the first migration function (MIG1) in a migration step , characterized in that the control program (A) is executed cyclically, and in that the initialization step is executed at a time before the migration step . initializing the second data element (GB) in an initialization step , wherein the initializing comprises setting a value of the second data element (GB) to a predetermined initial value, and wherein initializing the second data element (GB) comprises initializing all second data sub-elements (GB1) of the second data element; generating a first migration function (MIG1) for mapping the first data element (GA) to the second data element (GB) in a first generation step , interrupting the execution of the first control program (A) in an interruption step , determining a value of the first data element (GA) in a first determination step , wherein the determined value of the first data element (GA) describes a program state of the first control program (A) at the time of the interruption, and mapping the value of the first data element (GA) to the second data element (GB) and writing values of first data sub-elements (GA1) to second data sub-elements (GB1), which are initiated with an initial value, by executing the first migration function (MIG1) in a migration step , characterized in that the control program (A) is executed cyclically, and in that the initialization step is executed at a time before the migration step . <EOS>