You can create a generic datasource using a function module.

For delta functionality you need a delta field. Some tables like VBAK (Sales Document: Header Data) don’t have a timestamp field for creation/change that we can use as a unique delta field but have separate fields for creation date (ERDAT), creation time (ERZET) and change date (AEDAT). To get the data of the VBAK table by using delta functionality we will create a generic datasource using a custom function module which implements the necessary logic.

We will create an extraction structure that has a timestamp field and we will use this field to implement the delta functionality. In this blog I will explain this concept.

There are two template function modules that one can copy and use:

– RSAX_BIW_GET_DATA_SIMPLE: A function module with simple interface for Full Load with no support of delta loads.

– RSAX_BIW_GET_DATA: : A function module with complete interface that supports Delta Load. We will use this FM.

Step 1: Create an Extract Structure

– Go to transaction SE11 and create a new structure ZZVBAK.

– Insert the table VBAK as an include into the structure.


– Add a field ZTMSTMP (Data element: TZNTSTMPS, it is of datatype DEC with Length 15). This field will hold the timestamp and allow us to use the extraction for delta purposes.

struc_create_5

– Save and activate the structure. This structure will be our extract structure for the datasource.

Step 2: Create the function module:

– Go to transaction code se80 and copy the function group RSAX to the new function group Z_RSAX and copy the function module RSAX_BIW_GET_DATA to Z_RSAX_BIW_GET_DATA_VBAK . Be sure to copy and activate all the related objects (interfaces, datatypes etc.).

– Go to SE37 and Open your FM Z_RSAX_BIW_GET_DATA_VBAK to edit. In TABLES tab set the parameter E_T_DATA to associated type ZZVBAK.

– Go to the source code tab. Copy the ABAP Code and paste it.

– Save and activate the function module.

Step 3: Create the Datasource:

– Go to transaction RSO2 and create a new datasource for transaction data and name it to ZDSVBAK.

– Set the Application component and the description texts.

– Click on Extraction by FM. Enter the name of the function module Z_RSAX_BIW_GET_DATA_VBAK and the extract structure ZZVBAK.

– Click on Generic Delta. Select the timestamp Field ZTMSTMP and set the option Timestamp.

– Optionally set the Safety Interval Lower Limit. For more Information refer to
SAP HELP.

– Click Save and click Save again. In the following screen you can set the selection fields. The timestamp field is disabled because it will be automatically populated as part of the delta process.

– Now go to transaction RSA2 to see the details of our datasource ZDSVBAK. The Extraction Method is set to F2 (Simple Interface). To change it to F1 (Complete Interface) execute the following ABAP code. (You can go to SE38 and create new report with this ABAP code). Unfortunately this is not possible in the GUI. I don’t know why.

REPORT ZABAPDEMO.
UPDATE roosource
SET delta = ‘E’
exmethod = ‘F1′
genflag = ‘X’
WHERE oltpsource = ‘ZDSVBAK’.

– Go to RSA2 and display the status of the datasource ZDSVBAK (just to confirm, that it is set to F1).

– Check that there are no erros.

– This is an optional step: To test the function module go to SE37 and call it two times in succession – one call for Initialization and the second to read data. This is actually not necessary but it’s a good way to check, if the function module is basically working well.

– This was the initialization Call. Now the second call to get the data:

– Be sure that the table E_T_DATA contains the data.

Step 4: Go to transaction RSA3 to test the datasource.

– Now the datasource is created and you can use the Xtract DeltaQ component to read it. Be sure to activate it via the activate button.

– The datasource supports the Full and Update Delta mode. To use the Update Delta mode the first call must have the update type C (Delta Initialization). All following calls must have the update type D (Delta Update). The delta process of the datasource can be monitored and maintained in RSA7 (Delta queue).

References:

SAP Help about Maintaining generic datasources.

SAP BI Generic Extraction Using a Function Module

How to Create Generic Delta

SAP BI Generic Extraction Using a Function Module

Written by Khoder Elzein

Khoder is responsible for presales and always has an attentive ear for our customers, prospectives and partners. When travelling in Germany or abroad, he provides customer support at PoCs, workshops and on training courses. He also looks after the further development of our software solutions. Khoder has been working in IT since the turn of the millennium; he has been a member of team Theobald since 2009. When it comes to private interests, family, nature and reading feature at the top of his list – along with innovative fusion cuisine, as you may infer from his favourite dish of Swabian cheese noodles with tabouleh.