ABAP: SAP EP Communication between iViews via BSP & WD

In the SAP Enterprise Portal, we can process different application types in special iViews on the same portal page. Here, iViews can be included using different technologies (such as Web Dynpro ABAP, Java, or BSP). The communication between these iViews takes place through an event function – portal eventing (or client-side eventing).
A WD or BSP can be registered for portal events. In this way, the WD or BSP can react to an event that was triggered in another iView in the portal. Therefore, it does not matter what technique you used to set up the application that is the basis for the other iView. The assignment as to which event handler is to be called when this event occurs is stored in the WD or BSP that has registered itself on the portal event.

Similarly to registration, a WD or BSP application can trigger any portal event. In this case, the event is passed to the portal by the respective iView. The portal passes the event to all iViews that have registered for this event. The application that finally handles this event can, in turn, have been set up with a different technique than the WD or BSP application triggering it.

Portal eventing functions only between iViews that are on the same browser window. Events between iViews in different browser windows cannot be transported.

All participating iViews must also belong to the same domain. Otherwise portal eventing cannot work due to JavaScript restrictions.

Syntax for Namespace and Names of Events:

Valid characters: “A””Z”,”a””z”,”0″”9″,””,”_”,”-“,”.”

Namespaces com.sapportals.portal.* and com.sapportals.* are reserved by sap, normally we used the company namespace.

Namespaces and event are case sensitive so be careful on the typing, because there is no syntax check.

In my tutorial I trigger and register the WD or BSP from different systems into one portal IView.

WebDynpro Event Sender

Goto SE80 create z_portal_event_sender component and application with default.view and default.window.

In the context of default view add context node main and 3 attributes: text_area_1 and text_area_2, text_area_3. In the layout of default view add 3 input fields: input_1, input_2, input_3 which bind respectively to the context attributes: text_area_1, text_area_2, text_area_3, 1 button btn with action trigger_event.

In the event method onactiontrigger_event on view I only want to send input_1 and input_2 to the portal. The data has be concatenated into one parameter on the server side before triggering the portal event

method onactiontrigger_event .
  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_area_1                    like stru_main-text_area_1,
		item_text_area_2                    like stru_main-text_area_2,
		item_text_area_3                    like stru_main-text_area_3.
* navigate from  to  via lead selection
  node_main = wd_context->get_child_node(wd_this->wdctx_main ).
* get element via lead selection
  elem_main = node_main->get_element(  ).
* get single attribute
  elem_main->get_static_attributes(
    exporting
      name =  `TEXT_AREA_1`
    importing
      value = item_text_area_1 ).

	elem_main->get_static_attributes(
    exporting
      name =  `TEXT_AREA_2`
    importing
      value = item_text_area_2 ).

	elem_main->get_static_attributes(
    exporting
      name =  `TEXT_AREA_3`
    importing
      value = item_text_area_3 ).
WebDynpro Event receiver

Goto SE80 create z_portal_event_receiver component and application with default.view and default.window.

In the context of default view add context node main and 3 attributes: text_area_1 and text_area_2, text_area_3. In the layout of default view add 3 input fields: input_1, input_2, input_3 which bind respectively to the context attributes: text_area_1, text_area_2, text_area_3, 1 button btn with action catch_event

Register default view to the portal event Framework, in the wddoinit of default I registered the portal manager, on the server side after receiving the portal parameter, I split the parameter again into different field.

method wddoinit .

  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 l_wd_view type ref to if_wd_view_controller.

  l_wd_view ?= wd_this->wd_get_api( ).
  l_portal_manager->subscribe_event(
      portal_event_namespace = 'com.xiaohong'
      portal_event_name      = 'test_event'
      view                   = l_wd_view
      action                 = 'CATCH_EVENT' ).

Endmethod.

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  to  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.
BSP application event sender

Goto SE80, create bsp application z_portal_bsp_sender, page event_sender.htm with page flow logic, it has 3 input fields and 1 button. When the button is pressed, we trigger the portal event using javascript on the browser instead of server event to avoid the respect/response cycle, technically HTML DOM can read the value of each UI element, so I read the data before triggering the portal event.

Layout of event_sender.htm

&lt;%@page language="abapljavascript" %&gt;<script type="text/javascript">// <![CDATA[
		function alertValue(){
			x = document.getElementById("input_field_1").value + "*" + 
					document.getElementById("input_field_2").value;
			portalFireEvent('com.testNamespace','test_event',x);
		}

// ]]></script>
&lt;%@extension name="htmlb" prefix="htmlb" %&gt;
BSP application event receiver

The portal event send the data to the server, then I split the portal content in the server side.

Goto SE80 and create bsp application z_portal_bsp_receiver. Page event_receiver.htm

Layout of event_receiver.htm

&lt;%@page language="abap" %&gt;
&lt;%@extension name="htmlb" prefix="htmlb" %&gt;
&lt;%@extension name="bsp" 	prefix="bsp" %&gt;
OnInputProcessing Event Handler
	data: event type ref to if_htmlb_data.
	data: event_dataobject type string.
	data: event_sourceid type string.
	data: event_namespace type string.
	data: event_name type string.
	Data: wa_string type string.
	Data:lt_string like table of wa_string.

	event = cl_htmlb_manager=&gt;get_event_ex(
		runtime-&gt;server-&gt;request ).

	if event is bound.
	  if event-&gt;event_name eq 'portalEvent'.
	    event_dataobject = event-&gt;event_server_name.
	    event_sourceid = event-&gt;event_defined.
	    split event-&gt;event_id at ':'  into event_namespace event_name.
	    if event_namespace = 'com.xiaohong' and
	       event_name = 'test_event'.
	   		 Split event_dataobject at '*' into table lt_string.
	 			 Read table lt_string into wa_string index 1.
				 event_text_1 = wa_string.
	 			 Clear wa_String.
 				 Read table lt_string into wa_string index 2.
  			 Event_text_2 = wa_string.
    	endif.
	  endif.
	endif.

First we have to configure the different system into Portal using Single Sign On(SSO).

Configure systems into portal

Configure system landscape

sso_2Logon the portal as administrator ->system administration->system configuration->system landscape->create folder name and id. Under new folder create system and choose dedicated Application server for R/3 system and name and id, You have to configure each systems you used in the portal.

sso_6Open the new system and modify the property editor, enter all the system technical information: host, port, client, system id; system number. Editor system alias for the new system, alias is used to identify the backend system.

Configure single sign on(SSO) to portal and abap system

sso_1Logon the portal as administrator->system administration->system configuration->keystore administration->download SAPLogonTicketKeypair verify.der into local pc and unzip it. Logon to ABAP system user, go to STRUSTSSO2 and import verify.der

Configure user and role on portal

Logon the portal as administrator->user administration->users->create user.

Enter the same user as backend ABAP system.

Content administration->portal content->new role->create role ->open the object for setting->navigation->entry point

User Administration->Roles->edit, assign the user to the role

Configure iview

sso_10Logon portal as administrator->content administration->portal content->

Create Iview, add all the four BSP and WDA application into Iview
create page: add all the iview into page by delta link
Portal content->folder ->add iView to role->Delta Link

Add page to the role by Delta Link

Leave a Reply

*

captcha *