You are on page 1of 10

Replication of Views with SAP LT Replication Server

Views are a good option to restrict the amount of transferred data already on the source system: You
can define which fields are required and which are obsolete in the target system and thus which data has
to be replicated. You can use two different types of views, the Projection View and the Database View.
The Projection View helps to reduce the amount of fields from one table. The Database View can be used
to combine fields from several tables.

Projection View

Creating a Projection View with a subset of fields of a table means filtering on the source system. Only
the data in the fields which are selected for the view are transferred with SLT into the target system. The
table in the target system has then the same name as in the source but only contains the subset of fields.

Creating the Projection View

In the ABAP Workbench (se80) of the source system create a projection view (Dictionary Objects ->
Views -> Context Menu “View -> Create”) with a name that should differ from the table name.
Enter the name of the Basis Table. Then click “Table fields” and select the subset of the table fields that
you want to replicate. Select the key fields.

Database View

A Database View is used if you join fields of different tables into one view, one table (A) is the leading
table and fields from other tables can be added. In the SLT system, the table deviation has to be built as
a transformation of table A. The table keeps the name as in the source system but is enlarged with the
additional fields.
Creating a Database View

In the ABAP Workbench (se80) of the source system create a database view (Dictionary Objects -> Views
-> Context Menu “View -> Create”) with a name indicating that it is a combination of fields from different

On the tab Table/Join Conditions, enter the tables you want to include in the view, and enter the join
Then you can select the fields you want to see in the view on the tab View Flds.

Assigning the View to the Table

In the system where the SLT server is running, open the Advanced Replication Settings (LTRS), select
your configuration (only works if the configuration is running) and assign the view to the table: First you
add the table itself under Table Settings, then you assign the view in the Processing Settings of the table.
You may assign the view for both initial load and replication (if you want to distinguish between initial
load and the replication you can also assign two different views).

You can add a deviating table name, meaning that the table is created with this new name in the target
system (compare screenshot). This helps to show that a table is modified (not possible in the ODP
If you have assigned a database view, you have to adapt the table structure to display the additional

Hint: You can enter the view as a Structure Template on the Table Settings tab, too, then you do not
have to change the table structure manually.
A very important step is that you have to add the same table to the Performance Options in the
Advanced Replication Settings, an set the Reading Type for the table with view to “5 – INDX CLUSTER
with FULL TABLE SCAN”. The default reading type 3 does not work for views.

Now you can start the replication of the table with view (in the Replication Server Cockpit or Hana
Studio, for the ODP scenario in the subscribing application).

Important: Start the replication of the table, do not enter the view name.

Replication of a View from a non-ABAP source

The replication of views is possible for non-ABAP sources, too. If you want to replicate a view from a
supported database, use the following procedure:

1. Create the view in the source system or use a Z_report in the SLT system like the one below to
create the view.
2. Assign the view to the leading table in LTRS as described in the section “Assigning the view to the
3. Start the replication for the table.
Report for Creating a View in a non-ABAP system from the SLT system
(Use if you do not have access to the source system directly)


REPORT z_view_create.

DATA: go_sql_connection TYPE REF TO cl_sql_connection,

go_sql_statement TYPE REF TO cl_sql_statement,
go_sql_result TYPE REF TO cl_sql_result_set,
gv_statement TYPE string,
gx_sql_exception TYPE REF TO cx_sql_exception.

* set here your view name here *

DATA: gv_tblname TYPE tabname VALUE 'ZVIEW_SPFLI'.

* set here your DBCON db connection and the schema names *

DATA: gv_dbcon_name TYPE dbcon_name VALUE 'SL5',

gv_schema_name TYPE dbcon_uid VALUE 'SAPSL5'.
* Establish DB connection
go_sql_connection = cl_sql_connection=>get_connection( gv_dbcon_name ).
go_sql_statement = go_sql_connection->create_statement( ).

CATCH cx_sql_exception INTO gx_sql_exception.

WRITE / 'Error occured during the opening of the db connection.'.

* do not forget to set the value of the gv_tblname variable*
* to the correct string value (your view name) *
* before performing the create / delete subroutines *

* comment out the subroutine which you don't need ! *

" Create view

PERFORM create_view
USING gv_tblname.

"Delete view
PERFORM delete_view
USING gv_tblname.

* Close DB connection
IF go_sql_connection IS BOUND.
go_sql_connection->commit( ).
go_sql_connection->close( ).
CATCH cx_sql_exception INTO gx_sql_exception.
WRITE: / 'Error occured during the closing of the db connection.'.

FORM delete_view USING p_gv_tblname.

gv_statement = `DROP VIEW ` && p_gv_tblname.

go_sql_statement->execute_ddl( gv_statement ).
go_sql_connection->commit( ).
CATCH cx_sql_exception INTO gx_sql_exception.
WRITE: / 'Error occured during the deletion of the view.'.


FORM create_view USING p_gv_tblname.

" Oracle, MSSQL, HANA, MaxDB, Informix, Sybase, DB6, DB4

INTO gv_statement.

go_sql_statement->execute_ddl( gv_statement ).
go_sql_connection->commit( ).
CATCH cx_sql_exception INTO gx_sql_exception.
WRITE: / 'Error occured during the creation of the view.'.