Local constructors in ABAP.

Introduction to constructors - Introduction to constructor

Creation of Global constructorGlobal constructor

1. Goto SE38.

2. Give program name and click on create.

3. Give title and click on save.

4. Write code.

REPORT zab_rp_constructors.

CLASS DEFINITION.
  PUBLIC SECTION.
    METHODSconstructor.
    CLASS-METHODSclass_constructor.
ENDCLASS.
CLASS IMPLEMENTATION.
  METHOD constructor.
    WRITE'Instance constructor'.
  ENDMETHOD.
  METHOD class_constructor.
    WRITE'Static constructor'.
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  DATAobj TYPE REF TO a.
  CREATE OBJECT obj.
  ULINE.
  CREATE OBJECT obj.

5. Activate and execute.

Output


**********************Thank You**********************

Comments

Popular posts from this blog

New syntax for append- VALUE (new syntax 7.4+) in ABAP

Read statement new syntax in ABAP. (7.4+).

Concatenation new syntax( 7.4+ ).