Professional Documents
Culture Documents
Doing Calculations on a Group of Data Where the Group is Split across Data Packets
Applies to:
SAP_BW Release 350 or prior
Summary
During the data load data is split by data packets and the start routine in update rule is applied packet by packet. It is hence not possible to do calculation in start routine which requires a group of the records as they could be split in to different packets. Created on: 24 April 2006
Author Bio
Rajeev Kumar works for IBM India Limited. Areas of interest: SAP BI, ABAP, FICO. Graduation in Physics from Delhi University, Masters in Business Economics from Delhi University.
2006 SAP AG
Table of Contents
Problem description ......................................................................................................................... 2 Solutions .......................................................................................................................................... 2 Code samples.................................................................................................................................. 3 Related Content............................................................................................................................... 5 Disclaimer and Liability Notice......................................................................................................... 5
Problem Description
In a data warehouse landscape where data is stored in layers and in first layer you want data to be as received from the source system and do the calculations when loading the data to second layer. In this scenario while loading data from one ODS to another the extractor does not allow the choice of packaging the data with certain key values and as a result we could get scenarios where data is packaged in such a way that for a certain key value it is split across packets. If this happens then it is not possible to do calculations in update rule where all the records with certain key are required for doing the calculation. This is only a problem with BI 3.5 or prior release. This issue is resolved with the introduction of semantics in BI 7.0.
Solutions
A workaround to this problem is to load the data to PSA and use the PSA APIs to read all the data packets from PSA and do the calculations with all the data packets in one single internal table and writer the data back to PSA after that. Data can then later be loaded into data targets with process update from PSA in process chain. This totally gets rid of the problem of data being split in data packets without any packaging logic when loading from ODS to another ODS.
2006 SAP AG
Code samples
The ABAP for reading the PSA data and writing back to PSA is in four sections a- Get the request number b- Get data c- Change Data d- Write data back to PSA
2006 SAP AG
a- Get the request number CALL FUNCTION 'RSSM_API_REQUEST_GET' EXPORTING i_source = v_datasource i_typ = 'D' i_datefrom = sy-datum IMPORTING e_t_request = i_request EXCEPTIONS internal_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.
b- Get data from PSA CALL FUNCTION 'RSAR_ODS_API_GET' EXPORTING i_t_request = i_request TABLES e_t_data = i_dp EXCEPTIONS no_data_found =1 parameter_failure =2 request_not_available =3 no_request_found =4 no_fields_to_ods =5 no_ods_found =6 package_locked_by_loading =7 OTHERS =8. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
2006 SAP AG
d- Write data back to PSA CALL FUNCTION 'RSAR_ODS_API_PUT' EXPORTING i_request = v_request TABLES e_t_data = i_dp EXCEPTIONS parameter_failure =1 no_ods_found =2 put_data_failure =3 put_header_failure =4 decide_partno_failure =5 write_partno_failure =6 OTHERS = 7. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF.
Related Content
1. http://help.sap.com/saphelp_nw04/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
2006 SAP AG