Application Development and Automation 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: 
Read only

OOPS text example Doubt

Former Member
0 Likes
1,308

Hi ,

I am training on OOPS which one of the concept is really trouble-shooting to understand.

In the class ...CL_SEND_BCS_EXAMPLE....

There is one Method called ASYNCHRONUS.

When i am chekcing the code inside the mehtod it has written as

TRY.

RAISE EVENT IP_OPS_METHOD~RAISE_ERROR.

ENDTRY.

i KNOW raise event is just like rasing the error which can be caught by

But when i double click..there is notjhing code it is written inside that event

I just want to know why this event is used here???

Sas

1 ACCEPTED SOLUTION
Read only

Clemenss
Active Contributor
0 Likes
1,264

Hi saslove,

I really wonder where you do what kind of training. In our ECC600 system we have no class

CL_SEND_BCS_EXAMPLE

We don't even have any method called

ASYNCHRONUS

.

Questions and answers are lot more helpful if they refer to something that exists.

Regards,

Clemens

11 REPLIES 11
Read only

Former Member
0 Likes
1,264

Hi

The event is like an exception....a traffic light....no code there , the code is in the method is triggered as soon as the event is raised

Max

Read only

0 Likes
1,264

Max my concern is the same..............

There is nothing code in the method.......what it means?

It onlyhave

method aysncronous.

try.

raise event,

endtry.

endmethod.

It means callng Method itself raise event?(Raising error )

Sas

Read only

0 Likes
1,264

As Max said, raising an event is like setting a traffic light, or running a flag up a flagpole - you have to decide within your code how you want to react to that event - and you may chose to do nothing by not implementing a handler for it.

An example of this would be the ALV grid (class CL_GUI_ALV_GRID) where when the user double-clicks on a cell, the ALV grid class raises an event "double_click" - however your report may not support drill-down or similar processing, thus you won't implement code to handle that event... actually that CL_GUI_ALV_GRID class has over 40 events, and it's rare to need to trap more than a couple of them.

Take a look at the ABAP help on "set handler" and "raise event" - both have code examples in them.

Jonathan

Read only

0 Likes
1,264

Not Satisficatory.....................

But Jonathan thanks for taking pain to explain me......Is it mean that method which doesnt have any code except the raising events is nothing but calling the the method means raising the events???

Any Hint pls?????

Regards

Sas

Edited by: saslove sap on Nov 8, 2009 3:32 AM

Read only

0 Likes
1,264

If you want an example, take a look at BCALV_TEST_GRID_EVENTS - the selection screen gives you options for turning on "listening" logic for events that the ALV grid class may raise.

Jonathan

Read only

Clemenss
Active Contributor
0 Likes
1,264

HI saslove;

I'm not on the system now. so I can't check the details.

In OO RAISE EVENT ans RAISE EXCEPTION is a big difference. If an event is raised, it will look what method of what class (instance) is registered for this event. Then this method (the 'listener') is executed.

Events are used in OO to establish the communication between instances of classes, 'notifiers' and 'listeners'.

Class-based Exceptions are raised to leave the current processing block immediately. They can (and should) be caught in a calling block.

Regards,

Clemens

Read only

Clemenss
Active Contributor
0 Likes
1,265

Hi saslove,

I really wonder where you do what kind of training. In our ECC600 system we have no class

CL_SEND_BCS_EXAMPLE

We don't even have any method called

ASYNCHRONUS

.

Questions and answers are lot more helpful if they refer to something that exists.

Regards,

Clemens

Read only

Former Member
0 Likes
1,264

Thanks Clemens...Here i go with clear example which should exists in all the Systems..

Sorry for wrong input.

Please go to class se24 class: CL_BCS.

we can see one attribute send_request.

In the method select asynchronous doube clikc we can see code :

method asynchronous.

Call method: send_request ->get_asynshronus.

Receiving

Result = Result.

endmethod.

when we double click get_asynchronous it will refer to send_request type cls_send_request_bcs.

In the method get_asynchronus we have code as below

method get_asynchronus.

state read acess.-> this is amacro

result = result.

endmethod.

MACRO.

define read

Raise event if_os_state~read_access.----


>Here is the problem what i am discussing.

end of definition.

i know ~ stands for interface ...when i check read_acess it doenst have code it doenst have paramters.it is a event.

So my point is calling asynchronous method in CL_BCS class measn Raising the event?

Sas

Read only

Former Member
0 Likes
1,264

Thanks Clemens...Here i go with clear example which should exists in all the Systems..

Sorry for wrong input.

Please go to class se24 class: CL_BCS.

we can see one attribute send_request.

In the method select asynchronous doube clikc we can see code :

method asynchronous.

Call method: send_request ->get_asynshronus.

Receiving

Result = Result.

endmethod.

when we double click get_asynchronous it will refer to send_request type cls_send_request_bcs.

In the method get_asynchronus we have code as below

method get_asynchronus.

state read acess.-> this is amacro

result = result.

endmethod.

MACRO.

define read

Raise event if_os_state~read_access.----


>Here is the problem what i am discussing.

end of definition.

i know ~ stands for interface ...when i check read_acess it doenst have code it doenst have paramters.it is a event.

So my point is calling asynchronous method in CL_BCS class measn Raising the event?

Sas

Read only

Clemenss
Active Contributor
0 Likes
1,264

Hi saslove,

sometimes it is not required to understand everything.

Method

ASYNCHRONOUS

returns

VALUE( RESULT )	TYPE OS_BOOLEAN

which is a flag that informs you if the send request of the BCS object instance is created for asynchronous (background) processing.

This

ASYNCHRONOUS

is called a functional method.

To determine the RESULT, a functional method of class

CL_SEND_REQUEST_BCS

is called: Method

GET_ASYNCHRONOUS

also returns boolean value RESULT, this is just taken from the attribute, so

result = ASYNCHRONOUS

.

This is the main function of the method.

The macro

state_read_access

raises event

READ_ACCESS

which is defined in interface

IF_OS_STATE

.

If in the class or an inherited class a handler for this event has been implemented and set for this event, this will automatically be triggered without any changes to the class.

This is what I tried to explain about the Notifier - Listener concept.

In this case to summarize: The function of Method

ASYNCHRONOUS

is just to return a flag about the processing function (SYNCHRONOUS/ASYNCHRONOUS). As a side-effect, event

READ_ACCESS

is triggered. This may be useful if any listeners are configured.

The Notifier - Listener concept is used when objects have to inform other objects about state changes: This is not hard-coded but implemented via so called loose-coupling. This allows you to exchange classes and objects freely.

[Page 44 ff - the observer pattern|http://books.google.com/books?id=LjJcCnNf92kC&printsec=frontcover&dq=designpatternshead+first&hl=de#v=onepage&q=&f=false]

is just an idea for further studies.

Regards,

Clemens

Read only

Former Member
0 Likes
1,264

Hy Clemens

Wirklich dankt für den hilfreichen infomation .................

Von Morgen Arbeiten Arbeiten: (hat nur gebunden. ..............get zurück Sie tomorow

Noch einmal Dankt alot

Sas