How to Call RFC from Web Dynpro Application Applies to: SAP Net Weaver 2004s (SP8, SP10 and SP11 and SP13) Web Dynpro. Summary This document explains how to access a BAPI From web dynpro application. It explains the process of creating a Web dynpro project; importing a BAPI as adaptive RFC Model from Webdynpro application and executing the Model get the Details. Author: Mithu Ghosh Company: IBM India Private Limited, KOLKATA Created on: 30 Oct, 2008 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). 2008 SAP AG 1
Table of Contents Preconditions... 3 The Step By Step Solution... 3 CAF Development Component Project... 3 Step1: Creating a New Development Component Project... 3 Step2: Create Adaptive RFC Model... 6 Step3: Create Component, View and Window and use Model... 9 Step4: Context Model Mapping... 11 Step5: Create Action in View... 14 Step6: Designing view Layout and associate the Action... 15 Step7: Implementation... 17 Step8: Create Application... 18 Step9: Build and Deploy project... 20 Run Application... 21 Output Screen Slot... 22 Related Content... 22 2008 SAP AG 2
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] 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 Step1: Creating a New Development Component Project Open NWDS, Select File => New => Project 2008 SAP AG 3
A New Project wizard will appear select Development Component Project Click on Next. Select My Components under Local Development Click on Next. 2008 SAP AG 4
A New Development Component Project wizard will appear. Enter the following information Vendor: ibm.com Name: fltdata/ui Caption: Flight User Interface Language: American English Domain: Sap xapps Type: select Web Dynpro under sap.com Click on Next. Click on Finish. 2008 SAP AG 5
Created project will be appeared in Web Dynpro Perspective Step2: Create Adaptive RFC Model Expand the node Web Dynpro Right click Models. Choose Create Model. A New Model wizard will appear. Choose Import Adaptive RFC Model. Click on Next. 2008 SAP AG 6
A New wizard will appear. Enter the following information. Model Name: FlightModel Model Package: com.ibm.fltdata.model.flightmodel Default Logical system name for model Instances: WD_RFC_FLIGHTDATA_MODEL Default Logical system name for RFC Metadata: WD_RFC_FLIGHTDATA_META Click on Next. A wizard will appear Select Single Server (SAP server you want to connect to). Enter relevant server logon information. Host Name: Address of the target system host System Number: System service ID number Client: Client of the system Logon Name: user name Password: user password Language: Preferred language (Default value: EN) Click on Next and wait until the Connection is established. A wizard for importing RFCs appears. 2008 SAP AG 7
Enter Function Name: BAPI_FLIGHT_GETLIST Click on Search. Check the function Name and Click on Finish. Click on Next. Click on Finish. Created FlightModel will be appeared under Models. 2008 SAP AG 8
Step3: Create Component, View and Window and use Model 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: FlightComp Component Package: com.ibm.fltdata Window Name: FlightWindow Window Package: com.ibm.fltdata View Name: FlightView View Package: com.ibm.fltdata Click on Finish 2008 SAP AG 9
Created FlightComp component will be available under Web Dynpro Components. And Created view FlightView will be available under Views and Created FlightWindow will be available under Windows. In the Web Dynpro Explorer Expand the tree of FlightComp Right Click on Used Models and choose Add. 2008 SAP AG 10
A Selection needed wizard will appear. Check FlightModel. Click on OK. Choose (Save All Metadata) to save the project. Step4: Context Model Mapping Go to the diagram view by double Click on the FlightComp. Do the mapping between Component Controller and Used Models (FlightModel) by drawing a line from Component Controller to FlightModel. A Edit Context Mapping wizard will appear drag the BAPI_Flight_Getlist_Input class from FlightModel to FlightComp. A Edit Context Mapping wizard will Appear Check the nodes. Destination _From, Destination_To, Flight_List under Output node with the attributes as per the figure, Airline and Max_Rows Click on OK. 2008 SAP AG 11
Click on Finish. Similarly draw the mapping between FlightView to Component Controller. Drag the Bapi_Flight_Getlist_Input Node from FlightComp to FlightView 2008 SAP AG 12
A Edit Context Mapping wizard will Appear Check the nodes. Click on OK. Click on Finish. 2008 SAP AG 13
Choose (Save All Metadata) to save the project. After Mapping diagram view looks like. Step5: Create Action in View Double Click on the FlightView Click On Actions attributes Click on New. A wizard will appear. Enter the following details Name: SearchFlight Text: Search Flight List Click Next. Click Finish. 2008 SAP AG 14
Step6: Designing view Layout and associate the Action In the Web Dynpro Explorer expand the tree of FlightComp and double click on FlightView. Design the Layout Like.. Associate the action created Action SearchFlight with the Search Button 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 Flight Layout Select Group [Group-Child] click secondary mouse button and select Insert Child a wizard will appear select Type TransparentContainer Id TransparentContainer. Click on Finish 2008 SAP AG 15
Select TransparentContainer [TransparentContainer-Child] click secondary mouse button and select Apply Template a wizard will appear select Form. Click on Next. Select the following Attributes 1> City under Destination_From 2> City under Destination_To 3> Airline 4> Max_Rows Click Next Click Finish Select TransparentContainer [TransparentContainer-Child] click secondary mouse button and select Insert Child a wizard will appear select Type Button Id Button. Click on Finish in Properties of Button text value Enter text Search. Select Group [Group-Child] click secondary mouse button and select Apply Template a wizard will appear select Table. Click on Next. Select the following attributes under Bapi_Flight_Getlist_Input=> Output => Flight_List 1> Airline 2> Airlineid 3> Arrdate 4> Arrtime 5> Cityfrom 6> Cityto 7> Connectionid 8> Curr 9> Deptime 10> Flightdate 11> Price 2008 SAP AG 16
Change the table layoutdata property value to MatrixHeadData Outline of Webdynpro looks like Enter the labelfor property value blank For City_0_label, City_label, Airline_label and Max_Rows_label And Text property value City From,City To,AirLine and Max_Rows Choose (Save All Metadata). Step7: Implementation. Provide the following implementation within the wddoinit method and SearchFlight Action of the View (Flight View). //@@begin wddoinit() Bapiret2 bapiret2 = new Bapiret2(); Bapisfldat bapisfldat = new Bapisfldat(); Bapisfldra bapisfldra = new Bapisfldra(); Bapisfldst bapisfldstfrom = new Bapisfldst(); Bapisfldst bapisfldstto = new Bapisfldst(); Bapiparex bapiparex = new Bapiparex(); Bapi_Flight_Getlist_Input bapi_flight_getlist_input = new Bapi_Flight_Getlist_Input(); 2008 SAP AG 17
//@@begin onactionsearchflight(serverevent) try { wdcontext.nodebapi_flight_getlist_input().currentbapi_flight_getlist_inputel ement().modelobject().execute(); wdcontext.nodeflight_list().invalidate(); wdcontext.nodeoutput().invalidate(); } catch (WDDynamicRFCExecuteException e) { wdcomponentapi.getmessagemanager().reportexception("error in Executing Flight Model."+e.getMessage(),true); } Choose (Save All Metadata). Step8: 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 : FlightApp Package: com.ibm.fltdataapp Click on Next. 2008 SAP AG 18
A wizard will appear ensure use existing component is selected. Click on Next. A wizard will appear choose Web Dynpro Component: FlightComp Interface View: FlightWindowInterfaceView Click on Finish. Created Application will be available Under Applications. 2008 SAP AG 19
Step9: Build and Deploy project Click the project fltdata~ui~ibm.com 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. Before Deploying Check the status of the J2EE engine whether it is running or not. 2008 SAP AG 20
Run Application Before Running the Application make sure that JCos are configured. To configure JCos go to the path http://hostname:port/webdynpro/welcome/welcome.jsp then got to the Content Administrator enter user id and password Click on Maintain JCO Detonations Right click on FlightApp and Choose Run. 2008 SAP AG 21
Output Screen Slot Related Content For more information, visit the User Interface Technology homepage. 2008 SAP AG 22