Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
uladzislau_pralat
Contributor

SPO with BAdi can be used to implement rollowing snapshots scenarios. For example, 24 monthly forecast snapshots are stored in SPO cube. Every month new snapshot is stored replacing one which is 2 years old.

BW supports you all steps of the way helping create Transformations, DTPs, Process Chain and maintain SPO partitions. Generated Process Chain though is not ideally suited for rolling snapshots scenario (has 24 parallel processes to update all 24 partitions) and needs to be enhanced.

Enhanced Process Chain has Decision step added to update only one partition.

Decision step serves two purposes:

  • Saves system resources (no unnecessary loads, indexes deletion / creation and statistic updates);
  • Handles scheduling errors (if process chain runs second time after current month snapshot is loaded then Decision step ends in error).

Please note that Decision step runs prior to ABAP re-partitioning step (RSLPO_MASS_ACT_BDG program) comparing current SPO partition criteria with new one from SPO BAdi. No matter how complex SPO partitioning criteria can be comparison is as simple as comparing two ABAP tables. ABAP coding is kept generic to be reusable for other rolling snapshots scenarios.

Below are step by step instructions for adding Decision step:

1. Implement C_SPO_PARTITION_CHANGED custom function logic in ABAP class method:

CLASS zcl_rslpo_badi_partitioning DEFINITION
 
PUBLIC
 
FINAL
 
CREATE PUBLIC .

PUBLIC SECTION.

  CLASS-METHODS partition_changed
   
IMPORTING
      iv_spo  
TYPE rslponame
      iv_idpart
TYPE rslpo_idpart
   
RETURNING
     
VALUE(rv_partition_changed) TYPE char1 .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_rslpo_badi_partitioning IMPLEMENTATION.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_RSLPO_BADI_PARTITIONING=>PARTITION_CHANGED
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_SPO                        TYPE        RSLPONAME
* | [--->] IV_IDPART                      TYPE        RSLPO_IDPART
* | [<-()] RV_PARTITION_CHANGED          TYPE        CHAR1
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD partition_changed.
DATA: wt_badi_part_crit_new TYPE rslpo_badi_t_part_crit,
      wt_badi_part_crit_old
TYPE rslpo_badi_t_part_crit.
DATA: partitioning TYPE REF TO rslpo_badi_partitioning.

 
GET BADI partitioning.
 
CALL BADI partitioning->get_t_part_crit
     
EXPORTING
            i_spo       
= iv_spo
     
RECEIVING
            r_t_part_crit
= wt_badi_part_crit_new.

 
SELECT *
 
INTO CORRESPONDING FIELDS OF TABLE wt_badi_part_crit_old
 
FROM rslpopartrange
 
WHERE lpo    = iv_spo
   
AND objvers = 'A'.
 
SORT: wt_badi_part_crit_old,
        wt_badi_part_crit_new.
 
DELETE: wt_badi_part_crit_old WHERE idpart <> iv_idpart,
          wt_badi_part_crit_new
WHERE idpart <> iv_idpart.
 
IF wt_badi_part_crit_old[] <> wt_badi_part_crit_new[].
    rv_partition_changed
= abap_true.
 
ELSE.
    rv_partition_changed
= abap_false.
 
ENDIF.

ENDMETHOD.
ENDCLASS.

2. Implement RSAR_CONNECTOR classic BAdi for C_SPO_PARTITION_CHANGED custom function

METHOD if_ex_rsar_connector~get.
DATA: w_function TYPE sfbeoprnd.

CASE i_key.
WHEN 'CUSTOM'.

  w_function-tech_name = 'C_SPO_PARTITION_CHANGED'.
  w_function-descriptn
= 'SPO Partition changed'.
  w_function
-class = 'ZCL_RSLPO_BADI_PARTITIONING'.
  w_function
-method = 'PARTITION_CHANGED'.
 
APPEND w_function TO c_operands.

ENDCASE.

ENDMETHOD.

3. Add Decision Process Chain step

Each If or Else If command formula looks like this

Note: first parameter is SPO name and second one is a partition number.

Lets execute enhanced Process Chain to load 2014/12 shapshot

This is how SPO looks after 2014/12 shapshot load

Finally, lets see if scheduling error handling works by trying load the same 2014-12 snapshot second time. Sure it does: