Hi Folks,
well the main problem with data clusters is that you store a binary representation of the content of your data structures and ddic data at the TIME OF SAVING THE CLUSTER
If something changes later on you are on your own.
A good approach to save data in clusters is to save data in the cluster in another form that can be easily written and read from your programs and put in the abap data structures.
In modern times this could well be called "serialization" and "deserialization" of data.
It works like this.
You take your tables and structures.
Transform them into an XML string.
The xml string can be a binary string in abap so if ddic and the like changes (up to a certain degree of change) you get no effects.
You write the xml to the cluster.
Now if you change the data structure when deserializing the xml most unwanted effects with the binary representations of data in clusters disappear.
For example adding a new field in between is harmless: the transformation will leave it empty instead of dumping.
Of course if you change the data type of a char to numeric or worse floating point you are likely to get trash out of your data or a dump. But this is normal in some way.
Here is a snippet of coding you can use as an example
*old structure
TYPES: BEGIN OF struc1,
f1 TYPE c LENGTH 2,
f2 TYPE c LENGTH 2,
f3 TYPE c LENGTH 2,
END OF struc1.
*new structure
TYPES: BEGIN OF struc2,
fnew TYPE c LENGTH 2,
f1 TYPE c LENGTH 5,
f2 TYPE i,
END OF struc2.
*data tables
DATA gt_tab1 TYPE STANDARD TABLE OF struc1.
DATA gt_tab2 TYPE STANDARD TABLE OF struc2.
*id for storing data
DATA gc_id TYPE c LENGTH 20 VALUE 'MYKEY'.
* XML-String c
DATA gv_xml TYPE string.
DATA gx_error TYPE REF TO cx_..._check.
START-OF-SELECTION.
APPEND 'ZZ1122' TO gt_tab1.
APPEND 'EE2233' TO gt_tab1.
APPEND 'DD3344' TO gt_tab1.
*transform table into xml
CALL TRANSFORMATION id
SOURCE test = gt_tab1
RESULT XML gv_xml.
*save xml to data cluster
EXPORT test = gv_xml TO DATABASE indx(zr) ID gc_id.
CLEAR gt_tab1.
CLEAR gt_tab2.
CLEAR gv_xml.
*import data to xml
IMPORT test TO gv_xml FROM DATABASE indx(zr) ID gc_id.
TRY .
* transform xml data with NEW structure
CALL TRANSFORMATION id
SOURCE XML gv_xml
RESULT test = gt_tab2.
CATCH cx_transformation_error INTO gx_error.
*Does not DUMP!!!
ENDTRY.