Sunday, August 2, 2020

OOABAP CLASS SIMPLE EXAMPLE (CLASS 1)

*&---------------------------------------------------------------------*
*& Report  ZOOABAP_CL1
*& Developed by : Sourav
*&---------------------------------------------------------------------*
*& test class 1 for simple ooabap 1
*&
*&---------------------------------------------------------------------*
REPORT ZOOABAP_CL1.
class lcl_abc DEFINITION.
 public SECTION.
  data x type i. "instance attr
  class-data y type i. "static attr
endclass.
write :/ 'Static attr y is ',lcl_abc=>y.
lcl_abc=>y = 20.
write :/ 'Static attr y is ',lcl_abc=>y.
format color 5.
write :/ 'First Object ob1...'.

data ob1 type ref to lcl_abc. "reference / alias for class
create object ob1.
write :/ ob1->x,ob1->y.

ob1->x = 10.
ob1->y = 15.
write :/ ob1->x,ob1->y,lcl_abc=>y.

uline.
format color 7.
write :/ 'Second Object ob2...'.

data ob2 type ref to lcl_abc. "reference / alias for class
create object ob2.
write :/ ob2->x,ob2->y.