Thursday, June 20, 2013

SAP ABAP Cluster table problem example




Hi Folks,
my previous post  might sound a bit cryptic.
I want to make an example of the havoc that can happen when you use cluster tables.

Suppose you have decided to store in a cluster table the following data

TYPES: BEGIN OF struc,
         procedure TYPE c LENGTH 10,
         sernr   TYPE c LENGTH 13,
       END OF struc.
 You do 

EXPORT gt_mydata TO DATABASE indx(ZR) ID 'MYKEY'.

Then a couple of years pass and your cluster indx RELID ZR is full of your stored procedure numbers with material numerbs and serial numbers.
But because of a change in company procedures you need to store from today on a new number the "processing number".

What any programmer would do is to extend the structure struc like this


TYPES: BEGIN OF struc,
         procedure TYPE c LENGTH 10,
         procnr  type c linght 10

         sernr   TYPE c LENGTH 13,
       END OF struc.


If now you try to import your previously exported data you get a DUMP.
Yes a dump.
IMPORT gt_mydata from DATABASE INDX(ZR) ID 'MYKEY'.
will return CX_SY_IMPORT_MISMATCH_ERROR 

Now this example is trivial. But imagine you use a ddic type and someone (maybe SAP or an external provider) changes tha ddic type not knowing that it is used in a cluster. 
What happens?
How can one solve this problem?

The answer in my next post.