Structures - ABAP Keyword Documentation (2024)

SAP NetWeaver AS ABAP Release 752, ©Copyright 2017 SAP AG. All rights reserved.

ABAP - Keyword Documentation→ABAP - Reference→Processing Internal Data→

Structures

Structures are data objects (comprised of components of any data type) that are saved in sequence in the memory. The data type of a structure is astructured type or a structure defined in theABAP Dictionary.

In a program, a structured type or structure is created using the additions BEGIN OF ... END OF additions of the statements TYPES, DATA etc. They can also be created dynamically usingRTTC methods. Im ABAP Dictionary, structures appear asstandalone data types, as types ofdatabase tables, ofclassic views or of CDS entities.

  • Types of Structures
  • Using Structures
  • Using Deep Structures
  • Using Deep ABAP Dictionary Structures
  • Boxed Components

Programming Guidelines

  • Names of structure components
  • Do not include components from structures

Types of Structures

Structures are named as follows (depending on the type of the component):

  • Flat structures do not contain anydeep components. They only containcomponents with flat data types, such as elementary types c, n,d, t, decfloat16, decfloat34, f, i, int8,p, x, plus b, s (or structures with these types).
  • Flat character-like structures are flat structures that contain only character-like components.
  • Nested structures contain at least onesubstructure. A nested structure is flat or character-like, depending on the attributes of all of the components.
  • Deep structures contain at least onedeep component, at any nestinglevel. Possible deep components include strings, internal tables, boxed components, data references, or object references.

A structure that contains static or dynamic components is (formally) astatic ordynamic data object, respectively.

The following figure illustrates a deep structure.

Structures - ABAP Keyword Documentation (1)

Note

The term "nested structure" must not be confused with the term "deep structure". A nested structureis flat if it only contains flat components and subcomponents. A nested structure is deep when it has at least one deep component or subcomponent.

Example

Nested structure. The substructure is created using a reference to the dictionary structure SCARR for the second component. Access to the components using the structure component selector(-).

DATA:
BEGIN OF struct,
nameTYPE c LENGTH 10 VALUE 'SCARR',
scarr TYPE scarr,
END OF struct.

SELECT SINGLE *
FROM scarr
WHEREcarrid = 'LH'
INTO CORRESPONDING FIELDS OF @struct-scarr.

cl_demo_output=>new(
)->write_data( struct-name
)->write_data( struct-scarr-carrid
)->write_data( struct-scarr-carrname
)->display( ).

Example

Deep structure The following structure contains deep components only.

DATA:
BEGIN OF struct,
text TYPE string,
hexTYPE xstring,
tabTYPE STANDARD TABLE OF i WITH EMPTY KEY,
dref TYPE REF TO i,
iref TYPE REF TO if_demo_output,
END OF struct.

Using Structures

Structures are addressed either fully or by component, at appropriate operand positions. Thestructure component selector(-) is used for the latter case. In the case of data reference variablesthat are typed as a structure, the components of the structure to which the data reference variable points are addressed using the object component selector (->).

Special conversion andcomparison rules apply to assignments that involve structures. Flat character-like structures differ in that they can be used likecharacter-like dataobjects in many operand positions and included in the generic ABAP type clike. They can be specified in almost all operand positions where elementarycharacter-like data objects are possible. The ABAP runtime environment then interprets the structureas an elementary field of the type c in the length of the structure. An exception to this are operand positions ofstring expressions and string functions.

For the assignement of structure components, there is a special statement MOVE-CORRESPONDING, a constructor operator CORRESPONDING, and a system classCL_ABAP_CORRESPONDING. The INTO clause of Open SQL also has an addition CORRESPONDING.The ASSIGN statement has a specialvariant COMPONENT OF STRUCTURE for dynamic access to stucture components.

Example

Inline-Deklaration einer Struktur wa in einer SELECT-Anweisungmit Bezug auf die Datenbanktabelle SCARR im ABAP Dictionary. Zugriff auf die Komponenten der Struktur über den Strukturkomponenten-Selektor (-). .

SELECT carrid, carrname
FROM scarr
INTO @DATA(wa).
cl_demo_output=>write( |{ wa-carrid WIDTH = 5
}{ wa-carrname }| ).
ENDSELECT.
cl_demo_output=>display( ).

Example

Erzeugung einer Struktur als anonymes Datenobjekt mit dem Typ der Datenbanktabelle SCARR im ABAP Dictionary, auf das die Datenreferenzvariable dref zeigt. Verwendung über denDereferenzierungsoperator(->*) als Zielbereich einer SELECT-Anweisung. Zugriff auf die Komponenten der Struktur über den Objektkomponenten-Selektor (->).

DATA(dref) = NEW scarr( ).

SELECT *
FROM scarr
INTO @dref->*.
cl_demo_output=>write( |{ dref->carrid WIDTH = 5
}{ dref->carrname }| ).
ENDSELECT.
cl_demo_output=>display( ).

Example

Das folgende Beispiel zeigt, dass sich eine flache Struktur mit rein zeichenartigen Komponenten sowohl wie eine Struktur als auch wie ein zeichenartiges Datenobjekt verhalten kann.

DATA:
BEGIN OF struct,
col1 TYPE c LENGTH 5 VALUE '12345',
col2 TYPE c LENGTH 5 VALUE 'abcde',
END OF struct.

cl_demo_output=>new(
)->write_data( struct
)->write_data( struct-col1
)->write_data( struct-col2
)->write_data( CONV string( struct )
)->display( ).

Using Deep Structures

The data content of deep structures is not saved in full within the memory bounds of the structure andthe deep components are instead just references to the actual data. This means that some general restrictions apply when using deep structures (unlike flat structures):

  • Deep structures must be compatible in assignments and comparisons.
  • Substring access using offset/lengths is not possible for deep structures.
  • Deep structures cannot be used as character-like data objects in operand positions and are not includedin the generic ABAP type clike. This applies in particular to structures that containstrings.
  • When data objects are cast with ASSIGN,the type, position in the type of the data object, and the position in the type of the field symbol must match for deep components in deep structures.
  • The work area of Open SQL statements cannot contain any deep components other than strings orLOB handles
  • The target or source field of the statements OPENDATASET and TRANSFER cannot be a deep structure.
  • Internal tables with a deep row type cannot be passed to a TABLES parameter in aremote function call.Deep structures can be passed to the other parameters, as long as they do not contain any reference variables.

Note

These restrictions are particularly important if single components in existing flat character-like structures are converted to strings, which makes the entire structure deep.

Example

The following two deep structures are not compatible and cannot be converted to each other.

DATA:
BEGIN OF struct1,
col1 TYPE c LENGTH 4,
col2 TYPE REF TO data,
END OF struct1,
BEGIN OF struct2,
col1a TYPE c LENGTH 2,
col1b TYPE c LENGTH 2,
col2 TYPE REF TO data,
END OF struct2.

struct1 = struct2. "syntax error

Using Deep ABAP Dictionary Structures

The same restrictions apply to deep structures defined in ABAP Dictionary as to deep structures definedin ABAP programs. Further restrictions apply only when the following language elements forbidden in classes are used (only flat ABAP Dictionary structures can be specified in classes):

  • Statement TABLES for table work areas
  • Obsolete use of LIKE instead of TYPE as a reference to data types in ABAP Dictionary withtype declarations and typings
  • Obsolete use of INCLUDE STRUCTURE
  • Obsolete forcing of a structure STRUCTURE tofield symbols or interface parameters offunction modules or subroutines

Boxed Components

The substructures of nested structures and structured components of classes or interfaces can be declared as boxed components.


This translation does not reflect the current version of the documentation.

Continue
Boxed Components
Examples of structures

Structures - ABAP Keyword Documentation (2024)
Top Articles
IS IT EASY TO GET A JOB IN DUBAI?
5 Capstone Topics on Business Administration
It's Official: Sabrina Carpenter's Bangs Are Taking Over TikTok
Craftsman M230 Lawn Mower Oil Change
Kansas Craigslist Free Stuff
Steamy Afternoon With Handsome Fernando
Puretalkusa.com/Amac
Ashlyn Peaks Bio
Owatc Canvas
Nikki Catsouras Head Cut In Half
7543460065
The Blind Showtimes Near Showcase Cinemas Springdale
Craigslist Dog Kennels For Sale
Bros Movie Wiki
Labor Gigs On Craigslist
Teenleaks Discord
Cpt 90677 Reimbursem*nt 2023
Leader Times Obituaries Liberal Ks
"Une héroïne" : les funérailles de Rebecca Cheptegei, athlète olympique immolée par son compagnon | TF1 INFO
Uktulut Pier Ritual Site
Sni 35 Wiring Diagram
Band Of Loyalty 5E
Effingham Bookings Florence Sc
Zoe Mintz Adam Duritz
Sussyclassroom
Panolian Batesville Ms Obituaries 2022
Mythical Escapee Of Crete
Mineral Wells Skyward
Malluvilla In Malayalam Movies Download
Afni Collections
Horses For Sale In Tn Craigslist
Craigslist Comes Clean: No More 'Adult Services,' Ever
By.association.only - Watsonville - Book Online - Prices, Reviews, Photos
Babydepot Registry
Ehome America Coupon Code
Appraisalport Com Dashboard /# Orders
Ippa 番号
Daly City Building Division
Mid America Irish Dance Voy
Bartow Qpublic
Www Usps Com Passport Scheduler
Rocky Bfb Asset
Is Ameriprise A Pyramid Scheme
Grand Valley State University Library Hours
Caesars Rewards Loyalty Program Review [Previously Total Rewards]
5103 Liberty Ave, North Bergen, NJ 07047 - MLS 240018284 - Coldwell Banker
Bonecrusher Upgrade Rs3
60 Days From August 16
Evil Dead Rise - Everything You Need To Know
Dmv Kiosk Bakersfield
Latest Posts
Article information

Author: Domingo Moore

Last Updated:

Views: 6319

Rating: 4.2 / 5 (73 voted)

Reviews: 80% of readers found this page helpful

Author information

Name: Domingo Moore

Birthday: 1997-05-20

Address: 6485 Kohler Route, Antonioton, VT 77375-0299

Phone: +3213869077934

Job: Sales Analyst

Hobby: Kayaking, Roller skating, Cabaret, Rugby, Homebrewing, Creative writing, amateur radio

Introduction: My name is Domingo Moore, I am a attractive, gorgeous, funny, jolly, spotless, nice, fantastic person who loves writing and wants to share my knowledge and understanding with you.