Design Better Custom Extractors For ODS Delta Loads
Design Better Custom Extractors For ODS Delta Loads
Design Better Custom Extractors For ODS Delta Loads
by Shreekant Shiralkar and Bharat Patel, BW Systems Managers, Bharat Petroleum, India Data
Extraction,R/3,Extractors
A better understanding of the role the "ROCANCEL" field plays in R/3 and the corresponding "0RECORDMODE" InfoObject in BW allows you to design better delta load solutions. The authors introduce "ROCANCEL" and "0RECORDMODE" and describe a custom extractor they created for processing these values.
When performing delta loads with an ODS, the ROCANCEL field in R/3 plays a vital role for record processing along with its BW counterpart, InfoObject 0RECORDMODE. Extractors delivered as part of the SAP R/3 Plug-In package convey the appropriate values to ROCANCEL, and these values are assigned to InfoObject 0RECORDMODE in the transfer rules for the data source. The ROCANCEL and 0RECORDMODE values identify records as new, changed, or deleted in the source system. Processing these values happens automatically, so you may not have been aware of it in the past. However, understanding the procedure is critical if no standard R/3 extractor is available and you must create a generic extractor with delta capabilities that passes the ROCANCEL values on its own. No generic extractor program linked to the R/3 application provides values for field ROCANCEL, so youll need to develop a custom workaround. Also, when data is coming from nonSAP systems, understanding how processing ROCANCEL values works will help you to design better BW solutions. We will provide you with an overview of what happens in the R/3 system when field ROCANCEL is populated with certain key values for a delta load. We will also introduce you to the corresponding InfoObject in BW (0RECORDMODE) and show you how it processes values assigned to the records in field ROCANCEL. Then well show you how we developed a solution based on a custom generic extractor and ODS that processes the ROCANCEL/ 0RECORDMODE values.
Note! Not all extractors deliver all values for the field ROCANCEL. Use transaction SE16 in the R/3 system and refer to tables ROOSOURCE/RODELTAM for
details about other extractors and possible field values for ROCANCEL.
Unlike an InfoCube, which offers only an addition mode, an ODS can be updated by overwriting as well as adding data. The Addition mode is used when key figures in an ODS, known technically as data fields, contain cumulative data such as sales quantities. The Overwrite mode is evoked when only the last value of a field is required for example, whether the delivery document status is open or closed. The value of InfoObject 0RECORDMODE determines whether the update rule for key figures supports addition or overwrite procedures. This InfoObject is required for delta loads and is added by the system if a data source is delta-capable. It is added to an ODS during the creation process. Records are updated during the delta process using a variety of ROCANCEL/0RECORDMODE values including N for a new record image, A for an additive image, and Y for an update record image used by ODS key figures processing with a minimum or maximum aggregation. We will limit our discussion here to the following four more commonly used values:
When delta requests are processed by the ODS, the ROCANCEL values assigned in R/3 and maintained by InfoObject 0RECORDMODE accurately update the data target automatically in different ways depending on if the ODS update rules are configured for the Addition or Overwrite mode.
Out of R/3
Lets take a look at how ROCANCEL values are passed from R/3 to BW. For our example, a delivery document originates in the R/3 system for a single item with a 1,860 Kg net weight. When the data for that item is extracted into BW, the ROCANCEL value is mapped to InfoObject 0RECORDMODE and the record carries a blank character value into the PSA indicating an after image. For this delta load, were using the SAP DataSource 2LIS_12_VCITM (delivery item) mapped for all objects with Move in the transfer rules, including field ROCANCEL. Its corresponding InfoSource 2LIS_12_VCITM is used to update the ODS. There are three ODS update rule settings for key figures Addition, Overwrite, and No Update and two options for characteristic InfoObjects Overwrite and No Update. In our example, the update rule for the key figure is set to Addition (Figure 1), while characteristics are set to Overwrite.
Figure 1
Before we examine this particular update, lets review the basic design of an ODS. It uses three tables during a delta load. The first is the new data table, or activation queue, where multiple requests can be stored. These requests must be activated to make them available for reporting and for data to be loaded into the data target. Once a request is activated, data from the new data table is deleted and moved to the second table, the active data table. The change log table is the third ODS table and is used to further update the activated request before it moves into the data target. Now lets look at our scenario. Data is loaded from the PSA into the ODS, and the new data table processes the record, which has a blank character value (Figure 2). When the first request for ODS data is activated, the active data table and the change log table the record is sent to and it is deleted from the new data table.
Figure 2
The first delta request is processed by the ODS in the Addition mode
The active data table and the change log table have R columns for values received from the reversal indicator InfoObject 0STORNO and U columns for values of the 0RECORDMODE InfoObject, also known as the update mode InfoObject. For the first request, the 0RECORDMODE value N is passed to the change log
indicating that the record delivers a new image. When the data is loaded into the final data target the InfoCube it contains a record for an item with a net weight of 1,860 Kg.
A Change in Value
The net weight of the item recorded in the R/3 system drops by half 1,860 Kg to 930 Kg and that change is extracted into BW. When a record changes, depending on the R/3 system, two views are generated. The before image is the record before changing, while the after image corresponds to the changed record. DataSource 2LIS_12_VCITM delivers both the before and after image, so the change generates two records. The before image has an X value for field ROCANCEL and a negative net weight of 1,860 Kg, negating the original amount. The other record, represented with a blank character for the ROCANCEL field, is the after image and has the present net weight of 930 Kg. Because the ODS update rules for this key figure are set to Addition, the net weight of the two records (1,860 Kg and +930 Kg) from the PSA are added and the resulting 930 Kg is entered in the ODS new data table (Figure 3). Prior to the second request being activated, the active data table retains the earlier 1,860 Kg data shown in Figure 2 on the previous page. On activating the request, the net weight in the new data table is added to the previous current net weight in the active table, resulting in 930 Kg.
Figure 3
On activation, the change log table is supplied with two records: one with a before image net weight of 1,860 Kg, which corresponds to the ROCANCEL/0RECORDMODE X value, and a blank-character value with a weight of 930 Kg. The record of the before-image value is then added to the afterimage value. When the delta load data is transferred from the ODS to the InfoCube, the new request provides a single record with a net weight of 930 Kg. The OLAP processor aggregates the key figures when a query is executed on the InfoCube. In this case, the original document in R/3 was reduced from a net weight of 1,860 Kg to 930 Kg, and the aggregation of the data from the two loads results in a final quantity of 930 Kg [1,860 + (930) = 930], so the report is accurate. When the delivery document is deleted from the R/3 system and the change is extracted to BW, it generates a single delta record containing a net weight of 930 Kg with an R ROCANCEL/ 0RECORDMODE reverse-image value (Figure 4). When loading the data from the PSA to the ODS, the new data table processes the record with the R value as the net weight 930 Kg. Activating the third request causes the record in the active table to be reversed, which deletes the entry entirely.
Figure 4
The change log table is supplied with one record with 0RECORDMODE value of R, which has a net weight of930 Kg. During the delta load from the ODS to the InfoCube, the new request provides a single record with the net weight of 930. The aggregation of all three requests (namely Rq1, Rq2, and Rq3) results in a total quantity of zero [1,860 + (930) + (930) = 0], which equals the final amount in R/3.
Figure 5
The big difference between the two modes comes when the weight changes and two records are extracted (Figure 6). Like in the Addition mode, when the weight is reduced, the records are extracted, indicating a change in weight from 1,860 Kg to 930 Kg. The before image represents the status of a record before it changes in the source system, and the after image is the changed status of the record.
Figure 6
The new data table ignores the X value but it is recorded in the change log
In the Overwrite mode, the ROCANCEL value of X for the 1,860 Kg weight, which reproduced the before image, is ignored when data is loaded from the PSA. The ODS new data table simply enters the record of the blank-character ROCANCEL value with a weight of 930 Kg. While the active table overwrites the earlier 1,860 Kg entry with the new 930 Kg quantity, the change log table is supplied with both the before- and after-image records. Both of these records are required because the InfoCube does not overwrite data. The system processes the 0RECORDMODE value X record with the 1,860 Kg weight and the record with the blank character value and 930 Kg weight. The results are passed from the ODS to the InfoCube like in the Addition mode. The delta load from the ODS to the InfoCube provides a single record with the net weight 930 Kg, and aggregating the two requests (Rq1 and Rq2) yields the 930 Kg weight, which is equivalent to the weight in the R/3. When the delivery document is deleted from R/3, it generates a single R ROCANCEL value. Processing the deleted record of the delivery document with the R value is identical in the Overwrite mode as it is in the Addition mode so the results are the same.
Figure 7
As you can see, ROCANCEL/0RECORDMODE values can be useful when you need to create solutions for specific scenarios. For more information, refer to SAP notes 399739, 335427, 320863, and 333492.