Skip to Content

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. 

Addfieldtargetstructure.JPG

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.

ASSRULMAP.JPG

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.

createinclude.JPGIncludetype.JPG

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.

CONCATENATE

<WA_S_xxxx_xxx_OPPORTUNI>-CREATION_DATE(4)

<WA_S_xxxx_xxx_OPPORTUNI>-CREATION_DATE+5(2)

<WA_S_xxxx_xxx_OPPORTUNI>-CREATION_DATE+8(2)

INTO h_date.

<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.

result_nvarchar.JPG

When SLT is configured to export DATS fields to a DATETIME field in HANA, the result will be as seen below:

Result_datetime.JPG

Event options for replication, image from the SLT config guide.

Events.JPG

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

      1. Mr. Amit W

        Hi Sjoerd,

        Suppose i have 3 Tables TAB1, TAB2 and TAB3.

        Each table has DATE and TIME field.

        Instead of wrting 3 includes for 3 tables, can it be possible to write inside only one include.

        -Amol

        (0) 
        1. S. van Middelkoop Post author

          Hi Amol,

          I guess you would be best off writing a simple function module in SE37 to do this. That way, you only need to call that function from the includes.

          Sjoerd

          (0) 
          1. Mr. Amit W

            But how can I get each time field symbol for perticular that table?

            We have three tables for updating 3 tables we required 3 field symbols right?

            So in run time how can i get?

            – Amol

            (0) 
            1. S. van Middelkoop Post author

              That would be done with import / export parameters.

              But easiest would be to just create a routine for each case.

              Maybe you’d best ask this question in the ABAP forum or here as a question, there are better ABAPers in the world than me 🙂

              (0) 
              1. Nilesh Pathak

                hi Sjoerd,

                My requirement is little diff – i am pulling data from SAP and need to convert to ORACLE format in SLT. Please can yu advice best way for it.

                thanks

                (0) 
                1. Laurent THIBERT

                   

                  Hi Nilesh,

                  A bit too late for you but not for others I hope: we had the same requirement.

                  The best option we have found is to create triggers on DB2 (our target in place of Oracle). These triggers (U and I) provide the value of the timestamp for each record.

                  Regards

                  (0) 
  1. Unknown Unknown

    Hi Amit,

    Were you able to get the solution for creating a generic code that can be used for any table without giving the table name in the include?

    -Regards,
    Mayur Bansal

    (0) 

Leave a Reply