Posts

Showing posts with the label constructors

Local constructors in ABAP.

Image
Introduction to constructors -  Introduction to constructor Creation of Global constructor -  Global 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   a  DEFINITION .    PUBLIC  SECTION .      METHODS :  constructor .      CLASS-METHODS :  class_constructor . ENDCLASS . CLASS   a  IMPLEMENTATION .    METHOD  constructor .      WRITE :  /  'Instance constructor' .    ENDMETHOD .    METHOD  class_constructor .      WRITE :  /  'Static constructor' .    ENDMETHOD . ENDCLASS . START-OF-SELECTION .    DATA :  obj  TYPE  REF  TO  a .    CREATE  OBJECT obj .    ...

Create global constructors in ABAP

Image
Once Refer- Introduction to constructors Steps to create global constructor in ABAP. 1. Goto  SE24. 2. Give  class name  and click on  create  and  give short description  and click on save. 3. Click on constructor it is instance constructor and click on class_constructor it is static constructor . 4. Double click on constructor and write code and save.             METHOD  constructor .           WRITE :  /  'Instance constructor called' .         ENDMETHOD . 5. Double click on class_constructor and write code.             METHOD  class_constructor .           WRITE :  /  'static constructor called' .         ENDMETHOD . 6. Check and activate and execute . ******************************** Thank You ***** ********...

Introduction to constructors in ABAP

  Constructors:          *  Constructor is a special type of method which is executed automatically when an object is created.          * Constructor  cannot be called using CALL METHOD.          *  Constructors are methods with a predefined name.         * Multiple CONSTRUCTOR and CLASS_CONSTRUCTOR are not allowed with in a class.   Types of constructors: * There are two types of constructors . * Instance constructor.     - Method name - CONSTRUCTORS.     - It has only imported  parameters.     - It can access  both instance and static attributes.     - It is called every time when object is created. * Static constructor.      - Method name - CLASS_CONSTRUCTORS.     - It does not have any parameters.     -  It can access  static attributes.   ...