Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
roger_rodriguez1
Employee
Employee
This case scenario cover requirements to add new fields & populate them via SLT to target structure .In this case we will populate the new fields with time-stamp for transfer behavior I (insert) & U (update).

  1. Execute T-Code LTRS:

  2. Select your MT-ID (Mass Transfer ID)

  3. Right click on table setting and click on Add Table to include your table name:

  4. Add your new fields to your table structure:




  • Define your new fields:




  • Save your new fields:




  • Right click on Rule Assignment then add your table name:




  • Click on create icon then select Field-Related Rule:




  • Enter one of your new fields: on target field:




  • Select the line created (double click) then include your table name in import parameter 1, Status = Released & your ABAP include program name (for the transformation):




Open a new session:

Via T-Code SE38 create an include ABAP program then copy and paste the following code:
DATA: lv_name(30) TYPE c.

FIELD-SYMBOLS: <ls_record>    TYPE any,
               <lv_operation> TYPE any,
               <lv_insert>    TYPE any,
               <lv_update>    TYPE any.

* get target structure
CONCATENATE '<WA_R_' i_p1 '>' INTO lv_name.
ASSIGN (lv_name) TO <ls_record>.

ASSIGN COMPONENT 'IUUC_OPERAT_FLAG' OF STRUCTURE <ls_record> TO <lv_operation>.

IF sy-subrc = 0.
  CASE <lv_operation>.
    WHEN 'I'.
*** set additional target fields
* set insert timestamp
      ASSIGN COMPONENT 'INSERT_TS' OF STRUCTURE <ls_record> TO <lv_insert>.
      IF sy-subrc = 0.
        GET TIME STAMP FIELD <lv_insert>.
      ENDIF.

    WHEN 'U'.
* set update time stamp
      ASSIGN COMPONENT 'UPDATE_TS' OF STRUCTURE <ls_record> TO <lv_update>.
      IF sy-subrc = 0.
        GET TIME STAMP FIELD <lv_update>.
      ENDIF.
  ENDCASE.
ENDIF.

 

Save your configuration in LTRS then continue with your process to Load / Replicate your table via t-code LTRC or via HANA Studio.

Regards,
Roger Rodriguez
SAP - HANA CoE NA
13 Comments
Former Member
0 Kudos
 
former_member184624
Participant
0 Kudos
Thank Roger for creating the wonderful document.

Can you please provide some inputs on how to extract data for the new field in same table. And need to extract history data for the new field.

Thanks.

 
roger_rodriguez1
Employee
Employee
0 Kudos
Hi Jalina,

Usually it will be populated automatically after you save & activate your transformations.

The most common case is the reload the table.

Regards,

Roger
AbeDong
Explorer
0 Kudos
Hi Roger. Thanks for sharing this blog. I implement the same code in our system, but I found it not fully meet the requirement.

First we create one record in source system, in target system, the insert timestamp is populated.

Then we change the same record in source system, in target system, the update timestamp is populated. But at the same time, the insert timestamp is wiped out. Our requirement is keep the insert timestamp, would you please give some suggestion on this.

Thanks in advance.

 
Former Member
0 Kudos
Hi Roger,

could you tell what is the meaning of status = "Released".

I can see that there are other statutes provided like "New" and "Obsolete".

please elaborate on this.
former_member238852
Participant
0 Kudos
Can we Debug this code if  yes , please pleat me know how to hold break point at this code
0 Kudos
This is really easy to understand for the one even new to SLT

Thanks!!

Cheers

Sethu
ariel_mena
Discoverer
0 Kudos
Hi Roger,

create the configuration as described in the blog, but when starting the replication the field is zero, additional in the code it presents an error in the code with the i_p1 parameter as it says that it does not recognize it.

Please can you help me.
roger_rodriguez1
Employee
Employee
0 Kudos
Hi Ariel,

Make sure you copy the code as is:  you can use ` as quote in ip_1 which is used in CONCATENATE '<wa_r'(space) 'ip_1'(space) '>' into lv_name.     you can test it replacing ip_1 with your table name you want to add new fields.   ex. lv_name = '<wa_r_vbak>'

DATA: lv_name(30) TYPE c.

FIELD-SYMBOLS: <ls_record>    TYPE any,
               <lv_operation> TYPE any,
               <lv_insert>    TYPE any,
               <lv_update>    TYPE any.

* get target structure
CONCATENATE ‘<WA_R_’ i_p1 ‘>’ INTO lv_name.
ASSIGN (lv_name) TO <ls_record>.

ASSIGN COMPONENT ‘IUUC_OPERAT_FLAG’ OF STRUCTURE <ls_record> TO <lv_operation>.

 

Regards,

Roger
ariel_mena
Discoverer
0 Kudos
Hi Roger,

I made the change in the code as you indicate, but when starting the initial load of the table, the new field is empty, suddenly I am omitting something in the configuration



Regards,
roger_rodriguez1
Employee
Employee
0 Kudos
See below:


 


 

matt_ellicott
Explorer
0 Kudos
is it possible to track deletes as well? if yes, would you have the sample code.
roger_rodriguez1
Employee
Employee
0 Kudos
Hi Matt,

Just include the 'D' and your logic in :

CASE <lv_operation>

WHEN 'D'.

*** HERE YOUR LOGIC ***   you can populate a new field (flag) for deletion in target table or depend of your business case include here your code.

 

Regards,

Roger