Skip to Content
0
Mar 17, 2012 at 04:27 PM

A piece of code, that should act as GLOBAL? Avoid code redenency

21 Views

Hello

I have a WDA (ABAP), where in i have 4 views, by using the below code i am throwing (mostly error) messages, working fine.

As per our business requirement, we are throwing these messages in many situations/spots of different views, so kind of code redenency. So, i want to avoid this code redennecy and instead of using this piece of code on all spots of different views, i want to put this code in a central place/globally, so that i will call it by using CALL METHOD some thing like that.

l_current_controller ?= wd_this->wd_get_api( ).

CALL METHOD l_current_controller->get_message_manager
RECEIVING
message_manager = l_message_manager.

CALL METHOD l_message_manager->report_t100_message
EXPORTING
msgid = 'ZZ'
msgno = '000'
msgty = 'E'
p1 = lv_p1.

Pls. let me know can i put this code by defining a METHOD in COMPONENT CONTROLLER and i can call it where ever i needed it?

If so, pls. let me know How shoud i call that method of COMPOENENT CONTROLER

(i dont think i should use WD_THIS->THROW_MESSAGE_FROM_COMPOEMENT_CONTROLLER_Z_METHOD)?

In general, any code (say, my_global_code), if i want to act as GLOBAL (i mean, i can use/trigger it from any where/any corner of the WDA), then where should i put/place that my_global_code? How should i call it to trigger its code?

Thank you