dynamic filters in infopackage - two scenarios

19
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2010 SAP AG 1 Implementing Dynamic Filters in InfoPackage: Two Scenarios Applies to: BI/BW and ABAP Developers working in SAP BW 3.x, SAP BI 7.x.For more information, visit the EDW homepage .. Summary This article encompasses the usage of Infopackage routines that can be implemented to put dynamic filters for extraction purposes. The nature of the filter can vary based on type of Data (i.e. Master Data Hierarchy or Transactional). Two types of filters will be demonstrated here with sample codes. Author: Akashdeep Banerjee Company: IBM India Pvt. Ltd. Created on: 28 September 2010 Author Bio The author is working in SAP BI for a period of 4 years. He has worked in both Implementation & Support projects with his current as well as previous organization (Pricewaterhouse Coopers’). Besides BI, he has knowl edge on BI security and basic SAP security.

Upload: samy22722

Post on 26-Nov-2015

114 views

Category:

Documents


8 download

DESCRIPTION

Dynamic Filters in Infopackage

TRANSCRIPT

  • SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 1

    Implementing Dynamic Filters in

    InfoPackage: Two Scenarios

    Applies to:

    BI/BW and ABAP Developers working in SAP BW 3.x, SAP BI 7.x.For more information, visit the EDW homepage..

    Summary

    This article encompasses the usage of Infopackage routines that can be implemented to put dynamic filters for extraction purposes. The nature of the filter can vary based on type of Data (i.e. Master Data Hierarchy or Transactional). Two types of filters will be demonstrated here with sample codes.

    Author: Akashdeep Banerjee

    Company: IBM India Pvt. Ltd.

    Created on: 28 September 2010

    Author Bio

    The author is working in SAP BI for a period of 4 years. He has worked in both Implementation & Support projects with his current as well as previous organization (Pricewaterhouse Coopers). Besides BI, he has knowledge on BI security and basic SAP security.

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 2

    Table of Contents

    Business Scenario .............................................................................................................................................. 3

    Scenario 1: Automatically selecting the latest available hierarchy from source system & loading it in BI ..... 3 Step-by-Step Procedure .............................................................................................................................................. 3

    Scenario 2: Dynamic Filter on Infopackage for Transactional Data ............................................................. 10 Step-by-Step Procedure ............................................................................................................................................ 11

    Related Content ................................................................................................................................................ 18

    Disclaimer and Liability Notice .......................................................................................................................... 19

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 3

    Business Scenario

    Many-a-time, business has requirement to restrict the volume of data inflow from source system to save space in database to accelerate DB time in reporting. Another scenario is to have updated values only whenever they are launched in the source system (like latest hierarchies or data for the latest posting dates). Here two such scenarios are mentioned:

    A number of time-based or name-based hierarchies exist in source system. But requirement is to bring in the latest available hierarchy to the BI system, ignoring any dummy hierarchy created as a test object for the future periods.

    Restrict transactional records while those are flowing into BI system (like to restrict the infopackage with the some conditional values in Info Object Master Data). We are calling it dynamic as the number of Master Data entries may get changed in the next month or anytime in the future.

    Scenario 1: Automatically selecting the latest available hierarchy from source system & loading it in BI

    Lets us assume that we have many hierarchies created in the source system to load the business content Info Object Consolidation Unit (0CS_UNIT). They are named as BPBU, BPCB, BPS2 etc and each of them is time-dependent i.e. they get changed monthly. One can see all of them in the infopackage view by clicking Available hierarchies from OLTP. Then we need to select the latest hierarchy by scrolling & searching manually (radio button). After that we run the infopackage.

    Imagine the degree of manual intervention when there are hierarchies for last 5 years i.e. say 12 types of hierarchies each one having 60 monthly hierarchies for last 60 months (12 years). Requirement is to load these hierarchies everyday and to start loading the new hierarchy for each one of them automatically from the day they are created in the source system. In this way, no manual intervention or delay is expected. Also, no one supporting the BI system needs to know when the new hierarchy was created in source system.

    Step-by-Step Procedure

    This describes how to load one hierarchy (BPBU) dynamically. For other hierarchies, one needs to repeat it within a different infopackages i.e. if 6 different hierarchies are needed to be loaded, we need to create 6 infopackages.

    1. Create an Infopackage under Hierarchy Datasource & go to tab Hierarchy Selection & press Dynamic Hierarchy Selections.

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 4

    2. Select option Determine Using Routine & click

    3. Give a name & click Editor

    4. This opens up the ABAP Editor with some pre-loaded code.

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 5

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 6

    5. Change the editable portion like below

    Code sample with explanation in Red (not to be written in code):

    DATA : i_hier_vers TYPE TABLE OF rshiertrsf.

    * p_s_sel_hier = l_s_presel_hier.

    loop at l_t_all_hier.

    IF l_t_all_hier-hienm = 'BPBU' (This condition gets changed in different

    Infopackages)

    AND l_t_all_hier-version = 'GRA' (This version may not relevant everytime)

    AND l_t_all_hier-datefrom LE sy-datum.

    APPEND l_t_all_hier TO i_hier_vers. (only BPBU hier leaving any future-dated

    one)

    ENDIF.

    *....

    endloop.

    SORT i_hier_vers DESCENDING BY dateto. (latest hier on the top)

    READ TABLE i_hier_vers INDEX 1 INTO p_s_sel_hier. (top-most one selected for

    loading)

    clear p_subrc.

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 7

    6. Check the syntax with & save the code . Hit enter to the following window :

    7. The button is now verified for the code

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 8

    8. Schedule the infopackage normally & run. In the monitor screen it shows which hierarchy got loaded

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 9

    Notes: For automation, we need to schedule it in a process chain & need as many infopackages as the number of

    different hierarchy names. A process named Save Hierarchy (3.x) may be needed after Infopackage in the Process Chain (sometimes loaded

    hierarchy needs this to get activated)

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 10

    Scenario 2: Dynamic Filter on Infopackage for Transactional Data

    Lets now take the situation where we are having a transactional datasource to load a DSO. The loading frequency and the data volume may be high and also customer only needs the data for the Consolidation Units which are appearing in the master data table with Country US.

    Master Data for Consolidation Unit

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 11

    Step-by-Step Procedure

    1. Create an infopackage on the datasource. Go-to Data Selection tab. Identify Consolidation Unit.

    2. Hit F4 help & select 6 (ABAP Routine)

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 12

    3. Click on Detail button

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 13

    4. An automatically generated code will appear. Change the code as below & run a syntax check with button

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 14

    Code sample with explanation in Red (not to be written in code):

    DATA: l_idx LIKE sy-tabix,

    cons_unit TYPE char18,

    it_cu TYPE STANDARD TABLE OF /bi0/pcs_unit,

    wa_cu LIKE LINE OF it_cu,

    g_msg TYPE string.

    READ TABLE l_t_range WITH KEY

    fieldname = 'CS_UNIT'.

    CLEAR l_t_range[].

    SELECT * FROM /bi0/pcs_unit INTO TABLE it_cu (Cons Units for US from Master

    Data)

    WHERE country = 'US'.

    IF sy-subrc = 0.

    LOOP AT it_cu INTO wa_cu.

    l_t_range-sign = 'I'.

    l_t_range-option = 'EQ'.

    l_t_range-low = wa_cu-cs_unit.

    APPEND l_t_range. (Populating filter list)

    ENDLOOP.

    ELSE.

    g_msg = 'No US Cons Unit'. (Error raised for no US Cons Units-See Notes

    below)

    MESSAGE g_msg TYPE 'E'.

    ENDIF.

    l_idx = sy-tabix.

    *....

    *modify l_t_range index l_idx.

    p_subrc = 0.

    5. Save the code & get back to the Infopackage screen. Test the outcome of the code via Test Routine button as shown below in Red circle

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 15

    6. The outcome

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 16

    7. Go-to Extras Restrict No of Selection Values, uncheck the following screen & save.

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 17

    8. Run the infopackage & re-validate the filter & incoming records

    Note: Always raise an Error message in the Infopackage code to terminate processing for undesired condition. Else, filter

    logic will be ignored e.g. in the example above, if no US consolidation unit is found, system will load data for all Consolidation Units.

    Advantage of this code is this can be edited even in Productive system if Infopackages are set as Everything Changeable in Object Changeability.

    One can even introduce file upload/download function modules inside the code to load filter values from Application server/local workstation.

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 18

    Related Content

    http://forums.sdn.sap.com/message.jspa?messageID=6710556

    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a05ac9fa-f44c-2c10-dbb8-ef54c102707c?QuickLink=index&overridelayout=true

    www.bi-expertonline.com/downloads/InfoPackage%20Selection%20Condition.doc

  • Implementing Dynamic Filters in InfoPackage: Two Scenarios

    SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

    2010 SAP AG 19

    Disclaimer and Liability Notice

    This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

    SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

    SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.