Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

class

Former Member
0 Kudos
129

Hi ,

Can anybody give some example of creating a local class which should have methods and events.

Regds,

khadeer.

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos
84

Go to SE38 and look at DEMO_ABAP_OBJECTS. This program demonstrates, objects and object references, inheritance, interfaces and event.

enjoy

5 REPLIES 5

Former Member
0 Kudos
84

This message was moderated.

Former Member
0 Kudos
84

Hi,

Check this link

Regards

Abhijeet

Former Member
0 Kudos
84

Hi...

this is a very simple program, which will just let you know the logic of the processing.. hope it helps, and later you can add on to this....

----


  • CLASS c1 DEFINITION

----


*

----


class c1 definition.

public section.

methods : m1, m2.

events : e1.

endclass. "c1 DEFINITION

----


  • CLASS c1 IMPLEMENTATION

----


*

----


class c1 implementation.

method m1.

write : /'simple method executed'.

endmethod. "m1

method m2.

write : /'before raising the event'.

raise event e1. " event raised.

write : /'after the event'.

endmethod. "m2

endclass. "c1 IMPLEMENTATION

----


  • CLASS cl_events DEFINITION

----


*

----


class cl_events definition.

public section.

methods : m_event for event e1 of c1.

endclass. "cl_events DEFINITION

----


  • CLASS cl_events IMPLEMENTATION

----


*

----


class cl_events implementation.

method m_event.

write : /'the event handler method.....'.

endmethod. "m_event

endclass. "cl_events IMPLEMENTATION

data: oref type ref to c1, oevent type ref to cl_events.

start-of-selection.

create object oref.

create object oevent.

set handler oevent->m_event for all instances.

oref->m1( ).

oref->m2( ).

narin_nandivada3
Active Contributor
0 Kudos
84

Hi Khadeer,

Please check this link

http://www.erpgenie.com/abap/OO/eg.htm

For more please check this thread

Check this pdf as well

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/0a33479c-0b01-0010-7485-dc8c09d6...

Hope this would help you.

Good luck

Narin

matt
Active Contributor
0 Kudos
85

Go to SE38 and look at DEMO_ABAP_OBJECTS. This program demonstrates, objects and object references, inheritance, interfaces and event.

enjoy