bc401-P-1-50

June 1, 2016 | Author: sto4000 | Category: N/A
Share Embed Donate


Short Description

Download bc401-P-1-50...

Description

BC401 ABAP Objects BC401

Release 630 02.09.2003

BC401 ABAP Objects.......................................................................................................................................................1 Copyright.......................................................................................................................................................................2 Course Prerequisites...................................................................................................................................................4 Target Group..............................................................................................................................................................5 Course Overview...........................................................................................................................................................1 Course Goal...............................................................................................................................................................2 Course Objectives......................................................................................................................................................3 Course Content (1).....................................................................................................................................................4 Course Content (2).....................................................................................................................................................5 Course Overview: Integration in Course Content......................................................................................................6 Main Business Scenario.............................................................................................................................................7 Technical Names........................................................................................................................................................8 Data Types and Data Objects in Detail..........................................................................................................................1 Data Types and Data Objects in Detail: Unit Objectives..........................................................................................2 Data Types and Data Objects in Detail: Integration in Course Content....................................................................3 Data Types and Data Objects in Detail (1)................................................................................................................4 Revision: Defining Data Objects...............................................................................................................................5 Predefined ABAP Types............................................................................................................................................6 Type Groups in the ABAP Dictionary.......................................................................................................................7 Data Types and Data Objects in Detail (2)................................................................................................................8 Integers and Integer Arithmetic.................................................................................................................................9 Packed Numbers and Fixed Point Arithmetic..........................................................................................................10 Floating Point Arithmetic........................................................................................................................................11 Summary: Recommendations for Using Numeric Data Types................................................................................12 Arithmetic and Mixed Expressions..........................................................................................................................13 Predefined ABAP Types for Character Strings.......................................................................................................14 Overview: Character String Processing...................................................................................................................15 Accessing Parts of Fields.........................................................................................................................................16 Data Types and Data Objects in Detail (3)..............................................................................................................17 Defining Structures with Local Types.....................................................................................................................18 Defining Nested Structures with Local Types.........................................................................................................19 Using Named Includes.............................................................................................................................................20 Data Types and Data Objects in Detail (4)..............................................................................................................21 Unicode: Overview..................................................................................................................................................22 Character-Type and Byte-Type Types.....................................................................................................................23 Functions and Comparison Operators......................................................................................................................24 Compatibility and Conversion.................................................................................................................................25 Conversion Under Unicode (1)................................................................................................................................26 Conversion Under Unicode (2)................................................................................................................................27

Example of Using the Conversion Rules.................................................................................................................28 Offset and Length Accesses and Elementary Data Objects.....................................................................................29 Offset and Length Accesses and Structures.............................................................................................................30 Data Types and Data Objects in Detail: Summary..................................................................................................31 Data Types and Data Objects in Detail Exercise 1..................................................................................................32 Data Types and Data Objects in Detail Solution 1..................................................................................................34 Using Internal Tables.....................................................................................................................................................1 Using Internal Tables: Unit Objectives......................................................................................................................2 Using Internal Tables: Integration in Course Content...............................................................................................3 Using Internal Tables (1)...........................................................................................................................................4 The Internal Table - a Data Object of Variable Length.............................................................................................5 Attributes of Internal Tables......................................................................................................................................6 Link Between Table Kind and Access Type..............................................................................................................7 Using Internal Tables (2)...........................................................................................................................................8 Overview: Types of Definitions for Internal Tables..................................................................................................9 The Data Type of an Internal Table.........................................................................................................................10 Table Attribute: Line Type......................................................................................................................................11 Table Attribute: Table Kind and Key......................................................................................................................12 Example: Standard Table with Local Type.............................................................................................................13 Example: Sorted and Hashed Table.........................................................................................................................14 The Standard Table Type.........................................................................................................................................15 Internal Tables with an Unstructured Line Type.....................................................................................................16 Using Internal Tables (3).........................................................................................................................................17 Overview: Types of Operation.................................................................................................................................18 Limiting the Scope of Line Operations: Target Records and Access Type.............................................................19 Preview: Field SymboIs (1).....................................................................................................................................20 Preview: Field SymboIs (2).....................................................................................................................................21 Insert........................................................................................................................................................................22 Reading a Single Record into a Work Area Using the Line Number......................................................................23 Reading a Single Record into a Work Area Using the Field Contents....................................................................24 Reading a Single Record Using a Field Symbol......................................................................................................25 Changing the Table Using a Work Area..................................................................................................................26 Changing a Single Record Using a Field Symbol...................................................................................................27 Delete.......................................................................................................................................................................28 Loop Processing.......................................................................................................................................................29 Overview of Operations...........................................................................................................................................30 Using Internal Tables (4).........................................................................................................................................31 Internal Tables with a Header Line..........................................................................................................................32 Selection Options and Selection Tables...................................................................................................................33

Using Internal Tables (5).........................................................................................................................................34 Single Record Access: Completely and Partially Qualified Key.............................................................................35 Loop Processing and Table Kinds...........................................................................................................................36 Partial Sequential Loop Through Standard Tables..................................................................................................37 Access Using Field Symbols...................................................................................................................................38 Using Internal Tables: Unit Summary.....................................................................................................................40 Using Internal Tables Exercise 1.............................................................................................................................41 Using Internal Tables Solution 1.............................................................................................................................48 Calling Programs and Passing Data...............................................................................................................................1 Calling Programs and Passing Data: Unit Objectives................................................................................................2 Calling Programs and Passing Data: Integration in Course Content.........................................................................3 Calling Programs and Passing Data (1).....................................................................................................................4 Calling Programs.......................................................................................................................................................5 Calling an Executable Program.................................................................................................................................6 Calling a Transaction.................................................................................................................................................7 Calling Programs and Passing Data (2).....................................................................................................................8 Logical Memory Model.............................................................................................................................................9 Inserting a Program (1)............................................................................................................................................10 Inserting a Program (2)............................................................................................................................................11 Terminating the Inserted Program...........................................................................................................................12 Restarting an Executable Program (1).....................................................................................................................13 Restarting an Executable Program (2).....................................................................................................................14 Restarting a Transaction (1).....................................................................................................................................15 Restarting a Transaction (2).....................................................................................................................................16 Calling Programs and Passing Data (3)...................................................................................................................17 Overview: Passing Data Between Programs............................................................................................................18 Passing Data Using the Program Interface..............................................................................................................19 Preassigning Values for Input Fields.......................................................................................................................20 ABAP Memory and SAP Memory..........................................................................................................................21 Passing Data Using the ABAP Memory..................................................................................................................22 Passing Parameters Using the SAP Memory...........................................................................................................23 Preview: Passing Data Using an Internal Table.......................................................................................................24 Fields of the Global Type bdcdata...........................................................................................................................26 Example: Passing Data Using an Internal Table......................................................................................................27 Calling Programs and Passing Data: Unit Summary...............................................................................................28 Introduction to Object-Oriented Programming..............................................................................................................1 Introduction to Object-Oriented Programming: Unit Objectives..............................................................................2 Introduction to Object-Oriented Programming: Integration in Course Content........................................................3 History of Programming Languages..........................................................................................................................4

Introduction: Programming Models (1).....................................................................................................................5 Characteristics of Procedural Programming..............................................................................................................6 Typical ABAP Program.............................................................................................................................................7 ABAP Main Memory and Function Groups..............................................................................................................8 Function Group Example...........................................................................................................................................9 Use of Function Group.............................................................................................................................................10 Several Instances of One Function Group...............................................................................................................11 Instantiation and Object-Oriented Languages.........................................................................................................12 Introduction: Programming Models (2)...................................................................................................................13 Programming Models...............................................................................................................................................14 Characteristics of the Object-Oriented Approach....................................................................................................15 Technical Implementation of the Object-Oriented Approach..................................................................................16 Client/Server Behavior.............................................................................................................................................17 Compatibility and Design Aims...............................................................................................................................18 ABAP Main Memory and Encapsulation................................................................................................................19 The Software Development Process........................................................................................................................20 Introduction to Object-Oriented Programming: Summary......................................................................................21 Analysis and Design......................................................................................................................................................1 Analysis and Design: Unit Objectives.......................................................................................................................2 Analysis and Design: Integration in Course Content.................................................................................................3 Analysis and Design (1).............................................................................................................................................4 Classification of Objects............................................................................................................................................5 Different Abstractions of a Class...............................................................................................................................6 Representation of a Class...........................................................................................................................................7 Classes and Objects....................................................................................................................................................8 Analysis and Design (2).............................................................................................................................................9 Modeling with UML................................................................................................................................................10 Example of a Class Diagram....................................................................................................................................11 Association...............................................................................................................................................................12 Aggregation and Composition.................................................................................................................................13 Generalization and Specialization............................................................................................................................14 Sequence Diagrams: Example.................................................................................................................................15 Sequence Diagram: Delegation................................................................................................................................16 Analysis and Design: Summary...............................................................................................................................17 Analysis and Design Exercises................................................................................................................................18 Analysis and Design Solutions................................................................................................................................19 Principles of Object-Oriented Programming.................................................................................................................1 Principles of Object-Oriented Programming: Unit Objectives..................................................................................2 Principles of Object-Oriented Programming: Integration in Course Content............................................................3

Principles (1)..............................................................................................................................................................4 Example of a Class.....................................................................................................................................................5 Defining Classes........................................................................................................................................................6 Attributes....................................................................................................................................................................7 Attributes, Types, and Constants: Syntax..................................................................................................................8 Attributes and Visibility.............................................................................................................................................9 Accessing Private Attributes....................................................................................................................................10 Instance Attributes and Static Attributes (1)............................................................................................................11 Instance Attributes and Static Attributes (2)............................................................................................................12 Methods: Syntax......................................................................................................................................................13 Accessing Private Methods......................................................................................................................................14 Methods and Visibility.............................................................................................................................................15 Instance Methods and Static Methods.....................................................................................................................16 Instance Methods and Static Methods: Example.....................................................................................................17 Summary and UML Notation..................................................................................................................................18 Principles (2)............................................................................................................................................................19 Creating Objects.......................................................................................................................................................20 Reference Variables.................................................................................................................................................21 Creating Objects: Syntax.........................................................................................................................................22 Garbage Collector....................................................................................................................................................23 Garbage Collector: Procedure..................................................................................................................................24 Buffering References...............................................................................................................................................25 Aggregation Example..............................................................................................................................................26 Principles (3)............................................................................................................................................................27 Calling Methods.......................................................................................................................................................28 Calling Instance Methods: Syntax...........................................................................................................................29 Calling Static Methods: Syntax...............................................................................................................................30 Functional Methods.................................................................................................................................................31 Functional Methods: Example.................................................................................................................................32 External Access to Public Attributes.......................................................................................................................33 Principles (4)............................................................................................................................................................34 Constructor...............................................................................................................................................................35 Constructor: Example..............................................................................................................................................36 Preview: Static Constructor.....................................................................................................................................37 Principles (5)............................................................................................................................................................38 Namespace Within a Class.......................................................................................................................................39 The Reference Variable ME....................................................................................................................................40 Principles of Object-Oriented Programming: Unit Summary.................................................................................41 Principles of Object-Oriented Programming Exercises...........................................................................................42

Principles of Object-Oriented Programming Solutions...........................................................................................48 Inheritance......................................................................................................................................................................1 Inheritance: Unit Objectives......................................................................................................................................2 Inheritance: Integration in Course Content................................................................................................................3 Inheritance: UML Example.......................................................................................................................................4 Multiple Inheritance?.................................................................................................................................................5 Relationships Between Superclasses and Subclasses................................................................................................6 Inheritance: Syntax....................................................................................................................................................7 Redefining Methods...................................................................................................................................................8 Inheritance and Redefining the Constructor..............................................................................................................9 Rules for Calling the Constructor............................................................................................................................10 Inheritance and Visibility.........................................................................................................................................11 Visibility of Protected Components.........................................................................................................................12 Rules for Redefining Methods.................................................................................................................................13 Redefining Methods: Example................................................................................................................................14 Inheritance: Unit Summary......................................................................................................................................15 Inheritance Exercises...............................................................................................................................................16 Inheritance Solutions...............................................................................................................................................18 Casting...........................................................................................................................................................................1 Casting: Unit Objectives............................................................................................................................................2 Casting: Integration in Course Content......................................................................................................................3 Casting (1)..................................................................................................................................................................4 Principle of Narrowing Cast......................................................................................................................................5 Compatibility and Narrowing Cast............................................................................................................................6 Generic Access?.........................................................................................................................................................7 Preparations for Generic Access (1)..........................................................................................................................8 Preparations for Generic Access (2)..........................................................................................................................9 Polymorphism - Generic Access..............................................................................................................................10 Static and Dynamic Types of References................................................................................................................11 Comparison to Procedural Programming.................................................................................................................12 Casting (2)................................................................................................................................................................13 Use of Widening Cast..............................................................................................................................................14 Widening Cast: Example.........................................................................................................................................15 Casting (3)................................................................................................................................................................16 Semantics and Use with Inheritance........................................................................................................................17 Incorrect Use of Inheritance.....................................................................................................................................18 Casting: Unit Summary............................................................................................................................................19 Casting Exercises.....................................................................................................................................................20 Casting Solutions.....................................................................................................................................................22

Interfaces........................................................................................................................................................................1 Interfaces: Unit Objectives........................................................................................................................................2 Interfaces: Integration in Course Content..................................................................................................................3 Interfaces (1)..............................................................................................................................................................4 Interfaces: Use...........................................................................................................................................................5 Interfaces: Services....................................................................................................................................................6 Interface: UML Example...........................................................................................................................................7 Defining and Implementing an Interface...................................................................................................................8 Interfaces: Features....................................................................................................................................................9 Interfaces (2)............................................................................................................................................................10 Working with Interface Components.......................................................................................................................11 Interface References: Narrowing Cast.....................................................................................................................12 Using the Interface...................................................................................................................................................13 Polymorphism and Interfaces..................................................................................................................................14 Interface References: Widening Cast.......................................................................................................................15 Interfaces (3)............................................................................................................................................................16 Compound Interfaces...............................................................................................................................................17 Compound Interfaces: Example...............................................................................................................................18 Interfaces: Unit Summary........................................................................................................................................19 Interfaces Exercises.................................................................................................................................................20 Interfaces Solutions..................................................................................................................................................25 Events.............................................................................................................................................................................1 Events: Unit Objectives.............................................................................................................................................2 Events: Integration in Course Content.......................................................................................................................3 Events: Overview.......................................................................................................................................................4 Features......................................................................................................................................................................5 Triggering and Handling Events: Overview..............................................................................................................6 Defining and Triggering Events: Syntax...................................................................................................................7 Handling and Registering Events...............................................................................................................................8 Event Handler Methods.............................................................................................................................................9 Registering for an Event: Syntax.............................................................................................................................10 Registration/Deregistration: Handler Tables...........................................................................................................11 Event Handling: Features.........................................................................................................................................12 Events: Unit Summary.............................................................................................................................................13 Events Exercises......................................................................................................................................................14 Solutions..................................................................................................................................................................16 Global Classes and Interfaces........................................................................................................................................1 Global Classes and Interfaces: Unit Objectives.........................................................................................................2 Global Classes and Interfaces: Integration in Course Content..................................................................................3

Global Classes and Interfaces (1)..............................................................................................................................4 Review: Local Classes and Interfaces........................................................................................................................5 Global Classes and Interfaces....................................................................................................................................6 Creating Global Classes in the Object Navigator.....................................................................................................7 Class Builder: Attributes............................................................................................................................................8 Class Builder: Methods..............................................................................................................................................9 Class Builder: Interface Methods.............................................................................................................................10 Class Builder: Method Interface..............................................................................................................................11 Class Builder: Method Implementation...................................................................................................................12 Class Builder: Inheritance........................................................................................................................................13 Class Builder: Test Environment.............................................................................................................................14 Global Classes and Interfaces (2)............................................................................................................................15 Global Classes in the Object Navigator...................................................................................................................16 Class Builder: CREATE OBJECT...........................................................................................................................17 Class Builder: CALL METHOD.............................................................................................................................18 Global Classes and Interfaces (3)............................................................................................................................19 SAP Grid Control.....................................................................................................................................................20 Including a Grid Control Instance in a Dialog Program..........................................................................................21 Displaying Data with a Grid Control Instance.........................................................................................................22 Global Classes and Interfaces: Unit Summary........................................................................................................23 Exercises..................................................................................................................................................................24 Solutions..................................................................................................................................................................26 Special Techniques........................................................................................................................................................1 Special Techniques: Unit Objectives.........................................................................................................................2 Special Techniques: Integration in Course Content...................................................................................................3 Special Techniques (1)...............................................................................................................................................4 Abstract Classes.........................................................................................................................................................5 Final Classes..............................................................................................................................................................6 Special Techniques (2)...............................................................................................................................................7 Who Can Instantiate Classes?....................................................................................................................................8 Special Techniques (3)...............................................................................................................................................9 Friends......................................................................................................................................................................10 Special Techniques (4).............................................................................................................................................11 Persistence Service...................................................................................................................................................12 Features of the Persistence Service..........................................................................................................................13 Class Agent..............................................................................................................................................................14 Special Techniques: Unit Summary.........................................................................................................................16 Exercises - optional..................................................................................................................................................17 Solutions - optional..................................................................................................................................................20

Exception Handling.......................................................................................................................................................1 Exception Handling: Unit Objectives........................................................................................................................2 Exception Handling: Integration in Course Content..................................................................................................3 Class-Based Exceptions: Overview...........................................................................................................................4 Exception Classes: The Inheritance Hierarchy..........................................................................................................5 Handling Exceptions..................................................................................................................................................6 Example: Handling a Predefined Exception..............................................................................................................7 Example: Using Your Own Exceptions.....................................................................................................................8 Creating Your Own Exception Classes......................................................................................................................9 Maintaining Your Own Attributes and Exception Texts.........................................................................................10 Raising and Handling Exceptions You Have Written.............................................................................................11 Passing Exceptions Along........................................................................................................................................12 Example: Passing Exceptions Along.......................................................................................................................13 Exceptions That Must Be Declared.........................................................................................................................14 Exception Handling: Unit Summary........................................................................................................................15 Exception Handling Exercise 1................................................................................................................................16 Exception Handling Solution 1................................................................................................................................18 Dynamic Programming..................................................................................................................................................1 Dynamic Programming: Unit Objectives...................................................................................................................2 Dynamic Programming: Integration in Course Content............................................................................................3 Dynamic Programming (1)........................................................................................................................................4 Field Symbols............................................................................................................................................................5 The CASTING Addition............................................................................................................................................7 Dynamic Programming (2)........................................................................................................................................9 Using Dynamic Attributes in Statements.................................................................................................................10 Calling Methods Dynamically.................................................................................................................................11 Dynamic Programming (3)......................................................................................................................................12 Data Reference Variables........................................................................................................................................13 Example: Using Data Reference Variables in Dynamic Method Calls...................................................................14 Generating Data Objects at Runtime.......................................................................................................................15 Dereferencing Data References...............................................................................................................................16 Example: Generating Data Objects at Runtime.......................................................................................................17 Dynamic Programming (4)......................................................................................................................................18 Ascertaining Internal Table Attributes.....................................................................................................................19 Dynamic Type Descriptions for RTTI Classes........................................................................................................20 Declaring Types Dynamically: Example.................................................................................................................21 Dynamic Programming: Unit Summary..................................................................................................................22 Exercise 1 – Optional...............................................................................................................................................23 Solution 1 - Optional................................................................................................................................................26

0 BC401 ABAP Objects

BC401 ABAP Objects  SAP AG 2002

System: SAP R/3 System requirements: SAP R/3, Basis Release 6.10 or later 2002/Q3 Material number: 50054667

0.2 Copyright

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

 SAP AG 2002

Notes on 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®, OS/2®, DB2/6000®, Parallel Sysplex®, MVS/ESA®, RS/6000®, AIX®, S/390®, AS/400®, OS/390®, and OS/400® are registered trademarks of IBM Corporation. ORACLE® is a registered trademark of ORACLE Corporation. INFORMIX®-OnLine for SAP and INFORMIX® Dynamic ServerTM are registered trademarks of Informix Software Incorporated. UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group. HTML, DHTML, XML, and 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 developed and implemented by Netscape. SAP, SAP Logo, R/2, RIVA, R/3, ABAP, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP.com Logo, and mySAP.com are trademarks or registered trademarks of SAP AG in Germany and several other countries all over the

world. All other products mentioned are trademarks or registered trademarks of their respective companies.

0.3 Course Prerequisites

Programming experience SAPTEC (mySAP Technology Solution Overview) BC400 (ABAP Workbench: Foundations and Concepts) Programming experience in ABAP

 SAP AG 2002

0.4 Target Group

Participants: Developers, consultants Duration: 5 days

 SAP AG 2002

Notes to the user The training materials are not appropriate for self-study. They complement the course instructor's explanations. There is space for you to write down additional information on the sheets. There may not be enough time during the course to complete all the exercises. The exercises are intended as additional examples of the topics discussed during the course. Participants can also use them as an aid to enhancing their knowledge after the course has finished.

1 Course Overview

Contents: Course goal Course objectives Course content Course overview diagram Main business scenario

 SAP AG 2002

(C) SAP AG

BC401

1

1.2 Course Goal

This course will enable you to:

Learn the principles of object-oriented programming Learn the structure and application of ABAP Objects

 SAP AG 2002

(C) SAP AG

BC401

2

1.3 Course Objectives

At the conclusion of this course, you will be able to: Describe and use the most important principles: Internal tables Classes/inheritance/interfaces Polymorphism, inheritance, and interfaces Events Exception handling Dynamic programming Develop programs in ABAP Objects

 SAP AG 2002

(C) SAP AG

BC401

3

1.4 Course Content (1)

Preface Unit 1

Course Overview

Unit 2

Data Types and Data Objects in Detail

Unit 3

Using Internal Tables

Unit 4

Calling Programs and Passing Data

Unit 5

Introduction to Object-Oriented Programming

Unit 6

Analysis and Design

Unit 7

Principles of Object-Oriented Programming

Unit 8

Inheritance

Unit 9

Casting

Unit 10

Interfaces

 SAP AG 2002

(C) SAP AG

BC401

4

1.5 Course Content (2)

Unit 11

Events

Unit 12

Global Classes and Interfaces

Unit 13

Special Techniques

Unit 14

Exception Handling

Unit 15

Dynamic Programming

Appendix

 SAP AG 2002

(C) SAP AG

BC401

5

1.6 Course Overview: Integration in Course Content

erview Course Ov  SAP AG 2002

(C) SAP AG

BC401

6

1.7 Main Business Scenario

A travel agent maintains its connections to business partners - such as airlines, car hire companies, and hotels

 SAP AG 2002

(C) SAP AG

BC401

7

1.8 Technical Names

Package: BC401 Naming conventions for program objects: Demonstrations:

SAPBC401_xxxD_...

Copy templates:

SAPBC401_xxxT_...

Model solutions:

SAPBC401_xxxS_...

xxx is the individual unit code

 SAP AG 2002

Unit codes: Unit 2: DTO Unit 3: TAB Unit 4: CAL Unit 7: AIR Unit 8: INH Unit 9: CAS Unit 10: INT Unit 11: EVE Unit 12: CLS Unit 13: SPC Unit 14: EXC Unit 15: DYN

(C) SAP AG

BC401

8

2 Data Types and Data Objects in Detail

Contents: Data objects in programs Elementary data objects Structures Character string processing in Unicode

 SAP AG 2002

(C) SAP AG

BC401

1

2.2 Data Types and Data Objects in Detail: Unit Objectives

At the conclusion of this unit, you will be able to: Use elementary data objects and structures appropriately Use numeric data types appropriately Use automatic type conversions appropriately Take the special features of character string processing in Unicode into account

 SAP AG 2002

(C) SAP AG

BC401

2

2.3 Data Types and Data Objects in Detail: Integration in Course Content

and Data Types in ts ec O bj Data Detail

ervie Course Ov

w

 SAP AG 2002

(C) SAP AG

BC401

3

2.4 Data Types and Data Objects in Detail (1)

Introduction Introduction Elementary Elementary Data Data Objects Objects Structures Structures Special Special Features Features in in Unicode Unicode

 SAP AG 2002

(C) SAP AG

BC401

4

2.5 Revision: Defining Data Objects

Local types TYPES type_name TYPE ...

Predefined ABAP types d t i f string xstring

DATA do_name TYPE type_name.

p n c x

Global types

DATA do_name_new LIKE do_name.

 SAP AG 2002

Data objects are usually defined with the DATA statement as follows. After the name of the data object, a a fully-specified type is assigned to it using the TYPE addition. The type is linked to the data object statically and cannot be changed at runtime. There are other syntax variants available (for historical reasons). Note however, that some of these historical variants are no longer supported in ABAP Objects. For further information, refer to the keyword documentation for the DATA statement. All types are based on predefined ABAP types, which will be discussed in greater detail in the following slide. Some of these ABAP types are fully specified and can be used to type data objects directly. Other types need to be modified to include the length, and in some cases the number of decimal places so that they are fully specified. These are the simplest examples of user-defined types. You can create complex structured types of any level of complexity, based on elementary types. You can also define types centrally in the ABAP Dictionary. You can then use these global types in all appropriate Repository objects in the system.

(C) SAP AG

BC401

5

2.6 Predefined ABAP Types Data type Numeric

Fixed length

i f p

Description

Length in bytes

Attributes Differ in:

Integer

4

Float. point number 8 Packed number 1 .. 16

• Rules for storage • Value range • Arithmetic used

Character string type

n c d t

Number sequence 1 .. 65535 Character sequence 1 .. 65535 Date 8 Time 6

Character string operations (allowed for all types) + date calculations + time calculations

Hexadecimal

Variable length

x

Hexadecimal code

1 .. 65535

Bit operations

Character string type / hexadecimal

string xstring

Runtime system adjusts length dynamically

Character sequence Hexadecimal code

 SAP AG 2002

The following ABAP types are fully specified and can be used directly to type data objects: d, t, i, f, string, and xstring. A special feature of the string and xstring types is that their length is adjusted dynamically at runtime. Thus, for these two types, length is not a component of the type. The following ABAP types are not fully specified, so you must include additional information before you use them to define data objects: c, n, and x Length needs to be added. Permitted values: 1 to 65535 characters. If you do not declare a length when you define a data object, the system assigns the default length of 1. p You must extend the type to include the length, and number of decimal places, Permitted length: 1 to 16 bytes. If you do not declare a length when you define a data object, the system assigns the default length of 8 bytes (that is, 15 digits) and 0 decimal places. The type also contains information on how the data is stored, what range of values is allowed, what operations can be performed on the data, and what sort of arithmetic is used (if the data object is suitable for use in calculations). We will deal with this topic in greater detail later in this unit.

(C) SAP AG

BC401

6

2.7 Type Groups in the ABAP Dictionary Name of type group: Up to 5 characters; each type name and constant name starts with the name of the type group.

Each type group, whose types and constants you want to use, must be specified in the ABAP program

Type group zmytp TYPE-POOL zmytp zmytp. CONSTANTS zmytp zmytp_const_name ... [ TYPES zmytp zmytp_type_name1 ... ] [ TYPES zmytp zmytp_type_name2 ... ] ...

Using a constant: ABAP program

TYPE-POOLS: TYPEzmytp TYPE-POOLS zmytp. [ DATA var TYPE zmytp zmytp_type1. ] IF var = zmytp zmytp_const_name. ... ENDIF.  SAP AG 2002

You must use a type group to define global constants. The name of the type group can contain up to 5 characters. You define constants in the type group using the CONSTANTS statement, just as in an ABAP program. You only have to adhere to the following namespace convention: All constants (and type names) must have the name of the type group as a prefix. You can use either a global Dictionary type or a predefined ABAP type as a valid type. To be able to use the types of a type group in a program, you must refer to the type group using the TYPE-POOLS statement. After this line in the program, you can then use all the constants in the type group. You can also define global data types in a type group. Before SAP R/3 Basis Release 4.5, this was the only way to define complex global data types.

(C) SAP AG

BC401

7

2.8 Data Types and Data Objects in Detail (2)

Introduction Introduction Elementary Elementary Data Data Objects Objects Structures Structures Special Special Features Features in in Unicode Unicode

 SAP AG 2002

(C) SAP AG

BC401

8

2.9 Integers and Integer Arithmetic

Length: 4 bytes

DATA: counter TYPE i VALUE 1.

Value range [-2147483648; 2147483647] Integer Arithmetic

int1 = int2 / int3 + int4.

All internal auxiliary fields are integers Interim results are rounded

int2 = int1

4

int3 = 4

=

3 3

/ 1

=

int4 =

Arithmetic operations for integers:

2

+

2

+

2

=

Integer auxiliary variable

3

+ * / DIV MOD **

Addition Subtraction Multiplication Division Integer division Remainder integer div. Power

 SAP AG 2002

In integer arithmetic, the system always rounds to the appropriate decimal place. So, for example: DATA int TYPE i. int = 4 / 10. " result: 0 int = 5 / 10. " result: 1 Calculations performed using integer arithmetic are faster than calculations using fixed point or floating point arithmetic. For further information on calculations performed on integers, refer to the keyword documentation for the COMPUTE statement.

(C) SAP AG

BC401

9

2.10 Packed Numbers and Fixed Point Arithmetic DATA: percentage(3) (3) TYPE p DECIMALS 2 VALUE '12.34'.

Length in bytes: n bytes correspond to 2n - 1 digits

Number of decimal places

Fixed point arithmetic: "like using paper and pencil" Number 12,34

+

1234,56 78,5 1313,06

Internal representation 0 1 2 3 4 + 1 digit per half-byte

Sign

Permitted length: 1 to 16 bytes (= 1 to 31 digits) Number of decimal places < number of digits, max. 15 Example: Length 3 bytes, 2 decimal places Þ Value range: [-999.99,+999.99]

 SAP AG 2002

The length of packed numbers is given in bytes. The connection between value range and length is derived from the internal representation: Each decimal digit is represented by a half-byte. The last byte is reserved for the plus or minus sign. The number of decimal places is defined using the DECIMALS addition. The maximum number of decimal places is either 15 or the length of the number minus 1 (that is, there must be at least one digit before the comma). In user dialogs, decimal numbers are formatted according to the settings in the user master record. Decimal point-aligned fixed point arithmetic is used as default for calculations. Packed numbers are thus well-suited to business calculations, where the correct rounding for the specified number of decimal places is very important. The algorithm for this arithmetic is similar to using "pencil and paper". The system always uses packed numbers of maximum length for interim results. You can switch off fixed point arithmetic in the program attributes. If you do, the DECIMALS addition when defining a packed number only affects the output of the number. Internally, all numbers are interpreted as integers, regardless of the position of the decimal point. The fixed point arithmetic option is always selected by default. You should always accept this value and use packed numbers for business calculations.

(C) SAP AG

BC401

10

2.11 Floating Point Arithmetic

|

| -

1,5 = 1×20 + 1×2 1 1 =1 + 2 | 0 0 | -3

Only 53 bits available

| ...

| 0 0 | -6

-7

-10

-11

0,15 = 1×2 + 1×2 + 1×2 + 1×2 + 1×2 + Λ 1 1 1 1 1 = + + + + + 8 128 1024 2048 Λ 64



= 0,125 + Λ = = =

0,140625 + Λ

Only for approximations

0,1484375 + Λ 0,1494140625 + Λ 0,1499023437 Λ

=  SAP AG 2002

Unlike packed numbers, floating point numbers are represented using sums of binary fractions. Floating point numbers are also normalized, and both the exponent and the mantissa are stored in binary form. This representation complies with the IEEE norm for double precision floating point numbers. The floating point operations of the relevant processors are used for calculations. Since algorithms are converted to binary, inaccuracies can occur. Therefore, floating point numbers are not suitable for business calculations. Example: You want to calculate 7.72% of 73050 and display the result accurate to two decimal places. The answer should be 5310.74 (73050 * 0.0727 = 5310.7735). The program, however: DATA: float TYPE f, pack TYPE p DECIMALS 2. float = 73050 * '0.0727'. " result: 5.3107349999999997E+03 pack = float. WRITE pack. " result: 5310.73 You should therefore only use floating point numbers for approximations. When you compare numbers, always use intervals, and always round at the end of your calculations. The advantage of floating point numbers is the large value range: It comprises numbers from is, from 2,2250738585072014E-308 to 1,7976931348623157E+308 including both positive and negative numbers as well as zero. In addition, you must use floating point numbers for special aggregation functions of the SELECT statement.

(C) SAP AG

BC401

11

2.12 Summary: Recommendations for Using Numeric Data Types

Required:

Integers only

Recommended predefined ABAP data type: Type i, since calculations using integer arithmetic are fastest

Decimal numbers for business calculations

Type p

Decimal numbers for rough calculations performed on very small or very large numbers

Type F

 SAP AG 2002

Note: The results of the following functions have the data type f: Trigonometric functions: cos, acos, sin, asin, tan, atan Hyperbolic functions: tanh, sinh, cosh Exponential functions (base e): exp Natural logarithms (base e): log Logarithms (base 10): log10 Square root: sqrt

(C) SAP AG

BC401

12

2.13 Arithmetic and Mixed Expressions

Fixed point arithmetic is the default Integer arithmetic is only used if all the components are integers Floating point arithmetic is used if at least one component is a floating point number All components are converted to the relevant data type After the calculation, all are converted to the result type

Example: p DECIMALS 3 r

i =

i

f

→ Float. point arithmetic ↓ Conversion after f and calculation

a

/

b

+

c

201

/

200

+

0.0000...E+000

1.004999...E+000 +

0.0000...E+000

Interim result: =

1.004999...E+000 ↓ Conversion after p DECIMALS 3

1.005  SAP AG 2002

An arithmetic expression may contain any data types that are convertible into each other and into the type of the result field. The system converts all the values into one of the three numeric data types (i, p, or f), depending on the data types of the operands. The ABAP runtime system contains an arithmetic for each of the three data types. The system then performs the calculation and converts it into the data type of the result field. This may mean that the same arithmetic expression leads to different results when performed on different combinations of data types. It is also possible for an arithmetic expression to have only character string type data objects, as long as their contents are appropriate. The values are converted to numeric type objects. Bear in mind that conversions affect performance. Wherever possible, choose a data type that does not require runtime conversion. If an arithmetic expression contains numeric literals, the choice of arithmetic depends on the size of the number: If the number is within the value range for the data type i, the numeric literal is interpreted as an integer. If the value of the literal is greater than 2147483647, it is interpreted as a packed number. Example: DATA int TYPE i. int = 1000000000 / 300000000 * 3. "result: 9 int = 10000000000 / 3000000000 * 3. "result: 10

(C) SAP AG

BC401

13

2.14 Predefined ABAP Types for Character Strings

Type t

Type d

Type n

Time

Date

6 digits HHMMSS

8 digits 1 .. 65535 YYYYMMDD characters

Description

Length

Value range

Calculations

Formatting options

By clock

Time arithmetic HH:MM:SS

Type c

Sequence FixedFixed-length of digits char. string

By Gregorian calendar

Date arithmetic

Digits

Conversion

1 .. 65535 characters

Type string Char. string of variable length Variable

Depends on codepage Conversion

Conversion

Based on user default values

 SAP AG 2002

The value range of each string depends on the code page, which contains all the supported characters in form of a table. Internally, each character is represented by a code number. When the system outputs the character, it uses the code page to convert this number. To find the code page valid in a given system, choose Tools → CCMS → Spool Administration → Full Administration → Character Sets. The initial value of each character string with fixed length is a space character. Numeric strings are represented internally as character strings. Note, however, that only digits are permissible as characters. When character strings are assigned to numeric strings, the system ignores letters and only copies the digits (right-aligned). Missing characters are filled with zeros. The initial value of each character in a numeric string is a zero. Only sequences of digits are valid for values of type d. These digits form a meaningful date, which complies with the Gregorian calendar. The first four digits represent the year, the next two the month and the last two the date. For performance reasons however, the object is only checked if it is an input field on a screen or selection screen. The initial value of a date is '000000'. The formatting options are determined by the user settings. For values of type t, a sequence of digits is only valid if it can be interpreted as a time on the 24-hour clock. The rules for interpreting the value are analogous to those used for dates. The initial value of a time is '000000'.

(C) SAP AG

BC401

14

2.15 Overview: Character String Processing Description and notes Found: sy-subrc = 0

FIND

B

?

ABAP

Search in a character string Position of search string using MATCH OFFSET off addition

REPLACE

ABAP

BBAP

Replace first occurrence

TRANSLATE

ABAP

a b ap

Replace all occurrences

SHIFT

ABAP AP AB P

BAP AP

Move

CONDENSE OVERLAY

ABAP

Overwrite : Spaces are overwritten by characters from the second character string

A B +A P

ABAP

Concatenate several character strings

ABCAP

AB

Split a character string

AAAA CONCATENATE SPLIT

Remove space characters

AP

 SAP AG 2002

Note for FIND statement (search in a character string): There are special comparison operators for strings, which you can use in logical expressions in a query (IF) to search more flexibly for character sequences in a character string. For more information, see the keyword documentation for IF. For every statement, the operands are treated like type c fields, regardless of their actual field type. No internal type conversions take place. All of the statements apart from TRANSLATE and CONDENSE set the system field sy-subrc. (SEARCH also sets the system field sy-fdpos with the offset of the character string found.) All of the statements apart from SEARCH are case-sensitive. To find out the occupied length of a string, use the standard function STRLEN(). For the SPLIT statement there is the variant SPLIT ... INTO TABLE , which you can use to split the character string dynamically. You do not need to specify the number of parts into which the string should be split.

(C) SAP AG

BC401

15

2.16 Accessing Parts of Fields

+() ...

Possible with any character-type field

REPORT ... PARAMETERS: pa_str(40) LOWER CASE, pa_pos TYPE i, pa_len TYPE i. +pa_ WRITE pa_str+pa_pos(pa_len). pa_pos( pos(pa_ pa_len) len)

19991231ttA235959

000000

 SAP AG 2002

In any statement that operates on a character-type field, you can address part of the field or structure by specifying a starting position and a number of characters. If the field lengths are different, the system either truncates the target or fills it with initial values. The source and target fields must have the type x, c, n, d, t, or STRING. You can also use structures. Example MOVE +() TO +(). This statements assigns characters of field starting at offset to characters of starting at offset .

(C) SAP AG

BC401

16

2.17 Data Types and Data Objects in Detail (3)

Introduction Introduction Elementary Elementary Data Data Objects Objects Structures Structures Special Special Features Features in in Unicode Unicode

 SAP AG 2002

(C) SAP AG

BC401

17

2.18 Defining Structures with Local Types Definition of a structure type

TYPES: TYPES: BEGIN OF s_name_type s_name_type, prename(25) TYPE c, surname(25) TYPE c, title(5) TYPE c, END OF s_name_type.

Definition of a structure with implicit type construction

DATA: BEGIN OF s_name, s_name prename(25) TYPE c, surname(25) TYPE c, title(5) TYPE c, END OF s_name s_name.

Definition of a structure with reference to a user-defined type

DATA: s_name_type . s_name TYPE s_name_type Alternatives

START-OF-SELECTION. s_name-prename = 'Smith'. s_names_name-surname = 'John'. s_name SAP AG 2002

As with elementary data objects, you can define structures in two ways: First, define a structure type explicitly using the TYPES statement. To do this, enter the name of the structure after BEGIN OF and then list the definitions of all the components. End the definition of the structure type using END OF. You then define the structured data object with the DATA statement, using your own user-defined structure type. Define the data object directly using the DATA statement. The syntax is similar to the definition of a structure type. If you use this option, the corresponding structure type is defined implicitly at the same time. In both cases, the type is defined locally. Bear in mind that you can also use globally defined types instead. You address components of structures using: structure_name-comp_name. For this reason, you should avoid using hyphens in variable names.

(C) SAP AG

BC401

18

2.19 Defining Nested Structures with Local Types TYPES: BEGIN OF s_name_type, s_name_type prename(25) TYPE c, surname(25) TYPE c, title(5) TYPE c, END OF s_name_type.

Structure type s_name_type prename surname title

DATA: BEGIN OF s_address, name TYPE s_name_type s_name_type, street(15) TYPE c, city(25) TYPE c, END OF s_address.

Nested structure s_address name prename surname title street city

s_address-name-surname = 'Smith'. s_address-city = 'London'. -

Application: Logical subgrouping of data

 SAP AG 2002

You can define nested structures by assigning a structure type to a component within a structure type. You can address this substructure as a whole using the component name: structure_name-substructure_name. You can also address individual components in the substructure: structure_name-substructure_name-comp_name. Structures can be nested to any level you wish. You can also integrate components of a dynamic type in a structure. This can either be an elementary data object of variable length (string or xstring),an internal table, or a reference. These structures are known as deep structures. There are constraints on how such deep structures can be used. For instance, a deep structure cannot be used as a whole in the INTO clause of the SELECT statement. (Instead, each component must be listed separately). Offset operations are also not appropriate. For more information, refer to SAP Note 176336.

(C) SAP AG

BC401

19

2.20 Using Named Includes Structure type

DATA: BEGIN OF t_linetype, s_name_type prename(25) TYPE c, surname(25) TYPE c, title(5) TYPE c, END OF s_name_type.

s_name_type prename surname title

DATA BEGIN OF s_address. INCLUDE INCLUDE STRUCTURE STRUCTURE s_name_type AS name. DATA: street(15) TYPE c, city(25) TYPE c, END OF s_address. s_address-name-surname = 'Smith'. * or: s_address-surname = 'Smith'.

Structure with named include s_address prename surname title street city

name

Use: Logical subgroup desired, but nested structures not technically possible

 SAP AG 2002

In some cases, you cannot use nested structures, for example: Because you can only define database tables with flat line types In situations where user dialogs with a table-type display can only contain simple structures (such as in the SAP List Viewer or Table Control) In situations like these, you may still want to group parts of the structure and address it as a whole. You do this using named includes: You can include a substructure in another structure, and give this substructure a name: DATA: BEGIN OF structure_name, ... . INCLUDE STRUCTURE substructure_type AS name. DATA: ... , END OF structure_name. You can address this substructure using structure_name-name. You can address the fields in the substructure using structure_name-name-comp_name or directly using structure_namecomp_name. Technically, however, this structure is not nested. If naming conflicts occur - for example, if you want to include the same substructure twice - you can append another name to the component names using RENAMING. For further information, refer to the keyword documentation for the INCLUDE STRUCTURE statement.

(C) SAP AG

BC401

20

2.21 Data Types and Data Objects in Detail (4)

Introduction Introduction Elementary Elementary Data Data Objects Objects Structures Structures Special Special Features Features in in Unicode Unicode

 SAP AG 2002

(C) SAP AG

BC401

21

2.22 Unicode: Overview

Previous problems Mixture of different incompatible character sets in one central system Data exchange between systems with incompatible character sets

a Solution: Unicode

a Unicode

й S

‫ق‬

ONE codepage that comprises all known characters Every character is generally displayed by two bytes

ю  SAP AG 2002

To be able to work with Unicode, you must have a Unicode-compatible SAP System installed that itself has a corresponding operating system and database. The ABAP programs must also be Unicodecompatible. In Unicode programs, other syntax rules apply than in non-Unicode programs. This is due to the difference between the length in bytes and the number of characters in a character set in Unicode. Existing programs are affected by a conversion to Unicode if an explicit or implicit assumption is made about the internal length of a character. To execute the relevant syntax checks, you must check Unicode Checks Active under program attributes. In a Unicode system, you can only execute programs that have the Unicode flag set. If the Unicode flag is set for a program, the syntax check and program are executed in accordance with the rules described in the Unicode online help (irrespective of whether it is a Unicode or a non-Unicode system). If the Unicode flag is not set, the program can only be executed in a non-Unicode system. For such programs, the Unicode-specific changes of syntax and semantics do not apply. However, you can use all language enhancements introduced in connection with the conversion to Unicode.

(C) SAP AG

BC401

22

2.23 Character-Type and Byte-Type Types

Character-type types in Unicode programs byte-type Only components with the types c, n, d, and t

d c t

n

Character-type structure types

xstring

x

string

Difference between byte processing and character processing c_field

DATA: c_field(4) TYPE c VALUE 'HUGO', x_field(4) TYPE x VALUE 'E391B9A2'.

H

SHIFT c_field BY 2 PLACES [IN CHARACTER MODE]. SHIFT x_field BY 2 PLACES IN BYTE MODE.

G

U

x_field G

O E391B9A2

O

_

_ B9A20000

 SAP AG 2002

In Unicode programs, the following data types are interpreted as character-type: c, n, d, t, string as well as structure types, that directly or in substructures only contain components with types c, n , d and t. In non-Unicode systems, a character of this type is one byte and in Unicode systems, it is as long as corresponds with the length of a character on the relevant platform. Variables of the types x and xstring are described as byte-type. The character string processing (for which, previously, all arguments were implicitly interpreted as type c fields) is separated into string processing for character-type and byte-type arguments. In the case of the string processing for character-type arguments, the single fields must be type c, n, d, t, or string; character-type structures are also permitted. If arguments of another type are transferred, this triggers a syntax or runtime error. The X variants of the string statement are distinguished from the character string commands by the IN BYTE MODE addition. For the character string variants, IN CHARACTER MODE is an optional addition. If the IN BYTE MODE addition is specified, only X fields and X strings are permitted as arguments. If arguments of another type are transferred, this triggers a syntax or runtime error.

(C) SAP AG

BC401

23

2.24 Functions and Comparison Operators Length in bytes

Length in characters Character-type type

Functions

STRLEN STRLEN

Byte-type type

XSTRLEN BYTE-CO, BYTE-CA,

Comparison operators

CO, CA, CS, CP, CN, NA, NS, NP

BYTE-CS, BYTE-CN, BYTE-NA, BYTE-NS

Examples: DATA: c_fld1(4) TYPE c VALUE 'HUGO', c_fld2(1) TYPE c VALUE 'G'. IF c_fld1 CA c_fld2. ... ENDIF.

DATA: x_field(4) TYPE x VALUE 'E391B9A2', len TYPE i. len = XSTRLEN( x_field ).

 SAP AG 2002

The operators CO, CN, CA, NA, CS, NS, CP, NP are available for comparing the contents of character string type data objects (for syntax and semantics, see keyword documentation). As with the statements for string processing, these operators require single fields of type c, n, d, t, or string as arguments. Again, character-type structures are also permitted. The X variants of the string comparison operators are distinguished from the character string variants by the BYTE- prefix. For this operation, only X fields and fields of the type xstring are allowed as arguments. The STRLEN function only works with character-type fields and returns the length in characters. With c fields, only the so-called occupied length is relevant, that is, unlike with strings, trailing blanks are not counted. The XSTRLEN function is available for the length of byte sequences. For X strings, XSTRLEN returns the current length and for X fields, the defined length in bytes, where null bytes at the end of fields are counted.

(C) SAP AG

BC401

24

2.25 Compatibility and Conversion

MOVE a TO b. b = a.

When are two types compatible? Two elementary types are compatible when they have exactly the same type and length (and, in the case of packed numbers, the same number of decimal decimal places places ). Two structure types are compatible when they have the same same structure structure and their components components are are compatible .

Two table types are compatible if their row types are compatible compatible and their key key definitions definitions and table types are the same.

No conversion takes place if type-compatible data objects are assigned If non-type-compatible data objects are assigned, conversion does take place if a conversion rule is defined

 SAP AG 2002

If two data types are not compatible but there is a conversion rule, the system converts the source object into the type of the target object when you assign values, perform calculations, or compare values. For a full list of all conversion rules, refer to the ABAP syntax documentation for the MOVE statement. If there is no conversion rule defined for a particular assignment, the way in which the system reacts depends on the program context. If the types of the objects involved are defined statically, a syntax error occurs. Example: DATA: date TYPE d VALUE '19991231', time TYPE t. FIELD-SYMBOLS: TYPE d, TYPE t. ASSIGN: date TO , time TO . = . In the case of dynamic typing a runtime error occurs, because the field symbols are not assigned types until the assignment of the data objects at runtime. Example: ... FIELD-SYMBOLS: TYPE ANY, TYPE ANY. ... (Rest as above) (C) SAP AG

BC401

25

2.26 Conversion Under Unicode (1) Conversion between flat structures MOVE struc1 TO struc2.

struc1 C(6)

Under what condition is this assignment possible?

N(4)

X(3)

N(4)

I

C(3) C(3) X(3)

C(4)

I

C(4)

I

P(8)

struc2 C(4)

struc1

Decisive criterion: Fragment view

struc2

Assignment is possible ⇐

C(10)

X(3)

P(8)

Conversion between flat structures is possible if the fragments of the source and target structures match both in type and length in the length of the shorter structure.

 SAP AG 2002

For some data types there are, for technical reasons, specific alignment requirements that depend on the individual platforms. (In the memory, fields of this type must begin and end on specific addresses - for example, a memory address divisible by four.) Within a structure, the runtime system, if necessary, inserts bytes before or after these components with alignment requirements to achieve the alignment needed. These bytes are known as Alignment. To check whether the conversion is even permitted, the system first creates the Unicode fragment view of the structures by grouping adjacent components and alignment gaps (one group each for charactertype types [c, n, d, t], byte-type types, and types i, f, and p). Adjacent character-type components of a structure are therefore only grouped together if there are no alignment gaps between these components. Adjacent byte-type components are grouped in the same way. If the fragments of the source and initial structures match the type and length in the length of the shorter structure, the conversion is allowed. If the target structure is longer than the source structure, the character-type components of the remainder are filled with space characters. All other components in the remainder are filled with the type-specific initial value, alignment gaps are filled with null bytes.

(C) SAP AG

BC401

26

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF