Ansicht
Dokumentation

ABENTYPE_CHECKING - TYPE CHECKING

ABENTYPE_CHECKING - TYPE CHECKING

Fill RESBD Structure from EBP Component Structure   PERFORM Short Reference  
This documentation is copyright by SAP AG.
SAP E-Book

Typing Formal Parameters and Field Symbols

Formal parameters in FORM and FUNCTION, and field symbols (FIELD-SYMBOLS) may be typed in ABAP. To do so, you use the ... TYPE dataType or ... LIKE dataObject additions to specify a type.

Typed formal parameters and field symbols make programs safer, and easier to understand and maintain. They also allow the ABAP generator to generate optimized intermediate code, thus improving the performance of your programs.

If a formal paramter or field symbol is typed, the syntax check (if possible), or the runtime environment will check whether the actual parameter and formal parameter are compatible.

Typing with Complete Types

Compatibility in this context means that the two objects have the same technical type. Two types are compatible if they have exactly the same technical attributes.

The technical attributes of a simple field are its elementary data type and the field length (in the case of type P fields, the number of decimal places as well). These are considered in the type check. The conversion exit and help ID are not. Note that the types STRING and C as well as XSTRING and X, are not compatible.

In structures, the form of the structure is considered in addition to the component types. Two structures may have the same sequence of elementary components, but if that sequence is divided into substructures in different ways in the two structures, they are not compatible in the sense of the technical ABAP type check.

Two internal tables are compatible if their line types are compatible. The OCCURS value is not considered in the type check.

Typing with Generic Types

A formal parameter or a field symbol can be typed incompletely by choosing a generic type which restricts the type of the actual parameter or runtime type to a subset of specific runtime types. Generic type specifications can be performed as follows.

The type ANY allows all generic and elementary types.

The following generic types make a restriction to the elementary runtime types.

  • SIMPLE: Allows all types which are permitted by the generic types CLIKE, XSEQUENCE, or NUMERIC
  • CLIKE: Allows all types which are permitted by the generic types CSEQUENCE and N as well as the elementary types D and T and also structures which (directly or indirectly in substructures) contain only components of the types C, N, D, or T. In non-Unicode programs, the generic type XSEQUENCE and all generic and elementary types contained therein are allowed additionally, and besides the components of the above structures, the types X and XSTRING are also allowed.
  • CSEQUENCE: Allows all types permitted by the generic type C as well as type STRING
  • XSEQUENCE: Allows all types permitted by the generic type X as well as type XSTRING
  • NUMERIC: Allows the generic type P, the elementary types I and F as well as the Data Dictionary types INT1 and INT2
  • C, N, X: Allows all types C, N, X with a length between 1 and 32767
  • P: Allows all types P with a length between 1 and 16 and with decimal places from 0 to 14

The following generic types make a restriction to the types of internal tables.

  • ... TYPE TABLE allows you to mark a formal parameter or a field symbol as a table parameter or table symbol for any internal table.
  • ... TYPE [ANY|INDEX|STANDARD|SORTED|HASHED] TABLE is used to accept tables of the table type specified which are compatible with the access hierarchy. The line type of the actual parameter can be chosen as required.

The following overview shows all ways of generic typing.


                                           +---I,INT2,INT1
                   +-----------NUMERIC-----+---P
                   |                       +---F
                   |
                   |                       +---X
      +---SIMPLE---+-----------XSEQUENCE---+---XSTRING
      |            |
      |            +---CLIKE-+-CSEQUENCE---+---STRING
ANY---+                      |             +---C
      |                      |
      |                      |             +---N
      |                      +-------------+---D
      |                                    +---T
      |                                    +---STRUC(C,N,D,T)
      |
      +---TABLE



Other Comments on Typing with Generic Types

If a formal parameter or a field symbol is not typed or not typed completely, the formal parameter inherits the type attributes of the actual parameter. However, if a complete typing was made, the formal parameter always has the type attributes specified through typing.

In other words, this means that concerning the type attributes not considered by the type check (such as conversion exit and help ID) and which can therefore be different even for compatible actual and formal parameters,

  • the actual parameter takes priority in case of missing or incomplete typing, and
  • the formal parameter takes priority in case of complete typing.





CPI1466 during Backup   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 8439 Date: 20240425 Time: 132709     sap01-206 ( 101 ms )