Loading data to a newly added field in DSO using an ABAP program.

· Added by nasarat anjum, last edited by Arun Varadarajan on Sep 26, 2009  (view change)

Business Context

        In BW infrastructure, data targets are built and there can be a scenario in future to enhance/modify the existing data target . Suppose a DSO is built and we need to add a Key Figure to the DSO. Data would be present in the DSO since a long time and you can't take the pain to load data again into the Same DSO just to populate values into the new Key Figure.

       To face such scenario, an ABAP program can be written which will load data just to that Key Figure corresponding to the old values.

       We faced a similar scenario, where we had a Key figure which was of type "Interger". Now we had to Change this Key Figure to type "Number- FLTP". Changing the existing Key Figure and then Re-loading the existing (10 million records of data) DSO would require lot of time.

The solution we implemented was
1. Create a new Key Figure and include it in the DSO.
2. Create an ABAP program to populate the New Key Figure with the values from the already existing Key Figure.
3. Once this is done for existing data, we can stop loading the old key Figure (by modifying the transformations) and continue loading the New Key figure through the normal data loading procedure.

Advantage(s):

This will save us lot of time needed for re-loading of DSO.

Assumption(s):
Data is loaded into the data target prior to scheduling this program.

Limitation(s):
This program is hard coded to Key Figures, it can be enhanced to make the program generalized to accept Old Key Figure and New Key Figure at run time and do the processing based on the input values.

PROGRAM SOURCE CODE:

*&---------------------------------------------------------------------*
*& Report  YPOPULATE_DSO_KF
*&
*&---------------------------------------------------------------------*
*& This program has a selection variable called "Month". Based on the
*& month entered, the program updates the Key figure values into newly
*& added key figure for all the records corresponding to the month.
*&
*&---------------------------------------------------------------------*

REPORT YPOPULATE_DSO_KF.

***SELECTION SCREEN
***--------------------------------------------------------------------*
TABLES: /BIC/AZDSO_O0100,
        /BIC/AZDSO_O0200,
        /BIC/AZDSO_O0300,
        /BIC/AZDSO_O0400.

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
PARAMETERS L_DSO(10) TYPE C.
SELECT-OPTIONS: L_EFFMTH FOR /BIC/AZDSO_O0100-/BIC/ZEFF_MNTH.
SELECTION-SCREEN: END OF BLOCK B1.
*************************************************************************

* Check whether Month value is entered or not.
IF L_EFFMTH IS INITIAL.
* To check which DSO is to be updated.
CASE L_DSO.
* If 'ZDSO_O01'is selected.
WHEN 'ZDSO_O01'.
UPDATE /BIC/AZDSO_O0100 SET /BIC/ZNEWFLD = /BIC/AZDSO_O0100~/BIC/ZOLDFLD.
* If 'ZDSO_O02' is selected.
WHEN 'ZDSO_O02'.
UPDATE /BIC/AZDSO_O0200 SET /BIC/ZNEWFLD = /BIC/AZDSO_O0200~/BIC/ZOLDFLD.
* If 'ZDSO_O03'is selected.
WHEN 'ZDSO_O03'.
UPDATE /BIC/AZDSO_O0300 SET /BIC/ZNEWFLD = /BIC/AZDSO_O0300~/BIC/ZOLDFLD.
* If 'ZDSO_O04' is selected.
WHEN 'ZDSO_O04'.
UPDATE /BIC/AZDSO_O0400 SET /BIC/ZNEWFLD = /BIC/AZDSO_O0400~/BIC/ZOLDFLD.
ENDCASE.
* Check whether Effective Month value entered.
ELSE.
CASE L_DSO.
* If 'ZDSO_O01'is selected
WHEN 'ZDSO_O01'.
UPDATE /BIC/AZDSO_O0100  SET /BIC/ZNEWFLD = /BIC/AZDSO_O0100~/BIC/ZOLDFLD WHERE /BIC/ZEFF_MNTH IN L_EFFMTH.
* If 'ZDSO_O02' is selected.
WHEN 'ZDSO_O02'.
UPDATE /BIC/AZDSO_O0200 SET /BIC/ZNEWFLD = /BIC/AZDSO_O0200~/BIC/ZOLDFLD WHERE /BIC/ZEFF_MNTH IN L_EFFMTH.
* If 'ZDSO_O03'is selected.
WHEN 'ZDSO_O03'.
UPDATE /BIC/AZDSO_O0300 SET /BIC/ZNEWFLD = /BIC/AZDSO_O0300~/BIC/ZOLDFLD WHERE /BIC/ZEFF_MNTH IN L_EFFMTH.
* If 'ZDSO_O04' is selected.
WHEN 'ZDSO_O04'.
UPDATE /BIC/AZDSO_O0400 SET /BIC/ZNEWFLD = /BIC/AZDSO_O0400~/BIC/ZOLDFLD WHERE /BIC/ZEFF_MNTH IN L_EFFMTH.
ENDCASE.
ENDIF.

0 comments: