Usage of Global Variables in BW Routine.
Sometimes we wish to fill the internal table only once, and also we need use the internal table across all the start, end and field routines like STATIC internal table which will be used inside routines, function module or static methods.
BW routine is created using local class, where we can’t use STATIC statement within class definition and implementation. But we can use CLASS-DATA in private section of this local class which global declaration part of that routine. Variables and internal table declared using CLASS-DATA statement will be in memory until all data packages are executed and it will also be visible in all routines because of global area declaration.
We faced a major performance issue, caused by looking up of various database tables every time when the package starts. We had like more than 30 data packages running every time when we execute DTP. So we used a CLASS-DATA global variable which in turn keeps the internal table in run time memory.
CLASS-DATA should be declared in class definition within begin and end of global like above Figure, which will make it visible to all methods of that class.
Above figure shows the internal table IT_TCURR in start routine and end routine while debugging for two packages, like this the internal table will be in memory until all data packages are completed.