This blog aims to show how you can incorporate Java Web Start functionality with SAP NetWeaver BPM and provide offline order capabilities for your sales force. In the interest of time we will not get into all the specifics of creating a Java Swing application however we will cover the basic integration points with a business process. The complete example and scenario shown in this blog were created using functionality provided with the SAP NetWeaver Composition Environment EhP1.
The problem that we will be addressing is one where we need to provide offline ordering capabilities for the sales force so that orders can be prepared offline specifically while traveling. Once the sales person is online the orders can then be submitted for further processing. Due to the large order size considerable time is spent entering order information; therefore valuable time could be saved by allowing for offline order preparation. Two separate approvers will be responsible to review the orders and it is crucial that orders are created only once both parties have approved them.
Graphical representation of the SAP NetWeaver Business Process
The scenario represents a classical request and approval process. The outer area of a SAP NetWeaver BPM process is referred to as a pool; and a pool is divided into lanes that represent role information. There are individual lanes for the credit representative, account representative and one lane reserved for the backend system. Further there are 2 human activities shown by the little person icon and one automated activity shown by the 2 gears. Human activities represent user interface steps and automated activities represent web service calls.
The process starts off in the top left corner when an order is submitted by the sales person. A BPMN (Business Process Modeling Notation) parallel split directs the order request simultaneously to both the credit representative and the account representative for approval. Please note that when using a parallel split the process will only continue once both participants have completed their individual tasks. At that point the process is converged using a parallel join and the process continues and reaches a decision point. The gateway will interrogate each respondent’s decision and the order will only be created when both parties have approved the order.
The next bit of information that is worth mentioning is the existence of the “Context” artifact that represents the data type(s) used to store the process context throughout the lifecycles of the process. This information will be available while the process is executing and can be re-used between steps. Think of the process context as a memory area to store data while the process is executing. In our process we need information about the user that submitted the order, and then we need information about the two approvers and then finally order related information. Since the process context is really a XSD structure the context can simply be created within the ESR (Enterprise Services Repository) and then exported into your BPM process.
The different pieces to the puzzle
Now that we went through an overview of the process lets take a look at all the individual pieces of this scenario.
1: Product search web service
There needs to be a web service that will retrieve the price list and then make this list available from within the Java Web Start application. Once the products are downloaded the sales person can enter the order information offline.
2: Java Web Start Application
Here we have an example of a Web Start application calling a web service to retrieve the customers price list, the sales person can then enter quantities for each line item that they want to order. You need to ensure that the users work is serialized when they click “Save” so that it’s available offline. This specific functionality is of course not possible using standard browser technologies.
Once the sales person is back online and the order is complete then the order can be submitted for processing. This will in turn call the SAP NetWeaver BPM start event web service, and pass the order information into the process. It is at this point that the SAP NetWeaver BPM business process will be instantiated. Please understand that the Java Web Start application is not part of the business process, the order information from the Web Start application will be used as input data to start the SAP NetWeaver Business Process. Once the process is started the Java Web Start application is no longer used.
3: SAP NetWeaver BPM Process (Start Event)
The interesting thing is that you can use any user interface technology to start a SAP NetWeaver BPM process. By nature a SAP NetWeaver BPM process is started when the process start event is fired; behind the scenes this start event represents an actual web service. Therefore we will ensure that the process start web service operation will be able to accept in order information from the Java Web Start application. Also please be aware that you are not restricted to user interfaces alone to start a SAP NetWeaver BPM process; you can use any technology as long as it is capable of making web service calls.
Since the start event represents a web service you may want to use the ESR (Enterprise Services Repository) to create the web service including the input data types. Note that the process start web service operation has to be asynchronous so therefore you do not have to supply a response. Once you are finished you can import the start web service into your business process using the WSDL (Web Service Definition Language) file. Please note below that the input parameters of the start event are actually displayed as “Outputs” within a mapping activity. As the order information is received by the start web service the order information is then mapped or moved (left to the right) out of the start event and into the process context for re-use later during the approval steps. Also note the product node is a collection and is represented with the (“n:n”) symbol when mapped.
Eventually when you deploy the SAP NetWeaver BPM process the start event will be available as a web service within the Web Services Navigator and can then be called by the Java Web Start Application to submit orders against.
4: Approval User Interface
Even though the process consistsof two approval user interface steps spanned by a parallel split we can simply create one user interface and re-use that in both steps. The user interface technology that we will be using in the approval steps is Java Web Dynpro. Even though you can use any user interface technology to start a BPM process, once the process has started the human interaction technology that is supported with SAP NetWeaver BPM EhP1 is Java Web Dynpro.
It is worth mentioning while working on any offline ordering application you could potentially run into a situation where products are sold out. For this reason you might want to add some type of synchronization functionality within the approval step to make sure the products are still available and inform the approver of any discrepancies.
Then finally due to the nature of the parallel split the process will only continue when both users have completed their individual steps.
5: Order Web Service
Automated activities represent Web Service, so therefore the “Order” activity or web service will be responsible to create the order in the backend ERP system. Web services are imported using WSDL from a variety of sources, once imported it can be mapped to an automated activity. Interestingly you will see that the endpoint is not stored within the SAP NetWeaver BPM process but rather mapped to a Service Group. After deploying your BPM project the Service Group used will be available within the SAP NetWeaver Administrator for final configuration. A Service Group is part of Mass Configuration and represents a group of web services that can be mapped to a specific backend system; this allows for much faster and more manageable administration of endpoints.
6: Java Web Start
Java Web Start allows users to download and run Java applications from the web. It provides an easy activation of applications and guarantees that you are always running the latest version of the application and eliminates installation steps. Most importantly Java Web Start can be configured to allow the user to work offline; and in our example allow the sales person to prepare the order when internet connectivity is restricted.
Since Java Web Start applications are written in Java Swing they do require a specific set of programming skills different than standard web application development. As a background Java Swing is the successor over the legacy Java Applet AWT (Abstract Windows Toolkit) technology used to render older Java Applets. Since then AWT has completely been re-vamped into Java Swing and now supports a plethora or rich user interface controls. Java Applets can only run inside of a browser where as Java Web Start applications can be downloaded using a browser but then can run outside of a browser and still rely on the automatic updates.
A word of caution
If you do plan to use Java Web Start I would urge you to do proper research so that you understand the pros and cons of using this technology. There are many situations where Java Web Start applications are not the best choice and you should rather focus on standard Web technologies. If you have a limited and contained set of users that do have enough bandwidth (initial download of the application) and need offline capabilities then Java Web Start is a good fit. However, be aware that Java Web Start applications do require extra support at least initially to get users setup. Due to increasing complexities of automatic windows updates, unreliable connections, proxy servers, and virus software it all can lead to issues when running a Java Web Start application on the user’s desktop. Please be aware that Java Web Start requires a JRE (Java Runtime Engine) which must be installed on every users system before the user can start working. Depending on the size of the Java Web Start application the initial download of the application can take quite some time. Unlike standard web technologies that only render HTML of the current web page Java Web Start applications downloads the entire binary code of the application including any specific libraries. However, once downloaded Java Web Start applications can be run locally and will ensure that the user always have the latest version of the application.
Java Web Start assembly and deployment tips.jar .</p><p>keytool -genkey -keystore <your key name> -alias <your alias name></p><p>jarsigner -keystore <your key name> <your application>.jar <your alias name></p><p>To enable a Swing application to be downloadable using Java Web Start you must create a JNLP (Java Networking Language Protocol) file for the application. Note the settings within the information area that are required for offline processing.</p><p>!https://weblogs.sdn.sap.com/weblogs/images/251848367/jnlp.png|height=156|alt=image|width=385|src=https://weblogs.sdn.sap.com/weblogs/images/251848367/jnlp.png|border=0! </p><p>Add your signed Swing application jar file to a J2EE Web Module Project including any other vendor jar files. Last but not least add the JNLP file(s) to the Web Module Project as well. </p><p>!https://weblogs.sdn.sap.com/weblogs/images/251848367/webapp.png|height=137|alt=image|width=238|src=https://weblogs.sdn.sap.com/weblogs/images/251848367/webapp.png|border=0! </p><p> </p><p>Create a J2EE Enterprise Application Project and reference the previously created Web Module Project and deploy the Enterprise Application Project to the SAP NetWeaver Composition Environment</p><p>Then you can simply test your Java Web Start application as follows</p><p>[http://yourservername:port/yourapplication.jnlp | http://yourservername:port/yourapplication.jnlp]</p><p>When you have downloaded the application once you do not need to go back to the URL when you want to run the application again (and of course the URL will not be available offline). Instead create a short cut on your desktop by opening up the Java Cache viewer.</p><p>To do this type “javaws -viewer” in Start > Run</p><p>Then select the Java Web Start application > Right Click > Install Shortcut</p><p>!https://weblogs.sdn.sap.com/weblogs/images/251848367/javacache.png|height=194|alt=image|width=500|src=https://weblogs.sdn.sap.com/weblogs/images/251848367/javacache.png|border=0!</body>