Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Obsolete Language Elements →  Obsolete Modularization →  Subroutines →  FORM 

FORM - STRUCTURE

Quick Reference

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

... STRUCTURE struc ...

Effect

A formal parameter p1 p2 ... of a subroutine can be specified with the addition STRUCTURE instead of typing, where struc must be a program-local structure (data object, no data type) or a flat structure from 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 using STRUCTURE, the actual parameter must be at least as long as the formal parameter:

  • In the case of a structured actual parameter, its fragment view must match the fragment view of the corresponding initial part of struc.
  • An elementary actual parameter must be character-like and flat and the corresponding initial part of struc can contain only components of this type.


Note

Formal parameters typed with STRUCTURE can usually be replaced by formal parameters typed with TYPE or LIKE. If a casting is necessary, generic formal parameters should be used and assigned to field symbols using the statement ASSIGN and the addition CASTING.


Example

This example assigns the character string text the structure line.

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. 
  cl_demo_output=>display_data( p ). 
ENDFORM.