bit670 - programming display functions

234
THE BEST-RUN BUSINESSES RUN SAP © SAP AG 2003 BIT670 Programming Display Functions SAP R/3 – Release Enterprise 2003/Q3 Material Number: 50061013

Upload: beji1989

Post on 08-Nov-2014

316 views

Category:

Documents


26 download

TRANSCRIPT

Page 1: BIT670 - Programming Display Functions

© SAP AG 2003

Programming Display Functions

THE BEST-RUN BUSINESSES RUN SAP

© SAP AG 2003

BIT670Programming Display Functions

SAP R/3 – Release Enterprise 2003/Q3 Material Number: 50061013

Page 2: BIT670 - Programming Display Functions

© SAP AG 2003

Copyright 2003 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice.

All rights reserved.

Copyright

Trademarks:

Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.

Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® are registered trademarks of Microsoft Corporation.

IBM®, DB2®, DB2 Universal Database, OS/2®, Parallel Sysplex®, MVS/ESA, AIX®, S/390®, AS/400®, OS/390®, OS/400®, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere®, Netfinity®, Tivoli®, Informix and Informix® Dynamic ServerTM are trademarks of IBM Corporation in USA and/or other countries.

ORACLE® is a registered trademark of ORACLE Corporation. UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group. Citrix®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®, VideoFrame®, MultiWin® and other Citrix product names referenced herein are trademarks of Citrix Systems, Inc.

HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology.

JAVA® is a registered trademark of Sun Microsystems, Inc. JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

MarketSet and Enterprise Buyer are jointly owned trademarks of SAP AG and Commerce One. SAP, SAP Logo, R/2, R/3, mySAP, mySAP.com, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies.

Page 3: BIT670 - Programming Display Functions

© SAP AG 2003

Course Prerequisites

BC400BC405BC410BC660 or comparable knowledge about SAP Data Archiving

Page 4: BIT670 - Programming Display Functions

© SAP AG 2003

Target group

ParticipantsData archiving project team members who have to develop their own client-specific read programs.

Duration

2 Days

Page 5: BIT670 - Programming Display Functions

© SAP AG BIT670 1-1

� SAP AG 2003

Contents

Course Overview

l Course Goal

l Course Objectives

l Course Content

l Course Overview Diagram

l Main Business Scenario

Page 6: BIT670 - Programming Display Functions

© SAP AG BIT670 1-2

� SAP AG 2003

This course will prepare you to:

l Understand the logic of the write, delete and read programs used in data archiving

l Learn how to create customer-specific write, delete and read programs

l Create field catalogs and infostructures in SAP AS

l Use SAP AS to display original documents for an R/3 business object that were archived via SAP ArchiveLink

Course Goal

Page 7: BIT670 - Programming Display Functions

© SAP AG BIT670 1-3

� SAP AG 2003

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

l Create customer-specific archiving objects

l Create field catalogs in SAP AS

l Explain how to empty customer-specific tables via customer-specific archiving objects

l Explain how to expand existing archiving objects to include customer-specific tables

Course Objectives

Page 8: BIT670 - Programming Display Functions

© SAP AG BIT670 1-4

� SAP AG 2003

Chapter 4 Write and Delete Programs

Chapter 5 Sequential Read Programs

Chapter 6 Index-Based Read Programs

Chapter 1 Course Overview

Chapter 2 The Data Archiving Process

Chapter 3 ADK Development Tools

Preface

Course Content

Appendix

Page 9: BIT670 - Programming Display Functions

© SAP AG BIT670 1-5

� SAP AG 2003

Course Overview Diagram

ŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁ

������������

� �� ������ ���������

���� ������������������

ŁŁŁŁŁŁŁŁ � ��� ���� ������������� �

ŁŁŁŁŁŁŁŁ ���������������������� �

ŁŁŁŁŁŁŁŁ ���� !"����������������� �

ŁŁŁŁŁŁŁŁ ������

Page 10: BIT670 - Programming Display Functions

© SAP AG BIT670 1-6

� SAP AG 2003

l Your company, TablesRUs, has initiated a data archiving project and you are part of the project team.Your team, together with the relevant departments, has identified the following requirements for your data archiving project:

n You need to create your own archiving objects.

n You need to be able to carry out rapid, index-based read accesses to archived data.

Main Business Scenario

Page 11: BIT670 - Programming Display Functions

� SAP AG 2003

l Business Object and Archiving Object

l The Process of Data Archiving

Contents

The Data Archiving Process

Page 12: BIT670 - Programming Display Functions

� SAP AG 2003

l Describe the process of Data Archiving

l Explain the relevant components

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

The Data Archiving Process: Course Objectives

Page 13: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

The Data Archiving Process: Overview

ŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁ

������������

� �� ������ ���������

���� ������������������

ŁŁŁŁŁŁŁŁ � �������� ������������� �

ŁŁŁŁŁŁŁŁ ���������������������� �

ŁŁŁŁŁŁŁŁ ���� !"����������������� �

ŁŁŁŁŁŁŁŁ ������

Page 14: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

The Data Archiving Process: Business Scenario

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

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

� SAP AG 1999

Page 15: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

What Is Data Archiving?

Table VBAK63206321.....

Table VBUK63206321.....

Table VBPA6320 106321 10................ ...........

Order 6320 Order 6321

Archiving object SD_VBAK

DatabaseSAP

Business object SAP

ArchivingobjectADK

Files in thefile system

...........

n Data archiving means data records are extracted from the database tables of the SAP system database and written to at least one archive file. Data archiving is done using an archiving program and is based on archiving objects.

n The contents of business objects of the SAP system are distributed over several database tables. Archiving objects group together the logically linked tables of business objects. This ensures that during archiving all data for a business object is extracted from the database and deleted.

n Archived data can be accessed using reports, provided by the applications. It is also possible to create customer-specific reports. Archived data can also be accessed via the Archive Information System (SAP AS) and DART.

Page 16: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

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 Object

TableBSEG

TableBSET

R/3 Database Tables

Unique Key

n R/3 business documents are distributed across different tables in the R/3 database.

n FI document 1000 1900000 1999 is a concrete business object.

n In data archiving, all table records belonging to a business object are written together (in context) to an archive file and then deleted from the database tables.

Page 17: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

The Archiving Process

Archiving object

R/3 Database

Data archiving session

Archivefiles

Offlinestorage

File system

optional /manual

R/3 R/3 DatabaseDatabase

Business Objects

n The data archiving process is composed of two steps. Creation of archive files - The write 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.

n The storage of archive files on a tertiary storage medium can be seen as a third step in the archiving process. Depending on the storage medium and the customizing settings, this step can take place either before or after the delete phase. 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.

Page 18: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

Archiving-objects

FI_DOCUMNTSD_VBAKSD_VBKASD_VBRKRV_LIKPCO_ITEM

AM_ASSETMM_EBANMM_EKKO

IDOCWORKITEMPS_PLAN

CO_ORDER......

Archiving Objects (1)

Structure Definition

Archiving and Delete Programs

Archiving Classes Used

CustomizingTechnical Settings

CustomizingResidence Times/Application

Read Programs

Additional Indicators(e.g. 'Interruption Possible')

For everyarchiving objectinformation aboutthe points on the right isavailable in the system

Transaction AOBJ

n An archiving object must have at least one write and one delete program. Optional programs are read, pre- and post-processing, as well as reload programs.

n The maintenance transaction is AOBJ.

n An example of additional indicators is 'Interruption Possible', which enables you to interrupt a write program.

n In application-specific customizing you enter criteria - e.g. if or as of when data can be archivable. In addition to these criteria, the application (the write program) must check if a business object has the status 'Completed' so that the object can be archived.

Page 19: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

Structure DefinitionTable BKPF

Structure DefinitionTable BSET

Structure DefinitionTable BSEG

Structure DefinitionTable BVOR

Structure DefinitionTable BSEC

Archiving Objects (2)

.........

Archiving ObjectFI_DOCUMNT

The STRUCTURE DEFINITION of anarchiving object describeswhich tables are to be processedduring 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.

n Additional examples of archiving objects: SD_VBAK Data structure Orders SD_VBKA Data structure Sales activities RV_LIKP Data structure Deliveries PP_ORDER Data structure Production orders

n R/3 Release 4.6 contains more than 200 standard archiving objects.

n Archiving objects are defined by the individual applications.

n You can create customer-specific archiving objects for customer-specific Z- and Y- tables.

Page 20: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

Data Archiving: Step 1 - Archiving Data

Write Program

ArchiveArchivefilefile

R/3R/3DatabaseDatabase

n During the first step, the write 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 written to the archive

2. 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 number of data objects that was specified in Customizing.

n The write program has to make sure that only data of completed business processes that, based on the customizing settings, is archivable, is actually archived.

n Master data can only be archived if a deletion indicator has been set. 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).

Page 21: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

Data Archiving: Step 2 - Deletion of Data, Option 1:Delete Jobs Run Parallel to Archiving

Write Program

Deleteprogram

Prerequisite:You have marked the radio button 'Start Automatically' in the technical settings under Archiving Object-Specific Customizing

Delete jobs are started automaticallyafter an archive file is closed

Deleteprogram

ArchiveArchivefilefile

ArchiveArchivefilefile

ArchiveArchivefilefile

R/3R/3DatabaseDatabase

n There is one deletion process for each archive file created.

n The deletion process can be started in three different ways.

n 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, delete and write jobs run in parallel.

n For this option, the indicator 'Start Automatically' has to be set in the technical settings in Archiving Object-Specific Customizing. Moreover, the corresponding setting has to be made in the selection screen of the write program. If this is not done, then, despite the fact that the indicator 'Start Automatically' was set, you must follow the procedure described on the next slide.

Page 22: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

Data Archiving: Step 2 - Deletion of Data, Option 2:Delete Jobs Are Started Manually

The administrator MANUALLY startsthe delete jobs in the data archiving transaction after the archiving sessionis completed

Prerequisite:You have NOT marked the radio button 'Start Automatically' in the technical settings under Archiving Object-Specific Customizing

Deleteprogram

Deleteprogram

ArchiveArchivefilefile

R/3R/3DatabaseDatabase

ArchiveArchivefilefile

n 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.

n For this option, the indicator 'Start Automatically' in the technical settings in Archiving Object-Specific Customizing is NOT set.

Page 23: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

Data Archiving: Step 2 - Deletion of Data, Option 3:Delete Jobs Are Started Automatically

The delete jobs are started AUTOMATICALLY after the end of the archiving session

Prerequisite:You have marked the indicator 'Do Not Start Before End of Write Phase' in the definition of the archiving object

Deleteprogram

Deleteprogram

ArchiveArchivefilefile

R/3R/3DatabaseDatabase

ArchiveArchivefilefile

n Variant 3 for starting the delete program: The delete program is scheduled manually by the administrator once all archive files have been closed. The write program is completely finished. For every archive file created, a delete program is started as a batch process.

n For this option, the indicator 'Start Automatically' in the technical settings in Archiving Object-Specific Customizing is NOT set.

n If the radio button 'Do Not Start Before End of Write Phase' in the definition of the archiving object is set, then it may not be removed.

Page 24: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

Data Archiving: Step 3 - Storage on Third Party Storage Systems

l External storage system connected via SAP ArchiveLink or SAP CMS

l HSM Systemsl Exclusively for file

system used with ADK

Create archive filesdelete archived data

'Final storage' of archive files

ArchiveArchivefilefileArchiveArchive

filefileArchiveArchivefilefileArchiveArchive

filefileR/3R/3

DatabaseDatabase ArchiveArchivefilefile

n There are various ways to store and administer archive files on external storage media. You can use archive management to find out where an archive file is located. Read/write authorizations are mandatory at UNIX-level for the directories used.

n Connection to a Heirarchical Storage Managment 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.

n Connection to an external archive system. Up to and including 4.6B the connection takes place via the SAP ArchiveLink Interface. If you want to store the archive files on a third party archive system, the data has to be successfully deleted from the database. As of 4.6C this connection takes place via the interface SAP CMS. With this interface it is possible to store archive files either before or after the delete phase.

n 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.

n 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 CD's or WORM's after a number of years.

Page 25: BIT670 - Programming Display Functions

© SAP AG BIT670 1

� SAP AG 2003

You are now able to:

The Data Archiving Process: Summary

l Explain the steps of the data archiving process

n Writing data to archive files

n Deleting data from the database

n Storing data on third party storage systems

l Define an archiving object as the central component of the data archiving process

Page 26: BIT670 - Programming Display Functions

© SAP AG BIT670 1

Exercises

Unit: The Data Archiving Process

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

• Explain the relationship between data objects and archiving objects

• Carry out the Customizing required to start the delete jobs

1-1 Business Object – Archiving Object

1-1-1 What is data archiving?

1-1-2 What is an archiving object?

1-1-3 Where can you see which table entries can be written out of the database for a specific archiving object?

1-2 Delete Jobs

1-2-1 Which Customizing settings do you have to make so that instead of being scheduled immediately after an archive file is closed, the delete jobs have to be scheduled manually?

1-2-2 Which Customizing settings do you have to make so that a delete job is automatically scheduled immediately after an archive file has been closed?

1-2-3 Which Customizing settings do you have to make so that the delete jobs are automatically scheduled immediately after the entire archiving session is completed?

1-2-4 Can you remove the indicator ‘Do Not Start Before Beginning of Write Phase’ in the definition of the archiving object, if it has already been marked?

1-2-5 Can you mark the check box ‘Interruption Possible’ in the definition of the archiving object, if it has not been marked?

Page 27: BIT670 - Programming Display Functions

© SAP AG BIT670 2-1

Solutions

Unit: The Data Archiving Process

1-1 Solution to question 1-1

1-1-1 Extracting data records from the database tables of the SAP system database and writing them to at least one archive file.

1-1-2 An object that contains all programs and customizing settings that are necessary to write the complete information of a business object to archive files, and also to delete, read, etc. this information.

1-1-3 Call up transaction AOBJ. Select the archiving object. Select the dialog structure ‘Structure definition’

1-2 Solution to question 1-2

1-2-1 Tools, Administration, Administration, Data Archiving Enter the archiving object Button <Customizing> Call up ‚Archiving Object-Specific Customizing’ Technical Settings’, ‘Settings for Delete Program’: ‘Start Automatically’ should not be selected.

1-2-2 Tools, Administration, Administration, Data Archiving Enter the archiving object Button <Customizing> Call up ‚Archiving Object-Specific Customizing’ Technical Settings’, ‘Settings for Delete Program’: ‘Start Automatically’ must be selected.

1-2-3 Call up transaction AOBJ Double click on the archiving object 'Do Not Start Before End of Write Phase' must be selected

1-2-4 For archiving objects delivered by SAP: No!

1-2-5 For archiving objects delivered by SAP: No!

Page 28: BIT670 - Programming Display Functions

© SAP AG BIT670 3-1

� SAP AG 2003

Contents

l Overview of the ADK Programming Interface

l What are archiving classes and what are they used for?

ADK Development Tools

Page 29: BIT670 - Programming Display Functions

© SAP AG BIT670 3-2

� SAP AG 2003

l Name the components of the ADK Programming Interface.

l Understand how to use and apply archiving classes.

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

ADK Development Tools: Course Objectives

� SAP AG 1999

Page 30: BIT670 - Programming Display Functions

© SAP AG BIT670 3-3

� SAP AG 2003

ADK Development Tools: Overview

ŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁ

������������

� �� ������ ���������

���� ������������������

ŁŁŁŁŁŁŁŁ � ��� ���� ������������� �

ŁŁŁŁŁŁŁŁ ���������������������� �

ŁŁŁŁŁŁŁŁ ���� !"����������������� �

ŁŁŁŁŁŁŁŁ ������

Page 31: BIT670 - Programming Display Functions

© SAP AG BIT670 3-4

� SAP AG 2003

ADK Development Tools: Business Scenario

l Before developers can begin to work, they need to familiarize themselves with the ADK Programming Interface.

� SAP AG 1999

Page 32: BIT670 - Programming Display Functions

© SAP AG BIT670 3-5

� SAP AG 2003

ADK Programming Interface - ADK API

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

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

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

n In addition to reading and writing data, ADK also undertakes conversion tasks during the data archiving process, 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

n 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.

Page 33: BIT670 - Programming Display Functions

© SAP AG BIT670 3-6

� SAP AG 2003

ADK API - Function Group ARCH (1)

ADK function modules used in archiving programs

ARCHIVE_CLOSE_FILEARCHIVE_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

n The function group ARCH includes the function modules for access to ADK archive files.

n The function group AADM contains function modules for managing ADK archive files.

n The group ARCH is essential for customer developments.

n Archiving programs are created by the respective applications. The application is responsible for the programming of the selection and check logic. The application uses the function modules listed above as the interface to ADK.

Page 34: BIT670 - Programming Display Functions

© SAP AG BIT670 3-7

� SAP AG 2003

ADK API - Function Group ARCH (2)

ADK function modulesused in delete programs

ARCHIVE_CLOSE_FILEARCHIVE_GET_INFORMATION ARCHIVE_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

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

Page 35: BIT670 - Programming Display Functions

© SAP AG BIT670 3-8

� SAP AG 2003

Where In the R/3 System Can You Find the ADK API?

l ADK Function modules that are available to customers can be found in the function group ARCH

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

l Display of function group Drilldown of function modules

n You can find documentation for ADK under the following path in the SAP Library: SAP Web Application Server - ABAP Workbench (BC-DWB) - BC Extended Applications Library- Archive Development Kit

Page 36: BIT670 - Programming Display Functions

© SAP AG BIT670 3-9

� SAP AG 2003

Archiving Classes (1)

� SAP AG 1999

l Archiving Classes

n Function modules and form routines for a business object that isnot archived separately. It is reused within the system and archived together with other objects.

n Examples of archiving classes:SAPscript TextsChange DocumentsVariant ConfigurationSAP ArchiveLink EntriesIDOCsWork ItemsHR Time DataHR Trip DataCO Settlement Documents......

n Release 4.6 contains 57 archiving classes.

n Archiving classes are maintained in transaction ACLA.

n 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.

Page 37: BIT670 - Programming Display Functions

© SAP AG BIT670 3-10

� SAP AG 2003

Archiving Classes (2)

1000 19000000 19941000 19000001 19941000 19000002 19941000 19000003 1994

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.1000 19999999 1994

4500000551 19944500000552 19944500000553 19944500000554 1994

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.4500000999 1994

Table BKPFArchiving Class

Change DocumentsTable CDHDR

Table VBAK

Data archiving isdone using an archiving object

Data archiving isdone using an archiving object

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 ........

Data archiving isdone using an archiving class

n Use of archiving classes: The figure shows how during the archiving of FI and SD documents the function modules for the archiving of change document tables are called up and how the change documents of the R/3 business objects are stored together with these objects in the archive file. Similarly, change documents in other R/3 applications are also archived together with their corresponding business objects.

n Archiving classes collect change documents.

n The archiving class Changedocu archives not only from CDHDR, but also from the second table CDPOS.

n 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.

n Data that is stored using archiving classes is not transparent for ADK. ADK cannot interpret the data. While reading the archived data ADK needs a read function module from the archiving class to access the data.

Page 38: BIT670 - Programming Display Functions

© SAP AG BIT670 3-11

� SAP AG 2003

Archiving Classes (3)

l Using Archiving Classes

n Processing of complex, cross-archiving-object logical data objects

n Data structures are used and archived by different applications

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

n NOTE: Archiving class development does not belong to the ADK development environment, which is released to customers.

Page 39: BIT670 - Programming Display Functions

© SAP AG BIT670 3-12

� SAP AG 2003

Archiving Classes (4)

l Advantages of Archiving Classes

n Can be reused without extra effort

n Archiving objects can be easily expanded through new archiving classes

n Allows you to view the object without having to worry about where the data is physically stored

n Preservation of data integrity

n Encapsulation of data and its methods

n Central implementation of archiving functionality

n 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 hierarchies. By using archiving classes, you can easily archive and read data for which you have no detailed knowledge.

Page 40: BIT670 - Programming Display Functions

© SAP AG BIT670 3-13

� SAP AG 2003

You are now able to:

ADK API: Summary

l Explain which part of the ADK Programming Interface can be accessed by customers

l Exlpain that archiving classes can be used to reduce the size of tables that are filled from different applications at the same time.

Page 41: BIT670 - Programming Display Functions

© SAP AG BIT670 3-14

Exercises

Unit: ADK Development Tools Topic: Identifying ADK Function Modules

Identifying Archiving Classes

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

• Find and identify ADK function modules in the system

• Explain what archiving classes are

• Identify archiving classes used

1-1 ADK Function Modules

1-1-1 Which function group contains the function modules that can be used by customers?

1-1-2 Display the function modules

1-1-3 Which modules are used in the write program, and which in the delete program?

1-2 Archiving Classes

1-2-1 For what purpose were archiving classes developed? What type of data is archived/deleted using archiving classes

1-2-2 Who creates archiving classes? Can customers create archiving classes?

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

Page 42: BIT670 - Programming Display Functions

© SAP AG BIT670 3-15

Solutions

Unit: ADK Development Tools Topic: Identifying ADK Function Modules

Identifying Archiving Classes

1-1 Solution to question 1-1

1-1-1 The function modules are located in the function group ARCH.

1-1-2 Tools, ABAP Workbench, Overview, Object Navigator Choose 'Function Group' Entry: ARCH Push button 'Display' Drilldown 'Function Modules'

1-1-3 Write program: Archive_open_for_write Archive_new_object Archive_put_record Archive_put_table Archive_save_object Archive_write_statistics Archive_close_file Delete program: Archive_get_customizing_data Archive_close_file Archive_get_next_object Archive_get_next_record Archive_get_table 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 that are not filled directly by a business object, but that are used as cross-application and cross-object tables in R/3.

1-2-2 Archiving classes are created by the respective applications. For customers we do NOT support the development of archiving classes

1-2-3 Call up transaction AOBJ Select the archiving object SD_VBKA Choose dialog structure 'Archiving Classes Used'

Result: address, text

Page 43: BIT670 - Programming Display Functions

© SAP AG BIT670 4-1

� SAP AG 2003

Contents:

Write and Delete Programs

l Definition of Archiving Objects

l Structure of Write Programs

l Function Modules in Write Programs

l Structure of Delete Programs

l Function Modules in Delete Programs

l Procedure to Extend Standard Archiving Objects: Example IS-OIL

Page 44: BIT670 - Programming Display Functions

© SAP AG BIT670 4-2

� SAP AG 2003

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

Write and Delete Programs: Course Objectives

l Explain the logic of write programs.

l Explain the logic of delete programs.

l Create a new archiving object.

l Extend a standard archiving object.

Page 45: BIT670 - Programming Display Functions

© SAP AG BIT670 4-3

� SAP AG 2003

Write and Delete Programs: Overview

ŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁ

������������

� �� ������ ���������

���� ������������������

ŁŁŁŁŁŁŁŁ � �������� ������������� �

ŁŁŁŁŁŁŁŁ ���������������������� �

ŁŁŁŁŁŁŁŁ ���� !"����������������� �

ŁŁŁŁŁŁŁŁ ������

Page 46: BIT670 - Programming Display Functions

© SAP AG BIT670 4-4

� SAP AG 2003

Write and Delete Programs: Business Scenario

l The developers of customer-specific archiving objects learn about the logic that lies behind SAP Data Archiving.

Page 47: BIT670 - Programming Display Functions

© SAP AG BIT670 4-5

� SAP AG 2003

Availability of ADK API

l ADK is a development tool for:

n SAP developers for the development of SAP standard archiving objects

n Customers for the development of customer-specific archiving objects

n Customers for the development of read access to data that was archived using standard archiving objects

n Customers who need to extend SAP standards - you can do this only if you have a developer's key (and after consultation with SAP development)

w Z/Y tables as extensions of SAP archiving objects

n SAP standard archiving objects archive data from SAP standard tables.

n Customer-specific archiving objects archive data from customer-specific tables (Z/Y tables).

Page 48: BIT670 - Programming Display Functions

© SAP AG BIT670 4-6

� SAP AG 2003

Creating An Archiving Object

l Creating an archiving object:

n Transaction AOBJ

l Information that can be entered:

n Programs for the archiving object

n General characteristics

n Tables involved

n Customizing settings

n Archiving classes used

n Network graphic

Page 49: BIT670 - Programming Display Functions

© SAP AG BIT670 4-7

� SAP AG 2003

Transaction AOBJ

Dialog structureArchiving object

Structure definitionTable, only for deleteMaintain network graphicCustomizing settingsArchiving classes used

Read programCustomizing transactionInfo tablesAssign exit routines

Object Description of the archiving objectCO_KSTRG Cost Object: Master and transaction dataCO_ML_BEL Material ledger documents (MLHD/IT/PP/PPF...)CO_ML_DAT Material ledger Records (CKMLPP, CKMLCR)CO_ML_IDX Index entries material documents: LedgerCO_ML_ML1 Material ledger period rates (CKML1)CO_ORDER Orders with transaction dataCO_PROCESS Business process, incl. transact. dataCO_TEST Only for testingCS_BOM PP bills of materialCV_DVS Document managementDATAFDLOG TR-TM: Datafeed access logEC_PCA_SUM Profit Center invoice: Totals recordsEIS_CF001 Archiving object for aspect CF001EIS_CF002 Archiving object for aspect CF003EIS_CF003 Archiving object for aspect CF003EIS_CF004 Archiving object for aspect CF004EIS_CF005 Archiving object for aspect CF005EIS_CF006 Archiving object for aspect CF006EIS_CF050 Archiving object for aspect CF050EIS_CF501 Archiving object for aspect CF501EIS_CF502 Archiving object for aspect CF502EIS_CF503 Archiving object for aspect CF503

Position Entry 1 of 182

Page 50: BIT670 - Programming Display Functions

© SAP AG BIT670 4-8

� SAP AG 2003

Archiving Object: Programs

Write and delete program

Sequential read program

Preprocessing program

Index-basedread program

Reload program

Postprocessing program

n An archiving object needs to have at least one write program and one delete program.

n Normally an archiving object also has programs for the reading of archived data.

n If necessary, the archiving object can also have a preprocessing and a postprocessing program. You can set a deletion flag in the preprocessing program (e.g. for master data). A preprocessing program can also be an analysis program that shows which business objects cannot be archived and why (i.e. which business-related conditions they have not fulfilled).

n Also optional are the index build program and the index delete programs for directly accessing the business object in the archive file. However, direct access to a business object is controlled using the generic functionality of the Archive Information System (SAP AS). Index build programs that are entered in the transaction AOBJ are no longer needed with the AS.

n 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.

Page 51: BIT670 - Programming Display Functions

© SAP AG BIT670 4-9

� SAP AG 2003

Archiving Object: General Characteristics

l Name and descriptive text

l Application area and application component

l Settings for write, delete, index and reload programs

l Settings for archive management

l Tips for the programs of the archiving object

n For documentation about the individual check boxes and entry fields go to the F1 help.

Page 52: BIT670 - Programming Display Functions

© SAP AG BIT670 4-10

� SAP AG 2003

Archiving Object: Tables and Technical Customizing

l Structure Definition

n Entry of tables that are to be archived

n These entries are the data model of the archiving object

l Tables from which data is only deleted

l Customizing settings

n Technical settings, such as file size, commit counter, delete program variant, connection to external storage system

n The technical settings can be maintained by the user via transaction SARA

n Entries in the structure definition: Record no.: For defining the order

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 hierarchically. Segment: Subordinate segment in the archive hierarchy. Name of the structure belonging to the archiving object. This field informs ADK (and its function module) which tables are to be processed. ADK uses the entries for the following functions: - Meta data for the archive file to be written- Basic information 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).

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

Page 53: BIT670 - Programming Display Functions

© SAP AG BIT670 4-11

� SAP AG 2003

Archiving Object: Archiving Classes and Read Programs

l Transaction AOBJ - Archiving Classes Used

n Archiving classes used by the archiving object are entered

n An entry in transaction AOBJ means that the archiving class is used by the archiving object

l Transaction AOBJ - read programs

n If an entry exists for a read program, this program can be called up from archive administration (transaction SARA)

n It is necessary to enter the archiving classes into transaction AOBJ, for transaction DB15 and the Archive Information System to take the archiving classes into account.

n Transaction DB15 finds the tables for an archiving object, or the archiving object that belongs to a specific table.

n The corresponding function modules of the archiving classes that are entered here, have to be called up in the programs of the archiving object.

Page 54: BIT670 - Programming Display Functions

© SAP AG BIT670 4-12

� SAP AG 2003

Archiving Object: Application-Specific Customizing

l Transaction AOBJ - Customizing Transactions

n Group of transactions that require application-specific customizing

n In application-specific Customizing, applications can enter criteria for the archivability of data. During the archiving session the data is analyzed based on these criteria.

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

n The application-specific customizing settings are made by the application

Page 55: BIT670 - Programming Display Functions

© SAP AG BIT670 4-13

� SAP AG 2003

Examples of Archiving Objects

l As of BASIS Release 640 example archiving object 'BC_SBOOK'

l R/3 >= 4.5A: With some restrictions, the example archiving object 'BC_SBOOK' can be used as an example archiving object

l R/3 < 4.5A: Example archiving object 'EXAMPLE'

� SAP AG 2003

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

n Functionality 'read single document' for SBOOK is realized via SAP AS; generally, the index build program is not actively used anymore.

Page 56: BIT670 - Programming Display Functions

© SAP AG BIT670 4-14

� SAP AG 2003

Write Program: Structure

l Define selection screen

l Authorization check

l Data Selection

l Business-relevant checks for the archivability of the data

l Create archive file, fill logs/statistics, produce progress messages

l Produce logs/statistics

n Authorization checks to be implemented: - Authorization from the different applications to write the archive file.

- Authorization from the different applications to archive the data specified in the selection screen.

n The system automatically checks the following:

- Authorization to call up ADK function modules.

- Authorization to create and administer jobs.

Page 57: BIT670 - Programming Display Functions

© SAP AG BIT670 4-15

� SAP AG 2003

Write Program: Selection Screen

<Object>e.g.: Material

DocumentCost center

Constraintse.g.: Fiscal year

Period<Blank line>Value typeVersionRecord type................

Options

o Set deletion flago Set deletion indicatoro Set deletion flag and deletion indicatorq Check document flow

Process Control

o Test modeo Production mode q Delete with test variant

q Detail log

Comment about the archiving session

• <Object> contains selections that describe the business object to be archived. Generally these are selections for the object key and organizational units. <Object> means the description of the objects to be archived

• Constraints contains further restrictions for the range of data to be archived, such as time restrictions.

• Options contains check boxes or radio buttons such as "Check ... " (e.g. Check Document Flow"), "Deletion Flag/Set Deletion Flag".

• Process Control and the Entry Field "Comments about the archiving session" always have to exist in exactly this format. The statement “INCLUDE ARCH_WRITE_PRG_STANDARD1” inserts a standard frame "Process Control" and the entry field "Comment about the archiving session" into the program. You must use this include! It will allow you to more quickly create a more standardized selection screen.

• Check box "Detail Log“ should only appear, when a detail log is being offered. The log contains statistics taken from the ADK table statistics. In addition to the above-named elements, the statement “INCLUDE ARCH_WRITE_PRG_STANDARD2.” also inserts the check box "Detail Log" into the program.

• The above-named includes are available in the standard as of BASIS 640. For Release BASIS 620 the includes are available via SAP Note 528861 and in Release 46B and 46C via SAP Note 565298.

Page 58: BIT670 - Programming Display Functions

© SAP AG BIT670 4-16

� SAP AG 2003

Write Program: Data Selection

The Options:

1. Select all data through a SELECT statement, according to the selection criteria

2. Select all data through a SELECT statement, but using the FETCH technique, according to the selection criteria

3. Create an internal table with "selection packages/selection portions". In a LOOP via this table, issue a SELECT statement with the FETCH technique.

n 1. Possible problems: The internal table that contains the data to be archived (result of the SELECT statement) becomes overloaded and can break down , or it is impossible to further process the table later (organization, etc.).

n 2. Advantages: the internal table no longer breaks down. Possible problems: the cursor on the table continues to remain open for a long time. With ORACLE databases this often leads to ORA1555 runtime errors.

n 3. Advantages: the internal table does not break down; the cursor remains open for a shorter period of time, because the single SELECT statement is shorter. The efficiency of this solution depends on which selection packages are chosen (Remedy: use object keys or the fields of the table indexes) and which value is chosen for the PACKAGE SIZE parameter during the FETCH. Recommendation: To make sure that all packages are full, the PACKAGE SIZE should be determined by dividing 28K by the width of the row of the results table of a SELECT. It is also possible to have more than one package. (The data of the FETCH are transported in packages of 32 K, of which 28K are available for data).

n If the data that is to be archived is available in the internal table, it has to be checked for archivability (completed processes, etc.) and whether it coincides with the settings made in archiving-object-specific Customizing (residence times, etc.). For performance reasons, this should be done via the WHERE conditions of the SELECT.

Page 59: BIT670 - Programming Display Functions

© SAP AG BIT670 4-17

� SAP AG 2003

Write Program: Fill Archive Files

n ARCHIVE_OPEN_FOR_WRITEn ARCHIVE_PROTOCOL_INITn LOOP etc. over the data to be archived

w ARCHIVE_NEW_OBJECTl ARCHIVE_PUT_RECORD / ARCHIVE_PUT_TABLEl <Name of the archiving class>_ARCHIVE_OBJECT

(Archiving function module of an archiving class)

w ARCHIVE_SAVE_OBJECTw ARCHIVE_PROTOCOL_COLLECTw PROGRESS_INDICATOR

n ENDLOOPn ARCHIVE_WRITE_STATISTICSn ARCHIVE_CLOSE_FILEn ARCHIVE_PROTOCOL_WRITE

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

n ARCHIVE_PUT_RECORD (ARCHIVE_PUT_TABLE) writes the record (a table of records) to the prepared data container.

n <Name of the archiving class> means the archiving module of the archiving class (e.g. TEXT_ARCHIVE_OBJECT 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.

n 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.

n ARCHIVE_CLOSE_FILE releases all resources and starts the delete program, if required. If you forget the ARCHIVE_CLOSE_FILE, the last archive file is not closed.

Page 60: BIT670 - Programming Display Functions

© SAP AG BIT670 4-18

� SAP AG 2003

ADK API: ARCHIVE_OPEN_FOR_WRITE

l Interface parameter export

n archive_handle

l Interface parameter import

n call_delete_job_in_test_mode, create_archive_file

n object, comments

l Capabilities of the function module:

n create archive file in the file system

n generate archive handle

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

n The archiving function modules use platform-independent file names to create new archive files. In transaction AOBJ "Customizing Settings", you can specify the platform-independent file names that are to be used for your archiving object. If you have not defined a file name, the system will automatically use the platform-independent file name ARCHIVE_DATA_FILE to create the server-independent file name.

n 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 during the session.

n 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.

Page 61: BIT670 - Programming Display Functions

© SAP AG BIT670 4-19

� SAP AG 2003

ADK API: ARCHIVE_NEW_OBJECT

l Interface parameter import

n archive_handle

l Capabilities of the function module:

n Initializing of new data object

n Discarding of processed data

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

n 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.

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

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

Page 62: BIT670 - Programming Display Functions

© SAP AG BIT670 4-20

� SAP AG 2003

ADK API: ARCHIVE_PUT_RECORD

l Interface parameter import

n archive_handle

n record_flag

n record_structure

n record

l Capabilities of the function module:

n You can use this function module to transfer a data record to the data object that was previously called by the function module ARCHIVE_NEW_OBJECTAll data records that you transferred to the data object are written to the archive file together when you call up the function module ARCHIVE_SAVE_OBJECT.

n The import parameter 'RECORD_FLAG' is available for any supplementary information. For example, FI uses it to mark records that are to be deleted.

n 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.

n The import parameter 'RECORD' receives the actual transferred data. If the structure entered under RECORD_STRUCTURE and the record transferred via RECORD do not match, you will get a runtime error. Archive cannot be read.

n 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. Due to performance reasons you should carry out these types of checks during the data selection stage.

Page 63: BIT670 - Programming Display Functions

© SAP AG BIT670 4-21

� SAP AG 2003

ADK API: ARCHIVE_PUT_TABLE

l Interface parameter import

n archive_handle

n record_structure

l Interface table

n table

l Capabilities of the function module:

n You can use this function module to transfer an internal table to the data object that was previously called by the function module ARCHIVE_NEW_OBJECT.Every row of the internal table is written to the data object as a separate data record. All transferred data records are written to the archive file together when you call up the function module ARCHIVE_SAVE_OBJECT.

n In the 'RECORD_STRUCTURE' parameter, you enter the name of the structure/table whose objects are to be written.

n The data is transferred to an internal table via the table interface.

n 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.

Page 64: BIT670 - Programming Display Functions

© SAP AG BIT670 4-22

� SAP AG 2003

ComparisonARCHIVE_PUT_RECORD - ARCHIVE_PUT_TABLE

l Writes one record at a time

l requires more coding

l Performance not as good, because it processes one record at a time

l writes array of records

l Requires less coding, due to loop structure

l Better performance, because does not process one record at a time

Page 65: BIT670 - Programming Display Functions

© SAP AG BIT670 4-23

� SAP AG 2003

l Interface parameter import

n archive_handle

l Capabilities of the function module:

n This function module writes an entire data object to the archive file. It includes the data that was transferred with the function module ARCHIVE_PUT_RECORD, and the data that was transferred via the archiving classes.

l Exceptions

n termination_requested

ADK API: ARCHIVE_SAVE_OBJECT

n 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 program, unless this option was switched off in transaction AOBJ "Customizing Settings".

n The exception "TERMINATION_REQUESTED" is triggered when the archiving session was interrupted in transaction SARA. In this case, the current data object will not have been written to the archive file. In this case, the write program must close the archive file created up to that point and come to an end.

Page 66: BIT670 - Programming Display Functions

© SAP AG BIT670 4-24

� SAP AG 2003

l ARCHIVE_PROTOCOL_INIT

n Interface parameter import

u I_DETAILPROTOCOL

l ARCHIVE_PROTOCOL_COLLECT

n Interface parameter import

u I_OBJECT

u I_TEXT

u I_MSGTYPE

u I_MSGID

u I _MSGNO

u I_MSGV1 to I_MSGV4

l ARCHIVE_PROTOCOL_WRITE

ADK API: ARCHIVE_PROTOCOL_*

n Function module ARCHIVE_PROTOCOL_INIT must be called only once before the first call of the function module ARCHIVE_PROTOCOL_COLLECT. The value of the check box "Detail Log" from the selection screen, must be transferred in the parameter I_DETAILPROTOCOL.

n Function module ARCHIVE_PROTOCOL_COLLECT must be called per archived business object. The business object is transferred via the parameter I_OBJECT, while the message type is transferred via parameter I_MSGTYPE (1 = processed, 2 = not processed, 3 = other). With the other parameters you can transfer the object information (e.g. "archived", "not archivable due to residence times", etc.). You can transfer the information in the form of text (I_TEXT) or as a message (I_MSGID and I_MSGNO). The parameters transferred in I_MSGV1 to I_MSGV4 are replaced in the message and in the text.

n The function module ARCHIVE_PROTOCOL_WRITE has to be called only once at the end of the program (e.g. after ARCHIVE_CLOSE_FILE). It generates the log.

n You can find complete documentation on the function modules in the function module documentation as of Release BASIS 640.

n The function modules are available in the standard as of BASIS 640. For Release BASIS 620 the function modules are available via SAP Note 583448 and in Release 470 via SAP Note 583995.

Page 67: BIT670 - Programming Display Functions

© SAP AG BIT670 4-25

� SAP AG 2003

PROGRESS_INDICATOR

l PROGRESS_INDICATOR

n Interface parameter import

u I_TEXT

u I_MSGID

u I_MSGNO

u I_MSGV1 to I_MSGV4

u I_PROCESSED

u I_TOTOAL

u I_OUTPUTIMMEDIATELY

n Interface parameter export

u E_PROGRESS_SENT

l The function module can be used everywhere, not only for data archiving!

n The function module shows the progress of a process. The information can be transferred as text or in the form of a message. For text use the parameter I_TEXT and for messages the parameters I_MSGID and I_MSGNO. It is better to use a message instead of a text if you want to also use a long text, for example.

n During a background job the progress is displayed via a message in the job log. During online processing the progress is displayed as text in the status field, with the help of the function module 'SAPGUI_PROGRESS_INDICATOR'.

n During background processing, progress is displayed about every 30 minutes, while during online processing progress is displayed every 10 seconds. See documentation for the parameter I_OUTPUT_IMMEDIATELY.

n The variables "&1" to "&4" of your text or your messages can be transferred or replaced by values calculated by the function module. See documentation for the parameter I_PROCESSED, I_TOTAL and I_MSGV4.

n You can find complete documentation on the function modules in the function module documentation as of Release BASIS 640.

n The function modules are available in the standard as of BASIS 640. For Release BASIS 620 the function modules are available via SAP Note 578812 and in Release 470 via SAP Note 583995.

Page 68: BIT670 - Programming Display Functions

© SAP AG BIT670 4-26

� SAP AG 2003

ADK API: ARCHIVE_WRITE_STATISTICS

l Interface parameter import

n archive_handle

n statistics_only_per_run

n statistics_only_per_file (as of Release 4.6)

l Capabilities of the function module:

n You can use this function module to generate statistics about the data objects that were written to the archive file with ARCHIVE_SAVE_OBJECT. These statistics are generated in the form of a list and therefore appear in the log of the archiving program.

n You can use the import parameter 'STATISTICS_ONLY_PER_RUN' to request totals statistics for the whole archiving 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.

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

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

Page 69: BIT670 - Programming Display Functions

© SAP AG BIT670 4-27

� SAP AG 2003

ADK API: ARCHIVE_CLOSE_FILE

l Interface parameter import

n archive_handle

l Capabilities of the function module:

n The function module closes the archive file.The resources that were allocated to a handle, are released.After that the handle is no longer valid and may not be used anymore. Each additional operation with this handle triggers the exception WRONG_ACCESS_TO_ARCHIVE .

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

Page 70: BIT670 - Programming Display Functions

© SAP AG BIT670 4-28

� SAP AG 2003

Example Report SBOOKA (1)

������ �����

�� ���� �����

������������������������ �������������� ����!����"�������#��$��% ��� �� %�&���� �'�(����������)*+���������,����-

�'������������.���)*+������,����-�'�!����������������������� � �/"���0-�'���������������12���)*+��,�����#��$��%�%-�'��������������(����������,��������3-�'��������������1.��������,����-�'���������2���������������,�����

&���� ������� �� � ����-������� �� ���� ����4 �����

�����������������������2�.��������������"������� �5����4� ��� ���!������3�6��7�4��8����������0�"*9:�������"�������� ��������4�������"�������&�4�$���%�7�%-

���������4�������"���������&�4�$���%*;999*9*%����%<99<9*9*%�

���������"���������&��4� ��� ���!������3�

����$&����!�=�����2�3�������<� >�(��=��������

Page 71: BIT670 - Programming Display Functions

© SAP AG BIT670 4-29

� SAP AG 2003

Example Report SBOOKA (2)

��������?���������4��8���������2��=����2�3������ >�(��=��������� (�.� �����

������������"��������$��$�����4��8���������2��=����2�3���1�21� $���5 ����������

�����"�4"���������������� 2�������������4$�������%���7�#���������������%�@������5��������2������� A�2�2����

������������(��.��!����������������4��8 ���� ������� �� �������

67��� ����� ���������� ��&�����������������������'��������������1.����A �/"������

������2�.������(���%���7�#�������4���6����%�(��.������������������'������������.��� A�%@%��4�2�=����� A�%@%��'�(�����������A��2���

������'�(�����������A�%@%��4�2�������������������

�'������������.����A��2�����&�4�

��&�4�

Page 72: BIT670 - Programming Display Functions

© SAP AG BIT670 4-30

� SAP AG 2003

Example Report SBOOKA (3)

���2������=���!�'��3��������������!�'���������4$�������%���7�#�������4���6����%�@������5������������������������.����A �'������������.���

��..�������������������������A�2���.�����������!�'��(�������������A �'�(���������������������������������������A ���������

�8������5���!�'��!�������������������A �'�!�����

������� ������� ���� �������������������������� �������������������������������������������������������

��3��B�!�����������(��.��� ��2����3B(1��!�������������������4��8�C��2�����3�����*D�������� �� �����2�����3�����*�����

���������E�����=���������������4$�������%���7�#����6�� F���%

�@������5���!�'��!�����A��'�!�����

��21�������������������& %������������������4$�������%���7�#���$�������&%

�@������5���!�'��!�������A��'�!��������������1��1���A�%� �� %�����������������A���������

Page 73: BIT670 - Programming Display Functions

© SAP AG BIT670 4-31

� SAP AG 2003

Example Report SBOOKA (4)

����������������������������������������������������������������� !"�#$%"�&�'�($)*+,!#+#�-�*&�������*.,%'#$"/�������+������������0 ��+���������������������������+�����������0�&1*,*"1$"/+#�-�*2&�������#�-�*3������������������������0 ��+���������+�����2������

��=���������������������!����!�'��(��������4$�������%���7�#����#��� F���%�@������5���!�'��!�������A �'�!�����@������������.���������G1������A�*�

�4 �/"�1��� A�*��'���������������12����A�%@%��@���

��&�4�

����������2��������.���3������������� �������"�������������"��������������"(�����������"������������'��������������(������������&� ,��2���

�����4$�������%���7�#������������������%�@������5�����������A��'��������������(���

����0�����A�%���3���(��3!�������3���!�'��%�)99*+��.�3�/2��A�*�

�'���������2���������A��'���������2���������H�*�

Page 74: BIT670 - Programming Display Functions

© SAP AG BIT670 4-32

� SAP AG 2003

Example Report SBOOKA (5)

��������������������������� !"�#$%"�&,'%/'*33+$"1$��#%'&*.,%'#$"/��+��4��0�&52��56����57������������������� ���������

�������&�886��+���������0���+��9����+���������+����������0���+�����+��9���+������

*"1�%%,�

��������������������������������9��������������������� !"�#$%"�&,'%/'*33+$"1$��#%'&

*.,%'#$"/��+��4��0�&52��56����57������������������� ����������������&�886�

�+���������0���+��9����+���������+�������������������0���+�����+��9���+������+������+�����������0�&.&�

$ ���+�������+����������0�&.&��������:������;����������������������������������������������������������������������������������������<�����������������������=

*"1$ �������������������������������

����� !"�#$%"�&�'�($)*+>'$#*+3#�#$3#$�3&*.,%'#$"/�������+�������0 ��+�������

��������������������������������� !"�#$%"�&�'�($)*+��%3*+ $�*&

*.,%'#$"/�������+�������0 ��+���������������������

����� !"�#$%"�&�'�($)*+,'%#%�%�+>'$#*&�

Page 75: BIT670 - Programming Display Functions

© SAP AG BIT670 4-33

� SAP AG 2003

Delete Program: Structure

� SAP AG 1999

l ARCHIVE_GET_CUSTOMIZING_DATAl ARCHIVE_OPEN_FOR_DELETEl Do

n ARCHIVE_GET_NEXT_OBJECTn ARCHIVE_GET_TABLE “or ARCHIVE_GET_NEXT_RECORD in DO Loopn PROGRESS_INDICATORn ARCHIVE_DELETE_OBJECT_DATA "call up archiving classesn If cut = cust_cut „check commit counter

Perform DeleteARCHIVE_GIVE_STATISTICS

n endifl ENDDOl If cust_cut > 0 „possible processing of remaining data

Perform DeleteARCHIVE_GIVE_STATISTICS

l Endifl PROGRESS_INDICATORl ARCHIVE_WRITE_STATISTICSl ARCHIVE_CLOSE_FILE

n Form DELETE: Deleting data from the database

Page 76: BIT670 - Programming Display Functions

© SAP AG BIT670 4-34

� SAP AG 2003

ADK API: ARCHIVE_GET_CUSTOMIZING_DATA

l Interface parameter export

n commit_count_for_delete_prg

n maintain_index

l Interface parameter import

n object (archiving object)

l Capabilities of the function module:

n This function module delivers values set in customizing for the archiving object to the archiving programs. At the moment only values that are important for the delete program are transferred. It is also possible to use the commit counter for the reload program.

Page 77: BIT670 - Programming Display Functions

© SAP AG BIT670 4-35

� SAP AG 2003

ADK API: ARCHIVE_OPEN_FOR_DELETE

l Interface parameter export

n archive_handle

l Interface parameter import

n archive_name

n object

n test_mode

l Capabilities of the function module:

n This function module opens archives in order todelete the data they contain from the database.The status of the archive files is adjusted accordingly in archive administration.

n The import parameter 'OBJECT' specifies the name of the archiving object containing the records for deletion.

n 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.

n During 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.

n Every additional call of this function module creates a new handle. This makes it possible to process many archives from different archiving objects simultaneously. It does not matter whether the archives have been opened for read access or write access.

Page 78: BIT670 - Programming Display Functions

© SAP AG BIT670 4-36

� SAP AG 2003

ADK API: ARCHIVE_GET_NEXT_OBJECT

l Interface parameter export

n object_offset

n archive_name

l Interface parameter import

n archive_handle

l Capabilities of the function module:

n For a handle, this function module reads the next data object in an archive that was opened for read.

n The parameters ARCHIVE_OFFSET and ARCHIVE_NAME are relevant for writing an index, if you want to use other indexes in addition to those supplied by SAP.

n 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.

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

Page 79: BIT670 - Programming Display Functions

© SAP AG BIT670 4-37

� SAP AG 2003

ADK API: ARCHIVE_GET_NEXT_RECORD

l Interface parameter export

n record

n record_structure

l Interface parameter import

n archive_handle

n automatic_conversion

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

n 'RECORD_STRUCTURE' contains the name of the table/structure that is being processed.

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

n When ARCHIVE_GET_NEXT_RECORD is called, temporary, automatic conversions could take place: Adaptation of structural changes; adaptation to heterogeneous system environments (code page), etc.

n With this function module you can sequentially read the data records of a data object.

n During the first call of the function module ARCHIVE_GET_NEXT_OBJECT the first record is delivered automatically; after that every subsequent data record is called until no more records exist in the data object.

Page 80: BIT670 - Programming Display Functions

© SAP AG BIT670 4-38

� SAP AG 2003

ADK API: ARCHIVE_GET_TABLE

l Capabilities of the function module:

n With this function module you can read all data records in a table for a current data object.

n If you want to read several records from the same table, do not use ARCHIVE_GET_NEXT_RECORD, because it is slower.

Page 81: BIT670 - Programming Display Functions

© SAP AG BIT670 4-39

� SAP AG 2003

ADK API: ARCHIVE_DELETE_OBJECT_DATA

l Interface parameter import

n archive_handle

l Capabilities of the function module:

n This function module calls up the delete methods for all registered archiving classes of the archiving object. As a result, the archived data of all classes are deleted automatically from the database.

n The function module 'ARCHIVE_GET_NEXT_OBJECT' must be called for each object, that is, once per data object. Here, the data that was archived via an archiving class, is deleted.

n The ADK API of the archiving objects themselves does not provide any delete methods. You must program 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 write program by ARCHIVE_PUT_RECORD or ARCHIVE_PUT_TABLE.

Page 82: BIT670 - Programming Display Functions

© SAP AG BIT670 4-40

� SAP AG 2003

Example Report SBOOKD (1)

������ �����

�� ��� ��� ������������������������������������ ��!"���"���!�#���� �$���%����������������������� �&����'()

�$���**'���%� ����������+����������*'�)�$���������%� �,���')�$����%� �,���')�$��%� �,���')�$���+*�%������������,�� �*'��+%���+*�%�)�$�����'$���&��������,�� �*'�-'��������'$��&)�$�������������������,���'�

#���� ������� �,�����"����. ����)��������������������,�����"����. �����

� �� #�������������/�0����%��1� 2333�-��4���%����

� ������5���� ����.��6����%����/�������/�0�'%'�� 2333�-��4���%����� -��*���'���

�������.��������� �7��/�%���%�4�����'$'%0�����'�%�������������

�����. ���� �!���8������� �.���#�����!�9����� :�����������������;����������

�����*��������;�/�������6����� :�����'$����%�����������������;��$���%���

Page 83: BIT670 - Programming Display Functions

© SAP AG BIT670 4-41

� SAP AG 2003

Example Report SBOOKD (2)

7�0����+���*'<'%0�����-��*���������'$'%0�������

�����. ���� �!���8����:���� ���6�5� :�#���!

�9����� :�����������������; ���������

�6����� :���**'����+%��-���������/�0 ; �$���**'���%��

7�0���������%+*�����-��������������������

�����. ���� �!���8����:���� .��6���� !

�9����� :�����'$����%�����; �$���%��

�6����� :�����'$����+*�%��; �$���+*�%�

����'$��%�*������; �$�����'$���&�

��������� :�� ������+%��.��6 �*'�-'����� �� �$�����������������

=8������+*�%����; �$���+*�%���� # ����'$��&�; �$�����'$���&�

7����/����0�������%�(�������������-��*���������'$��-'��>�?

�������$���������%��

#��

�����. ���� �!���8����:��� �9���"@���!

�9����� :�����'$����%�����;��$���%��

�9������ ���%��-�-'������;�A1�

�.��&��+����;�1�

�9���

� #�.�

Page 84: BIT670 - Programming Display Functions

© SAP AG BIT670 4-42

� SAP AG 2003

Example Report SBOOKD (3)

�##�1��� �$���������%��

��.���8 ��������

�����. ���� �!���8����:�����"��!

�9����� :�����'$����%�����; �$���%��

���������+��+���;�!�"���!

������������-��������;�!9!

��"�����������������������������; ��������

���� #��� ����. ������� �� ��������������

7���-�� �/�%'0B-+������������

7��������-+%��'�%�!���8����:�����"��!

7������(/���'%0�����'$����%����������; �$���%��

7�������������������������+��+������;�!#��� #� :���"��1!

7���������������������������-��������;�!9!

7�������������������������������������; ����/�%'%0������1�

7������� #��� ����.�����/�%'%0������1��������/�%'%0������1�������

7��'%�������-�����'$'%0��������

7�������-+%��'�%�!���8����#�������"@����#���!

7������(/���'%0�����'$����%����������;��$���%��

Page 85: BIT670 - Programming Display Functions

© SAP AG BIT670 4-43

� SAP AG 2003

Example Report SBOOKD (4)

�.��$���������%� ;��$���**'���%���������������������������������������������������������������� ;�������������������

���.��6�������-��*������� �� :��$���%��/�������$���������%���������������

#�����"����"������������������� ����$��%���##��$���������%� ����$����%���������$���������%�� ��.���8���������������2����/�%'0B-+������������

� #�.�7���%�/��0�����'%'�����

�����. ���� �!���:������ #������!�9����� :�'���(��;�!C1�>CD��-�CE?��-�����-�'0������'%0��������%

/�������!>AAE?'�/��������; �$����%�'�����������; �$������������������

� ##��

�. �$���������%� F;�1����.��6�������-��*������� �� : �$���%���2�����'%0������/���0�

/�������$���������%���������������

�## �$���������%� �� �$����%������� �$���������%��

Page 86: BIT670 - Programming Display Functions

© SAP AG BIT670 4-44

� SAP AG 2003

Example Report SBOOKD (5)

2����/�%'0B-+������������� #�.�

�.��$����%� ;��$������������������7���%�/��0�����'%'��������������%

�����. ���� �!���:������ #������!�9����� :

'���(����;�!C1�>CD��-�CE?��-�����-�'0������'%0���������%�/�������!>AAE?

'�/��������;��$����%�'���������������������;��$�����������������'��+�/+��'**�'����&�;�!9!�

� #�.�

7������������'��'����'�������. ���� �!���8����=���������������!�9����� :����'$����%�������������;��$���%������'��'����%�&�/���-'���;�!9!�

7���������������'$'%0�����'�%�����. ���� �!���8����������.���!�9����� :����'$����%���; �$���%���

Page 87: BIT670 - Programming Display Functions

© SAP AG BIT670 4-45

� SAP AG 2003

Example Report SBOOKD (6)

.��6�������-��*������� �� :�$��+�>/���%��?������������ �&����'($��+�>/�����*��?�����������/������$��+�>/���������%�?�������� �&���%�$��+�>/������������?����� ��������������

#���� ��������'��� �,������������)��������'��� �,�����"����.����������)���������+(��,�����"����. ����)�������������������$���%� �,�� �&���%��

��.���8 ��������'����

�.�/�����*�� ���� ������G�����������%�#"�'%�/��+��'�%�*��#����� ���� .��6���"���/������������� 2���������� ������������$���%��;��&���%��2����/�%'%0B-+������������

����� H�����������-��*�#"�'-��+%%'%0�'%������*����������7�.��6������� �����"������������+(

.�������� ������� �/������������=8��������'���;���/�����������������'� #���%%'���;���/���������������%%'� #�-�������;���/�������������-����� #����'���;��/����������������'��$���%��;��&���%��2����/�%'%0B-+������������

� #�.�

Page 88: BIT670 - Programming Display Functions

© SAP AG BIT670 4-46

� SAP AG 2003

Example Report SBOOKD (7)

��������'�������%�*� ;�!�!�

��������'������+%����;�/���������%��

���� # ��������'��� �� ��������'����

��������'�������%�*� ;�!�"���!�

��������'������+%����; �$���%��

���� # ��������'��� �� ��������'����

7�/��$'���#��4'�������'��'�������>��-�����$��&���66���=���I?

�����. ���� �!���8����:��������������!

�9����� :

����'$����%���;�/���%��

��"���

���������������; ��������'����

��66���=����

� #.��6� 2�#������.��6���"��

n COMMIT WORK 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.

n The collection of data belonging to an archiving class which is to be deleted, occurs via a call of ARCHIVE_DELETE_OBJECT_DATA. You only need to call this function module once per call of ARCHIVE_GET_NEXT_OBJECT.

Page 89: BIT670 - Programming Display Functions

© SAP AG BIT670 4-47

� SAP AG 2003

ADK API: Other Function Modules Relevant For Customers

l Archive_get_information

l Archive_open_for_move

� SAP AG 2003

n ARCHIVE_GET_INFORMATION This function module enables you to determine the latest information about an archive handle. This includes information about when the archive files were written, which structure they are based on, etc.The data could be important, for example, for adapting customer-specific analysis programs, when the structure of a table has changed.

n ARCHIVE_OPEN_FOR_MOVE This 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.

Page 90: BIT670 - Programming Display Functions

© SAP AG BIT670 4-48

� SAP AG 2003

Standard Tables and Customer-Specific Tables

APPEND

Standard tablewith customer-specific

structure

Extensionnot alwaysnecessary

Customer-SpecificZ table

ZZZ

Standardtable

B

Standard tables andcustomer-specific Y/Z

tables exist nextto each other

Creating of customer-specificarchiving object

Customer-specific Y/Z tablesthat belong logically

to standard R/3tables

Extension necessaryAssistance from

consultant recommended

Standardtable

C

Customer-Specific

Z table ZC,dependent

onStandardC table

Standardtable

A

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

Page 91: BIT670 - Programming Display Functions

© SAP AG BIT670 4-49

� SAP AG 2003

Procedure to Extend Standard Archiving Object

l List the modifications made

l Analyze the modifications to determine whether as a result of the modifications, current archiving objects or classes need to be changed

l Determine where in the data model the customer-specific tables belong

l Check whether dependencies to other archiving objects were created

n Caution: To ensure that the standard archiving programs continue to function correctly, the extensions must be carried out in the customer namespace in a new program.

n Caution: When extending a standard archiving object, ensure that the performance of the standard write program is not reduced.

Page 92: BIT670 - Programming Display Functions

© SAP AG BIT670 4-50

� SAP AG 2003

Extension: Dependencies

l Starting point:

n New dependencies due to the introduction of new documents

n New dependencies due to customer-specific requirements

l Possible consequences:

n New checks have to be entered into existing archiving programs: For SD archiving objects it is possible to use user exits

n Network graphic may have to be updated for the purpose of documentation

n 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.

n User exits in SD are discussed in course BIT660.

Page 93: BIT670 - Programming Display Functions

© SAP AG BIT670 4-51

� SAP AG 2003

Extension: Append Structure in Standard Tables

l Starting point:

n New fields were added to standard tables with the help of the append/include technique

l Consequences:

n As long as the archiving object or archiving class writes the original table, the write and delete programs do not need to be modified

n Read reports have to be adapted if the fields are to be displayed

n Check if dependencies were created

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

Page 94: BIT670 - Programming Display Functions

© SAP AG BIT670 4-52

� SAP AG 2003

Extension: New Tables for Standard Documents

l Starting point:

n Information about standard documents is stored in customer-specific tables

l Consequences:n The structure of the archiving object may have to be changed

in transaction AOBJ, to include the customer-specific tables

n Write and delete programs may have to be copied and adapted

n Analysis reports may have to be copied and adapted, if required

n Check for new dependencies

Page 95: BIT670 - Programming Display Functions

© SAP AG BIT670 4-53

� SAP AG 2003

Example Extension to MM_MATBEL (1)

l Add-on IS-OIL

For goods movements in the oil industry it is necessary to save temperature and density information in the database for every material item

This data is stored in a separate table, which has to be archived and deleted together with the standard tables MKPF and MSEG

Page 96: BIT670 - Programming Display Functions

© SAP AG BIT670 4-54

� SAP AG 2003

Example Extension to MM_MATBEL (2)

l Data model standard:

MKPF-> MSEG

l Extended data model IS-OIL:

MKPF-> MSEG

-> MSEGO1-> MSEGO2

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

Page 97: BIT670 - Programming Display Functions

© SAP AG BIT670 4-55

� SAP AG 2003

Example Extension to MM_MATBEL (3)

l Analysis of dependencies

n Unlike the standard, in certain situations (‘not mseg-oiexgnum‘) the material document is needed for a process called ‚Netting‘, which is carried out together with the invoice verification. In the section 'oil_put_oiaqb' the system checks if this process is completed

n Cross-dependencies to other archiving objects are not offered

Page 98: BIT670 - Programming Display Functions

© SAP AG BIT670 4-56

� SAP AG 2003

Example Extension to MM_MATBEL (4)

l Analysis of standard write program with a focus on structure logic and performance optimization

n The program looks for the optimal strategy to select the documents to be archived(the selection takes place via head and items data)

n If it is necessary to select via items data, a database view is used

n The program works with dynamic SQL

n The program determines new selection criteria to keep the selection amount of data as small as possible

n The program uses a central authorization check to restrict the amount of data to be selected and processed.

n The program writes head data of a document separately, using 'ARCHIVE_PUT_RECORD', and all items data of a document together using 'ARCHIVE_PUT_TABLE'.

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

Page 99: BIT670 - Programming Display Functions

© SAP AG BIT670 4-57

� SAP AG 2003

Example Extension to MM_MATBEL (5)

l Adapting standard write program:

n Insert the coding for the necessary data definitions

n Insert the coding for the processing log for the new data

n Insert the coding for the selection of the new data

n Insert the coding for the archivability checks

n Insert the coding for the writing of the table records to archive files after the superior tables have been written in thestandard

Page 100: BIT670 - Programming Display Functions

© SAP AG BIT670 4-58

� SAP AG 2003

Example Extension to MM_MATBEL (6)

l Adapting the Standard Delete Programn Insert the necessary data declarations

n Filling of the internal table for new data, after the data has been read from the archive file(s)

w The programming code corresponds to the coding for standard tables

w The new coding is inserted after the coding for the processing of the superior tables

n Insertion of a delete sequence for the new data

w The programming code corresponds to the coding for standard tables

w The new coding is inserted after the coding for the processing of the superior tables

n 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.

Page 101: BIT670 - Programming Display Functions

© SAP AG BIT670 4-59

� SAP AG 2003

Extension: Summary (1)

l Adapting the write program

n Copy the standard program into your customer namespace

n Carefully analyze the write program

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

n Find out where the superior table is processed in the write program

n Add the definition of the data structures you need

n Add the coding for the selection of the data in the Z table

n If necessary, add the coding for the archivability check

n Add the coding for the transfer of the data in the Z table to ADK

n NOTE: A careful analysis of the write 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.

n User exits are not offered so that further performance optimization and the inclusion of new structures in the standard can be carried out 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.

Page 102: BIT670 - Programming Display Functions

© SAP AG BIT670 4-60

� SAP AG 2003

Extension: Summary (2)

l Adapting the delete program

n Find the place where the data records are deleted

w CASE structure after calling up the function moduleARCHIVE_GET_NEXT_RECORD

w List of delete calls

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

Page 103: BIT670 - Programming Display Functions

© SAP AG BIT670 4-61

� SAP AG 2003

Extension: Summary (3)

l Adapting an analysis program (optional)

n Extending the output structure

n Extending to include the output of the data

Page 104: BIT670 - Programming Display Functions

© SAP AG BIT670 4-62

� SAP AG 2003

Extension: Recommendation

l We do not recommend that you extend any standard archiving objects

l If it cannot be avoided, you should contact SAP consulting

l Recommended procedure:

n If you have your own Y/Z tables that belong to a standard archiving object, archive them as individual tables using your own archiving object

n Write reports that read and bring together the archive files of the standard object and those of your own object

n 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.

Page 105: BIT670 - Programming Display Functions

© SAP AG BIT670 4-63

� SAP AG 2003

l Explain the steps involved in creating a new archiving object

l Explain the logic of a write program

l Explain the logic of a delete program

l Explain the procedure for extending an archiving object

You are now able to:

Write and Delete Programs: Summary

Page 106: BIT670 - Programming Display Functions

© SAP AG BIT670 4-64

Exercises

Unit: Write and Delete Programs Topic: Archiving STICKET

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

• Use data archiving to write the data of the customer-specific table STICKET into an archive file.

Your company is using its own table, called STICKET. This table has been identified as a critical table. The size of this table must be reduced. First you must write a write and delete program for the new archiving object.

1-1 Creating a write program for STICKET: Use the program ZSTICKET00_WRI as an example. Program name: ZSTICKETxx_WRI. XX is your group number. Type: Executable program Status: Test program Application: Basis

1-1-1 Create a write program that archives records from the table STICKET. The selection parameters are the airline (CARRID), the flight number (CONNID), the flight date (FLDATE) and the booking number (BOOKID).

1-1-2 Select the data to be archived from table STICKET, so that even for large data volumes, the issued SELECT statements do not take long. First, create a table with all combinations of fields to be archived for CARRID, CONNID, FLDATE, BOOKID. Then loop via this table and only at this point select from the database all records to be archived for every combination of the aforementioned fields.

1-1-3 Archivability checks for STICKET records are not necessary.

1-1-4 A data object is to contain all of the same records of the aforementioned fields.

1-1-5 Use the standards you learned about for the write program. These standards are available in the program you are using as an example.

Page 107: BIT670 - Programming Display Functions

© SAP AG BIT670 4-65

2-1 Creating a delete program for STICKET - Use the program ZSTICKET00_DEL as an example. Program name: ZSTICKETxx_DEL XX is your group number. Type: Executable program Status: Test program Application: Basis

2-1-1 Use the standards you learned about for the delete program. These standards are available in the program you are using as an example.

2-1-2 Do not create an “old“ index. SAP AS is to be used later to read the archived data.

Page 108: BIT670 - Programming Display Functions

© SAP AG BIT670 4-66

Unit: Logic of the data archiving programs Topic: Customizing and testing ZBCSTICKxx

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

• Create an archiving object in transaction AOBJ.

• Test a new archiving object

Your company is using its own table, called STICKET. This table has been identified as a critical table. The size of this table must be reduced. After you have written the basic required programs, you must create the archiving object in the system.

1-1 Creating archiving object ZBCSTICKxx - XX is your group number.

1-1-1 Create a new archiving object in transaction AOBJ. Use BC for the application area and use the F4 Help to choose Basis as your application component.

1-1-2 Enter your write and delete programs.

1-1-3 Enter the structure definition. You are working on table STICKET.

1-1-4 Maintain the cutsomizing settings:

1-1-4-1 Your logical file name should reference to the path Archive_data_file.

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

1-1-4-3 After being archived, the file should not be stored on an external optical archive.

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

2-1 In transaction SARA start an archiving session and a delete run for your newly created archiving object. Start the sessions with ‘Start Immediately’. Your instructor will give you the necessary information for your group.

Page 109: BIT670 - Programming Display Functions

© SAP AG BIT670 4-67

Solutions

Unit: Write and Delete Programs Topic: Archiving STICKET

1-1 Tools, ABAP Workbench, Development, ABAP Editor Enter ZBCSTICK00_WRI, Push Button Copy. Enter ZSTICKETxx_WRI. XX is your group number. Copy all available parts of the program Save as a local object Enter the archiving object ZBCSTICKxx, and LC_OBJECT for the constant. Note: Watch out for the capitalization of letters. Adapting the coding of the interfaces for the function modules used.

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

2-1 Tools, ABAP Workbench, Development, ABAP Editor Enter ZBCSTICK00_DEL, Push Button Copy. Enter ZSTICKETxx_DEL. XX is your group number. Copy all available parts of the program Save as a local object Enter the archiving object ZBCSTICKxx, and LC_OBJECT for the constant. Note: Watch out for the capitalization of letters. Adapting the coding of the interfaces for the function modules used.

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

Page 110: BIT670 - Programming Display Functions

© SAP AG BIT670 4-68

����������� �����

����������� ��

��� ������������������ ���

���������� ������!����� "� �����

�����������##����!����� "��##���

���������$%� ���!����� "$%� ��

���������&�������!����� "&������

���������'���������� ���

(�� �� �% � �#�

)����������%���&* ������!�� ��+��&*"�&* ��,��-��./�)���)!��.��

'�������%0�$% ���� 123���������4������

��������%0�� % � �5�� 123������4������

��������%0�+ #�% �������������������!����" &6��

'�������%0��&* ��� #$ ��������4�����#7��

��������%0�� %��&* ��#85& ������4�����

��������%0��&* ������� �� ��������4�����

'�������%����� �������������������4������������������ ���

��������%���� �����������������4��������������� ��

����'"�49������:%������ �;����������!����������%����� ���

(�� % ��#��� � � #��� � 5 ���

����)����"�)�����������������)!� ��+�&���#7�<��=����9�������� 6"2>?��

����)�"������������ ����������� "� �����

��������������������##��������� "��##���

������������������$%� �������� "$%� ��

������������������&������������ "&������

����)����"�)�������'�������)!� ��+�&���#7��

��)�-'�� ��+��� ���7�� #� ��@�������A�$%�����#��%�

��������/�������

��������9�� #� �������� ��7�#���A�$%�����#��%��$� 5 � %�

�������)����"�)������-��-���

��������9�� #� �������� ��7� �8�8�-�����%���&* ���

��A����#��$���� ���$�� % ����7� 5�

Page 111: BIT670 - Programming Display Functions

© SAP AG BIT670 4-69

�����"��"����)������

(�� �� � 5 ���$���.��)=�,�����������<����.�$��5�� % ��#���� #�

��%0�� % � �5�� �B�.C.��

�����������B�.C.��

����%0�$% ���� �B��� � ��

��������

����%0�$% ���� �B�.C.��

���������� %��������������

������%0�� % � �5�� �B��� � ��

������'����

����'����

(�#�������%%�

��)�����-�)�����.��)=�,�������)�������.�

�����C��������

�������� %������%�B��������

(�&8%��� % ��#�� �� 7 ��

������)��'�����)��� ������##��$%� �&��������9���� �

��������������������%����� ��

���������<=����� ���������� ����

�������������'���##���������##��

�������������'�$%� ������$%� �

�������������'�&����������&������

��%0�� %��&* ��#85& ��B���"�&�#��

(��� #� �# �� ��+0#7�� ���#��� ��+0 �� �

��)�����-�)�����.��)=�,�����������<����.�

�����C��������

������� %%�� % �*�&�#� ��5�� �B�%0�� % � �5�� �

��������55 #����������������������B�����5 #�

�������� � ��+0 �$% ����������B�%0�$% ���� �

�������&* ������������������������B�%���&* ��

�����9��������

������ ��+0 �+ #�% �B�%0�+ #�% ��

Page 112: BIT670 - Programming Display Functions

© SAP AG BIT670 4-70

����������%����� ������������:%������ �;��

(�� % ��� �$��5�+ �� & � �

����������=�%���� ��

��������)��(����9���� ������������%���� �

���������<=����� ����B�:%������ �;"� ����

�������������'���##��B�:%������ �;"��##��

�������������'�$%� �B�:%������ �;"$%� �

�������������'�&�����B�:%������ �;"&������

(�# %� � �# ��� ��&* ��

����)�����-�)�����.��)=�,����<���D�)�.�

�������C��������

�������� ��+0 �+ #�% �B�%0�+ #�% ��

(��8�� �� ������#���'!.��� ���# # ��

����)�����-�)�����.��)=�,���-�������.�

�������C��������

�������� ��+0 �+ #�% �����������B�%0�+ #�% �

��������� �������8�8� �B�.���)!��.�

�������������

�������� &% ������������B�%���� ��

(��� �� ��&* ��#��+ � ��+0 �$% �

����)�����-�)�����.��)=�,����,����D�)�.�

�������C��������

�������� ��+0 �+ #�% �����������B�%0�+ #�% �

�������C)��������

�������� �5# �#�� E8 � ��B�2��

���������"�8&���������������

������%0��&* ������� �� ��B�%0��&* ������� �� ��F�2��

�������������"�8&���B�2��

�������C����

������'����

(���%% ��������%�5 �� 7 ��

���)��)��������:%������ �;"� ����:%������ �;"��##��:%������ �;"$%� �

����:%������ �;"&����������%0��&* ��� #$ ����������'��4��� � ��

����)�����-�)�����.��)=�,�������)���)����)�.�

�������C��������

����������&* ���B�%0��&* ��� #$ ��

��������� 6����B�.$%7+��� ��+ 0 �& #� ��+0 �.1>>23�

���������5�7�� �B�2��

Page 113: BIT670 - Programming Display Functions

© SAP AG BIT670 4-71

(�� #�����7� ���#�� ���

����)�����-�)�����.�����������'�)����.�

�������C��������

��������� 6������B�.G2H��$�$%7+��� ��+ 0 �& #� ��+0 �.1>>@3�

������������� �� ��B�%0��&* ������� �� ��

���������� %�����B�%0�� %��&* ��#85& ���

����'������

(�� #�����7� ���#�� ���$� %%��&* ��� � ����� �� ��

��)�����-�)�����.�����������'�)����.�

�����C��������

������� 6������B�.G2H��$�$%7+��� ��+ 0 �& #� ��+0 �.1>>@3�

����������� �� ��B�%0��&* ������� �� ��

�������� %��������������B�%0�� %��&* ��#85& ��

��������8�8�55 � %��B�.C.��

(��� �+ �� $ 8%�����%�%��

��)�����-�)�����.��)=�,��<�������������)�.�

�����C��������

������ ��+0 �+ #�% �B�%0�+ #�% ��

(��%�� �+ � ��+0#7�� ���#�

��)�����-�)�����.��)=�,��)���������.�

�����C��������

������ ��+0 �+ #�% �B�%0�+ #�% ��

(��� �������%�

��)�����-�)�����.��)=�,�������)���<����.��

Page 114: BIT670 - Programming Display Functions

© SAP AG BIT670 4-72

��������/���)!���'����

(�� �� �% � �#�

)����������%���&* ������!�� ��+��&*"�&* ��,��-��./�)���)!��.��

'�����%0�+ #�% �������������������!����" &6��

������%0���55��#����������!�� ��+�8��" ��+���5��

������%0��&* ���#���������4�����

������%0�� %�#���������4�����

'�����%���� ����������4��������������� ��

������%���� �� % ���4��������������� ��

'�����%0����85 #�����������4��� �5��8#"���85 #��

������%0� ��+0 �� ���������4��� �5�$% �" ��+0�� ���

������%0��&* ������ % ��4�����

��)�-'�� ��+�� % ���7�� #� ��2�������A:::�$%�����#��%�

��������/�������

��������9�� #� ������� % ��7�#���A:::�$%�����#��%��$� 5 � %�

�����"��"����)������

(��� #� �# �� ��+0#7�� ���#���� % �� �

��)�����-�)�����.��)=�,�����������'�����.�

�����C��������

�������&* ������������������������B�%���&* ��

������ ��5�� ������B���� %��

�����9��������

������ ��+0 �+ #�% �B�%0�+ #�% ��

(�7 �)8��5�#7�� �$��5�+ � ��+0#7��&* ��

��)�����-�)�����.��)=�,������)-���9�/����'���.�

�����C��������

�������&* ������������������������B�%���&* ��

�����9��������

��������55���8#�$���� % ���7�B�%0���55��#��

(�7 �� %�#85& ���$��&* �����& �� % ��

Page 115: BIT670 - Programming Display Functions

© SAP AG BIT670 4-73

��)�����-�)�����.��)=�,�����������9�����.�

�����C��������

������ ��+0 �+ #�% �����������B�%0�+ #�% �

�����9��������

������ ��+0 ����85 #�B�%0����85 #�

������ ��+0 �# 5 �����B�%0� ��+0 �� ���

������)����������&*���8#����9� �5�$% �������%0��&* ������ % �

�������������������<=�������85 #���B�%0����85 #�

�����������������������'� ��+0�� ��B�%0� ��+0 �� ���

(�%������7 �+ �# 6�� ��&* ��$��5�+ � ��+0 �$% 1�3�

��)�����%0��&* ���#��

��'���

����)�����-�)�����.��)=�,��������C����D�)�.�

�������C��������

�������� ��+0 �+ #�% �����������B�%0�+ #�% �

�������C)��������

�������� #���$�$% ����B�>2��

���������"�8&���B�2��

�������C����

������'����

�����''�2����%0��&* ���#��

����������=�%����)!����

����)�����-�)�����.��)=�,�����������.�

�������C��������

�������� ��+0 �+ #�% �����������B�%0�+ #�% �

��������� �������8�8� �B�.���)!��.�

�������� %%�� �������$��&* ��B�.C.�

�������������

�������� &% �����������������B�%����)!����

���������'����������%���� ����%����)!���� % ��

Page 116: BIT670 - Programming Display Functions

© SAP AG BIT670 4-74

�������%0��&* ���#�B�%0���55��#��

(������ % �� �1$��8###7�#�����8��#�5�� 3�����58% �� % �#�

(�����1$��8###7�#� ��5�� 3� #����%% ��� ����

������������9�� % �$��5� &% �-�����%0�+ #�% �

����������������������������������������� %��

��������������������������������������%0��&* ���#�

��������������������������������������%���� �� % ��

�������''�%0��&* ���#����%0�� %�#��

������)�����%0��&* ���#��

������������=�%���� �� % ��

������'����������������������������������A�0 %8 ��$���55���8# ��

(�� #�����7� ���#�� ���

����)�����-�)�����.�����������'�)����.�

�������C��������

��������� 6������B�.G2�1G@��$�GI3��$�$%7+��� ��+ 0 �& #����� �� �.1>>I3�

������������� �� ��B�%0�� %�#�

���������� %�����B�%0��&* ������ % ��

����''���

�����%0��&* ���#�;B�2��

����������9�� % �$��5� &% �-�����%0�+ #�% �A�� % #7�% ��� �� 7 �

��������������������������������������� %��

������������������������������������%0��&* ���#�

������������������������������������%���� �� % ��

�����''�%0��&* ���#����%0�� %�#��

����)�����%0��&* ���#��

����'����

�����%0�� %�#�B�%0��&* ������ % ��

(�� #�����7� ���#�� ��� �+ � #��

����)�����-�)�����.�����������'�)����.�

�������C��������

��������� 6������B�.G2�1G@��$�GI3��$�$%7+��� ��+ 0 �& #����� �� �.1>>I3�

������������� �� ��B�%0�� %�#�

���������� %���������������B�%0��&* ������ % �

����������8�8�55 � %��B�.C.��

����'����

Page 117: BIT670 - Programming Display Functions

© SAP AG BIT670 4-75

(��� �� ����%��

��)�����-�)�����.��)=�,��<�������������)�.�

�����C��������

������ ��+0 �+ #�% �����������B�%0�+ #�% �

������� �����#%��� ��$% �B�.C.��

(��%�� �+ � ��+0#7�� ���#�

��)�����-�)�����.��)=�,��)���������.�

�����C��������

������ ��+0 �+ #�% �B�%0�+ #�% ��

Page 118: BIT670 - Programming Display Functions

© SAP AG BIT670 4-76

("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(�

(����������9�'���������9����������������������������������������������(�

("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(�

(��"";��,�=��'�������������'!�+ #�% �

(��"";��,�����9�'���������C�B�� % #7�#� ��5�� �

(��"";��,���D�)��)��������#85& ���$�� % ��� ��&* ���

(��"";�������)!���'�������� ��������� % �$��5���� �

("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""(�

���9�� % �$��5� &% �

����������������-�����0 %8 1$0�+ #�% 3�����������!����" &6�

����������������������0 %8 1$0� �5�� 3���������!����� %��

����������������������0 %8 1$0��&* ���#3�������!����"�&�#�

����������������������0 %8 1$���� �� % 3���!��%���� �� % ��

��'������%�� �������4������������ ��+�� ��

���������%0��&�#������4�����"�&�#��

��$ %�"��5&�%���:%��� ;�%� �%# ��$�%�� ��

�����$0� �5�� �������������

(���� % �� ��#�'��$��8###7�#�����8��#�5�� �

����'��������� ����9�������$���� �� % ��

����%0��&�#�B���"�&�#��

��������

(���� % ��� �$��5�'��$��8###7�#� ��5�� �

��������)����8#1(3����9���� ������%0��&�#�

��������������������������������$���� �� % �

�������������<=����� �����B�$���� �� % "� ����

�����������������'���##���B�$���� �� % "��##��

�����������������'�$%� ��B�$���� �� % "$%� �

�����������������'�&������B�$���� �� % "&������

����'����

�������'�# %�%# ���%�� � ��7##7�:%��� ;��

��:%��� ;" &# 5 �B�.�.��

��:%��� ;"��8#���B�$0��&* ���#��

�������'�# %�%# ���%�� � ��7##7�:%��� ;��

��:%��� ;" &# 5 �B�.���)!��.��

��:%��� ;"��8#���B�%0��&�#��

Page 119: BIT670 - Programming Display Functions

© SAP AG BIT670 4-77

(����0� ��'!��+�� ����� �1& $�� � 0 ���)�99���<��!J3�

��)�����-�)�����.��)=�,����,����������)�.�

�����C��������

������ ��+0 �+ #�% �B��,�+ #�% �

�����������

������ &% ����������B�%�� ��

��)�99���<��!��

��'���9��������������������������������A�'���������9�������

Page 120: BIT670 - Programming Display Functions

© SAP AG BIT670 4-78

Unit: Unit: Logic of the data archiving programs Topic: Customizing and testing the archiving object

1-1 Creating archiving object ZBCSTICKxx for STICKET.

1-1-1 Call transaction AOBJ Push Button <New Entries> Object name: ZBCSTICKxx / Text: Archiving object for STICKET/Group xx

1-1-2 Write Program: ZSTICKETxx_WRI / Delete program: ZSTICKETxx_DEL Save archiving object Back to basic screen

1-1-3 Select the archiving object ZBCSTICKxx Double click on the dialog structure 'Structure definition' Enter STICKET in the field in the ‘Segment’ column Save the archiving object Back to the basic screen

1-1-4 Select the archiving object ZBCSTICKxx Double click on the dialog structure 'Customizing Settings'

1-1-4-1 Enter the logical file name: Archive_data_file

1-1-4-2 Enter ‘Size of an Archive File’ Size in MB: 100

1-1-4-3 Make no entry under connection to the archive system.

1-1-4-4 Entries under Settings for Delete Program – Delete Jobs: Flag 'Not Scheduled' is set Entry for Test Mode Variant: TESTxx Entries under Production Mode Variant: PRODxx. For both variants: Push Button <Variant> Set the appropriate delete flag in the variant: Test X Production Mode: no entry

Page 121: BIT670 - Programming Display Functions

© SAP AG BIT670 4-79

2-1 Tools, Administration, Administration, Data Archiving Enter archiving object ZBCSTICKxx Testing of the write program: Push Button <Write> Maintain variant Groupxx; your instructor will provide you with the data that needs to be archived Back to the basic screen 'Create Archive Files’ Push Button <Start Date>

Choose: Immediately Save and back to basic screen 'Create Archive Files’ Push Button <Spool Parameter> Printer: LP01 Output Device: Printer Save and back to basic screen 'Create Archive Files’ Push Button <Execute> Archiving sessions are being created. Monitor jobs via push button <Job Overview> Back to the screen: Archive Administration Initial Screen Testing of the delete program: Push Button <Delete> Start Date 'immediately' and in Spool Parameter enter LP01 as described above Push Button 'Archive Selection' Choose your archiving session in the popup Save Push Button <Execute> Delete jobs are being generated. Monitor jobs via push button <Job Overview> Back to the screen: Archive Administration Initial Screen

Page 122: BIT670 - Programming Display Functions

© SAP AG BIT670 5-1

� SAP AG 2003

l The logic behind sequential read programs

l The logic behind reading archiving classes

l Creating a sequential read program with and without archiving classes

Contents:

Sequential Read Programs

Page 123: BIT670 - Programming Display Functions

© SAP AG BIT670 5-2

� SAP AG 2003

l Create a sequential read program

l Use a read program to read data that was written to an archive via archiving classes

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

Sequential Read Programs: Course Objectives

Page 124: BIT670 - Programming Display Functions

© SAP AG BIT670 5-3

� SAP AG 2003

Sequential Read Programs: Overview

ŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁ

������������

� �� ������ ���������

���� ������������������

ŁŁŁŁŁŁŁŁ � ��� ���� ������������� �

ŁŁŁŁŁŁŁŁ ���������������������� �

ŁŁŁŁŁŁŁŁ ���� !"����������������� �

ŁŁŁŁŁŁŁŁ ������

Page 125: BIT670 - Programming Display Functions

© SAP AG BIT670 5-4

� SAP AG 2003

l Your company wants to create its own read programs for its own archiving objects and for the R/3 standard archiving objects

l The developers responsible for creating the read programs learn about the logic behind these programs

l The new read programs will also be used to read archiving classes

Sequential Read Programs: Business Scenario

Page 126: BIT670 - Programming Display Functions

© SAP AG BIT670 5-5

� SAP AG 2003

Index-Based and Sequential Read Access

1. Index-based access

Requires an index, which is:

a) Listed in transaction AOBJ

b) Created using the new SAP AS tool (transaction SARI)

Both index solutions can be used in parallel; each read program should use exactly one of them.

2. Sequential access

During a sequential access the report displays a dialog box, in which the user can choose which archive files he or she wants to read. The files chosen by the user are read completely (sequentially). Each data object in the archive file is read and the program checks if it contains records that match the criteria chosen in the selection screen. Only those records that do are pulled.

n 1a) The flags for "Build Index" and for index build and delete programs have to be set. This is the "old" index solution. The index is kept in the ADK table ARCH_IDX, or in the tables that were especially created by the application (e.g. ARIX-BKPF for FI_DOCUMNT). Which tables are being used can be seen in the coding of the index build and delete program. For new developments we recommend alternative b).

n 1b) The index is the infostructure, that is, the table that is created when the infostructure is activated. This index does not have to be entered in transaction AOBJ.

n Example for point 1 on slide: accessing the selected, archived documents directly from the application. E.g. FI_DOCUMNT, EC-PCA, MM_MATBEL (as of Release 4.0 up to and including Release 4.5, the report RM07MASE must be executed for MM_MATBEL, in order to create selection parameters for archived documents in transaction MB51). Customer-specific or SAP reports. Archive85

n Explorer in the SAP AS (technical access as via SE16).

n Example for point 2 on slide: Customer-specific or SAP reports.

n All read programs, regardless of whether they come from Group 1 or Group 2, can be entered in transaction AOBJ under "Read Programs" if you want to call them up from transaction SARA via the push button "Read". Customers can also use transaction SM30 (instead of AOBJ) to maintain entries in in table ARCH_REPOW for the corresponding archiving object.

Page 127: BIT670 - Programming Display Functions

© SAP AG BIT670 5-6

� SAP AG 2003

Sequential Read Program Logic

l ARCHIVE_OPEN_FOR_READ

l Do

n ARCHIVE_GET_NEXT_OBJECT

n ARCHIVE_GET_TABLE or ARCHIVE_GET_NEXT_RECORD in DO Loop

n PROGRESS_INDICATOR

n Read archiving classes

l ENDDO

l PROGRESS_INDICATOR

l ARCHIVE_CLOSE_FILE

n The read logic of read programs is basically the same as the logic of delete programs. The function module ARCHIVE_OPEN_FOR_DELETE is replaced by ARCHIVE_OPEN_FOR_READ.

Page 128: BIT670 - Programming Display Functions

© SAP AG BIT670 5-7

� SAP AG 2003

ADK API: ARCHIVE_OPEN_FOR_READ

l Interface parameter export

n object (archiving object)

l Interface parameter import

n archive_handle (pointer to the selected archiving sessions)

l Capabilities of the function module:

n Authorization check for S_ARCHIVE

n Displays popup of all archiving sessions:User selects the archiving sessions to be displayed

n Creates archive_handle

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

Page 129: BIT670 - Programming Display Functions

© SAP AG BIT670 5-8

� SAP AG 2003

ADK API: ARCHIVE_GET_NEXT_OBJECT

l Interface parameter export

n archive_handle (pointer to the selected archiving sessions)

l Capabilities of the function module:

n Reads the first/subsequent data objects and transfers the data from the archive to ADK

l Exception: End of file

n The function module reads the next data object in the archive file.

n The function module operates in the same way, regardless of whether it is called from a read, delete or reload program.

Page 130: BIT670 - Programming Display Functions

© SAP AG BIT670 5-9

� SAP AG 2003

ADK API: ARCHIVE_GET_NEXT_RECORD

l Interface parameter export

n archive_handle (pointer to the selected archiving sessions)

l Interface parameter import

n record (contents of a single table record for the object)

n record_structure (name of table from which the record originated)

l Capabilities of the function module:

n Retrieves the table records of an object and makes them available in the buffer area

l Exception: end of object

Page 131: BIT670 - Programming Display Functions

© SAP AG BIT670 5-10

� SAP AG 2003

ADK API: ARCHIVE_GET_TABLE

l Interface parameter import

n archive_handle

n record_structure

n all_records_of_object

l Interface table

n Table

l Capabilities of the function module:

This function module was developed to facilitate the implementation of read operations. It reads several data records from a structure, which is specified via RECORD_STRUCTURE, and writes these records to an internal table.

n The parameter 'RECORD_STRUCTURE' transfers the name of the structure/table containing the objects to be read.

n ALL_RECORDS_OF_OBJECT = ' ‘

All records are 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, which 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.

n ALL_RECORDS_OF_OBJECT = 'X' In this case, the function module reads all data records in the whole data object for the specified structure. The data records that are read are stored in table TABLE. It does not matter if there are data records with another structure between the data records with the specified structure RECORD_STRUCTURE. All records for the specified structure are collected in the current data object regardless of their location in the current data object. It is possible to continue to read with ARCHIVE_GET_NEXT_RECORD. ARCHIVE_GET_NEXT_RECORD continues reading the records from the point reached when the function module was last called. This is done independently from the data records that were read with ARCHIVE_GET_TABLE. If ARCHIVE_GET_NEXT_RECORD has not previously been called, the first data record is read.

Page 132: BIT670 - Programming Display Functions

© SAP AG BIT670 5-11

� SAP AG 2003

ComparisonARCHIVE_GET_RECORD - ARCHIVE_GET_TABLE

l Reads one record at a time

l More coding required, since CASE query must be processed

l Operations done in main memory (Data moved to work area)-> Lowers performance

l Reads array of records

l Standard procedure: delivers all records of the same type that reside in subsequent order in an ADK file, to a table-> requires less coding

l Improves performance due to mass processing of data

n 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.

n The records are given to the read program in the order in which they were written by PUT_RECORD or PUT_TABLE.

Page 133: BIT670 - Programming Display Functions

© SAP AG BIT670 5-12

� SAP AG 2003

ADK API: ARCHIVE_CLOSE_FILE

l Interface parameter export

n archive_handle (pointer to the selected archiving sessions)

l Capabilities of the function module:

n Closes the archive file

n Releases the resources of an archive_handle

n 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 .

Page 134: BIT670 - Programming Display Functions

© SAP AG BIT670 5-13

� SAP AG 2003

Sequential Access Logic (1)

ADK/AOBJ:Definition Archiving Object X

A TableB TableC Table

ARCHIVE_OPEN_FOR_READABAP program with internal tables

Archivefile

Data container with current data object

ABBBCC

A

B

C

ARCHIVE_CLOSE_FILE

ARCHIVE_GET_NEXT_OBJECT

ARCHIVE_GET_TABLE

ARCHIVE_GET_TABLE

ARCHIVE_GET_TABLE

1

2

4

3

3

3

n Step 1: Check whether the named archive file is available. Open files.

n Step 2: The first object is transferred from the archive file to an area in the main memory that is only accessible to ADK.

n Step 3: From the main memory all the corresponding records per table are transferred to an internal table. The contents of this table can then be processed as needed.

Page 135: BIT670 - Programming Display Functions

© SAP AG BIT670 5-14

� SAP AG 2003

Sequential Access Logic (2)

DeclarationInternal tables (itabA, itabB, itabC)

open existing archive file(s) for read accessARCHIVE_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 table records from container to an internal tableARCHIVE_GET_TABLE

export: archive_handleimport: table

write record to list

close archive filesARCHIVE_CLOSE_FILE

export: archive_handle

Pertable to

beread

Loopas long as

there are stilldata objectsto process

n The process supplies the data sequentially according to the order in which it is stored in the ADK archive file. If you want a different order, you must sort it in the main memory.

Page 136: BIT670 - Programming Display Functions

© SAP AG BIT670 5-15

� SAP AG 2003

Example Report: SBOOKR (1)

������������

����������������� ������������������ �������� ������������!

������� �����������!��"����� ������"������

#"$��%��������������

����������������&���� �������������������'���������� ���!

#���"$��%����������������()��"$��%����������������*)������������'���������� ����

&���� �+�%������������������������,���(�����-� ���&��'.����� /�����0�����'������ ��������������/���"$��%���������0��()�����!

������� ����������� �)����-�����1����%�+��"����

����� 2�������3���4�5������� ������&3�6������7���8������������9�3�������,3�.������7�����%�+��%������9��+�%������6�����������4������������9�:�

Page 137: BIT670 - Programming Display Functions

© SAP AG BIT670 5-16

� SAP AG 2003

Example Report: SBOOKR (2)

� ��(��$��� /0�;�.����7���&��(�*�1�� �'���3�3��2.�����(�*�1�

<��4��(�*�1+:��(�*�1+=��(�*�1+>��(�*�1+?��6���

��&� �

��)���1����%����-��������8����"�*��%�����%�+��"���@�A&��

����� 2�������3���4�5��7�����6����B���3�6������7����%�+��%��������9��+�%������6�������������"�"�������9�:��#��(��%���-��)����

� ��(��$��� /0�;�����������������#��C%��%�($����$���(�C������������6���

��&� �

�1���������������"�*��%�������������������� 2�������3���4�5��7��������3

�6������7����%�+��%��������9��+�%��������������$��$���9�3����,3�����������"��8����9�363

��������������������������������9 �������*)�6������������"��8������������9�;����������#�����������"��%����()�

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

Page 138: BIT670 - Programming Display Functions

© SAP AG BIT670 5-17

� SAP AG 2003

Example Report: SBOOKR (3)

���%����������*) ���������1���������������� &��������� ����D$�������������

���������������*) ����7���7�/�����0<4���������� �������������&������ ������������&�"����� �����"������

�����&�/�����0������������&������� ���4��������*)�

���"$��%��������� ��������� 2�������3���4�5��7��������3 �������6������7�����4�5��4��&����������9��+�%����� ����������������������&����2��2��������9�3"$�%�����������*)3 ��������������������������&��� ���B����9�363 ���������������������������������������9����"$��%�������� �������6�����������&�� ���B������������9�:� ������� ����%������������1������������������������ &��������� ����D$������������� ������

��&&��

n In step 3, the data from the main memory is transferred to a work area in the program using the function module ARCHIVE_GET_TABLE. The tables are transferred to different internal tables.

Page 139: BIT670 - Programming Display Functions

© SAP AG BIT670 5-18

� SAP AG 2003

Example Report: SBOOKR (4)

�)��)����������@��������A ����

�C$���������������$�����1��3��2�����5������&�����'3������������� ����7���7�/�����0�

<����� E�3�����&�����3!�/�����0�������!E�3���,�&�����3!�/�����0����!E�3�����&�����3!�/�����0������!E�3 �&��������3!�/�����0�"�����!E�3�2���.�&���3!�/�����0��$��*��!E�3��&���&����3!�/�����0�����������

�,���

�����)�������"$��%�������������1���1�/���"$��%��������0� ������C����� E ��������)�

��&�����

�������%�����%�+��1������������ 2�������3���4�5�������� ���3

�6������7

���%�+��%������9 �+�%������

Page 140: BIT670 - Programming Display Functions

© SAP AG BIT670 5-19

� SAP AG 2003

The Logic Behind Reading Archiving Classes

l Archive_open_for_read

n Archive_get_next_object

w Archive_get_table / Archive_get_next_record

w Call up the relevant archiving classes, for example:

l TEXT_ARCHIVE_GET_TABLE (archiving class ‘TEXT’)

l WORKITEM_ARCHIVE_GET_TABLE

(archiving class ‘WORKITEM’)

l Archive_close_file

n ADK cannot directly retrieve data that was written to the archive via the archiving function module of an archiving class. That is why you cannot call up the function module ARHCIVE_GET_TABLE/ARCHIVE_GET_NEXT_RECORD for this type of data. You must call up the function module for read access of each archiving class.

Page 141: BIT670 - Programming Display Functions

© SAP AG BIT670 5-20

� SAP AG 2003

Where Are Archiving Classes Located in R/3?

l Transaction ACLA

l Naming convention for archiving function module (for write program)

n <archiving class>_archive_object

l Naming convention for read function module

n <archiving class>_ARCHIVE_GET_TABLE

n Older function modules can have the following names:

w <archiving class>_read_archive_object

w Identical with the read function module that also reads the database Example: „READ_TEXT“ for the archiving class Texts

n You can find out which function modules offer an archiving class by following these steps: � Specify the function group of the archiving class in transaction ACLA

� Call up transaction SE80 and enter the function group

� Determine the function modules of the function group

� Determine the read function module using the program documentation n If you know the name of the function module because of the naming convention, you can call up the

function module directly via the SAP Menu: Tools -> ABAP Workbench -> Development -> Call up function builder

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

Page 142: BIT670 - Programming Display Functions

© SAP AG BIT670 5-21

� SAP AG 2003

The Reading of Archiving Classes

l Determine which fields should be retrieved and displayed

l Determine which fields the class has archived

n The data archived via the classes must be logically assigned to the other archived tables

l Integrate the function modules of the archiving class into the report

n If required: You can create a check box field 'Read Archiving Classes Yes/No'

n Create the necessary data structures

n Read data via the read function module

l Determine, where the data should be displayed

n 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.

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

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

n 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.

Page 143: BIT670 - Programming Display Functions

© SAP AG BIT670 5-22

� SAP AG 2003

Example: Reading of Texts (1)

DATA: gt_vbka type table of vbka.„gt_... for further tables

DATA: gv_ar_handle TYPE sy-tabix.

CALL FUNCTION 'ARCHIVE_OPEN_FOR_READ'EXPORTINGobject = 'SD_VBKA'

IMPORTINGarchive_handle = gv_ar_handle

EXCEPTIONSno_files_available = 1not_authorized = 7.

IF sy-subrc <> 0.MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.STOP.

ENDIF.

Page 144: BIT670 - Programming Display Functions

© SAP AG BIT670 5-23

� SAP AG 2003

Example: Reading of Texts (2)

DO.* get business object data first (only for requested tables)

CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'EXPORTING

archive_handle = gv_ar_handleEXCEPTIONS

end_of_file = 1.IF sy-subrc <> 0.EXIT.

ENDIF.

CALL FUNCTION 'ARCHIVE_GET_TABLE'EXPORTING

archive_handle = gv_ar_handlerecord_structure = 'VBKA'all_records_of_object = 'X'

TABLEStable = gt_vbka

EXCEPTIONSend_of_object = 0.

„ for further tables: CALL FUNCTION 'ARCHIVE_GET_TABLE' ...

Page 145: BIT670 - Programming Display Functions

© SAP AG BIT670 5-24

� SAP AG 2003

Example: Reading of Texts (3)

PERFORM output_doc_info.

ENDDO.

CALL FUNCTION 'ARCHIVE_CLOSE_FILE'EXPORTINGarchive_handle = gv_ar_handle.

FORM output_doc_info.

DATA: lt_text_lines TYPE TABLE OF tline.FIELD-SYMBOLS: <lw_vbka> LIKE vbka,

„ for further tables <lw_...> LIKE ...<lw_vbfa> LIKE vbfa,<lw_text_line> TYPE tline.

Page 146: BIT670 - Programming Display Functions

© SAP AG BIT670 5-25

� SAP AG 2003

Example: Reading of Texts (4)

LOOP AT Gt_vbka ASSIGNING <lw_vbka>."there will be only one VBKA per data objectWRITE: /1 <lw_vbka>-vbeln, 15 <lw_vbka>-ktaar, 22 <lw_vbka>-erdat,

40 <lw_vbka>-ernam, 56 <lw_vbka>-aedat.ENDLOOP.

* Wirte data of further tables...

IF ausgtext = 'X'.

* select the text linesCALL FUNCTION 'TEXT_ARCHIVE_GET_TABLE'

EXPORTINGarchive_handle = gv_ar_handlerecord_structure = 'TLINE'

TABLESt_data = lt_text_lines.

Page 147: BIT670 - Programming Display Functions

© SAP AG BIT670 5-26

� SAP AG 2003

Example: Reading of Texts (5)

LOOP AT lt_text_lines ASSIGNING <lw_text_line>.WRITE: / <lw_text_line>-tdline. „ display the text on screen

ENDLOOP.

ENDIF.ENDFORM. "OUTPUT_DOC_INFO

Page 148: BIT670 - Programming Display Functions

© SAP AG BIT670 5-27

� SAP AG 2003

Exercise 'Read Contacts': Contacts Data Model

VBUKHead status

VBELN

VBKAContact

VBELN

VBPA2Partner

NASTMessages

VBFADoc. flow

VBUVIncomp. log

ZAVCentral Addr.

Admin.

TextsSAPScript

Address list:SADLSTWUSADLSTADMSADLSTIAD...

CHANGEDOCUChange docs.

VBPA

Page 149: BIT670 - Programming Display Functions

© SAP AG BIT670 5-28

� SAP AG 2003

Exercise 'Read Contacts': Contacts Table Structure

VBKA VBELN Sales document of a CAS contact ERDAT Date on which the record was inserted ERZET Data entry time ERNAM Name of the person who entered the object AEDAT Last changed date AEZET Last changed time AENAM Name of person who changed the object KTAAR Contact type for CAS contacts VBTYP Sales document category

VBPA VBELN Sales document number POSNR Items number of sales document PARVW Partner role KUNNR Customer number LIFNR Account number of vendor or creditor PERNR Personnel number PARNR Contact person number ADRNR Address ABLAD Unloading point LAND1 Country key ADRDA Address indicator VBFA VBELV Preceding sales document POSNV Preceding item of a sales document VBELN Subsequent sales document POSNN Subsequent item of a sales document VBTYP_N Subsequent sales document category RFMNG Referenced amount in base unit of measure MEINS Base unit of measure

Page 150: BIT670 - Programming Display Functions

© SAP AG BIT670 5-29

� SAP AG 2003

l Create sequential read programs for an archiving object

l Read the archiving classes of an archiving object using a read program

You are now able to:

Sequential Read Programs: Summary

Page 151: BIT670 - Programming Display Functions

© SAP AG BIT670 5-30

Exercises

Unit: Sequential Read Programs Topic: Report for archived flight tickets,

Read access without archiving classes

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

• Create a report that reads archived flight tickets without using archiving classes.

You have archived flight tickets and want to create a read report for this data.

1-1 Report to read archived flight tickets Copy the report ZSTICKET00_READ1 to your report ZSTICKETxx_READ1. XX is your group number.

1-2 Add the correct interfaces to call up the necessary function modules.

1-3 Process the records retrieved by the function module ARCHIVE_GET_TABLE so that only the selected STICKET records are displayed.

2-1 Test the report via transaction SE38

3-1 If the data was retrieved successfully, enter the report in table ARCH_REPOW via transaction SM30, as a read program that can be used by your archiving object. Test the report again via transaction SARA.

Page 152: BIT670 - Programming Display Functions

© SAP AG BIT670 5-31

Unit: Sequential Read Programs Topic: Report for contacts that belong to a customer

order, reading with archiving classes

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

• Create a report that reads archived customer contacts using archiving class TEXT

You have archived customer contacts and want to create a read report for this data.

1-1 Report to retrieve archived contacts with texts

Copy report Z00VBKAREADTEXT to your report ZxxVBKAREADTEXT.

1-2 Include a function in the report that allows you to read texts that were archived together with the contacts. The function should be included in the retrieval form routine after the last table has been retrieved. 1-2-1 Read the texts from table TLINE using the function module

'TEXT_ARCHIVE_GET_TABLE' and write them to internal table LT_TEXT_LINES.

1-2-2 Display the data: Loop over LT_TEXT_LINES display text (LT_TEXT_LINES -TDLLINE)

Page 153: BIT670 - Programming Display Functions

© SAP AG BIT670 5-32

Solutions

Unit: Sequential Read Programs Topic: Report for archived flight tickets,

Read access without archiving classes

1-1 Tools, ABAP Workbench, Development, ABAP Editor Copy ZSTICKET00_READ1 to ZSTICKETxx_READ1. XX is your group number.

1-2 to 1-3 See example solution program ZSTICKET_READ1.

2-1 Tools, ABAP Workbench, Development, ABAP Editor Enter ZSTICKETxx_READ1. XX is your group number. Execute program.

3-1 Call up transaction SM30. Enter table ARCH_REPOW. Choose Maintain. Choose New Entries. For object name, enter your archiving object. Leave Report type blank. For program name enter your read program. Save

Page 154: BIT670 - Programming Display Functions

© SAP AG BIT670 5-33

��������F����,������&:��

�����������

����������������

������������������������� ����������������!�

������������������������ ���������������!�

������������������"������ ����������"�����!�

���������������������,�&�"��������������

�����������������

&������������������������'���������� �������!�

�����������������*)������������'���������� ���������

&������+�%������������������������,���(�����-��

���&��'.������/�C�������0�����'�����������

������� ������������

�)����-�����1����%�+��"�����

������� 2�������3���4�5������� ������&3�

�����6������7�

�������8������������9�3F������,��3�

�����.������7�

���������%�+��%����������������9��+�%������

�����6���������

��������4������������9�:��

��� ��(��$����/0�;��

����.����7���&��(�*�1����'���3�3��2.�����(�*�1��

������������<��4��(�*�1+:��(�*�1+=��(�*�1+>��(�*�1+?��

�����6����

����&� ��

Page 155: BIT670 - Programming Display Functions

© SAP AG BIT670 5-34

��)���1����%����-��������8����"�*��%�����%�+��"���@�A�

��&���

��������� 2�������3���4�5��7�����6����B���3�

�������6������7�

�����������%�+��%����������������9��+�%������

�������6���������

������������"�"�������9�:�����������#��(��%���-��)�����

����� ��(��$����/0�;�����������������#��C%��%�($����$���(�C������������

�������6����

������&� ��

�1���������������"�*��%����������������

����������

��������� 2�������3���4�5��7��������3�

�������6������7�

�����������%�+��%����������������9��+�%������

�����������������$��$���9�3����,��3�

�������������������"��8����9�363�

�������������

������������������������������9������������*)�

�������6���������

������������"��8������������9�;����������#�����������"��%����()��

����%��������������*)����������1�����������������&����������

����D$��������������

�����������������������*)�����7���7�/�C�������0�

�������������������������<4�����������������������

�����������������������������&������������������

�����������������������������&�"�����������"������

�����������������������������&����,�&�����������

�����������&�/�C�������0���������������

������&������

������ ���4������������*)��

����&&���

�)��)����������@��������A�

�����

Page 156: BIT670 - Programming Display Functions

© SAP AG BIT670 5-35

�C$���������������$�����1��3��2�����5������&�����'3���1����������

��<������E@:;A�3�����&3!�@:;A�3�����&3!�@:;A�3 �&���3!�@:;A�3���,�&3!�

����������@:;A�3�2���.�&3!�@:;A�3���,���3��

������������������������7���7�/�C�������0��

����<������E@:;A�/�C�������0�������!���@:;A�/�C�������0������!�

������������@:;A�/�C�������0�"�����!���@:;A�/�C�������0����!�

������������@:;A�/�C�������0��$��*��!�@:;A�/�C�������0����,����

����&������

��� ��(��$��������������������

����<������E�3�%���������������������G�@;;:A��

����&� ��

�������%�����%�+��1��������

������� 2�������3���4�5�������� ���3�

�����6������7�

���������%�+��%������9��+�%������

Page 157: BIT670 - Programming Display Functions

© SAP AG BIT670 5-36

Unit: Customer-Specific Reporting Topic: Report for archived contacts,

Read access with archiving classes

1-1 Tools, ABAP Workbench, Development, ABAP Editor Copy Z00VBKAREADTEXT to ZxxVBKAREADTEXT. XX is your group number.

1-2 to 1-4 See example solution program ZSDVBKAREADTEXT

Page 158: BIT670 - Programming Display Functions

© SAP AG BIT670 5-37

�������H��+��������-����

I��������������������������������������������������������������������� �

I����%�+�������)�1��*�"������������+�����������%������������)����-��� �

I��������������������������������������������������������������������� �

I��������������������������������������������������������������������� �

����.��������$�1��-������4��,��6��

&�����1��+����'���������� �+��!�

������1��+�"���'���������� �+�"�!�

������1��+�)���'���������� �+�)���

&�����1+����%�������'����(�����-��

����� 2�������3���4�5������� ������&3�

���6������7�

�����8������������������ 9�3�&�5�,�3�

���.������7�

�������%�+��%�����������9�1+����%������

���6���������

������"������+���������9�:�

��������$�%��H��������9�J��

� ��(��$����/0�;��

��.����7���&��(�*�1����'���3�3��2.�����(�*�1��

����������<��4��(�*�1+:��(�*�1+=��(�*�1+>��(�*�1+?��

��������

��&� ��

&���

������� 2�������3���4�5��7�����6����B���3�

�����6������7�

���������%�+��%����������� 9�1+����%������

�����6���������

����������"�"�������� 9�:��

��� ��(��$����/0�;��

�����6����

����&� ��

Page 159: BIT670 - Programming Display Functions

© SAP AG BIT670 5-38

������� 2�������3���4�5��7��������3�

�����6������7�

���������%�+��%����������� 9�1+����%������

���������������$��$��������9�35�,�3�

�����������������"��8����9�363�

�����������

����������������������������9�1��+���

�����6���������

����������"��8������������9�;��

������� 2�������3���4�5��7��������3�

�����6������7�

���������%�+��%����������� 9�1+����%������

���������������$��$��������9�35� �3�

�����������������"��8����9�363�

�����������

����������������������������9�1��+�"��

�����6���������

����������"��8������������9�;��

������� 2�������3���4�5��7��������3�

�����6������7�

���������%�+��%����������� 9�1+����%������

���������������$��$��������9�35���3�

�����������������"��8����9�363�

�����������

����������������������������9�1��+�)��

�����6���������

����������"��8������������9�;��

����� ��.�$�)$�������"��

��&&���

����� 2�������3���4�5�������� ���3�

���6������7�

�������%�+��%������9�1+����%�������

Page 160: BIT670 - Programming Display Functions

© SAP AG BIT670 5-39

��������������������������������������������������������������������� �

������� ��.��2��2��&����� ������������������������������������������� �

��������������������������������������������������������������������� �

��������������������������������������������������������������������� �

��������������������������������������������������������������������� �

��.�$�)$�������"��

��&����������-���������'���������� ��������

�� ���&��'.������/�C�+��0��������,��+��!�

�����������������/�C�+�)�0��������,��+�)�!�

�����������������/�C�+�"�0����������,��+�"�!�

�����������������/�C���-������0��'����������

����������1��+�������7���7�/�C�+��0��

����#�%����C���������(����5�,��)���������8����

����<������E:�/�C�+��0�+����!�:K�/�C�+��0�����!�==�/�C�+��0������!�

�����������?;�/�C�+��0�����*!�KL�/�C�+��0��������

����&������

����������1��+�)������7���7�/�C�+�)�0��

����<������E==�/�C�+�)�0�)��+C!�?;�/�C�+�)�0�)����!�KL�/�C�+�)�0��������

����&������

����������1��+�"������7���7�/�C�+�"�0��

����<������EKL�/�C�+�"�0�+����!�J:�/�C�+�"�0�+��()����

����&������

��� ��$�1��-��9�363��

�����������%����-��������

��������� 2�������3��6�����4�5��7��������3�

�������6������7�

�����������%�+��%����������� 9�1+����%������

�����������������$��$���9�3�����3�

�������������

��������������������������������9������-���������

Page 161: BIT670 - Programming Display Functions

© SAP AG BIT670 5-40

������)��(��%����-�����������

�����������������-������������7���7�/�C���-������0��

������<������E�/�C���-������0���������

������&������

����&� ��

���,���=��

��& ��.���������������������#�2��2��&����� ��

Page 162: BIT670 - Programming Display Functions

© SAP AG BIT670 6-1

� SAP AG 2003

l The logic behind index-based read accesses

l Creating field catalogs in SAP AS

l Displaying optically archived original documents for a business object

Contents:

Index-Based Read Programs

Page 163: BIT670 - Programming Display Functions

© SAP AG BIT670 6-2

� SAP AG 2003

l Write index-based read programs

l Create field catalogs in SAP AS

l Display optically archived original documents

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

Index-Based Read Programs Course Objectives

Page 164: BIT670 - Programming Display Functions

© SAP AG BIT670 6-3

� SAP AG 2003

Index-Based Read Programs Overview

ŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁŁ

������������

� �� ������ ���������

���� ������������������

ŁŁŁŁŁŁŁŁ � ��� ���� ������������� �

ŁŁŁŁŁŁŁŁ ���������������������� �

ŁŁŁŁŁŁŁŁ ���� !"����������������� �

ŁŁŁŁŁŁŁŁ ������

Page 165: BIT670 - Programming Display Functions

© SAP AG BIT670 6-4

� SAP AG 2003

l You want to find out how you can read specific business objects from the archive with the help of an index.

Index-Based Read Programs Business Scenario

Page 166: BIT670 - Programming Display Functions

© SAP AG BIT670 6-5

� SAP AG 2003

SAP AS - The Archive Information System

l Tool to create indexes for archived data

l Facilitates the direct access to individual business objects directly from the application

l It is a cross-archiving-object tool

l Provides a "Data Browser" for archived data

l Transaction SARI

n Every application that provides archiving objects defines the required indexes in SAP AS. These indexes can be used in read programs for accessing specific data in the archive. As a result, the end user does not have to choose the archive files him or herself.

n Additionally, the SAP AS offers read programs that display data in a technical view (as opposed to a business view). It is also possible to create additional business views, if the application does not provide suitable programs for displaying archived data.

Page 167: BIT670 - Programming Display Functions

© SAP AG BIT670 6-6

� SAP AG 2003

n Function: Template (meta data) for an index

n Contains fields from the database tables of the archiving object, to be used during a search

n The relevant applications provide the necessary field catalogs.

SAP AS: Field Catalogs

n Field catalogs are a type of template for indexes that can be created later. You determine which field can or should be contained in an index.

n A field catalog is assigned to exactly one field catalog. An archiving object can have several field catalogs, if it is to support several search strategies (for example, searching for a business object via document number or account).

n Field catalogs should be created by the developers that are responsible for the archiving object.

n SAP AS provides standard field catalogs for SAP archiving objects. You should only create customer-specific field catalogs for SAP archiving objects as exceptions.

Page 168: BIT670 - Programming Display Functions

© SAP AG BIT670 6-7

� SAP AG 2003

SAP AS: Archive Information Structures

n An infostructure is based on exactly one field catalog

n The fields you select from a field catalog are incorporated into the archive information structure

n For every information structure there is a transparent database table, which is created when the infostructure is activated. This table is the relevant index for the archived data.

n The archive information structure contains an extract of the archived data

n Each archiving object can have several information structures.

n Fields that are marked as 'not selectable' are automatically integrated into the infostructure. Selectable fields of the field catalog are optional and can be integrated into the archive information structure if so desired.

n When the infostructure is activated, a read program is created to display the archived data (technical view).

Page 169: BIT670 - Programming Display Functions

© SAP AG BIT670 6-8

� SAP AG 2003

SAP AS Components

SAP R/3 Application(for standard

archiving objects)

Customer(for customer-specific

archiving objects)

sets up

n field catalog(s) per archiving object

incorporates fields in

an Archive Information Structurebased on a field catalog

Reporting-programArchive

informationstructure table

Page 170: BIT670 - Programming Display Functions

© SAP AG BIT670 6-9

� SAP AG 2003

SAP AS and Archiving Classes

l Archiving classes can be displayed in SAP AS as of Release 4.6A in the standard system

l The display of PP_ORDER in SAP AS is already possible as of Release 4.5B.

n To be able to use SAP AS for PP_ORDER see SAP Note 135784. For PM_ORDER, PM_QMEL, SM_QMEL, QM_QMEL see SAP Note 195425.

n For more information about archiving classes in SAP AS see the following SAP Notes: 183774, 181598, 156780

Page 171: BIT670 - Programming Display Functions

© SAP AG BIT670 6-10

� SAP AG 2003

Filling the Archive Information Structures

Deleteprogram

Deleteprogram

Option 1:Fill duringdelete run

Option 2:Fill triggered by explicit command via SAP AS

ArchiveArchivefilefile

R/3R/3DatabaseDatabase

ArchiveArchivefilefile

ArchiveArchivefilefile

ArchiveArchivefilefile

Archiveinformation

structure table

n Both variants are equally valid.

n Automatic fill during delete program. If an infostructure is activated it is filled automatically during the delete phase of an archiving session.

n 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.

n Explicit activation from SAP AS: It is possible for you to fill the archive information structure tables with data from existing archive files, at any time. To do this, go to SAP AS administration.

Page 172: BIT670 - Programming Display Functions

© SAP AG BIT670 6-11

� SAP AG 2003

SAP AS: Archive Explorer

List for archive information structure T_CO_ORDER

Order .......... to ..........Created on ...... to ......

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

Maximum No. of Hits 500

List for Archive Information Structure T_CO_ORDER

Order Created on Short text100000 12.10.1998 Vehicle Maintenance 97-5100001 12.10.1998 Repair 76A8/67 98-5100002 12.10.1998 Vehicle Maintenance 97-6100003 12.10.1998 TechEd ‚98‘....

Selection screen transaction SARI

Hit List

l For every information structure the system generates an analysis program.

l In this step an archive access is not necessary.

Analysisprogram

Archiveinformation

structure table

n 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.

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

n 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.

Page 173: BIT670 - Programming Display Functions

© SAP AG BIT670 6-12

� SAP AG 2003

Archive Explorer: Technical View

List for Archive Information Structure T_CO_ORDER

Order Created on Short text100000 12.10.1998 Maintenance100001 12.10.1998 Repair 76A8/67 98-5100002 12.10.1998 Maintenance100003 12.10.1998 TechEd ‚98‘....

Display data object from the archive: Table view

000143-001CO_ORDER

Table AUFK 1 Order master dataTable COBRA 1 Settlement rule orderTable COBRB 2 Distribution rules settlementTable COKA 1 CO-Object: Control data

List for Archive Information Structure T_CO_ORDER

Amount Object Currency 345,00Amount Currency 345,00

0Object No. OR0000000100095Fiscal Year 1998Class 94Version 0

Display data object

Choose a display function

Display master dataTechnical View X

List for Archive Information Structure T_CO_ORDER

CO Obj.No. PR Per Amount Currency

0001 200000005 1 10 1.200,00 DEM0001 200000006 1 10 345.00 DEM

n With a double-click, you can directly access the data object in the archive.

n The system uses the offset and the file name that are saved in the archive information structure, to access the object.

n If archived data is directly accessed, the system checks the authorization objects S_ARCHIVE and S_TABU_DIS. To create customer-specific authorization checks, see SAP Note 175901.

Page 174: BIT670 - Programming Display Functions

© SAP AG BIT670 6-13

� SAP AG 2003

Creating a Field Catalog (1)

Field Catalog Name Arch.Object File Offset

SAP_FI_DOC_001 FI Docs./doc.head FI_DOCUMNT D D

SAP_CO_ITEM_001 Based on Object CO_ITEM K K

SAP_MM_MATBEL01 Comb.MKPF/MSEG MM_MATBEL K D

n Transaction SARI -> Customizing -> Environment -> Field catalogs; or Transaction SARJ -> Environment -> Field catalogs

n SAP field catalogs begin with "SAP_", while the remaining namespace is reserved for customer-specific field catalogs.

n Entries "File" and "Offset" are used to determine whether the offset of a data object and the archive file must be a key field of the index table later.

n FI documents are unique because of their application key, because the fiscal year is part of this key. Therefore, the archive file and the offset do not have to be included in the key.

n Cost centers may have many line items that do not fit into a single data object within an archive file. In order for the index table to remain unique, the archive file and the offset are incorporated into the archive file.

n In other applications, keys can be reassigned after an archiving session. This is the case in SD, for example. 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.

Page 175: BIT670 - Programming Display Functions

© SAP AG BIT670 6-14

� SAP AG 2003

Creating a Field Catalog (2) MM_MATBEL

l Fields include all fields to be used for the search

Fld. No. Targ. Fld. Key Src. Table Src. Fld. oblig.

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.....

l The key fields from table MSEG must be assigned to fields in the table MKPF via the function 'further source fields', when the field catalog is being created.

n 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.

n 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'.

Page 176: BIT670 - Programming Display Functions

© SAP AG BIT670 6-15

� SAP AG 2003

Creating a Field Catalog (3) MM_MATBEL

l Starting point: The desired search criterion is material number.

l Possible fields for the field catalog

Fld.No. Targ.Fld. Key Src.Table Src.Fld. oblig.

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

l The reference to 'other source fields' is omitted.

Page 177: BIT670 - Programming Display Functions

© SAP AG BIT670 6-16

� SAP AG 2003

Index-Based Read Programs (1)

Steps for creating an index-based read program with the help of SAP AS:

n Determine or create a relevant field catalog

n Determine or create the corresponding infostructure.

n Create the read program, or extend a program that only reads from the database, to also read from the archive.

n New field catalogs should only be created for customer-specific archiving objects.

n To be able to access archived data, make sure the relevant infostructures are active and filled.

Page 178: BIT670 - Programming Display Functions

© SAP AG BIT670 6-17

� SAP AG 2003

Index-Based Read Programs (2)

l In the menu of the selection screen, offer the option "Extras -> Data Source...".

l If the user chooses this menu option, the function module AS_DATASOURCE_SELECT will be called up for the selection of the data source.

l During INITIALIZATION the Data Source selection screen can be made available with the help of the function module AS_DATASOURCE_INIT.

n When you extend programs that previously only read from the database, we recommend the following: Modifying the program so that it can read from the archive should not create any changes for the user. The default for data source should therefore only provide the option of searching in the database. Only if the user explicitly marks the check box "Archive" will the program read from the archive.

n SAP Note 511920 explains the availability of function group AS_DATASOURCE and table ASDATASRC1.

Page 179: BIT670 - Programming Display Functions

© SAP AG BIT670 6-18

� SAP AG 2003

AS_DATASOURCE_SELECT (1)

l Interface parameter import

n I_DB_AND_ARC

n I_NO_SOURCE_SELECT

n I_INFOSYS_POSSIBLE

n I_DOCUMENTATION

n I_REPORT

n I_REPORTTYPE

n IT_OBJECTS

n I_DB_AND_ARC: If the report does not support the analysis of data from both the database and archive, then this parameter must be set to SPACE. As a result, the options Database and Archive will appear as radio buttons and not as check boxes. The default setting here is I_DB_AND_ARC = X, that is both options can be selected at the same time.

n I_NO_SOURCE_SELECT: For reports that only read archived data, the option database is not valid. I_NO_SOURCE_SELECT = X makes sure that the user does not see the options Database and Archive. This only makes sense if C_USE_ARCHIVE = X has been set; if not the reaction of the function module is not defined.

n I_INFOSYS_POSSIBLE: If the report does not support accesses via SAP AS, this option can be switched off with I_INFOSYS_POSSIBLE = SPACE. Then the user will only have the options of manually selecting the archive files and the archiving object.

n I_DOCUMENTATION: The data source selection dialog box has an I push button to display the standard documentation. Via this parameter you can replace this documentation with your own document of the type "Dialogue Text".

n IT_OBJECTS, I_REPORT, I_REPORTTYPE: See slide for function module AS_DATASOURCE_INT.

Page 180: BIT670 - Programming Display Functions

© SAP AG BIT670 6-19

� SAP AG 2003

AS_DATASOURCE_SELECT (2)

l Interface parameter changing

n C_USE_DATABASE

n C_USE_ARCHIVE

n C_USE_INFOSYS

n C_ARCHOBJ

n CT_ARCH_SEL

n C_USE_DATABASE: If this parameter is set, then the report is expected to search for data (also) in the database. Otherwise no data is to be retrieved from the database.

n C_USE_ARCHIVE: If this parameter is set, then the report is expected to search for data (also) in the archive. Otherwise no data is to be retrieved from the archive. If C_USE_ARCHIVE is empty (space, initial), then all other parameters for accessing the archive (C_USE_INFOSYS, C_ARCHOBJ, CT_ARCH_SEL) must be ignored. The function module makes sure that at least one of the parameters C_USE_DATABASE or C_USE_ARCHIVE is set (= ’X’).

n C_USE_INFOSYS: If this parameter is set, then the report is expected to read data from the archive and find it without the need for any other user action (no manual selection of archive files, etc.). If the report is meant for several archiving objects, then the archiving object is also supposed to be selected automatically. If C_USE_INFOSYS is not set (but C_USE_ARCHIVE is set), then the archive files to be retrieved are entered by the user. In this case the archive files are delivered in CT_ARCH_SEL. The report is then expected to take the data from these files, usually through sequential read accesses. If C_USE_INFOSYS is set, then C_ARCHOBJ and CT_ARCH_SEL must be ignored. C_USE_INFOSYS should only be considered if C_USE_ARCHIVE is set.

Page 181: BIT670 - Programming Display Functions

© SAP AG BIT670 6-20

� SAP AG 2003

AS_DATASOURCE_SELECT (3)

l Interface parameter changing

n C_USE_DATABASE

n C_USE_ARCHIVE

n C_USE_INFOSYS

n C_ARCHOBJ

n CT_ARCH_SEL

l ASDATASOURCETEST is an example program for the function module AS_DATASOURCE_SELECT.Available as of BASIS 640.

n C_ARCHOBJ: This parameter contains the archiving object and is only valid if C_USE_ARCHIVE = X and C_USE_INFOSYS = SPACE. If not, the program is not supposed to read from the archive or the archiving object is supposed to be determined automatically. The data source selection dialogue box ensures that C_ARCHOBJ is one of the objects from IT_OBJECTS. Therefore, this parameter is only significant for those programs that can analyze data from different archiving objects.

n CT_ARCH_SEL: This parameter contains the archive files selected by the user and is only valid if C_USE_ARCHIVE = X and C_USE_INFOSYS = SPACE. If not, the program is not supposed to read from the archive or the archive files are supposed to be determined automatically. The data source selection dialogue box ensures that the archive files match the archiving object C_ARCHOBJ. The data selection function, however, does not ensure that the program delivers only data with a specific status (e.g "deletion completed"). Therefore, it is possible that the same data is displayed from the database and from the archive. This could be viewed as a user error, but a better solution is if the program recognizes this and mixes up the data accordingly. Even if technically speaking this is a ranges table, this table only contains single values for archive files (it is only allowed to hold this type of data!). This means that all entries have the following format: SIGN = I, OPTION = EQ, LOW = <Archive File>, HIGH = SPACE. An empty table means "no files selected" (not "all files selected", as is common in a ranges table). This table can be transferred directly to the function module ARCHIVE_OPEN_FOR_READ.

Page 182: BIT670 - Programming Display Functions

© SAP AG BIT670 6-21

� SAP AG 2003

AS_DATASOURCE_INIT

� SAP AG 1999

l Is used for the initialization of the parameters of the function module AS_DATASOURCE_SELECT (Data Source Selection Screen).n Reads the customizing table ASDATASRC1.n Checks if the read program is called from transaction SARA.

l Interface parameter importn I_REPORTn I_REPORTTYPEn IT_OBJECTS

l Interface parameter exportn E_USE_DATABASEn E_USE_ARCHIVEn E_USE_INFOSYSn E_ARCHOBJn ET_ARCH_SEL

n ASDATASRC1: Real customizing; activates automatic access to the archive. An entry in this table with USE_INFSYS=X means, that the corresponding program (REPORT, REPORTTYPE) must access the archive automatically, without the need for further user action, that is without the user making any entries in the data source selection dialogue box. (An entry with USE_INFSYS = SPACE is equal to no entry). Compare: ARCH_RPRG: Read programs for archiving object, not real customizing. ARCH_REPOW: Real customizing, "Relevant Read Programs" and ReportWriter reports and transactions.

n I_REPORT, I_REPORTTYPE: The function modules for the data source selection dialogue make customizing easy via the name of the report or the transaction, for which the dialogue was called up. For programs that take part in this customizing the name of the report or the name of the transaction must be transferred in I_REPORT, when AS_DATASOURCE_INIT and AS_DATASOURCE_SELECT are called. I_REPORTTYPE is used to transfer information about the function type: SPACE for normal (SA38-) reports, ‚TR’ for transactions, ‚RW’ for Report Writer reports.

n IT_OBJECTS: Archiving objects that the report can process and for which an archive selection is relevant. The data source selection dialogue box does not allow you to enter a different object. If you leave off the parameter IT_OBJECTS (or it is empty) it means that this report is suitable for all archiving objects.

Page 183: BIT670 - Programming Display Functions

© SAP AG BIT670 6-22

� SAP AG 2003

Index-Based Read Programs (3)

l AT SELECTION SCREEN:

n Optional when data source is archive via SAP AS: Finds the field catalogs that are used for searching in the archive. Issues a warning, when the determined field catalogs do not have any active infostructures.

l START AT SELECTION:

n When data source is the database: As usual, reads data from the database.

n When data source is archive, via SAP AS: If the above-mentioned check does not occur at the time of AT SELECTION SCREEN, then it must take place now. An error message or a type I message is issued when the determined field catalogs do not have any active infostructures.

n The name of the field catalog whose infostructures are used for accesses to the archive, can be hard coded into the program. This ensures that the program uses the correct archiving index.

n If the data source was only "Archive" and no infostructures were available for the above-named field catalogs, the program will be terminated.

Page 184: BIT670 - Programming Display Functions

© SAP AG BIT670 6-23

� SAP AG 2003

Index-Based Read Programs (4)

l START AT SELECTION:

n When data source is archive, via SAP AS: reading from the archive. The essential function modules here are:AS_API_READ, ARCHIVE_READ_OBJECT.

n When the data source is archive with manual file selection:Reading is carried out as in sequential read programs that read archive files, which were selected by the user.

n Data that was read from the database and from the archive is brought together, organized, etc. If necessary archived data is marked by a special indicator. Determine if duplicate records should be displayed.

n Display results.

� SAP AG 1999

Page 185: BIT670 - Programming Display Functions

© SAP AG BIT670 6-24

� SAP AG 2003

AS_API_READ

l Interface parameter import

n I_FIELDCAT

n I_SELECTIONS

n I_OBLIGATORY_FIELDS

l Interface parameter export

n E_RESULT

n I_FIELDCAT: Field catalog for which data is to be read. The function module looks for active infostructures for the specified field catalog.

n I_SELECTIONS: Selections used for searching. Here you have three options: a) Selections (in the format of type RSDS_FRANGE_T, that is as a table of field names with the corresponding selection options), b) A structure (Structure). Selection takes place using all non-initial fields in the structure that also appear in the field catalog (including ARCHIVEKEY and ARCHIVEOFS), c) A table with the same line structure as in 2. A selection takes place per line and the result brought together.

n All fields transferred in I_SELECTIONS have to be contained in the field catalog I_FIELDCAT. The field of a field catalog can be determined using the function module AS_API_INFOSTRUC_FIND.

n I_OBLIGATORY_FIELDS: Table of fields that must appear in the infostructure, for the selection to take place (if not you will have an exception). No field is obligatory.

n E_RESULT: Result of the selection. Here you enter an internal table. The structure of the table must contain at least one field of the field catalog or the name of the archive file. If the structure contains the offset, the name of the archive file has to also be included. The name of the archive file must appear in the field ARCHIVEKEY, the offset in ARCHIVEOFS.

Page 186: BIT670 - Programming Display Functions

© SAP AG BIT670 6-25

� SAP AG 2003

ARCHIVE_READ_OBJECT

l Interface parameter import

n OBJECT

n ARCHIVEKEY

n OFFSET

l Interface parameter export

n ARCHIVE_HANDLE

n ARCHIVE_READ_OBJECT includes ARCHIVE_OPEN_FOR_READ and ARCHIVE_GET_NEXT_OBJECT. The function module accesses the desired data object (parameter OFFSET) in the archive file (parameter ARCHIVEKEY) and delivers a handle for further processing. If the archive file was stored via ArchiveLink, it is also possible to read the data object via this function module. The different processing technique is treated within this function module.

n After the data object has been read with ARCHIVE_READ_OBJECT you can access the data via the handle using function module ARCHIVE_GET_TABLE or ARCHIVE_GET_NEXT_RECORD.

n Before calling the function module ARCHIVE_READ_OBJECT again, ARCHIVE_CLOSE_FILE must be called for the returned handle. Therefore, the function module is meant for interactive reporting - that is, to read a specific business object. It is not meant for sequential read programs!

n You can obtain the name of the archive file and the offset of a data object via the function module AS_API_READ, for example.

Page 187: BIT670 - Programming Display Functions

© SAP AG BIT670 6-26

� SAP AG 2003

Index-Based Read Programs (5)

DeclarationInternal tables (itabA, itabB, itabC)

Get archive key and offsetAS_API_READ

export: i_fieldcat, i_selections, i_obligatory_fieldsimport: e_result

Read requested tables of the data objectARCHIVE_GET_TABLE or ARCHIVE_GET_NEXT_RECORD

If necessary, check records against furtherselection criteriaCollect records

Close archive filesARCHIVE_CLOSE_FILE

export: archive_handle

If necessary read from database

Display records

Loop over alldata objects retrieved

by AS_API_READ

n If necessary, you must also read an archiving class

n Another example is the transaction KE5Z, which was extended to also access archived data, as of Release 4.6B. Transaction KE5Z does not use the function modules of the function group AS_DATASOURCE, which previously did not exist, but the predecessors of these function modules from the function group KARL. It also uses the previous table ASACCESS01 instead of table ASDATASRC1. That is why it is a good example for releases prior to R/3 Enterprise Core 4.7.

Page 188: BIT670 - Programming Display Functions

© SAP AG BIT670 6-27

� SAP AG 2003

Archive Explorer: Business View (1)

List for Archive Information Structure T_CO_ORDER

Order Created on Short text100000 12.10.1998 Maintenance100001 12.10.1998 Repair 76A8/67 98-5100002 12.10.1998 Maintenance100003 12.10.1998 TechEd ‚98‘....

Display internal order: Master data xxx

Order 100003 Order type PFE1Short text TechED ‚98‘

System status Rel DLT SETCStatus number 0

Control dataCurrency DEMOrder category 1

Double click on data object,choose the view you want:

Technical View<Name of View, e.g. Master Data>

n To execute the business view for a data object in an archive file, use a function module that is entered in table AIN_STR5.

Page 189: BIT670 - Programming Display Functions

© SAP AG BIT670 6-28

� SAP AG 2003

Archive Explorer: Business View (2)

l Creating a function module in the customer namespace

n Create function group <zxxxxx>

n Create function module <zyyyyy> in the function group

n Interface parameter import:

u I_ARCHIVEKEY

u I_OFFSET

n Read the data object specified in the interface via the functionmodule; display the requested information in a business view.

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

n For for information about how to create a business view see the appendix.

Page 190: BIT670 - Programming Display Functions

© SAP AG BIT670 6-29

� SAP AG 2003

Archive Explorer: Business View (3)

l Creating a new view option to be offered in the dialog box

n Create a new entry in table AIN_STR5

w OBJECT: The archiving object for which this view will be offered

w FUNCTION: Name of the function module that will offer this view

w LINE: Specific order to appear in the dialog box

w TEXT: Text that is to appear in the dialog box - name of the business view

n You can find a detailed description for creating an entry in SAP Note 192976.

n As soon as a table entry exists for an archiving object, a dialogue box with the name of the business view will appear if you double click on the object. However, the dialogue box no longer offers the technical view that previously was called up directly without the dialogue box, since it was the only available view. To provide the user with the technical view option, you must create an entry in the table with SPACE as the FUNCTION.

Page 191: BIT670 - Programming Display Functions

© SAP AG BIT670 6-30

� SAP AG 2003

Display Archived Originals of R/3 Document (1)

l Calling function module ARCHIV_DISPLAY_META

n call function 'ARCHIV_DISPLAY_META' exporting

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

exceptions others = 1.

l The function module displays the optically archived original. If several documents have been optically archived for an R/3 document, the system will display a hit list, from which the user can choose the desired object.

n This function module offers the desired functionality.

n When the function module is called it must receive the name of the BOR object to which the original document being searched for belongs, and the key of the BOR object.

Page 192: BIT670 - Programming Display Functions

© SAP AG BIT670 6-31

� SAP AG 2003

Display Archived Originals of R/3 Document (2)

l Determine to which business object type the original document has been assigned.

l Create the key variable in the program

l Compose the key variable so that it corresponds to the key of the business object type.You can find the key definitions in the business object repository (BOR).

l Call up the function moduleARCHIV_DISPLAY_META

n Export: Name of the business object typeKey variable

n Result: The archived original or a hit list with several archived originals is displayed.

n You can find the Business Object Repository (BOR) in transaction SWO1.

n The document type identifies the original document (transaction OAC3).

n Examples: FIIINVPREL Incoming invoice for parking FIIINVOICE Incoming invoice without verification SDOORDER Order confirmation ......

n SAP ArchiveLink assigns optically archived original documents to a document type and a business object type (an n:1 assignment).

n Archived originals are always related to an R/3 business object. The key of the corresponding business object is uniquely identified through its link with the business object type. This is necessary for search strategies.

Page 193: BIT670 - Programming Display Functions

© SAP AG BIT670 6-32

� SAP AG 2003

Display Archived Originals of R/3 Document (3)

l Determine to which business object type in SAP Archive Link the document has been assigned.

n Analyze how the archived document has been assigned to the object type:

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

w Examples:Doc. Type Description Object TypeFIIINVOICE incoming invoice BKPFFIIINVPREL invoice parking BKPFSDOORDER Order confirm. VBAKMMOORDER Order EKKO

n If the object type cannot be found via the ArchiveLink linkages, you can set a breakpoint at SWU_OBJECT_PUBLISH in the display transaction, and in this way debug, which object type is transferred in OBJTYPE.

n It is also possible to analyze the SAP ArchiveLink linkage tables. The standard tables used are TOA01, TOA02 and TOA03. These tables contain the R/3 key of the object, along with the object type and the document type.

Page 194: BIT670 - Programming Display Functions

© SAP AG BIT670 6-33

� SAP AG 2003

Display Archived Originals of R/3 Document (4)

l Creating a key definition:<variable with key of the business document>

n data: <variable name> like sapb-sapobjid. "key to be passed"

n data: begin of objectid, "Variable structured....... according to business

object type keyend of objectid.

l Construct key according to business object

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

Page 195: BIT670 - Programming Display Functions

© SAP AG BIT670 6-34

� SAP AG 2003

Example: Display Archived Original (1)

function fi_documnt_display_data_originale.*"----------------------------------------------------------------------*"*"Local interface:*" IMPORTING*" REFERENCE(I_ARCHIVEKEY) TYPE ADMI_FILES-ARCHIV_KEY*" REFERENCE(I_OFFSET) TYPE ARCH_IDX-OFFSET*"----------------------------------------------------------------------..........

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‘..........

Page 196: BIT670 - Programming Display Functions

© SAP AG BIT670 6-35

� SAP AG 2003

Example: Display Archived Original (2)

call function 'ARCHIVE_GET_TABLE‘exporting archive_handle = ...

record_structure = 'BKPF‚tables

table = lt_bkpf.“ internal table LT_BKPF includes only one record due to the archiving write program........

* Daten ausgeben

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

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

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

..........

Page 197: BIT670 - Programming Display Functions

© SAP AG BIT670 6-36

� SAP AG 2003

Example: Display Archived Original (3)

write: / sy-vline, 2 lt_bkpf-budat,

16 sy-vline, 17 lt_bkpf-hwaer,

..........* Display archived original for the document* Compose key

move lt_bkpf-bukrs to objectid-oidbukrs.move lt_bkpf-belnr to objectid-oidbelnr.move lt_bkpf-belnr to objectid-oidbelnr.object_id = objectid.

* Call function module ArchiveLink call function 'ARCHIV_DISPLAY_META'

exportingsap_object = 'BKPF' object_id = object_id

exceptions

others = 1.

Page 198: BIT670 - Programming Display Functions

© SAP AG BIT670 6-37

� SAP AG 2003

l Integrate a business view for an archiving object into SAP AS

l Integrate the display of an archived R/3 document original into SAP AS

You are now able to:

Index-Based Read Programs: Summary

Page 199: BIT670 - Programming Display Functions

© SAP AG BIT670 6-38

Exercises

Unit: Index-Based Read Programs Topic: Creating a field catalog for an infostructure and

for an index-based read program

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

• Create a field catalog and the corresponding infostructure

• Create a read program for archived data, based on SAP AS indexes

You have archived data and one of your departments wants to rapidly access its archived data.

1-1 SAP AS: Creating field catalogs

1-1-1 Create the field catalog ZBCSTICKETxx_001 for your archiving object in the archive information system.

Decide whether or not the file and the offset have to be in the key of the index table.

The field catalog must contain the fields CARRID, CONNID, and BOOKID of the table STICKET.

Decide, which fields should be key fields.

Decide, which fields should be selectable.

Decide whether additional source fields are necessary.

Save the field catalog.

1-2 SAP AS: Creating infostructures

1-2-1 Create the infostructure ZBCSTICKETxx_001 for your field catalog, in the archive information system.

The infostructure must contain all the fields of the field catalog.

Save the infostructure.

Activate the archive information structure.

Page 200: BIT670 - Programming Display Functions

© SAP AG BIT670 6-39

1-3 Fill the infostructure with the data of your archiving session.

1-4 Display your data using the Archive Explorer.

1-5 Creating an index-based read program for your archiving object.

1-5-1 Copy the report ZSTICKET00_READ2 to your report ZSTICKETxx_READ2. xx is your group number. When you copy, select ‘Interfaces’, so that these are also copied.

1-5-2 The program should offer the same selection options as your sequential read program.

1-5-3 Add the correct interfaces to call up the necessary function modules. Pay special attention to the following points:

’AS_DATASOURCE_SELECT': for data source the user should be able to choose between ‘Database’, ‘Archive’ and ‘Archive Information System’.

Before the call of this function module fill the table LT_ARCH_OBJ with your archiving object.

'RS_SET_SELSCREEN_STATUS': At the interface of this function module, transfer the name of your program.

1-5-4 The data source ‘Archive’ should appear as the default setting when the program is called. To achieve this, make the appropriate entry in table ASDATASRC1.

1-5-5 Enter your report in table ARCH_REPOW via transaction SM30, as a read program that can be used by your archiving object.

1-5-6 Test the report via transaction SE38

Page 201: BIT670 - Programming Display Functions

© SAP AG BIT670 6-40

Unit: Index-Based Read Programs Topic: Displaying the archived original (a letter) in SAP AS

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

• Display the optically archived original for a purchase requisition via SAP AS

The relevant department does not only want to see the purchase requisition, but also the corresponding original documents that were optically archived.

1-1 Call up the function module used in 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, which corresponds to the key of the business object. Create a second variable, object_id, which links to sapb-sapobjid.

4-1 Give your business object key variable the field BANFN from table EBAN, and assign the variable to the object_id variables.

5-1 At the end of your list output call up the function module 'ARCHIV_DISPLAY_META' Export parameter:

sap_object = <business object type found> object_id = Variable <object_id>

Page 202: BIT670 - Programming Display Functions

© SAP AG BIT670 6-41

Solutions

Unit: Index-Based Read Programs Topic: Creating a field catalog for an infostructure and

for an index-based read program

1-1 SAP AS: Creating field catalogs

1-1-1 Create the field catalog ZBCSTICKETxx_001 for your archiving object in the archive information system.

Transaction SARJ -> Environment -> Field catalogs

New entries

Enter ZBCSTICKETxx_001 as a field catalog, enter the name, enter the archiving object. Enter ‘K’ in the column ‘File’ and ‘D’ in the column ‘offset’.

Push enter, select new line, choose field selection from the tree on the left

Choose new entries

Enter the desired fields of the field catalog in the column ‘Target Field’ and ‘Reference Field’. For field number enter 10, 20, 30, 40, for example. Enter STICKET as source table. All fields must be key fields. All fields must be selectable.

Additional source fields are not necessary.

Save field catalog.

1-2 SAP AS: Creating infostructures

1-2-1 Create the infostructure ZBCSTICKETxx_001 for your field catalog, in the archive information system.

Transaction SARI -> Customizing, or directly via transaction SARJ

Enter a name for the archive information structure

F5 to create

Description of the infostructure, enter archiving object and field catalog

F5 to create

Incorporate all selectable fields

Save infostructure

Exit screen. In the menu, choose ‘activate’

Page 203: BIT670 - Programming Display Functions

© SAP AG BIT670 6-42

1-3 Fill the infostructure with the data of your archiving session.

Transaction SARI -> Status

Enter archiving object

Choose status per infostructure or per archive.

1-4 Display your data using the Archive Explorer.

Transaction SARI -> Archive Explorer, or directly via transaction SARE

1-5 Create an index-based read program for your archiving object.

1-5-1 Tools, ABAP Workbench, Development, ABAP Editor Copy ZSTICKET00_READ2 to ZSTICKETxx_READ1. XX is your group number.

1-5-2 to 1-5-3 See example solution program ZSTICKET_READ2.

1-5-4 Call up transaction SE16. Enter table ASDATASRC1, choose F5 Leave report type empty; for report, enter your read program; enter ‘X’ in the field ‘USE_INFSYS’ Save your entry

1-5-5 Call up transaction SM30. Enter table ARCH_REPOW. Choose Maintain. Choose New Entries. For object name, enter your archiving object. Leave Report type blank. For program name enter your read program. Save

Page 204: BIT670 - Programming Display Functions

© SAP AG BIT670 6-43

����������������� ����

�������������

������������������

� ����������!�"�#��$������

����������%������"�����&�������'����"����!�

�������������������������&�������'���������!�

������������������$��"���&�������'���$��"��!�

������������������ �����$�������'���(��'����

)$����"�"���*����+�+*+��

� � ,�������+���"��(���������������������������& -���./.�%������ �!�

������������+���"�"��������������������������������������%������ �!�

������������+�"���(0�����������"��1��(0��(0�������������%������ �!�

������������+���"�"����������������������������& -���./.�%������ ���

����������%����$�����&���"�#��$�����"��1�2�'�3���������%������ ���

���"�"�����"�"�����

�3+�����3��������������� ����&������!�

������� �4%��&��3�$����"����$$���!�

���������"��1�2�'�3������"�'�3!�

���������"��1�2��$�������"�#���$$��!�

��������%���&��3�$����"����$$���!�

��������3���$����"����$$����������3�$����"����$$�����-���5!�

������� �4%��&��3�$���!�

���������"��1�2�'�3������"�'�3!�

��������%���&��3�$���!�

��������3���$����������3�$�����-���5��

� � �����"��1��(0��������� ����&�"��1��(0��(0����6�7�7� �����%���

Page 205: BIT670 - Programming Display Functions

© SAP AG BIT670 6-44

%� �� ��%��

��������"�"���*����+�+*+�

�� ���&-%��%�. ��� � ��-���%�.�

�����/����%4�

����������+����������8�.��������� ��.�

����������+����3+����8��+"���

����,����%4�

��������*����"�"("���8�+���"��(�

��������*���"��1�2���8�+���"�"��

��������*�����$��3���8�+���"�"��

��������"��1�(0������8�+�"���(0�

���������"��1��������8���$����9:��

��������"�*��

��� � ������;��*���<������3�*��##��-���5�6�7�7� �����%���

�� ���&-%��%�.��������������%��� �-�.�

�����/����%4�

������+���"�*���8�.�������%.�

������+�+��<�"#�8�.��������� ��.�

����� ����

������+��;��*���8�����;��*���<��

Page 206: BIT670 - Programming Display Functions

© SAP AG BIT670 6-45

��������%�����%��

��&��3�*��##�8�.-��.�

����������3�*��##�8�.�%�.� %��+���"�"��8�./.�

������ %��+���"�"����%� �� %����$����9:���%� ���

�����������"�"���*����+�+*+��$���=*����������$��"�"���*�������

�����������#+������(*���1����+�����1�*���(���;��*����

����&����"��1��(09:���%� ���

���������"��1��(0�8�.� �����.�� ���%�����"��1��(0��

�����%�&��

���� ���&-%��%�. ��� � ��-��������.�

�������/����%4�

�����������(�"���"���������8�./.�

������������$��3��+����(���8�./.�

������������+����������8�.��������� ��.�

������������+����3+����8��+"���

������������(0�������������8����"��1��(09:�

������7 %4%4�

����������*����"�"("�������8�+���"��(�

����������*���"��1�2�������8�+���"�"��

����������*�����$��3�������8�+���"�"��

�����������"��1������������8���$����9:��

���%�&��

�� ����&�������%��

�����&��,��"�"�<����

Page 207: BIT670 - Programming Display Functions

© SAP AG BIT670 6-46

�>�����������������������������������������������������������������������

�>������&��#���"�"���"��

�>�����������������������������������������������������������������������

&��,��"�"�<����

��� � ����������������������������������� ����&��������

��&������, �����?�@������A��������������������

��&�+���"��(�8�./.��

������"��$��#�� �

������������&��,�������%���� ������������

������67�����"�����%����"�����

�������� %��(��'�������%���(��'���

�������� %��$��"���%���$��"���

�������� %�������������%�����������

���%�&��

��&�+���"�"��8�./.��

������"��$��#�"��1�2��

�������&��,�"��1�2����"��7 %4%4���������9:��

���%�&��

��@�*���(��(���������*�����<��.��-��� �B��������� �.����<������������

��6�����CDE5F�. ���.!�DE5F�.�%%�.!�DE5F�.&�� ��.!�DE5F�. ����.!�

�����������DE5F�.-���,�.!�DE5F�.����.!�DE5F�.�� �.��

������� ����������� ��4%%4�?�@������A��

����6�����CDE5F�?�@������A��"����!���DE5F�?�@������A�������!�

������������DE5F�?�@������A�$��"��!���DE5F�?�@������A�(��'��!�

������������DE5F�?�@������A��*���#��!�DE5F�?�@������A����'��!�

������������DE5F�?�@�����'��A�+�"����

���%�������

��&��3��*(�����%���%� ���

����6�����C�.�1��������������������"���"�3��"�".D55EF��

���%�&��

�%�&��,���������������������)��"�"���"��

Page 208: BIT670 - Programming Display Functions

© SAP AG BIT670 6-47

�>�����������������������������������������������������������������������

������"��"��1�2��$������

�������������������������������������������������������������������������

��?���&������������������<�����������������$��#��1��"��1�2��

�������������������������������������������������������������������������

&��,�"��1�2����"��7 %4%4�$��������������3����������

��� � ����������������������������������������$�"�<���!�

�����������$�������"��(3��(0��������������3���$����"����$$���!�

�����������$�������=*����"����"�����������3���$���!�

�����������$�����"����$$����$��#�"��������3���$����"����$$�����

��� � ���2�1"��������������������������3��"(�;!�

���������2��(0��$$����������������������"��1���;��$$�����

��&������, �����?�@�$�����$�A������������3�$����"����$$���!�

�����������������?�@�$���A���������������"��1�2�'�3��

��+��+"���$�����"���<�$��#�"��1�2��

�����&��,�"��1�2����"��+��+"���

����������������������������7 %4%4����$�������"��(3��(0���9:�

����������������������������������������$�������=*����"����"�9:�

��������������������������������������������������9:�

����������������������������������������$�����"����$$����$��#�"�9:��

����"����=*����"��

����������$�������=*����"����"�� ��"��1�2�'�3��

������� �����$�������=*����"����"�� ��4%%4�?�@�$���A��

���� ���&-%��%�. �7B�����%�&����� �.�

�������/����%4�

��������"��1�2���"#����8�?�@�$���A�"��1�2�'�3�

���������(0������������8�.� �����.�

������,����%4�

��������"��1�2��1"�����8��2�1"������

Page 209: BIT670 - Programming Display Functions

© SAP AG BIT670 6-48

��������

������ ���&-%��%�. �7B��4���%�/��� G��.�

���������/����%4�

����������"��1�2��1"���������������8��2�1"�����

��������,����%4�

�����������(0�����$$�����8��2��(0��$$����

���������/����%��

���������������$�$�������� 8�E��

������&�%����3��*(�����%� ���

���������/���

�������%�&��

������&�%������$�����"����$$����$��#�"�9:���%� ���

��������� �� ��@"��*�����A��1��'��$��1���������"������*�����"��1����"�"�

���������� ��� ������$�����"����$$����$��#�"���� %�����%4�%��&�����

�������������6�7�����"��1�2�'�3�8�?�@�$���A�"��1�2�'�3�

����������������������"��1�2��$��8��2��(0��$$����

������������� % ����� �7��

��������7����3��*(�����%� ���

�������%�&��

����������"���"�"��(0����@��1��������%��

���������&��,��"�"��(0������"��-�%4��2�1"�����

��������������������������������������������������9:�

����������������������������7 %4%4�$�������9:��

�����%�����

���%�������

����"�����3��1������2"����"�"��(0�����

����������$�������"��(3��(0����� ��"��1�2�'�3�"��1�2��$���

������� �����$�������"��(3��(0���� ��4%%4�?�@�$�����$�A��

���� ���&-%��%�. �7B���� ��� G��.�

�������/����%4�

���������(0������������8�.� �����.�

��������"��1�2'�3������8�?�@�$�����$�A�"��1�2�'�3�

���������$$������������8�?�@�$�����$�A�"��1�2��$��

������,����%4�

��������"��1�2��1"�����8��2�1"������

Page 210: BIT670 - Programming Display Functions

© SAP AG BIT670 6-49

������"���"�"��(0����

�������&��,��"�"��(0������"��-�%4��2�1"�����

������������������������������������������������9:�

��������������������������7 %4%4�$�������9:��

���� ���&-%��%�. �7B�������&��.�

�������/����%4�

��������"��1�2��1"�����8��2�1"������

���%�������

�%�&��,���������������������)�"��1�2����"��

Page 211: BIT670 - Programming Display Functions

© SAP AG BIT670 6-50

�>�����������������������������������������������������������������������

�>������&��#��"��1�2����"��+��+"���

�>�����������������������������������������������������������������������

������+"��������"��$��#�"��1�2���

�������������������������������������������������������������������������

��?���&��&������ �� ��� G���&����H�$$����$�������;�("������"��

��?���&��&������ ����I-�%� ���� ��&�����$�����=*����"����"��

��?���&��������%����������������������

��?���&��&���� %���&&���� ��$���=����"���������"'��+�"���"����$�

�������1��$��������(����"��@��������2�����(3�� �� �!�3�*��"��

����������1���!�@1��1��"�"��(0�����"������(��������������*���<��1����"��

������D+*���3�$����+��#�J"�����+*�+����F��

�������������������������������������������������������������������������

&��,�"��1�2����"��+��+"���

������7 %4%4�$��$�������"��(3��(0�����������3���$����"����$$����

���������������$��$�������=*����"����"��������3���$����

���������������$����������������������������������$�"�<����

���������������$��$�����"����$$����"����������3���$����"����$$�����

��&������, �����?$@�����������A������%���&�$������������!�

�����������������?�@�����+�A������������������+�!�

�����������������?���$����A�����������%���&���$����!�

�����������������?�@�$����A�����������%���&�$��$�������=*����"����"���

����&���7��$��$�������"��(3��(0���!�$��$�������=*����"����"�!�

�����������$������������!�$��$�����"����$$����"���

��&���$����9:���%� ���

����(*���������"(���@��1�"��������������

���� ���%��%� ���%�����$������������� ��4%%4�?$@�����������A��

����?$@�����������A�$�����"#���8�. ���.��

��������� �����"������

������ ���%��%� ���%�����?$@�����������A�����+����

������������� ��4%%4�?�@�����+�A��

������,�B���������%�%4����"��������?�@�����+�A��

�����%�������

Page 212: BIT670 - Programming Display Functions

© SAP AG BIT670 6-51

���� ���%��%� ���%�����$������������� ��4%%4�?$@�����������A��

����?$@�����������A�$�����"#���8�.�%%�.��

��������� �����%%���

������ ���%��%� ���%�����?$@�����������A�����+����

������������� ��4%%4�?�@�����+�A��

������,�B���������%�%4�������������?�@�����+�A��

�����%�������

���� ���%��%� ���%�����$������������� ��4%%4�?$@�����������A��

����?$@�����������A�$�����"#���8�.&�� ��.��

��������� ����$��"����

������ ���%��%� ���%�����?$@�����������A�����+����

������������� ��4%%4�?�@�����+�A��

������,�B���������%�%4���$��"������?�@�����+�A��

�����%�������

���� ���%��%� ���%�����$������������� ��4%%4�?$@�����������A��

����?$@�����������A�$�����"#���8�. ����.��

��������� ����(��'����

������ ���%��%� ���%�����?$@�����������A�����+����

������������� ��4%%4�?�@�����+�A��

������,�B���������%�%4���(��'������?�@�����+�A��

�����%�������

����<����"�"��(0�����@��1���=*�������"�"�

���� ���&-%��%�. �� ���� �.�

�������/����%4�

����������$�����"����������8�.� ������55E.�

���������������������������8�$������������9:�

������,����%4�

�������������*�������������8�$��$�����"����$$����"�9:�

�������/����%��

�������������$����*��$�*���8����

����&��3��*(���?A�5��

������,��� 4�����3�#�<��������..�%-, ����3�#�<���

�������6�7��3�#�<2E��3�#�<2���3�#�<2K��3�#�<2L��

�������� B���������%�5��

�����%�&��

Page 213: BIT670 - Programming Display Functions

© SAP AG BIT670 6-52

�����������"(�*��$"�����"������'�������"����=*����"�����

�������3�����2"����"�"��(0����M�

����7���%���$��$�����"����$$����"�9:���%� ���

���������$��$�����"����$$����"�� ��"��1�2�'�3�"��1�2��$���

����������� �G �%���-�� ����&��,�$��$�����"����$$����"��

��������������������������������,� �%4� ���&������

���� ���&-%��%�. �7B��&���� �����%��4��.�

������� ����

�����������$�����"���+����8�$��$�����"����$$����"��

�����������$�������=���"��8�$��$�������=*����"����"��

�����������$������(0���"��8�$��$�������"��(3��(0�����

��������

�������2�����"�<��@��1�"��1�2��$��������"��"(���@��1�"��1�2��$�����

��������� ����$����� ��4%%4�?���$����A��

������ ���%��%� ���%�����$��$�������=*����"����"��

������������� ��4%%4�?�@�$����A��

������?�@�$����A�"��1�2�'�3�8�?���$����A���@��

�����%�������

���%�&��

�%�&��,���������������������)�"��1�2����"��+��+"���

Page 214: BIT670 - Programming Display Functions

© SAP AG BIT670 6-53

�>�����������������������������������������������������������������������

�>������&��#���"�"��(0������"��

�>�����������������������������������������������������������������������

������"���+����"�"��(0����

�������������������������������������������������������������������������

�����A��&B�7 %������������������1��)����)�����1���"�"��(0����

�����A��&��������%����������������������

��?���&������������������<�����������������$��#��1��"��1�2��

�������������������������������������������������������������������������

&��,��"�"��(0������"��

������������������-�%4�2"�*�D$2�1"����F��������������3��"(�;�

������������������������2"�*�D$������������F��������������$�"�<����

���������������7 %4%4�$���������������������������3����������

��� � ������������#+������� ����&��������

��� � ���2����;�������������3��"(�;��

��&������, �����?�@������A���������������!�

�����������������?�@�����������A�������%���&�$������������!�

�����������������?�2�$�����2"�*�A������ %���

�� ���&-%��%�. �7B��4���� ��.�

�����/����%4�

������"��1�2��1"������������8�$2�1"�����

����������������*��*���8�.�����.�

������"������������$��(0����8�./.�

����� ����

�������"(�������������������8�����������#+��

������� ������������#+� ��4%%4�?�@������A��

�����2����;�8��3��"(�;��

��������� ��$������������� ��4%%4�?�@�����������A��

������ ��4%��,��%�%��?�@�����������A�$�����"#��

�����������&����-�-���?�@������A����?�2�$�����2"�*�A��

������7����3��*(�����%� ���

������&�%���?�2�$�����2"�*�A�%�?�@�����������A�����+�����

�������������������������#+�%��/��2����;��

���������/���

�������%�&��

�����%�������

���%�������

�� ���%���%����&�����������#+����$���������

�%�&��,���������������������)��"�"��(0������"��

Page 215: BIT670 - Programming Display Functions

© SAP AG BIT670 6-54

Unit: Index-Based Read Programs Topic: Displaying the archived original (a letter) in SAP AS

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

• Display the optically archived original for a purchase requisition via SAP AS

1.

The relevant department does not only want to see the purchase requisition, but also the corresponding original documents that were optically archived.

1-1 Call up the function module used in the previous exercise.

2-1 Determine, which business object in ArchiveLink belongs to a purchase requisition. The document type used is called MYLETTER. Enter SE16; Table TOA01; search for document type MYLETTER. The object type you are searching for is stored in the record.

3-1 to 5-1 see example solution for function module ZZMM_EBAN_ORIGINALE

Page 216: BIT670 - Programming Display Functions

© SAP AG BIT670 6-55

&-%��%���,,�� %���4% ����

�)�����������������������������������������������������������������������

�)�)���"�������$"����

�)�������,����%4�

�)� ��&���%�D� �7B����F������� �,�&���� �7B�����

�)���������������&���%�D��&&���F������� �7��/��&&����

�)�����������������������������������������������������������������������

����$���1�����("���

��"�"��(�<����$��(0�����!�

������������("�$����'���("��("�$�!�

������������$��(0�������

��"�"���(0���������'����"+(��"+�(0����

���"���$*�������. �7B���� ��� G��.�

��������;+�����<�

��������������(0������������8�.,,�� %.�

�������������"��1�2'�3������8���"��1�2�'�3�

��������������$$������������8����$$����

��������#+�����<�

������������"��1�2��1"�����8�1"�����

��������;��+������

��������������1��������8�E����������������������������������

��$������3��*(�����������"���

����#���"<������3�#�<����3+��..��*#(����3�#�<���

������������@��1��3�#�<2E��3�#�<2���3�#�<2K��3�#�<2L��

�����;����

������$��

������

����"���$*�������. �7B��4���%�/�������.�

���������;+�����<�

�������������"��1�2��1"�����8�1"�����

���������#+�����<�

������������������������������8�"���(*$$�����<#����

�����������������������*��*���8�"���(*$$�����"#��

���������;��+������

������������������$��(0������������8�E��

Page 217: BIT670 - Programming Display Functions

© SAP AG BIT670 6-56

�����$��3��*(���8�E��

�������;����

��������$��

�����"���"���(*$$�����"#���

������@1���.� %.��

�����������("��8�"���(*$$�����<#�����

��������"++�������("���

��������"����

���������

�"���$*�������. �7B�������&��.�

������;+�����<�

����������"��1�2��1"��������������8�1"������

��������������� ������� ����������

������� ����������� ����

��������� ����������������� �!"#���������������������

����������$%�& �'�

�����������(%������ ����)*�+,-.��

���������������� ������������ ����������������������������

����������$��% ��(�

������������ /�&(�������,����������������������������������������������� ��

�����������

���������

���"�"��*�+*��2�"��3�+���@��1���"��+��������<�

�"����������K55��

�%�&-%��%��

Page 218: BIT670 - Programming Display Functions

© SAP AG BIT670 7-1

� SAP AG 2003

l Glossary <delete if not applicable>

l Menu Paths <delete if not applicable>

l Country-Specific Information<delete if not applicable>

l Additional Slides <delete if not applicable>

Contents:

Appendix

Page 219: BIT670 - Programming Display Functions

© SAP AG BIT670 7-2

� SAP AG 2003

l Creating Business Views in SAP AS

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

Course Objectives

Page 220: BIT670 - Programming Display Functions

© SAP AG BIT670 7-3

� SAP AG 2003

Output of Business View

l Options for controlling the output

n List output programmed directly in the function module

n Output via a self-programmed screen that switches to list processing;Possible to use an existing report

n It is also possible to output to a screen that is a copy of the standard screen, which the application uses for display. If this is the case, the existing processing logic must be adapted to reading data from an ADK archive file. Disadvantages: If the application changes its processing logic in between releases, the customer-specific variant will most probably not work anymore after a Put of the system. Therefore, we do not cover this option.

n The variant 'List output directly in the function module' is especially useful for a rapid test implementation.

Page 221: BIT670 - Programming Display Functions

© SAP AG BIT670 7-4

� SAP AG 2003

Output Directly from the Function Module

l Control output without a screen

n The list output occurs directly in the function module.

n Create a list structure using WRITE statements.

n The list inherits the PF status of the archive information system. No specific list control options are provided for the user.

n Caution: 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.

Page 222: BIT670 - Programming Display Functions

© SAP AG BIT670 7-5

� SAP AG 2003

Output Directly from the Function Module: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_archivekeyoffset = i_offset

importingarchive_handle = handle

exceptionsothers = 12.

Page 223: BIT670 - Programming Display Functions

© SAP AG BIT670 7-6

� SAP AG 2003

Output Directly from the Function Module: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 = handleimporting

record = arc_buffer-segmentrecord_structure = arc_buffer-rname

exceptionsend_of_object = 1.

if sy-subrc = 1.exit.

endif.

Page 224: BIT670 - Programming Display Functions

© SAP AG BIT670 7-7

� SAP AG 2003

Output Directly from the Function Module: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',

Page 225: BIT670 - Programming Display Functions

© SAP AG BIT670 7-8

� SAP AG 2003

Output Directly from the Function Module: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.

Page 226: BIT670 - Programming Display Functions

© SAP AG BIT670 7-9

� SAP AG 2003

Output Directly from the Function Module: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.

Page 227: BIT670 - Programming Display Functions

© SAP AG BIT670 7-10

� SAP AG 2003

Output Using Screen and List Processing

l Output control

n Creating screen for function group

n Calling up screen in the function module and switching to list function

n Filling and output of list

Page 228: BIT670 - Programming Display Functions

© SAP AG BIT670 7-11

� SAP AG 2003

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_archivekeyoffset = i_offset

importingarchive_handle = handle

exceptions

others = 12.

Page 229: BIT670 - Programming Display Functions

© SAP AG BIT670 7-12

� SAP AG 2003

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'

exportingarchive_handle = handle

importingrecord = arc_buffer-segmentrecord_structure = arc_buffer-rname

exceptionsend_of_object = 1.

if sy-subrc = 1.exit.

endif.

Page 230: BIT670 - Programming Display Functions

© SAP AG BIT670 7-13

� SAP AG 2003

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.

n In interactive reporting it is possible to read data before starting the function module 'ARCHIVE_CLOSE_FILE‘. The context of the object still exists.

Page 231: BIT670 - Programming Display Functions

© SAP AG BIT670 7-14

� SAP AG 2003

Screen/List Output: MM_MATBEL (4)

process before output.module status_0200.

module display_liste_materialdocuments.

process after input.module user_command_200.

Switching to list processing

Read/Output

internal table

Head/Items data

Empty module

bec. switched to

list processing

Logical struct.Screen 200

n The PAI module must be available, although the system switched to list processing. The module can be empty.

n Interactive reporting is possible via event AT_USER_COMMAND.

Page 232: BIT670 - Programming Display Functions

© SAP AG BIT670 7-15

� SAP AG 2003

Screen/List Output: MM_MATBEL (5)

module status_0200 output.

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

SET PF-STATUS ‘Screen list'.* SET TITLEBAR 'xxx'.

endmodule. " STATUS_0200 OUTPUT

module user_command_0200 input.

endmodule. " USER_COMMAND_0200 INPUT

n The desired GUI status for the screen can/must be set in the PF status.

Page 233: BIT670 - Programming Display Functions

© SAP AG BIT670 7-16

� SAP AG 2003

Screen/List Output: MM_MATBEL (6)

module display_liste_materialbelege output.

write: /2 'Posting Date:', 18 i_mkpf-budat, 66 'Name:',73 i_mkpf-usnam.

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

10 'Amount',30 'EME', 35 'Material', 55 'Plant',60 'Loc'.

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

skip 1.

Page 234: BIT670 - Programming Display Functions

© SAP AG BIT670 7-17

� SAP AG 2003

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_LISTE_MATERIALBELEGE OUTPUT