Reacting to a Portal Event SAP ABAP Web Dynpro

Now, we are creating the Web Dynpro application able to react to the event triggered in the first iView in the portal.The structure of this component,the view layout and the context view are presented.

Web Dynpro component structure,view layout and context view

In the context view,we need only the attribute “NAME”, where we pass the parameter value concatenate with a WELCOME string.To be capable to register our Web Dynpro application for a portal event,we have to use the SUBSCRIBE_EVENTmethod of the same IF_WD_PORTAL_INTEGRATION interface.This method shall be used into the wdDoInit Hook Method.

The wdDoInit Hook method

METHOD wddoinit .
DATA lr_api_component TYPE REF TO if_wd_component.
DATA lr_portal_manager TYPE REF TO if_wd_portal_integration.
lr_api_component = wd_comp_controller->wd_get_api( ).
lr_portal_manager = lr_api_component->get_portal_manager( ).
DATA lr_api_controller TYPE REF TO if_wd_view_controller.
lr_api_controller ?= wd_this->wd_get_api( ).
lr_portal_manager->subscribe_event(
portal_event_namespace = 'sap.example'
portal_event_name = 'person_name'
view = lr_api_controller
action = ‘EVENT_RECEIVER’
).
ENDMETHOD.

The SUBSCRIBE_EVENT method has three parameters of STRING type and one parameter type ref to IF_WD_VIEW_CONTROLLER. As we can see, this method needs to specify not only the namespace,the name of the event and the view, but also the name of the action to be called when the event occurs.We have created an action named “EVENT_RECEIVER”. The event handler method is presented.

The onactionevent_receiver event handler method

METHOD onactionevent_receiver .
DATA lv_event_name TYPE string.
DATA lv_event_parameter TYPE string.
lv_event_name = wdevent->get_string(name = 'PORTAL_EVENT_NAME').
IF lv_event_name = 'person_name'.
lv_event_parameter = wdevent-
>get_string(name = 'PORTAL_EVENT_PARAMETER').
CONCATENATE 'WELCOME' lv_event_parameter INTO lv_event_parameter
SEPARATED BY space.
wd_context->set_attribute(name = 'NAME'
value = lv_event_parameter).
ENDIF.
ENDMETHOD.

By using the method GET_STRING (parameter: PORTAL_EVENT_NAME),we pass the value of the portal event name into the local variable lv_event_name.Then,in case this local variable has the value “person_name”(our defined even tname),we have to obtain the value of the parameter.

By using the method GET_STRING (parameter: PORTAL_EVENT_PARAMETER),we can pass the parameter of the portal event to the action parameter WDEVENT and to our local variable lv_event_parameterIn the last step, we create the greeting and we pass this value in the context attribute.



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAP ABAP Web Dynpro Topics