By

NEW Instance Operator

Description:

A constructor expression using the NEW operator creates either an anonymous data object or an instance of a class.

  • The result is a reference variable that refers to the newly created object.
  • The following options can be specified for the type:
    • A non-generic data type.
      • The NEW operator functions similarly to the statement CREATE DATA dref TYPE dtype.
    • A Class
      • The NEW operator behaves the same way as the statement CREATE OBJECT oref TYPE class.
    • The # character.

Syntax:

NEW type( ... ) ...

Example:

DATA(lo_cls) = NEW class_name( ).

Thanks for visiting!

Sangeeta Singh

Leave a Reply

Discover more from HANAxABAP

Subscribe now to keep reading and get access to the full archive.

Continue reading