## 4.2.15.10.5  Reload Archived Data into the Database
Reloading is optional and should only be used in exceptional cases. The application must decide if a reload is necessary or not.
In the standard process, a reloading of archived data is not required, as archived data and direct access to individual data objects can be performed by using the Read API [page 1496].
There are two cases which need to be distinguished:
1. Data must be reloaded shortly after deleting data from the database within the archiving process. An example for this case would be if selection criteria were set wrongly for the archiving process.
2. Reload of archived data after a long period of time. In this case it must be ensured that references to and within the reloaded data are still available in database. Furthermore, it needs to be guaranteed that no table key conflicts exist. Since this is not a real error, it's strongly recommended not to reload the data in this case.
The runtime to reload archived data from an external storage system back into the database should be implemented in a central ABAP class. This ABAP class has to register interface IF\_ARCH\_RELOAD to be able to be selected in an archiving object definition in ADT.
CL\_ARCH\_RELOAD\_API (API to reload archived data)
| Method                                                         | Parameter                        | Description                                             |
|----------------------------------------------------------------|----------------------------------|---------------------------------------------------------|
| GET_INSTANCE Returns an instance of lete API. Reference to     | Importing: IV_ARCHIVING_OBJECT   | Nameof the archiving object which will be used          |
| the de- interface IF_ARCH_RELOAD_API                           | Importing: IV_ARCHIVING_SESSION  | Sessions of the archiving object which will be used     |
| the de- interface IF_ARCH_RELOAD_API                           | Importing: IV_TESTMODE           | Reload program runs in test mode                        |
| the de- interface IF_ARCH_RELOAD_API                           | Returning: RO_RELOAD_INSTANCE    | Instance of the reload API for further processing       |
| GET_SESSIONS_TO_RELOAD Read a data object from an archive file | Importing: IT_DATA_SELECTION     | Range on dates on which archive files have been created |
| GET_SESSIONS_TO_RELOAD Read a data object from an archive file | Importing: IT_USER_SELECTION     | Range on users which have created ar- chive files       |
| GET_SESSIONS_TO_RELOAD Read a data object from an archive file | Importing: IV_ARCHIVING_OBJECT   | Archiving object which will be used                     |
| GET_SESSIONS_TO_RELOAD Read a data object from an archive file | Returning: RT_SESSION_ATTRIBUTES | Archiving sessions' attributes                          |
## IF\_ARCH\_RELOAD\_API (Interface to reload archived data)
| Method                                                      | Parameter                       | Description                                         |
|-------------------------------------------------------------|---------------------------------|-----------------------------------------------------|
| GET_DATA_RECORDS                                            | Importing: IV_RECORDS_STRUCTURE | Nameof a structure of all data records in the table |
| Read records by structure from the cur- rent data object    | Exporting: ET_DATA_RECORDS      | Table containing the data records                   |
| GET_NEXT_DATA_OBJECT Read data object from the archive file | Exporting: EV_ARCHIVE_KEY       | Archive key according to archive man- agement       |
## IF\_ARCH\_RELOAD\_API (Interface to reload archived data)
|                                                               | Exporting: EV_END_OF_FILE Exporting: EV_ARCHIVING_SESSION   | Boolean values: TRUE (='X') FALSE (= ' ') Sessions of the archiving object which   |
|---------------------------------------------------------------|-------------------------------------------------------------|------------------------------------------------------------------------------------|
| RELOAD_DATA_FOR_OBJECT                                        |                                                             |                                                                                    |
| RELOAD_DATA_FOR_TABLE Reloading the data of an internal table | Importing: IV_TABLE_NAME                                    | DDIC structure name of an internal ta- ble                                         |
## FINALIZE
Open archive files will be closed
A typical flow of the archiving reload process would be as follows:
1. Determine archiving sessions which are still available for reload by using the method CL\_ARCH\_RELOAD\_API=&gt; GET\_SESSIONS\_TO\_RELOAD , with filter options on creating user and creation
2. date of the archive file.
2. Create an instance of the reload API and open the archiving reload session for one of the selected archiving sessions by using the method CL\_ARCH\_RELOAD\_API=&gt;GET\_INSTANCE .
3. Open the next data object via method GET\_NEXT\_DATA\_OBJECT . If the method returns EV\_END\_OF\_FILE = TRUE ('X') , continue with step 6 to call the method FINALIZE .
4. Reload the data of the object from the external storage system back into your database tables, either by:
- Use of the method RELOAD\_DATA\_FOR\_OBJECT
- Or use of the method RELOAD\_DATA\_FOR\_TABLE . This method needs to be called once for each table.
- Use of the method GET\_DATA\_RECORDS . With this method, the result needs to be used to perform your own INSERT statements.
5. Continue with the next data object. See step 3.
6. Finish the archiving reload session by calling the method FINALIZE .
An example coding snippet:
##  Sample Code
```
CONSTANTS: lc_object TYPE if_arch_api_types=>ty_object_name VALUE 'MY_OBJECT'. DATA:     lv_test TYPE abap_bool VALUE abap_true, lt_data TYPE STANDARD TABLE OF my_header_table, lv_session TYPE sarch_session_number. " get newest complete archiving session DATA(lt_sessions) = cl_arch_reload_api=>get_sessions_to_reload(           iv_archiving_object = lc_object ). SORT lt_sessions BY creation_date DESCENDING creation_time DESCENDING. READ TABLE lt_sessions ASSIGNING FIELD-SYMBOL(<ls_session>)
```
INDEX 1.
```
DATA(lo_reload) = cl_arch_reload_api=>get_instance ( iv_archiving_object =   lc_object iv_archiving_session = lv_session iv_testmode = lv_test ). " read next data object from archive file into internal memory DO. lo_reload->get_next_data_object( IMPORTING ev_end_of_file = DATA(lv_end_of_file) ev_archive_key = DATA(lv_archive_key) ev_object_offset = DATA(lv_offset) ). IF lv_end_of_file = abap_true. EXIT. ENDIF. " optional: remove " read archived data for table ZADK_SFLIGHT lo_reload->get_data_records( EXPORTING iv_record_structure = 'MY_HEADER_TABLE' IMPORTING et_data_records = lt_data ). " reload the data into the data base lo_reload->reload_data_for_object( ). " optional: delete data from customer owned index DELETE FROM <my_index_table> WHERE archive_key = @lv_archive_key. ENDDO. COMMIT WORK. lo_reload->finalize( ).
```