cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot receive event fired from component1 in component2

siongchao_ng
Contributor
0 Kudos

Hi all,

Based on the link http://wiki.sdn.sap.com/wiki/display/BSP/Usingportaleventtocommunicatemultipledatabetweendifferentwebapplication(WDAandBSP)

I enter a text each in the 3 input fields in app1. I failed to receive the 3 text in app2. Debugging mode on the code below shows evt_name and evt_parameter as blank.

Method onactioncatch_event.

data: EVT_NAME type STRING,

evt_parameter type string,

wa_string type string,

it_string like table of wa_string.

EVT_NAME = WDEVENT->GET_STRING( NAME = 'PORTAL_EVENT_NAME' ).

if EVT_NAME = 'test_event'.

evt_parameter = WDEVENT->GET_STRING( NAME = 'PORTAL_EVENT_PARAMETER' ).

Split evt_parameter at "*" into table lt_string.

DATA:

node_main TYPE REF TO if_wd_context_node,

elem_main TYPE REF TO if_wd_context_element,

stru_main TYPE if_default=>element_main ,

item_text_reciever LIKE stru_main-text_reciever.

  • navigate from <CONTEXT> to <MAIN> via lead selection

node_main = wd_context->get_child_node( name = `MAIN` ).

  • get element via lead selection

elem_main = node_main->get_element( ).

Read table it_string into wa_string index 1.

  • get single attribute

elem_main->set_attribute(

EXPORTING

name = `TEXT_AREA_1`

value = wa_string ).

Clear wa_string.

Read table it_string into wa_string index 2.

Elem_main->set_attribute(

Exporting name = 'TEXT_AREA_2'

Value = wa_string).

)

endif.

endmethod.

Edited by: Siong Chao on May 12, 2010 11:28 AM

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You are hitting the breakpoint, so the event is being triggered - correct? Is it just that the event parameters are empty? Are you sure the sending application is properly filling the event parameters?

siongchao_ng
Contributor
0 Kudos

Hi Thomas,

http://wiki.sdn.sap.com/wiki/display/BSP/Usingportaleventtocommunicatemultipledatabetweendifferentwebapplication(WDAandBSP)

On the firing event side from component 1,

I run a debug on that and found out that the portal_event_parameter is working fine. The text that is entered is concatenated there. However, I would like to know the what is exactly the portal_event_namespace? And as well as the portal event name? Is is I can give any name for the portal_even_name? I would not be sure though on the portal_event_namespace? HOw do I filled that up?

data l_api_component type ref to if_wd_component.

data l_portal_manager type ref to if_wd_portal_integration.

l_api_component = wd_comp_controller->wd_get_api( ).

l_portal_manager = l_api_component->get_portal_manager( ).

data: portal_event_parameter type string.

portal_event_parameter = item_text_area_1.

l_portal_manager->fire(

portal_event_namespace = 'com.xiaohong' -


> ( How do I filled up this)

portal_event_name = 'test_event' -


>( Is this just any name will do?)

portal_event_parameter = portal_event_parameter

).

Former Member
0 Kudos

Try the below code to fire the Portal Event in your first WD application from where you want to fire the Portal event:

*************************************************************************************************************************************************************

  • get single attribute

lo_el_importing->get_attribute( EXPORTING name = `IM_BNAME` IMPORTING value = lv_im_bname ).

CONCATENATE lv_im_bname ls_roles-role ls_partners-parvw ls_partners-parnr ls_parent_node-node_type

ls_parent_node-node_value INTO lv_event_parameter SEPARATED BY space.

DATA lo_api_component TYPE REF TO if_wd_component.

DATA lo_portal_manager TYPE REF TO if_wd_portal_integration.

lo_api_component = wd_comp_controller->wd_get_api( ).

lo_portal_manager = lo_api_component->get_portal_manager( ).

IF lo_portal_manager IS NOT INITIAL.

CALL METHOD lo_portal_manager->fire

EXPORTING

portal_event_namespace = 'urn:com.sap.bc.webdynpro.sap.test_event'

portal_event_name = 'test_event'

portal_event_parameter = lv_event_parameter.

ENDIF.

*************************************************************************************************************************************************************

For Receiving the Portal event you need to subscribe the Portal event (in WDDOINIT method) in your second WD application, From where you are trying to receive the Portal event as below:

*************************************************************************************************************************************************************

DATA lo_api_component TYPE REF TO if_wd_component.

DATA lo_portal_manager TYPE REF TO if_wd_portal_integration.

lo_api_component = wd_comp_controller->wd_get_api( ).

IF lo_api_component IS NOT INITIAL.

lo_portal_manager = lo_api_component->get_portal_manager( ).

DATA lo_api_controller TYPE REF TO if_wd_view_controller.

lo_api_controller ?= wd_this->wd_get_api( ).

IF lo_portal_manager IS NOT INITIAL.

CALL METHOD lo_portal_manager->subscribe_event

EXPORTING

portal_event_namespace = 'urn:com.sap.bc.webdynpro.axonfmp.test_event'

portal_event_name = 'test_event' " 'ARCFT_ENGN'

view = lo_api_controller

action = 'CATCH_EVENT2'. " Action, where you need to get the Portal event from 1st application

ENDIF.

ENDIF.

*************************************************************************************************************************************************************

Now you have subscribed the Portal Event. Finally you need to receive the Portal event in CATCH_EVENT2 method as below:

*************************************************************************************************************************************************************

METHOD ONACTIONCATCH_EVENT2 .

DATA: evt_name TYPE string,

evt_parameter TYPE string.

evt_name = wdevent->get_string( name = 'PORTAL_EVENT_NAME' ).

*IF evt_name = 'ARCFT_ENGN'.

evt_parameter = wdevent->get_string( name = 'PORTAL_EVENT_PARAMETER' ).

DATA lo_nd_search_criteria TYPE REF TO if_wd_context_node.

DATA lo_el_search_criteria TYPE REF TO if_wd_context_element.

DATA ls_search_criteria TYPE wd_this->element_search_criteria.

  • navigate from <CONTEXT> to <SEARCH_CRITERIA> via lead selection

lo_nd_search_criteria = wd_context->get_child_node( name =

wd_this->wdctx_search_criteria ).

IF lo_nd_search_criteria IS NOT INITIAL.

  • get element via lead selection

lo_el_search_criteria = lo_nd_search_criteria->get_element( ).

SPLIT evt_parameter AT space INTO ls_search_criteria-bname

ls_search_criteria-role

ls_search_criteria-parvw

ls_search_criteria-parnr

ls_search_criteria-node_type

ls_search_criteria-value.

IF lo_el_search_criteria IS NOT INITIAL.

  • get all declared attributes

lo_el_search_criteria->set_static_attributes(

EXPORTING

static_attributes = ls_search_criteria ).

ENDIF.

ENDIF.

ENDMETHOD.

*************************************************************************************************************************************************************

Hope it works for you...

siongchao_ng
Contributor
0 Kudos

Hi Sanket,

Your fire event and receive event portal_namespace and portal_event_name is not consistent though.

Firing part:

IF lo_portal_manager IS NOT INITIAL.

CALL METHOD lo_portal_manager->fire

EXPORTING

portal_event_namespace = 'urn:com.sap.bc.webdynpro.sap.test_event'

portal_event_name = 'test_event'

portal_event_parameter = lv_event_parameter.

ENDIF.

Receive part:

CALL METHOD lo_portal_manager->subscribe_event

EXPORTING

portal_event_namespace = 'urn:com.sap.bc.webdynpro.axonfmp.test_event'

portal_event_name = 'test_event' " 'ARCFT_ENGN'

view = lo_api_controller

action = 'CATCH_EVENT2'. " Action, where you need to get the Portal event from 1st application

I want to know is for my case here, the portal_event_name is any name I can give to identify which event I am firing so the receive part can identify and receive the correct event. However, what about the portal_event_namespace?

'urn:com.sap.bc.webdynpro.sap.test_event' means 'urn:com.sap.bc.webdynpro.sap. (portal name) + test_event (event name).

Omigosh, how do I derive my portal name? Any hint?

Former Member
0 Kudos

Hi,

1) Sorry typo mistake. Change the AXONFMP to sap in the Recieve part as below:

Receive part:

CALL METHOD lo_portal_manager->subscribe_event

EXPORTING

portal_event_namespace = 'urn:com.sap.bc.webdynpro.sap.test_event' " change AXONFMP to sap

portal_event_name = 'test_event'

view = lo_api_controller

action = 'CATCH_EVENT2'. " Action, where you need to get the Portal event from 1st application

2) Yes, as per my knowledge you can opt any name for Portal Event. And you have to subscribe that Portal Event in the other WD component as I had pointed out earlier post.

3) For portal_event_namespace, 'urn:com.sap.bc.webdynpro.sap' is the standard Namespace for Poral. If you are using any other Namespace for your application, then the nsamespace will be like 'urn:com.sap.bc.webdynpro.<Other Namespace>' e.g. 'urn:com.sap.bc.webdynpro.abc'.

By default the Portal namespace is 'urn:com.sap.bc.webdynpro.sap'.

Hope it helps you.

siongchao_ng
Contributor
0 Kudos

Hi Sanket,

Thanks for your info. One more thing when you mention the the subscribe event part in wddoinit. Is this the wddoinit of the 2nd component view method or 2nd component controller method?

Former Member
0 Kudos

It's always depends on your requirement.

If you want to use the Portal event in just one of your View, then you would subscribe the Portal event in View WDDOINIT method.

If you want to use the Portal event in multiple views then you need to subscribe the Portal event in Comp controller WDDOINIT method, so that you can use the Portal event data globally.

Answers (0)