Skip to Content
avatar image
Former Member

Portal eventing in WD ABAP

Hello ,

We have an requirment to pass values from one WD ABAP application iView to another in the Enterprise portal.Is there any configuration that needs be done in WD ABAP or is there any setting in EP that we need to do ??

Rahul

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 23, 2006 at 07:12 PM

    Hi rahul,

    We need to do a little bit of custom code to in WD ABAP .

    Sender Application Sample code:

    In the Sender application: call the FIRE method to pass on the value.

    data: L_API_COMPONENT type ref to IF_WD_COMPONENT,

    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( ).

    L_PORTAL_MANAGER->FIRE

    (PORTAL_EVENT_NAMESPACE = 'Web_Dynpro_ABAP'

    PORTAL_EVENT_NAME = 'PassValue'

    PORTAL_EVENT_PARAMETER = Input_Value ).

    Recieving application sample code:

    In the Init method you need to subscribe the WD ABAP application for the portal eveenting

    data: L_API_COMPONENT type ref to IF_WD_COMPONENT,

    L_PORTAL_MANAGER type ref to IF_WD_PORTAL_INTEGRATION,

    VIEW type ref to IF_WD_VIEW_CONTROLLER.

    L_API_COMPONENT = WD_COMP_CONTROLLER->WD_GET_API( ).

    L_PORTAL_MANAGER = L_API_COMPONENT->GET_PORTAL_MANAGER( ).

    VIEW ?= WD_THIS->WD_GET_API( ).

    L_PORTAL_MANAGER->SUBSCRIBE_EVENT

    (PORTAL_EVENT_NAMESPACE = 'Web_Dynpro_ABAP'

    PORTAL_EVENT_NAME = 'PassValue'

    VIEW = VIEW

    ACTION = 'RECIEVE_Input_Value' ).

    Then in the RECIEVE_Input_Value event you can fetch the input value from the sender app & the same can be used in the current application.

    data: EVT_NAME type STRING,

    CUST_ID type SCUSTOM-ID.

    EVT_NAME = WDEVENT->GET_STRING(

    NAME = 'PORTAL_EVENT_NAME' ).

    check EVT_NAME = 'PassValue'.

    Input_Value = WDEVENT->GET_STRING(

    NAME = 'PORTAL_EVENT_PARAMETER' ).

    You can use the Web Dynpro Code Wizard to generate the stubs.

    Imp Note : Portal eventing works only if you trying to pass values inside a single browser window.

    Regards,

    Srivathsan.K

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 23, 2006 at 07:10 PM

    Rahul,

    Though most of this stuff is of web dynpro for java. You can just replace java Code with ABAP.

    You need to use eventing functionality.In the SAP Enterprise Portal, different application types in specific iViews can be arranged on one page. To communicate between the different iView types the portal provides the Enterprise Portal Client Framework (EPCF), also known as client-side eventing. This document describes how Web Dynpro applications can use EPCF.

    http://help.sap.com/saphelp_nw04/helpdata/en/24/243ca46e1c334f8a6f8b0792656bc7/content.htm

    The following code shows the signature of the subscribe method:

    WDPortalEventing.subscribe(java.lang.String nameSpace, java.lang.String event, IWDAction action);

    for example

    WDPortalEventing.subscribe (“urn:com.sap.tc.webdynpro.test.portal”,

    “TestEvent”,

    wdThis.wdGetTestEventAction());

    You have to define the event’s name and its namespace. The combination of these two names must be unique.

    The third parameter is the Web Dynpro action, which should be mapped to the portal event. The action event handler is called if the Web Dynpro application receives the specified portal event on the client side. The mapping between a portal event and a Web Dynpro action is done automatically and it is completely transparent for the Web Dynpro application developer.

    You can reuse a Web Dynpro action for several portal events. If you want to receive the portal event’s data you have to define the following parameters for your Web Dynpro action:

    · dataObject

    The dataObject parameter contains the portal event parameter.

    · nameSpace

    The namespace parameter contains the portal event’s namespace.

    · name

    The name parameter contains the portal event’s name.

    It is useful to add the nameSpace and nameparameters to the Web Dynpro action if the action is reused for several portal events because you can use this information to differentiate between the portal events.

    Note: In the current version a portal event subscription is valid for a Web Dynpro view. Therefore you should add the required Java coding, for example in the wdDoInit() method of the generated view class. If you navigate between different views, you have to subscribe to every view for the portal event required.

    Unsubscribe from a portal event

    Unsubscribing from a portal event is very similar to subscribing. The following code shows the signature of the unsubscribemethod:

    WDPortalEventing.unsubscribe(java.lang.String nameSpace, java.lang.String event, IWDAction action);

    for example

    WDPortalEventing.unsubscribe (“urn:com.sap.tc.webdynpro.test.portal”,

    “TestEvent”,

    wdThis.wdGetTestEventAction());

    Note: You must unsubscribe every Web Dynpro view, because subscription and unsubscription is valid only for the current view.

    Raise a portal event

    The following example shows how to raise a portal event. The signature is:

    WDPortalEventing.fire(java.lang.String nameSpace, java.lang.String event, java.lang.String parameter);

    for example

    WDPortalEventing.fire (“urn:com.sap.tc.webdynpro.test.portal”,

    “TestEvent”,

    “AParameter”);

    You can fire a portal event anywhere in your Web Dynpro application. The event is sent to the client with the next response. You can also raise more than one portal event in a request-response cycle. Typically, you will fire a portal event in a Web Dynpro action event handler (for example, as a response to pressing a button).

    The following step-by-step example shows how to carry out portal eventing within two simple Web Dynpro example applications.

    Example Description

    The user can enter an arbitrary string in an input field. If the user presses the pushbutton Click here in the sender view, the input string will be displayed in a TextView UI element of the listener application.

    Prerequisites

    You have built two Web Dynpro applications. How to build Web Dynpro applications is described in Creating a Simple Web Dynpro Application. In each application you have created a Web Component with a view that uses the portal eventing.

    You can find the detailed procedure describing how to insert UI elements into a view in Creating a Simple Web Dynpro Application.

    Further information about the integration of a Web Dynpro application into the SAP Enterprise Portal can you find under Running a Web Dynpro Application in SAP Enterprise Portal.

    Procedure

    Creating the Web Dynpro applications

    ...

    1. Create the Web Dypro project. Call it webdynproexample_portal_eventing.

    2. Create two Web Dynpro components. Call them:

    a. EventSenderComponent

    b. EventListenerComponent

    3. Create two Web Dynpro applications. Call them:

    a. EventSenderApplication

    b. EventListenerApplication

    Creating the necessary views:

    Create the layout of the EventSenderView in the EventSenderComponent as follows:

    Create the context structure of the EventingSender View:

    The context value attribute Name must be of type String.

    Create an action “Show”

    Define the data binding of corresponding UI element properties:

    The appropriate properties of the UI elements must be bound to the context that contains and displays the data.

    4. Define a text, for instance, “Enter a text:” for the label UI element (ID: NameLabel) using the property text.

    5. Bind the property value of the input field (ID: NameInputField) to the context attribute Name.

    6. Bind onAction of the button (ID:ShowButton) to the corresponding action Show.

    Implementation of the view controller

    7. If you create an action declaratively within the SAP NetWeaver Developer Studio, the Web Dynpro framework automatically generates an onAction method in the controller’s implementation. The generated method enables you to write code to fetch the input string and to fire the portal event. The fire method of WDPortalEventing passes the data and the name of the event that should be handled by the second application as parameters. The following code shows the implementation of onActionShow method:

    public void onActionShow(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

    {

    //@@begin onActionShow(ServerEvent)

    String name = wdContext.currentContextElement().getName();

    WDPortalEventing.fire("urn:com.sap.tc.webdynpro.example.portaleventing",

    "Show",

    name);

    //@@end

    }

    Create the layout of the EventListenerView in the EventListenerComponent as follows:

    Create the context structure of the EventingListenerView:

    The context attribute Name must be of type String.

    Create an action, for example, ReactPortalEventing which should be mapped to the portal event.

    8. Create an action ReactPortalEventing.

    9. Add the parameter dataObject. It should have the type java.lang.String.

    Define the data binding of the corresponding UI element properties:

    The corresponding properties of the UI elements must be bound to the context that contains and displays the data.

    10. Define a text for the NameLabel for example, The entry is displayed in a TextView UI element:

    11. Bind the property text of the TextView UI element (ID: TextViewShow) to the context attribute Name.

    Implementation of the view’s controller

    12. You have to subscribe to the event within the wdDoInit method. You have to define the namespaceof the event and the name of the event, for example Show. The third parameter is the Web Dynpro action, which should be mapped to the portal event.

    13. You have to implement the action (ReactPortalEventing) that passes the dataObjectand fills the context with data. The following code shows the implementation of the wdDoInit and the reactPortalEventing methods:

    public void wdDoInit()

    {

    //@@begin wdDoInit()

    WDPortalEventing.subscribe("urn:com.sap.tc.webdynpro.example.portaleventing", "Show",

    wdThis.wdGetReactPortalEventingAction() );

    //@@end

    }

    public void onActionReactPortalEventing(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String dataObject )

    {

    //@@begin onActionReactPortalEventing(ServerEvent)

    wdContext.currentContextElement().setName(dataObject);

    //@@end

    }

    Deploying the Web Dynpro Application

    Before you can call the Web Dynpro application, you have to build the Web Dynpro project and deploy the application on the J2EE Engine.

    Simple Testing of the Portal Eventing and Calling the Web Application

    14. Create two iViews in the newly-created example folder as described in Running a Web Dynpro Application in SAP Enterprise Portal.

    15. Create a page and add the two iViews to the newly-created page.

    To preview the Web Dynpro applications, choose the button Preview in the Portal Content Studio.

    16. Enter your input and choose button Click here.

    Result

    A page preview will demonstrate portal eventing.

    Also, Please refer to these links,

    http://help.sap.com/saphelp_nw04/helpdata/en/c6/21fc3f82c2e469e10000000a155106/content.htm

    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/portal integration of web dynpro applications.pdf

    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cfb80249-0801-0010-3eaa-829afeac170f

    Please let me know whether its useful.

    Thanks,

    Raj.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Question I have is the following: Do we need to configure/set values in the Portal environment at all. The course on WD4A on describes the fireing and listening from the Webdynpro's?

      Thanks in advance,

      Marco

  • avatar image
    Former Member
    Apr 24, 2006 at 01:42 AM

    Rahul,

    Take look at this template for portal eventing.

    https://www.sdn.sap.com/irj/sdn?rid=/library/uuid/6653b690-0201-0010-f19d-f11e47f7354a

    Thanks,

    Raj.

    p.s: Let us know whether its of any helpful.

    Message was edited by: Raj

    Add comment
    10|10000 characters needed characters exceeded