Wednesday, 12 January 2022

Capture Deleted Records-Using SLT

Context/Background: As we all know using SLT we replicate the records from source system, so as part of the replication, SLT basically perform three actions which are insert, update and delete. So lets consider we have a below scenario, where are replicating records from S4 system to HANA database. This seems to be normal and this is what SLT suppose to do.

But actual problems arrives when you have further downstream system which read data from your HANA database directly. Also, if there is non-sap system which is reading from HANA database, it is difficult to capture deleted records on target, so it goes out of sync if it is not a trigger based solution or stores the data to the flat files.

So have you ever wondered how you can sync that data or how you can make sure those systems will remain in sync to the source system.

Ok, we have a below scenario:

Source: S4 system

Central system: SLT

Target System: HANA DB

Downstream System: NON SAP application ( Stores data in flat files)

So you all will be wondering how we can capture the deleted records which has been replicated by SLT. So to answer this puzzle is we have built/developed the custom solution which can help you to capture the deleted records into another table in HANA db.

How to retrieve deleted records?

Lets consider a scenario you have a table ACDOCA which has been replicated to target, in our case is EHANA. Now we perform the action to capture those deleted records, ok before we move to our topic, just want to introduce another enhancement, lets say if we have a requirement to add a another field also to be replicated as part of deletion. So have you wonder how we can add a field to logging table.

Yes we will cover all that information in the article.:) ok, lets first read about how we can add extra field to logging table.

Just for example, lets say we want to add FISCYEAR field also to be replicated or added as part of the logging table. FISCYEAR field is not a part of the logging table.

SAP HANA, SAP HANA Exam Prep, SAP HANA Exam Preparation, SAP HANA Career, SAP HANA Skills, SAP ABAP Jobs, SAP HANA Materials
Logging Table Without FISCYEAR Field

Before you add new field make sure no records are available in logging table. Stop the SAP jobs, lock the users, work with your basis team for that.

Once assured there is 0 records in logging table. Stop the replication of table, in our example is ACDOCA.

Now go to se16 in table ( IUUC_LOGTB_FIELD) and maintain the below entries.

SAP HANA, SAP HANA Exam Prep, SAP HANA Exam Preparation, SAP HANA Career, SAP HANA Skills, SAP ABAP Jobs, SAP HANA Materials
Custom Logging Table

After executing this, add the table into start recording, do NOT start replication as it will wipe out the data on target and it will do the initial load. So with this new logging table will be customized and new filed is added.

SAP HANA, SAP HANA Exam Prep, SAP HANA Exam Preparation, SAP HANA Career, SAP HANA Skills, SAP ABAP Jobs, SAP HANA Materials
Logging Table With Custom Field

Hope you liked this piece of information, So lets stick back to our original topic of capturing the deleted records.

So to capture deleted records you need to create a custom include, which can be assigned to rule assignment and a custom table on SLT to capture deleted records. For this you have to work with your development team who can write a piece of code and creates a custom table.

Once developers has written a custom include you need to assign that to the ACDOCA table in rule assignment.

SAP HANA, SAP HANA Exam Prep, SAP HANA Exam Preparation, SAP HANA Career, SAP HANA Skills, SAP ABAP Jobs, SAP HANA Materials
LTRS: Rule Assignment

Custom table on SLT will keep holding those deleted records and will be passed to HANA db into another custom table. So on HANA DB create a custom table and synonym.

SAP HANA, SAP HANA Exam Prep, SAP HANA Exam Preparation, SAP HANA Career, SAP HANA Skills, SAP ABAP Jobs, SAP HANA Materials
Custom Table in HANA

Now activate the MTID to start the replication, Since we have Realtime replication, our deleted records will be replicated to another custom table and built a another logic to sync your third party application with deleted records.

SAP HANA, SAP HANA Exam Prep, SAP HANA Exam Preparation, SAP HANA Career, SAP HANA Skills, SAP ABAP Jobs, SAP HANA Materials
Captured Deleted Records From Source

No comments:

Post a Comment