Hi All,
In my previous post i showed how a change in the cluster data structures can bring up big problem.
Here i will try to explore a solution.
Solution 1: the good old time's solution: add the new field to the end.
If you change the structure like this:
TYPES: BEGIN OF struc,
procedure TYPE c LENGTH 10,
sernr TYPE c LENGTH 13,
prat TYPE c LENGTH 12,
END OF struc.
It works just fine.
So as long as you add a new field at the very very end of everithing you write to the cluster you can do it.
Of course if you have a cluster holding several tables and you want to add a field to one of the tables not the last. You cannot do it. You need to do a conversion. Here we go.
Solution 2:
run a conversion report.
You write a report like this on.
TYPES: BEGIN OF struc_new,
procedure TYPE c LENGTH 10,
prat TYPE c LENGTH 12,
sernr TYPE c LENGTH 13,
END OF struc_new.
TYPES: BEGIN OF struc,
procedure TYPE c LENGTH 10, prat TYPE c LENGTH 12,
sernr TYPE c LENGTH 13,
END OF struc.
DATA gt_mydata type standard table of struc.
DATA gt_mydatanew type standard table of struc_new.
data ls_struc type struc.
data ls_struc_new type struc_new.
import gt_mydata from DATABASE indx(ZR) ID 'MYKEY'.
loop at gt_mydata into ls_struc.
move corresponding ls_struc to ls_struc_new.
append ls_struc_new to gt_mydata_new.
endloop.
export gt_mydata_new to DATABASE indx(ZR) ID 'MYKEY'.
From now on the import export will work with the new structure, but not with the old structure.
This is basically what the good old xpra programs did.
There is also a better solution which i would call "the modern solution".
More in the next post about this.