bc670_v46c_en_2001_09

247
BC670 Programming Display Functions BC670 Версия 46D 25.07.2003

Upload: debopriyo-mallick

Post on 24-Oct-2014

241 views

Category:

Documents


8 download

TRANSCRIPT

Page 1: BC670_v46c_en_2001_09

BC670 Programming Display FunctionsBC670

Версия 46D 25.07.2003

Page 2: BC670_v46c_en_2001_09
Page 3: BC670_v46c_en_2001_09
Page 4: BC670_v46c_en_2001_09

0

SAP AG 2002

BC670 Programming Display Functions

BC670BC670

Programming Display FunctionsProgramming Display Functions

The R/3 System Release 4.6C 2001, Q3 Mat. No.: 50041363

Page 5: BC670_v46c_en_2001_09

0.2

SAP AG 2002

Copyright 2002 SAP AG. Все права защищены.

Копирование и воспроизведение данного материала спомощью любых средств и в любых целях, как полностью, так и частично без предварительного разрешения SAP AG запрещены. Информация, содержащаяся в данном материале, может быть изменена без предварительного уведомления.

Все права защищены

Copyright

Торговые марки: некоторые программные продукты, реализуемые компанией SAP AG и ее дистрибуторами, содержат программные компоненты, являющиеся собственностью других производителей ПО.

Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® и SQL Server® являются зарегистрированными торговыми марками Microsoft Corporation.

IBM®, DB2®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390® и OS/400® являются зарегистрированными торговыми марками IBM Corporation.

ORACLE® является зарегистрированной торговой маркой ORACLE Corporation. INFORMIX®-OnLine for SAP и INFORMIX® Dynamic ServerTM являются

зарегистрированными торговыми марками Informix Software Incorporated. UNIX®, X/Open®, OSF/1® и Motif® являются зарегистрированными торговыми марками

Open Group. HTML, DHTML, XML, XHTML являются торговыми марками зарегистрированных

торговых марок W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. JAVA® является зарегистрированной торговой маркой Sun Microsystems, Inc. JAVASCRIPT® является зарегистрированной торговой маркой Sun Microsystems, Inc.,

используемой по лицензии на технологию, разработанную и внедренную Netscape. SAP, SAP Logo, R/2, RIVA, R/3, ABAP, SAP ArchiveLink, SAP Business Workflow,

WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP.com Logo и mySAP.com являются зарегистрированными торговыми марками SAP AG в Германии и нескольких других странах по всему миру. Все другие упоминаемые продукты являются торговыми марками или зарегистрированными торговыми марками соответствующих компаний.

Page 6: BC670_v46c_en_2001_09

0.3

SAP AG 2002

Технологии бизнес-интеграции I

SAP Business Workflow - введение

BC600 2 дня

Уровень 2 Уровень 3

ПотокоперацийSAP Business

Workflow -программирование

BC610 3 дня

Архивация

SAP ArchiveLink

BC615 3 дня

ADK - программирование архивного восстановления

BC670 2 дня

Web-соединениеSAP Business Connector

BIT530 2 дня

Архивация данных

BC660 3 дня

SAP Business Workflow -создание и использование

BC601 5 days

Инструмент хранения архивных данных (DART)

BC680 2 дня

Page 7: BC670_v46c_en_2001_09

0.4

SAP AG 2002

Технологии бизнес-интеграции II

Технология бизнес-интеграции

BC095 3 дня

Уровень 2 Уровень 3

Перенос данных

BC420 5 дней

BAPI: программиро-вание на Visual Basic

*CA925 5 дней Программирование интерфейсов

Обмен данными

Коммуникационные интерфейсы на ABAP

BC415 2 дня

BAPI: программиро-вание на JAVA

*CA926 5 дней

Разработка SAP Idoc-интерфейсов

BC621 1 деньТехнология SAP Idoc-интерфейсов

BC620 2 дня

Технология Application Link Enabling (ALE)

BC619 3 дня

EDI-интерфейс

CA210 4 дня*BC620 с 01/2002 BIT320

*BC619 с 01/2002 BIT300

*BC621 с 04/2002 BIT350

*CA925 с 01/2002 BIT525

*CA926 с 01/2002 BIT526

Page 8: BC670_v46c_en_2001_09

0.5

SAP AG 2002

Course Prerequisites

BC400BC405BC410BC660 or equivalent knowledge of SAP Data Archiving

Page 9: BC670_v46c_en_2001_09

0.6

SAP AG 2002

Target Group

Participants:

Members of data archiving project teams, who have to program customer-specific retrieval solutions

Duration: 2 days

Page 10: BC670_v46c_en_2001_09

1

SAP AG 2002

Contents:

Course Overview

Course Goals

Course Objectives

Course Content

Course Overview Diagram

Main Business Scenario

(C) SAP AG BC670 1

Page 11: BC670_v46c_en_2001_09

1.2

SAP AG 2002

This course will prepare you to:

Understand the logic of archiving and delete programs

Create customer-specific sequential read programs

Program business views of an archiving object in SAP AS

Display in SAP AS original documents belonging to an R/3 business object that have been archived using SAP ARCHIVELINK

Course Goals

(C) SAP AG BC670 2

Page 12: BC670_v46c_en_2001_09

1.3

SAP AG 2002

At the conclusion of this course, you will be able to:

Create customer-specific read programs

Create business views in SAP AS

Explain the procedure required to empty customer-specific tables using customer-specific archiving objects

Explain the procedure required to extend existing archiving objects to archive customer-specific tables

Course Objectives

(C) SAP AG BC670 3

Page 13: BC670_v46c_en_2001_09

1.4

SAP AG 2002

Unit 4 Program logicData Archiving

Unit 5 Sequential read progams

Unit 6 Direct read access to archived data

Unit 1 Course Overview

Unit 2 Process of Data Archiving

Unit 3 ADK Development Tools

Preface

Course Content

(C) SAP AG BC670 4

Page 14: BC670_v46c_en_2001_09

1.5

SAPAG 2002

Overview Diagram

The Data Archiving Process

ADK Development ToolsADK Development Tools

Program Logic in Data Archiving

Sequential Read Programs

Direct Access to Archived Data in SAP AS

Introduction START

(C) SAP AG BC670 5

Page 15: BC670_v46c_en_2001_09

1.6

SAP AG 2002

You work in the large enterprise TablesRUs. A large data archiving project has been installed and you are a member of the project team.Together with the user departments, you have created a requirements catalog.

Customer-specific read programs must be written.

Business views must be created in SAP AS.

Main Business Scenario

(C) SAP AG BC670 6

Page 16: BC670_v46c_en_2001_09

2

SAP AG 2002

The Process of Data Archiving

Data Object and Archiving Object

Access to Archived Data

Contents

The Process of Data Archiving

(C) SAP AG BC670 1

Page 17: BC670_v46c_en_2001_09

2.2

SAP AG 2002

Describe the process of Data Archiving

Explain the relevant components

At the conclusion of this unit, you will be able to:

Data Archiving Topic Objectives

SP AG 1999 S

(C) SAP AG BC670 2

Page 18: BC670_v46c_en_2001_09

2.3

SAP AG 2002

Course Overview Diagram

The Process of Data Archiving

Course Overview

ADK Development Tools

Program Logic in Data Archiving

Customer-Specific Read Programs

Business Views in SAP AS

Appendix

(C) SAP AG BC670 3

Page 19: BC670_v46c_en_2001_09

2.4

SAP AG 2002

Data Archiving: Business Scenario

The user department, IT department, and the project team meet to discuss the existing data archiving solution within their enterprise.

They also list the options in the standard SAP System for accessing archived data.

SP AG 1999 S

(C) SAP AG BC670 4

Page 20: BC670_v46c_en_2001_09

2.5

SAP AG 2002

The Archiving Process

R/3 R/3 DatabaseDatabase

Archiving objectDocuments/Data objects

R/3 Database

Data archiving session

Archivefiles

Offlinestorage

File system

optional /manual

R/3 documents are made up of records, which are stored in different tables in the R/3 database.For the purposes of data archiving, a concrete R/3 document is a data object.

The data archiving process is composed of two steps.Creation of archive files - The archiving program writes the files for archiving from the R/3 database to archive files.Deletion of data - The delete program first reads the data in the archive files and then deletes the records from the database.

The removal of archive files to a tertiary storage medium can be seen as a third step in the archiving process. This step occurs after the first two steps of the data archiving procedure have been completed.You should consider this third step to be part of the archiving process: It is not generally enough to write the data to be archived to archive files and delete it from the database. The archive files must be stored and managed to guarantee future access when required.

(C) SAP AG BC670 5

Page 21: BC670_v46c_en_2001_09

2.6

SAP AG 2002

Data Objects in R/3

001 1000 1900000 1999 KR 1.2.99 5.2.99 ...001 1000 1900001 1999 KR 1.2.99 5.2.99 ...001 1000 1900002 1999 KR 1.2.99 5.2.99 ...

......

001 1000 1900000 1999 50 02 157,60 134,50 001 1000 1900001 1999 50 02 45,30 33,70 001 1000 1900002 1999 50 02 230,00 200,40

......

TableBKPF

001 1000 1900000 1999 001 A1 175000 01 H001 1000 1900001 1999 001 A2 175000 02 H 001 1000 1900002 1999 001 A0 400000 01 H

......

........

1000 1900000 1999

1000 1900001 1999

1000 1900002 1999

......

R/3 business documents

TableBSEG

TableBSET

R/3 database tables

unique key

R/3 business documents are distributed across different tables in the R/3 database. The FI document 1000 1900000 1999 represents a concrete data object in R/3. Within the data archiving framework, all table records belonging to a data object are written together

(in context) to an archive file and then deleted from the database tables.

(C) SAP AG BC670 6

Page 22: BC670_v46c_en_2001_09

2.7

SAP AG 2002

Structure descriptionTable BKPF

Structure descriptionTable BSET

Structure descriptionTable BSEG

Structure descriptionTable BVOR

Structure descriptionTable BSEC

Archiving Objects (1)

.........

Archiving objectFI_DOCUMNT

The STRUKTURE DEFINITION of anarchiving object describes which tables are to be processed during data archiving

An ARCHIVING OBJECT is a set of linked business data, which is periodically extracted from the database, archived, and deleted according to individual criteria from the current system.

Additional examples of archiving objects:

SD_VBAK Data structure OrdersSD_VBKA Data structure Sales activitiesRV_LIKP Data structure DeliveriesPP_ORDER Data structure Production orders

R/3 Release 4.6 contains more than 200 standard archiving objects. Archiving objects are defined by the individual applications. You can create customer-specific archiving objects for customer-specific Z and Y tables.

(C) SAP AG BC670 7

Page 23: BC670_v46c_en_2001_09

2.8

SAP AG 2002

Archiving objects

FI_DOCUMNTSD_VBAKSD_VBKASD_VBRKRV_LIKPCO_ITEM

AM_ASSETMM_EBANMM_EKKO

IDOCWORKITEMPS_PLAN

CO_ORDER......

Archiving Objects (2)

Structure definition

Programs for archivingand deletion

Archiving classes used

Customizingtechnical settings

Customizingresidence times/application

Read programs

Additional flags (for example ‘start at end’)

Information aboutthe points listed on the rightis stored in the system for every archiving object

Transaction AOBJ

An archiving object must have programs for archiving and deleting.Optional programs include programs for reloading, reporting, filling and emptying indexes, preprocessing and postprocessing.

The maintenance transaction is AOBJ. 'Start at end' is an example of an additional indicator that is analyzed after after an archiving session

when the deletion job is run. A further indicator enables you to specify whether an index can be created.

Application-specific Customizing generally contains criteria to determine whether documents are archivable or not. In addition to these criteria, a document must always have the status 'closed' before it can be archivable.

(C) SAP AG BC670 8

Page 24: BC670_v46c_en_2001_09

2.9

SAP AG 2002

Archiving: Step 1 - Data Archiving

R/3 R/3 DatabaseDatabase

Archiving program

Archive Archive filefile

During the first step, the archiving program creates an (initial) archive file.The data to be archived is read from the database by a batch process and written to the archive file. This process continues until one of the following occurs:

1. The archiving is finished: All the data for selection has been read and written2. The archiving is not yet completed but the archive file has reached the maximum size that was specified in Customizing.3. The archiving is not yet completed but the archive file contains the specified number of objects that was specified in Customizing.

Only data from completed business processes is archivable. Master data can only be archived if a deletion indicator has been set in it.

Some archiving objects set the deletion indicator in a specific preprocessing program within the framework of data archiving (for example, the archiving object CO_ORDER).

(C) SAP AG BC670 9

Page 25: BC670_v46c_en_2001_09

2.10

SAP AG 2002

ArchiveArchivefilefile

Archiving: Step 2 - Data Deletion Variant 1:Deletion Jobs Parallel to Archiving

R/3 R/3 DatabaseDatabase

Archivingprogram

Deleteprogram

ArchiveArchivefilefile

ArchiveArchivefilefile

Prerequisite:‘Start automat.’ is selected in technicalCustomizing for the archiving object

Deletion jobs startautomatically after an archivefile has been closed

Deleteprogram

There is one deletion process for each archive file created. The deletion process can be started in three different ways. Variant 1 for starting the delete program:

After closing an archive file, ADK opens a new one and continues with the archiving process. The system starts the delete program in parallel, which reads the archived records from the file which has just been closed and deletes them from the database.In this case, the delete jobs and the archiving jobs run in parallel.

For this variant, 'Start automatic.' must be set in 'Delete program settings' in technical Customizing of the archiving object.

(C) SAP AG BC670 10

Page 26: BC670_v46c_en_2001_09

2.11

SAP AG 2002

ArchiveArchivefilefile

ArchiveArchivefilefile

Archiving: Step 2 - Data Deletion Variant 2:Delete Jobs Started Manually

Administrator starts the deletionjobs MANUALLY in the data archiving transaction after the archiving session is finished

Prerequisite:‘Start automat.’ is not selectedin technical Customizing forthe archiving object

R/3 R/3 DatabaseDatabase

Deleteprogram

Deleteprogram

Variant 2 for starting the delete program:The delete program is scheduled manually by the administrator once all archive files have been closed.The archiving session is completely finished.There is one deletion process for each archive file created.

For this variant, the 'Start at end' indicator is set in the definition of the archiving object. 'Start automatic.' must NOT be set in 'Delete program settings' in the technical Customizing of the archiving object.

(C) SAP AG BC670 11

Page 27: BC670_v46c_en_2001_09

2.12

SAP AG 2002

ArchiveArchivefilefile

ArchiveArchivefilefile

Archiving: Step 2 - Data Deletion Variant 3:Delete Jobs Started Automatically

Delete jobs started AUTOMATICALLY after the archiving session has finished

Prerequisite:‘start at end’ is set in the definition of the archiving object

R/3 R/3 DatabaseDatabase

Deleteprogram

Deleteprogram

Variant 3 for starting the delete program:The delete program is scheduled manually by the administrator once all archive files have been closed.The archiving session is completely finished.There is one deletion process for each archive file created.

For this variant, the 'Start at end' indicator is set in the definition of the archiving object. 'Start automatic.' must NOT be set in 'Delete program settings' in the technical Customizing of the archiving object.

Once an indicator has been set in an archiving object, it can not be removed.

(C) SAP AG BC670 12

Page 28: BC670_v46c_en_2001_09

2.13

SAP AG 2002

ArchiveArchivefilefile

Archiving: Step 3 - Tertiary Storage Media

R/3 R/3 DatabaseDatabase

External storage system addressed via SAP ArchiveLink

HSM systems File system available only

to ADK

Create archive fileDelete data

‘Final storage location’ of archive files

ArchiveArchivefilefileArchiveArchive

filefileArchiveArchivefilefileArchiveArchive

filefile

There are various ways to store and administer archive files on external storage media.Archive management always knows the exact location of an archive file.Read/write authorizations are mandatory at UNIX-level for the directories used.

Connection to a Hierarchical Storage Management system (HSM): An HSM system simulates an 'infinitely large' file system. The archive files created during an archiving session are stored in the HSM file system. You just have to enter the HSM file system path in archiving object Customizing as the target path for the archive files.

Connection to an external archive system via SAP ArchiveLink: If you want to store the archive files on an external storage system via SAP ArchiveLink, the archive files can only be passed to the third-party product archive after the data has been successfully deleted from the database.

Manual administration: If you do not want to store the archive files on an external archive or in an HSM System, then the IT department can administer the files on tapes or CDs. There is no interface to these files from SAP R/3.

Ensure that backup strategies are in place for the relevant storage medium. It may also be necessary to make new copies of the contents of CDs or WORMs after a number of years.

(C) SAP AG BC670 13

Page 29: BC670_v46c_en_2001_09

2.14

SAP AG 2002

You now know:

Archiving Process: Summary

The steps of the archiving process

Writing data to archive files

Deleting data from database

Final storage of archive files ontertiary storage media

That archiving objects are the central components of data archiving

(C) SAP AG BC670 14

Page 30: BC670_v46c_en_2001_09

2.15Data Archiving and Working with Archived DataExercises

Unit: Data Archiving and Working with Archived Data

Topic The Process of Data ArchivingAccess using SAP AS

At the conclusion of this exercise, you will be able to:

Carry out the Customizing required to start the delete jobs

Explain the relationship between data objects and archiving objects

Create an archive information structure that links 2 tables

1-1 Control the delete job

1-1-1 Which Customizing setting must you implement to prevent the delete jobs from starting immediately so that you can schedule them manually?

1-1-2 Which setting leads to them starting immediately after an archive file has been closed?

1-1-3 Which setting enables you to start the delete jobs automatically after the complete archiving session is finished and all of the archive files have been closed?

1-2 Data Object and Archiving Object

1-2-1 What is a data object?

1-2-2 Where is the definition (within the context of data archiving) of a data object stored?

(C) SAP AG BC670 15

Page 31: BC670_v46c_en_2001_09

2.16Data Archiving and Working with Archived Data: Solutions

Unit: Data Archiving and Working with Archived Data

Topic The Process of Data ArchivingAccess using SAP AS

1-1 Solution to question 1-1

1-1-1 Tools, Administration, Management, Data ArchivingEnter the archiving objectButton <Customizing>Select ‘Technical Settings’Settings for delete program: ‘Start autom’ should not be selected.

1-1-2 Tools, Administration, Management, Data ArchivingEnter the archiving objectButton <Customizing>Select ‘Technical Settings’Settings for delete program: ‘Start autom’ should be selected.

1-1-3 Call transaction AOBJDouble click the archiving objectSelect ‘start at end’

1-2 Solution to question 1-2

1-2-1 Data objectFrom the ADK’s viewpoint, a data object is made up of all of the table records that make up an R/3 business document.

1-2-2 Call transaction AOBJSelect the archiving objectSelect dialog structure ‘structure definition’

(C) SAP AG BC670 16

Page 32: BC670_v46c_en_2001_09

3

SAP AG 2002

Overview of the ADK programming interface

Overview of archiving classes

Contents:

ADK Development Tools

(C) SAP AG BC670 1

Page 33: BC670_v46c_en_2001_09

3.2

SAP AG 2002

List the component parts of the ADK programming interface

Understand the use and application of archivingclasses

At the conclusion of this unit, you will be able to:

ADK Development Tools: Topic Objectives

SAP AG 1999

(C) SAP AG BC670 2

Page 34: BC670_v46c_en_2001_09

3.3

SAP AG 2002

Course Overview Diagram

Course Overview

The Data Archiving Process

ADK Development Tools

Data Archiving Programming Logic

Customer-Specific Read Programs

Business Views in SAP AS

Appendix

(C) SAP AG BC670 3

Page 35: BC670_v46c_en_2001_09

3.4

SAP AG 2002

ADK Development Tools: Business Scenario

Before work can begin, the developers must have an overview of the ADK programming interface.

SAP AG 1999

(C) SAP AG BC670 4

Page 36: BC670_v46c_en_2001_09

3.5

SAP AG 2002

ADK Programming Interface - ADK API

ADK includes a series of function modules that are are used by all programs on a cross-application basis during data archiving

These function modules write data to and read data from archive files.

The selection of data for archiving or deletion (that is, database access) must be defined in archiving and deletion programs in the relevant application.

As well as reading and writing data, ADK also undertakes conversion tasks within the framework of data archiving, for example: Codepage changes (for example, HP/UX to AS/400) Format conversion (for example, Compaq/Alpha to HP/UX) Structure changes (for example, additional table fields) Data compression and decompression

Since Release 3.0, ADK is the only means of archiving data from R/3 database tables.Archived data from Releases 2.1 and 2.2 are readable.

(C) SAP AG BC670 5

Page 37: BC670_v46c_en_2001_09

3.6

SAP AG 2002

ADK API - Function Group ARCH (1)

ADK function modules used inwrite programs

ARCHIVE_CLOSE_FILE ARCHIVE_GET_INFORMATION ARCHIVE_GET_NEXT_OBJECTARCHIVE_GET_NEXT_RECORD

ARCHIVE_GET_NEXT_STRUCT_SPECIFARCHIVE_GET_OPEN_FILES

ARCHIVE_GET_RECORD_INFOARCHIVE_GET_STATISTICS

ARCHIVE_GET_TABLEARCHIVE_GET_WITH_CURSOR

ARCHIVE_NEW_OBJECTARCHIVE_OPEN_FOR_CONVERSION

ARCHIVE_OPEN_FOR_DELETEARCHIVE_OPEN_FOR_MOVEARCHIVE_OPEN_FOR_READ

ARCHIVE_OPEN_FOR_WRITEARCHIVE_POPUP_CUSTOMIZING_DATA

ARCHIVE_PUT_RECORDARCHIVE_PUT_TABLE

ARCHIVE_READ_OBJECTARCHIVE_REGISTER_CLASS

ARCHIVE_RELOAD_OBJECT_DATAARCHIVE_ROLLBACK_WORK

ARCHIVE_SAVE_OBJECTARCHIVE_SET_RECORD_CURSOR

ARCHIVE_WRITE_STATISTICS

The function group ARCH includes the function modules for access to ADK archive files. The function group AADM contains function modules for managing ADK archive files. The group ARCH is essential for customer developments. Archiving programs are created by the respective applications. The application programs selection

and check logic. The application uses the function modules listed above as the interface to ADK.

(C) SAP AG BC670 6

Page 38: BC670_v46c_en_2001_09

3.7

SAP AG 2002

ADK API - Function Group ARCH (2)

ADK function modules used indelete programs

ARCHIVE_CLOSE_FILEARCHIVE_GET_INFORMATIONARCHIVE_GET_NEXT_OBJECT

ARCHIVE_DELETE_OBJECT_DATAARCHIVE_GET_NEXT_RECORD

ARCHIVE_GET_NEXT_STRUCT_SPECIF

ARCHIVE_GET_CUSTOMIZING_DATAARCHIVE_GET_OPEN_FILES

ARCHIVE_GET_RECORD_INFOARCHIVE_GET_STATISTICS

ARCHIVE_GET_TABLEARCHIVE_GET_WITH_CURSOR

ARCHIVE_GET_NEXT_OBJECTARCHIVE_GET_NEXT_RECORD

ARCHIVE_GIVE_STATISTICSARCHIVE_OPEN_FOR_CONVERSION

ARCHIVE_OPEN_FOR_DELETEARCHIVE_OPEN_FOR_MOVEARCHIVE_OPEN_FOR_READ

ARCHIVE_POPUP_CUSTOMIZING_DATAARCHIVE_READ_OBJECT

ARCHIVE_REGISTER_CLASSARCHIVE_RELOAD_OBJECT_DATA

ARCHIVE_ROLLBACK_WORKARCHIVE_SET_RECORD_CURSOR

ARCHIVE_WRITE_STATISTICS

Delete programs are created by the relevant applications. The application uses the function modules listed above as the interface to ADK.

(C) SAP AG BC670 7

Page 39: BC670_v46c_en_2001_09

3.8

SAP AG 2002

Where Can You Find the ADK API in R/3?

Function modules (for ADK processing) that are released for customers are located in the function group ARCH

Path:Tools -> ABAP Workbench -> Overview ->Object Navigator -> Function Group ARCH

Display the function group Expand the function modules

Documentation on ADK can be found under:BA-ABAP Workbench - BC Extended functin library - Archiving

(C) SAP AG BC670 8

Page 40: BC670_v46c_en_2001_09

3.9

SAP AG 2002

Archiving Classes (1)

Table BKPFArchiving class

change documentsTable CDHDR

Table VBAK

Data is archived using anarchiving object

Data is archived using anarchiving object

Data is archived using anarchiving class

1000 19000000 19941000 19000001 19941000 19000002 19941000 19000003 1994

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.1000 19999999 1994

4500000551 19944500000552 19944500000553 19944500000554 1994

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.4500000999 1994

Change1 1994 to1000 19000001 1994

Change2 1994 to1000 19000001 1994

Change1 1994 to1000 19999999 1994

Change1 1994 to4500000552 1994

Change1 1994 to1000 19000003 1994

Change1 1994 to4500000554 1994

Change1 1994 to4500000551 1994........

Use of archiving classes:Within the framework of FI- and SD-document archiving, the function modules for archiving the change document tables are called, and the change documents belonging to the relevant R/3 business objects are stored together with them in the archive file.

Archiving classes collect change documents. The archiving class Changedocu archives not only from CDHDR, but also from the second table

CDPOS. Data from archiving classes can only be accessed with the function modules belonging to the

archiving class itself.These function modules, which are tailored specifically to suit the archiving class data, are developed by the relevant applications.

Data that is stored using archiving classes is not transparent for ADK. ADK cannot interpret data. It reads archived data by using an application-specific function module.

(C) SAP AG BC670 9

Page 41: BC670_v46c_en_2001_09

3.10

SAP AG 2002

Archiving Classes (2)

Archiving classes

Function modules and form routines belonging to a business object which is not usually archived on its own, but which is used and archived more than once as a service function within the system.

Examples of archiving classes:SAPscript textsChange documentsVariant configurationsSAP ArchiveLink entriesIDOCsWork itemsHR time dataHR travel dataCO settlement documents......

SAP AG 1999

Release 4.6 contains 57 archiving classes. Archiving classes are maintained in transaction ACLA. Class-specific function modules are useful for customer-specific function modules that are required

to read data from archiving classes.Form routines are important for the communication between ADK and archiving classes.

(C) SAP AG BC670 10

Page 42: BC670_v46c_en_2001_09

3.11

SAP AG 2002

Archiving Classes (3)

Use of Archiving Classes

Archiving classes process complex, cross-archiving object, logical data objects.

Data structures are used and archived by various applications.

Archiving classes are created by the responsible persons from the development area

Note:Archiving classes are not developed in the ADK develoment environment, which is released to customers.

(C) SAP AG BC670 11

Page 43: BC670_v46c_en_2001_09

3.12

SAP AG 2002

Advantages of archiving classes

Reusability without additional workload

New archiving classes can be used easily to extend archiving objects

View of the object and not its physical data

Retention of data integrity

Contain archiving data and archiving methods

Central implementation of archiving functionality

Archiving Classes (4)

Archiving classes reflect an object-oriented approach and encapsulate the methods for accessing data.Because of the data encapsulation, the calling program no longer has to know the specific data structures and heirarchies. By using archiving classes, you can easily archive and read data for which you have no detailed knowledge.

(C) SAP AG BC670 12

Page 44: BC670_v46c_en_2001_09

3.13

SAP AG 2002

You now know:

ADK API: Conclusion

The scope of the ADKprogramming interface whichis released to customers

Archiving classes provide themeans to reduce the size of tableswhich are simultaneously filledby different applications

(C) SAP AG BC670 13

Page 45: BC670_v46c_en_2001_09

3.14ADK development tools Exercises

Unit: ADK development tools

Topic: Assign ADK function modules Assign archiving classes

At the conclusion of this unit, you will be able to:

find and assign ADK function modules within the system

explain the reason for archiving classes

assign the archiving classes used

1-1 ADK function modules

1-1-1 Which function groups contain function modules released for customers?

1-1-2 Take a look at the function modules.

1-1-3 Which are used for deletion, which for archiving?

1-2 Archiving classes

1-2-1 Why were archiving classes developed? Which data is archived/deleted with them?

1-2-2 Who creates archiving classes? Are customers allowed to create archiving classes?

1-2-3 Which archiving classes are used by the archiving object SD_VBKA?

(C) SAP AG BC670 14

Page 46: BC670_v46c_en_2001_09

3.15ADK Development Tools Solutions

Unit: ADK Development Tools

Topic: Assigning ADK function modules Assigning archiving classes

1-1 Solution to question 1-1

1-1-1 The modules are contained in the function group ARCH

1-1-2 Tools, ABAP Workbench, Overview, Object Navigator Select 'Function group' Entry: ARCH Button 'Display Open 'Function modules'

1-1-3 Write: Archive_open_for_write Archive_new_object Archive_put_record Archive_put_table Archive_save_object Archive_write_statistics Archive_close_file

Delete: Archive_get_customizing_data Archive_close_file Archive_get_next_object Archive_get_next_record Archive_open_for_delete Archive_delete_object_data Archive_write_statistics

1-2 Solution to question 1-2

1-2-1 Archiving classes read and write objects to tables, which are not filled by a specific business object, but which are used on a cross-application basis by R/3 .

1-2-2 Archiving classes are created by the responsible application. The development of archiving classes by customers is NOT supported.

1-2-3 Call transaction AOBJ Flag the archiving object SD_VBKA Select dialog structure 'archiving classes used'

Result: address, changedocu, cu_config, k_total, k_unitcost, text

(C) SAP AG BC670 15

Page 47: BC670_v46c_en_2001_09

(C) SAP AG BC670 16

Page 48: BC670_v46c_en_2001_09

4

SAP AG 2002

Contents:

Data Archiving Programming Logic

Definition of archiving objects

Constructing archiving progams

Function modules in archiving programs

Constructing delete progams

Function modules in delete programs

Important procedures when extending standard archivingobjects: example IS-OIL

(C) SAP AG BC670 1

Page 49: BC670_v46c_en_2001_09

4.2

SAP AG 2002

At the conclusion of this unit, you will know:

Data Archiving Programming Logic:Unit Objectives

The logic of archiving programs

The logic of delete programs

The procedure for creating a new archiving object

The procedure for extending a standardarchiving object

SAP AG 1999

(C) SAP AG BC670 2

Page 50: BC670_v46c_en_2001_09

4.3

SAP AG 2002

Overview Diagram

Course Overview

The Data Archiving Process

ADK Development Tools

Data Archiving Progamming Logic

Customer-Specific Read Progams

Business Views in SAP AS

Appendix

(C) SAP AG BC670 3

Page 51: BC670_v46c_en_2001_09

4.4

SAP AG 2002

Data Archiving Progamming Logic:Business Scenario

The progammers of customer-specificarchiving objects want to understand thelogic behind SAP data archiving

SAP AG 1999

(C) SAP AG BC670 4

Page 52: BC670_v46c_en_2001_09

4.5

SAP AG 2002

Availability of ADK API

ADK is available as a development tool:

SAP developers: for SAP standard objects

Customers: For customer-specific tables - not for SAP standard objects

Customers can use a developer’s key to extend the SAP standard system

Z and Y as an extension to an SAP archiving object

Customers can create access routines to archived data

Analysis reports

Direct access to a single document

Business views in SAP AS

SAP AG 1999

(C) SAP AG BC670 5

Page 53: BC670_v46c_en_2001_09

4.6

SAP AG 2002

An Archiving Object’s Programs

An archiving object’s programs

write programand

delete program

sequentialread program

readprogram

and / or

preprocessingprogram

single document access using

SAP AS

reloadprogram

postprocessingprogram

The minimum requirements for an archiving object are a write program and a delete program. Most archiving objects also contain additional reports and a single-document access function using

SAP AS. An archiving object can also contain programs for preprocessing, analysis, reloading and

postprocessing.Optionally, there is also an index progam for direct access to a single document in an archive file. However, direct single-document access is controlled using the generic functions of the Archive Information System (SAP AS). Index programs are therefore unnecessary.

You can create reload programs, but these should only ever be used immediately after an archiving session for situations where the wrong data has been selected for archiving.

The deletion indicator is often set for master data in the preprocessing program. Analysis programs make it easier to identify documents for selection and can identify documents that

cannot be archived due to business considerations.

(C) SAP AG BC670 6

Page 54: BC670_v46c_en_2001_09

4.7

SAP AG 2002

Creating an Archiving Object

Creating an archiving object

transaction AOBJ

The following entries are mandatory

Step 1: Archiving and delete progams

Step 2: Archiving object parameters

Step 3: Tables which are archived

Step 4: Customizing settings

Step 5: Where available: Archiving classes used

Step 6: Where available: Available read programs

(C) SAP AG BC670 7

Page 55: BC670_v46c_en_2001_09

4.8

SAP AG 2002

Transaction AOBJ - Release 3.1 to 4.5

/naobj

Navigation

Archiving object-->Tables which are archived-->Tables in which you only delete-->Maintain network graphicLevel 1 of 10

ObjectAM_ASSETAM_STEUERARCHIVELNKBANKENBC_ARCHIVEBC_DBLOGSBC_SBOOKBELEGCATPROARCHCA_KBLXCCMCALLBCKCCMLOGGINGCOPA1_IDEACOPA1_R300COPA1_S001COPA2_IDEACOPA2_R300COPA2_S001CO_ALLO_ST

Description of the archiving object Asset - master data, values and movementsAssets - tax tablesLink entries from ArchiveLinkTest for banksArchiving of archive management dataArchiving changes to Customizing tablesBC_TRAVEL-Demo: SBOOKFI documentCATT - Log/ProcedureIntern. RW docs. (Funds reserv./Fixed price/...)Callcenter-Callback Archiving CallbacksCall Center-Activity Logging ArchiveCosting-Based CO-PA, Operating Concern IDEACosting-Based CO-PA, Operating Concern R300Costing-Based CO-PA, Operating Concern S001Costing-Based CO-PA, Operating Concern IDEACosting-Based CO-PA, Operating Concern R300Costing-Based CO-PA, Operating Concern S001Completely cancelled documents

Archiving programRAARCH01RAARCH01OAARCH04

RSAADMARRSLDARCH01SBOOKA

RSCATPRARKBEARWRCCMCLBAACCMCLGAARK4AIDEARK4AR300RK4AS001RK4DIDEARK4DR300RK4DS001RKSARSWRPosition... Entry 1 of 172

New Entries Variable list

Table view Edit Goto Selection Utilities System Help Change View “Archiving Objects”: Overview

Navigation steps in transaction AOBJ:

Step 1: Archiving objectStep 2: Tables which are archived Step 3: Tables in which you only delete Step 4: Maintain network graphicStep 5: Customizing settingsStep 6: Archiving classes used Step 7: Read programs Step 8: Customizing transactions Step 9: Info tables belonging to archive files Step 10: Assignment of exit routines at generation

(C) SAP AG BC670 8

Page 56: BC670_v46c_en_2001_09

4.9

SAP AG 2002

Transaction AOBJ - Release 4.6

Dialog structureArchiving object

Structure definitionTables which you only del.Maintain network graphicCustomizing settingsArchiving classes usedRead progamsCustomizing transactionsAppl. information tablesExit-routine assignment

Object Description of archiving object CO_KSTRG Cost object with master and transaction dataCO_ML_BEL Material ledger docs (MLHD/IT/PP/PP...)CO_ML_DAT Material ledger records (CKMLPP, CKMLCR)CO_ML_IDX Index entries material document: ledgerCO_ML_ML1 Material ledger period records (CKML1)CO_ORDER Orders with transaction dataCO_PROCESS Business process incl. transaction dataCO_TEST Test onlyCS_BOM PP object listsCV_DVS Document management systemDATAFDLOG TR-TM: Record accesses to datafeedEC_PCA_SUM Profit-Center-Rechnung: SummensätzeEIS_CF001 Archive object for aspect CF001EIS_CF002 Archive object for aspect CF002EIS_CF003 Archive object for aspect CF003EIS_CF004 Archive object for aspect CF004EIS_CF005 Archive object for aspect CF005EIS_CF006 Archive object for aspect CF006EIS_CF050 Archive object for aspect CF050EIS_CF501 Archive object for aspect CF501EIS_CF502 Archive object for aspect CF502EIS_CF503 Archive object for aspect CF503

Position Entry 1 of 182

(C) SAP AG BC670 9

Page 57: BC670_v46c_en_2001_09

4.10

SAP AG 2002

Minimum Requirements per Archiving Object (1)

Transaction AOBJ - archiving object Enter the available programs

Programs for the following processes can or must be available for an archiving object:

Preprocessing (optional)

Create archive file(s)

Delete data from database

Postprocessing (optional)

Reload data to the database (optional)

SAP AG 1999

Possible functions of preprocessing progams: Set the deletion indicator in the master data (for example, in PP)Determine archivable data (for example, in SD)

Archiving objects with postprocessing progams (Release 4.5A):QM_CONTROLPA_PDOCFI_DOCUMNTCATPROARCH

The postprocessing progam for the archiving object FI_DOCUMNT (FI documents) for example, deletes data from the FI indexes.

You can find SAP Notes on archiving objects in transaction SARA by choosing the ‘i’ symbol in the activity screen (schedule archiving, schedule deletion,...).

(C) SAP AG BC670 10

Page 58: BC670_v46c_en_2001_09

4.11

SAP AG 2002

Minimum Requirements per Archiving Object (2)

SAP AG 1999

Transaction AOBJ - Archiving object Entering definition flags

-> Build index-> Start at end-> Cross-client-> End dialog-> Invalid flag-> No reload files

Cross-application: The transaction SARA is client-specific. You can set this indicator if you want to work on a cross-client basis.

End dialog: During archiving, R/3 dialog operations should be stopped in order to avoid data collisions. When scheduling the jobs, the administrator receives a warning that further checks will not be carried out.

Invalid: If archiving sessions are incomplete and there is no completed status, you can mark the entry as invalid in archive administration.If the invalid indicator is set for an archiving object, the indicator for invalid archive files cannot be reversed in archive managment.

no r. files (from Release 4.0A): When reloading data to the database, new archive files are created if not all of the data from a session was reloaded. If this indicator is set, the system will not create any new files.

Prg.generated: Archiving objects that work with statistical or controlling data, generate their programs based on individual user inputs at runtime. Example: MKIS, COPA1_*

Build index: The archiving object is usually able to construct an index. There must also be an index build program stored in AOBJ.

(C) SAP AG BC670 11

Page 59: BC670_v46c_en_2001_09

4.12

SAP AG 2002

Minimum Requirements per Archiving Object (3)

Transaction AOBJ - structure definition

Enter the tables, from which you want to archive data

The entries represent the archiving object’s data model

Transaction AOBJ - Customizing settings

Technical settings, such as file sizes, commit counter, delete program variants, connection to external storage system

The technical settings can be maintained by the user in transaction SARA

Entries in the structure definition:Record no.: order definition only

Parent segment: Name of the next highest structure in the hierarchy. Therefore, for the first record, this field remains empty. From Release 3.0, entries are also only for defining the order.In Release 2.2, archiving was organized hierachically.

Segment: Subordinate segment in the archive heirarchy. Name of the structure belonging to the archiving object. This field informs ADK (and its function module) which tables are to be processed.

The ADK uses the entries for the following functions:- Metadata for the archive file that is to be written- Information basis for transaction DB15

Structure: If a structure name is entered here, this structure will be used for conversions. This is essential if you are working with logical databases and the structure name entered under segment is a pseudonym for a real structure. ADK uses the entries in the same way as was described for segments (see above).

Technical Customizing:From 4.6A, the commit counter can only be maintained in transaction AOBJ.

(C) SAP AG BC670 12

Page 60: BC670_v46c_en_2001_09

4.13

SAP AG 2002

Minimum Requirements per Archiving Object (4)

Transaction AOBJ - archiving classes used

Enter the archiving classes that the archiving object uses

An entry in transaction AOBJ means that the archiving classis used by the archiving object

Transaction AOBJ - read programs

if the available read programs are entered, then the programscan be called from the context of the archiving transactionSARA

It is necessary to enter the archiving classes in AOBJ so that transaction DB15 and the Archive Information System consider the archiving classes.

Transaction DB15 determines the tables that belong to an archiving object or, conversely, the suitable archiving object for a table.

(C) SAP AG BC670 13

Page 61: BC670_v46c_en_2001_09

4.14

SAP AG 2002

Minimum Requirements per Archiving Object (5)

Transaction AOBJ - Customizing transactions

Group of transactions in which application-specific Customizing must be carried out

In application-specific Customizing, the applications allowcriteria for the archivability of data to be entered, which are checked during an archiving session.

For transaction data, this is mainly defining residence times. For master data, this is mainly setting deletion indicators.

The application-specific settings are carried out withinapplication Customizing.

SAP AG 1999

(C) SAP AG BC670 14

Page 62: BC670_v46c_en_2001_09

4.15

SAP AG 2002

Support Components in R/3

R/3 >= 4.5A: Example archiving object ‘BC_SBOOK’ with progams for

Writing archive files (SBOOKA)

Deleting archived data from the database (SBOOKD)

Reporting from archive files (SBOOKR)

Filling an archive index (SBOOKI)

R/3 < 4.5A: Example archiving object ‘EXAMPLE’

Progams similar to SBOOKRSARCH04, RSARCH06, RSARCH19, RSARCH15

Single-document read RSARCH13

SAP AG 1999

Note:The archiving object EXAMPLE only simulates deletion of data from the database.

Functionality ‘read single document’ for SBOOK is realised via SAP AS; The index construct program has a greater documentation character.

(C) SAP AG BC670 15

Page 63: BC670_v46c_en_2001_09

4.16

SAP AG 2002

Programming Logic: ‘Archiving’ (1)

Authorization check

Read selection

Read Customer-Specific Customizing

Data selection

Implement check logicfrom a business logic point of view

Authorization checks include the - authorizations for calling ADK function modules - authorizations for maintaining AOBJ- authorizations for creating and managing jobs- authorizations from the relevant application for writing the archive file - authorizations for maintaining the application-specific archiving Customizing

You must make sure that checks are implemented in exactly the same way as in online operations.The selection of data from the database should be as specific as possible. Avoid reading unnecessary data relating to authorization checks.

The person responsible for the archiving must enter the required criteria in the selection screen. In the data selection, the database data is collected according to the selection criteria. The check logic establishes whether data records are archivable. It examines the residence times in

application-specific Customizing as well as specific additional internal check logic.

(C) SAP AG BC670 16

Page 64: BC670_v46c_en_2001_09

4.17

SAP AG 2002

Programming Logic: ‘Archiving’ (2)

Write data object: ADK API used

Archive_open_for_write

Do

Archive_new_object

Archive_put_record

TEXT_ARCHIVE_OBJECT (Archiving FM belonging to an archiving class)

Archive_save_object

Enddo

Archive_write_statistics

Archive_close_file

ARCHIVE_NEW_OBJECT prepares a data container in the main memory. This function module also ensures communication with any archiving classes.

ARCHIVE_PUT_RECORD writes a record in the prepared data container. TEXT_ARCHIVE_OBJECT is the archiving function module for the archiving class TEXT. It is

used to collect archiving class data for an object and to store it in its own data area on the main memory.

In ARCHIVE_SAVE_OBJECT, ADK takes the records from the data container and compresses it. From the archiving classes, ADK requests the compressed archiving class data for the object and writes it to the ADK file. At present, ADK cannot subsequently decompress this data.

ARCHIVE_CLOSE_FILE releases all resources and starts the delete program if ‘Start autom.’ has been selected in Customizing.If you forget the Archive_Close_File, the last archive file is not closed.

(C) SAP AG BC670 17

Page 65: BC670_v46c_en_2001_09

4.18

SAP AG 2002

ADK API: ARCHIVE_OPEN_FOR_WRITE

Interface parameter export

archive_handle

Interface parameter import

call_delete_job_in_test_mode, create_archive_file

object, comments

Function module functionality:

Create archive file in the file system

Create archive handle

ADK has multi-instance capability.Each handle addresses one instance. In one program, more than one archive can be read in parallel. The handle, as it is used in ADK, is comparable with a file handle in the file management system.

In transaction AOBJ “Customizing settings” you can specify whether the delete program for the archived data is to be called automatically.

The archiving function modules use platform-independent filenames to create new archive files. In transaction AOBJ “Customizing settings”, you can specify the platform-independent filenames that are to be used for your archiving object. If you have not defined a filename, the system will automatically use the platform-independent filename ARCHIVE_DATA_FILE to create the server-independent filename.

The import parameters mentioned do not come from the technical settings for the archiving object. They are selection parameters.In the Comments parameter, you can enter a text that is automatically saved as management data during the session.

The function module informs the archiving classes used and makes an entry in the archive management that signifies that an archiving session is in progress.

(C) SAP AG BC670 18

Page 66: BC670_v46c_en_2001_09

4.19

SAP AG 2002

ADK API: ARCHIVE_NEW_OBJECT

Interface parameter importarchive_handle

Function module functions:Initializes a new data object Discards the processed data

This function module should always be called if a new data object is to be prepared for writing to an archive.

There can only be one data object per handle. When this function module is called, all of the data from the current data object is forgotten, and all of the accompanying archiving classes are informed that the following operations with this handle belong to a new data object.

The archiving classes will forget all of the information about the current data object.

The system does not check whether you have stored the current data object with the function module ARCHIVE_SAVE_OBJECT.

(C) SAP AG BC670 19

Page 67: BC670_v46c_en_2001_09

4.20

SAP AG 2002

ADK API: ARCHIVE_PUT_RECORD

Interface parameter import

archive_handle

record_flag

record_structure

record

Function module functions:

With this function module, you can transfer a data record to the data object that was previously requested with the function moduleARCHIVE_NEW_OBJECT. All of the data records that you pass to the data object are written together to the archive file when you call the function moduleARCHIVE_SAVE_OBJECT .

The import parameter ‘record_flag’ is available for any supplementary information. For example, FI uses it to mark records that are to be deleted.

The import parameter ‘record_structure’ is given the name of the structure that is to be transferred. This name must be stored in the structure definition in AOBJ.

The actual transferred data is transferred to the import parameter ‘record’.If the structure named under ‘record_structure’ is not the same as the record in ‘record_real’, the system may issue the runtime error ‘Archive cannot be read’

For complex data objects, you might have to first read and analyse all of the data records, before you can decide whether this data object is to be archived.

You do not have to remember the data records, or even re-read the data records from the database. You can use the function mode to transfer the data records to the data object immediately.

If you realize that the data records that you transferred should not be archived, call the function module ARCHIVE_NEW_OBJECT. This ensures that the data that you transferred is discarded. The data that you transferred to the archiving classes for archiving is also discarded.

(C) SAP AG BC670 20

Page 68: BC670_v46c_en_2001_09

4.21

SAP AG 2002

ADK API: ARCHIVE_PUT_TABLE

Interface parameter import

archive_handle

record_structure

Interface table

table

Function module functionality:

With this function module, you transfer an internal table to the data object that was called previously with the function module ARCHIVE_NEW_OBJECT.Each line of the internal table is placed in the data object as a separate data record. All transferred data records are written together to the archive file when you call the function module ARCHIVE_SAVE_OBJECT

In the ‘record_structure’ parameter, you enter the name of the name of the structure/table whose objects are to be written.

The data is transferred to an internal table via the table interface. If required, an archiving program typically selects all line items for one document in an internal

table. This internal table can be transferred, record by record, in its entirety to ADK.

(C) SAP AG BC670 21

Page 69: BC670_v46c_en_2001_09

4.22

SAP AG 2002

ComparisonARCHIVE_PUT_RECORD - ARCHIVE_PUT_TABLE

Writes one record each

More coding

Lower performance as records are processed per record

Writes array of records

Less coding required as no loop construction

Better performance as records notwritten individually

(C) SAP AG BC670 22

Page 70: BC670_v46c_en_2001_09

4.23

SAP AG 2002

ADK API: ARCHIVE_SAVE_OBJECT

Interface parameter export

archive_name

object_offset

Interface parameter import

archive_handle

Function module functionality :

This function module writes a data object to the archive file. As well as the data transferred with thefunction module ARCHIVE_PUT_RECORD, the data that was transferred via the archiving classes will also be taken into account.

The export parameter object_offset enables you to find the object in the ADK archive file.

The parameter archive_name returns the key for the ADK archive file.

If the data object does not fit into the current archive file, the system closes the archive file and opens a new archive file. The system then automatically calls the delete progam, unless this option was switched off in transaction AOBJ "Customizing settings".

(C) SAP AG BC670 23

Page 71: BC670_v46c_en_2001_09

4.24

SAP AG 2002

ADK API: ARCHIVE_WRITE_STATISTICS

Interface parameter import

archive_handle

statistics_only_per_run

statistics_only_per_file (from Release 4.6)

Function module functionality :

With this function module, you can create statisticsabout data objects that you have written to an archive file using function module ARCHIVE_SAVE_OBJECT. These statistics are written as a list and therefore appearin the archiving program log.

You can use the import parameter ‘statistics_only_per_run’ to request totals statistics for the whole arhiving session. The parameter ‘statistics_only_per_file’ provides statistics for one archive file and is, for this reason, only useful when used with a delete program.

You must call this function module immediately before the function module ARCHIVE_CLOSE_FILE , otherwise you will obtain incorrect values in the number fields.

The size of the archive file in MB also appears in the output. If you run the archiving program for a limited selection in test mode, you can use this output to estimate the required disk space.

(C) SAP AG BC670 24

Page 72: BC670_v46c_en_2001_09

4.25

SAP AG 2002

ADK API: ARCHIVE_CLOSE_FILE

Interface parameter import

archive_handle

Function module functionality :

The function module closes the archive file. The resources which were allocated for a handle arereleased. The handle is then invalid and can no longer beused. Every additional operation with this handle triggersthe exception WRONG_ACCESS_TO_ARCHIVE

This function module is not only called when writing archives, but also within every ADK function.

(C) SAP AG BC670 25

Page 73: BC670_v46c_en_2001_09

4.26

SAP AG 2002

Example Report SBOOKA (1)

REPORT sbooka.

* data declarationTABLES: 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.

* selection criteria and parametersSELECTION-SCREEN BEGIN OF BLOCK arch_booking WITH FRAME TITLE text-101.SELECT-OPTIONS: o_carrid FOR sbook-carrid

DEFAULT 'LH ',o_order FOR sbook-order_date

DEFAULT '19000101' TO '20020101'.SELECTION-SCREEN END OF BLOCK arch_booking.

(C) SAP AG BC670 26

Page 74: BC670_v46c_en_2001_09

4.27

SAP AG 2002

Example Report SBOOKA (2)

SELECTION-SCREEN BEGIN OF BLOCK arch_control WITH FRAME TITLEtext-102.PARAMETERS: no_file LIKE button RADIOBUTTON GROUP radi,

del_test LIKE button RADIOBUTTON GROUP radiDEFAULT 'X',

del_prod LIKE button RADIOBUTTON GROUP radi.SELECTION-SCREEN END OF BLOCK arch_control.

PARAMETERS comments TYPE admi_text LOWER CASEDEFAULT 'This is test data for archiving with

BC_SBOOK'(103).

* select data from the databaseSELECT * FROM sbook INTO TABLE sbook_itab

WHERE carrid IN o_carrid ANDorder_date IN o_order.

* build ADK parameters from chosen buttonIF no_file = 'X'. create = ' '. no_delete = ' '. ENDIF.IF del_test = 'X'. create = 'X'. no_delete = 'X'. ENDIF.IF del_prod = 'X'. create = 'X'. no_delete = ' '. ENDIF.

(C) SAP AG BC670 27

Page 75: BC670_v46c_en_2001_09

4.28

SAP AG 2002

Example Report SBOOKA (3)

* open a new archive session to archive dataCALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'

EXPORTINGcall_delete_job_in_test_mode = no_deletecomments = commentscreate_archive_file = createobject = 'BC_SBOOK'

IMPORTINGarchive_handle = handle.

LOOP AT sbook_itab.CONCATENATE sy-mandt sbook_itab-carrid sbook_itab-bookid

INTO data_object_id.

* initialize a new data objectCALL FUNCTION 'ARCHIVE_NEW_OBJECT'

EXPORTINGarchive_handle = handleobject_id = data_object_id. " optional: ADK index

(C) SAP AG BC670 28

Page 76: BC670_v46c_en_2001_09

4.29

SAP AG 2002

Example Report SBOOKA (4)

* put data records into ADK's data containerCALL FUNCTION 'ARCHIVE_PUT_RECORD'

EXPORTINGarchive_handle = handlerecord_structure = 'SBOOK'record = sbook_itab.

* further (depending) records from other tables usually follow** loop at <depending table X> where ...* call function 'ARCHIVE_PUT_RECORD' ...* endloop.* loop at <depending table Y> where ...* call function 'ARCHIVE_PUT_RECORD ...* endloop.

* write data object into the archive fileCALL FUNCTION 'ARCHIVE_SAVE_OBJECT'

EXPORTINGarchive_handle = handle.

ENDLOOP.

(C) SAP AG BC670 29

Page 77: BC670_v46c_en_2001_09

4.30

SAP AG 2002

Example Report SBOOKA (5)

create the default spool listCALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'

EXPORTINGarchive_handle = handle.

* close the archive sessionCALL FUNCTION 'ARCHIVE_CLOSE_FILE'

EXPORTINGarchive_handle = handle.

(C) SAP AG BC670 30

Page 78: BC670_v46c_en_2001_09

4.31

SAP AG 2002

Programming Logic ‘Data Deletion’ (1)

Archive_get_customizing_data

Archive_open_for_delete

Do

Archive_get_next_object

Do

Archive_get_next_record

Enddo

Archive_delete _object_data “call archiving classes

If cut = cust_cut “check commit counter Perform Deleteendif

Enddo

If cut > 0 “possible remaining amount processingPerform Deleteendif

Archive_close_file

SAP AG 1999

Function module ARCHIVE_GET_NEXT_OBJECT transfers the ADK data to the main memory.

Form DELETE: Delete data from the database according to the read structure.

(C) SAP AG BC670 31

Page 79: BC670_v46c_en_2001_09

4.32

SAP AG 2002

ADK API: ARCHIVE_GET_CUSTOMIZING_DATA

Interface parameter export

commit_count_for_delete_prg

maintain_index

Interface parameter import

object (archiving object)

Function module functionality:

This function module delivers set values from the archiving-object-Customizing to the archiving progam. Currently only those values are passed which areimportant for the delete program. However, thecounter for the Commit Work can also be used for thereload progam.

(C) SAP AG BC670 32

Page 80: BC670_v46c_en_2001_09

4.33

SAP AG 2002

ADK API: ARCHIVE_OPEN_FOR_DELETE

Interface parameter export

archive_handle

Interface parameter import

object

test_mode

Function module functions:

This function module opens archives to delete fromthe database the data they contain. The status of the archive files is modified accordingly in archiveadministration.

The import parameter ‘object’ specifies the name of the archiving object containing records for deletion.

The parameter ‘test_mode’ specifies whether it is a live or test run. The parameter copies the indicator from the relevant delete program variant that was specified on the selection screen of the delete program.

The parameter ‘aindflag’ controls the interaction with the archive information system. All active archive information structures are updated during the deletion run.

Within the scope of the delete job, the function module ARCHIVE_CLOSE_FILE transfers, on request, (technical settings in Customizing for the relevant archiving object) the archive files that have been created using SAP ArchiveLink for storage to an external storage system.

(C) SAP AG BC670 33

Page 81: BC670_v46c_en_2001_09

4.34

SAP AG 2002

ADK API: ARCHIVE_GET_NEXT_OBJECT

Interface parameter export

object (Archivierungsobjekt)

object_offset

archive_name

Interface parameter import

archive_handle

Function module functions:

This function module reads the next data object for a handle from an archive that has been opened forread access

The import parameter ‘object’ contains the name of the archive objects processed.

The parameters archive_offset and archive_name are relevant for writing an index.

The data belonging to an archiving class is automatically passed on to the relevant archiving class. This means that the data can be called by the archiving class immediately after the function module has been called. Long texts and change documents are typical archiving classes.

You can only use function modules ARCHIVE_GET_NEXT_RECORD and ARCHIVE_GET_NEXT_STRUCT_SPECIF to access data once a data object has been read from an archive.

The same functions are present in this function module as in the function module ARCHIVE_OPEN_FOR_READ , because a new archive file is automatically opened for read access when the current file has been read completely. This means that the same exceptions can be triggered as in the function module ARCHIVE_OPEN_FOR_READ. You should take this into account when writing your programs.

(C) SAP AG BC670 34

Page 82: BC670_v46c_en_2001_09

4.35

SAP AG 2002

ADK API: ARCHIVE_GET_NEXT_RECORD (1)

Interface parameter export

record

record_strucure

Interface parameter import

archive_handle

automatic_conversion

The export parameter ‘record’ contains the name of the work area into which the data is to be imported.

‘Record_structure’ contains the name of the table or structure that is being processed.

The data record that is returned by the ADK is unstructured and must be copied into a suitable work structure.

When ARCHIVE_GET_NEXT_RECORD is called, temporary automatic conversion takes place, if required, such as adjustment of structure changes; adjustments to heterogeneous system environments (codepage), and so on.

(C) SAP AG BC670 35

Page 83: BC670_v46c_en_2001_09

4.36

SAP AG 2002

ADK API: ARCHIVE_GET_NEXT_RECORD (2)

Function module functionality :

This function module allows you to read sequentially the data records contained in a data object

At the first call after the function moduleARCHIVE_GET_NEXT_OBJECT has been called, the firstdata record is automatically returned, and, from then on, each further record is returned until there are no morerecords to be read from the data object.

To read an archive file sequentially, it is sufficient to read the next data object in an external DO-loop using function module ARCHIVE_GET_NEXT_OBJECT so that function module ARCHIVE_GET_NEXT_RECORD can read the data object in an internal DO-loop.

(C) SAP AG BC670 36

Page 84: BC670_v46c_en_2001_09

4.37

SAP AG 2002

ADK API: ARCHIVE_DELETE_OBJECT_DATA

Interface parameter import

archive_handle

Function module functionality :

This function module calls the delete methods forall of the registered archiving classes belonging to the archiving object. The archived data from all classes is then automatically deleted from thedatabase.

The function module ARCHVE_GET_NEXT_OBJECT must be called for each object - directly in the loop.

The ADK API of the archiving objects themselves does not provide any delete methods. You must progam and call this functionality yourself. This means that you must use the delete program to delete from the database all of the data that was written to data objects in the archiving progam by ARCHIVE_PUT_RECORD.

(C) SAP AG BC670 37

Page 85: BC670_v46c_en_2001_09

4.38

SAP AG 2002

Example Report SBOOKD (1)

REPORT sbookd.

* data declarationCONSTANTS:

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.

The variable buffer is divided into the following parts: buffer_segment and buffer_rname. The name of the table for deletion is contained in buffer_rname. buffer_segment specifies the work area containing the record for deletion.

(C) SAP AG BC670 38

Page 86: BC670_v46c_en_2001_09

4.39

SAP AG 2002

Example Report SBOOKD (2)

PARAMETERS: testrun DEFAULT 'X' AS CHECKBOX. " do not delete" from database

* open a new archive session to delete dataCALL FUNCTION 'ARCHIVE_OPEN_FOR_DELETE'

EXPORTINGobject = objecttest_mode = testrun

IMPORTINGarchive_handle = handle

EXCEPTIONSOTHERS = 01.

IF sy-subrc <> 0.WRITE / 'No file can be accessed'(001).EXIT.

ENDIF.

(C) SAP AG BC670 39

Page 87: BC670_v46c_en_2001_09

4.40

SAP AG 2002

Example Report SBOOKD (3)

* get customizing data from the archive objectCALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'

EXPORTINGobject = object

IMPORTINGcommit_count_for_delete_prg = commit_cntmaintain_index = index_flag.

* 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'

EXPORTINGarchive_handle = handle

IMPORTINGobject_id = object_idobject_offset = offsetarchive_name = arkey

EXCEPTIONSend_of_file = 01.

(C) SAP AG BC670 40

Page 88: BC670_v46c_en_2001_09

4.41

SAP AG 2002

Example Report SBOOKD (4)

IF sy-subrc = 1.EXIT.

ENDIF.

* build an index to allow for random access to data objects*** This index is optional. Try to use the Archive Information*** System SAP AS instead.

IF index_flag IS INITIAL.* no index is to be built according to customizingELSEIF 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.

(C) SAP AG BC670 41

Page 89: BC670_v46c_en_2001_09

4.42

SAP AG 2002

Example Report SBOOKD (5)

* loop to get data records from ADK's data containerDO.CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'

EXPORTINGarchive_handle = handle

IMPORTINGrecord = buffer-segmentrecord_structure = buffer-rname

EXCEPTIONSend_of_object = 01.

IF sy-subrc = 1.EXIT.

ENDIF.

* keep data records in mind; take their structure into accountCASE buffer-rname.WHEN 'SBOOK'.MOVE buffer-segment TO sbook_wa.APPEND sbook_wa TO sbook_itab. " will be deleted in db

* when ... " further structuresENDCASE.

ENDDO.

(C) SAP AG BC670 42

Page 90: BC670_v46c_en_2001_09

4.43

SAP AG 2002

Example Report SBOOKD (6)

IF testrun IS INITIAL AND object_cnt = commit_cnt.PERFORM delete_from_table. " actual delete from databaseCLEAR object_cnt. " restart counting up to

ENDIF. " value of commit counterENDDO.

IF testrun IS INITIAL AND object_cnt > 1.PERFORM delete_from_table. " deleting last package

ENDIF.

* provide statisticstabfield-tabname = ' '.tabfield-count = sum_objects.APPEND tabfield TO stat_itab.tabfield-tabname = 'SBOOK'.APPEND tabfield TO stat_itab.CALL FUNCTION 'ARCHIVE_GIVE_STATISTICS'

EXPORTINGarchive_handle = handle

TABLEStable = stat_itab.

(C) SAP AG BC670 43

Page 91: BC670_v46c_en_2001_09

4.44

SAP AG 2002

Example Report SBOOKD (7)

* write statisticsCALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'

EXPORTINGarchive_handle = handlestatistics_only_per_file = 'X'.

* get all processed files for update of index statusCALL FUNCTION 'ARCHIVE_GET_ARCHIVE_FILES'

EXPORTINGarchive_handle = handle

TABLESarchive_files = sel_files_itab.

* close the archive sessionCALL FUNCTION 'ARCHIVE_CLOSE_FILE'

EXPORTINGarchive_handle = handle.

(C) SAP AG BC670 44

Page 92: BC670_v46c_en_2001_09

4.45

SAP AG 2002

Example Report SBOOKD (8)

* set status "index created" in SARA administrationIF index_flag IS INITIAL.* no index has been built according to customizingELSEIF testrun IS INITIAL.

CALL FUNCTION 'ARCHIVE_ADMIN_SET_STATUS'EXPORTING

files_are_converted = ' 'index_created = 'X'

TABLESarchive_files = sel_files_itab.

ENDIF.

*---------------------------------------------------------------------** 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 restartableCOMMIT WORK.

Commit Work then triggers the actual deletion of data from the archiving classes.The delete routine belonging to the archiving classes is called via a Perform ... On Commit, that is the actual deletion only takes place at a database commit.

The collection of data belonging to an archiving class which is to be deleted, occurs via a call of ARCHIVE_DELETE_OBJECT_DATA. This function module is started once per call of ARCHIVE_GET_NEXT_OBJECT .

(C) SAP AG BC670 45

Page 93: BC670_v46c_en_2001_09

4.46

SAP AG 2002

Example Report SBOOKD (9)

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

(C) SAP AG BC670 46

Page 94: BC670_v46c_en_2001_09

4.47

SAP AG 2002

ADK API: Additional Customer-Relevant FMs

Archive_get_information

Archive_open_for_move

SAP AG 1999

Archive_get_information This function module enables you to determine the latest information about an archive handle. This includes the question of when the archive files were written, what their underlying structure is, and so on. This data is important, for example, for tailoring your own reporting programs if a table’s data structure has changed.

Archive_open_for_moveThis function module enables you to read archive files in order to write data objects from these archive files to new archive files. You must call it if you want to reload individual data objects from archive files to the R/3 System.

(C) SAP AG BC670 47

Page 95: BC670_v46c_en_2001_09

4.48

SAP AG 2002

Standard Tables and Customer-specific Tables

standardtable

A

APPEND

Standard tablewith

customer-specificappend structure

Extension notalways necessary

customer-specificZ-table

ZZZ

standardtable

B

Combination ofstandard tables

and customer-specificY-/Z-tables

Create customer-specificarchiving object

Customer-specific Y-/Ztables, which logicallybelong to R/3 standard

tables

Extension necessary,contact your SAP

consultant

standardtable

C

customer-specificZ-table

ZC,independent

ofstandardtable C

Note:In R/3 standard tables, you are only allowed to delete using R/3 standard programs!

(C) SAP AG BC670 48

Page 96: BC670_v46c_en_2001_09

4.49

SAP AG 2002

List the modifications that have been carried out

Analyse the modifications to see whether changes are required to existing archiving objects or archiving classes

Categorize the customer-specific tables with the help of the data model used(where does the table sit in the data model)

Check whetherdependencies on other archiving objects have been created

Procedure for Extending a Standard ArchivingObject

SAP AG 1999

Note:To ensure that the standard archiving progams continue to function correctly, the extensions must be carried out in the customer namespace in a new progam.

Note:When extending a standard archiving object, ensure that the performance of the standard archiving progam is not reduced.

(C) SAP AG BC670 49

Page 97: BC670_v46c_en_2001_09

4.50

SAP AG 2002

Extension: Dependencies

Starting point:

New dependencies by introducing new documents

New dependencies due to customer-specific requirements

Possible consequences:

Maintain new checks in existing archiving programs:User exits possible for SD archiving objects

Update the network graphic for documentation

Some industry-specific requirements call for modifications to the transport process. For example, in IS-OIL, it was necessary, to introduce a new delivery-related document. Delivery documents must not be archived until the new subsequent document has been closed.

User exits in SD are discussed in course BC660.

(C) SAP AG BC670 50

Page 98: BC670_v46c_en_2001_09

4.51

SAP AG 2002

Extension: Append Structure in Standard Table

Starting point:

New fields were inserted into the standard tables using the Append/Include technique

Consequences:

As long as the archiving object or archiving classes write the original table entries, no changes are required to write or delete programs.

Analysis programs must be adjusted in case the fields have to bedisplayed.

Check whether dependencies have arisen.

Check the archiving program to see whether structures are written instead of the original tables. If so, the archiving program transfers the table entries to these structures. In this case, the archiving program and the structures must be adjusted in line with the changed data.

(C) SAP AG BC670 51

Page 99: BC670_v46c_en_2001_09

4.52

SAP AG 2002

Extension: New Tables for Standard Documents

Starting point:

Information on standard documents is stored in customer-specific tables

Consequences:

Use transaction AOBJ to extend the archiving object structure toinclude customer-specific tables

Copy and adjust the write- and delete progams

Copy and adjust the reporting progam (optional)

Monitor potential new dependencies

(C) SAP AG BC670 52

Page 100: BC670_v46c_en_2001_09

4.53

SAP AG 2002

Add-on IS-OIL

For goods movements in the oil industry, you must enter temperature and density data in the database for every material item.This data is stored in its own table, which must be archivedand deleted together with the standard tables MKPF andMSEG.

Example Extension to MM_MATBEL (1)

SAP AG 1999

(C) SAP AG BC670 53

Page 101: BC670_v46c_en_2001_09

4.54

SAP AG 2002

Example Extension to MM_MATBEL (2)

Standard data model:

MKPF-> MSEG

Extended data model IS-OIL:

MKPF-> MSEG

-> MSEGO1-> MSEGO2

In the above data model of MM-data, there is also NAST data. Within the context of data archiving, this data is deleted only.

(C) SAP AG BC670 54

Page 102: BC670_v46c_en_2001_09

4.55

SAP AG 2002

Example Extension to MM_MATBEL (3)

Analyze dependencies

In contrast to the standard system, the material document may still be required in certain situations (‘not mseg-oiexgnum’) for a process called ‘netting’, which follows billing/invoice verification. In the section ‘oil_put_oiaqb’, the system checks whether this process has been completed

Cross-application dependencies to other archiving objects are not given

SAP AG 1999

(C) SAP AG BC670 55

Page 103: BC670_v46c_en_2001_09

4.56

SAP AG 2002

Example Extension to MM_MATBEL (4)

Analyze the standard archiving program with reference to flow logic and performance optimization

Program searches for the optimum strategy to select the documents to be archived (selection via header- or item data)

If the selection uses item data, the system uses a database view

Program works with dynamic SQL

Program redetermines the selection criteria to keep the data for selection to a minimum

Program works with central authorization checking, to restrict the amount of data to be selected and processed

Program writes header data individually with ‘ARCHIVE_PUT_RECORD’ and all item data from a document with ‘ARCHIVE_PUT_TABLE’

SAP AG 1999

Note:From a check logic viewpoint, MM_MATBEL should be seen as a “simply structured” archiving object.

(C) SAP AG BC670 56

Page 104: BC670_v46c_en_2001_09

4.57

SAP AG 2002

Example Extension to MM_MATBEL (5)

Adjustments to standard archiving program

Insert required data definition

Insert processing log for new data

Insert selection of new data

Insert archivability checks

Insert the writing of table records in the archive files, after theassigned tables have been written in the standard system.

SAP AG 1999

(C) SAP AG BC670 57

Page 105: BC670_v46c_en_2001_09

4.58

SAP AG 2002

Example Extension to MM_MATBEL (6)

Adjustments to standard delete program

Insert required data declaration

Fill the internal tables for new data after data has been read from the archive file(s)

Programming similar to standard table processing

The new progam code is inserted behind the processing ofthe master table

Insert a delete sequence for the new data

Programming similar to standard table processing

The new progam code is inserted behind the processing of the master table

SAP AG 1999

In some cases, data has to be deleted only. Such data is not transferred to the archive file, but simply deleted from the database. An example of this is the message control data for MM and SD documents.

(C) SAP AG BC670 58

Page 106: BC670_v46c_en_2001_09

4.59

SAP AG 2002

Extension: Summary (1)

Adjusting the archiving programs

Copy the standard program in the customer namespace.

Analyze the archiving program carefully.

Determine to which already archived table the new table logically belongs.

Determine where in the archiving program the master table is processed.

Extend the definition of the required data structures.

Extend the selection of data from the Z table

If necessary, extend the archivability checks.

Extend the transfer of data from the Z table to ADK

SAP AG 1999

Note:A careful analysis of the archiving program is essential, because the programs are generally optimized with regard to performance. To avoid problems in future, check that the performance of the write and delete programs is still satisfactory after the new tables have been added.

User exits are not offered so that performance can be further optimized and new structures can be included in the standard system at any time.

New developments may lead to future changes in the underlying program logic of the standard archiving objects. For example, the SD document programs have already been redesigned.

(C) SAP AG BC670 59

Page 107: BC670_v46c_en_2001_09

4.60

SAP AG 2002

Extension: Conclusion (2)

Adjusting the delete program

Determine the point at which the data records are to be deleted

CASE-structure after calling the function module ARCHIVE_GET_NEXT_RECORD

List of delete calls

Extend the delete calls to include your own table(s)

SAP AG 1999

(C) SAP AG BC670 60

Page 108: BC670_v46c_en_2001_09

4.61

SAP AG 2002

Extension: Conclusion (3)

Adjusting a reporting program (optional)

Extending the output structure

Extending the output of the data

SAP AG 1999

(C) SAP AG BC670 61

Page 109: BC670_v46c_en_2001_09

4.62

SAP AG 2002

Extension: Evaluation

We recommend that you do not extend a standard archiving object.

If this is unavoidable, contact your SAP consultant.

Recommended procedure:

Use a customer-specific archiving object to archive your own Y or Z tables that belong to a standard archiving object.

Write reports that read and merge the archive files belonging to the standard object and to customer-specific object.

SAP AG 1999

After modifying a standard archiving object, you should check whether the same level of throughput performance can be maintained as before you made the modification.

(C) SAP AG BC670 62

Page 110: BC670_v46c_en_2001_09

4.63

SAP AG 2002

The logic of an archiving progam

The logic of a delete progam

Procedure for creating a newarchiving object

Procedure for extending anarchiving object

You now know:

Data Archiving Programming Logic : Conclusion

(C) SAP AG BC670 63

Page 111: BC670_v46c_en_2001_09

4.64

Unit: Program Logic in Data Archiving

Topic: Archiving STICKET

At the conclusion of this exercise, you will be able to:

Write data from the customer table STICKET to an archiving file

Your enterprise has the customer table STICKET.

This table has been identified as a critical table, and is to be reduced in size.

First, you must write an archiving program.

1-1 Create an archiving program for STICKET. Use program SBOOKA as template.Program name: ZBCSTICKxxA. XX stands for your group number.Type: Executable programStatus: Test programApplication: Basis

1-1-1 Create an archiving program that archives records from the table STICKET.

Selection parameters: Airline (carrid) and booking number (bookid).

1-1-2 Configure your program so that the user can decide - Whether to create an archive file- Whether to use the test run variant or live run variant if the deletion program is to be run immediately.

1-1-3 Write an archive file only if the parameter has been set as follows.Sequence of function modules:Open archive file for write jobInitialize new data objectTransfer data recordSave data object

1-1-4 Ensure that the statistics are written with the standard statistics module before you close the archive file.

2-1 Create deletion program for STICKET. Use the program SBOOKD as a template.Program name: ZBCSTICKxxD. xx stands for your group number.

(C) SAP AG BC670 64

Page 112: BC670_v46c_en_2001_09

Type: Executable program

Status: Test program

Application: Basis

2-1-1 Enter a parameter that determines whether the deletion run is to be a test run, or whether data is really to be deleted.

2-1-2 Sequence of function modules: Retrieve file for deletionRead Customizing data (Commit counter/Start deletion jobLoop 1: Read archiving record object from data containerLoop 2: Copy record in buffer and run deletion routine if the deletion indicator is set.Output statisticsClose file

2-1-3 No index is to be built.

(C) SAP AG BC670 65

Page 113: BC670_v46c_en_2001_09

Unit: Data Archiving Programming Logic

Topic: Customizing and Testing BCSTICKxx

At the conclusion of this unit, you will be able to:

Create an archiving object in transaction AOBJ

Test a new archiving object

The customer-specific table STICKET exists in your organization. This table is recognized as being a critical table. The size of this table needs to be reduced.After you have written the necessary programs, you must create the archiving object in your system.

1-1 Create the archiving object ZBCSTICKxx. (XX represents your group number.)

1-1-1 Create the archiving object in transaction AOBJ.Specify BC as the work area and use input help to select application component Basis.

1-1-2 Enter your archiving and delete programs

1-1-3 Publicize the structure definitions: You are processing the table STICKET

1-1-4 Maintain the Customizing settings:

1-1-4-1 Your logical filename should link to the path Archive_data_file

1-1-4-2 Enter the file size 100 MB and leave the number of objects blank

1-1-4-3 After data archiving, the file is not going to be stored in an external optical archive.

1-1-4-4 Do not start the delete program immediately, but rather manually. Create 2 delete program variants: TESTxx for a test delete run and PRODxx for the production delete run

(C) SAP AG BC670 66

Page 114: BC670_v46c_en_2001_09

2-1 Start an archiving and delete run in transaction SARA for your newly created archiving object.

2-2 Additional taskDisplay the archived data via SAP AS

2-2-1 In the Archive Information System, create an archive information structure for your newly created archiving object.

2-2-2 Activate your archive information structure.

Fill your archive information structure with the data from your archiving session.

Display the data in the Archive Explorer.

(C) SAP AG BC670 67

Page 115: BC670_v46c_en_2001_09

4.65Data Archiving Programming Logic Solutions

Unit: Data Archiving Programming Logic

Topic: Archiving STICKET

1-1 Tools, ABAP Workbench, Development, ABAP Editor

Enter SBOOKA, Button CopyEnter ZBCSTICKxxA. (xx represents your group number.)Copy all available parts of the programSave as local object

Exchange table SBOOK for STICKETExchange the archiving object BC_SBOOK for ZBCSTICKxxNote: Pay attention to upper/lower case

1-1-1 to 1-1-4 see example solution: Program ZZBC670_Archiving

2-1 Tools, ABAP Workbench, Development, ABAP Editor

Enter SBOOKD, Copy button.Enter ZBCSTICKxxD. (xx represents your group number.)Copy all available parts of the program Save as local object

Exchange table SBOOK for STICKETExchange archiving object BC_SBOOK for ZBCSTICKxxNote: Pay attention to upper/lower case

2-1-1 to 2-1-3 see example solution: Program ZZBC670_Delete

REPORT ZZBC670_archivieren.

* data declarationTABLES: STICKET.DATA: BUTTON(1) TYPE C, CREATE(1) TYPE C VALUE 'X', NO_DELETE(1) TYPE C VALUE 'X', HANDLE LIKE SY-TABIX, STICKET_ITAB TYPE TABLE OF STICKET WITH HEADER LINE.

* selection criteria and parametersSELECTION-SCREEN BEGIN OF BLOCK ARCH_BOOKING WITH FRAME TITLE TEXT-101.SELECT-OPTIONS: O_CARRID FOR STICKET-CARRID DEFAULT 'LH ', O_BOOKID FOR STICKET-BOOKID.SELECTION-SCREEN END OF BLOCK ARCH_BOOKING.

(C) SAP AG BC670 68

Page 116: BC670_v46c_en_2001_09

SELECTION-SCREEN BEGIN OF BLOCK ARCH_CONTROL WITH FRAME TITLE TEXT-102.PARAMETERS: NO_FILE LIKE BUTTON RADIOBUTTON GROUP RADI, DEL_TEST LIKE BUTTON RADIOBUTTON GROUP RADI DEFAULT 'X', DEL_PROD LIKE BUTTON RADIOBUTTON GROUP RADI.SELECTION-SCREEN END OF BLOCK ARCH_CONTROL.

PARAMETERS COMMENTS TYPE ADMI_TEXT LOWER CASE DEFAULT 'This is test data for archiving with BC_SBOOK'(103).

* create cursor for data selectionDATA: DB_CURSOR TYPE CURSOR.OPEN CURSOR WITH HOLD DB_CURSOR FOR SELECT * FROM STICKET WHERE CARRID IN O_CARRID AND BOOKID IN O_BOOKID.

* build ADK parameters from chosen buttonIF NO_FILE = 'X'. CREATE = ' '. NO_DELETE = ' '. ENDIF.IF DEL_TEST = 'X'. CREATE = 'X'. NO_DELETE = 'X'. ENDIF.IF DEL_PROD = 'X'. CREATE = 'X'. NO_DELETE = ' '. ENDIF.

* open a new archive session to archive dataCALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE' EXPORTING CALL_DELETE_JOB_IN_TEST_MODE = NO_DELETE COMMENTS = COMMENTS CREATE_ARCHIVE_FILE = CREATE OBJECT = 'ZBCSTICK20' IMPORTING ARCHIVE_HANDLE = HANDLE.DO.* get next records (up to 100) FETCH NEXT CURSOR DB_CURSOR INTO TABLE STICKET_ITAB PACKAGE SIZE 100. IF SY-SUBRC NE 0. EXIT. ENDIF.

* initialize a new data object CALL FUNCTION 'ARCHIVE_NEW_OBJECT' EXPORTING ARCHIVE_HANDLE = HANDLE.

* put data records into ADK's data container CALL FUNCTION 'ARCHIVE_PUT_TABLE' EXPORTING ARCHIVE_HANDLE = HANDLE RECORD_STRUCTURE = 'STICKET' TABLES TABLE = STICKET_ITAB.

* write data object into the archive file CALL FUNCTION 'ARCHIVE_SAVE_OBJECT' EXPORTING ARCHIVE_HANDLE = HANDLE.ENDDO.

* close database cursorCLOSE CURSOR DB_CURSOR.

* create the default spool listCALL FUNCTION 'ARCHIVE_WRITE_STATISTICS' EXPORTING ARCHIVE_HANDLE = HANDLE.

* close the archive sessionCALL FUNCTION 'ARCHIVE_CLOSE_FILE' EXPORTING ARCHIVE_HANDLE = HANDLE.

(C) SAP AG BC670 69

Page 117: BC670_v46c_en_2001_09

REPORT ZZBC670_LOESCHEN.

* data declarationCONSTANTS: OBJECT LIKE ARCH_OBJ-OBJECT VALUE 'ZBCSTICK20'.DATA: HANDLE LIKE SY-TABIX, BUFFER TYPE ARC_BUFFER, STICKET_WA LIKE STICKET, STICKET_ITAB TYPE TABLE OF STICKET, RECORD_ITAB TYPE TABLE OF STICKET, COMMIT_CNT LIKE ARCH_USR-ARCH_COMIT, OBJECT_CNT TYPE I, SUM_OBJECTS TYPE I VALUE 0, STAT_ITAB TYPE TABLE OF ARCH_STAT, TABFIELD LIKE ARCH_STAT.

PARAMETERS: TESTRUN DEFAULT 'X' AS CHECKBOX. " do not delete " from database* open a new archive session to delete dataCALL FUNCTION 'ARCHIVE_OPEN_FOR_DELETE' EXPORTING OBJECT = OBJECT TEST_MODE = TESTRUN IMPORTING ARCHIVE_HANDLE = HANDLE EXCEPTIONS OTHERS = 01.IF SY-SUBRC <> 0. WRITE / 'No file can be accessed'(001). EXIT.ENDIF.

* get customizing data from the archive objectCALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA' EXPORTING OBJECT = OBJECT IMPORTING COMMIT_COUNT_FOR_DELETE_PRG = COMMIT_CNT.

* 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 EXCEPTIONS END_OF_FILE = 01. IF SY-SUBRC = 1. EXIT. ENDIF.

CALL FUNCTION 'ARCHIVE_GET_TABLE' EXPORTING ARCHIVE_HANDLE = HANDLE RECORD_STRUCTURE = 'STICKET' ALL_RECORDS_OF_OBJECT = 'X ' TABLES TABLE = RECORD_ITAB.

APPEND LINES OF RECORD_ITAB TO STICKET_ITAB.

IF TESTRUN IS INITIAL AND OBJECT_CNT = COMMIT_CNT. PERFORM DELETE_FROM_TABLE. " actual delete from database CLEAR OBJECT_CNT. " restart counting up to ENDIF. " value of commit counterENDDO.

IF TESTRUN IS INITIAL AND OBJECT_CNT > 1.

(C) SAP AG BC670 70

Page 118: BC670_v46c_en_2001_09

PERFORM DELETE_FROM_TABLE. " deleting last packageENDIF.

* provide statisticsTABFIELD-TABNAME = ' '.TABFIELD-COUNT = SUM_OBJECTS.APPEND TABFIELD TO STAT_ITAB.TABFIELD-TABNAME = 'STICKET'.APPEND TABFIELD TO STAT_ITAB.CALL FUNCTION 'ARCHIVE_GIVE_STATISTICS' EXPORTING ARCHIVE_HANDLE = HANDLE TABLES TABLE = STAT_ITAB.

* write statisticsCALL FUNCTION 'ARCHIVE_WRITE_STATISTICS' EXPORTING ARCHIVE_HANDLE = HANDLE STATISTICS_ONLY_PER_FILE = 'X'.

* close the archive sessionCALL FUNCTION 'ARCHIVE_CLOSE_FILE' EXPORTING ARCHIVE_HANDLE = HANDLE.

*---------------------------------------------------------------------** FORM DELETE_FROM_TABLE **---------------------------------------------------------------------** global: STICKET_itab, sum_objects*---------------------------------------------------------------------*FORM DELETE_FROM_TABLE. DATA: TABCOUNT TYPE I VALUE 0. DELETE STICKET FROM TABLE STICKET_ITAB. " delete job restartable COMMIT WORK. DESCRIBE TABLE STICKET_ITAB LINES TABCOUNT. SUM_OBJECTS = SUM_OBJECTS + TABCOUNT. REFRESH STICKET_ITAB.ENDFORM. " DELETE_FROM_TABLE

(C) SAP AG BC670 71

Page 119: BC670_v46c_en_2001_09

Unit: Data Archiving Programming Logic

Topic: Customizing and testing the archiving object

1-1 Create archiving object ZBCSTICKxx for STICKET.

1-1-1 Call transaction AOBJButton <New entries >Object name: ZBCSTICKxx / Text: Archiving object for STICKET/Group xx

1-1-2 Write program: ZBCSTICKxxA / Delete program: ZBCSTICKxxDSave archiving object Return to initial screen

1-1-3 Flag the archiving object ZBCSTICKxxDouble click on the dialog structure 'structure definition'Enter STICKET in the field Segment Save the archiving object Return to initial screen

1-1-4 Flag the archiving object ZBCSTICKxx Double click on the dialog structure 'Customizing settings'

1-1-4-1 Enter logical filename: Archive_data_file

1-1-4-2 Enter 'Size of archive file': Size in MB 100

1-1-4-3 No entry under connection to archive system

1-1-4-4 Entry under delete program settings: Mark ‘Not scheduled’ Entry for test run variants: TESTxx Entry for production run variants: PRODxx. For both variants: Button <Variants> Supply the variants with suitable deletion indicator: Test X

Productive: no entry

(C) SAP AG BC670 72

Page 120: BC670_v46c_en_2001_09

2-1 Tools, administration, management, Data Archiving. Enter archiving object ZBCSTICKxx Test archiving progam:Button <Archiving>Maintain variant groupxx; the course instructor will tell you which data is to be archivedReturn to initial screen 'Create archive files'

Button <Start date>

Choose: ImmediatelySave and return to initial screen 'Create archive files'

Button <Spoolparameter>Printer: LP01Hardware type: printerSave and return to initial screen 'Create archive files'

Button <execute>The system will create the archiving jobs.Monitor jobs with button <Job overview>Return to screen: Archive management: entry screen

Test delete progam:Button <Delete>Start data 'immediately' and maintain spool parameter with LP01 as above

Button 'Archive selection'From the popup which appears, select your own archiving session Save Button <execute>The system will create the delete jobs.Monitor jobs with button <Job overview >Return to screen: Archive management: entry screen

2-2 Additional exercise: Displaying archived data using SAP AS

2-2-1 Create archive information structure for object ZBCSTICKXX.

Button<Info system> in transaction SARA

Button <Customizing>

Entry name TASBCSTICKXX

Button<Create>

Field catalog: BCSTICKXX

Transfer fields by saving

Button <Activate>

Return to initial screen in Archive Information System

Button <Status per Infostructure>

Select Infostructure and Button <Build structure>

Button <Archive Explorer>

(C) SAP AG BC670 73

Page 121: BC670_v46c_en_2001_09

Enter ZBCSTICKXX. Infostructure is selected by the system

Display data

(C) SAP AG BC670 74

Page 122: BC670_v46c_en_2001_09

5

SAP AG 2002

Logic of sequential read progams

Logic of reading from archiving classes

Creating a sequential read program with and without archiving classes

Contents:

Sequential Read Programs

(C) SAP AG BC670 1

Page 123: BC670_v46c_en_2001_09

5.2

SAP AG 2002

Create a sequential read program

Display archiving classes in a read program

At the conclusion of this unit, you will be able to:

Sequential Read Programs : Unit Objectives

SAP AG 1999

(C) SAP AG BC670 2

Page 124: BC670_v46c_en_2001_09

5.3

SAP AG 2002

Course Overview Diagram

Course Overview

The Data Archiving Process

ADK Development Tools

Data Archiving Programming Logic

Customer-Specific Read Programs

Business Views in SAP AS

Appendix

(C) SAP AG BC670 3

Page 125: BC670_v46c_en_2001_09

5.4

SAP AG 2002

You have to create customer-specific read programs for your own archiving objects, as well as for standard R/3 archiving objects.

The programmers have to learn the logic of read programs.

The new read programs must also be able to read and display archiving classes.

Sequential Read Programs: Business Scenario

SAP AG 1999

(C) SAP AG BC670 4

Page 126: BC670_v46c_en_2001_09

5.5

SAP AG 2002

Overview: Access to Archived Data

Direct access to a document from the application(FI_DOCUMNT and MM_MATBEL)

Archive Information System (SAP AS)

ABAP Evaluation reports

retrieved from the application

customer-specific reports

SAP AG 1999

Single document access from the application is available for FI DOCUMNT, and from Release 4.0, from MATBEL.

Programs for reporting archive files are provided by the application and are available in transaction SARA.

(C) SAP AG BC670 5

Page 127: BC670_v46c_en_2001_09

5.6

SAP AG 2002

‘Sequential Read’ Programming Logic

Archive_open_for_read

Archive_get_next_object

Archive_get_next_record“

Archive_close_file

SAP AG 1999

The read logic in delete programs is similar to that in read programs. The function module ARCHIVE_OPEN_FOR_DELETE is replaced with ARCHIVE_OPEN_FOR_READ.

(C) SAP AG BC670 6

Page 128: BC670_v46c_en_2001_09

5.7

SAP AG 2002

Interface parameter export

object (archiving object)

Interface parameter import

archive_handle (pointer to the selected archiving sessions)

Function module functionality:

Authority-Check on S_ARCHIVE

Prepares and dsiplays a dialog box that displays all archivingsessions: The user selects the relevant archiving session.

Creates Archive_handle

ADK API: ARCHIVE_OPEN_FOR_READ

ADK has multi-instance capability.Each handle addresses an instance. In a program, more than one archive can be read in parallel. The handle, as it is used in ADK, can be compared to the file handle in the file management system.

In addition to the S_ARCHIVE authorization check, there may be application-specific authorizations that should be checked.

(C) SAP AG BC670 7

Page 129: BC670_v46c_en_2001_09

5.8

SAP AG 2002

ADK API: ARCHIVE_GET_NEXT_OBJECT

Interface parameter export

archive_handle (pointer to the selected archiving sessions)

Interface parameter import

object_offset (where is the object in the archive file)

archive_name (key to the archive file)

Function module functions::

Reads the first or next data object and transfers the data from the archive to ADK.

Exception: End of file

The function module reads the next data object in the archive file. Information such as object_offset and archive_name are necessary if SAP AS is to be able to access

a document directly. The information defined here is relevant for direct access to a document using the function module

ARCHIVE_READ_OBJECT (see unit ‘Direct access via SAP AS’). The function module operates in the same way, regardless of whether it is called from a read, delete

or reload program.

(C) SAP AG BC670 8

Page 130: BC670_v46c_en_2001_09

5.9

SAP AG 2002

ADK API: ARCHIVE_GET_NEXT_RECORD

Interface parameter export

archive_handle (pointer to the selected archiving sessions)

Interface parameter import

record (content of an individual table record in the object)

record_structure (table name, from which record is taken)

Function module functionality :

Retrieves the table records belonging to an object in a bufferarea

Exception: End of object

(C) SAP AG BC670 9

Page 131: BC670_v46c_en_2001_09

5.10

SAP AG 2002

ADK API: ARCHIVE_GET_TABLE (1)

Interface parameter import

archive_handle

record_structure

all_records_of_object

automatic_conversion

Interface Table

Table

Function module functionsThis function module was developed to simplify the implementation of the read operation. Several data records are read for the structure that is specified with record_structure and then stored in an internal table.

The parameter ‘record_structure’ transfers the name of the structure or table containing the objects to be read.

ALL_RECORDS_OF_OBJECT = ' ' In this case, the function module functions in a similar way to the function module ARCHIVE_GET_NEXT_STRUCT_SPECIF. All records are simply read sequentially for the specified structure until the structure changes. All read data records are placed in the internal table TABLE.Reading continues with ARCHIVE_GET_NEXT_RECORD. This automatically reads the next unread data record. Similarly, when the function module ARCHIVE_GET_TABLE is called, it reads from the next unread data record.

ALL_RECORDS_OF_OBJECT =‘X’In this case, the function module reads all data records for the specified structure in the whole data object. The data objects read are stored in table TABLE. It does not matter if between the data records with the specified structure RECORD_STRUCTURE there are data records with other structures. All data records for the specified structure are collected in the current data object, regardless of their place in the current data object. Further reading is possible with ARCHIVE_GET_NEXT_RECORD. In this case, regardless of the data records that were read with ARCHIVE_GET_TABLE; the next data record is read from when ARCHIVE_GET_NEXT_RECORD was called. If ARCHIVE_GET_NEXT_RECORD was not yet called, the first data record is read.

(C) SAP AG BC670 10

Page 132: BC670_v46c_en_2001_09

5.11

SAP AG 2002

ComparisonARCHIVE_GET_RECORD - ARCHIVE_GET_TABLE

Reads one record

More coding required, sinceCASE query must be processed

Operations in main memory(Move data to work area)->lowers performance

Reads array of records

By default, supplies all records of the same type that occur insequence in the ADK file in a file-> Less coding

Performance improved with mass processing

The parameter all records enables all records to be read that belong to a specific type, regardless of whether they are arranged sequentially in the ADK file or not.

The records are made available to the read program in the same sequence as they were transferred by PUT_RECORD or PUT_TABLE.

(C) SAP AG BC670 11

Page 133: BC670_v46c_en_2001_09

5.12

SAP AG 2002

ADK API: ARCHIVE_CLOSE_FILE

Interface parameter export

archive_handle (pointer to the selected archiving sessions)

Function module functionality :

Closes the archive file

Releases the resources of an archive handle

The archive handle is invalid after the function module is run and cannot be reused. Each additional operation with this handle triggers the exception WRONG_ACCESS_TO_ARCHIVE .

(C) SAP AG BC670 12

Page 134: BC670_v46c_en_2001_09

5.13

SAP AG 2002

Sequential Access Logic (1)

ADK/AOBJ:Definition: Archiving object X

A TableB TableC Table

ARCHIVE_OPEN_FOR_READABAP program with internaltables

Archivefile

Data container with current data object

A

B

B

B

C

C

A

B

C

ARCHIVE_CLOSE_FILE

ARCHIVE_GET_NEXT_OBJECT

ARCHIVE_GET_NEXT_RECORD

ARCHIVE_GET_NEXT_RECORD

ARCHIVE_GET_NEXT_RECORD

1

2

4

3

3

3

Step 1: Check whether the named archive file is available. Open files. Step 2: The first object is transferred from the archive file to an area in the main memory that

is only accessible to ADK. Step 3 From the main memory area, the object is transferred record by record to a variable of

the read program. The contents of the variables of the read program. The contents of the variables can then be processed as required.

You can work with ARCHIVE_GET_TABLE as well as with ARCHIVE_GET_NEXT_RECORD.

(C) SAP AG BC670 13

Page 135: BC670_v46c_en_2001_09

5.14

SAP AG 2002

Sequential Access Logic (2)

DeclarationInternal tables (itabA, itabB, itabC)

open existing archive file(s) for read access ARCHIVE_OPEN_FOR_READ

export: archiving objectimport: archive_handle

read next object from archive file in ADK data containerARCHIVE_GET_NEXT_OBJECT

export: archive_handle[import: archive_key, offset]

read next record from container in ABAP reportARCHIVE_GET_NEXT_RECORD

export: archive_handleimport: record_structure, record

write record in list

close archive filesARCHIVE_CLOSE_FILE

export: archive_handle

loop aslong as

records areavailable

loop aslong as

data objectsare available

The function module ARCHIVE_OPEN_FOR_READ supplies the data sequentially according to the order in which they are stored in the ADK archive file. If you want a different order, you must sort them in the main memory.

(C) SAP AG BC670 14

Page 136: BC670_v46c_en_2001_09

5.15

SAP AG 2002

Example Report SBOOKR (1)

report sbookr.

* data declaration data: handle like sy-tabix,

buffer like arc_buffer,sbook_wa like sbook,number_of_records_read type i.

* open existing archive files call function 'ARCHIVE_OPEN_FOR_READ'

exporting object = 'BC_SBOOK'

importing archive_handle = handle

exceptions

others = 1.

if sy-subrc <> 0.write: / 'File open error'.

(C) SAP AG BC670 15

Page 137: BC670_v46c_en_2001_09

5.16

SAP AG 2002

Example Report SBOOKR (2)

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 = handleexceptions

end_of_file = 1others = 2.

if sy-subrc <> 0.exit.

endif.

* get data records from the data container do.

If the last archive file was read to the end, end of file is triggered.

(C) SAP AG BC670 16

Page 138: BC670_v46c_en_2001_09

5.17

SAP AG 2002

Example Report SBOOKR (3)

call function 'ARCHIVE_GET_NEXT_RECORD'exporting

archive_handle = handleimporting

record = buffer-segment record_structure = buffer-rname

exceptionsend_of_object = 1others = 2.

if sy-subrc <> 0.exit.

endif.

add 1 to number_of_records_read.

enddo.

enddo.

In step 3, the data from the main memory is transferred to a work area in the program using ARCHIVE_GET_NEXT_RECORD.The data in one object belongs to various tables.

The work area in our example is arc_buffer. Arc_buffer is split into buffer_rname, which contains the name of the table to which the transferred record belongs, and buffer_segment, in which the data is to be stored.

Up to Release 4.6C, the segments have a size of 8K.

(C) SAP AG BC670 17

Page 139: BC670_v46c_en_2001_09

5.18

SAP AG 2002

Example Report SBOOKR (4)

write: / 'Number of records read:', number_of_records_read.uline.write / 'Last record read:'.case buffer-rname.

when 'SBOOK'.sbook_wa = buffer-segment.write: / 'CARRID :', sbook_wa-carrid,

/ 'BOOKID :', sbook_wa-bookid, / 'CONNID :', sbook_wa-connid, / 'FLDATE :', sbook_wa-fldate, / 'CUSTOMID :', sbook_wa-customid, / 'ORDER_DATE:', sbook_wa-order_date, / '...'.

* when ... * If the archive object contained more than one table* (different buffer-rname), more cases would be needed.endcase.

Buffer_segment is an unstructured area from which the data must be transferred to a structured work area.How the work area is defined depends on the table record that is currently being read.

If you are working with the function module ARCHIVE_GET_TABLE, the transfer to a work area is omitted since the internal table forms the work area and includes the correct records from the table for an object.

(C) SAP AG BC670 18

Page 140: BC670_v46c_en_2001_09

5.19

SAP AG 2002

Example Report SBOOKR (5)

* close the archive session call function 'ARCHIVE_CLOSE_FILE'

exporting

archive_handle = handle.

(C) SAP AG BC670 19

Page 141: BC670_v46c_en_2001_09

5.20

SAP AG 2002

Programming Logic: ‘Read Archiving Classes’

Archive_open_for_read

Archive_get_next_object

Archive_get_next_record

CU_CONFIG_READ_ARCHIVE_OBJECT(Archiving class ‘Variant configuration‘)

TEXT_SELECT_ ARCHIVE_OBJECT(Archiving class ‘TEXT’)

READ_TEXT (Archiving class ‘TEXT’)

Archive_close_file

SAP AG 1999

The data that was stored together with an archiving object using the archiving module or an archiving class cannot be accessed directly by ADK.

The data is transferred to ADK by the read module in the archiving class.

(C) SAP AG BC670 20

Page 142: BC670_v46c_en_2001_09

5.21

SAP AG 2002

Where to Find Archiving Classes in R/3

SAP AG 1999

From Release 3.1G Management in Transaction ACLA

From Release 4.6C Report Class_Browser

Naming convention for archiving function module

<archiving class>_archive_object

No naming convention for read function module

Possible name<archiving class>_read_archive_object

Identical to the read function module, which also reads the database: For example: Read_text for archiving class texts

Report Class_Table_Search enables the assignment of table and archiving class.It outputs not only the respective archiving classes but also the relevant function group. The listed naming conventions are applicable within the function group for the function modules.

Function module for reading an archiving class:There is no naming convention for the function module for reading data.

Procedure 1. Specify the function group of the archiving class in transaction ACLA.2. Determine the function modules of the function group.3. Determine the read function module using the program documentation.

Function module for archiving an archiving class:To call the function module, choose Tools -> ABAP Workbench -> Development -> Function Builder.Use the naming convention described above.

(C) SAP AG BC670 21

Page 143: BC670_v46c_en_2001_09

5.22

SAP AG 2002

Reading Archiving Classes

Determining the function group of the archiving class

Release 3.0: Transaction AOBJ

Release 3.1 bis 4.6: Transaction ACLA

Determining the read module of the rachiving class

Transaction SE80, enter function group

Display function modules

Read documentation

Note: The Archive_handle must also be included with the function modules for the archiving classes.

(C) SAP AG BC670 22

Page 144: BC670_v46c_en_2001_09

5.23

SAP AG 2002

Read Archiving Classes (2)

Clarify which fields are to be displayed

What fields does the used structure contain?

Analyze the archived data using the archiving progam

Determine where data is to be read

Logical assignment of contents to the archived tables

Determine where data is to be displayed

Logical assignment of contents to the archived tables

SAP AG 1999

There is a link to the function module documentation which explains the interface.The function module must be released.The interfaces can be complex - for example, the archiving class TEXT supplies data for headers and line items.

Logical assignment of data: Position texts from orders can, for example, only be read if the relevant order positions are available in the program.

(C) SAP AG BC670 23

Page 145: BC670_v46c_en_2001_09

5.24

SAP AG 2002

Read Archiving Classes (3)

Build the archiving class into the relevant report

Optional: Create checkbox field ‘Output yes/no’.

Create necessary data structures.

Read data using function module.

If necessary:Collect data in advance using the selection module

Display the data in list format.

SAP AG 1999

You can use the documentation to determine which data structures are to be created and the interface for the read module.

You are advised to make archiving class data available as an option by adding a checkbox, rather than having to process it in the read program, since, generally, this data is not of interest to all users.

(C) SAP AG BC670 24

Page 146: BC670_v46c_en_2001_09

5.25

SAP AG 2002

Example: Output Texts (1)

* DEFINITION DATA

* Texts / Classes tables: thead, tline.

types: begin of vb_text,head like thead,lines like tline occurs 5,

end of vb_text.

data: l_tname like thead-tdname occurs 0 with header line, l_text type vb_text occurs 0 with header line,xvbbk like thead occurs 0 with header line,xvbbp like thead occurs 0 with header line.

data: xlines like tline.

(C) SAP AG BC670 25

Page 147: BC670_v46c_en_2001_09

5.26

SAP AG 2002

Example: Output Texts (2)

* Select the texts in an internal table after * Calling the function module ‘ARCHIVE_GET_NEXT_OBJECT’

call function 'TEXT_SELECT_ARCHIVE_OBJECT' exporting

archive_handle = archive_handle object = 'VBBK' “text object header

tables selections = xvbbk.

call function 'TEXT_SELECT_ARCHIVE_OBJECT' exporting

archive_handle = archive_handle object = 'VBBP' “text object line item

tables selections = xvbbp.

loop at xvbbk.xvbbp = xvbbk. append xvbbp.

endloop.

(C) SAP AG BC670 26

Page 148: BC670_v46c_en_2001_09

5.27

SAP AG 2002

Example: Output Texts (3)

* Read the text data and output in list formatif text = 'X'.format color col_heading intensified. write: /2 text-130.format color col_background intensified.write: / sy-uline(105).format color col_heading intensified.write: / sy-vline,

2 text-135, 9 sy-vline,

10 text-140, 105 sy-vline.

(C) SAP AG BC670 27

Page 149: BC670_v46c_en_2001_09

5.28

SAP AG 2002

Example: Output Texts (4)

sort xvbbp.loop at xvbbp.

call function 'TEXT_READ_ARCHIVE_OBJECT'exporting

archive_handle = archive_handleid = xvbbp-tdid language = xvbbp-tdspras name = xvbbp-tdname object = xvbbp-tdobject client = sy-mandt

importing header = l_text-head

tables lines = l_text-lines

exceptionsnot_found = 1wrong_access_to_archive = 2others = 3.

(C) SAP AG BC670 28

Page 150: BC670_v46c_en_2001_09

5.29

SAP AG 2002

Example: Output Texts (5)

format color col_background intensified off. i = i + 1. j = i mod 2.if j = 0.format color col_normal intensified off.

else.format color col_normal intensified.

endif.write: / sy-vline,

2 l_text-head-tdobject, 9 sy-vline.

if not l_text-lines[] is initial.loop at l_text-lines into xlines.write: 10 xlines-tdline.

endloop.write: 105 sy-vline.

endif.endloop.write: / sy-uline(105).

endif.

endform.

(C) SAP AG BC670 29

Page 151: BC670_v46c_en_2001_09

5.30

SAP AG 2002

Archived Data and Data from the Online Database

Selection and output of data from the online database

Create checkbox: Do you want to edit archived data in the report?

Optional:

Call ADK function module to read archived data

Output archived data

You can use check boxes to make processing as sophisticated as you want.

(C) SAP AG BC670 30

Page 152: BC670_v46c_en_2001_09

5.31

SAP AG 2002

Exercise “Read Sales Activities” - Data Model

VBUKHeader status

VBELN

VBKASales

activity

VBELN

VBPAVBFADocument

flow

VBUVIncomplete.

log

Addresslist

SADLSTWUSADLSTADM

...

NASTMessages

Changedocuments

VBPA2Partner

Central address

management

SAPScripttexts

(C) SAP AG BC670 31

Page 153: BC670_v46c_en_2001_09

5.32

S A P A G 2 0 0 2

E x e r c i s e “ R e a d S a l e s A c t i v i t i e s ” : T a b l e S t r u c t u r e

V B K A

V B E L N S D d o c u m e n t n o . o f a s a l e s a c t i v i t y i n s a l e s s u p p o r tE R D A T D a t e o n w h i c h t h e r e c o r d w a s c r e a t e dE R Z E T E n t r y t i m eE R N A M N a m e o f p e r s o n w h o c r e a t e d t h e o b j e c tA E D A T L a s t c h a n g e d o nA E Z E T T i m e l a s t c h a n g e w a s m a d eA E N A M N a m e o f p e r s o n w h o c h a n g e d o b j e c tK T A A R S a l e s A c t i v i t y T y p e f o r S a l e s S u p p o r tV B T Y P S D d o c u m e n t c a t e g o r y. . . . . .

V B P A

V B E L N S a l e s d o c u m e n t n u m b e rP O S N R I t e m n u m b e r o f t h e S D d o c u m e n tP A R V W P a r t n e r f u n c t i o nK U N N R C u s t o m e r n u m b e rL I F N R A c c o u n t n u m b e r o f v e n d o r o r c r e d i t o rP E R N R P e r s o n n e l N u m b e rP A R N R N u m b e r o f c o n t a c t p e r s o nA D R N R A d d r e s sA B L A D U n l o a d i n g p o i n tL A N D 1 C o u n t r y k e yA D R D A A d d r e s s i n d i c a t o r

V B F A

V B E L V P r e c e d i n g s a l e s a n d d i s t r i b u t i o n d o c u m e n tP O S N V P r e c e d i n g i t e m o f a n S D d o c u m e n tV B E L N S u b s e q u e n t s a l e s a n d d i s t r i b u t i o n d o c u m e n tP O S N N S u b s e q u e n t i t e m o f a n S D d o c u m e n tV B T Y P _ N D o c u m e n t c a t e g o r y o f s u b s e q u e n t d o c u m e n tR F M N G R e f e r e n c e d q u a n t i t y i n b a s e u n i t o f m e a s u r eM E I N S B a s e u n i t o f m e a s u r e

(C) SAP AG BC670 32

Page 154: BC670_v46c_en_2001_09

5.33

SAP AG 2002

Create sequential readprograms for an archivingobject

Report archiving classesbelonging to an archivingobject in read programs

You are now able to:

Sequential Read Programs: Unit Conclusion

(C) SAP AG BC670 33

Page 155: BC670_v46c_en_2001_09

5.34Customer-specific reporting Exercises

Unit: Customer-Specific Reporting

Topic: Program for archived sales activities, Read without archiving classes

At the conclusion of these exercises, you will be able to:

Create a program that reads the archived sales activities without using archiving classes

You have archived sales activities and want to create a reporting program for them.

1-1 Reporting program for archived sales activities Copy the report Z00VBKAREAD to your report ZxxVBKAREADThis report already contains a column header.The program also contains data definitions for all of the tables used in SD_VBKAD

1-2 Use the list header to familiarize yourself with the list layout. Look at the SD_VBKA data model on the last page in this unit. Here, you can also find the definition structure for tables VBKA, VBPA, VBFA.

1-3 Build the function module ARCHIVE_OPEN_FOR_READ into your program

1-4 Build the function module ARCHIVE_GET_NEXT_OBJECT into your program

(C) SAP AG BC670 34

Page 156: BC670_v46c_en_2001_09

1-5 With the help of the function module ARCHIVE_GET_TABLE, read each table from SD_VBKA .Record_structure is respectively: VBKA VBFA VBPA

Call the function module 3 times with each new Record_structure. (Export parameter record_structure)Process all of the records belonging to an object (export parameter all_record_of_object). Pass the archive_handle (export parameter archive_handle).

Import a table with the hitlists of the individual table records. The table, to which the data is transferred, is for VBFA and VBPA the internal table 'X<original table name>'. For VBKA, the structure YVBKA is imported. YVBKA is then assigned to XVBKA.

1-6 Close the archive file with the function module ARCHIVE_CLOSE_FILE

1-7 Output the data in the format of a layout in a form routine OUTPUT_DOC_INFO.

1-7-1 Output the data from XVBKA: the required names can be found in the appendix.'document no.' starting at position 2'sales activity type' starting at position 14'creation date' starting at position 21'created by' starting at position 40'change date' starting at position 56

1-7-2 Loop via XVBPA'partner function' starting at position 21'contact person number' starting at position 40'address' starting at position 47

1-7-3 Loop via XVBFA'document number of subsequent document' starting at position 60'type of subsequent document' starting at position 71

(C) SAP AG BC670 35

Page 157: BC670_v46c_en_2001_09

2-1 Test the program in transaction SE38

3-1 If the data is output correctly, enter your program in transaction AOBJ as a read program for SD_VBKA and test it again by calling it from transaction SARA.

(C) SAP AG BC670 36

Page 158: BC670_v46c_en_2001_09

Unit: Customer-Specific Reporting

Topic: Program for sales activities for a sales order Read with archiving classes

At the conclusion of these exercises, you will be able to:

Create a program to read archived sales activities using the archiving class TEXT

You have archived sales activities and want to create a reporting program for them.

1-1 Output archived sales activities with texts Copy the program Z00VBKAREADTEXT to your program ZxxVBKAREADTEXT

1-2 Build into the program (in the output form routine after the output of the last table) the reporting of texts that have been archived with a sales activity.

1-2-1 First collect the texts belonging to an object by calling the function module SELECT_TEXT_ARCHIVE_OBJECTExport parameter: Archive_handle Import parameter: Entries - Text_entriesTable: txt_tab

(C) SAP AG BC670 37

Page 159: BC670_v46c_en_2001_09

1-3 If the call is successful and text_entries > 0 Read the actual texts

Loop via table txt_tabFor each record, call function module TEXT_READ_ARCHIVE_OBJECT

Export parameter: ID: txt_tab.tdidlanguage: txt_tab-tdsprasname: txt_tab-tdnameobject: tst_tab-tdobjectarchive_handle

A table (lines) is returned containing the texts found. It is read according to text lines.

.

1-4 Output the data:

Loop via Text_linesText at position 4 (text_lines-tdline)

(C) SAP AG BC670 38

Page 160: BC670_v46c_en_2001_09

5.35Customer-specific reporting Solutions

Unit: Customer-Specific Reporting

Topic: Program for archived sales activities, Read without archiving classes

1-1 Tools, ABAP Workbench, Development, ABAP Editor

Copy Z00VBKAREAD to ZxxVBKAREAD. (XX represents your group number)

1-2 Information in appendix

1-3 to 1-7 See sample program ZSDVBKAREAD

2-1 Tools, ABAP Workbench, Development, ABAP Editor

Enter ZxxVBKAREAD. (XX represents your group number.)Execute program

3-1 Call transaction AOBJ

Mark SD_VBKADialog structure read progams Enter ZxxSDVBKASave

(C) SAP AG BC670 39

Page 161: BC670_v46c_en_2001_09

REPORT ZSDVBKAREAD .

*&---------------------------------------------------------------------**& archive read program for sales activites **& **&---------------------------------------------------------------------*

TABLES: VBKA, VBFA, VBPA.

DATA: "XVBKA LIKE VBKA OCCURS 0 WITH HEADER LINE, YVBKA LIKE VBKA OCCURS 0 WITH HEADER LINE,

XVBFA LIKE VBFA OCCURS 0 WITH HEADER LINE, YVBFA LIKE VBFA OCCURS 0 WITH HEADER LINE,

XVBPA LIKE VBPA OCCURS 0 WITH HEADER LINE,

BEGIN OF XVBKA. INCLUDE STRUCTURE VBKA.DATA: END OF XVBKA.

DATA: AR_HANDLE TYPE SY-TABIX.

CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ' EXPORTING OBJECT = 'SD_VBKA' IMPORTING ARCHIVE_HANDLE = AR_HANDLE EXCEPTIONS OTHERS = 8.

IF SY-SUBRC <> 0. WRITE: / 'error open file'. STOP. ENDIF.

WRITE /. DO.

CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT' EXPORTING ARCHIVE_HANDLE = AR_HANDLE EXCEPTIONS OTHERS = 6. . IF SY-SUBRC <> 0. EXIT. ENDIF.

* Table VBKA has only one record for each sales activity. In the data* structure you find VBKA AFTER VBUK. Therefore you must read several* records, im you use function module 'ARCHIVE_GET_NEXT_RECORD'.* The program performance will be better, if you use function module* ARCHIVE_GET_TABLE to find and read the VBKA record.

CALL FUNCTION 'ARCHIVE_GET_TABLE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE RECORD_STRUCTURE = 'VBKA' ALL_RECORDS_OF_OBJECT = 'X' TABLES TABLE = YVBKA EXCEPTIONS OTHERS = 4. READ TABLE YVBKA INDEX 1 INTO XVBKA.

CALL FUNCTION 'ARCHIVE_GET_TABLE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE

(C) SAP AG BC670 40

Page 162: BC670_v46c_en_2001_09

RECORD_STRUCTURE = 'VBFA' ALL_RECORDS_OF_OBJECT = 'X' TABLES TABLE = XVBFA EXCEPTIONS OTHERS = 4.

CALL FUNCTION 'ARCHIVE_GET_TABLE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE RECORD_STRUCTURE = 'VBPA' ALL_RECORDS_OF_OBJECT = 'X' TABLES TABLE = XVBPA EXCEPTIONS OTHERS = 4.

PERFORM OUTPUT_DOC_INFO.

ENDDO. CALL FUNCTION 'ARCHIVE_CLOSE_FILE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE.

FORM OUTPUT_DOC_INFO.

WRITE: /1 XVBKA-VBELN, 15 XVBKA-KTAAR, 22 XVBKA-ERDAT, 40 XVBKA-ERNAM, 56 XVBKA-AEDAT.

LOOP AT XVBPA. WRITE: /22 XVBPA-PARVW, 40 XVBPA-PARNR, 56 XVBPA-ADRNR. ENDLOOP.

LOOP AT XVBFA. WRITE: /56 XVBFA-VBELN, 71 XVBFA-VBTYP_N. ENDLOOP.

ENDFORM.

(C) SAP AG BC670 41

Page 163: BC670_v46c_en_2001_09

Unit: Customer-specific reporting

Topic: Program for archived sales activities Read with archiving classes

1-1 Tools, ABAP Workbench, Development, ABAP Editor

Copy Z00VBKAREADTEXT to ZxxVBKAREADTEXT.(XX represents your group number)

1-2 to 1-4 see sample program ZSDVBKAREADTEXT

(C) SAP AG BC670 42

Page 164: BC670_v46c_en_2001_09

REPORT ZSDVBKAREADTEXT .

*&---------------------------------------------------------------------**& archive read program for sales activites **& **&---------------------------------------------------------------------*

TABLES: VBKA, VBFA, VBPA.

PARAMETERS: AUSGTEXT AS CHECKBOX.

DATA: YVBKA LIKE VBKA OCCURS 0 WITH HEADER LINE,

XVBFA LIKE VBFA OCCURS 0 WITH HEADER LINE, YVBFA LIKE VBFA OCCURS 0 WITH HEADER LINE,

XVBPA LIKE VBPA OCCURS 0 WITH HEADER LINE,

BEGIN OF XVBKA. INCLUDE STRUCTURE VBKA.DATA: END OF XVBKA.

DATA: TXT_TAB LIKE THEAD OCCURS 0 WITH HEADER LINE.DATA: TEXT_LINES LIKE TLINE OCCURS 0 WITH HEADER LINE.DATA: TEXT_ENTRIES LIKE SY-TFILL.

DATA: AR_HANDLE TYPE SY-TABIX.

CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ' EXPORTING OBJECT = 'SD_VBKA' IMPORTING ARCHIVE_HANDLE = AR_HANDLE EXCEPTIONS OTHERS = 8.

IF SY-SUBRC <> 0. WRITE: / 'no archive files'. STOP.ENDIF.

WRITE /.DO.

CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT' EXPORTING ARCHIVE_HANDLE = AR_HANDLE EXCEPTIONS OTHERS = 6.

IF SY-SUBRC <> 0. WRITE: / ' no object'. EXIT. ENDIF.

* Table VBKA has only one record for each sales activity. In the data* structure you find VBKA AFTER VBUK. Therefore you must read several* records, im you use function module 'ARCHIVE_GET_NEXT_RECORD'.* The program performance will be better, if you use function module* ARCHIVE_GET_TABLE to find and read the VBKA record.

CALL FUNCTION 'ARCHIVE_GET_TABLE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE RECORD_STRUCTURE = 'VBKA' ALL_RECORDS_OF_OBJECT = 'X' TABLES TABLE = YVBKA EXCEPTIONS

(C) SAP AG BC670 43

Page 165: BC670_v46c_en_2001_09

OTHERS = 4.

XVBKA = YVBKA.

CALL FUNCTION 'ARCHIVE_GET_TABLE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE RECORD_STRUCTURE = 'VBFA' ALL_RECORDS_OF_OBJECT = 'X' TABLES TABLE = XVBFA EXCEPTIONS OTHERS = 4.

CALL FUNCTION 'ARCHIVE_GET_TABLE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE RECORD_STRUCTURE = 'VBPA' ALL_RECORDS_OF_OBJECT = 'X' TABLES TABLE = XVBPA EXCEPTIONS OTHERS = 4.

PERFORM OUTPUT_DOC_INFO.

ENDDO.

CALL FUNCTION 'ARCHIVE_CLOSE_FILE' EXPORTING ARCHIVE_HANDLE = AR_HANDLE.

*---------------------------------------------------------------------** FORM OUTPUT_DOC_INFO **---------------------------------------------------------------------** ........ **---------------------------------------------------------------------*FORM OUTPUT_DOC_INFO.

DATA: XSTADM_LINES TYPE N. DATA: TEXTNAME LIKE THEAD-TDNAME.

WRITE: /1 XVBKA-VBELN, 15 XVBKA-KTAAR, 22 XVBKA-ERDAT, 40 XVBKA-ERNAM, 56 XVBKA-AEDAT.

LOOP AT XVBPA. WRITE: /22 XVBPA-PARVW, 40 XVBPA-PARNR, 56 XVBPA-ADRNR. ENDLOOP.

LOOP AT XVBFA. WRITE: /56 XVBFA-VBELN, 71 XVBFA-VBTYP_N. ENDLOOP.

IF AUSGTEXT = 'X'.

* Select text belonging to the current document

CALL FUNCTION 'TEXT_SELECT_ARCHIVE_OBJECT' EXPORTING ARCHIVE_HANDLE = AR_HANDLE IMPORTING ENTRIES = TEXT_ENTRIES TABLES SELECTIONS = TXT_TAB EXCEPTIONS OTHERS = 2.

IF TEXT_ENTRIES > 0 AND SY-SUBRC = 0.* loop through all text entries

(C) SAP AG BC670 44

Page 166: BC670_v46c_en_2001_09

LOOP AT TXT_TAB.* Read the text CALL FUNCTION 'TEXT_READ_ARCHIVE_OBJECT' EXPORTING ARCHIVE_HANDLE = AR_HANDLE ID = TXT_TAB-TDID LANGUAGE = TXT_TAB-TDSPRAS NAME = TXT_TAB-TDNAME OBJECT = TXT_TAB-TDOBJECT TABLES LINES = TEXT_LINES EXCEPTIONS OTHERS = 3.* Display the text on screen

LOOP AT TEXT_LINES. WRITE: / TEXT_LINES-TDLINE. ENDLOOP. SKIP 3. ENDLOOP. ENDIF.

ENDIF.

ENDFORM.

(C) SAP AG BC670 45

Page 167: BC670_v46c_en_2001_09

6

SAP AG 2002

Logic of direct read access using SAP AS

Creating a business view for MM_MATBEL in SAP AS

Contents:

Direct Read Access to Archived Data

(C) SAP AG BC670 1

Page 168: BC670_v46c_en_2001_09

6.2

SAP AG 2002

Create business views for archiving objects in SAP AS

At the conclusion of this unit, you will be able to:

Direct Read Access: Unit Objectives

SAP AG 1999

(C) SAP AG BC670 2

Page 169: BC670_v46c_en_2001_09

6.3

SAP AG 2002

Course Overview Diagram

Course Overview

The Data Archiving Process

ADK Development Tools

Data Archiving Programming Logic

Customer-Specific Read Programs

Business Views in SAP AS

Appendix

(C) SAP AG BC670 3

Page 170: BC670_v46c_en_2001_09

6.4

SAP AG 2002

You have to create a business view for an archiving object in SAP AS.

Direct Read Access : Business Scenario

SAP AG 1999

(C) SAP AG BC670 4

Page 171: BC670_v46c_en_2001_09

6.5

SAP AG 2002

Archive Reporting with SAP AS

Methods independent of archiving object

Generic solution for presenting archived data

Direct single document access

Configurable

SAP AG 1999

The archived data can always be presented in a technical view. Business views are available in the standard system for selected objects and customers can create their own additional business views.The available function modules can serve as frameworks.

Specific archiving sessions can be selected for reporting purposes.Also, specific archive information structures can be selected as reporting inputs.

At technical view level, additional functions such as search, sort and summarize are provided.

(C) SAP AG BC670 5

Page 172: BC670_v46c_en_2001_09

6.6

SAP AG 2002

Field catalog

Contains from the archiving object’s database tables

Key fields

Fields that are important for customer’s search functionality

Field catalog fields are available to the Archive Information System.

Field catalogs are provided by the applications.

Customers can define their own field catalogs to meet their specific requirements.

Field Catalogs

SAP AG 1999

(C) SAP AG BC670 6

Page 173: BC670_v46c_en_2001_09

6.7

SAP AG 2002

Creating Field Catalog for MM_MATBEL

Field catalog for MM_MATBEL

Create field catalog

Fld. catalog Description Arch.object File Offset

Fi-Docs. Fi-Docs. FI_DOCUMNT D DZcoitem Controlling CO_ITEM K K Mmatbel Material docs MM_MATBEL D D

Archive information structures are based on field catalogs.There is one table per archive information structure, which incorporates all records from all of the selected archiving sessions.

By making ‘file’ and ‘offset’ entries, you can guarantee the uniqueness of the key for all archiving sessions.

Explanation of the entries in the slide:

FI documents are unique for every application key, as the fiscal year is part of the key. Therefore, the archive key and the offset do not have to be included in the key.

In other applications, keys can be reassigned after an archiving session.Therefore, for example in SD, the name of the archive file (which is declared as part of the key in SAP AS), guarantees uniqueness over more than one archiving session.

Cost centers may have many line items that do not fit into a data object.In order to keep the key unique, the offset in an archive file is incorporated into a key.

(C) SAP AG BC670 7

Page 174: BC670_v46c_en_2001_09

6.8

SAP AG 2002

Standard Field Catalog MM_MATBEL

Field selection includes all fields that you want to use for your search

fld.no. target fld. key source tab. source fld. mand.

10 MBLNR x MSEG MBLNR20 MJAHR x MSEG MJAHR25 ZEILE x MSEG ZEILE30 VGART MKPF VGART40 BLDAT MKPF BLDAT50 BUDAT MKPF BUDAT

.....110 MATNR MSEG MATNR120 WERKS MSEG WERKS.....

When the field catalog is created, the key fields from table MSEG must be assigned to table MKPF using the function ‘additional source fields’.

SAP AG 1999

This field catalog contains fields from table MKPF and fields from table MSEG. If more than one table is used, the function ‘additional source fields’ is used.

The field catalog key fields from table MSEG must also be present in table MKPF and are assigned to table MKPF using the function ‘additional source fields’.

(C) SAP AG BC670 8

Page 175: BC670_v46c_en_2001_09

6.9

SAP AG 2002

Alternative Field Catalog for MM_MATBEL (2)

The material number is your search criterion.

Possible field selection for the field catalog

Fld.no. Target fld. Key Source tab. Source fld. mand.

10 matnr x mseg matnr x20 mblnr x mseg mblnr30 mjahr x mseg mjahr

The pointer to ‘additional source fields’ is omitted.

(C) SAP AG BC670 9

Page 176: BC670_v46c_en_2001_09

6.10

SAP AG 2002

SAP AS Components

SAP R/3 application customer

sets up

n field catalogs per archiving object

carry fields over to

n archive information structuresbased on a field catalog

Reportingprogram

The field catalogs are assigned to archiving objects. They contain fields from the archiving object tables. These fields can be incorporated in archive information structures. Standard field catalogs are delivered with the archive information system. You should only create customer-specific field catalogs as exceptions.

Archive information structures are the foundation for reporting within the Archive Information System. They are defined using the Archive Retrieval Configurator and are based on the field catalogs. Customers incorporate into the archive information structures the key fields that uniquely identify an object and the data fields that meet their information requirements. These fields are filled with the archived data and thereby allow the archive files to be reported.

Archive information structures must be activated. When they are activated, a transparent table with defined data structures is created in R/3. A reporting program is also generated. The table is filled with data during the deletion part of the archiving session. The table can also be filled in a separate process as an administrative function. Reporting is based on this data.

(C) SAP AG BC670 10

Page 177: BC670_v46c_en_2001_09

6.11

SAP AG 2002

Archive Information Structures

Archive information structure

The archive information structure contains an extract of thearchived data.

Information structures are dependent on the archiving object.. There can be more than one information structure for eacharchiving object.

There is a transparent database table for each information structure.

SAP AG 1999

Several field catalogs can be defined for one archiving object. Several archive information structures can also be defined for one archiving object. However, an archive information structure always refers to one specific field catalog. Fields used in archive information structures must be contained in the assigned field catalog.

(C) SAP AG BC670 11

Page 178: BC670_v46c_en_2001_09

6.12

SAP AG 2002

ArchiveArchivefilefile

ArchiveArchivefilefile

ArchiveArchivefilefile

ArchiveArchivefilefile

Filling the Archive Information Structures

R/3 R/3 DatabaseDatabase

Deleteprogram

Delete program

Variant 1:fill duringdelete run

Variant 2:fill after explicitinstruction from SAP AS

Both variants are equally valid. Automatic fill during delete program run:

If an information structure is active, it s filled automatically during the archiving session’s delete program run.

By explicitly activating and deactivating the information structures before the start of the delete program run, you can specify that only those information structures that are always going to be used as a means of accessing information are to be filled.

Explicit instruction from SAP AS:You can fill the archive information structure tables at any time with data from existing archive files.To do this, go to SAP AS administration.

(C) SAP AG BC670 12

Page 179: BC670_v46c_en_2001_09

6.13

SAP AG 2002

Data Display in SAP AS

Reporting data from the archive information structure

The structure table entries are displayed on the screen as in SE16.

No access to the ADK file is required for this display.

Double-click a table line for direct access to the data object in the ADK archive

The data display is possible for all archiving objects in a technical view. This view lists the individual tables with their values.

You can program a business view of the data.

The standard system in Release 4.6 contains business views for 14 objects.Further business views are planned.Customer-specific business views can also be created by the customer.

(C) SAP AG BC670 13

Page 180: BC670_v46c_en_2001_09

6.14

SAP AG 2002

Reporting Archive Info Structures: Archive Explorer

Reportingprogram

The system generates areporting program for eachinformation structure

Archive access is not required for this step

List for archive info structure T_CO_ORDER

Order .......... to ..........Cap. ...... to ......

Short text .................... to ....................

Maximum hits 500

List for archive information structure T_CO_ORDER

Order Date of Entry Short Text100000 12.10.1998 service car lot 97-5100001 12.10.1998 repair 76A8/67 98-5100002 12.10.1998 service car lot 97-6100003 12.10.1998 TechEd KA 98....

Transaction SARI selection screen

Trefferliste

Call transaction SARI Button ‘Archive Explorer’Select the desired archiving object and archive information structure.

The system displays the table records from the archive information structure table. The display is the same as the table view in transaction SE16.

No access to archive files is required for this list of structure records containing an extract of archived data.

From this list you can branch to an object’s technical view. This view is possible for all objects that can be accessed in SAP AS.

(C) SAP AG BC670 14

Page 181: BC670_v46c_en_2001_09

6.15

SAP AG 2002

Access to Individual Data Objects: Technical View

List for archive information structure T_CO_ORDER

Order Date of Entry Short Text100000 12.10.1998 Service 100001 12.10.1998 Repair 76A8/67 98-5 100002 12.10.1998 Service 100003 12.10.1998 TechEd KA ‚98‘....

Display data object from archive: Table view

000143-001CO_ORDER

Table AUFK 1 Order master dataTable COBRA 1 Sett. rule for order settlementTable COBRB 2 Dist. rules sett. rule order Sett.Table COKA 1 CO-Object: Control data

List for archive info structure T_CO_ORDER

Amount in object curr. 345.00Amount currency 345.00

0Document key OR0000000100095Fiscal year 1998Class 94Version 0

List for archive info structure T_CO_ORDER

CO Doc. no PR Per Amount Curr

0001 200000005 1 10 1,200.00 UNI0001 200000006 1 10 345.00 UNI

Display data object

Select the desireddisplay function

Display master dataTechnical view X

By double clicking, you can access the archived document directly from the list display.

You access individual data record in the offset, which is stored in the archive information structure. The relevant archive file is read directly.

For direct access to the archived data, the system checks the authorization objects S_ARCHIVE and S_TABU_DIS.For more information on the creation of customer-specific authorization objects, refer to SAP Note 175901.

(C) SAP AG BC670 15

Page 182: BC670_v46c_en_2001_09

6.16

SAP AG 2002

Access to Individual Data Objects: Business View

List for archive information structure T_CO_ORDER

Order Date of Entry Short text100000 12.10.1998 Service 100001 12.10.1998 Repair 76A8/67 98-5100002 12.10.1998 Service100003 12.10.1998 TechEd KA ‚98‘....

Display internal: Master data xxx

Order 100003 Order type PFE1Short text TechED KA ‚98‘

Systemstatus Rel DLT SETCStatus number 0

Control data

Currency DEMOrder category 1

Display data object

Select the desired display function

Display master dataBusiness view X

The business view of a data record is created using function modules. They are listed in table AIND_STR5.

(C) SAP AG BC670 16

Page 183: BC670_v46c_en_2001_09

6.17

SAP AG 2002

Programming Logic: Direct Single-Document Access

Archive_read_object

Archive_get_next_record

READ_TEXT (Archiving class “TEXT”)

Archive_close_file

SAP AG 1999

ARCHIVE_READ_OBJECT includes ARCHIVE_OPEN_FOR_READ and ARCHIVE_GET_NEXT_OBJECT and searches the required data object in the archive file.

Before calling the function module again, ARCHIVE_CLOSE_FILE must be called for the returned handle.

(C) SAP AG BC670 17

Page 184: BC670_v46c_en_2001_09

6.18

SAP AG 2002

ADK API: ARCHIVE_READ_OBJECT

Interface parameter import

Object

Archive key

Offset

Interface parameter export

archive_handle

Function module functionality:

This function module reads a specific data object from an archiving object in an archiving file and returns a handle for further processing. If the archive file was stored using ArchiveLink, it is also possible to read the data object using this function module. The different forms of processing are dealt with by this function module. After the data object has been read by ARCHIVE_READ_OBJECT, you can access the data using the function module ARCHIVE_GET_NEXT_RECORD or using the handle.

The name of the archiving object is transferred in the interface parameter object’. The archive key supplies the archive file and the offset of the required doucment in the arhcive file.

In turn, the information for offset and archive key are copied from the archive information structure table from SAP AS.

Note:The function module is intended for interactive reporting - that is - for the display on screen of a specific document.It is not intended for reading documents in archive files in the context of sequential evaluations.

(C) SAP AG BC670 18

Page 185: BC670_v46c_en_2001_09

6.19

SAP AG 2002

Structure of a Read Program with Direct Access

Declaration Internal tables (itabA. itabB, itabC)

Determine Archive key and Offsetselect single archive_key offset from IndexTablewhere ...

import: archive_key, offset

Include object in the ADK work areaARCHIVE_READ_OBJECT

export: archive_key, offset import: archive_handle

Include in progam the next record belonging to objectARCHIVE_GET_NEXT_RECORD

export: archive_handleimport: record_structure, record

Output record

Close archive filesARCHIVE_CLOSE_FILE

export: archive_handle

Loop, so long asrecords are present

If necessary, you must also read an archiving class

(C) SAP AG BC670 19

Page 186: BC670_v46c_en_2001_09

6.20

SAP AG 2002

Views in SAP AS

Lists belonging to archive info structure T_CO_ORDER

Order Date of entry Short text100000 12.10.1998 Service 100001 12.10.1998 Repair 76A8/67 98-5100002 12.10.1998 Service100003 12.10.1998 TechEd KA ‚98‘....

Display internal order: master data xxx

Order 100003 Order type PFE1Short text TechED KA ‚98‘

System status Rel DLT SETCStatus number 0

Contol data

Currency DEMOrder category 1

Field ‘Alternative’ in tableAIND_STR5

Display data object Select desired displayfunctionality

Technical viewDisplay data from FMcopied screen X

The business view of a data record is created using function modules. They are listed in the table AIND_STR5.

(C) SAP AG BC670 20

Page 187: BC670_v46c_en_2001_09

6.21

SAP AG 2002

Dialog Box ‘Business View’

Create a dialog box text for selecting the business view

Table entry with name of the display function module in table ‘AIND_STR5’

Object name: <processed archiving object >

Display function module: Name of the function module created

Line: Defines the sequence in the dialog box

text: Display text in the dialog box, link to application-specific view

SAP AG 1999

Create entries:

1) Call table AIND_STR5 via Tools -> ABAP Workbench -> Overview -> Data Browser 2) Button CREATE

3) Carry out entries for Object Function Line Text

4) Button SAVE -> entry written in table

(C) SAP AG BC670 21

Page 188: BC670_v46c_en_2001_09

6.22

SAP AG 2002

Table AIND_STR5

OBJECT FUNCTION LINE TEXT

MM_MATBEL 05 matdoc - technical MM_MATBEL MM_MATBEL_DISPLAY_DATA_DYN 40 copied screen MM_MATBEL MM_MATBEL_DISPLAY_DATA 01 display data from fmRV_LIKP 05 RV_LIKP RV_LIKP_01_DISPLAY_DATA 01 delivery - document RV_LIKP RV_LIKP_01_DISPLAY_DATA2 02 display originals SD_VBAK 05 SD_VBAK SD_VBAK_01_DISPLAY_DATA 01 order - document SD_VBAK SD_VBAK_01_DISPLAY_DATA2 02 display originals SD_VBRK 05 SD_VBRK SD_VBRK_01_DISPLAY_DATA 01 billing document SD_VBRK SD_VBRK_01_DISPLAY_DATA2 02 display originals

Note:As soon as an application-specific display function has been entered in table aind_str5, the technical view no longer appears.

If you want to provide both options, you must also create an entry for the technical view in aind_str5. This entry has the value ‘space’ for the function. Text can also remain empty.

Entries must be transported manually.You can use the function ‘table entry -> transport entries’ in transaction SE16 to do this.

(C) SAP AG BC670 22

Page 189: BC670_v46c_en_2001_09

6.23

SAP AG 2002

Function Module ‘Business View’

Create function module in customer namespace.

Create function group <zxxxxx>.

Create function module <zyyyyy> in function group.

Adjust function module in line with the selected object.

SAP AG 1999

Create function group: Tools -> ABAP Workbench -> Overview -> Object Browser

(C) SAP AG BC670 23

Page 190: BC670_v46c_en_2001_09

6.24

SAP AG 2002

Function Module Interface

Interface similar to function module KASH_ARCHIVE_DATA_OBJECT_SHOW

Passing parameters

I_ARCHIVEKEYName of archive file as it appears in archive management

I_OFFSETOffset of data object in the archive for direct access

SAP AG 1999

(C) SAP AG BC670 24

Page 191: BC670_v46c_en_2001_09

6.25

SAP AG 2002

Output of the Business View

Output control options

The list output is programmed directly in the function module.

Display on the customer-specific screen, which switches to list processing.You can use an existing program for the list processing.

SAP AG 1999

(C) SAP AG BC670 25

Page 192: BC670_v46c_en_2001_09

6.26

SAP AG 2002

Output Directly from the Function Module

Control output without a screen

The list output occurs directly in the function module.

Create a list structure using WRITE statements.

SAP AG 1999

As soon as there is more than one function module in the function group, the globally used tables and data must be present in the global area.

(C) SAP AG BC670 26

Page 193: BC670_v46c_en_2001_09

6.27

SAP AG 2002

Output Directly from the FM: MM_MATBEL (1)

function mm_matbel_display_data. *"----------------------------------------------------------------------*"*"Local interface: *" IMPORTING *" VALUE(I_ARCHIVEKEY) LIKE ADMI_FILES-ARCHIV_KEY *" VALUE(I_OFFSET) LIKE ARCH_IDX-OFFSET *" EXCEPTIONS *" OBJECT_NOT_FOUND *"----------------------------------------------------------------------

tables: arc_buffer, mkpf, mseg, makt. data: handle like sy-tabix. data: xmaktx like makt-maktx.

call function 'ARCHIVE_READ_OBJECT' exporting

object = 'MM_MATBEL' archivkey = i_archivekey offset = i_offset

importing archive_handle = handle

exceptions others = 12.

(C) SAP AG BC670 27

Page 194: BC670_v46c_en_2001_09

6.28

SAP AG 2002

Output Directly from the FM: MM_MATBEL (2)

if not sy-subrc is initial. message id sy-msgid type 'I' number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. exit.

endif. do. call function 'ARCHIVE_GET_NEXT_RECORD'

exporting archive_handle = handle

importing record = arc_buffer-segment record_structure = arc_buffer-rname

exceptions end_of_object = 1.

if sy-subrc = 1. exit.

endif.

(C) SAP AG BC670 28

Page 195: BC670_v46c_en_2001_09

6.29

SAP AG 2002

Output Directly from the FM: MM_MATBEL (3)

case arc_buffer-rname. when 'MKPF'.mkpf = arc_buffer-segment. write: / ' ', mkpf-mblnr, mkpf-mjahr. write: / sy-uline(105). format color col_heading intensified. skip 2.

write: /2 ‘Posting date:’, 18 mkpf-budat, 66 'Name:', 73 mkpf-usnam.

skip 2. write: /2 ‘Items’. skip 1. write: /4 'Pos',

10 ‘Amount’, 30 'EME',

(C) SAP AG BC670 29

Page 196: BC670_v46c_en_2001_09

6.30

SAP AG 2002

Output Directly from the FM: MM_MATBEL (4)

35 'Material', 55 ‘Plant’, 60 ‘Loc’.

write: /35 ‘Material short text’, 73 'BwA'.

skip 1.

when 'MSEG'.mseg = arc_buffer-segment. write: /5 mseg-zeile, mseg-matnr. write: /4 mseg-zeile,

10 mseg-erfmg, 30 mseg-erfme, 35 mseg-matnr, 55 mseg-werks,

60 mseg-lgort.

(C) SAP AG BC670 30

Page 197: BC670_v46c_en_2001_09

6.31

SAP AG 2002

Output Directly from the FM: MM_MATBEL(5)

select maktx into xmaktx from makt where matnr = mseg-matnr. endselect. write: /35 xmaktx,

73 mseg-bwart.

endcase. enddo.

call function 'ARCHIVE_CLOSE_FILE' exporting

archive_handle = handle.

endfunction.

(C) SAP AG BC670 31

Page 198: BC670_v46c_en_2001_09

6.32

SAP AG 2002

Output with Screen and List Processing

Contol output

Create screen for function group

Screen-call in function module with switch to list function

Fill and output lists

SAP AG 1999

(C) SAP AG BC670 32

Page 199: BC670_v46c_en_2001_09

6.33

SAP AG 2002

Screen/List Output: MM_MATBEL (1)

function mm_matbel_display_data_dyn. *"----------------------------------------------------------------------*"*"Local interface: *" IMPORTING *" VALUE(I_ARCHIVEKEY) LIKE ADMI_FILES-ARCHIV_KEY *" VALUE(I_OFFSET) LIKE ARCH_IDX-OFFSET *" EXCEPTIONS *" OBJECT_NOT_FOUND *"----------------------------------------------------------------------

refresh: i_mkpf, i_mseg.

call function 'ARCHIVE_READ_OBJECT'exporting

object = 'MM_MATBEL'archivkey = i_archivekey offset = i_offset

importing archive_handle = handle

exceptions

others = 12.

(C) SAP AG BC670 33

Page 200: BC670_v46c_en_2001_09

6.34

SAP AG 2002

Screen/List Output: MM_MATBEL (2)

if not sy-subrc is initial.message id sy-msgid type 'E' number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.endif.

do.call function 'ARCHIVE_GET_NEXT_RECORD'

exporting archive_handle = handle

importing record = arc_buffer-segment record_structure = arc_buffer-rname

exceptionsend_of_object = 1.

if sy-subrc = 1.exit.

endif.

(C) SAP AG BC670 34

Page 201: BC670_v46c_en_2001_09

6.35

SAP AG 2002

Screen/List Output: MM_MATBEL (3)

case arc_buffer-rname.

when 'MKPF'. i_mkpf = arc_buffer-segment.append i_mkpf.

when 'MSEG'. i_mseg = arc_buffer-segment.append i_mseg.

endcase.enddo.

call screen 200.

call function 'ARCHIVE_CLOSE_FILE'exporting

archive_handle = handle.

endfunction.

(C) SAP AG BC670 35

Page 202: BC670_v46c_en_2001_09

6.36

SAP AG 2002

Screen/List Output: MM_MATBEL (4)

process before output.module status_0200.

module display_list_materialdocuments.

process after input.module user_command_200.

flow logicscreen 200

Switch to list processing

Read/output

internal tables

header/item data

Empty module/unnecessary,

because of switch to

list processing

(C) SAP AG BC670 36

Page 203: BC670_v46c_en_2001_09

6.37

SAP AG 2002

Screen/List Output: MM_MATBEL (5)

module status_0200 output.

suppress dialog.leave to list-processing and return to screen 0.

* SET PF-STATUS 'xxxxxxxx'. * SET TITLEBAR 'xxx'.

endmodule. " STATUS_0200 OUTPUT

module user_command_0200 input.

endmodule. " USER_COMMAND_0200 INPUT

(C) SAP AG BC670 37

Page 204: BC670_v46c_en_2001_09

6.38

SAP AG 2002

Screen/List Output: MM_MATBEL (6)

module display_list_materialdocument output.

write: /2 'Booking date:', 18 i_mkpf-budat, 66 'Name:', 73 i_mkpf-usnam.

skip 2.write: /2 ‘Items‘. skip 1.write: /4 'Pos',

10 ‘Set, 30 'EME', 35 'Material', 55 ‘Plant‘ 60 'LOrt'.

write: /35 'Material short text, 73 'BwA'.

skip 1.

(C) SAP AG BC670 38

Page 205: BC670_v46c_en_2001_09

6.39

SAP AG 2002

Screen/List Output: MM_MATBEL (7)

loop at i_mseg.write: /4 i_mseg-zeile,

10 i_mseg-erfmg, 30 i_mseg-erfme, 35 i_mseg-matnr, 55 i_mseg-werks,

60 i_mseg-lgort.

select maktx into xmaktx from makt where matnr = i_mseg-matnr.endselect.write: /35 xmaktx,

73 i_mseg-bwart.endloop.

endmodule. " DISPLAY_LIST_MATERIALDOCUMENT OUTPUT

(C) SAP AG BC670 39

Page 206: BC670_v46c_en_2001_09

6.40

SAP AG 2002

Displaying Archived Originals of R/3 Document (1)

Determine which business object type the document is assigned to.

Create key variable inprogram.

Construct key variable corresponding to key of the busineeobject type. The key is defined in the Business Object Repository (BOR).

Call Function Module ARCHIV_DISPLAY_META

Export: Name of the business object typeKey varialbe

Result: Display the archived originals, or a hit list of the originals

SAP AG 1999

As you can access the Business Object Repository in transaction SWO1 SAP ArchiveLink assigns a document type and a business object type to the archived originals The document type identifies the original document. Examples:

FIIINVPRELIncoming invoice preliminary postingFIIINVOICE Incoming invoice without verificationSDOORDER Order acknowledgement......

Archived originals are always related to an R/3 business object. The key of the accompanying business object is uniquely identified via the assignment to a business type. This is necessary for search strategies.

(C) SAP AG BC670 40

Page 207: BC670_v46c_en_2001_09

6.41

SAP AG 2002

Displaying Archived Originals of R/3 Document (2)

Determine which business object type the document is assigned to.

Report assignment of archived document to object type

Path: Tools -> Business Documents -> Basic Settings -> Links (transaction OAC3)

Examples:Doc. type Description Object typeFIIINVOICE incoming invoice BKPFFIIINVPREL invoice preliminary posting BKPFSDOORDER order acknowledgement VBAKMMOORDER order EKKO......

SAP AG 1999

If the object type is not found in ArchiveLink, you can set a breakpoint in the display transaction for the object at SWU_OBJECT_PUBLISH and debug so that the correct object type is transferred to OBJTYPE.

It is also possible to analyze link tables in ArchiveLink. By default, tables TOA01, TOA02, and TOA03 are used. The R/3 key for the object is stored here together with the object type and the document type.

(C) SAP AG BC670 41

Page 208: BC670_v46c_en_2001_09

6.42

SAP AG 2002

Display Archived Original of R/3 Document (3)

Create key definitions:<variable with key of the business document >

data: <variable name> like sapb-sapobjid. “key to be passed”

data: begin of objectid, “variable constructed according to the key of the business object type”

end of objectid.

Construct key according to business object

move <database field 1> to objectid-<xxx>.move <database field 2> to objectid-<zzz>.......Object_id = objectid.

SAP AG 1999

(C) SAP AG BC670 42

Page 209: BC670_v46c_en_2001_09

6.43

SAP AG 2002

Display Archived Original of R/3 Document (4)

Call function module ‘ARCHIV_DISPLAY_META’

call function 'ARCHIV_DISPLAY_META' exporting

sap_object = <Business object type> object_id = <variable with key to business document >

exceptions others = 1.

The function module displays the archived original.If more than one document is archived per R/3 document,the user obtains a hitlist from which to select the desired original.

(C) SAP AG BC670 43

Page 210: BC670_v46c_en_2001_09

6.44

SAP AG 2002

Example: Display Archived Original (1)

function fi_documnt_display_data_originale. *"----------------------------------------------------------------------*"*"Local interface: *" IMPORTING *" VALUE(I_ARCHIVEKEY) LIKE ADMI_FILES-ARCHIV_KEY *..........

*"----------------------------------------------------------------------

..........

data: begin of objectid,oidbukrs like bkpf-bukrs,oidbelnr like bkpf-belnr,oidgjahr like bkpf-gjahr,

end of objectid.data: object_id like sapb-sapobjid.

..........call function 'ARCHIVE_READ_OBJECT‘..........

(C) SAP AG BC670 44

Page 211: BC670_v46c_en_2001_09

6.45

SAP AG 2002

Example: Display Archived Original (2)

do.call function 'ARCHIVE_GET_NEXT_RECORD‘........

case arc_buffer-rname.when 'BKPF'.

bkpf = arc_buffer-segment. ........

endcase.enddo...........

* Output data

write: / ' ', bkpf-bukrs, bkpf-belnr, bkpf-gjahr.write: / sy-uline(105).

format color col_heading intensified.write: / sy-vline,

2 ‘Posting date, 16 sy-vline, 17 ‘Local currency,

..........

(C) SAP AG BC670 45

Page 212: BC670_v46c_en_2001_09

6.46

SAP AG 2002

Example: Display Archived Original (3)

write: / sy-vline, 2 bkpf-budat, 16 sy-vline, 17 bkpf-hwaer,

..........

* Output archived original of document

* Construct key

move bkpf-bukrs to objectid-oidbukrs.move bkpf-belnr to objectid-oidbelnr.move bkpf-gjahr to objectid-oidgjahr.object_id = objectid.

* Call function module ArchiveLink call function 'ARCHIV_DISPLAY_META'

exporting sap_object = 'BKPF'object_id = object_id

exceptions

others = 1.

(C) SAP AG BC670 46

Page 213: BC670_v46c_en_2001_09

6.47

SAP AG 2002

Addendum: Displaying Archiving Classes

Displaying archiving classes is possible in SAP AS from Release 4.6A.

In Release 4.5B, display of PP_ORDER in SAP AS is already implemented.

Programmable display functions for archivng classes withdirect access without using SAP AS:

Fill an index for the archived data or use a table in SAP AS

Implement a reporting program that accesses an individual document in the archiving class using the index.

SAP AG 1999

For more information on the previous development of PM_ORDER, refer to SAP Note 135784. Compare also Note 195425 for development regarding PM_ORDER, PM_QMEL,SM_QMEL, and QM_QMEL.

Further Notes on archiving classes in SAP AS:183774, 181598, 156780

(C) SAP AG BC670 47

Page 214: BC670_v46c_en_2001_09

6.48

SAP AG 2002

Single Document Access to Archiving Classes (1)

Program 1: Fill ADK index table

Fill:

Archive_open_for_read

Do

Archive_get_next_object

<Function module for reading the class>

Fill a customer-specific table with ADK- index values

Enddo

Archive_close_file

SAP AG 1999

With the function module Archive_get_next_object, you can determine the archive key and the offset of the document. Both of these are required for direct access to a document.

With the help of the function module, which reads the archiving class, you obtain the information that is required for an ADK-index.

You then store the ADK-index information in a customer-specific table.

(C) SAP AG BC670 48

Page 215: BC670_v46c_en_2001_09

6.49

SAP AG 2002

Single Document Access to Archiving Classes (2)

Program 2: Direct access to a document

Fill:

Read the ADK index table

Archive_read_object

<Function module for reading the class>

Archive_close_file

SAP AG 1999

(C) SAP AG BC670 49

Page 216: BC670_v46c_en_2001_09

6.50

SAP AG 2002

Integrate a business view for anarchiving object in SAP AS

Integrate display of archived originalsfor an R/3 document in SAP AS

You are now able to:

Direct Read Access: Unit Conclusion

(C) SAP AG BC670 50

Page 217: BC670_v46c_en_2001_09

6.51SAP AS Business Views Exercises

Unit: SAP AS Business Views

Topic: Creating a Business View for MM_EBAN

At the conclusion of these exercises, you will be able to:

Display archived purchase requisitions via a business view in SAP AS

You have archived purchase requisitions and, in addition to the technical views, the user department wants to have a business view

1-1 Create new function group ZBC670_xx. Here, create function module ZZMM_EBANxx, using as a template ZZMM_EBAN00.The function is part of Basis (Application S).

Create the following global data for the function module:

Table arc_bufferField handle like sy-tabixInternal table i_eban like ebanField ok-code like sy-ucomm

Familiarize yourself with the interface

1-1-2 Refresh table i_eban.

1-1-3 Call function module 'ARCHIVE_READ_OBJECT'. The transferred object is MM_EBAN. i_archive key and i_offset are also transferred. The function module returns a handle.

1-1-4 In a loop, call 'ARCHIVE_GET_NEXT_RECORD'. This transfers parts of arc_buffer. The exception is end_of object. After calling the function module, EXIT if the exception is fulfilled.

1-1-5 In a CASE structure, query the contents of ARC_BUFFER_RNAME and fill the internal table i_eban with the data from ARC_BUFFER_SEGMENT.

1-1-6 Close the archive file

1-1-7 Call screen 300 and create it using forward navigation.

(C) SAP AG BC670 51

Page 218: BC670_v46c_en_2001_09

1-1-8 Declare in PBO Module status_0300 that you want to make a list output, notscreen processing (suppress screen dialog and leave to list processing).

Set the PF-STATUS 'INLI'

Create an empty PAI module status_0300 by double clicking. The module involves no processing.

After module status_0300, call module display_liste_mm_eban.Create this module using forward navigation, and output the data in it for MM_EBAN

1-1-9 The list layout is as follows:

Line 1: Position 2: Text 'Purchase requisition'Position 23: BANFN from table EBANPosition 40: Text 'Document type'Position 50: BSART from table EBAN

Line 4:Position 2: Text 'Purchase requisition items'

Line 7Position 4: Text 'Pos'Position 20: Text 'Material'

Line 8Position 20: Text 'Requested quantity'

Line 10:Position 4: BNFPO from table EBANPosition 20: MATNR from table EBAN

Line 11:Position 20: MÈNGE from table EBAN

2-1 Create an entry in table aind_str5 for your business view. Enter your function module. Name your view ‘View_xx’, where xx is your group number.

3-1 Call the Archive Information System. Select as object MM_EBAN and view the archived documents from the structure table.Branch to the detail view by double clicking, and try to select your business view.

(C) SAP AG BC670 52

Page 219: BC670_v46c_en_2001_09

Unit: SAP AS Business Views

Topic: Display an Archived Original (Letter) in SAP AS

At the conclusion of these exercises, you will be able to:

Use SAP AS to display the optically archived original document for a purchase requisition

The user department wants to see not only the purchase requisition, but also the optically archived original document

1-1 Call your function module from the previous exercise.

2-1 Determine which business object in ArchiveLink belongs to a purchase requisition. The document type used is called MYLETTER.

3-1 In the list output module, create a variable that reflects the key of the business object.Create a second variable object_id , that links to sapb-sapobjid.

4-1 Supply your variable of the business object key with the field BANFN from table EBAN and assign the variable to the variables object_id

5-1 At the end of your list output, call function module 'ARCHIV_DISPLAY_META'

Export parameter:sap_object = <business object type defined >object_id = Variable <object_id>

(C) SAP AG BC670 53

Page 220: BC670_v46c_en_2001_09

(C) SAP AG BC670 54

Page 221: BC670_v46c_en_2001_09

6.52Business Views in SAP AS Solutions

Unit: Business Views in SAP AS

Topic: Creating a Business View for MM_EBAN

1-1 Tools, ABAP Workbench, Overview, Object Navigator

From menu, choose: Workbench Edit Object Function Group Create.Enter group name: ZBC670_xx

Switch to display for function group ZBC670_00Expand function modulesMark function module ZZMM_EBAN00Right mouse click: Copy

Enter: ZZMM_EBANxx (xx represents your group number)Function group: ZBC670Button <Copy>

Double click ZZMM_EBANxx.

Create global data: From menu, choose Goto Global Data. For data definition, see sample solution ZZMM_EBAN

1-1-2 to 1-1-9 see sample solution ZMM_EBAN

2-1 Call transaction SE16Table: aind_str5, button <execute>Button <create>Object: MM_EBANFunction: ZMM_EBANxxLine: The instructor will give you this; must not be more that 15 per object Text: BANF xxButton <save>

3-1 Tools, Administration, Administration, Archiving, Button <Info system>,Archive ExplorerObject: MM_EBANArchive info structure: ZAIMM_EBANButton <execute>Double-click on a document number from the displayed list Select your own business view

FUNCTION ZZMM_EBAN.*"----------------------------------------------------------------------*"*"Lokale Schnittstelle:*" IMPORTING

(C) SAP AG BC670 55

Page 222: BC670_v46c_en_2001_09

*" REFERENCE(I_ARCHIVEKEY) TYPE ADMI_FILES-ARCHIV_KEY*" REFERENCE(I_OFFSET) TYPE ARCH_IDX-OFFSET*"----------------------------------------------------------------------* tables: arc_buffer, eban. global definiert

data: handle like sy-tabix. refresh: i_eban.

call function 'ARCHIVE_READ_OBJECT' exporting object = 'MM_EBAN' archivkey = i_archivekey offset = i_offset importing archive_handle = handle exceptions others = 12.

if not sy-subrc is initial. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. exit. endif. do.

call function 'ARCHIVE_GET_NEXT_RECORD' exporting archive_handle = handle importing record = arc_buffer-segment record_structure = arc_buffer-rname exceptions end_of_object = 1.

if sy-subrc = 1. exit. endif. case arc_buffer-rname. when 'EBAN'. i_eban = arc_buffer-segment. append i_eban.

endcase. enddo.

call function 'ARCHIVE_CLOSE_FILE' exporting archive_handle = handle.

** Ausgabe der Daten über Dynpro mit Listprocessing call screen 300.

ENDFUNCTION.

(C) SAP AG BC670 56

Page 223: BC670_v46c_en_2001_09

Logic

PROCESS BEFORE OUTPUT. MODULE STATUS_0300. MODULE display_liste_mm_eban.PROCESS AFTER INPUT. MODULE USER_COMMAND_0300.

MODULE STATUS_0300 OUTPUT.

suppress dialog. leave to list-processing and return to screen 0.

SET PF-STATUS 'INLI'.* SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0300 OUTPUT*&---------------------------------------------------------------------**& Module DISPLAY_LISTE_MM_EBAN OUTPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE DISPLAY_LISTE_MM_EBAN OUTPUT. write: /2 'Bestellanforderung: ', 23 i_eban-banfn, 40 'Belegart:', 73 i_eban-bsart.

skip 2. write: /2 'Bestellanforderungspositionen'.

skip 1. write: /4 'Pos', 20 'Material'. write: /20 'Anforderungsmenge'.

skip 1. write: /4 i_eban-bnfpo, 20 i_eban-matnr. write: /20 i_eban-menge.

ENDMODULE. " DISPLAY_LISTE_MM_EBAN OUTPUT*&---------------------------------------------------------------------**& Module USER_COMMAND_0200 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE USER_COMMAND_0200 INPUT.

ENDMODULE. " USER_COMMAND_0200 INPUT

*&---------------------------------------------------------------------**& Module USER_COMMAND_0300 INPUT*&---------------------------------------------------------------------** text*----------------------------------------------------------------------*MODULE USER_COMMAND_0300 INPUT.

ENDMODULE. " USER_COMMAND_0300 INPUT

(C) SAP AG BC670 57

Page 224: BC670_v46c_en_2001_09

Unit: Business Views in SAP AS

Topic: Display an Archived Original (Letter) in SAP AS

At the conclusion of these exercises, you will be able to:

Use SAP AS to display the optically archived original document for a purchase requisition.

The user department wants to see not only the purchase requisition, but also the optically archived original document

1-1 Call your function module from the previous exercise.

2-1 Determine which business object in ArchiveLink belongs to a purchase requisition. The document type used is called MYLETTER.

Enter transaction SE16; Table TOA01; Search for document type MYLETTER. The object type that is stored in the record is the one being searched for.

3-1 to 5-1: See sample solution function module ZZMM_EBAN_ORIGINALE.

(C) SAP AG BC670 58

Page 225: BC670_v46c_en_2001_09

FUNCTION ZZMM_EBAN_ORIGINALE.*"----------------------------------------------------------------------*"*"Lokale Schnittstelle:*" IMPORTING*" REFERENCE(I_ARCHIVEKEY) TYPE ADMI_FILES-ARCHIV_KEY*" REFERENCE(I_OFFSET) TYPE ARCH_IDX-OFFSET*"----------------------------------------------------------------------

refresh: i_eban.

data: begin of objectid, oidbanfn like eban-banfn, end of objectid. data: object_id like sapb-sapobjid.

call function 'ARCHIVE_READ_OBJECT' exporting object = 'MM_EBAN' archivkey = i_archivekey offset = i_offset importing archive_handle = handle exceptions others = 12.

if not sy-subrc is initial. message id sy-msgid type 'I' number sy-msgno with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. exit. endif. do. call function 'ARCHIVE_GET_NEXT_RECORD' exporting archive_handle = handle importing record = arc_buffer-segment record_structure = arc_buffer-rname exceptions end_of_object = 1.

if sy-subrc = 1. exit. endif. case arc_buffer-rname. when 'EBAN'. i_eban = arc_buffer-segment. append i_eban.

endcase. enddo.

call function 'ARCHIVE_CLOSE_FILE' exporting archive_handle = handle.

move i_eban-banfn to objectid-oidbanfn. object_id = objectid.

call function 'ARCHIV_DISPLAY_META' exporting sap_object = 'BUS2105' object_id = object_id exceptions others = 1. if sy-subrc ne 0. exit.

(C) SAP AG BC670 59

Page 226: BC670_v46c_en_2001_09

endif.

* Ausgabe der Daten über Dynpro mit Listprocessingcall screen 300.

ENDFUNCTION.

7

(C) SAP AG BC670 60