Documente Academic
Documente Profesional
Documente Cultură
No part of this brochure may be reproduced or transmitted in any form or for any purpose
without the express permission of SAP AG. The information contained herein may be changed
without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software
components of other software vendors.
Microsoft®, WINDOWS®, NT®, EXCEL®, Word® and SQL-Server® are registered trademarks of
Microsoft Corporation.
IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®,
AS/400®, OS/390®, und OS/400® are registered trademarks of IBM Corporation.
UNIX®, X/Open®, OSF/1® and Motif® are registered trademarks of the Open Group.
SAP, the SAP logo, mySAP.com, R/2, R/3, RIVA, ABAP, SAP-EDI, SAP Business Workflow, SAP
EarlyWatch, SAP ArchiveLink, ALE/WEB, BAPI, SAPPHIRE, Management Cockpit, SEM, are
trademarks or registered trademarks of SAP AG in Germany and in several other countries all
over the world. All other products mentioned are trademarks of their respective companies.
2
Data Archiving and Archive Development Kit
Contents
Introduction to Data Archiving 4
3
Data Archiving and Archive Development Kit
4
Data Archiving and Archive Development Kit
5
Data Archiving and Archive Development Kit
The Archiving Process tween the database and the archive file. If an error oc-
Data archiving allows you to archive data in parallel to curs, you can restart the archiving process because the
normal R/3 operations. The archiving programs are data is still either in the database or in an archive file.
scheduled as background jobs and can run during pro- Graphic 3 gives an overview of the archiving process:
duction (online) operation. Data objects such as financial documents are grouped
You do not have to backup the database before you start together and written to the archive files.
the archiving process. However, we recommend you For permanent storage, you can automatically or manu-
backup the archive files. ally store the archive files in an external storage system
Data archiving consists of two basic steps: using SAP ArchiveLink or the Content Management
Service (CMS). Alternatively, you can use Hierarchical
■ Generating archive files:
Storage Management (HSM), redundant array of inde-
The archiving program writes the selected data from
pendent disks (RAID) system, or a tertiary storage sys-
the database to archive files in a magnetic file system
tem, such as a tape system.
(hard disk).
■ Deleting the data: As of Release 4.6C, you have the following choices when
The delete program first reads the data from the ar- moving the archive files to permanent storage:
chive file and then deletes the corresponding data in ■ Store after deleting
the database. After the data is written to the archive file, the data is
This two-phase process guarantees data protection if deleted from the database. Then, the archive file is
problems occur during the archiving process. For exam- moved to the storage system and deleted from the file
ple, the procedure traps network data transfer errors be- system. Choose this option for higher performance.
6
Data Archiving and Archive Development Kit
■ Store before deleting Within the data archiving environment, there are also
After the data is written to the archive file, the archive the following functions:
file is moved to the storage system. After this is com- ■ Tables/archiving objects
pleted, the data is read from the archive file to deter- Display the relationships between database tables and
mine which data is to be deleted from the database. archiving objects as well as display space statistics
Choose this option for increased data security. ■ Archive information system (SAP AS)
A third option offers a balance between good perform- Access individual data objects in the archive file
ance and data security: ■ Customizing
After the data is archived, the archive file is stored in Maintain the object-specific and cross-object data
the storage system, but the archive file is not deleted archiving parameters as well as file names and paths
from the file system. Then, the data is read from the ■ Job overview
archive file in the file system to determine which data Display archiving jobs
is to be deleted from the database. ■ Data archiving monitor
Monitor and analyze information about writing of
To increase data security during archiving even further,
archive files (write jobs) and deletion of data from the
verification information can be written to the archive
database (delete jobs) during an archiving session.
files along with the data. The system uses this verifica-
tion information to check archive files during delete,
read, and reload sessions. This allows the system to rec-
ognize corrupt files in time and notify the user. For ex-
ample, no delete operation at all is executed in the data-
base for a corrupt archive file.
Archive Administration
Archive administration (transaction SARA) is the central
starting point for all data archiving activities.
7
Data Archiving and Archive Development Kit
Archive Development Kit (ADK) storage formats. This is only done temporarily during
read access. The data in the archive file is not changed.
Archive management is based on the Archive Develop-
ment Kit (ADK), a software layer between SAP applica- The following items are changed (if necessary) during an
tions and an archive that encapsulates the technical online conversion:
aspects of data archiving programs. This means that ar- ■ Database table structure (new and deleted columns)
chiving programs do not need to deal with file manage- ■ Data type of a column
ment or job scheduling. ADK provides an application ■ Column length
programming interface, also used by SAP developers, ■ File encoding (ASCII, EBCDIC, or specific code pag-
that customers and partners can use for the development es)
of new archiving solutions. ■ Number format (such as the use of the integer format
on various hardware platforms)
The ADK provides the functions necessary for data ar-
chiving. It supports the development of archiving and If database structures have changed more than the ADK
delete programs, as well as read and analysis programs. can handle, for example, fields have been moved from
Graphic 4 clarifies the concept of ADK and archive man- one table to another or a table has been divided into sev-
agement in the context of the SAP System. eral others, the application will take care of these chang-
es, or will provide a program for the permanent conver-
When archived data is read, the system automatically sion of existing archive files.
makes the required conversions due to any hardware and
software changes. When archived files from Release 2.1 on During archiving, data is automatically compressed by
are accessed, ADK takes database structural changes into up to a factor of five. However, if the data to be archived
account. ADK also handles different hardware-dependent is stored in cluster tables, it is not further compressed.
8
Data Archiving and Archive Development Kit
Data Flow
Structure of an Archiving Program
Archiving Program
9
Data Archiving and Archive Development Kit
Data Flow
Delete Program
10
Data Archiving and Archive Development Kit
Data Flow
Read Program
11
Data Archiving and Archive Development Kit
ARCHIVE_OPEN_FOR_READ
This function module opens archives for reading. A han-
dle is created, through which an archive file can be read.
You can also open several archive files at the same time;
they all share one handle. Function modules that read
using this handle treat all the files for this handle as a
12
Data Archiving and Archive Development Kit
single file. Every call of the function module generates tion module, not by the ABAP statement ROLLBACK
a new handle. This enables simultaneous processing of WORK. This function module guarantees the correct re-
several archives (even from different archiving objects. setting of the data for all archiving classes used.
ARCHIVE_OPEN_FOR_WRITE ARCHIVE_SAVE_OBJECT
This function module creates a new archive file and a This function module writes a data object into an archive
handle with which you have write access to this file. file. The data passed by ARCHIVE_PUT_RECORD, as well
as the data passed via the archiving classes, is saved.
If you have not specified a logical file name in archive
Customizing, the platform-independent logical file name If the data object no longer fits in the current archive file,
ARCHIVE_DATA_FILE is automatically used to deter- the file is closed and a new archive file is automatically
mine a platform-dependent physical file name. opened. The delete program is also called automatically
if requested by the Customizing setting.
You can also specify, with control parameters, whether
the delete program for the archived data should be called ARCHIVE_WRITE_STATISTICS
automatically after writing.
This function module creates a statistics print-out for the
ARCHIVE_PUT_RECORD data objects you have written to the archive files with
ARCHIVE_SAVE_OBJECT.
This function module passes data records to the data
container previously requested by function module
ARCHIVE_NEW_OBJECT. All records you transfer to the
data container are written to the archive file when func-
tion module ARCHIVE_SAVE_OBJECT is called.
ARCHIVE_READ_OBJECT
For an archiving object, this function module reads a
particular data object from an archive file (random ac-
cess) and returns a handle for further processing. If a
data object was read from an archive, you can access the
data records using function modules ARCHIVE_GET_
NEXT_RECORD or ARCHIVE_GET_NEXT_STRCT_SPECIF.
ARCHIVE_RELOAD_OBJECT_DATA
This function module calls the reload routines of the ar-
chiving classes registered for the archiving object.
ARCHIVE_ROLLBACK_WORK
If a ROLLBACK WORK has to be carried out in a delete
or reload program, it must be done by calling this func-
13
Data Archiving and Archive Development Kit
REPORT SBOOKA.
****************************************************************************
* This is an example of how to use the ADK function modules. *
* This demo ARCHIVING program is part of the archiving object *
* BC_SBOOK. It creates a new archive session based on the data model *
* BC_TRAVEL. Actually, it only archives the database table SBOOK. *
* For production use, you have to include proper exception handling. *
****************************************************************************
* data declaration
TABLES: sbook.
DATA: button(1) TYPE c,
create(1) TYPE c VALUE X,
no_delete(1) TYPE c VALUE X,
handle LIKE sy-tabix,
sbook_itab TYPE TABLE OF sbook WITH HEADER LINE,
data_object_id LIKE arch_idx_s-obj_id.
14
Data Archiving and Archive Development Kit
LOOP AT sbook_itab.
CONCATENATE sy-mandt sbook_itab-carrid sbook_itab-bookid
INTO data_object_id.
15
Data Archiving and Archive Development Kit
REPORT sbookd.
**************************************************************************
* This is an example of how to use the ADK function modules. *
* This demo DELETE program removes data from the database table SBOOK. *
* At the same time, an index can be built up to support random access. *
* The related archiving program in archiving object BC_SBOOK is SBOOKA. *
* For production use, you have to include proper exception handling. *
**************************************************************************
* data declaration
CONSTANTS:
object LIKE arch_obj-object VALUE BC_SBOOK.
DATA:
handle LIKE sy-tabix,
buffer TYPE arc_buffer,
sel_files_itab TYPE TABLE OF arch_files,
sbook_wa LIKE sbook,
sbook_itab TYPE TABLE OF sbook,
commit_cnt LIKE arch_usr-arch_comit,
object_cnt TYPE i,
arkey LIKE arch_idx_s-archivekey,
object_id LIKE arch_idx_s-obj_id,
offset LIKE arch_idx_s-obj_offset,
index_tab TYPE TABLE OF arch_idx_s WITH HEADER LINE,
index_flag LIKE arch_usr-arch_index,
sum_objects TYPE i VALUE 0,
stat_itab TYPE TABLE OF arch_stat,
tabfield LIKE arch_stat.
16
Data Archiving and Archive Development Kit
* loop to get the next data object from the archive file(s)
CLEAR object_cnt.
DO.
ADD 1 TO object_cnt.
CALL FUNCTION ARCHIVE_GET_NEXT_OBJECT
EXPORTING
archive_handle = handle
IMPORTING
object_id = object_id
object_offset = offset
archive_name = arkey
EXCEPTIONS
end_of_file = 01.
IF sy-subrc = 1.
EXIT.
ENDIF.
IF index_flag IS INITIAL.
* no index is to be built according to customizing
ELSEIF testrun IS INITIAL.
MOVE: object_id TO index_tab-obj_id,
arkey TO index_tab-archivekey,
offset TO index_tab-obj_offset.
APPEND index_tab.
PERFORM save_index_tab ON COMMIT.
ENDIF.
Continuation
see next page
17
Data Archiving and Archive Development Kit
* provide statistics
tabfield-tabname = .
tabfield-count = sum_objects.
APPEND tabfield TO stat_itab.
tabfield-tabname = SBOOK.
APPEND tabfield TO stat_itab.
CALL FUNCTION ARCHIVE_GIVE_STATISTICS
EXPORTING
archive_handle = handle
TABLES
table = stat_itab.
* write statistics
CALL FUNCTION ARCHIVE_WRITE_STATISTICS
EXPORTING
archive_handle = handle
statistics_only_per_file = X.
18
Data Archiving and Archive Development Kit
* ---------------------------------------------- *
* FORM DELETE_FROM_TABLE *
* ---------------------------------------------- *
* global: sbook_itab, sum_objects
* ---------------------------------------------- *
FORM delete_from_table.
DATA: tabcount TYPE i VALUE 0.
DELETE sbook FROM TABLE sbook_itab. delete job restartable
COMMIT WORK.
DESCRIBE TABLE sbook_itab LINES tabcount.
sum_objects = sum_objects + tabcount.
REFRESH sbook_itab.
ENDFORM. DELETE_FROM_TABLE
* ---------------------------------------------- *
* Form SAVE_INDEX_TAB *
* ---------------------------------------------- *
* global: index_tab
* ---------------------------------------------- *
FORM save_index_tab.
DELETE arch_idx_s FROM TABLE index_tab.
INSERT arch_idx_s FROM TABLE index_tab
REFRESH index_tab.
ENDFORM. SAVE_INDEX_TAB
19
Data Archiving and Archive Development Kit
REPORT sbookr.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* This is an example of how to use the ADK function modules. *
* This READ program demonstrates reporting from/analyzing archives. *
* The only output is the number of records and the last record read. *
* It belongs to the archiving object BC_SBOOK based on BC_TRAVEL. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* data declaration
DATA: handle LIKE sy-tabix,
buffer TYPE arc_buffer,
sbook_wa LIKE sbook,
number_of_records_read TYPE i.
IF sy-subrc <> 0.
WRITE: / No file can be accessed(001).
EXIT.
ENDIF.
CLEAR number_of_records_read.
* loop to get the next data object from the archive file(s)
DO.
CALL FUNCTION ARCHIVE_GET_NEXT_OBJECT
EXPORTING
archive_handle = handle
EXCEPTIONS
end_of_file = 1
OTHERS = 2.
IF sy-subrc <> 0.
EXIT.
ENDIF.
20
Data Archiving and Archive Development Kit
ADD 1 TO number_of_records_read.
ENDDO.
ENDDO.
* when ...
* If the archive object contained more than one table
* (different buffer-rname), more cases would be needed.
ENDCASE.
21
Data Archiving and Archive Development Kit
22
Data Archiving and Archive Development Kit
23
SAP AG
Neurottstrasse 16
69190 Walldorf, Germany
Mailing address
69189 Walldorf, Germany
SAP information service
Tel. +49 (180) 5 34 34 24
Fax +49 (180) 5 34 34 20
www.mysap.com
www.sap.com
You can find this and other current literature on our home page in the media centers for each subject.