The runtime to write archived data to an external storage should be implemented in a central ABAP class. This ABAP class must register the interface IF_ARCH_WRITE
to be able to be selected in an archiving object definition in ADT. This ABAP class can be performed within an application job.
The purpose of the ABAP class is the selection of application data which will be archived from the database. By using the ADK write API, this application data can be handed over to create a data object. A data object can contain entries of different tables that have been listed in the definition of the archiving object in ADT. Typically, these are all tables belonging to one business object instance, but there is no technical restriction. The application is free to group the tables according to their needs.
As soon as the data object is completed, the object will be transferred as an archiving file to the related storage manager implementation to store data in the related external storage.
The following table shows the write API to collect the data that will be archived:
|
||
---|---|---|
Method |
Parameter |
Description |
Static method which returns an instance of the write API via parameter |
Importing: |
Name of the archiving object which will be used |
Importing: |
True: no storage takes place False: Archive content is written, and storage is requested |
|
Returning: |
Instance of the write API for further processing |
The following table shows the interface for writing archived data:
|
||
---|---|---|
Method |
Parameter |
Description |
Opens a new data object for the data of the business object instance |
|
|
Writes the data for a specific table to the open data object |
Importing: |
Name of the table which will be archived |
Importing: |
Records of the table |
|
Closes the data object and writes it to the archive file |
Exporting: |
Offset at which the data of the data object starts (can be used to build application owned indices for the archived data) |
Exporting: |
Archive key of the archive file to which the data was written (can be used to build application owned indices for the archived data) |
|
Exporting: |
Sessions of the archiving object to be used |
|
Finalizes processing and closes the archiving session |
|
|
Typical flow of the archiving write process:
-
Create an instance of the write API and open the archiving write session by using method
CL_ARCH_WRITE_API=>GET_INSTANCE
. -
Select the data from your application DB tables.
-
For each data object you want to archive, call method
OPEN_DATA_OBJECT
. -
For each table you want to archive entries from, call method
PUT_DATA_RECORDS
. -
As soon as all tables of your data object are passed to the API, call method
CLOSE_DATA_OBJECT
. -
Either start with the next data object (step 3) or finish the archiving write session by calling method
FINALIZE
.
CONSTANTS: lc_object TYPE sarch_object VALUE ‘MY_OBJECT’. " Replace with the name of your ADT archiving object " select flight data (leading table) from the database (replace table names with your names of your own tables) SELECT * FROM my_header_table WHERE carrid IN @lt_range_carrid AND connid IN @lt_range_connid AND fldate IN @lt_range_fldate INTO TABLE @DATA(lt_flights). " open a new archiving session to archive data TRY. DATA(lo_write) = cl_arch_write_api=>get_instance( iv_archiving_object = lc_object iv_testmode = lv_test ). LOOP AT lt_flights ASSIGNING FIELD-SYMBOL(<ls_flight>). " select data of dependent tables (replace table names with your names of your own tables) INSERT <ls_flight> INTO lt_flights. SELECT * FROM my_item_table1 WHERE carrid = @<ls_flight>-carrid AND connid = @<ls_flight>-connid AND fldate = @<ls_flight>-fldate INTO TABLE @DATA(lt_bookings). SELECT * FROM my_item_table2 WHERE carrid = @<ls_flight>-carrid AND connid = @<ls_flight>-connid AND fldate = @<ls_flight>-fldate INTO TABLE @DATA(lt_tickets). SELECT * FROM my_item_table3 WHERE carrid = @<ls_flight>-carrid AND connid = @<ls_flight>-connid AND fldate = @<ls_flight>-fldate INTO TABLE @DATA(lt_invoices). " open new ADK data object lo_write->open_data_object( ). " write data of header table lo_write->put_data_records( iv_table_name = ‘<MY_HEADER_TALBE>’ it_records = lt_sflight_arch ). CLEAR lt_sflight_arch. " write data of depending tables lo_write->put_data_records( iv_table_name = ‘<MY_ITEM_TABLE1>’ it_records = lt_bookings ). " bookings CLEAR lt_sflight_arch. Lo_write->put_data_records( iv_table_name = ‘<MY_ITEM_TABLE2>’ it_records = lt_tickets ). " tickets CLEAR lt_sflight_arch. Lo_write->put_data_records( iv_table_name = ‘<MY_ITEM_TABLE3>’ it_records = lt_invoices ). " invoices CLEAR lt_sflight_arch. " write data object into the archive file lo_write->close_data_object( ). ENDLOOP. " finalize and end writing lo_write->finalize( ).