structures

4
Structures A structure (structured type) comprises components (fields). Types are defined for the components A component can refer to an elementary type (via a data element or by directly specifying the data type and length in the structure definition), another structure or a table type. A structure can therefore be nested to any depth. Structures are used to define the data at the interface of module pools and screens and to define the parameter types of function modules. The data for managing the addresses of persons can be represented as a nested structure PERSON. The structure comprises the components (structures) NAME and ADDRESS. The structure NAME comprises the components (data elements) FIRSTNAME and LASTNAME. The structure ADDRESS comprises the components (structures) STREET and TOWN. The structure STREET comprises the components (data elements) STREETNAME and HOUSENO. The structure TOWN comprises the components (data elements) ZIP and TOWNNAME. The central definition of structures that are used more than once makes it possible for them to be changed centrally. The active ABAP Dictionary then makes this change wherever required. ABAP programs or screen templates that

Upload: gerardo-lopez

Post on 14-Mar-2016

213 views

Category:

Documents


0 download

DESCRIPTION

Structures

TRANSCRIPT

Page 1: Structures

Structures  A structure (structured type) comprises components (fields). Types are defined for the components A component can refer to an elementary type (via a data element or by directly specifying the data type and length in the structure definition), another structure or a table type. A structure can therefore be nested to any depth.

Structures are used to define the data at the interface of module pools and screens and to define the parameter types of function modules.

The data for managing the addresses of persons can be represented as a nested structure PERSON. The structure comprises the components (structures) NAME and ADDRESS. The structure NAME comprises the components (data elements) FIRSTNAME and LASTNAME. The structure ADDRESS comprises the components (structures) STREET and TOWN. The structure STREET comprises the components (data elements) STREETNAME and HOUSENO. The structure TOWN comprises the components (data elements) ZIP and TOWNNAME.

The central definition of structures that are used more than once makes it possible for them to be changed centrally. The active ABAP Dictionary then makes this change wherever required. ABAP programs or screen templates that use a structure are automatically adjusted when the structure is changed (see Runtime Objects). This ensures the greatest possible consistency of the data definition, also for complex programs.

Page 2: Structures

There are Flat, nested and deep structures. A flag structure only references elementary types. A nested structure references at least one further structure, but not a table type. A deep structure references at least one table type.

In a database table, you can only include flat structures as substructures.

See also:

Creating Structures  Procedure

1. In the initial screen of the ABAP Dictionary, enter the structure name in field Data type and choose Create.

A dialog box appears in which you must select the type category.

2. Select Structure and choose .

The maintenance screen for structures appears.

3. Enter an explanatory short text in the field Short text.

You can for example find the structure at a later time using this short text.

Page 3: Structures

Carry out the following steps for all the components you want to insert in the structure.

You can also include structures, tables or views instead of individual components. The procedure here is described in Inserting an Include.

4. Enter a name in column Components.

If you want to insert the structure as an include in a transparent table at a later time, the component names may not be longer than 16 characters.

5. Enter the name of the type whose attributes should be used in the component in field Component name. You can enter any type (data element, structure or table type) here.

If you want to add components by entering the data type and length directly, choose Built-in type. You can now enter values for fields DTyp, Length, Dec.places, and Short description. With Component type you can switch back to the screen for entering references to existing types.

You can also enter a Reference Type in the Component Type field. If you enter a class, interface, or generic reference (ANY, OBJECT, or DATA) in the Component Type field, the R type field is set automatically. If you enter a reference type already defined in the Dictionary as a reference type, a blue arrow appears in the D type column.

If the type defined in the ABAP Dictionary or the built-in type is a reference type, set the indicator in the R Type column.

You can combine components with direct type definition and components that are defined by referencing an existing type as you like.

6. The

reference field and reference table must be specified for components of type CURR (currency) and QUAN (quantity).

You can make these entries on the Currency/quantity fields tab page.

7. Now maintain the foreign keys of the structure.

Proceed as when maintaining the foreign keys of a table (see Creating Foreign Keys).

8. Choose Search Help, if you want to assign a search help to a structure field that points to a data element. Enter the name of a search help in the dialog box that appears. See

Attaching a Search Help to a Table or Structure Field. 9. Save your entries once you have defined all the components of the structure.

You are asked to assign the structure a development class. You can change the development class later with Goto Change object directory entry.

10. Choose an enhancement category. For more information, see

Structure Enhancements. 11. Choose .

Page 4: Structures

Result

The structure is now activated. The runtime object of the structure is created. At activation, a log is written; it can be displayed with Utilities Activation log. If errors occurred when the structure was activated, the activation log is automatically displayed.