oops3

2
report z745oops3. Start-of-selection event and calling a method from other method class emp definition. public section. methods : m1, m2. protected section. methods m3. data : empno type i, ename(20) type c. endclass. "emp DEFINITION class emp implementation. method m1. empno = 8. ename = 'ravi' . * call method k->m3. "k is not recognized call method m3. endmethod. "m1 method m2. * write :/ me->empno,me->ename. "(or) write :/ empno,ename. endmethod. "m2 method m3. write :/ 'inside instance protected method m3' .

description

SAP OOPS

Transcript of oops3

Page 1: oops3

report  z745oops3. Start-of-selection event and calling a method from other method

class emp definition.  public section.    methods : m1,              m2.  protected section.    methods m3.    data : empno type i,           ename(20) type c.endclass.                    "emp DEFINITION

class emp implementation.

  method m1.    empno = 8.    ename = 'ravi'.*    call method k->m3. "k is not recognized    call method m3.  endmethod.                    "m1

  method m2.*    write :/ me->empno,me->ename. "(or)    write :/ empno,ename.  endmethod.                    "m2

  method m3.    write :/ 'inside instance protected method m3'.  endmethod.                    "m3endclass.                    "emp IMPLEMENTATION

start-of-selection.

  data k type ref to emp.

Page 2: oops3

  create object k.

  write :/ 'Object k.....'.  call method k->m2.  call method k->m1.  call method k->m2.*call method k->m3. "m3 cannot be called as it is protected

  uline.  data k1 type ref to emp.  create object k1.

  uline.  write :/ 'Object k1.....'.  call method k1->m2.