cancel
Showing results for 
Search instead for 
Did you mean: 

Message Handling from model to controller

Former Member
0 Kudos

Hi,

I'm looking into how (error) messages that are trapped in the model can be communicated to the controller.

Up till now I have been using flags as model attributes.

So I'm creating a different flag for each possible error in the model. I guess there must be a better way to tackle this.

Thanks for any help provided.

Regards,

Eric

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Eric, I´m also investigatin on this.

Why not using exceptions?? As I said I´m still investigatin, but I guess it´s the best solution..

Answers (4)

Answers (4)

thomasalexander_ritter
Active Contributor
0 Kudos

Hi Guys,

it took me a little longer than expected but here is my <a href="/people/thomasalexander.ritter/blog/2005/05/25/bsp-using-the-observer-design-pattern-for-error-handling have fun

regards

Thomas

SergioFerrari
Active Contributor
0 Kudos

Via debugger have a look to the CL_BSP_MODEL->ERRORS attribute for example in the DO_HANDLE_EVENT method of your controller...

Do you know that MODELs perform a format check on each field binded by a view (//model/structure.field)?

Your controller could ask to the model if there are errors; I never found any standard way to do that but I created a simple public method (get_errors) that returns the protected attribute ERRORS (do not ask me why it is protected!!).

You could also add your messages in the object ERRORS for example via the ADD_MESSAGE_FROM_T100 method.

Sergio

thomasalexander_ritter
Active Contributor
0 Kudos

Hi Eric,

the best solution in my opinion is implementing the observer pattern. So you make your model observable and the controller acts as an observer which registers itself for certain error events (http://patternshare.org/default.aspx/Home.PP.Observer). This solution is highly reuseable and easy to implement. I talked about this solution during my sdn presentation at walldorf so I already have some materials. If there are more people interested in this solution I can write a weblog about it.

regards

Thomas

maximilian_schaufler
Active Contributor
0 Kudos

Of course we want to read more about that - as your presentation was way to short to cover everything you wanted to talk about, a blog would be a nice way to get this topic explained better.

Former Member
0 Kudos

Hi all,

I seem to have triggered an interesting topic here...

Thanks all for the valuable input.

Last night (yep, I get my best ideas in bed and also on another location I'll not further discuss about...) it dawned on me that I could of course simply use return codes/exceptions for the different methods in my model in stead of creating and using flags as extra model attributes.

Thomas, your post about the observer is most intreguing.

Definitely worth a weblog! I have the feeling it answers

my underlying need for it's not only "errors" I'm trying to trap...

Regards,

Eric

Former Member
0 Kudos

hi Eric,

you can use a string or an internal table in model in which u can insert ur error messages.

Then u can access that table or string from controller.

Hope this will help you.

Regards,

Ankur