Ansicht
Dokumentation

ABAPINCLUDE_TYPE - INCLUDE TYPE

ABAPINCLUDE_TYPE - INCLUDE TYPE

BAL Application Log Documentation   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

INCLUDE, TYPE, STRUCTURE

Short Reference



Syntax

INCLUDE { {TYPE struc_type} | {STRUCTURE struc} }
        [AS name [RENAMING WITH SUFFIX suffix]].


Additions

1. ... AS name

2. ... RENAMING WITH SUFFIX suffix

Effect

This statement can only be executed within a structure definition with the additions BEGIN OF and END OF of the statements TYPES, DATA, CLASS-DATA, and STATICS. It includes all components of a structured type at this position in the current structure definition. The structured type can be specified as follows:

  • As a structured data type struc_type after TYPE, both visible and usable at this position. struc_type can be a local structured type, a visible structured type of a global class or global interface, or a structure from ABAP Dictionary.
  • As a structured data object struc after STRUCTURE, visible at this position. Its structured data type is used. struc must be a structure of the same program or a visible attribute of a global class or global interface.

The INCLUDE statement does not create a substructure, which means the components are inserted as if they were listed individually instead of the statement INCLUDE.

Notes

  • The statement INCLUDE described here should no longer be used for the following reasons:
  • If the statement INCLUDE is used to add more structure components to existing components, or if multiple INCLUDE statements are used in a structure, this can produce syntax errors due to naming conflicts. This is particularly problematic if structures are included that are not defined in the same program and that are subsequently changed.

  • The included structures cannot be addressed as such without restrictions.

  • The necessary metadata is stored again for each component of an included structure, whereas the metadata for the components of a substructure is only stored once when the substructure is defined.

  • In contrast to real substructures, structures included using INCLUDE cannot be declared as static boxes when embedded.

Where possible, real substructures should be created instead of the statement INCLUDE. However, the addition RENAMING WITH SUFFIX should be used to avoid naming conflicts. This recommendation also applies to includes of structures in ABAP Dictionary, where the structures of database tables particularly cannot contain any real substructures.
  • As usual, the addition TYPE is used to specify a data type. Like the addition LIKE, the addition STRUCTURE is used to specify a data object. Outside of ABAP objects, flat structures, database tables, or views of the ABAP Dictionary can also be specified for struc with the addition STRUCTURE.
  • In constant structures defined with CONSTANTS, no components can be included using INCLUDE because it is not possible to assign a start value to them.
  • In regard to their alignments, structures included using INCLUDE behave like substructures, which means alignment gaps can occur before the first or after the last component. These do not occur when the components are declared directly.
  • A structure that is included using INCLUDE is handled by the method GET_COMPONENTS of the class CL_ABAP_STRUCTDESCR of RTTI like a substructure. The returned component table only contains one line for an included structure. The component type is represented by an object from CL_ABAP_STRUCTDESCR, but the AS_INCLUDE column contains the value "X". The method GET_INCLUDED_VIEW_TAB can be used to resolve components of included structures.
  • When a static box is inherited by one structure from another, its boxed component property is also inherited.

Addition 1

... AS name

Effect

By specifying the name name after the addition AS, the components of the included structure struc_type or struc become a component group also known as named include. Besides regular addressing using the name of the including structure, they either can be addressed together using the name name or as individual components using the structure component selector (name-). The name name must be unique within the structure into which the components are included. This means that there must not be any other component with this name and it must not be specified in a different INCLUDE statement after AS.

Notes

  • Included components for which a name is specified after AS, can be addressed in the same way as if they were components of a substructure name.
  • A name name specified with AS name is used only for an additional explicit addressing option and is ignored by an implicit addressing in statements such as MOVE-CORRESPONDING or SELECT INTO CORRESPONDING. A component renamed using RENAMING WITH SUFFIX actually has this name and is therefore never ignored.

Addition 2

... RENAMING WITH SUFFIX suffix

Effect

The addition RENAMING WITH SUFFIX is used to rename each individual component by appending the extension suffix, which prevents naming conflicts between components with the same name. suffix must be specified directly.

Notes

  • The use of the RENAMING WITH SUFFIX addition makes it possible to include an individual structure multiple times.
  • Renaming the components of included structures can prevent errors during an upgrade of these structures.

In this example, the structure week is defined by repeated transfer of the components of the structured type t_day. The components of week are all at the same level and can be addressed as follows: week-work_mon, week-free_mon, week-work_tue, and so on. Alternatively, they can also be addressed as follows: week-monday-work, week-monday-free, week-tuesday-work, and so on.








General Material Data   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 9587 Date: 20240329 Time: 132248     sap01-206 ( 158 ms )