Thursday, September 22, 2005

[BCS] Check FS Item breakdown category for staging cube

Start Routine
==============================================
PROGRAM UPDATE_ROUTINE.
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
DATA: I_ZACCORI LIKE /BIC/PZACCORI OCCURS 0 WITH HEADER LINE.
DATA: I_GL_ACCOUNT LIKE /BI0/PGL_ACCOUNT OCCURS 0 WITH HEADER LINE.
DATA: I_CS_ITEM LIKE /1FB/MD___2S003L OCCURS 0 WITH HEADER LINE.
DATA: I_BDC LIKE UCMI100 OCCURS 0 WITH HEADER LINE.
*$*$ 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/CSZISBCST0.
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
REFRESH I_ZACCORI.
REFRESH I_GL_ACCOUNT.
REFRESH I_CS_ITEM.
REFRESH I_BDC.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_ZACCORI
FROM /BIC/PZACCORI WHERE objvers = 'A'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_GL_ACCOUNT
FROM /BI0/PGL_ACCOUNT WHERE objvers = 'A'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_CS_ITEM
FROM /1FB/MD___2S003L WHERE AREA = 'L1'.
SELECT * INTO CORRESPONDING FIELDS OF TABLE I_BDC
FROM UCMI100 WHERE AREA = 'L1'.
* 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.


Update Rule
==============================================
PROGRAM UPDATE_ROUTINE.
*$*$ begin of global - insert your declaration only below this line *-*
* TABLES: ...
DATA: I_ZACCORI LIKE /BIC/PZACCORI OCCURS 0 WITH HEADER LINE.
DATA: I_GL_ACCOUNT LIKE /BI0/PGL_ACCOUNT OCCURS 0 WITH HEADER LINE.
DATA: I_CS_ITEM LIKE /1FB/MD___2S003L OCCURS 0 WITH HEADER LINE.
DATA: I_BDC LIKE UCMI100 OCCURS 0 WITH HEADER LINE.
*$*$ end of global - insert your declaration only before this line *-*


FORM compute_key_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CSZISBCST0
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BIC/VZCBCSR0T-CS_ITEM
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
*
*$*$ begin of routine - insert your code only below this line *-*
* fill the internal table "MONITOR", to make monitor entries
*---Derive 0CS_ITEM---*
REFRESH MONITOR.
READ TABLE I_ZACCORI WITH KEY
/BIC/ZACCORI = COMM_STRUCTURE-/BIC/ZACCORI
/BIC/ZCOAORI = COMM_STRUCTURE-/BIC/ZCOAORI
OBJVERS = 'A'.
IF SY-SUBRC = 0.
READ TABLE I_GL_ACCOUNT WITH KEY GL_ACCOUNT = I_ZACCORI-GL_ACCOUNT
CHRT_ACCTS = I_ZACCORI-CHRT_ACCTS
OBJVERS = 'A'.
IF SY-SUBRC = 0.
RESULT = I_GL_ACCOUNT-CS_ITEM.
ELSE.
MONITOR-msgno = '000'.
MONITOR-msgid = 'ZBW'.
MONITOR-msgty = 'E'.
MONITOR-msgv1 = I_ZACCORI-GL_ACCOUNT.
MONITOR-msgv2 = ' error in Derive 0CS_ITEM'.
APPEND MONITOR.
ABORT = 8.
ENDIF.
ELSE.
MONITOR-msgno = '000'.
MONITOR-msgid = 'ZBW'.
MONITOR-msgty = 'E'.
MONITOR-msgv1 = COMM_STRUCTURE-/BIC/ZACCORI.
MONITOR-msgv2 = ' error in Derive 0GL_ACCOUNT'.
APPEND MONITOR.
ABORT = 8.
ENDIF.
*---Check CS_ITEM breakdown category---*
IF SY-SUBRC = 0.
READ TABLE I_CS_ITEM WITH KEY /1FB/CS_ITEM = I_GL_ACCOUNT-CS_ITEM
/1FB/CS_CHART = I_GL_ACCOUNT-CS_CHART AREA = 'L1'.
IF SY-SUBRC NE 0.
LOOP AT I_BDC WHERE ITGRP = I_CS_ITEM-ITGRP AND AREA = 'L1' AND
BREAKDOWN = '4'.
CASE I_BDC-FIELDNAME.
WHEN '/1FB/MOVE_TYPE'.
IF COMM_STRUCTURE-MOVE_TYPE IS INITIAL OR
COMM_STRUCTURE-MOVE_TYPE = '999'.
MONITOR-msgno = '000'.
MONITOR-msgid = 'ZBW'.
MONITOR-msgty = 'E'.
MONITOR-msgv1 = I_GL_ACCOUNT-CS_ITEM.
MONITOR-msgv2 = ' error in checking MOVE_TYPE - '.
MONITOR-msgv3 = COMM_STRUCTURE-/BIC/ZACCORI.
APPEND MONITOR.
ABORT = 8.
ENDIF.
WHEN '/BIC/ZPNRSBU'.
IF COMM_STRUCTURE-/BIC/ZPNRSBU IS INITIAL OR
COMM_STRUCTURE-/BIC/ZPNRSBU = '9999'.
MONITOR-msgno = '000'.
MONITOR-msgid = 'ZBW'.
MONITOR-msgty = 'E'.
MONITOR-msgv1 = I_GL_ACCOUNT-CS_ITEM.
MONITOR-msgv2 = ' error in checking Partner SBU - '.
MONITOR-msgv3 = COMM_STRUCTURE-/BIC/ZACCORI.
APPEND MONITOR.
ABORT = 8.
ENDIF.
WHEN '/BIC/ZPNRSUB'.
IF COMM_STRUCTURE-/BIC/ZPNRSUB IS INITIAL OR
COMM_STRUCTURE-/BIC/ZPNRSUB = 'S19999'.
MONITOR-msgno = '000'.
MONITOR-msgid = 'ZBW'.
MONITOR-msgty = 'E'.
MONITOR-msgv1 = I_GL_ACCOUNT-CS_ITEM.
MONITOR-msgv2 = ' error in checking Partner SUB - '.
MONITOR-msgv3 = COMM_STRUCTURE-/BIC/ZACCORI.
APPEND MONITOR.
ABORT = 8.
ENDIF.
WHEN '/BIC/ZINVSBU'.
IF COMM_STRUCTURE-/BIC/ZINVSBU IS INITIAL OR
COMM_STRUCTURE-/BIC/ZINVSBU = '9999'.
MONITOR-msgno = '000'.
MONITOR-msgid = 'ZBW'.
MONITOR-msgty = 'E'.
MONITOR-msgv1 = I_GL_ACCOUNT-CS_ITEM.
MONITOR-msgv2 = ' error in checking Investee Unit SBU - '.
MONITOR-msgv3 = COMM_STRUCTURE-/BIC/ZACCORI.
APPEND MONITOR.
ABORT = 8.
ENDIF.
WHEN '/BIC/ZINVSUB'.
IF COMM_STRUCTURE-/BIC/ZINVSUB IS INITIAL OR
COMM_STRUCTURE-/BIC/ZINVSUB = 'S19999'.
MONITOR-msgno = '000'.
MONITOR-msgid = 'ZBW'.
MONITOR-msgty = 'E'.
MONITOR-msgv1 = I_GL_ACCOUNT-CS_ITEM.
MONITOR-msgv2 = ' error in checking Investee Unit SUB - '.
MONITOR-msgv3 = COMM_STRUCTURE-/BIC/ZACCORI.
APPEND MONITOR.
ABORT = 8.
ENDIF.
ENDCASE.
ENDLOOP.
ENDIF.
ENDIF.

* result value of the routine
* RESULT = .
* if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
* 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.