ABAP Keyword Documentation → ABAP - Reference → Obsolete Language Elements → Obsolete modularization → Subroutines → FORM
FORM - STRUCTURE
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 with STRUCTURE
and the actual parameter is structured, its
Unicode fragment
view must match the view of struc
. An elementary actual parameter must be character-like and flat.
Notes
-
Formal parameters typed with
STRUCTURE
can usually be replaced by formal parameters typed withTYPE
orLIKE
. If a casting is necessary, generic formal parameters should be used and assigned to field symbols using the statementASSIGN
and the additionCASTING
. -
In obsolete
non-Unicode programs,
only the length of the actual parameter is checked to see if it matches at least the length of the structure.
Problems can be caused here by the missing check for closing alignment gaps, for example when the actual parameter is filled by the content of an alignment gap in a way that is not type-compliant.
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.