Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Assignments →  Assignment and Conversion Rules →  Conversion Rules for Structures 

Conversion Between Flat Structures and Single Fields

The following rules apply when converting a flat structure to a single field and vice versa:

  • If a structure is character-like only, it is handled in the conversion like a data object of the type c (casting). The single field can have any elementary data type except an enumerated type.
  • If the structure is not character-like only, the single field must have the type c and the structure must begin with a character-like fragment that is at least as long as the single field. The assignment takes place only between this fragment and the single field. The character-like fragment of the structure is handled like a data object of the type c (casting) in the assignment. If the structure is the target field, the remaining character-like fragments are filled with blanks and all other components with the type-dependent initial value.

No conversion rule is defined for any other cases, and assignments are not possible.

Other versions: 7.31 | 7.40 | 7.54


Note

If a syntax error occurs due to an invalid assignment between flat structures and single fields, the fragment view of the corresponding structure can be displayed when displaying the syntax error in ABAP Editor by choosing the pushbutton with the information icon.


Example

Conversion of the character-like system field sy-abcde to a flat structure of character-like components. After this, each component contains a letter.

TYPES: 
  BEGIN OF characters, 
    a TYPE c LENGTH 1, 
    b TYPE c LENGTH 1, 
    c TYPE c LENGTH 1, 
    d TYPE c LENGTH 1, 
    e TYPE c LENGTH 1, 
    f TYPE c LENGTH 1, 
    g TYPE c LENGTH 1, 
    h TYPE c LENGTH 1, 
    i TYPE c LENGTH 1, 
    j TYPE c LENGTH 1, 
    k TYPE c LENGTH 1, 
    l TYPE c LENGTH 1, 
    m TYPE c LENGTH 1, 
    n TYPE c LENGTH 1, 
    o TYPE c LENGTH 1, 
    p TYPE c LENGTH 1, 
    q TYPE c LENGTH 1, 
    r TYPE c LENGTH 1, 
    s TYPE c LENGTH 1, 
    t TYPE c LENGTH 1, 
    u TYPE c LENGTH 1, 
    v TYPE c LENGTH 1, 
    w TYPE c LENGTH 1, 
    x TYPE c LENGTH 1, 
    y TYPE c LENGTH 1, 
    z TYPE c LENGTH 1, 
  END OF characters. 

cl_demo_output=>display( CONV characters( sy-abcde ) ).