When using SLT to replicate (in our case, an Oracle database) data to SAP HANA, and you have a requirement to do some transformation of your data in SLT, you can use a SAP include in the SLT application to apply your logic.
In our straight-forward situation where we are retrieving a date value from the oracle database in a “mm-dd-yyyy”, while we want to have a basic dateformat in flat yyyymmdd to work with in HANA, we used a very basic include consisting of a concatenate of different parts of the source date-field and inserting the outcome into the table as a new field.
Steps to achieve this transformation:
1. In transaction iuuc_repl_content, set up replication for a source table (I’m not going to cover setting up replication itself in this document).
In the IUUC_REPL_TABSTG, click the ‘Edit table structure’ button to add a field to the target table.For our example, we will add a dats field that will extract the yyyymmdd from the creation date field in the source table.
In the *** RUL MAP tab, enter BOR (Begin of Rule) in the Event field. Refer to the image at the bottom of this document for more information on the different event types. In the insert include name field, insert the name of the include you will create in a second.
2. Include creation
In transaction SE38, enter the name you wish to use for your include, and click create. Make sure you are registered as a developer in the system. Select INCLUDE in the type attribute. Also, give your include a title that covers the contents of your code-to-be.
Insert your code in the include. our example contains the following code:
*& Include ZTEST_SLTTRANS
*Extract date and place it in DATS field
data: h_date type dats.
<WA_R_xxxx_xxx_OPPORTUNI>-DATE_TEST = h_date.
*End of include
NOTE: two things are important in the above code:
a) The field symbol only contains the first 18 characters of your source table.
b) The S in the field symbol stands for Source structure, the R stands for Result.
Check and activate the include.
If you have already filled in the include name in the SLT settings and saved it, you can test the include.
4. testing – result
When exporting this DATS field as it is configured by default(NVARCHAR), the result will be as seen below.
When SLT is configured to export DATS fields to a DATETIME field in HANA, the result will be as seen below:
Event options for replication, image from the SLT config guide.