How-To Guide
How To Build Web Applications
Using MDM Web Dynpro Components
Applicable Releases:
SAP NetWeaver Master Data Management 7.1 and higher
Topic Area:
Enterprise Information Management
Capability:
Master Data Management
Version 2.30
December 2013
express permission of SAP AG. The information contained herein may be changed without prior notice.
Some software products marketed by SAP AG and its distributors contain proprietary software components of other software vendors.
Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, OpenPower and PowerPC are trademarks or registered trademarks of IBM Corporation. Adobe, the Adobe logo, Acrobat, PostScript, and Reader are either trademarks or registered trademarks of Adobe Systems Incorporated in the United States and/or other countries.
Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Citrix, ICA, Program Neighborhood, MetaFrame,
WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc.
HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.
MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world.
without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.
These materials are provided “as is” without a warranty of any kind, either express or implied, including but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. SAP shall not be liable for damages of any kind including without limitation direct, special, indirect, or consequential damages that may result from the use of these materials. SAP does not warrant the accuracy or completeness of the information, text, graphics, links or other items contained within these materials. SAP has no control over the information that you may access through the use of hot links contained in these materials and does not endorse your use of third party web pages nor provide any warranty whatsoever relating to third party web pages.
SAP NetWeaver “How-to” Guides are intended to simplify the product implementation. While specific product features and procedures typically are explained in a practical business context, it is not implied that those features and procedures are the only approach in solving a specific business problem using SAP NetWeaver. Should you wish to receive additional information, clarification or support, please refer to SAP Consulting.
Any software coding and/or code lines / strings (“Code”) included in this documentation are only examples and are not intended to be used in a productive system
environment. The Code is only intended better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, except if such damages were caused by SAP intentionally or grossly negligent.
Document Version Description
2.30 · Links have been updated.
2.20 · SAP NetWeaver 7.3 is now supported.
· As of MDM 7.1 SP07, you can encrypt communication between MDM clients and servers to prevent unauthorized parties from accessing sensitive data. Using a secure connection is documented in the MDM Web Dynpro Component Reference Guide (seePrerequisites section on page1 for links to the relevant sections of the guide).
· As of MDM 7.1 SP07, the MDM Java Connector is packaged in a separate SCA from the Java API library. This information is
documented in the MDM Web Dynpro Component Reference Guide (seePrerequisites section on page1 for links to the relevant sections of the guide).
2.10 Terminology updated to reflect changes in the user interface of the MDM Web Dynpro Configuration Manager
2.00 TheHow To Consume MDM Web Dynpro Components v1.0 guide has been split into the following two guides:
· How To Build Web Applications Using MDM Web Dynpro Components
Explains how MDM Web Dynpro components are consumed by other custom Web Dynpro components to create a Web Dynpro application with the flexibility to run as a stand-alone application or in a portal environment. This is the guide you are currently reading (as of v2.0). · How To Integrate MDM and BPM
The guide focuses on how to integrate MDM and Business Process Management (BPM) using MDM Web Dynpro Components and Web Services and is available on SAP Developer Network (SDN) at
http://www.sdn.sap.com/irj/sdn/howtoguides.
The direct link to the guide is:How to Integrate Master Data Management (MDM) and Business Process Management (BPM)
1.00 First official release of this guide:How To Consume MDM Web Dynpro Components
Example Text Words or characters quoted from the screen. These include field names, screen titles, pushbuttons labels, menu names, menu paths, and menu options.
Cross-references to other documentation
Example text Emphasized words or phrases in body text, graphic titles, and table titles
Example text
File and directory names and their paths, messages, names of variables and parameters, source text, and names of installation, upgrade and database tools.Example text
User entry texts. These arewords or characters that you enter in the system exactly as they appear in the
documentation.
<Example
text>
Variable user entry. Angle brackets indicate that you replace these words and characters with appropriate entries to make entries in the system.
EXAMPLE TEXT
Keys on the keyboard, for example,F2 orENTER.Caution
Note or Important Example
1 Business Scenario... 1
2 Prerequisites... 1
3 Building a Stand-Alone Web Dynpro Application ... 4
4 Controlling Field Visibility and Required Properties ...16
5 Limiting Lookup Field Values ... 20
6 Setting Field Default Values in an Item Details Component ... 25
7 Adding Custom Buttons to an Item Details Component ... 30
8 Integrating MDM Change Tracker and MDM WD Components ... 35
9 Other Examples ... 42
1
Business Scenario
SAP NetWeaver Master Data Management (MDM) – Web Dynpro
Components
SAP MDM Web Dynpro components are consumed (as used components), by custom developed Web Dynpro wrapper applications and can be used for customizing or applying different types of business logic to suit a variety of business scenarios such as Business Process Management (BPM).
For more information on how MDM Web Dynpro components can be consumed in a BPM process, seeHow To Integrate Master Data Management (MDM) and Business Process Management (BPM) available on SAP Developer Network (SDN) at
http://www.sdn.sap.com/irj/sdn/howtoguides
.MDM Web Dynpro components can also be consumed by custom Web Dynpro components. You can create a Web Dynpro application to run as a stand-alone application or in a portal environment. In this guide we describe how to build a generic stand-alone Web Dynpro application.
For more information, seeBuilding a Stand-Alone Web Dynpro Applicationon page 4.
In addition, you can extend or modify the generic behavior of Web Dynpro components at runtime by using User Exits (sometimes called hook methods). User Exits allow you to add your own functionality to SAP’s standard business applications without having to modify the original applications. There are several different types of User Exits, each of which acts as a hook to which you can attach (or hang) your own code.
For more information on User Exits, see
http://help.sap.com/nwmdm71
® SAP NetWeaver MasterData Management 7.1 ® Development Information ®MDM Web Dynpro Components: Reference Guide ®
MDM Web Dynpro Components User Exits.
The following are some examples of how you can apply User Exits to customize MDM Web Dynpro components at runtime to behave according to a particular business scenario:
· You can control the properties of a component (for example, whether a field is visible, required, or read-only).
For more information, seeControlling Field Visibility and Required Properties on page16.
· You can limit the list of lookup values in a dropdown list for a specific field to show only those values that are relevant for a particular scenario.
For more information, seeLimiting Lookup Field Values on page20.
· You can set default values for specific fields in an Item Details component so that a user does not have to keep re-entering identical values.
For more information, seeSetting Field Default Values in an Item Details Component on page25. · You can add a customized tool bar with buttons to the user interface of an Item Details component. For
each custom button you can also add label translations.
For more information,see Adding Custom Buttons to an Item Details Component on page30. · You can split a Web Dynpro application into its components, so that each component takes on the
appearance of an individual portal iView.
December 2013 2 · Before you can develop a Web Dynpro application, the following must be in place:
¡ You have installed one of the following supported SAP NetWeaver releases, together with SAP NetWeaver Application Server (AS) Java:
§
SAP NetWeaver Composition Environment (CE) 7.11 SP04 (or higher)§
SAP NetWeaver Composition Environment (CE) 7.2Note
If you are using MDM Web Dynpro components with Business Process Management (BPM) you need SAP NetWeaver Composition Environment (CE) 7.2 SP03 (or higher)
§
SAP NetWeaver 7.3 or higher.¡ SAP NetWeaver Developer Studio (NWDS) is installed and running and is the same version as the SAP NetWeaver AS Java you are running.
¡ You are using SAP NetWeaver MDM 7.1 SP04 or higher. ¡ The MDM repository is mounted and loaded.
¡ MDM JAVA API 7.1.is deployed.
For more information about deploying the Java API library and MDM Connector, see
http://help.sap.com/nwmdm71 ®SAP NetWeaver Master Data Management 7.1 ®
Development Information®MDM Java and .NET API Developer Guide:
§
Getting Started with Java API§
Installing and Referencing the MDM Connector® Installation§
Deploying the Java API and MDM Connector Using JSPM ¡ MDM JAVA WD FRAMEWORK 7.1 7.11 is deployed.For more information, see
http://help.sap.com/nwmdm71
® SAP NetWeaver MasterData Management 7.1®Development Information ®MDM Web Dynpro Components Reference Guide:
§
Installing the MDM Web Dynpro Environment§
Deploying the MDM Web Dynpro Components Framework¡ You have run the MDM Web Dynpro Configuration Manager application and configured your components.
For more information, see
http://help.sap.com/nwmdm71
®SAP NetWeaver MasterData Management 7.1 ®Development Information ®MDM Web Dynpro Components Reference Guide® Configuring a Project in the MDM WD Configuration Manager. · You have imported the MDM Web Dynpro and MDM Java API software components (SC) to your
workspace as follows:
a. In SAP NetWeaver Developer Studio (NWDS), choose theDevelopment Infrastructure
perspective as follows:
Window® Open Perspective® Other® Development Infrastructure.
b. Import the
MDM_JAVA_API
softare component to yourLocalDevelopment
development track as follows:i. In the context menu of the
LocalDevelopment
track, chooseImport SC… TheImport Software Component screen opens.c. Import the
MDM_JAVA_WD_FRAMEWORK
software component to your development trackexactly as you did in step b above for the API. Import the
MDMJAVAWDFRW<SP-Number>_P<Patch-Number>.sca
file.The following software components appear in the
LocalDevelopment
track:§
MDM_JAVA_API
§
MDM_JAVA_WD_FRAMEWORK
.d. Add a new dependency to the
MyComponents
SC, for theMDM_JAVA_API
andMDM_JAVA_WD FRAMEWORK
software components.December 2013 4
3
Building a Stand-Alone Web Dynpro
Application
Important
Ensure that you have carried out all the prerequisite steps. For more information, seePrerequisites on page1.
Step 1: Create a new development component (DC) project
Info
You have already imported the Web Dynpro software component (SC) to your workspace. You are now going to create a new Development Component (DC) Project.
...
1. In SAP NetWeaver Developer Studio (NWDS), choose theWeb Dynpro perspective as follows:
File® New® Web Dynpro Development Component.
2. Choose the software component (SC) where you want the development component (DC) project to be created (that is, in the
LocalDevelopment
track select theMyComponents
software component).Info
Local Development
is the name of a local development track, within which there is a software component calledMyComponents
.3. Name your Web Dynpro DC project
test/masterdc
.Step 2: Set the dependencies
Info
Development Components (DCs) may depend on and use each other. To enable a DC to use the functionality of another DC, you have to publish their functions in a set of public interfaces called public parts and a dependency to the public part of the DC must be declared. When you declare dependencies, you select only those public parts that your component actually uses.
4. Choose theDevelopment Infrastructure perspective.
6. In theDependencies tab, add dependencies to the public parts of the relevant UI components as well as the core ear DC:
For example:
¡
tc/mdm/wdcomps/core/ear
(mandatory)¡
tc/mdm/wdcomps/itemdetails/wd
(optional depending on scenario) ¡tc/mdm/wdcomps/resultset/wd
(optional depending on scenario) ¡tc/mdm/wdcomps/search/main/wd
(optional depending on scenario)December 2013 6 7. Some of the events and interface methods exposed by User Exits use the MDM Java API. To access
these events or methods, add a dependency to the MDM Java API (to the
api
public part of thecom.sap.mdm.tech.mdm4j
DC).8. ChooseNextto configure the dependencies.
Note
Uncheck theBuild Time checkbox of any DC that has a (red X) next to it. The red X means that its public parts are for internal use only. The name of the DC is also grayed out.
Step 3: Create a new Web Dynpro component
9. From theWeb Dynpro perspective, expand the
test/masterdc
Web Dynpro DC project.10. In the context menu of the
Components
node, create a new Web Dynpro component calledMasterComp
.December 2013 8 12. To be able to use an external component define component usage as follows:
a. Choose
Component Usage
from thePalette area on the right hand side of the screen. b. Drag and drop it onto the work area. ANew Web Dynpro Component Usage popup windowopens.
13. ChooseBrowse to select the required component. Repeat this step for as many components as you need for your scenario.
In our example, three MDM WD components are referenced: Item Details, Result Set, and Search components.
14. Create data links between the components you are using and the Component Controller of the
Step 4: Define the Window
Info
A Window enables the Web Dynpro component to be seen in a Web browser.
15. ChooseComponents®
MasterComp
(name of WD component)®Windowsto open the mainMasterCompWindow
window.16. Delete the default view.
Info
December 2013 10 17. In theViewsets area of thePalette, choose,
GridLayout
.18. In the context menu of
GridLayout
,embed the interface views in theViewSet cells as follows:EmbedView® Embed Interface View of a Component Instance.
19. Select the relevant interface view.
December 2013 12
Step 5: Initialize the components
Info
Each controller has its own set of standard hook methods. These methods are called
automatically when you initialize the Web Dynpro components. It is within these methods that you may implement your own code.
21. In the Component Controller of the
MasterComp
WD Component,initialize the components as follows:Define a variable
_repositoryBean
of typeRepositoryBean
in thebegin others
area as follows://@@begin others
RepositoryBean _repositoryBean = null;
//@@end
22. Enter the relevant code in the
wdDoInit
method:Note
When using the
setConfiguration
method, you must supply the configuration projectname and the component name as you defined in the MDM Web Dynpro Configuration Manager (see screen capture below):
Step 6: Log off
23. When closing the application, add the following code to the component’s
wdDoExit()
method:Note
The
logoff()
method destroys the MDM sessions created by the application.December 2013 14 For more information regarding authentication, seehttp://help.sap.com/nwmdm71®SAP
NetWeaver Master Data Management 7.1® Development Information® MDM Web Dynpro Components: Reference Guide® Defining a Trusted Connection.
27. ChooseNext and select the Master Component as the Web Dynpro component.
28. Build, deploy, and run the new
test/masterdc
Web Dynpro DC.Result
The runtime behavior is as follows:
Search Web Dynpro Component
December 2013 16
Item Details Web Dynpro Component
4
Controlling Field Visibility and Required
Properties
At runtime, you can control properties of a field on the user interface of an Item Details component by configuring the
Raise Event
property in the MDM Web Dynpro Configuration Manager. Examples of field properties that you can control are:·
Visible
·
Read-Only
·
Required
In this example, we show you how to configure field visibility when the property of one field (Vendor Region), is dependent on another field's values (Country). WhenCountry is
USA
,Vendor Region is visible and required,and whenCountry is
Japan
, Vendor Region is not applicable.Procedure
Important
Ensure that you have carried out all the prerequisite steps. For more information, seePrerequisites on page1.
Configure the Item Details WD component
...
1. Using the MDM Web Dynpro Configuration Manager, configure an Item Details WD component. For more information, see http://help.sap.com/nwmdm71®SAP NetWeaver Master Data
Management 7.1® Development Information® MDM Web Dynpro Components: Reference Guide®
Configuring an Item Details Web Dynpro Component.
Note
In the Item Details wizard, enter the following values:
§
In step 2, add the following three fields:Vendor,Country, andVendor region.Set th eRaise Valu e- to
True
(onl y for t heConfigure the Event Handler
2. After adding the Item Details WD component as a used component, add a new method to the Component Controller of the custom WD wrapper application.
December 2013 18 Property Value
Subscribed
Event
ValueChanged
Result:Implement the sample code in the wrapper application
5. Enter the following sample code for the
handleValueChange
method. (Any custom logic can be executed in theEvent handler method).In our example:
¡
USA
is selected from theCountry field dropdown list.Enter the following values for theVendor region field properties:
§
Visible
=true
§
Required
=true
¡
Japan
is selected from theCountry field dropdown list.Enter the following value for theVendor region field property:
Visible
=false
(Vendor region field will not appear).Result
The runtime behavior is as follows:
WhenCountry =
USA
, theVendor region is visible and set to required* (red asterix). However, whenCountryDecember 2013 20
5
Limiting Lookup Field Values
...
You can limit the list of lookup field values in a dropdown list for a specific field by configuring the
Raise
Event
property in the MDM Web Dynpro Configuration Manager.This example shows you how to limit the values in a dropdown list of aRegion field to show only those values that are relevant for a specific country (for exampleUSA).
Prerequisites
· Ensure that you have carried out all the prerequisite steps. For more information, seePrerequisites on page1. · In addition to the above prerequisites, ensure that:
¡ AVendor record has been created
¡ There are two lookup tables:MDM_REGIONS andMDM_COUNTRIES, which are interdependent ¡ TheCountry field in the MDM_REGIONS table is a lookup to the MDM_COUNTRIES table
Procedure
Configure the Item Details WD component
...1. Using the MDM Web Dynpro Configuration Manager, configure an Item Details WD component. For more information, seehttp://help.sap.com/nwmdm71®SAP NetWeaver Master Data
Management 7.1® Development Information® MDM Web Dynpro Components: Reference Guide®
Note
In the steps of the Item Details wizard, enter the following values:
§
In step 2, add theCountry andVendor region fields.§
In step 3, set theRaise Event
property toTrue (only for theCountries field). This raises an event for theCountry field value change.Configure the Event Handler
2. After adding the Item Details WD component as a used component, add a new method to the Component Controller of the custom WD wrapper.
3. ChooseEvent handler as theMethod Type.
4. Update the following method properties:
Property Value
Name
valueChangedhandler
(can be any name)Event Source
Select the name of the Item Details WD component that you created in step 1 above.December 2013 22
Implement the sample code in the wrapper application
5. Enter the following sample code for the
valueChangedhandler
method. Any custom logic can be executed in the event handler method.Example 1 – using a string to limit field values:
Result
When you selectCountry =
USA
, theVendor region dropdown list is limited to display only USA relevantregions:
When you selectCountry =
Canada
, theVendor region dropdown list is limited to display only CanadianDecember 2013 24 Example 2 – using an MDM value to limit field values by record Ids:
You can also limit the lookup field values to be specific values (MDM internal Ids). For example, when country =
USA
, limit theVendor region dropdown list to include regions with internal IDs1
and17
.6
Setting Field Default Values in an Item
Details Component
...
This example shows you how to define and set default values for fields in an Item Details WD component. This option is used when values are consistent and saves the user from having to keep re-entering the same values. If a value does change, the default values can be overridden.
How is this implemented?
A subset of fields in the Item Details WD component is populated with preconfigured default values. When the user chooses theCreate button on the UI of the Item Details WD component, a
CreateRecord
event is used as the trigger for a hook method and code is executed (a sample code is provided below).In this example, default values are set for the following fields: · Subject – lookup field toSubjectstable
· Country – lookup field toMDM_COUNTRIES table · Vendor region – lookup field toMDM_REGIONS table · URL – a standard text field
Procedure
Important
Ensure that you have carried out all the prerequisite steps. For more information, seePrerequisites on page1.
Configure the Item Details WD component
...
1. In the MDM Web Dynpro Configuration Manager, configure an Item Details WD component. For more information, seehttp://help.sap.com/nwmdm71®SAP NetWeaver Master Data
Management 7.1® Development Information® MDM Web Dynpro Components: Reference Guide®
Configuring an Item Details Web Dynpro Component.
Note
In step 2 of the Item Details wizard, select the following fields:
§
Subject§
Country§
Vendor regionDecember 2013 26 Field Details
Field Name Field Code Lookup Table LookupValue LookupValue ID
Subject
MDM_MDM_SUBJECT
Subjects Brushes 24Country
COUNTRY
MDM_COUNTRIES USA 11Vendor
region
VendorRegion
MDM_REGIONS NewYork 28The following screen captures show the MDM Data Manager view of the three lookup tables and for each, the selected lookup value and its internal ID.
December 2013 28
Configure the Event Handler
2. After adding the Item Details WD component as a used component, add a new method to the Component Controller of the custom WD wrapper.
3. ChooseEvent handler as theMethod Type.
4. Update the following method properties:
Property Value
Name
createRecordHandler
(any name)Event Source
Select the name of the Item Details WDcomponent you created in step 1 above.
Subscribed Event CreateRecord
Implement the sample code in the wrapper application
5. Enter the following sample code for the
createRecordHandler
method. (Any custom logic can be executed in theEvent handler method).The sample code below shows the settings of the following default values:
¡ The first is a multi-valued lookup field, where a multi-value lookup ID is specified. ¡ The second, a URL text field, where a text only value is specified.
December 2013 30
Result
The runtime behavior is as follows:
InCreate mode, the four chosen fields are pre-populated with the default settings.
7
Adding Custom Buttons to an Item
Details Component
You would typically use this configuration for controlling a BPM process but it can also be used in a stand-alone custom application. Using the MDM Web Dynpro Configuration Manager, you can add a customized tool bar with buttons, give each button a label (multilingual), and insert a uniqueStatus Text (for example,Reject
orApprove). These buttons are visible in a separate row on the UI of the Item Details WD component (above the standard buttons).
Procedure
Important
Ensure that you have carried out all prerequisite steps. For more information, seePrerequisites on page1.
Configure the Item Details WD component
...
1. Using the MDM Web Dynpro Configuration Manager, add theApprove andReject custom buttons in step 5 of the Item Details wizard. For each custom button, you can add label translations.
Example showing theReject button:
Configure the Event Handler
2. After adding the Item Details WD component as a used component, add a new method to the Component Controller of the custom WD wrapper.
December 2013 32 3. ChooseEvent handler as theMethod Type.
4. Update the following method properties:
Property Value
Name
completeTaskHandler
(any name)Event Source
Select the the Item Details WD component youcreated in step 1 above
Subscribed Event completeTaskEvent
5. In the Data Modeler view, select the data link and chooseEdit.
6. Map the context by creating and mapping the
BPMStatus
context attribute of the Item Details WD component.Note
At runtime when you choose any of the custom buttons on the UI of the Item Details WD component, the
BPMStatus
is filled with the values of theStatus Text buttons (for example,December 2013 34
Implement the sample code in the wrapper application
7. Enter the following sample code for the
completeTaskHandler
method (any custom logic can be executed in theEvent handler method). In our example, theApprove button was chosen. A message,Approve button was pressed
is printed by the wrapper application. The same applies for theReject button.
Result
The following is the runtime behavior when theApprove button is chosen:
8
Integrating MDM Change Tracker and
MDM WD Components
The Change Tracker is a Web Dynpro application that provides a user interface for displaying and viewing changes stored in the MDM Change History database.
This example demonstrates how you can define a custom Web Dynpro wrapper application that uses both Result Set and Change Tracker Web Dynpro components. A
selectRecord
event is fired from the Result Set WD component which passes the record’s internal ID to the Web Dynpro Change Tracker application. However, to list the selected record’s change history, the Change Tracker application expects to receive the record’s permanent ID. Therefore you need to implement a sample code that will convert the internal ID of the selected record to its permanent ID.Prerequisites
...
· You have configured a Change Tracker application.
For more information, seehttp://help.sap.com/nwmdm71®SAP NetWeaver Master Data
Management 7.1® Integration of SAP Components with MDM ® Change Tracker Application Guide ®
Configuration Process.
· You have carried out all prerequisite steps.
Important
The name of the Change Tracker Web Dynpro software component that you import to your workspace is
MDM_WEB_UI
.For more information, seePrerequisites on page1.
Procedure
...
1. Using the MDM Web Dynpro Configuration Manager, configure an MDM Project and a Result Set WD component.
Note
The names of the configured Project and the Result Set WD component will be used in the
wdDoInit()
method of your wrapper application.December 2013 36 2. Create your custom wrapper WD application using the MDM WD Result Set component and the Change
Tracker as used components.
Reference the steps in the following procedure as a guideline:Building a Stand-Alone Web Dynpro Application on page4. We have highlighted some of the changes that you will have to make for this example:
¡ When setting theDependenciesinclude references to the Result Set WD component, the Change Tracker application, and to the MDM Java API.
¡ When you have defined theComponents Usage for this application, you should see the following result:
¡ To initialize the components, add the following code in the'//@@begin others' area of the
Component Controller:
private RepositoryBean _repositoryBean;
private UserSessionContext _userSessionContext;
¡ Add the following sample code to initialize the custom application in the
wdDoInit()
method:_repositoryBean = new RepositoryBean();
try
{
wdThis.wdGetResultSetInterface().setRepositoryBean(_repositoryBean);
wdThis.wdGetResultSetInterface().setConfiguration("Proj01","rs01");
_userSessionContext =
_repositoryBean.getUserSessionContext();
}
catch (ConfigurationException e)
{
wdComponentAPI.getMessageManager().reportException(e.getLocalizedMessa
ge()
Note
When using the
setConfiguration
method, enter the configuration’s Project name and Result Set WD component name as defined in the MDM Web Dynpro Configuration Manager. ¡ When creating an application for your Web Dynpro DC project, choose your wrapper WDcomponent.
3. Add anEvent Handler as follows:
a. After adding the Result Set WD component as a used component, add a new method to the Component Controller of the custom WD wrapper application.
December 2013 38 b. ChooseEvent handler as theMethod Type.
c. Update the following method properties:
Value Description
Name
recordSelectionHandler
Event Source
Select the name of the Result Set WD component that you configured in step 1 above.Subscribed
Event
The result is the following newly addedEvent handler method with a parameter which is the permanent record ID value.
December 2013 40 d. Implement the following sample code in the wrapper application‘s Component Controller.
try
{
String tableCode =
wdThis.wdGetResultSetInterface().getTableCode();
RepositorySchemaEx schema =
MetadataManager.getInstance().
getRepositorySchema(_userSessionContext);
TableId tableId = schema.getTableId(tableCode);
GetPermanentIdFromRecordIdCommand command =
new
GetPermanentIdFromRecordIdCommand(_userSessionContext);
command.setRecordIds(new RecordId[]{new
RecordId(id)});
command.setTableId(tableId);
command.execute();
int[] permIds = command.getPermanentIds();
if(permIds != null && permIds.length > 0)
{
int permId = permIds[0];
wdThis.wdGetChangeTrackerInterface().setPermanentId(permId);
wdThis.wdGetChangeTrackerInterface().selectLookupTable("" +
tableId.getIdValue());
}
}
catch (SessionException e)
{
wdComponentAPI.getMessageManager().reportException(e.getLocalized
Message());
}
catch (ConnectionException e)
{
wdComponentAPI.getMessageManager().reportException(e.getLocalized
Message());
}
catch (CommandException e)
{
wdComponentAPI.getMessageManager().reportException(e.getLocalized
Message()); }
At runtime
4. After you have built and deployed your wrapper application, add the following as a suffix to the URL link that is generated:
jdbcAlias=<JDBC_Alias>
Where
JDBC_Alias
is the value you have configured as the JDBC alias property name. For example:http://<Host>:<Port>/webdynpro/dispatcher/<WD_application>?jdbcAlias=<
JDBC_Alias>
For more information about configuring the JDBC alias property name, see
http://help.sap.com/nwmdm71® SAP NetWeaver Master Data Management 7.1® Integration of SAP Components with MDM® MDM Change Tracker Application Guide® Creating a Data Source for a JDBC Connector.
5. Select the record in the Result Set WD component. The Change Tracker application displays the change history of the selected record.
December 2013 42
9
Other Examples
9.1
Splitting WD Components into Portal iViews
Background
In this example, we show you how to split a Web Dynpro application into its components, so that each component takes on the appearance of an a individual portal iView.
Process
There are three main steps: ...
1. Configure the components.
2. Add your custom wrapper WD application using the components as used components.
3. Add the
iViewSplitting
property in the application properties and embed the application views in theViewContainerUIElements
.Info
The
ViewContainerUIElement
is a UI element that offers you options when positioning views in the browser window. You can embed this UI element in the layout of an existing view and position it by selecting suitable container layouts (for example,GridLayout
).Procedure
Configure the components
...1. Using the MDM Web Dynpro Configuration Manager, configure the following components: ¡ Item Details (name it
SplitItemDetails
)¡ Result Set (name it
SplitResultSet
)Add your custom wrapper WD application using the components as used
components
2. Implement the procedure for creating a stand-alone application (some of the steps may not be valid for this example).
For more information, seeBuilding a Stand-Alone Web Dynpro Application on page4.
3. In the Component Controller of the wrapper application, initialize the MDM repository bean for the three used MDM components (using the project name and component name as keys for the configurations). Code example:
December 2013 44
Add the
iViewSplitting
property
4. ChooseNew to edit the wrapper application’s properties.
5. SelectPredefined as theType of property.
6. ChooseBrowse to select a predefined application property. 7. Select the
iViewSplitting
property.December 2013 46
Embed the application Views in the
ViewContainerUIElements
9. Add three
ViewContainerUIElements
as placeholders for containing the three views of the WD components.10. Repeat the above step three times for each Web Dynpro component. The result is as follows:
12. Drag and drop the
Interface View
from thePalette and associate the interface view of the three components with the correspondingView element you created in the previous step.13. Save the changes.
14. Build and deploy the new WD application.
15. Log on to portal as Administrator and from the Top Level Navigation (TLN), locate your WD application in thePortal Content role.
December 2013 48 17. Select the target folder and choosePaste as PCD Object.
Result
The new object includes the properties of a Web Dynpro portal page consisting of three Web Dynpro iViews – one for each for the three MDM Web Dynpro components: