Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Obsolete Language Elements →  Obsolete modularization →  Subroutines →  FORM 

FORM - STRUCTURE

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

... STRUCTURE struc ...

Effect

For a formal parameter p1 p2 ... of a subroutine, the STRUCTURE addition can also be specified instead of typing, whereby struc is a local program structure (a data object, not a data type) or a flat structure from the ABAP Dictionary. This structure is then applied to the formal parameter (Casting) and individual components can be accessed in the subroutine.

When an actual parameter is passed to a formal parameter typed with STRUCTURE, non- Unicode programs are only checked to determine whether the length of the actual parameter is at least the same as the length of the structure.

In Unicode-programs, structured and elementary actual parameters are distinguished. For a structured actual parameter, its Unicode fragment view must match that of struc. For an elementary actual parameter, this must be character-type and flat.


Note

Formal parameters typed with STRUCTURE can normally be replaced by formal parameters typed with TYPE or LIKE. If casting is to be carried out, we recommend that you use generic formal parameters and assign these to a field symbol with the ASSIGN statement and CASTING addition.


Example

In this example, the line structure is assigned to the text character string.

DATA: BEGIN OF line, 
        col1 TYPE c LENGTH 1, 
        col2 TYPE c LENGTH 1, 
      END OF line. 

DATA text LENGTH 2 TYPE c VALUE 'XY'. 

PERFORM demo USING text. 

FORM demo USING p STRUCTURE line. 
  WRITE: p-col1, p-col2. 
ENDFORM.