how to create webdynpro value help using caf …...sap netweaver 2004s (sp7, sp8 and sp10) web...

43
How to Create Web Dynpro Value Help using CAF Entity Service Method SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 1 How to Create WebDynpro Value Help using CAF Entity Service Method Applies to: SAP NetWeaver 2004s (SP7, SP8 and SP10) Web Dynpro for JAVA and CAF. Summary This document explains how to create Web Dynpro value help using CAF entity service methods. First we will create a Composite Application with Entity Service methods and then we will create a Web Dynpro project using CAF Web Dynpro model and also the presentation logic inside the Web Dynpro Project. But some times Entity Services do not fulfill our business logic requirement; In that case we can write our own custom business logic in side different types of Custom Application methods like “Custom”,” Access” (Create, Read, Update, and Delete), “Queries” or “BW Extractor” according to our requirement and create value help using those Application Service methods. Author: Mithu Ghosh Company: IBM India Private Limited. Created on: 5 th July 2007 Author Bio Mithu Ghosh is an Application Developer working in IBM India Private Limited on SAP Netweaver Technology (CAF, Web Dynpro for JAVA and GP).

Upload: others

Post on 11-Apr-2020

12 views

Category:

Documents


2 download

TRANSCRIPT

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 1

How to Create WebDynpro Value Help using CAF Entity Service Method

Applies to: SAP NetWeaver 2004s (SP7, SP8 and SP10) Web Dynpro for JAVA and CAF.

Summary This document explains how to create Web Dynpro value help using CAF entity service methods. First we will create a Composite Application with Entity Service methods and then we will create a Web Dynpro project using CAF Web Dynpro model and also the presentation logic inside the Web Dynpro Project. But some times Entity Services do not fulfill our business logic requirement; In that case we can write our own custom business logic in side different types of Custom Application methods like “Custom”,” Access” (Create, Read, Update, and Delete), “Queries” or “BW Extractor” according to our requirement and create value help using those Application Service methods. Author: Mithu Ghosh Company: IBM India Private Limited. Created on: 5th July 2007

Author Bio

Mithu Ghosh is an Application Developer working in IBM India Private Limited on SAP Netweaver Technology (CAF, Web Dynpro for JAVA and GP).

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 2

Table of Contents Preconditions .................................................................................................................... 3 The Step By Step Solution................................................................................................ 3

CAF Development Component Project ........................................................................................ 3 Step 1: Creating a New Development Component Project ...................................................... 3 Step 2: Modeling Entity Services.............................................................................................. 7 Step 3: Defining Entity Service Attributes................................................................................. 7 Step 4: Defining Entity Service Operations .............................................................................. 9 Step 5: Create and publish proxy classes in CAF DC............................................................ 10 Step 6: Customize NWDI settings .......................................................................................... 11 Step 7: Generating Code and Building Services .................................................................... 13 Step 8: Deploy and Test Project............................................................................................. 14

Create the Web Dynpro Application using CAF DC................................................................... 17 Step1: Web Dynpro Development Component Project .......................................................... 17 Step 2: Import proxy classes into Web Dynpro DC ................................................................ 19 Step 3: Create Dictionary Data Type...................................................................................... 23 Steps to create Simple Types................................................................................................. 23 Step 4: Defining Value Node with attributes under Context Structure ................................... 25 Steps to create Value Node and Value Attribute.................................................................... 25 Step 5: Context Mapping and Model Binding ......................................................................... 28 Step 6: Defining Life Cycle Methods for Value Help .............................................................. 30 Step 7: Designing view Layout ............................................................................................... 32 Steps to Design the View Layout............................................................................................ 32 Step 8: Implement the Methods.............................................................................................. 33 Step 9: Create Application...................................................................................................... 38 Step 10: Build and Deploy project .......................................................................................... 39

Run Application............................................................................................................... 40 Output Screen Shots ...................................................................................................... 40

Related Content.............................................................................................................. 42 Disclaimer and Liability Notice........................................................................................ 43

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 3

Preconditions The following are the preconditions that we need. • Basic Concepts of Java programming. [ Java Tutorials ] • Basic knowledge of Composite Application Framework. [My First Composite Application] • An overview of Web Dynpro Programming [Using a Composite Application via a Web Dynpro UI ] Before Deploying our Web Dynpro Application we should check whether the configuration settings for the J2EE server and for the SDM server are entered correctly in the Netweaver Developer Studio or not. To check the server settings, we have to choose the menu path Window => Preferences=> SAP J2EE Engine

The Step By Step Solution

CAF Development Component Project

Step 1: Creating a New Development Component Project

• Open NWDS, Select File => New => Project

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 4

• A New Project wizard will appear select “Development Component Project“

• Click on Next.

• Select “My Components” under “Local Development”

• Click on Next.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 5

• A New Development Component Project

wizard will appear. Enter the following information Vendor: ibm.com

Name: custcaf

Caption: Customer CAF Project

Language: American English

Domain: Sap xApps

Type: select Composite Application Services under sap.com • Click on Next. • Click on Next.

• Click on Finish.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 6

• Click on OK.

• Created project will be available in

Composite Application Services Perspective.

• In Navigator you will see 6 projects (Enterprise Application, Dictionary, EJB Module, Meta Data, Web Dynpro, UME permissions) that are created automatically.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 7

Step 2: Modeling Entity Services • In Service Explorer, expand the node custcaf and click the Entity Services node with the secondary mouse button. Choose New. • A New Entity Service wizard will appear. Create an Entity Service with the following information.

Entity Service name: Customer

• Click On Finish. • Created Entity Service (Customer) will be available under Entity Services node.

Step 3: Defining Entity Service Attributes • Select the Attributes tab page for the entity service Customer. • In the Attributes pane on the right-hand side of the screen, click Customer with the secondary mouse button and choose Create Attribute.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 8

• A New Attribute wizard will appear

Enter the following information Attribute name: custNo

Attribute description: Customer Number

Enable Key Browse and select

Datatype: com.sap.caf.core.shortText

• Click on Finish.

• Similarly create attribute 2 Non Key attributes with the following details.

Attribute name: custName

Attribute description: Customer Name

Datatype: com.sap.caf.core.shortText

Attribute name: custType

Attribute description: Customer Type

Datatype: com.sap.caf.core.shortText

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 9

• Created Attributes will be available in the Attributes list.

Step 4: Defining Entity Service Operations • Select to the Operations tab. Choose Add from the Operations window. • A New Operation wizard will appear. Enter following information.

Operation name : getAllAvailableCustomer

Description : Get All Available Customer • Click on Finish. • Similarly create another operation

with the following information. Operation name : getCustomerByNumber

Description : Get Customer by Number

Select custNo from the attribute list table.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 10

• Created operations will be available in the Operations list.

• Select Permissions tab and uncheck deselect the Permission checks enabled

Step 5: Create and publish proxy classes in CAF DC

• First the proxy classes have to be generated in the composite application DC: To do this, right click in the Service Explorer on the DC name (custcaf) and Choose Create Web Dynpro Model.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 11

• A Create Web Dynpro Model Wizard will appear. • Click on OK. • Go to the Web Dynpro Perspective. check in the Web Dynpro Explorer: The proxy classes are generated and can be browsed in the Web Dynpro DC of the composite application at: /src/packages/com/ibm/custcaf/servi

ces/..

Step 6: Customize NWDI settings • Before the new Web Dynpro DC can access the proxy classes from the CAF DC, you have to customize some necessary NWDI settings.

• In the Web Dynpro Explorer open the Web Dynpro project of the CAF DC .

• Expand the branch DC Metadata

• Right click on the node Public Parts and choose New Public Part…

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 12

• A Add Public Part wizard will appear. Enter Name: custcaf Ensure that “Provides an API for Developing/compiling other DCs” is checked. • Click Next • Select an available entry.

• Ιn Select Entity Type: Choose Java Package Tree • In Select Entities: Check com.ibm.custcat.services.custcaf

Ensure inside “Add Entity to public part” “as Class” is checked.

• Click on Finish

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 13

• Choose (Save All Metadata) to save the project.

Step 7: Generating Code and Building Services

• In the Service Explorer view, select the project custcaf with the secondary mouse button and choose Generate All Project Code. • A Generate Application window will appear.

• Click on OK. • Click custcaf with the secondary mouse button and select Development Component => Build…

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 14

• A Build Development Components window will appear. • Click on OK. • Check the build status in the General User Output and Deploy Output View at the bottom of the screen whether

build is successful or errors occur.

Step 8: Deploy and Test Project • Check the status of the J2EE engine whether it is running or not.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 15

• Click custcaf with the secondary mouse button and select Deploy to J2EE engine. • A Logon to SDM window will

appear. Enter your SDM password

• Click on OK • Check the deployment status in the General User Output and Deploy Output View at the bottom of the screen

whether Deploy is successful or errors occur.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 16

• Click Customer with the secondary

mouse button and Test. • A Service Browser Window will open Enter your portal User Id* and Password* • Click on Log On

• From the Available services Select “Customer” under “ibm.com/custcaf/customerService/ Customer” and Add some records. To insert record first click on New button then enter the value for field custNo, custName and custType and Save

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 17

Create the Web Dynpro Application using CAF DC

Step1: Web Dynpro Development Component Project • Select File => New => Project.

• A New Project wizard will appear select “Development Component Project“

• Click on Next.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 18

• Select “My Components” under

“Local Development” • Click on Next.

• A New Development Component Project

wizard will appear. Enter the following information Vendor: ibm.com

Name: custwd

Caption: Customer WD Project

Language: American English

Domain: Sap xApps

Type: select Web Dynpro under sap.com

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 19

• Click on Next. • Click on Finish. • Created project will be appeared in

Web Dynpro Perspective

Step 2: Import proxy classes into Web Dynpro DC • Now you have to import the custcaf generated classes into Web Dynpro DC “custwd”.

• In the Web Dynpro Explorer of the Web Dynpro perspective expand the new “custwd” Web Dynpro project.

• Expand the nodes DC Meta Data => DC Definition and right click on Used DCs.

• Choose Add used DC…

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 20

• A Add Dependency

wizard will appear. • Expand the node My Components under Local Development.

• Choose custcaf under custcaf/webdynpro

-> DC metadata -> Public Parts • Check Dependency Type Design Time, Build Time, Deploy Time and Run Time • Click on Finish.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 21

Similarly add the following DCs under Used DCs of custwd.

• Public parts types_compilation of DC caf/core/dict (CAF compartment)

• Public parts com.sap.caf.ui.utils of DC caf/UI/ptn/common (CAF compartment)

• Public parts default of DC tc/col/runtime (compartment SAP_JTECHS) • Click on Finish [For SP10 you have to add the following DC in Used DCs of custwd.

• Public Parts types_compilation of DC caf/core/dict (CAF compartment) • Public Parts com.sap.caf.ui.utils of DC caf/UI/ptn/common (CAF compartment) • Public Parts types_compilation in DC caf/runtime/uicoupling/api (CAF compartment) • caf/runtime/uicoupling/api/lib (CAF compartment)

] • Ensure all the DCs are added under LocalDevelopment~custwd~ibm.com -> DC MetaData -> DC Definition-> Used DCs

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 22

• Expand the node “Web Dynpro” Right click Web DynproComponents . • Choose Create Web Dynpro Component. • A Create Web Dynpro Component wizard will appear. Enter the following information Component Name: CustomerComp

Component Package: ibm.com.customer

Window Name: CustomerWindow Window Package: ibm.com.customer

View Name: CustomerView View Package: ibm.com.customer

• Click on Finish

• Choose (Save All Metadata). • In the “Web Dynpro Explorer” expand

the tree of “CustomerComp” Right Click on Used Models and choose Add.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 23

• A Selection Needed wizard will appear. • Check custcaf. • Click on OK.

Step 3: Create Dictionary Data Type Create 3 Simple Types Dictionary Data Type (cname_stype, cnum_stype and ctype_stype) under “ibm.com.customer “ package and give Field Label and Column Label in the Representation of each data type so that in the Value help popup all the fields label and column label comes.

Steps to create Simple Types • Expand the node “Dictionaries” Right click Simple Type under Local Dictionary -> Data Types and choose Create Simple Type. • A New Simple Type wizard

will appear. Enter the Following information

Simple Type name: cname_stype Simple Type package: ibm.com.customer • Click on Finish

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 24

• A Project is not under source control wizard will appear. • Click on Yes. • Created Simple Types will be shown

in the right-hand side pane click on Representation tab and Enter the Following information Field Label: Customer Name Column Label: Customer_Name

• Choose (Save All Metadata) to save the project. Similarly create 2 more Simple Type With the following information. 1> Simple Type name: cnum_stype Simple Type package: ibm.com.customer Field Label: Customer Number Column Label: Customer_Number

• Choose (Save All Metadata) to save the project. 2> Simple Type name: ctype_stype Simple Type package: ibm.com.customer Field Label: Customer Type Column Label: Customer_Type

• Choose (Save All Metadata) to save the project.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 25

• All the 3 Created Simple Types will

be available in the Simple Type list.

Step 4: Defining Value Node with attributes under Context Structure

Create the following “Value Node” with the “value attribute” within the context of CustomerComp component controller as described bellow. Select the attribute and change the Type of the attribute from the properties window if needed (default type is string).

Value Node Cardinality Value Attribute Type

cname ibm.com.customer.cname_stype cnum ibm.com.customer.cnum_stype

CustomerDetails

0..n ctype ibm.com.customer.ctype_stype

CustomerNum

0..1

customernumber

ibm.com.customer.cnum_stype

name

string no string

CustomerResult

0..n

type string

Steps to create Value Node and Value Attribute In the “Web Dynpro Explorer” expand the tree of “CustomerComp” and double click on Component Controller.

• Right click on context Choose New -> Value Node

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 26

• A Context value node wizard will appear.

Enter Name : CustomerDetails

• Click on Finish

• Created Value Node will be available in context. • Right click on Value Node “CustomerDetails” and choose New -> Value Attribute • A Context value Attribute wizard will

appear . Enter Name : cname

• Click on Finish.

• Created attribute will be available under “CustomerDetails” value Node. • From the Properties Window change the “cname” attribute “type” value to ibm.com.customer.cname_stype .

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 27

Similarly create 2 more “value attribute” under value Node “CustomerDetails” With the following information. 1> Name : cnum type : ibm.com.customer.cnum_stype 2> Name : ctype type : ibm.com.customer.ctype_stype • Choose (Save All Metadata). Similarly create another 2 Value Nodes and attributes with the following information.

1> Value Node Name : CustomerNum Value Attribute Name : customernumber type : ibm.com.customer.cnum_stype

Change the cardinality of Value node CustomerNum to 0..1 from the properties window. Choose (Save All Metadata).

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 28

2> Value Node name : CustomerResult Value Attributes

1> Name : name type : string

2> Name : no type : string

3> Name : type type : string

Choose (Save All Metadata).

• All the 3 created Value node will

be available under context.

Step 5: Context Mapping and Model Binding • Open Diagram View by double Click on the Component (CustomerComp) In the diagram view do the mapping between

1> Views (CustomerView) and “Component Controller “. 2> “Component Controller” and used model (custcaf).

Steps for Mapping.

1> Context Mapping

From CustomerView to “Component Controller “. • Select create a data link from toolbar and draw a line from CustomerView to Component Controller a wizard will appear. • Select CustomerDetails and try to drop it under the context of CustomerView a wizard will appear. Check CustomerDetails.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 29

• Click on OK. Similarly do the context mapping for the remaining two Value Nodes (CustomerNum, CustomerResult) from CustomerComp to CustomerView

• Click on Finish.

2> Model Mapping From “Component Controller” to used model (custcaf). • Select create a data link from toolbar and draw a line from Component Controller to used model custcaf a wizard will appear. • Select ACustomer and try to drop it under the context of CustomerComp a wizard will appear. Check attributes custName, custNo and custType.

• Click on OK. • Click on Finish.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 30

Choose (Save All Metadata).

• After Mapping Diagram View will look like.

Step 6: Defining Life Cycle Methods for Value Help Create the following methods.

Method Name Return Type getOVSInputNode com.sap.tc.webdynpro.progmodel.api.IWDNode getOVSListener com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener

getOVSOutputNode com.sap.tc.webdynpro.progmodel.api.IWDNode

Steps to create Methods. • Select to the Methods tab. Choose New from the Methods Pane. • A New Method wizard will appear. Select Method. • Click on Next • A wizard will appear. Enter the following information Name: getOVSInputNode

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 31

Browse Return Type: com.sap.tc.webdynpro.progmodel.api.IWDNode IWDNode. Click on … A Wizard will appear Select Java Native Type. Click on Browse. Enter the following information. Choose a Type: IWDNode Click on OK. Click on OK. • Click on Finish. Similarly create 2 more methods with the following information.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 32

1> Name : getOVSListener Return type : com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener 2> Name : getOVSOutputNode Return type : com.sap.tc.webdynpro.progmodel.api.IWDNode • All the three created methods will be available under Methods Pane.

Step 7: Designing view Layout In the “Web Dynpro Explorer” expand the tree of “CustomerComp” and double click on CustomerView. Design the Layout Like.

.

Steps to Design the View Layout. • Select Root UI element Container from the outline window click on the secondary mouse bottom and choose

Insert Child a wizard will appear select Group from Type and Finish. From outline window select Group [Group-Child] and from Properties window set “width” property value 100%. Select Group_Header [Caption-Header] and from the Properties window set “text” property value Customer Layout

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 33

• Select Group [Group-Child] click secondary mouse button and choose Insert Child a wizard will appear select

ToolBarInputField from Type and Finish. From the Properties window set “labelText” property value Customer Number: and “value” Property value CustomerNum.customernumber

• Select Group [Group-Child] click secondary mouse button and select Apply Template a wizard will appear select Table. Click on Next. A wizard will appear check CustomerResult. Click on Next. Click on Finish. • Select name_header From the outline and set “text” property value Customer Name. • Select no_header From the outline and set “text” property value Customer Number. • Select type_header From the outline and set “text” property value Customer Type. Choose (Save All Metadata).

Step 8: Implement the Methods.

Provide the following implementation within the wdDoInit method of the View (Customer View).

//@@begin wdDoInit() //Apply the Value Help for Customer Number Input field. IWDAttributeInfo ovsStartUpAttributes[] = { wdContext.nodeCustomerNum().getNodeInfo().getAttribute("customernumber") }; IWDOVSContextNotificationListener listener = wdThis.wdGetCustomerCompController().getOVSListener(); if (listener != null) { WDValueServices.addOVSExtension( "Customer Details", ovsStartUpAttributes, wdThis.wdGetCustomerCompController().getOVSInputNode(), wdThis .wdGetCustomerCompController() .getOVSOutputNode(), listener); } //@@end

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 34

//@@begin imports import ibm.com.customer.wdp.IPrivateCustomerView; import com.sap.tc.webdynpro.progmodel.api.IWDAttributeInfo; import com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener; import com.sap.tc.webdynpro.progmodel.api.WDValueServices; //@@end

Provide the following implementation with in the methods of Component Controller (CustomerComp). i> Inside wdDoInit Method

//initialize the Value.

wdContext.nodeCustomerNum().bind(wdContext.createCustomerNumElement()); //initialize the model node using caf service create method. wdContext.nodeACustomer().bind(CustomerServiceProxy.create());

ii> Inside getOVSInputNode Method

//return the Input Value node return wdContext.nodeCustomerNum();

iii> Inside getOVSListener Method

//return the listener return ovsListener;

iv> Inside getOVSOutputNode Method //return Value mode CustomerDetails

return wdContext.nodeCustomerDetails();

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 35

Listener Implementation: listener implements value help Life cycle methods i) onQuery ii) applyResult and iii) applyInputValues //@@begin others

private IWDOVSContextNotificationListener ovsListener = new OVSNotificationListener(); private class OVSNotificationListener implements IWDOVSContextNotificationListener { //This meth d will o be called on click event of the Go button in the OVS popup public void onQuery( IWDNodeElement queryInputNodeElement, IWDNode queryOutputNode) { //Type Cast Input element

IPublicCustomerComp.ICustomerNumElement custInputElm = (IPublicCustomerComp.ICustomerNumElement) queryInputNodeElement;

//Type cast Output node IPublicCustomerComp.ICustomerDetailsNode custOutNode = (IPublicCustomerComp.ICustomerDetailsNode)queryOutputNode;

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 36

try { if(wdContext.currentCustomerNumElement().getCustomernumber()== null) {//without input // Calling entity service method and storing the result in aspect_list IAspect aspect_list = CustomerServiceProxy.getAllAvailableCustomer(); // Assigning the Value to the Model node wdContext.nodeACustomer().bind(aspect_list); //Populating CustomerDetails Value Node from the ACustomer Model Node for(int i=0;i<wdContext.nodeACustomer().size();i++) {

IPublicCustomerComp.ICustomerDetailsElement custElm = custOutNode.createCustomerDetailsElement();

IAspectRow aspect_row = aspect_list.getAspectRow(i); custElm.setCname(wdContext.nodeACustomer().getACustomerElementAt(i).getCustName()); custElm.setCnum(wdContext.nodeACustomer().getACustomerElementAt(i).getCustNo()); custElm.setCtype(wdContext.nodeACustomer().getACustomerElementAt(i).getCustType()); wdContext.nodeCustomerDetails().addElement(custElm); } nd if }//e else //with input { // Calling entity service method and storing the result in aspect_list IAspect aspect_list = CustomerServiceProxy.getCustomerByNumber(

wdContext.currentCustomerNumElement() .getCustomernumber());

// Assigning the Value to the Model node wdContext.nodeACustomer().bind(aspect_list); // P pulo ating CustomerDetails Value Node from the ACustomer Model Node for(int i=0;i<wdContext.nodeACustomer().size();i++) {

IPublicCustomerComp.ICustomerDetailsElement custElm = custOutNode.createCustomerDetailsElement();

IAspectRow aspect_row = aspect_list.getAspectRow(i); custElm.setCname(wdContext.nodeACustomer().getACustomerElementAt(i).getCustName()); custElm.setCnum(wdContext.nodeACustomer().getACustomerElementAt(i).getCustNo()); custElm.setCtype(wdContext.nodeACustomer().getACustomerElementAt(i).getCustType()); wdContext.nodeCustomerDetails().addElement(custElm); } } d else // En }catch (Exception e)

{ IWDMessageManager msgMgr = wdComponentAPI.getMessageManager(); msgMgr.reportSuccess("Got Exception"); } }// End Of onQuery

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 37

// This method will be called on click event of the selected row in the OVS popup public void applyResult(IWDNodeElement applicationNodeElement,IWDNodeElement queryOutputNodeElement) { // Setting The lookup result value to the view

if(wdContext.nodeCustomerResult().size()>0) { // Populating CustomerResult Value Node from the CustomerDetails Value Node wdContext.currentCustomerNumElement().setCustomernumber(

wdContext.currentCustomerDetailsElement().getCnum()); wdContext.currentCustomerResultElement().setName(

wdContext.currentCustomerDetailsElement().getCname()); wdContext.currentCustomerResultElement().setNo(

wdContext.currentCustomerDetailsElement().getCnum()); wdContext.currentCustomerResultElement().setType(

wdContext.currentCustomerDetailsElement().getCtype()); } else { //first time when there is no created element // Populating CustomerResult Value Node from the CustomerDetails Value Node wdContext.currentCustomerNumElement().setCustomernumber( wdContext.currentCustomerDetailsElement().getCnum()); wdContext.nodeCustomerResult().addElement(

wdContext.nodeCustomerResult().createElement()); wdContext.currentCustomerResultElement().setName(

wdContext.currentCustomerDetailsElement().getCname()); wdContext.currentCustomerResultElement().setNo(

wdContext.currentCustomerDetailsElement().getCnum()); wdContext.currentCustomerResultElement().setType(wdContext.currentCustomerDetailsElement().getCtype());

} }// End of applyResult

//This method will be called on click event of the Value help used in the Customer Number input field public void applyInputValues(IWDNodeElement applicationNodeElement,IWDNodeElement queryInputNodeElement) {//Setting the input for value help wdContext.currentCustomerNumElement().setCustomernumber(null); }// End of applyInutValues }// End of OVSNotificationListener

//@@end

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 38

//@@begin imports import ibm.com.customer.wdp.IPrivateCustomerComp; import ibm.com.customer.wdp.IPublicCustomerComp; import com.ibm.custcaf.services.custcaf.customerservice.CustomerServiceProxy; import com.sap.tc.col.client.generic.api.IAspect; import com.sap.tc.col.client.generic.api.IAspectRow; import com.sap.tc.webdynpro.progmodel.api.IWDMessageManager; import com.sap.tc.webdynpro.progmodel.api.IWDNode; import com.sap.tc.webdynpro.progmodel.api.IWDNodeElement; import com.sap.tc.webdynpro.progmodel.api.IWDOVSContextNotificationListener; //@@end

Choose (Save All Metadata).

Step 9: Create Application

• Expand the node “Web Dynpro” Right Click on “Applications” and Choose Create Application. • A New Application wizard will appear. Enter the following information

Name : CustomerApp Package: ibm.com.customer Click on Next.

• A wizard will appear ensure “use existing component” is selected .

Click on Next.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 39

• A wizard will appear choose Web Dynpro Component: CustomerComp Interface View: CustomerWindowInterfaceView

Click on Finish. • Created Application will be available

Under Applications.

Step 10: Build and Deploy project

• Click custwd with the secondary mouse button and select Development Component => Build… • A wizard will appear choose OK.

• Check the build status in the General User Output and Deploy Output View at the bottom of the screen whether

build is successful or errors occur.

• Deploy the Component; choose Development Component=> Deploy.

• Check the deployment status in the General User Output and Deploy Output View at the bottom of the screen whether Deploy is successful or errors occur.

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 40

Run Application Right click on CustomerApp and choose Run.

Output Screen Shots Used Node CustomerNum applyInputValues Method is Called

Used Node CustomerResult Used Node CustomerDetails

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 41

onQuery Method is Called

applyResult Method is Called

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 42

Related Content Advanced Input Help - The Object Value Selector (OVS)

How to Create Web Dynpro Value Help using CAF Entity Service Method

SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 43

Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.