Skip to end of metadata
Go to start of metadata

List of all pages

Pages at first level

Author: Lijo John
Submitted: 10/02/2009
Related Links:

Description

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*****************Actual Source Code for the Program********************
***********************************************************************
*  PROGRAM          # LOOKUP_FINDER                                   *
*  RELEASE          # 1.0                                             *
*  DATE WRITTEN     # 04/04/2008                                      *
*  MODULE           # BW/BI                                           *
*  TYPE             # Executable Report                               *
*  Author           # Lijo John                                       *
***********************************************************************
*  TITLE            # Program to find out lookups                     *
*                                                                     *
*  PURPOSE          # The program takes the technical name of a       *
*                     dataprovider as input and displays the          *
*                     Transformations or update rules where it is     *
*                     looked up. The output gives details like source *
*                     and target of lookup, transformation id, rule id*
*                     and the line number, It can also be used to     *
*                     find patterns e.g:break-point, *TWD* etc in   *
*                     routines                                        *
*                                                                     *
***********************************************************************
* LOGICAL DATABASE  # N/A                                             *
* FUNCTION KEYS     # None                                            *
***********************************************************************
***********************************************************************
REPORT  lookup_finder LINE-SIZE 600.
***********************************************************************
***Type pools/Tables declerations for ALV Grid display/selections***
TYPE-POOLS slis.
DATA fcat1 TYPE slis_t_fieldcat_alv.
DATA: BEGIN OF t_display OCCURS 0,
         targetname LIKE rstran-targetname,
         sourcename LIKE rstran-sourcename,
         tranid LIKE rstran-tranid,
         routine LIKE rstran-startroutine,
         line_no LIKE rsaabap-line_no,
         line LIKE rsaabap-line,
END OF t_display.
DATA : input_pattern1(75) TYPE c.
DATA : input_pattern2(75) TYPE c.
DATA : same_source(30) TYPE c.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-004.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(22) text-002 FOR FIELD infoprov.
PARAMETERS infoprov LIKE input_pattern1.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(20) text-001 FOR FIELD mdobject.
PARAMETERS: mdobject AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 6(20) text-003 FOR FIELD pattern.
PARAMETERS: pattern AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK b01.
***Internal table declerations***************************************
TYPES:  BEGIN OF t_trans_lookup_finder,
         targetname TYPE rstran-targetname,
         sourcename TYPE rstran-sourcename,
         tranid TYPE rstran-tranid,
         routine TYPE rstran-startroutine,
         line_no TYPE rsaabap-line_no,
         line TYPE rsaabap-line,
        END OF t_trans_lookup_finder.

DATA: i_lookup_finder TYPE STANDARD TABLE OF t_trans_lookup_finder,
      wa_lookup_finder TYPE t_trans_lookup_finder,
      i_trans_lookup_finder TYPE STANDARD TABLE OF t_trans_lookup_finder,
      wa_trans_lookup_finder TYPE t_trans_lookup_finder,
      i_trans_final TYPE STANDARD TABLE OF t_trans_lookup_finder,
      wa_trans_final TYPE t_trans_lookup_finder.
DATA : i(7) TYPE n.
DATA  old_cube(20) TYPE c VALUE ' '.
DATA  old_source(20) TYPE c VALUE ' '.
***Selections for update rules***************************************
IF ( infoprov NE '' ).
  IF ( pattern NE 'X' ).
    IF ( mdobject NE 'X' ).
      CONCATENATE 'from*A' infoprov '00' '' INTO input_pattern1.
    ELSE.
      CONCATENATE 'from*p' infoprov '' INTO input_pattern1.
    ENDIF.
    CONCATENATE '8' infoprov '*' INTO same_source.
    SELECT DISTINCT
           infocube
           isource
           b~updid
           routine
           line_no
           line
           INTO TABLE i_lookup_finder FROM
           rsupdinfo AS a  INNER JOIN rsupdrout AS b ON a~updid = b~updid
                           INNER JOIN rsaabap AS c ON c~codeid = b~codeid
                           WHERE
                           a~objvers = 'A' AND b~objvers = 'A' AND
                           c~objvers = 'A' AND a~objvers = 'A'
                           AND
                           b~routine GE 9000.
  ELSE.
    input_pattern1 = infoprov.
    SELECT DISTINCT
           infocube
           isource
           b~updid
           routine
           line_no
           line
           INTO TABLE i_lookup_finder FROM
           rsupdinfo AS a  INNER JOIN rsupdrout AS b ON a~updid = b~updid
                           INNER JOIN rsaabap AS c ON c~codeid = b~codeid
                           WHERE
                           a~objvers = 'A' AND b~objvers = 'A' AND
                           c~objvers = 'A' AND a~objvers = 'A'.

    SELECT DISTINCT
           targetname
           sourcename
           a~tranid
           c~codeid
           line_no
           line
           INTO TABLE i_trans_lookup_finder FROM
           rstran AS a INNER JOIN rstransteprout AS b
                           ON a~tranid = b~tranid
                       INNER JOIN rsaabap AS c ON b~codeid = c~codeid
                           WHERE
                           a~objvers = 'A' AND b~objvers = 'A' AND
                           c~objvers = 'A'.
    APPEND LINES OF i_trans_lookup_finder TO i_lookup_finder.
  ENDIF.

***Selections for Transformations(start routine)*********************
  SELECT DISTINCT
         targetname
         sourcename
         tranid
         startroutine
         line_no
         line
         INTO TABLE i_trans_lookup_finder FROM
        rstran AS a INNER JOIN rsaabap AS b ON a~startroutine = b~codeid
                         WHERE
                         a~objvers = 'A' AND b~objvers = 'A'.
  APPEND LINES OF i_trans_lookup_finder TO i_lookup_finder.
***Selections for Transformations(End routine)***********************
  SELECT DISTINCT
         targetname
         sourcename
         tranid
         endroutine
         line_no
         line
         INTO TABLE i_trans_lookup_finder FROM
         rstran AS a  INNER JOIN rsaabap AS b ON a~endroutine = b~codeid
                         WHERE
                         a~objvers = 'A' AND b~objvers = 'A'.
  APPEND LINES OF i_trans_lookup_finder TO i_lookup_finder.
***Selections for Transformations(Expert routine)********************
  SELECT DISTINCT
         targetname
         sourcename
         tranid
         expert
         line_no
         line
         INTO TABLE i_trans_lookup_finder FROM
         rstran AS a  INNER JOIN rsaabap AS b ON a~expert = b~codeid
                         WHERE
                         a~objvers = 'A' AND b~objvers = 'A'.
  APPEND LINES OF i_trans_lookup_finder TO i_lookup_finder.
***Extracting records where lookup code is written*******************
  SORT i_lookup_finder BY targetname sourcename tranid routine line_no.
  LOOP AT i_lookup_finder INTO wa_lookup_finder.
    TRANSLATE wa_lookup_finder-line TO UPPER CASE.
    IF ( wa_lookup_finder-line CP input_pattern1 ) AND
       ( wa_lookup_finder-sourcename NP same_source ).
      IF ( pattern NE 'X' ).
        APPEND wa_lookup_finder TO t_display.
        old_cube = wa_lookup_finder-targetname.
        old_source = wa_lookup_finder-sourcename.
      ELSE.
        APPEND wa_lookup_finder TO t_display.
      ENDIF.
    ENDIF.
  ENDLOOP.

****code to diaplay the data in table/ALV grid format ***************
*MOVE i_lookup_finder[] TO t_display[].
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name         = 'ZBW_LOOKUP_FINDER'
      i_internal_tabname     = 'T_DISPLAY'
      i_inclname             = 'ZBW_LOOKUP_FINDER'
    CHANGING
      ct_fieldcat            = fcat1
    EXCEPTIONS
      inconsistent_interface = 1
      program_error          = 2
      OTHERS                 = 3.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = 'ZBW_LOOKUP_FINDER'
      it_fieldcat        = fcat1
    TABLES
      t_outtab           = t_display
    EXCEPTIONS
      program_error      = 1
      OTHERS             = 2.
ENDIF.
*************************************************************************

Author: Jim Spath (card blogs profile)

Submitted: 13-Jan-2008
Related Links:

(warning) Works on BW 3.5 and in 7.0

Description

View BW process chain run times graphically, to find bottlenecks.

SQL:

Oracle SQL script to pull BW process chain log details
select
 to_char(to_date(to_char(trunc(L1.STARTTIMESTAMP/100),'999999999999'),'YYYYMMDDHH24MI'), 'YYYY-MM-DD HH24:MI') st,
 ',',
 to_char(to_date(to_char(trunc( L1.ENDTIMESTAMP/100),'999999999999'),'YYYYMMDDHH24MI'), 'HH24:MI') en,
 ',',
 to_char(to_date(to_char(trunc(L1.STARTTIMESTAMP/100),'999999999999'),'YYYYMMDDHH24MI'), 'DD-Mon') DAY,
 ',',
 chain_id || ':' || l1.type chain_id
from
 sapr3.RSPCPROCESSLOG L1,
 sapr3.RSPCLOGCHAIN C
where
 to_date(to_char(trunc( L1.ENDTIMESTAMP/100),'999999999999'),'YYYYMMDDHH24MI') -
  to_date(to_char(trunc(L1.STARTTIMESTAMP/100),'999999999999'),'YYYYMMDDHH24MI')
   > (5 / (24*60)) -- 5 minutes or more
and
 L1.log_id = C.log_id
and
 substr(L1.STARTTIMESTAMP,1,6) = '200711'
and
 (L1.ENDTIMESTAMP - L1.STARTTIMESTAMP) > 60
and
 chain_id like 'Z_ORDER_DELIVERY_ODS%'
order by
 1,2

Results in spool file with data in this format:

2007-11-01,05:33,06:50,01-Nov,Z_ORDER_DELIVERY_ODS:LOADING
2007-11-01,06:51,07:22,01-Nov,Z_ORDER_DELIVERY_ODS:ODSACTIVAT
2007-11-01,07:22,08:34,01-Nov,Z_ORDER_DELIVERY_ODS:LOADING
2007-11-01,08:34,09:33,01-Nov,Z_ORDER_DELIVERY_ODS:ODSACTIVAT
2007-11-01,09:33,11:06,01-Nov,Z_ORDER_DELIVERY_ODS:LOADING
2007-11-01,11:06,11:45,01-Nov,Z_ORDER_DELIVERY_ODS:INDEX
2007-11-01,11:45,12:24,01-Nov,Z_ORDER_DELIVERY_ODS:ROLLUP

Then, using ploticus from ploticus.sourceforge.net, this control file graphs data

#proc areadef
 title: BW Nov-2007 Times in GMT [Z_ORDER_DELIVERY_ODS]
 areaname: whole
 xscaletype: time hh:mm
 xrange: 00:00 23:59
 yscaletype: categories
 ycategories: datafield 4

#proc yaxis
 stubs: categories
 grid: color=powderblue

#proc xaxis
 stubs: inc 60
 stubformat: hh:mm
 grid: color=orange style=2
 label: Hour of Day

#proc bars
 axis: x
 locfield: 4
 segmentfields: 2 3
 barwidth: 0.035
 tails: 0.05
Results:

Author: Surendra Kumar Reddy Koduru
Submitted: 26 Feb 2009

Description

Use the following code and execute everyday it in background, Basis will create Job in SM36 and this will take care of background job execution, and then you create a Event "ZEVENT1" in SM62 and in process chain you use this Event in Event screen i.e. don't execute immediately or Date/Time, select Event and give this event and give Parameter as "ZEVENTPARAM".

Save your PC and Activate and Execute PC.

Then execute this code in Background, so everyday it will check the date if the date is 03 or 04 then it will trigger the Event so your process chain will run.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT ztest_ev.
DATA: eventid LIKE tbtcjob-eventid.
DATA: eventparm LIKE tbtcjob-eventparm.
DATA: dt1 TYPE sy-datum,
      dt2 TYPE sy-datum,
      dt3 TYPE sy-datum,
      my1 TYPE /bi0/oicalmonth,
      my2 TYPE /bi0/oicalmonth,
      dd1(2) TYPE n,
      dd2(2) TYPE n,
      dd3(3) TYPE n.

eventid = 'ZEVENT1'.
eventparm = 'ZEVENTPARAM'.
dt1 = sy-datum.
dd1 = '03'.
dd2 = '04'.
my1 = dt1+0(6).
CONCATENATE my1 dd1 INTO dt2.
CONCATENATE my1 dd2 INTO dt3.
IF sy-datum = dt2 OR sy-datum = dt3.
  CALL FUNCTION 'RSSM_EVENT_RAISE'
    EXPORTING
      i_eventid              = eventid
      i_eventparm            = eventparm
    EXCEPTIONS
      bad_eventid            = 1
      eventid_does_not_exist = 2
      eventid_missing        = 3
      raise_failed           = 4
      OTHERS                 = 5.
ELSE.
  EXIT.
ENDIF.

Author: Marc Bernard, SAP Techology RIG
Submitted: 2007-06-15

Related Links:

Description:
This program creates and activates the missing HTTP service for the BI-IP file upload. Implement and run once.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
************************************************************************
* ZRSPLF_FILE_UPLOAD_ICF
* BI-IP File Upload HTTP Service
*
* (c) SAP AG 2007                                    MFB, SAP Labs, LLC
* last update: 2007-06-15
************************************************************************

REPORT zrsplf_file_upload_icf.

TYPE-POOLS: abap.

DATA:
  ls_icfservloc  TYPE icfservloc,
  l_nodeguid     TYPE icfnodguid,
  l_answer       TYPE c,
  lb_node_active TYPE boolean.

CONSTANTS:
  c_root_node   TYPE icfparguid VALUE 'BPXI9KP2BASOTAFYZA1IQQI7C', " /default_host/sap/bc/webdynpro/sap
  c_devclass    TYPE devclass   VALUE 'ZRSPLF',
  c_icfname     TYPE icfname    VALUE 'BIR00310',
  c_icfdocu     TYPE icf_docu   VALUE 'BI-IP File Upload',
  c_icfaltname  TYPE icfaltnme  VALUE 'ZRSPLF_FILE_UPLOAD',
  c_icfaltname2 TYPE icfaltnme  VALUE 'zrsplf_file_upload'.

lb_node_active = space.

CALL FUNCTION 'HTTP_GET_NODEGUID'
  EXPORTING
    parguid        = c_root_node
    nodename       = c_icfname
  IMPORTING
    nodeguid       = l_nodeguid
  EXCEPTIONS
    node_not_found = 1
    OTHERS         = 2.

IF sy-subrc = 0.
  lb_node_active = '-'.
  SELECT * FROM icfservloc INTO ls_icfservloc WHERE icf_name = c_icfname.
    IF ls_icfservloc-icfactive = 'X'.
      lb_node_active = 'X'.
    ENDIF.
  ENDSELECT.
ENDIF.

CASE lb_node_active.
* service DOESN'T EXIST => create ------------------------------
  WHEN space.
    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
        titlebar              = 'HTTP-Service'
        text_question         = 'Do you want to create an entry for Web Dynpro zrsplf_file_upload'
        display_cancel_button = space
      IMPORTING
        answer                = l_answer.

    IF l_answer = '1'. " yes

      CALL FUNCTION 'HTTPTREE_INSERT_NODE'
        EXPORTING
          p_icf_name                = c_icfname
          p_icfparguid              = c_root_node
          p_icfdocu                 = c_icfdocu
          p_doculang                = sy-langu
          p_icfactive               = 'X'
          p_package                 = c_devclass
        EXCEPTIONS
          no_new_virtual_host       = 1
          special_service_error     = 2
          parent_not_existing       = 3
          enqueue_error             = 4
          node_already_existing     = 5
          empty_docu                = 6
          doculang_not_installed    = 7
          security_info_error       = 8
          user_password_error       = 9
          password_encryption_error = 10
          invalid_url               = 11
          invalid_otr_concept       = 12
          formflg401_error          = 13
          handler_error             = 14
          transport_error           = 15
          tadir_error               = 16
          package_not_found         = 17
          OTHERS                    = 18.

      IF sy-subrc = 0.
        UPDATE icfservice
          SET   icf_cclnt      = sy-mandt
                icf_mclnt      = sy-mandt
                icfaltnme      = c_icfaltname
                icfaltnme_orig = c_icfaltname2
          WHERE icf_name       = c_icfname
            AND icfparguid     = c_root_node.

        MESSAGE i171(so2_tool) WITH c_icfdocu.
      ELSE.
        message e001(rsplf) with sy-subrc.
        MESSAGE e174(so2_tool) WITH c_icfdocu.
      ENDIF.

    ENDIF.

* service INACTIVE => activate ------------------------------
  WHEN '-'.

    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
        titlebar              = 'HTTP-Service'
        text_question         = 'Do you want to activate the service for Web Dynpro zrsplf_file_upload'
        display_cancel_button = space
      IMPORTING
        answer                = l_answer.

    IF l_answer = '1'.

      CALL FUNCTION 'HTTP_ACTIVATE_NODE'
        EXPORTING
          nodeguid          = l_nodeguid
        EXCEPTIONS
          node_not_existing = 1
          enqueue_error     = 2
          OTHERS            = 3.

      IF sy-subrc = 0.
        UPDATE icfservice
          SET   icf_cclnt      = sy-mandt
                icf_mclnt      = sy-mandt
                icfaltnme      = c_icfaltname
                icfaltnme_orig = c_icfaltname2
          WHERE icf_name       = c_icfname
            AND icfparguid     = c_root_node.

        MESSAGE i001(rsplf) WITH 'Service for Web Dynpro zrsplf_file_upload' 'successfully activated'.
      ELSE.
        MESSAGE e001(rsplf) WITH 'Service for Web Dynpro zrsplf_file_upload' 'could not be activated'.
      ENDIF.

    ENDIF.

* service ACTIVE => ok message ------------------------------
  WHEN OTHERS.

    MESSAGE i001(rsplf) WITH 'Service for Web Dynpro zrsplf_file_upload' 'already exists and is active'.

ENDCASE.
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
DATA: l_buper LIKE t009b-poper,
      l_gjahr LIKE t009b-bdatj,
      l_actctr LIKE ls_varsel-seqno,
      l_plndctr LIKE ls_varsel-seqno.

DATA: l_post_period TYPE /bi0/oifiscper3.

PERFORM get_posting_period CHANGING l_buper l_gjahr.

*-- Actuals data variable is VACTUALS
CLEAR l_post_period.
CLEAR eto_charsel.

* No Rolling Forecast for January so we will lock always
IF l_buper = 1.
  l_actctr = 1.
ELSE.
  l_actctr = l_buper - 1.
ENDIF.

DO l_actctr TIMES.
  ADD 1 TO l_post_period.
  ls_varsel-chanm = i_chanm.
  ls_varsel-seqno = sy-index.
  ls_varsel-sign = 'I'.
  ls_varsel-opt = 'EQ'.
  ls_varsel-low = l_post_period.
  INSERT ls_varsel INTO TABLE eto_charsel.
ENDDO.

*ENDFUNCTION.
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
DATA: l_buper LIKE t009b-poper,
      l_gjahr LIKE t009b-bdatj,
      l_actctr LIKE ls_varsel-seqno,
      l_plndctr LIKE ls_varsel-seqno.

DATA: l_post_period TYPE /bi0/oifiscper3.

PERFORM get_posting_period CHANGING l_buper l_gjahr.
*-- Planned data variable = VPLANNED
CLEAR l_post_period.
CLEAR eto_charsel.

* No Rolling Forecast for January so we will lock always
IF l_buper = 1.
  l_actctr = 1.
ELSE.
  l_actctr = l_buper - 1.
ENDIF.

l_plndctr = 12 - l_actctr.
l_post_period = l_actctr.
DO l_plndctr TIMES.
  ADD 1 TO l_post_period.
  ls_varsel-chanm = i_chanm. "0FISCPER3 (VPLANNED)
  ls_varsel-seqno = sy-index.
  ls_varsel-sign = 'I'.
  ls_varsel-opt = 'EQ'.
  ls_varsel-low = l_post_period.
  INSERT ls_varsel INTO TABLE eto_charsel.
ENDDO.

*endfunction.

Every time you make any changes to real-time cube used in BI-IP all your aggregation levels get deactivated which you might have created in Planning modeler.

Then you have to go to planning modeler, open every aggregation level in change mode and activate it. This is time-consuming so you can use the following program to activate all my aggregation levels in just few secs. Sharing the same with all BI-IP community members to save them from the hassle of activating aggregation levels one-by-one and also to avoid transporting the inactivate aggregation levels in test/prod systems.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT z_activate_alvl.

TYPE-POOLS: rs.

PARAMETER:  g_iprov TYPE rsinfoprov,
            g_objv TYPE rsobjvers DEFAULT 'M'.

PERFORM run.

*&---------------------------------------------------------------------
*& Form run
*&---------------------------------------------------------------------
FORM run.

  DATA: l_t_return TYPE STANDARD TABLE OF bapiret2,
        l_s_return TYPE bapiret2,
        l_subrc TYPE sysubrc,
        l_t_alvl TYPE STANDARD TABLE OF rspls_alvl,
        l_s_alvl TYPE rspls_alvl,
        l_t_alvl_iobj TYPE STANDARD TABLE OF rspls_s_rfc_alvl_iobj.

*Select all the aggregation levels for the given infoprovider
  SELECT * FROM rspls_alvl INTO TABLE l_t_alvl
    WHERE infoprov = g_iprov
    AND objvers = g_objv.
  CHECK l_t_alvl IS NOT INITIAL.

  LOOP AT l_t_alvl INTO l_s_alvl.

*Open the aggregation level in change mode
    CALL FUNCTION 'RSPLS_ALVL_CHANGE'
      EXPORTING
        i_aggrlevel    = l_s_alvl-aggrlevel
      IMPORTING
        e_subrc        = l_subrc
      TABLES
        i_tk_alvl_iobj = l_t_alvl_iobj
        e_tk_return    = l_t_return.

    CHECK l_subrc = 0.

*Check the aggregation level
    CALL FUNCTION 'RSPLS_ALVL_CHECK'
      EXPORTING
        i_aggrlevel = l_s_alvl-aggrlevel
        i_objvers   = rs_c_objvers-active
      IMPORTING
        e_subrc     = l_subrc
      TABLES
        e_tk_return = l_t_return.

    CHECK l_subrc = 0.

*Activate the aggregation level if no errors found
    CALL FUNCTION 'RSPLS_ALVL_ACTIVATE'
      EXPORTING
        i_aggrlevel = l_s_alvl-aggrlevel
      IMPORTING
        e_subrc     = l_subrc
      TABLES
        e_tk_return = l_t_return.

  ENDLOOP.

ENDFORM. "run

Author: Shilpa Yakalaspur
Submitted: 26-AUG-2008

Description: This code is to find and eliminate the hexadecimal characters (also referred to as special characters or invisible characters) that cannot be loaded into BW. These characters usually appear as '#' but internally they are hexadecimal characters like the return carriage, new line carriage, tab, etc. This code applies to a Unicode BW system version 3.5. This code can be used in the transfer routine for the info object which is getting special characters. This code is for the info object 0prod_desr which is of type character & length 40 and is used as a separate character in the reporting infoprovider. The dataload into this infoprovider was failing whenever a hexadecimal or an invisible character (which later appears as #) was present in the info object value for 0prod_descr. This code solved the problem.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
DATA: v_prod_descr.

v_prod_descr = tran_structure-prod_descr.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>cr_lf IN v_prod_descr WITH ' '.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab IN v_prod_descr WITH ' '.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>vertical_tab IN v_prod_descr WITH ' '.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>newline IN v_prod_descr WITH ' '.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>form_feed IN v_prod_descr WITH ' '.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>backspace IN v_prod_descr WITH ' '.

Author: Davide Cavallari
Submitted: 5/24/2007
Related Links:

Description

Functionalities for managing the data loading process of a target BW system from the source ECC system are described. Such functionalities include programs for triggering a data request, for starting a process chain and for deleting an outbound queue (AKA extract queue).

A function module is discussed which starts a process chain and periodically monitors its execution, until it has completed. In this context, the basic features of the RSPC API are also showed.

Introduction

Loading data from an OLTP system to a datawarehouse might be a highly resource consuming process. Moreover this activity is often very time consuming, as well. This also holds true when the two systems involved are SAP ECC and SAP NetWeaver BI respectively.

As the ETL processes should be carried out preferably at night-time, it's generally a good idea to automate them as far as possible. In the following I present some pieces of code which can be helpful in this regard.

Triggering a loading process on a BI system

The simpler method that can be used for achieving a better degree of automation is triggering a loading process on the BI system, by raising an event in the BI system from the ECC system, as soon as the extraction process has completed on the ECC side. The triggering event needs to have been registered on the BI system, with transaction SM62.

When the extraction job finishes, a subsequent job is started and a program executed, which calls a remote function on the BI system. This remote function raises an event that is caught by the BW scheduler and the loading process is started.

In the described scenario, two components are needed:

  1. A program in the ECC source system that calls the remote function on the BI system;
  2. A remote-enabled function module that is called by the triggering program.
Triggering program in the ECC system

Here is shown the first component's code. The program presents the user a selection screen asking for three inputs:

  • The name of the RFC logical destination identifying the BI system (rfcdest);
  • The name of the event to raise on the target BI system (eventid);
  • A confirmation checkbox to actually raise the event (p1).

If the confirmation flag (p1) has been set, the remote function ZBW_EVENT_RAISE is called on the target system (rfcdest) and the chosen event (eventid) is raised. We'll see how this function is defined in the next section.

The rest of the code is straightforward. Exception handling is performed and messages are output.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT Z253_BI_LOAD_TRIGGER .
************************************************************************
*                                                                      *
* The request is triggered raising an event on the target BW system    *
*                                                                      *
************************************************************************
data mess(128).

selection-screen begin of block b1 with frame title text-001.
* Logical RFC destination of the BW system
parameters: rfcdest like rfcdisplay-rfcdest DEFAULT 'D12' OBLIGATORY.
* ID of the event to be raised on the target system
parameters: eventid like tbtco-eventid default 'GO_N_LOAD' OBLIGATORY.
* Security checkbox
parameters: p1 as checkbox.
selection-screen end of block b1.

* Security check: only if the security checkbox is checked
* is the loading event raised
  if  not p1 is initial.
    call function 'ZBW_EVENT_RAISE'
      destination rfcdest
      exporting
        eventid = eventid
    EXCEPTIONS
       BAD_EVENTID                  = 1
       EVENTID_DOES_NOT_EXIST       = 2
       EVENTID_MISSING              = 3
       RAISE_FAILED                 = 4
       SYSTEM_FAILURE               = 5  MESSAGE mess
       COMMUNICATION_FAILURE        = 6  MESSAGE mess
       OTHERS                       = 7.

    if sy-subrc <> 0.
      data err_text type string.
      case sy-subrc.
        when 1.
          err_text = 'BAD_EVENTID'.
        when 2.
          err_text = 'EVENTID_DOES_NOT_EXIST'.
        when 3.
          err_text = 'EVENTID_MISSING'.
        when 4.
          err_text = 'RAISE_FAILED'.
        when 5.
          move mess to err_text.
        when 6.
          move mess to err_text.
        when 7.
          err_text = 'OTHERS'.
      endcase.
* An exception occurred
      message e001(Z253_BI_ALOAD) with err_text.

    else.
* the event has been successfully raised on the target system
      message s200(Z253_BI_ALOAD) with eventid rfcdest.

    endif. "if sy-subrc <> 0.

  else.
* the security checkbox has not been selected
    message i100(Z253_BI_ALOAD).
    exit.

  endif. "if  not p1 is initial.
Remote-enabled function module on the BI system

Here's the definition of the remote function that get called by the ECC triggering program. It is defined in the BI system and basically calls another function, the standard module BP_EVENT_RAISE.

As the parameters EVENTPARM and TARGET_INSTANCE are not needed, they are not exported. Consequently, the interface of Z_BW_EVENT_RAISE is simpler than that of BP_EVENT_RAISE. It just imports the EVENTID and returns some exceptions, should anything go wrong (these are the same exceptions declared in the BP_EVENT_RAISE interface).

Thus Z_BW_EVENT_RAISE acts simply as a wrapper of the standard BP_EVENT_RAISE. So why is it needed at all? The reason is BP_EVENT_RAISE is not remote accessible, therefore a second function is needed in between.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
FUNCTION Z_BW_EVENT_RAISE.
*"----------------------------------------------------------------------
*"*"Interfaccia locale:
*"  IMPORTING
*"     VALUE(EVENTID) LIKE  TBTCO-EVENTID
*"----------------------------------------------------------------------

call function 'BP_EVENT_RAISE'
  exporting
    eventid                      = EVENTID
*   EVENTPARM                    = ' '
*   TARGET_INSTANCE              = ' '
 EXCEPTIONS
   BAD_EVENTID                  = 1
   EVENTID_DOES_NOT_EXIST       = 2
   EVENTID_MISSING              = 3
   RAISE_FAILED                 = 4
   OTHERS                       = 5
          .
if sy-subrc <> 0.
 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

ENDFUNCTION.

Starting a BI process chain from ECC

Although the technique suggested above is quite a basic one, in principle it could be used to start a process chain. Nevertheless it doesn't offer an option to get back information about the status of the loading process. As a consequence, ECC has no way to know whether e.g. the BI loading process is still active, or it has already finished, or it was interrupted. Thus this technique is more suitable for starting a simple InfoPackage loading via the scheduler, rather than a complex process chain.

In this second scenario it's more advisable to employ the RSPC API. Among others, it comprises a collection of remote-enabled functions that can be called specifically for triggering and monitoring a BI process chain. These function modules are defined in the target BI system, and get called by some loading program in the ECC system.

Here follows the code of a function (Z253_BI_RSPC_CHAIN_START_MONIT) that can be defined in the ECC system. It starts the remote process chain with the function RSPC_API_CHAIN_START defined in the target BI system, and monitors the process chain's status until its execution has completed, using the function RSPC_API_CHAIN_GET_STATUS.

This function Z253_BI_RSPC_CHAIN_START_MONIT accepts three input parameters:

  • The logical RFC destination's name of the BI system;
  • The technical name of the process chain to be started;
  • The polling time of the process chain's execution status (i.e. the time interval between a check of the execution status and the next check).

When a process chain is started, the BI system assigns an ID to that execution. This is called the LOGID, and identifies that specific execution of that process chain.

The output parameters of the function Z253_BI_RSPC_CHAIN_START_MONIT are:

  • The logid of the execution;
  • The final status of the execution (i.e. the status that is reached when the run has completed).

If the process chain is successfully started by RSPC_API_CHAIN_START, the status of the execution is checked every polling time interval, and that status is output. When the process chain's execution finishes, the final status is output and passed back to the caller.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
FUNCTION Z253_BI_RSPC_CHAIN_START_MONIT.
*"----------------------------------------------------------------------
*"*"Interfaccia locale:
*"  IMPORTING
*"     REFERENCE(RFCDEST) LIKE  RFCDISPLAY-RFCDEST
*"     REFERENCE(CHAIN) TYPE  CHAR25
*"     REFERENCE(POLLTIME) TYPE  CHAR3
*"  EXPORTING
*"     REFERENCE(LOGID) TYPE  CHAR25
*"     REFERENCE(STATUS) TYPE  CHAR1
*"----------------------------------------------------------------------

************************************************************************
*                                                                      *
* Starts a process chain on a target BW system, calling the remote     *
* function RSPC_API_CHAIN_START                                        *
*                                                                      *
************************************************************************

  data: msg(128),
        nsec type i.

  CALL FUNCTION 'RSPC_API_CHAIN_START'
    DESTINATION rfcdest
    EXPORTING
      I_CHAIN             =  chain
*                               I_T_VARIABLES       =
*                               I_SYNCHRONOUS       =
*                               I_SIMULATE          =
*                               I_NOPLAN            =
    IMPORTING
      E_LOGID             =  logid
    EXCEPTIONS
      SYSTEM_FAILURE            = 1  MESSAGE msg
      COMMUNICATION_FAILURE     = 2  MESSAGE msg
      FAILED              = 3
      OTHERS              = 4.

  IF SY-SUBRC <> 0. " error when calling remote function
  case sy-subrc.
      when 1.
        message e000(Z253_BI_RSPC) with msg.
      when 2.
        message e000(Z253_BI_RSPC) with msg.
      when 3.
        message e002(Z253_BI_RSPC) with chain rfcdest '(FAILED)'.
      when 4.
        message e002(Z253_BI_RSPC) with chain rfcdest '(OTHERS)'.
    endcase.

  ELSE. " ok
* Process chain started successfully
    message s101(Z253_BI_RSPC) with chain rfcdest.
* The logID is logged
    message i202(Z253_BI_RSPC) with logid .

    CALL FUNCTION 'RSPC_API_CHAIN_GET_STATUS'
      DESTINATION rfcdest
      EXPORTING
        I_CHAIN        = chain
        I_LOGID        = logid
      IMPORTING
        E_STATUS       =  status
      EXCEPTIONS
        SYSTEM_FAILURE            = 1  MESSAGE msg
        COMMUNICATION_FAILURE     = 2  MESSAGE msg.

    if sy-subrc <> 0.
      message e000(Z253_BI_RSPC) with msg.
    endif.

    while status eq 'A'.
* Process chain running (active)
      message s102(Z253_BI_RSPC) with chain rfcdest.

      nsec = polltime * 60. " polling time in seconds
      wait up to nsec seconds.
      CALL FUNCTION 'RSPC_API_CHAIN_GET_STATUS'
        DESTINATION rfcdest
        EXPORTING
          I_CHAIN        = chain
          I_LOGID        = logid
        IMPORTING
          E_STATUS       =  status
        EXCEPTIONS
          SYSTEM_FAILURE            = 1  MESSAGE msg
          COMMUNICATION_FAILURE     = 2  MESSAGE msg.

      if sy-subrc <> 0.
        message e000(Z253_BI_RSPC) with msg.
      endif.

    endwhile.

    case status.
      when 'G'.
* Process chain completed successfully
        message i103(Z253_BI_RSPC) with logid chain.
      when 'R'.
* Process chain finished with errors
        message w003(Z253_BI_RSPC) with logid chain.
      when 'X'.
* Process chain interrupted
        message w004(Z253_BI_RSPC) with logid chain.
    endcase.

  ENDIF. "if sy-subrc <> 0.

ENDFUNCTION.

Deleting an outbound queue

The two functionalities described so far are particulary useful when the extraction job on the source system is the setup tables' initialization of Logistic DataSources. Usually the initialization job is extremly time consuming, and has to be performed when the ECC system is locked to the users. Therefore it is often performed at night-time. To minimize system downtime, the loading process on the BI system should be started immediately after the setup job has finished.

All LO DataSources support the delta loading process, since large amount of data are involved in logistic applications. Three different update methods are provided in support of the delta process, whose features are explained in detail in the SAP Note 505700 - LBWE: New update methods as of PI 2002.1 (SMP login required):

  • Direct delta;
  • Queued delta;
  • Unserialized V3 update.

According to LOGISTIC COCKPIT DELTA MECHANISM - Episode three: the new update methods, the queued delta mechanism is probably the most used and popular. This update method relies on the so called outbound (or extract) queues, that are basically a buffer used to decouple the applications' tables from the DataSources.

As the outbound queue of the involved logistic application has to be deleted before the reconstruction of the setup tables begins, we need a functionality to programmaticaly delete this queue. In fact only a dialog procedure is provided by SAP to delete an outbound queue (transaction LBWQ), so the following code fragment may be used in order to achieve our aim.

This program accepts two input parameters:

  • The extraction queue's name, as reported in the extraction queue monitor (transaction LBWQ);
  • RFC logical destination (select NONE if you want to delete a local extration queue).
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT Z253_BI_EXTRACTQUEUE_DELETE .

PARAMETER: qname LIKE trfcqout-qname DEFAULT 'MCEX??',
           dest LIKE trfcqout-dest DEFAULT 'NONE'.

DATA sl_entry(96).

CONCATENATE sy-uname '&' qname ','
            dest INTO sl_entry.
CALL 'C_WRITE_SYSLOG_ENTRY' ID 'TYP'  FIELD space
                            ID 'KEY'  FIELD 'Q22'
                            ID 'DATA' FIELD sl_entry.

CALL FUNCTION 'TRFC_QOUT_DELETE_QUEUE'
     EXPORTING
          qname = qname
          dest  = dest.

if sy-subrc = 0.
  message s201(Z253_BI_ALOAD) with qname.
endif

Putting all together

I have compiled an archive with the cofile and datafile of a change request – unfortunaly when I compiled this package I wasn't aware of SAPlink.. (sad) This CR has the programs and reports shown in this page, as well as some other utility and test procedures.

You can download the package here. Actually it's a ZIP file, so you may need to change its extension to .zip if different.

Once you've put the two request files in the appropriate directories (e.g. /usr/sap/trans/cofiles/ and /usr/sap/trans/data/), you can import the request with the transaction STMS. The request number is D10K910049.

Using SE80 you'll find two new development packages, Z253_BI_ALOAD and Z253_BI_RSPC. As described in the change request's documentation, the first is the main package, while the latter fullfils some dependincies of the first.

Z253_BI_ALOAD contains the two reports described above (Z253_BI_EXTRACTQUEUE_DELETE and Z253_BI_LOAD_TRIGGER) as well as a third report called Z253_BI_GO_CHAIN, which uses the function module Z253_BI_RSPC_CHAIN_START_MONIT shown above to start a process chain.

Now instead of working at night-time till late, when you need to initialize a delta process, you can simply schedule a job to run the program Z253_BI_EXTRACTQUEUE_DELETE, which starts a job that executes the statistical setup program (e.g. RMCVNEUF for the billing application), which in turn starts a job that executes the program Z253_BI_GO_CHAIN. Thus the process chain is started on the BI system as soon as the statistical setup has finished in the ECC system.

Author: Surendra Kumar Reddy Koduru
Submitted: 26 Feb 2009

Description

Use the following code and execute everyday it in background, Basis will create Job in SM36 and they will take care of background job execution, and then you create a Event "ZEVENT1" in SM62 and in procees chain you use this Event in Event screen i.e. don't execute immediately or Date/Time, select Event and give this event and give Parameter as "ZEVENTPARAM".

Save your PC and Activate and Execute PC.

Then execute this code in BackGround, so everyday it will check the date if the date is 03 or 04 then it will trigger the Event so your process chain will run.

REPORT ztest_ev.
DATA: eventid LIKE tbtcjob-eventid.
DATA: eventparm LIKE tbtcjob-eventparm.
DATA: dt1 TYPE sy-datum,
      dt2 TYPE sy-datum,
      dt3 TYPE sy-datum,
      my1 TYPE /bi0/oicalmonth,
      my2 TYPE /bi0/oicalmonth,
      dd1(2) TYPE n,
      dd2(2) TYPE n,
      dd3(3) TYPE n.
eventid = 'ZEVENT1'.
eventparm = 'ZEVENTPARAM'.
dt1 = sy-datum.
dd1 = '03'.
dd2 = '04'.
my1 = dt1+0(6).
CONCATENATE my1 dd1 INTO dt2.
CONCATENATE my1 dd2 INTO dt3.
IF sy-datum = dt2 OR sy-datum = dt3.
  CALL FUNCTION 'RSSM_EVENT_RAISE'
    EXPORTING
      i_eventid              = eventid
      i_eventparm            = eventparm
    EXCEPTIONS
      bad_eventid            = 1
      eventid_does_not_exist = 2
      eventid_missing        = 3
      raise_failed           = 4
      OTHERS                 = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ELSE.
  EXIT.
ENDIF.
 

Author: Arun Purohit
Submitted: 3 Dec '07

Description: I tried making a ABAP program for generating daily status reporting of BW production Support but some problem with time conversion was there. Then I got some code from SDN and modified it to add some good features features Acc to need. It will be giving information like Infoarea, Infopakages loaded , Data Targets, Type of Data Target (Basic Cube or ODS), Available for Reporting or not (Infocube & ODS), Load status etc.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT  abc.

**********TABLES*************
TABLES: rsreqdone,
        rsmonictab,
        rsdcube,
        rsldpio.

**TIME ZONE ADJUSTMENT***************************
DATA: v_tst(14) TYPE c,
      v_tstt(14) TYPE c,
      v_var(10) TYPE c,
      v_count TYPE i,
      v_cnt TYPE i,
      v_i TYPE i,
      v_r1 LIKE rsreqdone-rnr,
      v_ifarea(30) TYPE c,
      v_rnsidlast LIKE rsiccont-rnsidlast,
      v_techok LIKE rsmdatastate-techok,
      v_wa_tst_p(8) TYPE p,
      v_wa_tstt_p(8) TYPE p,
      v_wa_tzone(6) TYPE c VALUE 'EST',
      v_select_date LIKE sy-datum,
      v_diff TYPE i.

******** CONSTANTS
CONSTANTS v_gv_uline TYPE i VALUE 135.

*** SELECT-OPTIONS / PARAMETERS
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK b11 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
PARAMETERS: p_ok     AS CHECKBOX DEFAULT 'X',
            p_ok_0   AS CHECKBOX DEFAULT 'X',
            p_notfin AS CHECKBOX DEFAULT 'X',
            p_notok  AS CHECKBOX DEFAULT 'X'.

SELECTION-SCREEN END OF BLOCK b11.

SELECTION-SCREEN SKIP 4.
SELECTION-SCREEN BEGIN OF BLOCK b12 WITH FRAME TITLE text-002.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS: s_date  FOR sy-datum,
                s_uzeit FOR sy-uzeit.
SELECTION-SCREEN END OF BLOCK b12.

******************************TYPES***************************
TYPES: BEGIN OF k_monitor,
        rnr       LIKE rsreqdone-rnr,        "Request number
        logdpid   LIKE rsreqdone-logdpid,    "InfoPackage (ID)
        tstatus   LIKE rsreqdone-tstatus,    "Request status
        datum     LIKE rsreqdone-datum,      "Start date
        uzeit     LIKE rsreqdone-uzeit,      "Start time
        tuzeit    LIKE rsreqdone-tuzeit,     "End time
        records   LIKE rsreqdone-records,    "Records
        source    LIKE rsldpio-source,       "InfoSource
        logsys    LIKE rsldpio-logsys,       "Source System
        objvers   LIKE rsldpio-objvers,
        infocube(10) TYPE c, "like rsmonictab-infocube,
        infoarea(20) TYPE c ,"like rsdcube-infoarea,
        viewed(6) TYPE c,
        dt_type TYPE c,
        END OF k_monitor.

TYPES: BEGIN OF k_monic,
          rnr LIKE rsreqdone-rnr,
          logdpid LIKE rsreqdone-logdpid,
          infocube(10) TYPE c,
          objvers LIKE rsldpio-objvers,
          uzeit LIKE rsreqdone-uzeit,
          tuzeit LIKE rsreqdone-tuzeit,
          records LIKE rsreqdone-records,
          source LIKE rsldpio-source,
          logsys LIKE rsldpio-logsys,
          infoarea(20) TYPE c ,
          viewed(6) TYPE c,
          dt_type TYPE c,
          tstatus LIKE rsreqdone-tstatus,
          datum LIKE rsreqdone-datum,
END OF k_monic.

********************INTERNAL TABLES********************************
DATA: i_monitor TYPE STANDARD TABLE OF k_monitor
          WITH HEADER LINE.

DATA: i_monitor3 TYPE STANDARD TABLE OF k_monic
          WITH HEADER LINE.

AT SELECTION-SCREEN OUTPUT.
  IF s_date[] IS INITIAL.
    MOVE sy-datum TO s_date-high.
    s_date-low = sy-datum - 1 .
    APPEND s_date.
  ENDIF.

START-OF-SELECTION.

  v_diff = s_date-high - s_date-low.
****************************************
  IF  v_diff EQ 1.

*************
    IF s_uzeit IS NOT INITIAL.
      SELECT l~rnr
      l~logdpid
      l~datum
      l~tstatus
      l~uzeit
      l~tuzeit
      records
      r~source
      r~logsys
      r~objvers
               INTO CORRESPONDING FIELDS OF TABLE i_monitor
               FROM rsreqdone AS l
               LEFT OUTER JOIN rsldpio AS r
               ON l~logdpid = r~logdpid
               WHERE ( l~datum EQ s_date-low AND l~uzeit GT s_uzeit-low )
               OR ( l~datum EQ s_date-high AND l~uzeit LT s_uzeit-high ).

***************
    ELSE.
      SELECT l~rnr
      l~logdpid
      l~datum
      l~tstatus
      l~uzeit
      l~tuzeit
      records
      r~source
      r~logsys
      r~objvers
               INTO CORRESPONDING FIELDS OF TABLE i_monitor
               FROM rsreqdone AS l
               LEFT OUTER JOIN rsldpio AS r
               ON l~logdpid = r~logdpid
               WHERE l~datum IN s_date.
    ENDIF.

****************************************
  ELSEIF v_diff EQ 0.

*************
    IF s_uzeit IS INITIAL.
      SELECT l~rnr
      l~logdpid
      l~datum
      l~tstatus
      l~uzeit
      l~tuzeit
      records
      r~source
      r~logsys
      r~objvers
               INTO CORRESPONDING FIELDS OF TABLE i_monitor
               FROM rsreqdone AS l
               LEFT OUTER JOIN rsldpio AS r
               ON l~logdpid = r~logdpid
               WHERE l~datum IN s_date.
***************
    ELSE.
      SELECT l~rnr
      l~logdpid
      l~datum
      l~tstatus
      l~uzeit
      l~tuzeit
      records
      r~source
      r~logsys
      r~objvers
               INTO CORRESPONDING FIELDS OF TABLE i_monitor
               FROM rsreqdone AS l
               LEFT OUTER JOIN rsldpio AS r
               ON l~logdpid = r~logdpid
               WHERE l~datum IN s_date
               AND l~uzeit IN s_uzeit.
    ENDIF.

****************************************
  ELSEIF v_diff GT 1.
    SELECT l~rnr
    l~logdpid
    l~datum
    l~tstatus
    l~uzeit
    l~tuzeit
    records
    r~source
    r~logsys
    r~objvers
             INTO CORRESPONDING FIELDS OF TABLE i_monitor
             FROM rsreqdone AS l
             LEFT OUTER JOIN rsldpio AS r
             ON l~logdpid = r~logdpid
             WHERE l~datum IN s_date.

  ENDIF.

***************************************************************************
*****************TZONE ADJUSTMENT****************************************
  LOOP AT i_monitor.
    CONCATENATE i_monitor-datum i_monitor-uzeit INTO v_tst.
    v_wa_tst_p = v_tst.

    CONCATENATE i_monitor-datum i_monitor-tuzeit INTO v_tstt.
    v_wa_tstt_p = v_tstt.

    CONVERT TIME STAMP v_wa_tstt_p TIME ZONE v_wa_tzone
        INTO DATE i_monitor-datum
             TIME i_monitor-tuzeit.

    CONVERT TIME STAMP v_wa_tst_p TIME ZONE v_wa_tzone
        INTO DATE i_monitor-datum
             TIME i_monitor-uzeit.

************+++++++++***************
    IF i_monitor-tstatus+1(2) = '08'.
      i_monitor-tstatus = ' (08)'.
    ENDIF.
    IF i_monitor-tstatus+1(2) = '09'.
      i_monitor-tstatus = ' (09)'.
    ENDIF.
    IF i_monitor-tstatus+1(2) = '0A'.
      i_monitor-tstatus = ' (0A)'.
    ENDIF.

    MODIFY i_monitor.

  ENDLOOP.
***************************************************************************
**************************************************************************

  v_select_date = sy-datum - 1.

  SORT i_monitor BY rnr.

*********Get rid of unwanted entries and sort

  DELETE i_monitor WHERE objvers <> 'A' OR
                            source = ' '.

  SORT i_monitor BY datum uzeit source logdpid.

END-OF-SELECTION.
************************************************************
  LOOP AT i_monitor.
    v_count = v_count + 1.
    SELECT SINGLE rnr INTO v_r1 FROM rsiccont WHERE rnr = i_monitor-rnr.
    IF sy-subrc <> 0.
      DELETE i_monitor .
    ENDIF.
  ENDLOOP.

**************************************************************
***  loop at i_monitor.
***  endloop.

***********************************************************
  LOOP AT i_monitor.
    SELECT infocube INTO v_var FROM rsmonictab
          WHERE rnr = i_monitor-rnr.
      i_monitor-infocube = v_var.
      IF v_i = 0 .
        MODIFY i_monitor.
        v_i = 1.
      ELSE.
        APPEND i_monitor.
      ENDIF.
      CLEAR v_var.
    ENDSELECT.
    IF sy-subrc <> 0.
      SELECT icube INTO v_var FROM rsiccont
          WHERE rnr = i_monitor-rnr.
        i_monitor-infocube = v_var.
        IF v_i = 0 .
          MODIFY i_monitor.
          v_i =  1.
        ELSE.
          APPEND i_monitor.
        ENDIF.
        CLEAR v_var.
      ENDSELECT.
    ENDIF.
    CLEAR i_monitor.
    v_i = 0.
    v_cnt = v_cnt + 1.
    IF v_count = v_cnt.
      EXIT.
    ENDIF.
  ENDLOOP.

*********************************************
*********************************************
  LOOP AT i_monitor.
    SELECT SINGLE infoarea INTO v_ifarea FROM rsdcube
          WHERE infocube = i_monitor-infocube.

    IF sy-subrc = 0.
      i_monitor-dt_type = 'C'.
*********++++++++++++++++++++++++++++********
***************IC AFR************************Checking - Infocube - Available for Reporting
*********++++++++++++++++++++++++++++********
      CLEAR v_var.
      CLEAR v_rnsidlast.
      SELECT SINGLE rnsidlast icube INTO (v_rnsidlast, v_var) FROM rsiccont
              WHERE rnr = i_monitor-rnr AND icube = i_monitor-infocube.
      SELECT SINGLE techok INTO v_techok FROM rsmdatastate
             WHERE infocube = v_var.

      IF v_rnsidlast LE v_techok.
        i_monitor-viewed = 'X'.

      ELSE.
        i_monitor-viewed = ' '.
      ENDIF.

      MODIFY i_monitor.
      CLEAR v_var.
      CLEAR v_rnsidlast.
      CLEAR v_techok.

***********************************************
***********************************************

    ELSEIF sy-subrc <> 0.
      SELECT SINGLE infoarea INTO v_ifarea FROM rsdodso
         WHERE odsobject = i_monitor-infocube.
      i_monitor-dt_type = 'O'.

*********++++++++++++++++++++++++++++********
************************ODS AFR**************Checking - ODS - Available for Reporting
*********++++++++++++++++++++++++++++********
      v_i = 0.
      SELECT request INTO v_r1 FROM rsodsactreq
           WHERE operation = 'A' AND status = 0 AND request = i_monitor-rnr.
        IF sy-subrc = 0.
          i_monitor-viewed = 'X'.
          IF v_i = 0 .
            MODIFY i_monitor.
            v_i = 1.
          ELSE.
            APPEND i_monitor.
          ENDIF.
        ENDIF.
      ENDSELECT.
      CLEAR v_r1.

**********************************************
**********************************************

    ENDIF.

    i_monitor-infoarea = v_ifarea.
    MODIFY i_monitor.
    CLEAR i_monitor.
    CLEAR v_ifarea.
  ENDLOOP.

******************STATUS: SUCCESSFUL
  IF p_ok = 'X'.
    READ TABLE i_monitor WITH KEY tstatus+1(2) = '08'.  "GREEN
    IF sy-subrc = 0.
      ULINE /(34).
      WRITE: / sy-vline.
      FORMAT COLOR COL_POSITIVE.
      WRITE: 'Status InfoPackage: Successful'.
      FORMAT COLOR OFF.
      WRITE: sy-vline.

      ULINE AT /(v_gv_uline).
      PERFORM header.
      FORMAT COLOR COL_NORMAL.

************************************************************************
************************************************************************
************************************************************************

      LOOP AT i_monitor WHERE tstatus+1(2) = '08'  "GREEN
                             AND records NE 0.
        WRITE: / sy-vline,
                 i_monitor-logdpid,
                 sy-vline,
                 i_monitor-infocube,
                 sy-vline,
                 i_monitor-datum,
                 sy-vline,
                 i_monitor-uzeit,
                 sy-vline,
                 i_monitor-tuzeit,
                 sy-vline,
                 i_monitor-records,
                 sy-vline,
                 i_monitor-infoarea,
                 sy-vline,
                 i_monitor-tstatus,
                 sy-vline,
                 i_monitor-viewed,
                 sy-vline.

        HIDE: i_monitor-logdpid.
      ENDLOOP.
      FORMAT COLOR OFF.
      ULINE AT /(v_gv_uline).
      SKIP.
    ENDIF.
  ENDIF.

**********STATUS: SUCCESSFUL WITH 0 RECORD LOADED
  IF p_ok_0 = 'X'.
    READ TABLE i_monitor WITH KEY tstatus+1(2) = '08'.   "GREEN
    IF sy-subrc = 0.
      ULINE /(48).
      WRITE: / sy-vline.
      FORMAT COLOR COL_GROUP.
      WRITE: 'Status InfoPackage: Successful with 0 record'.
      FORMAT COLOR OFF.
      WRITE: sy-vline.

      ULINE AT /(v_gv_uline).
      PERFORM header.
      FORMAT COLOR COL_NORMAL.
      LOOP AT i_monitor WHERE tstatus+1(2) = '08'  "GREEN
                             AND records EQ 0.

        WRITE: / sy-vline,
                 i_monitor-logdpid,
                 sy-vline,
                 i_monitor-infocube,
                 sy-vline,
                 i_monitor-datum,
                 sy-vline,
                 i_monitor-uzeit,
                 sy-vline,
                 i_monitor-tuzeit,
                 sy-vline,
                 i_monitor-records,
                 sy-vline,
                 i_monitor-infoarea,
                 sy-vline,
                 i_monitor-tstatus,
                 sy-vline,
                 i_monitor-viewed,
                 sy-vline.

        HIDE: i_monitor-logdpid.
      ENDLOOP.
      FORMAT COLOR OFF.
      ULINE AT /(v_gv_uline).
      SKIP.
    ENDIF.
  ENDIF.

********** STATUS: NOT YET COMPLETED
  IF p_notfin = 'X'.
    READ TABLE i_monitor WITH KEY tstatus+1(2) = '09'.   "YELLOW
    IF sy-subrc = 0.
      ULINE /(41).
      WRITE: / sy-vline.
      FORMAT COLOR COL_TOTAL.
      WRITE: 'Status InfoPackage: Not Yet Completed'.
      FORMAT COLOR OFF.
      WRITE: sy-vline.

      ULINE AT /(v_gv_uline).
      PERFORM header.
      FORMAT COLOR COL_NORMAL.
      LOOP AT i_monitor WHERE tstatus+1(2) = '09'.      "YELLOW

        WRITE: / sy-vline,
                 i_monitor-logdpid,
                  sy-vline,
                  i_monitor-infocube,
                 sy-vline,
                 i_monitor-datum,
                 sy-vline,
                 i_monitor-uzeit,
                 sy-vline,
                 i_monitor-tuzeit,
                 sy-vline,
                 i_monitor-records,
                 sy-vline,
                  i_monitor-infoarea,
                  sy-vline,
                  i_monitor-tstatus,
                  sy-vline,
                  i_monitor-viewed,
                 sy-vline.
        HIDE: i_monitor-logdpid.
      ENDLOOP.
      FORMAT COLOR OFF.
      ULINE AT /(v_gv_uline).
      SKIP.
    ENDIF.
  ENDIF.

*********************** STATUS: INCORRECT
  IF p_notok = 'X'.
    READ TABLE i_monitor WITH KEY tstatus+1(2) = '0A'.    "RED
    IF sy-subrc = 0.
      ULINE /(33).
      WRITE: / sy-vline.
      FORMAT COLOR COL_NEGATIVE.
      WRITE: 'Status InfoPackage: Incorrect'.
      FORMAT COLOR OFF.
      WRITE: sy-vline.
      ULINE AT /(v_gv_uline).
      PERFORM header.
      FORMAT COLOR COL_NORMAL.
      LOOP AT i_monitor WHERE tstatus+1(2) = '0A'.   "RED

        WRITE: / sy-vline,
                 i_monitor-logdpid,
                  sy-vline,
                  i_monitor-infocube,
                 sy-vline,
                 i_monitor-datum,
                 sy-vline,
                 i_monitor-uzeit,
                 sy-vline,
                 i_monitor-tuzeit,
                 sy-vline,
                 i_monitor-records,
                 sy-vline,
                  i_monitor-infoarea,
                  sy-vline,
                  i_monitor-tstatus,
                  sy-vline,
                  i_monitor-viewed,
                 sy-vline.
        HIDE: i_monitor-logdpid.
      ENDLOOP.
      FORMAT COLOR OFF.
      ULINE AT /(v_gv_uline).
    ENDIF.
  ENDIF.

  LOOP AT i_monitor.
    IF i_monitor-tstatus+1(2) = '08'.
      i_monitor-tstatus = 'SUCC'.
    ENDIF.
    IF i_monitor-tstatus+1(2) = '09'.
      i_monitor-tstatus = 'RUN'.
    ENDIF.
    IF i_monitor-tstatus+1(2) = '0A'.
      i_monitor-tstatus = 'FAIL'.
    ENDIF.
    MODIFY i_monitor.
    CLEAR i_monitor.
  ENDLOOP.

  LOOP AT i_monitor.
    MOVE-CORRESPONDING  i_monitor TO i_monitor3.
    APPEND i_monitor3.
  ENDLOOP.

  SORT i_monitor3 BY rnr logdpid infocube.
  DELETE i_monitor3 WHERE tstatus = 'FAIL'.

******************************
  DELETE FROM z40tbiw_monitor1.
  COMMIT WORK.
******************************
  DELETE ADJACENT DUPLICATES FROM i_monitor3 COMPARING rnr logdpid infocube objvers.

  INSERT z40tbiw_monitor1 FROM TABLE i_monitor3.

*******************************************************************************
**********************Subroutine- header*************************************
*******************************************************************************
FORM header.

  FORMAT COLOR COL_HEADING.
  WRITE: /    sy-vline,
              'InfoPackage',
           34 sy-vline,
           35 'InfoCube',
           47 sy-vline,
           48 'Start Date',
           60 sy-vline,
           61 'Start Time',
           71 sy-vline,
           72 'End Time',
           82 sy-vline,
           83 'Records',
           96 sy-vline,
           97 'InfoArea',
           119 sy-vline,
           120 'Status',
           126 sy-vline,
           127 'Rstatus',
           135 sy-vline.

  FORMAT COLOR OFF.
  ULINE AT /(v_gv_uline).

ENDFORM.                        "Header

Author: Author: Marc Bernard, SAP Customer Solution Adoption (CSA)
Submitted: 2008-04-11
Updated: 2012-12-06

Description:

This code tutorial contains four programs that can be used to display and analyze ABAP routines, which are embedded in BI Update Rules, Transfer Rules, and Transformations. You can see an example in the attachments.

All four programs use the same base code to display and analyze the ABAP routines. This base code provides the following features:

  • Code display with line numbers
  • Replacement of internal field-symbols with text labels
  • Comparison of two object versions for example "active" vs. "content" with highlighting of differences
  • Option to highlight critical ABAP statements

    Useful Information

    The code comparison feature is especially helpful to identify differences between the active version (which you might have modified) and the most recent BI content version (which might include bug fixes). The comparison view helps you to determine if you should active the most recent BI content and overwrite you current routine. Alternatively you can use the analysis to determine which manual code adjustments should be made to the routines.

    The highlight feature comes in handy if you want to quickly identify performance critical ABAP statements.

Detailed Features:

The base code also identifies the following types of routines:

  • Transfer Rule
  • Update Rule
  • Time Conversion
  • InfoObject Conversion
  • Global Routine
  • Deletion Routine
  • Formula Routine (generated)
  • Transformation (7.x)

The analysis will show all parts of the routines:

  • Global data definitions
  • Start routines
  • End routines (7.x)
  • Expert routines (7.x)

The analysis will highlight the following statements:

  • CALL FUNCTION and PERFORM statements
    (green - potential for bad performance in function or form routine)
  • SELECT and SELECT SINGLE statements
    (yellow - potential for bad performance)
  • INSERT, UPDATE, MODIFY, DELETE statements
    (red - potential for data inconsistency -> Use APIs instead!)

What separates the programs is the selection screen. Each program allows to select a different set of ABAP routines:

  1. Analyze ABAP Routines by Routine ID (GUID)
    Program ZBI_ABAP_ROUTINES_ANALYZE (BI releases 3.x and 7.x)
  2. Analyze ABAP Routines in Transfer Rules
    Program ZBI_ABAP_ROUTINES_TRANSF_RULES (BI releases 3.x and 7.x)
  3. Analyze ABAP Routines in Update Rules
    Program ZBI_ABAP_ROUTINES_UPDATE_RULES (BI releases 3.x and 7.x)
  4. Analyze ABAP Routines in Transformations
    Program ZBI_ABAP_ROUTINES_TRANSFORM (BI release 7.x)

    Be Careful

    If you run the programs with a wide open selection, it might take a long time since there are typically many ABAP routines in a system.


    Handy Hint

    You will find the coding for the four programs in the child pages.

Version History:

2008-04-11 Initial release
2008-08-13 Renamed programs; minor update for code highlighting; added value-help for program 4
2012-12-06 Fixed the 7.x program for transformations to include field routines

Related Links:

A part of an automation program I wrote about a year ago. I needed a way to generate a datasource from any SAP table in the core ECC environment. So I wrote a program that would generate all the pieces needed to create a datasource.

The program uses DDIF_TABL_GET to get information about the table.

--Get Table structure

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
CALL FUNCTION 'DDIF_TABL_GET'
  EXPORTING
    name          = tbl
    state         = 'A'
    langu         = sy-langu
  IMPORTING
    dd02v_wa      = dd02v
    dd09l_wa      = dd09l
  TABLES
    dd03p_tab     = dd03p
    dd05m_tab     = zdd05m
    dd08v_tab     = zdd08v
    dd12v_tab     = dd12v
    dd17v_tab     = dd17v
    dd35v_tab     = dd35v
    dd36m_tab     = dd36m
  EXCEPTIONS
    illegal_input = 1
    OTHERS        = 2.

The program determines what to do with the table. Is it a cluster or transparent...etc. Next it creates a view using DDIF_TABL_PUT.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
*--Create Structure
CALL FUNCTION 'DDIF_TABL_PUT'
  EXPORTING
    name              = i_viewname
    dd02v_wa          = dd02v
    dd09l_wa          = dd09l
  TABLES
    dd03p_tab         = dd03p
    dd05m_tab         = zdd05m
    dd08v_tab         = zdd08v
    dd35v_tab         = dd35v
    dd36m_tab         = dd36m
  EXCEPTIONS
    tabl_not_found    = 1
    name_inconsistent = 2
    tabl_inconsistent = 3
    put_failure       = 4
    put_refused       = 5
    OTHERS            = 6.

Following this the program activates and generates a function module for the datasource using RS_FUNCTIONMODULE_INSERT.

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
"Create Function Module
CALL FUNCTION 'RS_FUNCTIONMODULE_INSERT'
  EXPORTING
    funcname                = funcname
    function_pool           = 'ZIDBI'
    short_text              = shrt_txt
  TABLES
    import_parameter        = import
    tables_parameter        = table
    source                  = source
  EXCEPTIONS
    double_task             = 1
    error_message           = 2
    function_already_exists = 3
    invalid_function_pool   = 4
    invalid_name            = 5
    too_many_functions      = 6
    no_modify_permission    = 7
    no_show_permission      = 8
    enqueue_system_failure  = 9
    canceled_in_corr        = 10
    OTHERS                  = 11.

Last but least it generates a datasource using RSA1_OLTPSOURCE_GENERATE

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
CALL FUNCTION 'RSA1_OLTPSOURCE_GENERATE'
  EXPORTING
    i_save_despite_warning = rsaot_c_flag-on
    i_no_transport         = i_no_transport  " note 605145
    i_s_oltpsource         = l_s_osgen
    i_s_mddelta            = g_s_mddelta
    i_s_gendelta           = g_s_gendelta
    i_t_oltpsourcefields   = l_t_osgenfd
    i_t_ostext             = l_t_ostext
    i_with_dynpro          = i_showdynp
    i_s_dd02v              = l_s_dd02v
    i_t_dd03p              = l_t_dd03p
    i_t_dd05m              = l_t_dd05m
    i_t_dd08v              = l_t_dd08v
  IMPORTING
    e_t_messages           = l_t_messages
    e_subrc                = l_subrc
    e_s_osource            = l_s_osource
  EXCEPTIONS
    cancelled              = 1
    OTHERS                 = 2.

Download Source code from here

http://www.sapminiapps.com/Store/ABAP-Reports/BW/BI-Datasource-generator-for-ECC/R3/index.php

Author: Marc Bernard, SAP Intelligence Platform and NetWeaver RIG Americas
Submitted: 2009-09-18

Description:
This function module is use in connection with the paper: How-to... Report on BW Accelerator Usage Counts

Related Links:

FUNCTION-POOL ZBI_VIP.    

TYPE-POOLS: rs.

FUNCTION zbi_vip_bwa_usage_count.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_INFOPROV) TYPE  RSINFOPROV
*"     REFERENCE(I_KEYDATE) TYPE  D
*"     REFERENCE(I_MAXROWS) TYPE  I DEFAULT -1
*"     REFERENCE(I_TH_SFC) TYPE  RSDRI_TH_SFC
*"     REFERENCE(I_TH_SFK) TYPE  RSDRI_TH_SFK
*"     REFERENCE(I_T_RANGE) TYPE  RSDRI_T_RANGE
*"     REFERENCE(I_TX_RANGETAB) TYPE  RSDRI_TX_RANGETAB
*"     REFERENCE(I_FIRST_CALL) TYPE  RS_BOOL
*"     REFERENCE(I_PACKAGESIZE) TYPE  I
*"     REFERENCE(I_USE_AGGREGATION) TYPE  RS_BOOL DEFAULT RS_C_FALSE
*"     REFERENCE(I_SHOW_STATEMENT) TYPE  RS_BOOL DEFAULT RS_C_FALSE
*"  EXPORTING
*"     REFERENCE(E_T_DATA) TYPE  STANDARD TABLE
*"     REFERENCE(E_END_OF_DATA) TYPE  RS_BOOL
*"     REFERENCE(E_T_MSG) TYPE  RS_T_MSG
*"  EXCEPTIONS
*"      REMOTE_READ_FAILED
*"      X_MESSAGE
*"----------------------------------------------------------------------

  DEFINE check_subrc.
    if sy-subrc <> 0.
      message e301(dbman) with &1 &2 &3 &4 into l_message.
      move-corresponding syst to l_s_msg.
      append l_s_msg to e_t_msg.
      raise remote_read_failed.
    endif.
  END-OF-DEFINITION. "check_subrc

  TYPES:
    BEGIN OF y_s_mapping,
      iobjnm          TYPE rsiobjnm,
      fieldnm         TYPE rsfieldnm,
    END OF y_s_mapping,
    y_th_mapping      TYPE HASHED TABLE OF y_s_mapping WITH UNIQUE KEY iobjnm.

  STATICS:
    s_tabnm           TYPE rstabnm,
    s_cursor          TYPE cursor,
    s_count           TYPE i,
    s_packagesize     TYPE i,
    s_logsys          TYPE rsslogsys,
    s_th_mapping      TYPE y_th_mapping,
    s_r_data          TYPE REF TO data,
    s_r_t_data        TYPE REF TO data.

  DATA:
    l_s_sfc           TYPE rsdri_s_sfc,
    l_s_sfk           TYPE rsdri_s_sfk,
    l_s_range         TYPE rsdri_s_range,
    l_s_range_prev    TYPE rsdri_s_range,
    l_t_range         TYPE rsdri_t_range,
    l_message         TYPE string,
    l_s_msg           TYPE rs_s_msg,
    l_s_fieldtab      TYPE dfies,
    l_t_fieldtab      TYPE spar_dfies,
    l_s_mapping       TYPE y_s_mapping,
    l_s_field         TYPE rsdmd_s_where,
    l_t_field         TYPE rsdmd_t_where,
    l_s_where         TYPE rsdmd_s_where,
    l_t_where         TYPE rsdmd_t_where,
    l_r_rswhere       TYPE REF TO cl_rs_where,
    l_s_code          TYPE rscodeline,
    l_t_code          TYPE TABLE OF rscodeline,
    l_first_item      TYPE rs_bool,
    l_intlen          TYPE i,
    l_intlow          TYPE i,
    l_inthigh         TYPE i,
    l_delfrom         TYPE i,
    l_count           TYPE i.

  FIELD-SYMBOLS:
    <l_data>          TYPE ANY,
    <l_s_data>        TYPE ANY,
    <l_t_data>        TYPE ANY TABLE,
    <l_olap>          TYPE ANY,
    <l_s_olap>        TYPE ANY.

*** FIRST CALL *********************************************************

  CHECK i_infoprov = 'ZTCT_VC31'.

  IF i_first_call = rs_c_true.

*-- 1) InfoProvider <-> Table ------------------------------------------

    s_tabnm = 'RSDDSTATBIAUSE'.

    CALL FUNCTION 'RSA_LOGICAL_SYSTEM_BIW_GET'
      EXPORTING
        i_without_popup          = rs_c_true
      IMPORTING
        e_logsys_biw             = s_logsys
      EXCEPTIONS
        no_logsys_to_this_client = 1
        logsys_changed           = 2
        OTHERS                   = 3.
    CHECK sy-subrc = 0.

*   Get information about fields
    CALL FUNCTION 'DDIF_NAMETAB_GET'
      EXPORTING
        tabname   = s_tabnm
      TABLES
        dfies_tab = l_t_fieldtab
      EXCEPTIONS
        not_found = 1
        OTHERS    = 2.
    check_subrc 'Table' s_tabnm 'does not exist' ''.

*-- 2) InfoObject <-> Table Field --------------------------------------

    CLEAR l_s_mapping.
    l_s_mapping-iobjnm  = '0CALDAY'.
    l_s_mapping-fieldnm = 'CALDAY'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.
    l_s_mapping-iobjnm  = '0TCTIFPROV'.
    l_s_mapping-fieldnm = 'INFOPROV'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.
    l_s_mapping-iobjnm  = 'ZTCTBWA1'.
    l_s_mapping-fieldnm = 'BIA_USED'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.
    l_s_mapping-iobjnm  = 'ZTCTBWA2'.
    l_s_mapping-fieldnm = 'BIA_TECHINA'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.
    l_s_mapping-iobjnm  = 'ZTCTBWA3'.
    l_s_mapping-fieldnm = 'BIA_INA'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.
    l_s_mapping-iobjnm  = 'ZTCTBWA4'.
    l_s_mapping-fieldnm = 'DB_FALLBACK'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.
    l_s_mapping-iobjnm  = 'ZTCTBWA5'.
    l_s_mapping-fieldnm = 'BIA_NOTPOSSIBLE'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.
    l_s_mapping-iobjnm  = 'ZTCTBWA6'.
    l_s_mapping-fieldnm = 'NO_BIA'.
    INSERT l_s_mapping INTO TABLE s_th_mapping.

*-- 3) InfoObjects <-> Into and Group By Clauses -----------------------

*   Characteristics
    LOOP AT i_th_sfc INTO l_s_sfc.
      READ TABLE s_th_mapping INTO l_s_mapping WITH TABLE KEY iobjnm = l_s_sfc-chanm.
      CHECK sy-subrc = 0.

      CLEAR l_s_field.
      l_s_field-line = l_s_mapping-fieldnm.
      INSERT l_s_field INTO TABLE l_t_field.
    ENDLOOP.

*   Key figures
    LOOP AT i_th_sfk INTO l_s_sfk.
      READ TABLE s_th_mapping INTO l_s_mapping WITH TABLE KEY iobjnm = l_s_sfk-kyfnm.
      CHECK sy-subrc = 0.

      CLEAR l_s_field.
      l_s_field-line = l_s_mapping-fieldnm.
      INSERT l_s_field INTO TABLE l_t_field.
    ENDLOOP.

*-- 4) Selection <-> Where Clause --------------------------------------

*   Clean up ranges
    l_t_range = i_t_range.
    SORT l_t_range BY chanm sign DESCENDING low high.
    DELETE ADJACENT DUPLICATES FROM l_t_range.

*   Build where clause
    l_first_item = rs_c_true.
    CREATE OBJECT l_r_rswhere.
    LOOP AT l_t_range INTO l_s_range.

      READ TABLE s_th_mapping INTO l_s_mapping WITH TABLE KEY iobjnm = l_s_range-chanm.
      CHECK sy-subrc = 0.

      READ TABLE l_t_fieldtab INTO l_s_fieldtab WITH KEY fieldname = l_s_mapping-fieldnm.
      CHECK sy-subrc = 0.

*     Connect with previous item (if not first one)
      IF l_first_item = rs_c_true.
        IF l_s_range-sign = 'I'.
          l_r_rswhere->add_opening_bracket( ).
        ELSE.
          l_r_rswhere->add_line( 'NOT' ).
          l_r_rswhere->add_opening_bracket( ).
        ENDIF.
        l_first_item = rs_c_false.
      ELSE.
*       Same CHANM + same sign
        IF l_s_range_prev-chanm = l_s_range-chanm AND
           l_s_range_prev-sign  = l_s_range-sign.
          l_r_rswhere->add_or( ).
*       Same CHANM + change from I to E
        ELSEIF l_s_range_prev-chanm = l_s_range-chanm AND
               l_s_range_prev-sign <> l_s_range-sign.
          l_r_rswhere->add_closing_bracket( ).
          l_r_rswhere->add_and( ).
          l_r_rswhere->add_line( 'NOT' ).
          l_r_rswhere->add_opening_bracket( ).
*       Change of CHANM + sign = 'I'
        ELSEIF l_s_range_prev-chanm <> l_s_range-chanm AND
               l_s_range-sign = 'I'.
          l_r_rswhere->add_closing_bracket( ).
          l_r_rswhere->add_and( ).
          l_r_rswhere->add_opening_bracket( ).
*       Change of CHANM + sign = 'E'
        ELSE.
          l_r_rswhere->add_closing_bracket( ).
          l_r_rswhere->add_and( ).
          l_r_rswhere->add_line( 'NOT' ).
          l_r_rswhere->add_opening_bracket( ).
        ENDIF.
      ENDIF.

*     Special logic for integer fields (no quotes around values)
      IF l_s_fieldtab-datatype(3) = 'INT'.

        l_intlow = l_s_range-low.
        l_inthigh = l_s_range-high.

        CASE l_s_range-compop.
          WHEN 'EQ'.
            l_r_rswhere->add_line( l_s_mapping-fieldnm ).
            l_r_rswhere->add_line( '=' ).
            l_r_rswhere->add_line( l_intlow ).
          WHEN 'BT'.
            l_r_rswhere->add_line( l_s_mapping-fieldnm ).
            l_r_rswhere->add_line( 'BETWEEN' ).
            l_r_rswhere->add_line( l_intlow ).
            l_r_rswhere->add_line( 'AND' ).
            l_r_rswhere->add_line( l_inthigh ).
          WHEN OTHERS.
*           Ignore
        ENDCASE.

*     Other fields
      ELSE.
        l_intlen = l_s_fieldtab-intlen.

        CASE l_s_range-compop.
          WHEN 'EQ'.
            l_r_rswhere->add_field(
              i_fieldnm               = l_s_mapping-fieldnm
              i_operator              = '='
              i_intlen                = l_intlen
              i_datatp                = l_s_fieldtab-datatype
              i_init_field_with_value = rs_c_true
              i_value                 = l_s_range-low ).
          WHEN 'BT'.
            l_r_rswhere->add_field_between_2values(
              i_fieldnm                 = l_s_mapping-fieldnm
              i_intlen                  = l_intlen
              i_datatp                  = l_s_fieldtab-datatype
              i_init_fields_with_values = rs_c_true
              i_value_low               = l_s_range-low
              i_value_high              = l_s_range-high ).
          WHEN 'CP'.
            TRANSLATE l_s_range-low USING '+?*%'.
            l_r_rswhere->add_field(
              i_fieldnm               = l_s_mapping-fieldnm
              i_operator              = 'LIKE'
              i_intlen                = l_intlen
              i_datatp                = l_s_fieldtab-datatype
              i_init_field_with_value = rs_c_true
              i_value                 = l_s_range-low ).
          WHEN OTHERS.
*           Ignore
        ENDCASE.
      ENDIF.

*     Keep reference to current entry
      l_s_range_prev = l_s_range.
    ENDLOOP.

    IF l_first_item = rs_c_false.
      l_r_rswhere->add_closing_bracket( ).
    ENDIF.

    l_r_rswhere->check_validity( IMPORTING e_t_where = l_t_where ).

*-- 5) Determine Package Size ------------------------------------------

    IF i_packagesize > 0.
      s_packagesize = i_packagesize.
    ELSEIF i_packagesize < 0.
      s_packagesize = 2147483647. "max int
    ELSE.
      s_packagesize = 10000.
    ENDIF.

    s_count = 0.

*-- 6) Open Cursor for Selection ---------------------------------------

    IF i_show_statement = rs_c_true.
      CLEAR: l_s_code, l_t_code.

      l_s_code = 'SELECT'.
      APPEND l_s_code TO l_t_code.

      LOOP AT l_t_field INTO l_s_field.
        l_s_code = l_s_field-line.
        APPEND l_s_code TO l_t_code.
      ENDLOOP.

      CONCATENATE 'FROM' s_tabnm INTO l_s_code SEPARATED BY space.
      APPEND l_s_code TO l_t_code.

      l_s_code = 'WHERE'.
      APPEND l_s_code TO l_t_code.

      LOOP AT l_t_where INTO l_s_where.
        l_s_code = l_s_where-line.
        CONDENSE l_s_code.
        APPEND l_s_code TO l_t_code.
      ENDLOOP.

      EDITOR-CALL FOR l_t_code DISPLAY-MODE.
    ENDIF.

    OPEN CURSOR WITH HOLD s_cursor FOR
      SELECT (l_t_field) FROM (s_tabnm) WHERE (l_t_where).

    CREATE DATA s_r_data   TYPE (s_tabnm).
    CREATE DATA s_r_t_data TYPE TABLE OF (s_tabnm).

  ENDIF.

*** SUBSEQUENT CALLS ***************************************************

  ASSIGN s_r_data->*    TO <l_s_data>.
  ASSIGN s_r_t_data->*  TO <l_t_data>.

  CLEAR: <l_t_data>, e_t_data, e_end_of_data, e_t_msg.

*-- 7) Fetch Next Package ----------------------------------------------

  FETCH NEXT CURSOR s_cursor
    INTO CORRESPONDING FIELDS OF TABLE <l_t_data>
    PACKAGE SIZE s_packagesize.
  IF sy-subrc = 0.
    e_end_of_data = rs_c_false.
  ELSE.
    CLOSE CURSOR s_cursor.
    e_end_of_data = rs_c_true.
    EXIT.
  ENDIF.

*-- 8) Convert Table Structure to OLAP Structure -----------------------

  ASSIGN LOCAL COPY OF INITIAL LINE OF e_t_data TO <l_s_olap>.

  LOOP AT <l_t_data> ASSIGNING <l_s_data>.
    CLEAR <l_s_olap>.

*   Characteristics
    LOOP AT i_th_sfc INTO l_s_sfc.
      ASSIGN COMPONENT l_s_sfc-chaalias OF STRUCTURE <l_s_olap> TO <l_olap>.
      IF sy-subrc <> 0.
        RAISE x_message.
      ENDIF.

      READ TABLE s_th_mapping INTO l_s_mapping WITH TABLE KEY iobjnm = l_s_sfc-chanm.
      IF sy-subrc = 0.
        ASSIGN COMPONENT l_s_mapping-fieldnm OF STRUCTURE <l_s_data> TO <l_data>.
        check_subrc 'Field' l_s_mapping-fieldnm 'does not exist in table' s_tabnm.

        <l_olap> = <l_data>.
      ELSE.
        CASE l_s_sfc-chanm.
          WHEN '0TCTSYSID'.
            <l_olap> = s_logsys.
          WHEN '0TCTIFTYPE'.
            ASSIGN COMPONENT 'INFOPROV' OF STRUCTURE <l_s_data> TO <l_data>.
            CHECK sy-subrc = 0.
            <l_olap> = cl_rstct_birs_extraction=>get_infoprovider_type( <l_data> ).
          WHEN '0TCTOBJVERS'.
            <l_olap> = rs_c_objvers-active.
        ENDCASE.
      ENDIF.
    ENDLOOP.

*   Key figures
    LOOP AT i_th_sfk INTO l_s_sfk.
      ASSIGN COMPONENT l_s_sfk-kyfalias OF STRUCTURE <l_s_olap> TO <l_olap>.
      IF sy-subrc <> 0.
        RAISE x_message.
      ENDIF.

*     Row count
      IF l_s_sfk-kyfnm = rsd_c_kyfnm-rowcount.
        <l_olap> = 1.
        CONTINUE.
      ENDIF.

      READ TABLE s_th_mapping INTO l_s_mapping WITH TABLE KEY iobjnm = l_s_sfk-kyfnm.
      CHECK sy-subrc = 0.

      ASSIGN COMPONENT l_s_mapping-fieldnm OF STRUCTURE <l_s_data> TO <l_data>.
      check_subrc 'Field' l_s_mapping-fieldnm 'does not exist in table' s_tabnm.

      <l_olap> = <l_data>.
    ENDLOOP.

*   InfoProvider
    ASSIGN COMPONENT rsd_c_dpanm-infoprov OF STRUCTURE <l_s_olap> TO <l_olap>.
    IF sy-subrc = 0.
      <l_olap> = i_infoprov.
    ENDIF.

    COLLECT <l_s_olap> INTO e_t_data.
  ENDLOOP.

*-- 9) Maximum Number of Rows ------------------------------------------

  l_count = s_count +  LINES( e_t_data ).

  IF l_count => i_maxrows AND i_maxrows > 0.
*   Done! Maybe a bit too much?
    l_delfrom = i_maxrows - s_count + 1.
    IF l_delfrom > 0.
      DELETE e_t_data FROM l_delfrom.
    ENDIF.

    CLOSE CURSOR s_cursor.
    e_end_of_data = rs_c_true.
  ELSE.
    s_count = l_count.
  ENDIF.

ENDFUNCTION.
Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
**** Begin - NAVEEN VYTLA 01/01/2012 Delete Invalid or Special Chars from Material Description.

DATA: hex_val TYPE   xstring .
DATA: wa_low TYPE ztgb_const_value-low.
DATA: charge_val TYPE string.
DATA: hex_check_offset TYPE  i.
DATA: hex_val_store(80) TYPE c.         "Double the InfoObject Length (40x2 = 80)
DATA: in_txz01 TYPE string.             "Source Field (TXZ01)

DATA: i_hex TYPE RANGE OF /bic/oinmatdesc,  "Target InfoObject (NMATDESC)
      i_hex_line LIKE LINE OF i_hex.

REFRESH i_hex.

i_hex_line-sign = 'I' .
i_hex_line-option = 'EQ' .

SELECT low FROM z_const_value INTO wa_low WHERE source = 'BW'   "Table to store Constant Values (Z_CONST_VALUE)
                                            AND constname = 'BATCH_HEX' .
  i_hex_line-low = wa_low+0(2) .
  COLLECT i_hex_line INTO i_hex.

ENDSELECT.

DATA: strlen TYPE i.
DATA: l_index TYPE sy-tabix.

LOOP AT source_package ASSIGNING <source_fields> .

  CLEAR in_txz01.

  in_txz01 = <source_fields>-txz01.

  l_index = sy-tabix.

  CLEAR hex_val.
  CLEAR strlen.

  CHECK NOT in_txz01 IS INITIAL.

  CALL FUNCTION 'NLS_STRING_CONVERT_FROM_SYS'
    EXPORTING
      lang_used             = sy-langu
      source                = in_txz01
*     TO_FE                 = 'MS '
    IMPORTING
      result                = hex_val
*     SUBSTED               =
    EXCEPTIONS
      illegal_syst_codepage = 1
      no_fe_codepage_found  = 2
      could_not_convert     = 3
      OTHERS                = 4.

  hex_val_store = hex_val .
  SHIFT hex_val_store LEFT DELETING LEADING space.

  strlen = strlen( hex_val_store )  / 2 .

  DO strlen TIMES.

    hex_check_offset = ( sy-index - 1 ) * 2 .

    IF hex_val_store+hex_check_offset(2) IN i_hex .
      CLEAR hex_val_store+hex_check_offset(2).
    ENDIF.

  ENDDO.

  CONDENSE hex_val_store NO-GAPS .

  hex_val = hex_val_store .

  CALL FUNCTION 'NLS_STRING_CONVERT_TO_SYS'
    EXPORTING
      lang_used             = sy-langu
      source                = hex_val
*     FROM_FE               = 'MS '
    IMPORTING
      result                = charge_val
*     SUBSTED               =
    EXCEPTIONS
      illegal_syst_codepage = 1
      no_fe_codepage_found  = 2
      could_not_convert     = 3
      OTHERS                = 4.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
             WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  SHIFT charge_val LEFT DELETING LEADING space.

  <source_fields>-txz01 = charge_val .

ENDLOOP.

******* End - NAVEEN VYTLA 01/01/2012 Delete Invalid or Special Chars from Material Description. 

Author: Marc Bernard, SAP Technology RIG
Submitted: 2010-03-22
Updated: 2010-03-22

Description:
This snippet is showing how to derive one BPS variable from another variable.

Related Links:

Variable User Exit
FUNCTION zmb_variable_user_exit.
*--------------------------------------------------------------------
**Local interface:
*       IMPORTING
*             VALUE(I_AREA) TYPE  UPC_Y_AREA
*             VALUE(I_VARIABLE) TYPE  UPC_Y_VARIABLE
*             VALUE(I_CHANM) TYPE  UPC_Y_CHANM OPTIONAL
*             VALUE(ITO_CHANM) TYPE  UPC_YTO_CHA
*       EXPORTING
*             REFERENCE(ETO_CHARSEL) TYPE  UPC_YTO_CHARSEL
*--------------------------------------------------------------------

* Source variable
  CONSTANTS:
    c_area      TYPE upc_y_area     VALUE 'ZAREA',
    c_variable  TYPE upc_y_variable VALUE 'ZVAR'.

* Local buffer
  STATICS:
    sto_value   TYPE upc_yto_charsel,
    sto_charsel TYPE upc_yto_charsel.

* Local variables
  DATA:
    l_seqno     TYPE i,
    ls_value    TYPE upc_ys_charsel,
    lto_value   TYPE upc_yto_charsel,
    ls_charsel  TYPE upc_ys_charsel,
    lr_var      TYPE REF TO cl_sem_variable.

* Get instance of variable
  CALL METHOD cl_sem_variable=>get_instance
    EXPORTING
      i_area       = c_area
      i_variable   = c_variable
    RECEIVING
      rr_variable  = lr_var
    EXCEPTIONS
      not_existing = 1
      OTHERS       = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
               RAISING failed.
  ENDIF.

* Get user-specific values
  CALL METHOD lr_var->get_value
    RECEIVING
      rto_value = lto_value
    EXCEPTIONS
      error     = 1
      OTHERS    = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
               RAISING failed.
  ENDIF.

* Is the source variable still the same as before?
* If yes, return same selection
  IF lto_value = sto_value.
    eto_charsel = sto_charsel.
    EXIT.
  ELSE.
    sto_value = lto_value.
  ENDIF.

* FOR EXAMPLE: Derive target variable from source selection
* >>> Add you own logic here
  REFRESH eto_charsel.
  CLEAR l_seqno.

  LOOP AT lto_value INTO ls_value.
    CLEAR ls_charsel.
    ls_charsel-chanm  = i_chanm.
    ls_charsel-seqno  = l_seqno.
    ls_charsel-sign   = 'I'.
    ls_charsel-opt    = 'EQ'.
    ls_charsel-low    = ls_value-low+5(10).  "<<<for example
    ls_charsel-high   = ''.
    COLLECT ls_charsel INTO eto_charsel.
    l_seqno = l_seqno + 1.
  ENDLOOP.

* Set export table to selected values
  sto_charsel = eto_charsel.

ENDFUNCTION.

Author: Michael Hoerisch
Submitted: 09/28/2007
Related Links:

  • How to guide: How To... Improve the runtime of the 0FI_GL_4 extractor (link)
  • Blog

Description
This Coding is related to the Howto paper mentioned above. Please read the Howto and use the blog to provide input and feedback.

*&---------------------------------------------------------------------*
*& Report  YBW_FI_GL_4_DELTA_COLLECT
*&
*&---------------------------------------------------------------------*
*&
*& This report collects new and changed documents for the 0FI_GL_4 from
*& the FI application tables and writes them to the delta queues of all
*& connected BW system.
*&
*& The BW extractor itself therefore needs only to process a small
*& amount of records from the application tables to the delta queue,
*& before the content of the delta queue is sent to the BW system.
*&
*&---------------------------------------------------------------------*
REPORT ybw_fi_gl_4_delta_collect.
TYPE-POOLS: sbiw.
* Constants
* The 'DUMMY_BW' constant is the same as defined in Step 1 of the How to guide
CONSTANTS: c_dlogsys    TYPE logsys     VALUE 'DUMMY_BW',
           c_oltpsource TYPE roosourcer VALUE '0FI_GL_4'.
* Filed symbols
FIELD-SYMBOLS: <l_s_roosprmsc> TYPE roosprmsc,
               <l_s_roosprmsf> TYPE roosprmsf.
* Variables
DATA: l_slogsys      TYPE logsys,
      l_tfstruc      TYPE rotfstruc,
      l_lines_read   TYPE sy-tabix,
      l_subrc        TYPE sy-subrc,
      l_s_rsbasidoc  TYPE rsbasidoc,
      l_s_roosgen    TYPE roosgen,
      l_s_parameters TYPE roidocprms,
      l_t_fields     TYPE TABLE OF rsfieldsel,
      l_t_roosprmsc  TYPE TABLE OF roosprmsc,
      l_t_roosprmsf  TYPE TABLE OF roosprmsf.
* Selection parameters
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP 1.
PARAMETER prlogsys LIKE tbdls-logsys OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK b1.
AT SELECTION-SCREEN.
* Check logical system
  SELECT COUNT * FROM  tbdls BYPASSING BUFFER
                  WHERE logsys = prlogsys.
  IF sy-subrc <> 0.
    MESSAGE e454(b1) WITH prlogsys.
* The logical system & has not yet been defined
  ENDIF.
START-OF-SELECTION.
* Check if logical system for dummy BW is defined (Transaction BD54)
  SELECT COUNT * FROM  tbdls BYPASSING BUFFER
                  WHERE logsys = c_dlogsys.
  IF sy-subrc <> 0.
    MESSAGE e454(b1) WITH c_dlogsys.
* The logical system & has not yet been defined
  ENDIF.
* Get own logical system
  CALL FUNCTION 'RSAN_LOGSYS_DETERMINE'
    EXPORTING
      i_client = sy-mandt
    IMPORTING
      e_logsys = l_slogsys.
* Check if transfer rules exist for this extractor in BW
  SELECT SINGLE * FROM  roosgen INTO l_s_roosgen
                  WHERE oltpsource = c_oltpsource
                  AND   rlogsys    = prlogsys
                  AND   slogsys    = l_slogsys.
  IF sy-subrc <> 0.
    MESSAGE e025(rj) WITH prlogsys.
* No transfer rules for target system &
  ENDIF.
* Copy record for dummy BW system
  l_s_roosgen-rlogsys = c_dlogsys.
  MODIFY roosgen FROM l_s_roosgen.
  IF sy-subrc <> 0.
    MESSAGE e053(rj) WITH text-002.
* Update of table ROOSGEN failed
  ENDIF.
* Assignment of source system to BW system
  SELECT SINGLE * FROM  rsbasidoc INTO l_s_rsbasidoc
                  WHERE slogsys = l_slogsys
                  AND   rlogsys = prlogsys.
  IF sy-subrc <> 0 OR
     ( l_s_rsbasidoc-objstat = sbiw_c_objstat-inactive ).
    MESSAGE e053(rj) WITH text-003.
* Remote destination not valid
  ENDIF.
* Copy record for dummy BW system
  l_s_rsbasidoc-rlogsys = c_dlogsys.
  MODIFY rsbasidoc FROM l_s_rsbasidoc.
  IF sy-subrc <> 0.
    MESSAGE e053(rj) WITH text-004.
* Update of table RSBASIDOC failed
  ENDIF.
* Delta initializations
  SELECT * FROM  roosprmsc INTO TABLE l_t_roosprmsc
           WHERE oltpsource = c_oltpsource
           AND   rlogsys    = prlogsys
           AND   slogsys    = l_slogsys.
  IF sy-subrc <> 0.
    MESSAGE e020(rsqu).
* Some of the initialization requirements have not been completed
  ENDIF.
  LOOP AT l_t_roosprmsc ASSIGNING <l_s_roosprmsc>.
    IF <l_s_roosprmsc>-initstate = ' '.
      MESSAGE e020(rsqu).
* Some of the initialization requirements have not been completed
    ENDIF.
    <l_s_roosprmsc>-rlogsys = c_dlogsys.
    <l_s_roosprmsc>-gottid  = ''.
    <l_s_roosprmsc>-gotvers = '0'.
    <l_s_roosprmsc>-gettid  = ''.
    <l_s_roosprmsc>-getvers = '0'.
  ENDLOOP.
* Delete old records for dummy BW system
  DELETE FROM  roosprmsc
         WHERE oltpsource = c_oltpsource
           AND rlogsys    = c_dlogsys
           AND slogsys    = l_slogsys.
* Copy records for dummy BW system
  MODIFY roosprmsc FROM TABLE l_t_roosprmsc.
  IF sy-subrc <> 0.
    MESSAGE e053(rj) WITH text-005.
* Update of table ROOSPRMSC failed
  ENDIF.
* Filter values for delta initializations
  SELECT * FROM  roosprmsf INTO TABLE l_t_roosprmsf
           WHERE oltpsource = c_oltpsource
           AND   rlogsys    = prlogsys
           AND   slogsys    = l_slogsys.
  IF sy-subrc <> 0.
    MESSAGE e020(rsqu).
* Some of the initialization requirements have not been completed
  ENDIF.
  LOOP AT l_t_roosprmsf ASSIGNING <l_s_roosprmsf>.
    <l_s_roosprmsf>-rlogsys = c_dlogsys.
  ENDLOOP.
* Delete old records for dummy BW system
  DELETE FROM  roosprmsf
         WHERE oltpsource = c_oltpsource
           AND rlogsys    = c_dlogsys
           AND slogsys    = l_slogsys.
* Copy records for dummy BW system
  MODIFY roosprmsf FROM TABLE l_t_roosprmsf.
  IF sy-subrc <> 0.
    MESSAGE e053(rj) WITH text-006.
* Update of table ROOSPRMSF failed
  ENDIF.
*************************************
* COMMIT WORK for changed meta data *
*************************************
  COMMIT WORK.
* Delete RFC queue of dummy BW system
* (Just in case entries of other delta requests exist)
  CALL FUNCTION 'RSC1_TRFC_QUEUE_DELETE_DATA'
    EXPORTING
      i_osource           = c_oltpsource
      i_rlogsys           = c_dlogsys
      i_all               = 'X'
    EXCEPTIONS
      tid_not_executed    = 1
      invalid_parameter   = 2
      client_not_found    = 3
      error_reading_queue = 4
      OTHERS              = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*******************************************
* COMMIT WORK for deletion of delta queue *
*******************************************
  COMMIT WORK.
* Get MAXLINES for data package
  CALL FUNCTION 'RSAP_IDOC_DETERMINE_PARAMETERS'
    EXPORTING
      i_oltpsource   = c_oltpsource
      i_slogsys      = l_slogsys
      i_rlogsys      = prlogsys
      i_updmode      = 'D '
    IMPORTING
      e_s_parameters = l_s_parameters
      e_subrc        = l_subrc.
  .
  IF l_subrc <> 0.
    MESSAGE e053(rj) WITH text-007.
* Error in function module RSAP_IDOC_DETERMINE_PARAMETERS
  ENDIF.
* Transfer structure depends on transfer method
  CASE l_s_roosgen-tfmethode.
    WHEN 'I'.
      l_tfstruc = l_s_roosgen-tfstridoc.
    WHEN 'T'.
      l_tfstruc = l_s_roosgen-tfstruc.
  ENDCASE.
* Determine transfer structure field list
  PERFORM fill_field_list(saplrsap) TABLES l_t_fields
                                    USING  l_tfstruc.
* Start the delta extraction for the dummy BW system
  CALL FUNCTION 'RSFH_GET_DATA_SIMPLE'
    EXPORTING
      i_requnr                     = 'DUMMY'
      i_osource                    = c_oltpsource
      i_showlist                   = ' '
      i_maxsize                    = l_s_parameters-maxlines
      i_maxfetch                   = '9999'
      i_updmode                    = 'D '
      i_rlogsys                    = c_dlogsys
      i_read_only                  = ' '
    IMPORTING
      e_lines_read                 = l_lines_read
    TABLES
      i_t_field                    = l_t_fields
    EXCEPTIONS
      generation_error             = 1
      interface_table_error        = 2
      metadata_error               = 3
      error_passed_to_mess_handler = 4
      no_authority                 = 5
      OTHERS                       = 6.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*********************************
* COMMIT WORK for delta request **********************************
   COMMIT WORK.
* Delete RFC queue of dummy BW system
  CALL FUNCTION 'RSC1_TRFC_QUEUE_DELETE_DATA'
    EXPORTING
      i_osource           = c_oltpsource
      i_rlogsys           = c_dlogsys
      i_all               = 'X'
    EXCEPTIONS
      tid_not_executed    = 1
      invalid_parameter   = 2
      client_not_found    = 3
      error_reading_queue = 4
      OTHERS              = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
* Data collection for 0FI_GL_4 delta queue successful
  MESSAGE s053(rj) WITH text-008.

BACKGROUND                                       
In the BW application environment, we build aggregates on the cubes, so as to improve the performance of the queries based on those cubes.
Aggregates are basically MINI CUBES or SUBSET of a cube, which physically contain data and have the same structure as that of a cube. Aggregates are used to improve the performance of the query by reducing the execution time.
Although, the aggregates are used to improve performance of the queries, maintaining unnecessary aggregates would prove to be an overhead in the system and they also occupy physical space.
Validating the Aggregate usage on a periodic basis is important due to following factors.
1)    Unnecessarily creating aggregates within the system, which are not primarily used, also contributes to the slow down of system performance.
2)    Unnecessary aggregates occupy physical space.
3)    Identifying unused aggregates will help in utilizing the system space more efficiently.
4)    Limitation should also be set on the number of aggregates being created, for ideal system performance.
5)    User behavior pertaining to the query analysis and navigation may be variable in terms of usage. This may lead to non-usage of certain aggregates over a certain period of time, thereby rendering the aggregate useless.
In such circumstances, the ASTAT tool eases the task of recognition of such aggregates, which are not used for a long time and also affecting the system performance.
The performance of the system can be improved by taking care of the unused aggregates.

PURPOSE:                                                
There are no standard SAP defined programs which provide the aggregate statistics.
There is a standard query defined under the Technical content ? BW Statistics Multiprovider. But this query provides only the 'Number of Navigations' and 'Last Used (Day)' and 'Last Used (Time of Day)', unlike the ASTAT which provides the entire statistical data pertaining the date of roll-up, date of last change, date of last use of the aggregate. This tool also provides additional information like:
1)    Cube name,
2)    Aggregate name,
3)    User responsible for changing the aggregate last time,
4)    Version of the aggregate,
5)    Average Factor Reduce.
The basic purpose of this tool is to provide interface to the user, based on which, one can enhance the system performance, by identifying the aggregates which are not being used over a period of time.
Also, it displays the date of roll-up, date of last change, date of last use of the aggregate pertaining to the particular infocube, thereby giving a fair idea of the usage of the aggregate

BENEFITS:                                               
1)    This tool gives a quick overview of the statistics pertaining to the aggregate created on the selected cube.
2)    As Rolling up of aggregates increases loading time in backend, therefore, a considerable amount of loading time can be saved, if the unused aggregates are identified.
3)    By identifying unused aggregates, the aggregates can either be remodeled or can be deleted, thereby leading to more appropriate usage of space.

FEATURES:                                               
The following features are available in this tool:
1)    It provides Multiple Cube Selection at the selection screen.
2)    It also provides selection between cube ranges.
3)    If the date for corresponding fields in the statistics is not available, then, the result display is left blank.

 DESCRIPTION:                                           
             
 This program displays the following details
1)    Cube Name,
2)    Aggregate Number,
3)    Last Roll-up date of the Aggregate,
4)    Last changed date for the Aggregate,
5)    User who last changed the Aggregate,
6)    Last Used date for the Aggregate,
7)    Aggregate User Id,
8)    Average Factor Reduce,
9)    Version.

How to create ASTAT in your system?                               

STEP 1: Go to transaction SE38: ABAP Editor
                Select Sub objects: Source Code
                Give the name of program and click on the pushbutton 'Create'

STEP 2:  Copy the source code given
                Click on the icon    to 'Check' the code or press (Ctrl+F2).
                Save the code.
                Click    to 'Activate' the code or press (Ctrl+F3).

REPORT  z_astat_tool_ver2.                    .
TYPE-POOLS: rsd, rsdu, slis, rs.
TABLES: rsddaggrdir, rsddaggrt, rsddstataggr.

DATA: agg_d(19) .
DATA: agg_de(19).
DATA: agg_de1(19).
DATA: agg_de2(19).
DATA: agg_dc(40).
DATA: agg_dt  TYPE sy-datum.
DATA: agg_dt1 TYPE sy-datum.
DATA: agg_dt2 TYPE sy-datum.
DATA: agg_pmdt TYPE sy-datum.
DATA: agg_ic TYPE rsddaggrdir-infocube.
DATA: agg_ac TYPE rsddaggrdir-aggrcube.
DATA: agg_uid TYPE rsddaggrdir-aggruid.
DATA: agg_afr TYPE rsddaggrdir-avgfactreduce.
DATA: agg_ov TYPE rsddaggrdir-objvers.
DATA: agg_noc TYPE rsddaggrdir-calls.
DATA: agg_lu TYPE rsddaggrdir-lastupdateuser.
DATA: l_cname(40) TYPE c.
DATA: l_aname(40) TYPE c.
DATA: c_tstp(19).
DATA: u_tstp(19).
DATA: c_date TYPE sy-datum.
DATA: u_date TYPE sy-datum.
DATA: c_date1 TYPE sy-datum.
DATA: u_date1 TYPE sy-datum.
DATA: agg_rur TYPE rsddstataggr-timeread.
DATA: agg_rui TYPE rsddstataggr-timeinsert.
DATA: agg_rut TYPE rsddstataggr-timeinsert.
DATA: id TYPE sy-uzeit.
DATA: agg_cc(21) TYPE c.
DATA: r_time TYPE rsddstataggr-timeread.
DATA: h_time TYPE rsddstataggr-timeinsert.
DATA: d_time TYPE rsddstataggr-timeread.

DATA: time TYPE rsddstataggr-timeread.
DATA: time1 TYPE rsddstataggr-timeinsert.
DATA: time2 TYPE rsddstataggr-timeinsert.
DATA: intime TYPE rsddstataggr-timeindex.
DATA: dtime TYPE rsddstataggr-timedbanalyze.
DATA: ctime TYPE rsddstataggr-timecondense.
DATA: itime TYPE rsddstataggr-timeinsert.
DATA: rtime TYPE rsddstataggr-timeread.

DATA: ttime1 TYPE rsddstataggr-timeinsert.
DATA: agg_odt(25) TYPE c.
DATA: s_ntime(16) TYPE c.
DATA: stime(25).
DATA: count LIKE sy-tabix.
DATA: agg_d1(27).
DATA: agg_d2(27).
DATA: agg_1 TYPE rsddstataggr-starttime.
DATA: agg_2 TYPE rsddstataggr-starttime.

DATA:     g_repid      LIKE sy-repid,              "Report Name
    x_fieldcat   TYPE slis_fieldcat_alv,
    t_fieldcat   TYPE slis_t_fieldcat_alv.

CONSTANTS: c_version LIKE rsdcube-objvers VALUE 'A',
           c_status  LIKE rsdcube-objstat VALUE 'ACT'.
*----------------------------------------------------------------------
*          TYPE DECLARATION
*----------------------------------------------------------------------

TYPES : BEGIN OF t_agg,
          t_cnm TYPE rsddaggrdir-infocube,
          t_an  TYPE rsddaggrdir-aggrcube,
          t_lld TYPE rsddaggrdir-lastupdate,
          t_lc  TYPE rsddaggrdir-timestmp,
          t_lca TYPE rsddaggrdir-lastcall,
          t_lcb TYPE rsddaggrdir-lastupdateuser,
          t_noc TYPE rsddaggrdir-calls,
          t_or  TYPE rsddaggrdir-aggruid,
          t_rec TYPE rsddaggrdir-avgfactreduce,
          t_ver TYPE rsddaggrdir-objvers,
          t_dc  TYPE rsddaggrt-txtlg,
        END OF t_agg.

TYPES : BEGIN OF t_agg1,
          t_cnm TYPE rsddaggrdir-infocube,
          t_an  TYPE rsddaggrdir-aggrcube,
          t_lld TYPE sy-datum,
          t_lc  TYPE sy-datum,
          t_lca TYPE sy-datum,
          t_lcb TYPE rsddaggrdir-lastupdateuser,
          t_noc TYPE rsddaggrdir-calls,
          t_or  TYPE rsddaggrdir-aggruid,
          t_rec TYPE rsddaggrdir-avgfactreduce,
          t_ver TYPE rsddaggrdir-objvers,
          t_dc  TYPE rsddaggrt-txtlg,
          t_rut TYPE rsddstataggr-timeread,
          t_hacr TYPE rsddstataggr-timeread,
          t_drop TYPE rsddstataggr-timeread,
        END OF t_agg1.

TYPES: BEGIN OF t_lc,
         t_cn  TYPE rsdcube-infocube,
         t_ld  TYPE rsdcubet-txtlg,
       END OF t_lc.

TYPES: BEGIN OF t_tab_dt ,
         v_cname TYPE rsddaggrdir-infocube,
         v_aname TYPE rsddaggrdir-aggrcube,
         v_cdate TYPE rsddaggrdir-timestmp,
         v_udate TYPE rsddaggrdir-lastcall,
       END OF t_tab_dt.

TYPES: BEGIN OF t_tab_ru ,
         v_acube TYPE rsddstataggr-aggrcube,
         v_adate TYPE rsddstataggr-timeread,
         v_pdate TYPE rsddstataggr-timeinsert,
       END OF t_tab_ru.

TYPES: BEGIN OF t_new ,
         v_icube TYPE rsddstataggr-infocube,
         v_acube TYPE rsddstataggr-aggrcube,
         v_cmode TYPE rsddstataggr-changemode,
         v_sdate TYPE rsddstataggr-starttime,
         v_rtime TYPE rsddstataggr-timeread,
         v_itime TYPE rsddstataggr-timeinsert,
         v_intime TYPE rsddstataggr-timeindex,
         v_dtime TYPE rsddstataggr-timedbanalyze,
         v_ctime TYPE rsddstataggr-timecondense,
       END OF t_new.

************************************************************************
*                 INTERNAL TABLES                                      *
************************************************************************
DATA   : it_agg TYPE STANDARD TABLE OF t_agg WITH HEADER LINE.
DATA   : it_agg1 TYPE STANDARD TABLE OF t_agg1 WITH HEADER LINE.
DATA   : it_lc  TYPE STANDARD TABLE OF t_lc.
DATA   : it_dt  TYPE STANDARD TABLE OF rsdatrange WITH HEADER LINE.
DATA   : it_nd  TYPE STANDARD TABLE OF rsintrange WITH HEADER LINE.
DATA   : it_ret LIKE ddshretval OCCURS 0 WITH HEADER LINE.
DATA   : it_tab_dt TYPE STANDARD TABLE OF t_tab_dt WITH HEADER LINE.
DATA   : it_tab_ru TYPE STANDARD TABLE OF t_tab_ru WITH HEADER LINE.
DATA   : it_roll TYPE STANDARD TABLE OF t_new WITH HEADER LINE.
DATA   : it_hacr TYPE STANDARD TABLE OF t_new WITH HEADER LINE.
DATA   : it_drop TYPE STANDARD TABLE OF t_new WITH HEADER LINE.

* internal table used to store infocube values for user selection
DATA: BEGIN OF it_cube OCCURS 0,
        infocube LIKE rsdcube-infocube,
        desc     LIKE rsdcubet-txtlg,
      END OF it_cube,
      t_return LIKE ddshretval OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_cdate OCCURS 10,                      "..............19/6/07
         v_cdate LIKE rsddaggrdir-timestmp,
*         v_ldate LIKE rsddaggrdir-lastcall,
       END OF it_cdate.

*----------------------------------------------------------------------
*          SELECTION SCREEN
*----------------------------------------------------------------------

SELECTION-SCREEN BEGIN OF BLOCK blka WITH FRAME.
SELECT-OPTIONS p_cube FOR rsddaggrdir-infocube NO INTERVALS.
SELECT-OPTIONS p_cdate FOR sy-datum NO INTERVALS.
SELECT-OPTIONS p_udate FOR sy-datum NO INTERVALS.
SELECTION-SCREEN END OF BLOCK blka.

*&---------------------------------------------------------------------*
*            START-OF-SELECTION                                        *
*&---------------------------------------------------------------------*

START-OF-SELECTION.

*******************check when no date is available for change and used******************

  IF p_cdate IS INITIAL AND p_udate IS INITIAL.

*              Select required fields from table RSDDAGGRDIR
    SELECT infocube aggrcube timestmp lastcall
                 FROM rsddaggrdir
                 INTO TABLE it_tab_dt
                 WHERE infocube IN p_cube AND
                       objvers = 'A'.

*              *Filter the data
    LOOP AT it_tab_dt.
      l_cname = it_tab_dt-v_cname.
      l_aname = it_tab_dt-v_aname.
      PERFORM get_data.

    ENDLOOP.
  ELSE.

******************check for change date but not for used date*******************

    IF p_cdate IS NOT INITIAL AND p_udate IS INITIAL.

      SELECT infocube aggrcube timestmp lastcall
                    FROM rsddaggrdir
                    INTO TABLE it_tab_dt
                    WHERE infocube IN p_cube AND
                          objvers = 'A'.

      LOOP AT it_tab_dt.
        c_tstp = it_tab_dt-v_cdate.
        c_date = c_tstp+4(8).
        c_date1 = p_cdate+3(8).
        IF c_date < c_date1.
          l_cname = it_tab_dt-v_cname.
          l_aname = it_tab_dt-v_aname.
          PERFORM get_data.
        ELSE.
        ENDIF.
      ENDLOOP.
    ELSE.

*******************check for used date but not for changed date*****************

      IF p_cdate IS INITIAL AND p_udate IS NOT INITIAL.

        SELECT infocube aggrcube timestmp lastcall
                      FROM rsddaggrdir
                      INTO TABLE it_tab_dt
                      WHERE infocube IN p_cube AND
                            objvers = 'A'.

        LOOP AT it_tab_dt.
          u_tstp = it_tab_dt-v_udate.
          u_date = u_tstp+4(8).
          u_date1 = p_udate+3(8).
          IF u_date < u_date1.
            l_cname = it_tab_dt-v_cname.
            l_aname = it_tab_dt-v_aname.
            PERFORM get_data.
          ELSE.
          ENDIF.
        ENDLOOP.
      ELSE.

*****************check for both changed date n used date********************

        IF p_cdate IS NOT INITIAL AND p_udate IS NOT INITIAL.
          SELECT infocube aggrcube timestmp lastcall
                              FROM rsddaggrdir
                              INTO TABLE it_tab_dt
                              WHERE infocube IN p_cube AND
                                    objvers = 'A'.

          LOOP AT it_tab_dt.
            c_tstp = it_tab_dt-v_cdate.
            u_tstp = it_tab_dt-v_udate.
            c_date = c_tstp+4(8).
            u_date = u_tstp+4(8).
            c_date1 = p_cdate+3(8).
            u_date1 = p_udate+3(8).

            IF c_date < c_date1 AND u_date < u_date1.
              l_cname = it_tab_dt-v_cname.
              l_aname = it_tab_dt-v_aname.

              PERFORM get_data.
            ELSE.
            ENDIF.
          ENDLOOP.

        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.

  PERFORM sub_build_fieldcatalog.
  PERFORM sub_display_alv_report.

*&---------------------------------------------------------------------*
*&      Form  GET_DATA_BASED_ON_DATE                                   *
*& THIS ROUTINE FETCHES THE DATA BASED ON THE SPECIFIED SELECTION      *
*&                                                                     *
*&---------------------------------------------------------------------*
FORM get_data.

  SELECT a~infocube a~aggrcube a~lastupdate a~timestmp
        a~lastcall a~lastupdateuser a~calls a~aggruid
        a~avgfactreduce a~objvers b~txtlg
        INTO TABLE it_agg
        FROM rsddaggrdir AS a INNER JOIN
             rsddaggrt AS b
        ON a~aggruid = b~aggruid AND
           a~objvers = b~objvers
        WHERE
        a~aggrcube = l_aname AND
        a~infocube = l_cname AND
        a~objvers = 'A'      AND
        b~langu   = 'E'.

  LOOP AT it_agg .
    agg_ic = it_agg-t_cnm.
    agg_ac = it_agg-t_an.
    agg_dc = it_agg-t_dc.
    agg_uid = it_agg-t_or.
    agg_lu = it_agg-t_lcb.
    agg_afr = it_agg-t_rec.
    agg_ov = it_agg-t_ver.
    agg_noc = it_agg-t_noc.
    agg_de = it_agg-t_lc.
    agg_de1 = it_agg-t_lld.
    agg_de2 = it_agg-t_lca.
    agg_dt = agg_de+4(8).
    agg_dt1 = agg_de1+4(8).
    agg_dt2 = agg_de2+4(8).

    PERFORM rollup.

    PERFORM hacr.

    PERFORM drop.

    it_agg1-t_cnm = agg_ic.
    it_agg1-t_an = agg_ac.
    it_agg1-t_dc = agg_dc.
    it_agg1-t_rut = r_time.
    it_agg1-t_hacr = h_time.
    it_agg1-t_drop = d_time.
    it_agg1-t_lld = agg_dt1.
    it_agg1-t_lc = agg_dt.
    it_agg1-t_lcb = agg_lu.
    it_agg1-t_noc = agg_noc.
    it_agg1-t_lca = agg_dt2.
    it_agg1-t_or = agg_uid.
    it_agg1-t_rec = agg_afr.
    it_agg1-t_ver = agg_ov.
    APPEND it_agg1.

    CLEAR: agg_ic, agg_ac, agg_dc, agg_uid, agg_lu, agg_afr, agg_ov,
           agg_de, agg_de1, agg_de2, agg_dt, agg_dt1, agg_dt2, r_time, h_time, d_time.

  ENDLOOP.

ENDFORM.                    "get_data_based_on_date
*&--------------------------------------------------------------------*
*&      Form  HACR                                                 *
*&--------------------------------------------------------------------*
*       To get time for HACR                                        *
*---------------------------------------------------------------------*
FORM hacr.

  SELECT infocube aggrcube changemode starttime timeinsert timeread
          timeindex timedbanalyze timecondense
          FROM rsddstataggr
          INTO TABLE it_hacr
          WHERE
          changemode = 'D' AND
          infocube = it_agg-t_cnm AND
          aggrcube = it_agg-t_an. "and

  SORT it_hacr BY v_sdate DESCENDING.
  DATA: wa LIKE LINE OF it_hacr.

  LOOP AT it_hacr INTO wa.
    time1 = wa-v_itime + wa-v_rtime + wa-v_intime + wa-v_dtime + wa-v_ctime.
    h_time = h_time + time1.
    IF sy-tabix = 30.
      count = sy-tabix.
      EXIT.
    ELSE.
      count = sy-tabix.
    ENDIF.
  ENDLOOP.

  IF h_time NE 0 AND sy-tabix NE 0.
    h_time = h_time / sy-tabix.
  ELSE.
    h_time = 0.
  ENDIF.
ENDFORM.                    "HACR
*&--------------------------------------------------------------------*
*&      Form  Rollup                                               *
*&--------------------------------------------------------------------*
*       To get time for Rollup                                        *
*---------------------------------------------------------------------*
FORM rollup.

  SELECT infocube aggrcube changemode starttime timeinsert timeread
          timeindex timedbanalyze timecondense
          FROM rsddstataggr
          INTO TABLE it_roll
          WHERE
          ( changemode = 'R' OR
          changemode = ' ' ) AND
          infocube = it_agg-t_cnm AND
          aggrcube = it_agg-t_an.

  SORT it_roll BY v_sdate DESCENDING.
  DATA: wa LIKE LINE OF it_roll.

  LOOP AT it_roll INTO wa.
    time = wa-v_itime + wa-v_rtime .
    r_time = r_time + time.
    IF sy-tabix = 30.
      count = sy-tabix.
      EXIT.
    ELSE.
      count = sy-tabix.
    ENDIF.

  ENDLOOP.

  IF r_time NE 0 AND count NE 0.
    r_time = r_time / count.
  ELSE.
    r_time = 0.
  ENDIF.

ENDFORM.                    "Rollup
*&--------------------------------------------------------------------*
*&      Form  Drop                                                    *
*&--------------------------------------------------------------------*
*       To get time for Dropping and Creating Aggregates              *
*---------------------------------------------------------------------*
FORM drop.

  SELECT infocube aggrcube changemode starttime timeinsert timeread
          timeindex timedbanalyze timecondense
          FROM rsddstataggr
          INTO TABLE it_drop
          WHERE
          changemode = 'N' AND
          infocube = it_agg-t_cnm AND
          aggrcube = it_agg-t_an. "and

  SORT it_drop BY v_sdate DESCENDING.
  DATA: wa LIKE LINE OF it_drop.
  LOOP AT it_drop INTO wa.
    time2 = wa-v_itime + wa-v_rtime + wa-v_intime + wa-v_dtime + wa-v_ctime.
    d_time = d_time + time2.
    IF sy-tabix = 30.
      count = sy-tabix.
      EXIT.
    ELSE.
      count = sy-tabix.
    ENDIF.
  ENDLOOP.

  IF d_time NE 0 AND count NE 0.
    d_time = d_time / count.
  ELSE.
    d_time = 0.
  ENDIF.

ENDFORM.                    "Drop
*&---------------------------------------------------------------------*
*&      Form user_command                                              *
*&---------------------------------------------------------------------*
FORM user_command  USING r_ucomm LIKE sy-ucomm
                         rs_selfield TYPE slis_selfield.

  DATA: infocube TYPE rsd_infocube.

  IF r_ucomm = '&IC1'.

    CHECK rs_selfield-fieldname = 'T_CNM'.

    infocube = rs_selfield-value.

    CALL FUNCTION 'RSDDK_AGGR_MAINTAIN'
      EXPORTING
        i_infocube          = infocube
        i_objvers           = 'A'
        i_action            = 'S'
      EXCEPTIONS
        user_not_authorized = 1
        no_aggr_possible    = 2
        OTHERS              = 3.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.

  ENDIF.  " Double click

ENDFORM.                    "user_command
*&--------------------------------------------------------------------*
*&      Form  sub_top_of_page                                         *
*&--------------------------------------------------------------------*
FORM sub_top_of_page.

**Declaration of local Variables
  DATA: l_date(10) TYPE c,
        l_time(10) TYPE c.

* Declaration of local Internal Tables
  DATA: lx_slis_listheader   TYPE slis_listheader,
        lt_slis_t_listheader TYPE slis_t_listheader.

* Declaration of local constants
  CONSTANTS:lc_cstat(50)
  TYPE c VALUE 'ASTAT-AGGREGATE STATISTICS TOOL'.

* Write Current date & Time to local variables
  WRITE: sy-uzeit TO l_time,
         sy-datum TO l_date.

  lx_slis_listheader-typ     = 'H'.
  lx_slis_listheader-info    = lc_cstat.
  APPEND lx_slis_listheader TO lt_slis_t_listheader.

  lx_slis_listheader-typ     = 'S'.
  lx_slis_listheader-key     = 'Date:'(015).
  lx_slis_listheader-info    = l_date.
  APPEND lx_slis_listheader TO lt_slis_t_listheader.

  lx_slis_listheader-typ     = 'S'.
  lx_slis_listheader-key     = 'Time:'(016).
  lx_slis_listheader-info    = l_time.
  APPEND lx_slis_listheader TO lt_slis_t_listheader.

* FM to display the TOP-OF-PAGE
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = lt_slis_t_listheader.

ENDFORM.                    "sub_top_of_page
*&---------------------------------------------------------------------*
*&      Form  sub_display_alv_report
*&---------------------------------------------------------------------*
FORM sub_display_alv_report .
  g_repid = sy-repid.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = sy-repid
      i_callback_user_command = 'USER_COMMAND'
      i_callback_top_of_page  = 'SUB_TOP_OF_PAGE' "'sub_top_of_page'
      i_grid_title            = 'Aggregate Statistics'
      it_fieldcat             = t_fieldcat[]
    TABLES
      t_outtab                = it_agg1[]
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

ENDFORM.                    " sub_display_alv_report
*&---------------------------------------------------------------------*
*&      Form  sub_build_fieldcatalog
*&---------------------------------------------------------------------*
FORM sub_build_fieldcatalog .

  x_fieldcat-fieldname  = 'T_CNM'.
  x_fieldcat-seltext_m  = 'Infocube'.
  x_fieldcat-col_pos    = 0.
  x_fieldcat-key        = 'X'.
  x_fieldcat-emphasize  = 'X'.
  x_fieldcat-fix_column = 'X'.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_AN'.
  x_fieldcat-seltext_m  = 'Aggregate Cube Name'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 10.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_DC'.
  x_fieldcat-seltext_m  = 'Description'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 40.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_LLD'.
  x_fieldcat-seltext_m  = 'Last Roll-up'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 26.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_RUT'.
  x_fieldcat-seltext_m  = 'AVG Roll-up Time(s)'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 26.
  x_fieldcat-just       = 'L'.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_HACR'.
  x_fieldcat-seltext_l  = 'AVG Delta HACR Time(s)'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 26.
  x_fieldcat-just       = 'L'.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_DROP'.
  x_fieldcat-seltext_m  = 'AVG Rebuild Time(s)'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 26.
  x_fieldcat-just       = 'L'.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_LC'.
  x_fieldcat-seltext_m  = 'Last Changed On'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 26.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_LCB'.
  x_fieldcat-seltext_m  = 'Last Changed By'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 26.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_LCA'.
  x_fieldcat-seltext_m  = 'Last Used Date'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 26.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_NOC'.
  x_fieldcat-seltext_m  = 'Number Of Calls'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 20.
  x_fieldcat-just       = 'L'.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_OR'.
  x_fieldcat-seltext_m  = 'Aggregate UID'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 30.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_REC'.
  x_fieldcat-seltext_m  = 'Average Factor Reduce'(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 10.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

  x_fieldcat-fieldname  = 'T_VER'.
  x_fieldcat-seltext_m  = 'Version '(002).
  x_fieldcat-col_pos    = 1.
  x_fieldcat-outputlen  = 10.
  x_fieldcat-just       = 'L'.
  APPEND x_fieldcat TO t_fieldcat.
  CLEAR x_fieldcat.

ENDFORM.                    " sub_build_fieldcatalog
 

Scenario.
Create and Populate User Exit Variable with default date as current date.

Step1.
Create a variable(ex: cur_date) on required characteristic with Processing type "Customer Exit" and check the check box for ready for input(if this variable need in selection screen).

Step 2.
Goto T Code : CMOD and provide appropriate Project and choose components and click on display.

Step3.
Double click on exit "EXIT_SAPLRRS0_001" you can see include "ZXRSRU01", double click on include.

Step4.
Sample code to populate.

WHEN 'CUR_DATE'.
Data : l_p_range_SSS TYPE rrrangesid.
IF I_STEP = 1.
l_p_range_SSS-Low = sy-datum.
l_p_range_SSS-Sign = 'I'.
l_p_range_SSS-Opt = 'EQ'.
APPEND l_p_range_SSS TO e_t_range.
Endif.

The following values are valid for I_STEP:
I_STEP = 1
Call up takes place directly before variable entry·
I_STEP = 2
Call up takes place directly after variable entry. This step is only started up when the same variable could not be filled at I_STEP=1.·
I_STEP = 3
In this call up, you can check the values of the variables. Triggering an exception (RAISE) causes the variable screen to appear once more. Afterwards, I_STEP=2 is also called up again.·
I_STEP = 0The enhancement is not called from the variable screen. The call up can come from the authorization check or from the Monitor.

Author: Marc Bernard, SAP Techology RIG
Submitted: 2010-07-26

Description:
This snippet gives three examples on how to use the API for reading BW master data and attributes.

Related Links:
SAP NetWeaver Developer's Guide for BIM Scenarios:
https://www.sdn.sap.com/irj/sdn/devguide2004s
> IT-Scenario-Driven Enhancements to Applications
> Enterprise Data Warehousing

Data Definitions
  DATA:
    l_chavl        TYPE rsd_chavl,
    i_co_area      TYPE /bi0/oico_area,
    i_costcenter   TYPE /bi0/oicostcenter,
    e_obj_curr     TYPE /bi0/oiobj_curr,
    es_wbs_elemt   TYPE /bi0/mwbs_elemt,
    et_country     TYPE TABLE OF /bi0/mcountry.
EXAMPLE 1: Read one attribute
* Look-up object currency attribute value on cost center 
  CONCATENATE i_co_area i_costcenter INTO l_chavl.
  
  CALL FUNCTION 'RSAU_READ_MASTER_DATA'
    EXPORTING
      i_iobjnm                = '0COSTCENTER'
      i_chavl                 = l_chavl
      i_attrnm                = '0OBJ_CURR'
    IMPORTING
      e_attrval               = e_obj_curr
    EXCEPTIONS
      read_error              = 1
      no_such_attribute       = 2
      wrong_import_parameters = 3
      chavl_not_found         = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
EXAMPLE 2: Read all attributes
* Lookup various attributes on wbs element
  l_chavl = i_wbs_elemt.

  CALL FUNCTION 'RSAU_READ_MASTER_DATA'
    EXPORTING
      i_iobjnm                = '0WBS_ELEMT'
      i_chavl                 = l_chavl
    IMPORTING
      e_structure             = es_wbs_elemt
    EXCEPTIONS
      read_error              = 1
      no_such_attribute       = 2
      wrong_import_parameters = 3
      chavl_not_found         = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
EXAMPLE 3: Read all characteristic values
* Look-up all countries
  CALL FUNCTION 'RSAU_READ_MASTER_DATA'
    EXPORTING
      i_iobjnm                = '0COUNTRY'
      i_flg_whole_table       = 'X'
    IMPORTING
      e_table                 = et_country
    EXCEPTIONS
      read_error              = 1
      no_such_attribute       = 2
      wrong_import_parameters = 3
      chavl_not_found         = 4
      OTHERS                  = 5.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.

A simple function which reads BW query result and transforms it to JSON, which can be later on exposed for usage in SAP UI5 application.

Author: Charles de Jager
Submitted: 08 May 2007

Code snippet to be added to update rules start routine.  The code will search all rows on the field txtlg (Long Text) and remove any line feeds, tabs and control breaks and replace these with a space.

  FIELD-SYMBOLS:
    <tb> type x,
    <tc> type c.

  DATA:
  tab(6) type x value '09200D200A20',
  it_datapak TYPE STANDARD TABLE OF transfer_structure WITH HEADER LINE,
    wa_datapak TYPE transfer_structure.


  assign tab to <tb> casting.
  assign <tb> to <tc> casting.

  LOOP AT datapak INTO wa_datapak.
    MOVE-CORRESPONDING wa_datapak TO it_datapak.

    if it_datapak-txtlg CA cl_abap_char_utilities=>cr_lf.
      translate it_datapak-txtlg using <tc>.
    endif.

    APPEND it_datapak.
  ENDLOOP.

  REFRESH datapak.
  CLEAR datapak.

  datapak[] = it_datapak[].

Author: Prinan Pandit
Submitted: 11.12.2008
Related Links:

  • <link>

<SAMPLE CODE TO COPY BW-HIERARCHY DATA AND DOWNLOAD IT TO APPLICATION SERVER IN .CSV FORMAT>

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
report  ztest_0country_hier message-id zmsg_test.

*     TYPE DECLARATION

*TYPE DECLARATION FOR TABLE /BIO/PCOUNTRY

types:
       begin of t_/bi0/pcountry,
         country type /bi0/oicountry,
         continen type /bic/oizcontinen,
         region type /bic/oizregion,
       end of t_/bi0/pcountry,

*TYPE DECLARATION FOR FINAL OUTPUT ".CSV" FORMAT
       begin of t_final_1,
         string type string,
       end of t_final_1,

*TYPE DECLARATION FOR THE FINAL OUTPUT TABLE
       begin of t_final,
         node_id(8) type n,
         info_object type char30,
         node_name type char32,
         link type char1,
         parent_id(8) type n,
         language type char1,
         short_text type char20,
       end of t_final,

*TYPE DECLARATION FOR THE TABLE /BIO/TCOUNTY
       begin of t_/bi0/tcountry,
         country type /bi0/tcountry-country,
         text type /bi0/tcountry-txtsh,
       end of t_/bi0/tcountry,

*TYPE DECLARATION FOR THE TABLE /BIC/TZREGION
       begin of t_/bic/tzregion,
         region type /bic/tzregion-/bic/zregion,
         text1 type /bic/tzregion-txtsh,
       end of t_/bic/tzregion,

*TYPE DECLARATION FOR THE TABLE /BIC/TZCONTINEN

       begin of t_/bic/tzcontinen,
         continent type /bic/tzcontinen-/bic/zcontinen,
         text2 type /bic/tzcontinen-txtsh,
       end of t_/bic/tzcontinen.

*      DATA DECLARATION

data:
************** INTERNAL TABLES ***********************
     i_/bi0/pcountry type standard table of t_/bi0/pcountry,
     i_/bi0/pcountry1 type standard table of t_/bi0/pcountry,
     i_/bi0/pcountry2 type standard table of t_/bi0/pcountry,
     i_final type standard table of t_final,
     i_temp type standard table of t_final,
     i_/bi0/tcountry type standard table of t_/bi0/tcountry,
     i_/bic/tzregion type standard table of t_/bic/tzregion,
     i_/bic/tzcontinen type standard table of t_/bic/tzcontinen,
     i_final_1 type standard table of t_final_1,

******************* WORK AREAS *************
     wa_/bi0/pcountry type t_/bi0/pcountry,
     wa_final type t_final,
     wa_final1 type t_final,
     wa_/bi0/tcountry type t_/bi0/tcountry,
     wa_/bic/tzregion type t_/bic/tzregion,
     wa_/bic/tzcontinen type t_/bic/tzcontinen,
     wa1 type t_final_1,

********************** VARIABLES *******************
     v_n_id(3) type n value '0',
     v_region type /bic/oizregion,
     v_continen type /bic/oizcontinen.

************************** CONSTANTS *************************
constants: c_file1 type string value '
filepath_in the_application server\name1.CSV',
                  c_file2 type string value '
filepath_in the_application server\name2.CSV',
                  c_file3 type string value '
filepath_in the_application server\name3.CSV'.

*&---------------------------------------------------------------------*
*&      START-OF-SELECTION.
*&---------------------------------------------------------------------*
start-of-selection.

  perform header_title.

  perform fixed_entry.

  perform select_data_itab.

  perform select_data_complete.

  perform download_result.

*----------------------------------------------------------------------*
*  -->  DOWNLOAD RESULT TO RESPECTIVE SERVER LOCATOIN
*  <--
*----------------------------------------------------------------------*
form download_result .

  perform download_data using c_file1.
  perform download_data using c_file2.
  perform download_data using c_file3.

endform.                    " DOWNLOAD_RESULT
*&---------------------------------------------------------------------*
*&      Form  header_title
*&---------------------------------------------------------------------*
*       PUTTING THE FIELD TITLES OF THE FINAL OUTPUT TABLE
*----------------------------------------------------------------------*
form header_title.

  concatenate  'NODE ID'
  'INFO OBJECT'
  'NODE NAME'
  'LINK'
  'PARENT ID'
  'LANGUAGE'
  'SHORT TEXT'
  into wa1-string separated by ';'.
  append wa1 to i_final_1.

endform.                    "header_title
*&---------------------------------------------------------------------*
*&      Form  fixed_entry
*&---------------------------------------------------------------------*
*       FILLING UP THE FIRST ROW OF FINAL OUTPUT TABLE WITH FIXED VALUES
*----------------------------------------------------------------------*
form fixed_entry.

  wa_final-node_id = text-002.
  wa_final-info_object = text-003.
  wa_final-node_name = text-004.
  wa_final-language = text-005.
  wa_final-short_text = text-001.
  append wa_final to i_final.
  clear wa_final.

endform.                    "fixed_entry
*&---------------------------------------------------------------------*
*&      Form  SELECT_DATA_ITAB
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  FILLING UP ALL THE RECORDS IN FINAL TABLE EXCEPT THE PARENT ID FIELD
*
*----------------------------------------------------------------------*
form select_data_itab .

*SEELCT DATA FROM /bi0/pcountry TABLE TO CORRESPONDING INTERNAL TABLE
  select
    country
    /bic/zcontinen
    /bic/zregion
    from  /bi0/pcountry
    into table i_/bi0/pcountry
    where objvers = 'A'.
  if sy-subrc <> 0.
    message e000.
  endif.

*SEELCT DATA FROM /bic/tzregion TABLE TO CORRESPONDING INTERNAL TABLE
  select
    /bic/zregion
    txtsh
    from /bic/tzregion
    into table i_/bic/tzregion.
  if sy-subrc <> 0.
    message e001.
  endif.

*SEELCT DATA FROM /bic/tzcontinen TABLE TO CORRESPONDING INTERNAL TABLE
  select
    /bic/zcontinen
    txtsh
    from
    /bic/tzcontinen
    into table i_/bic/tzcontinen.
  if sy-subrc <> 0.
    message e002.
  endif.

*SEELCT DATA FROM /bi0/tcountry TABLE TO CORRESPONDING INTERNAL TABLE
  select
      country
      txtsh
      from /bi0/tcountry
      into table i_/bi0/tcountry.
  if sy-subrc <> 0.
    message e003.
  endif.

*FILLING UP ALL THE RECORDS IN FINAL TABLE WHERE INFO OBJECT IS "0COUNTRY" EXCEPT THE PARENT ID FIELD
  sort i_/bi0/tcountry by country.
  sort i_/bic/tzregion by region.
  sort i_/bic/tzcontinen by continent.

  v_n_id = v_n_id + 1.   "INCREASING THE VARIABLE TO KEEP TRACK WITH THE NODE ID

  loop at i_/bi0/pcountry into wa_/bi0/pcountry.
    v_n_id = v_n_id + 1.

    wa_final-node_id = v_n_id.
    wa_final-info_object = '0COUNTRY'.
    wa_final-node_name = wa_/bi0/pcountry-country.
    wa_final-language = 'E'.
    read table i_/bi0/tcountry into wa_/bi0/tcountry with key country = wa_/bi0/pcountry-country binary search.
    if sy-subrc = 0.
      wa_final-short_text = wa_/bi0/tcountry-text.
      append wa_final to i_final.
      clear wa_final.
    endif.
  endloop.

**FILLING UP ALL THE RECORDS IN FINAL TABLE WHERE INFO OBJECT IS "ZREGION" EXCEPT THE PARENT ID FIELD
  v_n_id = 700.

  sort i_/bi0/pcountry by region.
  loop at i_/bi0/pcountry into wa_/bi0/pcountry.
    if v_region ne wa_/bi0/pcountry-region.
      v_n_id = v_n_id + 1.

      wa_final-node_id = v_n_id.
      wa_final-info_object = 'ZREGION'.
      wa_final-node_name = wa_/bi0/pcountry-region.
      wa_final-language = 'E'.
      v_region = wa_/bi0/pcountry-region.
      read table i_/bic/tzregion into wa_/bic/tzregion with key region = wa_/bi0/pcountry-region binary search.
      if sy-subrc eq 0.
        wa_final-short_text = wa_/bic/tzregion-text1.
        append wa_final to i_final.
        clear wa_final.
      endif.
      clear wa_/bi0/pcountry.
    endif.
  endloop.

**FILLING UP ALL THE RECORDS IN FINAL TABLE WHERE INFO OBJECT IS "ZCONTINEN" EXCEPT THE PARENT ID FIELD
  v_n_id = 800.

  sort i_/bi0/pcountry by continen.
  loop at i_/bi0/pcountry into wa_/bi0/pcountry.
    if v_continen ne wa_/bi0/pcountry-continen.
      v_n_id = v_n_id + 1.

      wa_final-node_id = v_n_id.
      wa_final-info_object = 'ZCONTINEN'.
      wa_final-node_name = wa_/bi0/pcountry-continen.
      wa_final-language = 'E'.
      v_continen = wa_/bi0/pcountry-continen.
      read table i_/bic/tzcontinen into wa_/bic/tzcontinen with key continent = wa_/bi0/pcountry-continen binary search.
      if sy-subrc eq 0.
        wa_final-short_text = wa_/bic/tzcontinen-text2.
        append wa_final to i_final.
        clear wa_final.
      endif.
      clear wa_/bi0/pcountry.
    endif.
  endloop.

endform.                    " SELECT_DATA_ITAB

*----------------------------------------------------------------------*
*  -->  SELECT DATA
*
*----------------------------------------------------------------------*
form select_data_complete .

  move i_final to i_temp.
  sort i_temp by node_name.
  move i_/bi0/pcountry to i_/bi0/pcountry1.
  move i_/bi0/pcountry to i_/bi0/pcountry2.
  sort i_/bi0/pcountry by country.
  sort i_/bi0/pcountry1 by region.
  sort i_/bi0/pcountry2 by continen.

*FILLING UP THE FINAL OUTPUT INTERNAL TABLE WITH PARENT ID FIELD DATA
  loop at i_final into wa_final.

*************************************************************************************
*FETCHING PARENT ID DATA WHERE INFO OBJECT IS "0COUNTRY"
*************************************************************************************
    if wa_final-info_object = '0COUNTRY' .

      read table i_/bi0/pcountry into wa_/bi0/pcountry with key country = wa_final-node_name binary search.
      if sy-subrc eq 0.
        read table i_temp into wa_final1 with key node_name = wa_/bi0/pcountry-region binary search.
        if sy-subrc eq 0.
          if wa_final1-node_id lt 800.
            move wa_final1-node_id to wa_final-parent_id.
            clear wa_final1-node_id.
          endif.
        endif.
      endif.
    endif.
*************************************************************************************
**FETCHING PARENT ID DATA WHERE INFO OBJECT IS "ZREGION"
*************************************************************************************
    if wa_final-info_object = 'ZREGION' .

      read table i_/bi0/pcountry1 into wa_/bi0/pcountry with key region = wa_final-node_name binary search.
      if sy-subrc eq 0.
        read table i_temp into wa_final1 with key node_name = wa_/bi0/pcountry-continen binary search.
        if sy-subrc eq 0.
          if wa_final1-node_id gt 800.
            move wa_final1-node_id to wa_final-parent_id.
            clear wa_final1-node_id.
          endif.
        endif.
      endif.
    endif.

*************************************************************************************
**FETCHING PARENT ID DATA WHERE INFO OBJECT IS "ZCONTINEN"
*************************************************************************************
    if wa_final-info_object = 'ZCONTINEN'.
      move '1' to wa_final-parent_id.
    endif.

*************************************************************************************
**FETCHING DEFAULT VALUES AS PARENT ID WHEN NO DATA FOR"ZREGION" OR "ZCONTINEN"
*************************************************************************************
    if wa_final-node_id is initial.
      move '000000' to wa_final-parent_id.
    endif.

*************************************************************************************
*REMOVING THE ZEROES IN THE RESPECTIVE FIELDS
*************************************************************************************
    perform remove_zeroes changing wa_final-node_id.
    perform remove_zeroes changing wa_final-parent_id.

*************************************************************************************
*FINAL OUTPUT FORMAT GETTING STORED
*************************************************************************************
    concatenate  wa_final-node_id
     wa_final-info_object
     wa_final-node_name
     wa_final-link
     wa_final-parent_id
     wa_final-language
     wa_final-short_text
    into wa1-string separated by ';'.

    append wa1 to i_final_1.
    clear:wa_/bi0/pcountry.

  endloop.
  free i_temp.
endform.                    " SELECT_DATA_COMPLETE

*----------------------------------------------------------------------*
*  -->  REMOVE UNNECESSARY ZEROES OF THE RESPECTIVE FIELDS
*
*----------------------------------------------------------------------*
form remove_zeroes changing p_rmv_zero type num8.

  call function 'CONVERSION_EXIT_ALPHA_OUTPUT'
    exporting
      input  = p_rmv_zero
    importing
      output = p_rmv_zero.

endform.                    " REMOVE_ZEROES

*----------------------------------------------------------------------*
*  -->  DOWNLOAD FINAL OUTPUT TO APPLICATION SERVER
*
*----------------------------------------------------------------------*
form download_data using lv_string type string.

  open dataset lv_string for output in text mode encoding default .
  if sy-subrc ne 0.
    exit.
  endif.
  delete dataset lv_string.
  close dataset lv_string.

  open dataset lv_string for output in text mode encoding default .
  if sy-subrc ne 0.
    exit.
  endif.
  loop at i_final_1 into wa1.
    transfer wa1-string to  lv_string .
  endloop.
  close dataset lv_string.

endform.                    " DOWNLOAD_DATA

SAP BI Performance Activity - Cube Compression

Compression:

Compression transfers the data from the F fact table to the E fact table while eliminating the request information in the InfoCube. It aggregates records with equal keys from different requests.

Refer Fig 1.

Advantages:

For DBMS supporting range partitioning, the E fact table is optimized for reporting with respect to database partitioning and the F fact table is optimized for data load and deletion. Customized partition settings (0CALMONTH or 0FISCPER) are only valid in the compressed E-table. Compression prevents the F-table (which is partitioned by request ID) from containing too many partitions. The DB-internal administration of some thousands (as a rule of thumb) partitions decreases the overall performance for an InfoCube.
The reference point of non-cumulative key figures is updated when the InfoCube is compressed. This reduces the OLAP time of queries on these InfoCubes. Compressing improves query performance of InfoCubes containing non-cumulative key figures significantly.

Disadvantages:

Compression only aids in query performance. It adds another step to the overall data load process and takes up resources.
Individual requests cannot be accessed and deleted any more after compressing. If you delete requests that have been rolled up and compressed in the aggregates, these aggregates have to be dropped and rebuilt completely. This can take a long time depending on the size of the aggregate and associated fact table.

Note:

SAP recommends compressing those requests in the InfoCube that are not likely to be deleted as soon as possible. Also compress aggregates as soon as possible. The InfoCube content is likely to be reduced in size, so DB-time for queries should improve.

How to check in system?

 1. Run the Program SAP_INFOCUBE_DESIGNS

Refer Fig 2.

 
 2. You can see details of all cubes in system as below

Refer Fig 3.

 
 3. Export the details to Excel

Refer Fig 4 & 5.



 
 4. Realign the details in Excel as shown below.

Refer Fig 6.

 
 5. Filter on /BI0/F (for Business Content Cubes) and /BIC/F (for Custom Cubes), realign fields to get the below details.

Refer Fig 7.

 
 6. Compress all the cubes which are not compressed.

If F table % = 100, Cube never compressed.

If F table % = 0, Cube is Completely compressed.

If F table % >0 & <100, Cube is partially compressed.

To schedule infopackage loads in Business Warehouse Monday to Friday we need Factory Calender and what if we need to schedule the loads in some random fashion.... I have written a code below to enable a BW consultant schedule loads in any random fashion.. Like:eg.1: Three days a week (Monday, Wednesday n Saturday)eg.2: Four days a week (Sun, Tue, Thus, Sat)eg.3: Two days a week (Mon, Thus).......etc any random combination for scheduling.
We can create a job with the code below with different variants and schedule this job to run daily.

Infopackage scheduling will be done After Event and this event will be raised by above daily running job appropriatel as reqiured.

In variants we have to define the sequence or pattern in which we want the loads to happen, event to be raised and destination server for the event.

REPORT zprogram.
DATA: v_date LIKE scal-date,
      v_cdate(10) TYPE c,
      v_tdate LIKE sy-datum,
      v_day LIKE scal-indicator.
*************************************************************************
**********different values V_DAY **************************************
**********Monday-1, Tuesday-2, Wednesday-3, Thursday-4,****************
********* Friday-5, Saturday-6, Sunday-7 ****************************
*************************************************************************
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK b11 WITH FRAME TITLE text-001.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS s_days FOR v_day OBLIGATORY.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN SKIP.
PARAMETERS: p_tdest LIKE rfcdisplay-rfcdest,
            p_tevent LIKE btcuev-eventid.
*****************************************************************************
*****Select Option *s_days is for entering the days of week when you want this program to raise event
*****Parameter *p_tdest is for Destination Server, where event is required to be raised
*****Parameter *p_tevent is for entering the name of event
*****************************************************************************
SELECTION-SCREEN END OF BLOCK b11.
v_tdate = sy-datum.
v_date = v_tdate.
**************************************************************
CALL FUNCTION 'DATE_COMPUTE_DAY'
  EXPORTING
    date = v_date
  IMPORTING
    day  = v_day.
**************************************************************
WRITE: / v_day.
IF v_day IN s_days.
  WRITE:/ 'Data Load is going to Start'.
  SUBMIT zprogram_raise_event WITH p_dest EQ p_tdest
**************************************************************
*****ZProgram_raise_event will use a function module BP_EVENT_RAISE
*****Refer the link below to write ABAP code for raising event
*****https://www.sdn.sap.com/irj/sdn/thread?threadID=861972
**************************************************************
  WITH p_event EQ p_tevent.
ELSE.
  WRITE:/ 'Data Load is not going to Start'.
ENDIF.
 
*Selection Screen**
SELECTION-SCREEN BEGIN OF BLOCK 001 WITH FRAME TITLE text-001.
PARAMETERS: infocube(30) TYPE c OBLIGATORY,
            dtp TYPE string OBLIGATORY.
SELECTION-SCREEN END OF BLOCK 001.
TYPES t_rsicount LIKE rsiccont.
DATA: i_rsicount TYPE STANDARD TABLE OF t_rsicount,
      wa_rsicount LIKE LINE OF i_rsicount,
      req TYPE rsiccont-rnr,
        cnt TYPE i.
TYPES: BEGIN OF tab,
       request TYPE rsiccont-rnr,
       END OF tab.
DATA: i_tab TYPE STANDARD TABLE OF tab,
      wa_tab LIKE LINE OF i_tab.
*****All requests for the Cube into internal Table.****
SELECT *
  FROM rsiccont
  INTO TABLE i_rsicount
  WHERE icube = infocube
  ORDER BY timestamp DESCENDING.
*****Filter on all the request as per the DTP on the selection screen.******
LOOP AT i_rsicount INTO wa_rsicount.
  SELECT rnr INTO wa_tab
    FROM rsreqdone
    WHERE rnr = wa_rsicount-rnr AND
          logdpid = dtp.
  ENDSELECT.
  IF sy-subrc EQ 0.
    wa_tab-request = wa_rsicount-rnr.
    APPEND wa_tab-request TO i_tab.
  ENDIF.
ENDLOOP.
DESCRIBE TABLE i_tab LINES cnt.
IF cnt > 1.
  CLEAR wa_tab.
*****Request Deletion leaving latest request.******
  LOOP AT i_tab INTO wa_tab.
    IF sy-tabix NE 1.
      IF sy-subrc = 0.
        req = wa_tab-request.
        CALL FUNCTION 'RSSM_DELETE_REQUEST'
          EXPORTING
            request                    = req
            infocube                   = infocube
          EXCEPTIONS
            request_not_in_cube        = 1
            infocube_not_found         = 2
            request_already_aggregated = 3
            request_already_comdensed  = 4
            no_enqueue_possible        = 5
            cube_in_planning_mode      = 6.
*****Reading the exceptions from the function module.************
        CASE sy-subrc .
          WHEN 0.
            MESSAGE s051(rsar) WITH 'Successfully Done'.
          WHEN 1.
            MESSAGE e051(rsar) WITH 'REQUEST_NOT_IN_CUBE'.
            EXIT.
          WHEN 2.
            MESSAGE e051(rsar) WITH 'INFOCUBE_NOT_FOUND'.
            EXIT.
          WHEN 3.
            MESSAGE e051(rsar) WITH 'REQUEST_ALREADY_AGGREGATED'.
            EXIT.
          WHEN 4.
            MESSAGE e051(rsar) WITH 'REQUEST_ALREADY_COMDENSED'.
            EXIT.
          WHEN 5.
            MESSAGE e051(rsar) WITH 'NO_ENQUEUE_POSSIBLE'.
            EXIT.
          WHEN 6.
            MESSAGE e051(rsar) WITH 'CUBE_IN_PLANNING_MODE'.
            EXIT.
        ENDCASE.
      ENDIF.
    ENDIF.
  ENDLOOP.
ELSE.
  MESSAGE s051(rsar) WITH 'No Request Available for Deletion'.
ENDIF.
 

Author: P. Saravana Kumar
Submitted: 18 Apr 2009

Data Flow :  : ZO02 DSO -> ZC01 Info Cube

Description : There is will be requirement that sometimes we need to keep unique records in Info cube. This sample code enables to achieve that by using Selective Deletion.

 
 
PROGRAM trans_routine.
 
 
*---------------------------------------------------------------------*
*       CLASS routine DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform DEFINITION.
  PUBLIC SECTION.
 
*  Attributs
    DATA:
      p_check_master_data_exist
            TYPE RSODSOCHECKONLY READ-ONLY,
*-    Instance for getting request runtime attributs;
*     Available information: Refer to methods of
*     interface 'if_rsbk_request_admintab_view'
      p_r_request
            TYPE REF TO if_rsbk_request_admintab_view READ-ONLY.
 
  PRIVATE SECTION.
 
    TYPE-POOLS: rsd, rstr.
 
*   Rule specific types
    TYPES:
      BEGIN OF _ty_s_SC_1,
*      InfoObject: 0CRM_OBJ_ID Transaction Number.
        CRM_OBJ_ID           TYPE /BI0/OICRM_OBJ_ID,
*      InfoObject: 0CRM_NUMINT Item Number in Document.
        CRM_NUMINT           TYPE /BI0/OICRM_NUMINT,
*      InfoObject: 0BPARTNER Business Partner.
        BPARTNER           TYPE /BI0/OIBPARTNER,
*      InfoObject: 0MATERIAL Material.
        MATERIAL           TYPE /BI0/OIMATERIAL,
*      InfoObject: ZORDER_DT Order Date.
        /BIC/ZORDER_DT           TYPE /BIC/OIZORDER_DT,
*      InfoObject: ZREDEM_DT Redeemed Date.
        /BIC/ZREDEM_DT           TYPE /BIC/OIZREDEM_DT,
*      InfoObject: ZEXPRY_DT Expiry Date.
        /BIC/ZEXPRY_DT           TYPE /BIC/OIZEXPRY_DT,
*      InfoObject: ZCANCELDT Cancel Date.
        /BIC/ZCANCELDT           TYPE /BIC/OIZCANCELDT,
*      InfoObject: ZREFER_IO Reference IO Number.
        /BIC/ZREFER_IO           TYPE /BIC/OIZREFER_IO,
*      InfoObject: ZPER_COMP Percentage Completion.
        /BIC/ZPER_COMP           TYPE /BIC/OIZPER_COMP,
*      InfoObject: 0RECORDMODE BW Delta Process: Update Mode.
        RECORDMODE           TYPE RODMUPDMOD,
*      Field: RECORD.
        RECORD           TYPE RSARECORD,
      END   OF _ty_s_SC_1.
    TYPES:
      _ty_t_SC_1        TYPE STANDARD TABLE OF _ty_s_SC_1
                        WITH NON-UNIQUE DEFAULT KEY.
 
*$*$ begin of global - insert your declaration only below this line  *-*
    ... "insert your code here
*$*$ end of global - insert your declaration only before this line   *-*
    METHODS
      start_routine
        IMPORTING
          request                  type rsrequest
          datapackid               type rsdatapid
        EXPORTING
          monitor                  type rstr_ty_t_monitors
        CHANGING
          SOURCE_PACKAGE              type _ty_t_SC_1
        RAISING
          cx_rsrout_abort.
    METHODS
      inverse_start_routine
        IMPORTING
          i_th_fields_outbound         TYPE rstran_t_field_inv
          i_r_selset_outbound          TYPE REF TO cl_rsmds_set
          i_is_main_selection          TYPE rs_bool
          i_r_selset_outbound_complete TYPE REF TO cl_rsmds_set
          i_r_universe_inbound         TYPE REF TO cl_rsmds_universe
        CHANGING
          c_th_fields_inbound          TYPE rstran_t_field_inv
          c_r_selset_inbound           TYPE REF TO cl_rsmds_set
          c_exact                      TYPE rs_bool.
ENDCLASS.                    "routine DEFINITION
 
*$*$ begin of 2nd part global - insert your code only below this line  *
... "insert your code here
*$*$ end of 2nd part global - insert your code only before this line   *
 
*---------------------------------------------------------------------*
*       CLASS routine IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_transform IMPLEMENTATION.
 
*----------------------------------------------------------------------*
*       Method start_routine
*----------------------------------------------------------------------*
*       Calculation of source package via start routine
*----------------------------------------------------------------------*
*   <-> source package
*----------------------------------------------------------------------*
  METHOD start_routine.
*=== Segments ===
 
    FIELD-SYMBOLS:
      <SOURCE_FIELDS>    TYPE _ty_s_SC_1.
 
    DATA:
      MONITOR_REC     TYPE rstmonitor.
 
*$*$ begin of routine - insert your code only below this line        *-*
    ... "insert your code here
 
**********************************************************************
 
* Type Pools
 
    TYPE-POOLS: rsdrd, rsdq, rssg.
 
* Local Internal Tables
 
    DATA: lit_msg     TYPE rs_t_msg,
          lit_sel      TYPE rsdrd_thx_sel.
 
    DATA : lit_sp         TYPE TABLE OF _ty_s_sc_1,
           lit_delete      TYPE TABLE OF _ty_s_sc_1.
 
* Local Work Area
 
    DATA : lwa_sel_kf1     TYPE rsdrd_sx_sel,
           lwa_range_kf1   TYPE rsdrd_s_range,
           lwa_sel_kf2     TYPE rsdrd_sx_sel,
           lwa_range_kf2   TYPE rsdrd_s_range,
           lwa_sp        TYPE _ty_s_sc_1,
           lwa_prod_config  TYPE /bic/az0100.
 
* Local Variable
 
    DATA : lv_count TYPE i.
 
* Local Constants
 
    CONSTANTS : lc_1         TYPE i  VALUE  1,
                lc_c(1)      TYPE c  VALUE 'C',
                lc_d(1)      TYPE c  VALUE 'D',
                lc_i(1)      TYPE c  VALUE 'I',
                lc_x(1)      TYPE c  VALUE 'X',
                lc_max(2)    TYPE c  VALUE '75',
                lc_eq(2)     TYPE c  VALUE 'EQ',
                lc_kf1(11)   TYPE c  VALUE '0BPARTNER'.
 
    CONSTANTS : lc_cube      TYPE rsddatatarget VALUE 'ZC01'.
 
**********************************************************************
 
* Delete Existing cube records
 
    REFRESH : lit_sp[].
 
    lit_sp[] =  SOURCE_PACKAGE[].
 
    SORT lit_sp BY bpartner.
 
* Assuming that we need to keep the unique records based on BPARTNER.
 
    DELETE ADJACENT DUPLICATES FROM lit_sp
           COMPARING bpartner.
 
    LOOP AT lit_sp INTO lwa_sp.
 
* Key Field 1 (Business Partner Number). Currently for bulk process, SAP Suggest that we should not give more than one field in selection,
* Otherwise,  unexpected result or data loss may happen.
* If you want the combination of fields to be deleted, then please pass, one record at a time to function module.
 
      lwa_range_kf1-sign    = lc_i.
      lwa_range_kf1-option   = lc_eq.
      lwa_range_kf1-high    = space.
      lwa_range_kf1-keyfl    = lc_x.
      lwa_range_kf1-low     = lwa_sp-bpartner.
 
      APPEND lwa_range_kf1 TO lwa_sel_kf1-t_range.
      CLEAR  lwa_range_kf1.
 
      lv_count = lv_count + lc_1.
 
* WARNING : RECORDS SHOULD NOT BE EXCEEDED !!!
* If more than 75 records, Selection String in Database will throw short Dump.
 
      IF lv_count <= lc_max.
 
        CONTINUE.
 
      ENDIF.
 
      lwa_sel_kf1-iobjnm = lc_kf1.
 
      INSERT lwa_sel_kf1 INTO TABLE lit_sel.
 
      CLEAR : lwa_sel_kf1,
              lv_count.
 
* Selective Deletion through FM
 
      CALL FUNCTION 'RSDRD_SEL_DELETION'
        EXPORTING
          i_datatarget       = lc_cube " Cube Name
          i_thx_sel         = lit_sel  " 75 BPARTNER Records
          i_authority_check   = space  " Not validating the Authority Check
          i_mode          = lc_c   " If found, delete the record
          i_no_enqueue     = lc_x   " No Lock
        CHANGING
          c_t_msg           = lit_msg " System Messages
        EXCEPTIONS
          x_message         = 1
          inherited_error       = 2
          invalid_type         = 3
          OTHERS           = 4.
 
      IF sy-subrc = 0.
 
        REFRESH : lit_sel[],
                  lit_msg[].
 
      ENDIF.
 
    ENDLOOP.
 
* Deletion for Remaining Records
 
    IF lv_count >= lc_1.
 
      lwa_sel_kf1-iobjnm = lc_kf1.
 
      INSERT lwa_sel_kf1 INTO TABLE lit_sel.
 
      CLEAR : lwa_sel_kf1,
              lv_count.
 
     CALL FUNCTION 'RSDRD_SEL_DELETION'
        EXPORTING
          i_datatarget       = lc_cube " Cube Name
          i_thx_sel         = lit_sel  " <75 BPARTNER Records
          i_authority_check   = space  " Not validating the Authority Check
          i_mode          = lc_c   " If found, delete the record
          i_no_enqueue     = lc_x   " No Lock
        CHANGING
          c_t_msg           = lit_msg " System Messages
        EXCEPTIONS
          x_message         = 1
          inherited_error       = 2
          invalid_type         = 3
          OTHERS           = 4.
 
      IF sy-subrc = 0.
 
        REFRESH : lit_sel[],
                  lit_msg[].
 
      ENDIF.
 
    ENDIF.
 
    IF SOURCE_PACKAGE[] IS NOT INITIAL.
 
* Keep the deletion record separatly in Internal Table (RECORDMODE = 'D')
 
      lit_delete[] = SOURCE_PACKAGE[].
 
      DELETE lit_delete WHERE recordmode <> lc_d.
 
      SORT SOURCE_PACKAGE BY bpartner.
 
      DELETE ADJACENT DUPLICATES FROM SOURCE_PACKAGE
             COMPARING bpartner.
 
      REFRESH : lit_sp[].
 
* Populating fresh Records for BP from Sorurce ZO02 DSO (Must!)
 
      SELECT *
        FROM /bic/az0200
        INTO TABLE lit_sp
         FOR ALL ENTRIES IN SOURCE_PACKAGE
       WHERE bpartner = SOURCE_PACKAGE-bpartner.
 
      IF sy-subrc = 0.
 
* Deletion Records should not be forwarded to Cube.
 
        CLEAR : lwa_sp.
 
        LOOP AT lit_delete INTO lwa_sp.
 
* Based on source DSO Keys
 
          DELETE lit_sp WHERE crm_obj_id = lwa_sp-crm_obj_id AND
                            crm_numint = lwa_sp-crm_numint.
 
 
        ENDLOOP.
 
        REFRESH : SOURCE_PACKAGE[],
                  lit_delete[].
 
        CLEAR : lwa_sp.
 
        SOURCE_PACKAGE[] = lit_sp[].
 
      ENDIF.
 
    ENDIF.
 
    REFRESH : lit_sp[].
 
**********************************************************************
 
*$*$ end of routine - insert your code only before this line         *-*
  ENDMETHOD.                    "start_routine

Author: Lokesh Pattnayak
Submitted: 23.08.2010

This is an approach to load real time  data into cube using SAP delivered API . The data uploaded are random values determined as per the data elements of the cubes  Info-objects.

There is  an ABAP routine to generate test data and it will  store the results directly in an Info Cube without using the normal data flow.The Application Programming Interface (API) RSDRI_CUBE_WRITE_PACKAGE_RFC can be used to write data per Request into a Real-Time Info Cube. 

For each execution of the report  a new Request is created and therefore it is not recommended to write data with high frequency to an InfoCube. This can result in heavy performance problems in the data load process, and it will decrease the Request Administration Performance.

  REPORT  zbi_cube_api2.

* DATA TYPES USED

TYPE-POOLS : rsd,rssb,rssg,rs.

FIELD-SYMBOLS : <g_t_data> TYPE STANDARD TABLE.

TABLES : rsdcube.

DATA : l_infocube TYPE rsinfocube,

       l_xstr TYPE xstring,

       l_samplesize TYPE i,

       i_modus TYPE i,

       l_s_cube TYPE rsd_s_cube,

       g_ref_to_data TYPE REF TO data,

       l_code TYPE abapsource,

       l_repid LIKE sy-repid,

       cube_ausgabe TYPE rsd_infocube,

       l_t_code TYPE STANDARD TABLE OF abapsource WITH DEFAULT KEY,

       l_tablnm TYPE rsd_tablnm,

       i_rfcdest TYPE rfcdest,

       w_answer TYPE c.

DATA : it_cube TYPE STANDARD TABLE OF rsdcube.

*---------------------------------------------------------------------------*
*SELECTION SCREEN
*---------------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-102.
PARAMETERS : p_infoc TYPE rsdcube-infocube VALUE CHECK ,
             p_size TYPE i DEFAULT 10.
SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON p_infoc.
  SELECT infocube
        FROM rsdcube
         INTO TABLE it_cube.

  IF sy-subrc = 0.

    CALL FUNCTION 'POPUP_TO_CONFIRM'
      EXPORTING
       titlebar                    = 'CONFIRM '
       text_question               = 'ARE YOU SURE TO UPLOAD DATA  '
       text_button_1               = 'YES'(001)
       icon_button_1               = 'ICON_ALLOW'
       text_button_2               = 'NO'(002)
       icon_button_2               = 'ICON_REJECT'
     IMPORTING
       answer                      = w_answer
     EXCEPTIONS
       text_not_found              = 1
       OTHERS                      = 2.
    IF sy-subrc <> 0.
    ENDIF.

CLEAR : l_samplesize.
    IF w_answer = '1'.
      MOVE p_infoc TO l_infocube.
      MOVE p_size TO l_samplesize.
    endif.

    IF w_answer = '2' OR w_answer = 'A'.
      CLEAR: p_infoc , p_size , l_infocube , l_samplesize.
    ENDIF.
  ELSEIF sy-subrc <> 0.
    MESSAGE ID 'BRAIN' TYPE 'I' NUMBER 330 WITH p_infoc.
  ENDIF.

*----------------------------------------------------------------------*
*CALL META DATA INFORMATION TO THE INFOCUBE
*----------------------------------------------------------------------*
  CALL FUNCTION 'RSD_CUBE_GET'
    EXPORTING
      i_infocube               = l_infocube
   IMPORTING
     e_s_cube                 = l_s_cube
   EXCEPTIONS
     infocube_not_found       = 1
     illegal_input            = 2
     OTHERS                   = 4    .
*------------------------------------------------------------------------*
* AUTHORITY CHECK
*--------------------------------------------------------------------------*
  CALL FUNCTION 'RSSB_AUTHORITY_ADMWB_INFOCUBE'
    EXPORTING
      i_actvt                   = rssb_c_auth_actvt-delete
      i_infocube                = l_infocube
      i_icubeobj                = rssb_c_auth_icubeobj-data
   EXCEPTIONS
     user_not_authorized       = 1
     OTHERS                    = 2   .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
*--------------------------------------------------------------------------------*
*    GENERATE DATA FOR INFOCUBE
*---------------------------------------------------------------------------------*
  " view all infoobjects

  l_tablnm = l_s_cube-viewtiobjnm2.
  PERFORM get_report_name CHANGING l_repid.
  CONCATENATE 'REPORT' l_repid '.' INTO l_code SEPARATED BY space.
  APPEND l_code TO                                                      l_t_code.
  CONCATENATE 'TYPES: L_S_DATA TYPE' l_tablnm ',' INTO l_code SEPARATED BY space.

  APPEND l_code TO                                                       l_t_code.
  APPEND '     L_T_DATA TYPE STANDARD TABLE OF L_S_DATA '  TO            l_t_code.
  APPEND '     WITH DEFAULT KEY .                       '   TO           l_t_code.
  APPEND '     FORM CREATE_TABLE_TYPES                  '   TO           l_t_code.
  APPEND ' CHANGING E_REF_TO_CHAVLTAB TYPE REF TO DATA .  ' TO           l_t_code.
  APPEND ' CREATE DATA E_REF_TO_CHAVLTAB TYPE L_T_DATA. ' TO l_t_code.
  APPEND '     ENDFORM.                                 ' TO l_t_code.

  INSERT REPORT l_repid FROM l_t_code.
  PERFORM create_table_types IN PROGRAM (l_repid)
           CHANGING g_ref_to_data.
*    GET THE COLUMN HEADINGS

  ASSIGN g_ref_to_data->* TO <g_t_data>.
  DELETE REPORT l_repid.

  CLEAR l_t_code.

*--------------------------------------------------------------------------------------*
*       CREATE RANDOM KEY FIGURES AND CHARACTERSTICS
*---------------------------------------------------------------------------------------*
* create random key figures and characterstics
  CALL FUNCTION 'RSSAMPLE_CUBE_SAMPLE_CREATE'
    EXPORTING
      i_infocube             = l_infocube
     i_samplesize           = l_samplesize
     i_use_masterdata       = 'X'
     i_random_seed          = 0
     i_modus                = 3
*          I_DATES_CLOSE          = RS_C_FALSE
   IMPORTING
     e_t_data               = <g_t_data>
   EXCEPTIONS
     illegal_input          = 1
     inherited_error        = 2
     OTHERS                 = 3            .

*    SEND THE DATA USING COMPRESSED XSTRING VIA RFC
  EXPORT rsdri = <g_t_data> TO DATA BUFFER l_xstr COMPRESSION ON.
  FREE <g_t_data>.
  DATA : i_t_rfcdata TYPE rsdri_t_rfcdata.
*       API CALL. WHEN DATA IS GENERATED TO INFOCUBE
  CALL FUNCTION 'RSDRI_CUBE_WRITE_PACKAGE_RFC'
     DESTINATION i_rfcdest
     EXPORTING
      i_infocube               = l_infocube
      i_curr_conversion         = ' '
      i_rfcdata_uc             = l_xstr
   TABLES
     i_t_rfcdata              = i_t_rfcdata
   EXCEPTIONS
     infocube_not_found       = 1
     illegal_input            = 2
     rollback_error           = 3
     generation_error         = 4
     duplicate_records        = 5
     request_locked           = 6
     not_transactional        = 7
     x_message                = 8
     OTHERS                   = 9
          .
*&---------------------------------------------------------------------*
*&      Form  GET_REPORT_NAME
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      <--P_L_REPID  text
*----------------------------------------------------------------------*

FORM get_report_name  CHANGING l_repid LIKE sy-repid.

  DATA : l_uniqueid TYPE rssg_uni_idc25.
  CALL FUNCTION 'RSS_SYSTEM_GET_UNIQUE_ID'
   IMPORTING
     e_uni_idc25       = l_uniqueid          .
  CONCATENATE 'GP' l_uniqueid INTO l_repid.
ENDFORM.                    " GET_REPORT_NAME


Regards

Lokesh

  • No labels