Hi All,
I have an issue when loading to a cube in relation to the start routine calculation. I am loading a file with 12 records, each record when being passed through the start routine is being replicated 365 times. I would like that the values are repeated however I am finding that with each new month that the values are increasing, see (Jan) 201301 55k and (Feb) 201302 112K
I would like to see that the value of each record is the same as the first day (01.01.2013) except that it has a new date & month reference.
Day Month Month Jan Feb March
174 74P3 TECMEC 01.01.2013 201301 1 55.936,25 84.136,25 76.886,25
174 74P3 TECMEC 02.01.2013 201301 1 55.936,25 84.136,25 76.886,25
174 74P3 TECMEC 03.01.2013 201301 1 55.936,25 84.136,25 76.886,25
174 74P3 TECMEC ……….. 201301 1 Etc……………………………………..
174 74P3 TECMEC 01.02.2013 201302 2 111.872,50 168.272,50 153.772,50
174 74P3 TECMEC 02.02.2013 201302 2 111.872,50 168.272,50 153.772,50
174 74P3 TECMEC 03.02.2013 201302 2 111.872,50 168.272,50 153.772,50
174 74P3 TECMEC Etc 201302 2 Etc……………………………..
174 74P3 TECMEC 01.03.2013 201303 3 167.808,75 252.408,75 230.658,75
174 74P3 TECMEC 02.03.2013 201303 3 167.808,75 252.408,75 230.658,75
174 74P3 TECMEC 03.03.2013 201303 3 167.808,75 252.408,75
Here is the code in the start routine. Also please bear in mind that we are using BI3.X and this code is within update rules, rather than a transformation.
************************************************************************************************************************
PROGRAM UPDATE_ROUTINE.
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
* DATA: ...
*$*$ end of global - insert your declaration only before this line *-*
* The follow definition is new in the BW3.x
TYPES:
BEGIN OF DATA_PACKAGE_STRUCTURE.
INCLUDE STRUCTURE /BIC/CSZEN_COSTES_PRESUP.
TYPES:
RECNO LIKE sy-tabix,
END OF DATA_PACKAGE_STRUCTURE.
DATA:
DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE
WITH HEADER LINE
WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
FORM startup
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n
DATA_PACKAGE STRUCTURE DATA_PACKAGE
USING RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
*
*$*$ begin of routine - insert your code only below this line *-*
* fill the internal tables "MONITOR" and/or "MONITOR_RECNO",
* to make monitor entries
DATA: L_MES(2),
L_DIA(2).
DATA: WA_DATA_PACKAGE LIKE /BIC/CSZEN_COSTES_PRESUP.
DATA: BEGIN OF AUX_DATA_PACKAGE OCCURS 0.
INCLUDE STRUCTURE /BIC/CSZEN_COSTES_PRESUP.
DATA: END OF AUX_DATA_PACKAGE.
DATA: L_DIAS TYPE I,
L_ULT_DIA_FEB LIKE SY-DATUM,
L_FECHA_INICIAL LIKE SY-DATUM,
L_ANIO(4) TYPE N,
L_SEMANA_ANIO(6) TYPE N,
L_MES_ANIO LIKE /BIC/CS0000000191-CALMONTH.
DATA: BEGIN OF MESES_ANIO OCCURS 0,
CALMONTH LIKE /BIC/CS0000000191-CALMONTH.
DATA: END OF MESES_ANIO.
DATA: A TYPE I.
clear a.
* do.
*
* if a = 1.
*
* exit.
*
* endif.
*
* enddo.
REFRESH AUX_DATA_PACKAGE.
CLEAR AUX_DATA_PACKAGE.
L_ANIO = SY-DATUM(4).
*-- Lo primero que se hace, es comprobar si el año es bisiesto
CONCATENATE L_ANIO '0229' INTO L_ULT_DIA_FEB.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
DATE = L_ULT_DIA_FEB
IMPORTING
WEEK = L_SEMANA_ANIO
EXCEPTIONS
DATE_INVALID = 1
OTHERS = 2.
IF SY-SUBRC = 0.
L_DIAS = 366.
ELSE.
L_DIAS = 365.
ENDIF.
L_MES = '01'.
L_DIA = '01'.
*-- Se rellena todos los meses del año
CLEAR MESES_ANIO.
REFRESH MESES_ANIO.
CONCATENATE L_ANIO '01' INTO L_MES_ANIO.
DO 12 TIMES.
MESES_ANIO-CALMONTH = L_MES_ANIO.
APPEND MESES_ANIO.
L_MES_ANIO = l_MES_ANIO + '01'.
ENDDO.
CLEAR L_MES_ANIO.
CONCATENATE L_ANIO '01' '01' INTO L_FECHA_INICIAL.
LOOP AT DATA_PACKAGE INTO WA_DATA_PACKAGE.
CONCATENATE L_ANIO '01' '01' INTO L_FECHA_INICIAL.
DO L_DIAS TIMES.
L_MES_ANIO = L_FECHA_INICIAL(6).
WA_DATA_PACKAGE-CALDAY = L_FECHA_INICIAL.
LOOP AT MESES_ANIO
WHERE CALMONTH <= L_MES_ANIO.
WA_DATA_PACKAGE-CALMONTH = MESES_ANIO(6).
WA_DATA_PACKAGE-CALYEAR = MESES_ANIO(4).
APPEND WA_DATA_PACKAGE TO AUX_DATA_PACKAGE.
************************************************************************
**
* Autor: Michelle Byrne
* Fecha: 07/08/2013
* CdM-ID645 - Defecto sobre Ratio Proyectado (mes)
Clear WA_DATA_PACKAGE.
*****************************FIN****************************************
ENDLOOP.
L_FECHA_INICIAL = L_FECHA_INICIAL + 1.
ENDDO.
************************************************************************
**
* Autor: Michelle Byrne
* Fecha: 07/08/2013
* CdM-ID645 - Defecto sobre Ratio Proyectado (mes)
Clear WA_DATA_PACKAGE.
*****************************FIN****************************************
***
ENDLOOP.
DATA_PACKAGE[] = AUX_DATA_PACKAGE[].
* if abort is not equal zero, the update process will be canceled
ABORT = 0.
*$*$ end of routine - insert your code only before this line *-*
*
ENDFORM.
************************************************************************************************************************
Many thanks for your help,
Kind Regards
Michelle