No definition of field groups in methods

The statement FIELD-GROUPS is not allowed in methods.

Error message in methods if the following syntax is used:

METHOD ...
  ...
  FIELD-GROUPS fg.
  ...
ENDMETHOD.

Reason:

An extract dataset currently exists only as a global object of the main program. Therefore the field groups can only be defined globally in the main program. However, the definition of the field group structure, which is generated at runtime by the statement INSERT ... INTO fg, can also be executed in methods.

Overview:

Replacement for Obsolete Statements ABAP Objects