Sie sind auf Seite 1von 28

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

Designing and Integrating a Business Rule as Web Service into Process Applies to:
SAP enhancement package 1 for SAP NetWeaver Composition Environment 7.1

Summary
This guide explains how to create a decision table within the rules composer and expose this business rule as web service and integrate it into business process. During the run time you are able to see how the business rule can control the process flow. Download the Source Files here

Author:

Jie Deng

Company: SAP AG Created on: 28 November 2008

Author Bio
Jie Deng is a Product Manager in SAP AG Germany. In this role, Jie focuses on the area of Business Process Management, Business Activity Monitoring as well as process monitoring and reporting. She is responsible for the rollout to customers as well as roll-out within the organizations. Jie has been working for the SAP organization for eight years and has been part of the Product Management Group in the SAP NetWeaver BI area for six years. In 2006, Jie joined the Product Management Group in the BPM area.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 1

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

Table of Contents
Step 1 Create a Decision Table within Rules Composer...............................................................................3 Step 2 Expose the Rule Project as a Web Service......................................................................................21 Step 3 Define Logical Destination for the Generated Web Service in NetWeaver Administrator................21 Step 4 Integrate this Web Service via Automated Activity into Process......................................................22 Related Content................................................................................................................................................27 Copyright...........................................................................................................................................................28

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

Step 1 Create a Decision Table within Rules Composer


1. Launch the SAP NetWeaver Developer Studio and open the Rules Composer Perspective (Window Open Perspective Other; next select Rules Composer and click OK).

2. Create a new Development Component Project of type Rules Composer. For this select File New Project from the menu. Next choose Development Component underneath the Development Infrastructure node. Press Next.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 3

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

3. Here we define the type of the Development Component. Choose Rules Composer and click on Next.

4. Next we specify the location of the DC. For the purpose of this example we will make it a local development component. Choose that option and click Next

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 4

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

5. Name the project module_4_exercise_3 and click Finish.

6. Expand the Rules project and choose import from the context menu of the wsdl folder youll find underneath the src folder. In this step we will import the XSD to be used by the decision table. 7. For our example we need some data types on which the decision table is relying. We have defined these data types in XML format in an external XSD (XML Schema Definition) file. In this step we will import this XSD file into our project.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 5

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

8. Choose Web services XSD as the import file type and click Next. Note: Another option for you to define the data types is to import Java types. You could also use a combination of XSD files and Java types.

9. Choose the File System option and click Next

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 6

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

10. Click on Browse and choose the approval.xsd file that was provided to you.

11. Click Finish.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 7

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

12. In order to make the data types available to the Rules Composer, you have to build the project first. Simply rightclick on the projects name and select Development Component Build from the context menu.

13. From the Project Explorer expand the Rules Modeling node and double click on Aliases. 14. In the majority of cases the XSD could be very complex with ugly field names and highly nested structures. To have a friendly and human readable format we define aliases. In the next few steps we will define the aliases for the XSD we imported.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 8

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

15. On the right pane choose XSD Aliases

16. Click on Add XSD Elements

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 9

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

17. From the resulting pop up choose Approval Request and click Finish

18. You can expand and inspect the XSD that we imported in step 10. By selecting one line and pressing the F2 button, you would be able to rename the fields as needed. We dont need that for our exercise.

20. Create a new ruleset by choosing New Ruleset from the context menu of the Rules Modeling node (as is shown in the screenshot)

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 10

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

21. Give it a speaking name for example ApprovalNeededRuleset and click OK. To the right of the Project Explorer an appropriate tab for managing your ruleset will be opened. Within a ruleset you can define rules and decision tables.

22. At the bottom of the Overview tab you can identify the Decision Tables section of your ruleset. Click on New to create a new decision table. An alternative would be to create a new decision table by choosing the corresponding menu item from the context menu of your newly created ruleset in the Project Explorer.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 11

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

23. Provide the decision table the name ApprovalNeededDecisionTable and click Next.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 12

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

24. Here we define the input condition. Choose ApprovalRequest/requestorCo untry from the top panel and click on the arrow down button as is shown in the figure.

25. Repeat the previous step to include ApprovalRequest/orderTotalA mount as well. The resulting condition is shown in the figure. Click Next. We express by this step that the decision table is relying on two fields: the country of the requester and the total amount of his purchase request.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 13

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

26. Next we select the action/ouput. Choose the attribute ApprovalRequest/approvalNec essary and click on the arrow down button.

27. Then click Finish.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 14

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

28. The first condition we want to create should express, that an approval is not necessary for the country United States if the total amount is less than 150000. To edit the condition, navigate to the Decision Tables tab, double click on the Default Value entry in the requestorCountry column, and change it to read United States. 29. Next move to the orderTotalAmount column and double click on the field containing 0. Enter <150000. 30. Finally double click on the first entry of the approvalNecessary column and select false from the dropdown list. With that youve finished you first entry in the decision table, expressing that for United States an approval is not necessary, if the total amount is below 150000. 31. Next we want to define what should happen in case the total amount exceeds 150000. For this we have to define another condition. Right-click in the orderTotalAmount column on the <150000 field and select Add Condition Values from the context menu.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 15

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

32. In the dialog that pops up enter the new condition >=150000. Click on OK. This dialog allows you to add even more conditions if needed.

33. Whats left is to set the appropriate approvalNecessary field to true (double-click the second field in the approvalNecessary column and select true). This indicates that an approval is necessary in case the request origins in United States and exceeds 150000. 34. We can add more regions by right-clicking in the United States field and choosing Add Condition Values from the context menu.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 16

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

35. In the dialog that pops up, add as many countries as you need. In our example we add Germany and china as additional countries. Close the dialog by clicking on OK.

36. As result you get a complete decision table. You can adapt values as you like by doubleclicking the appropriate field in the table and adjusting its contents to your needs. 37. The last step is to create a rule that wraps the decision table (that is: the rule calls the decision table for evaluation). Rules are the starting point for a rules engine and therefore we have to add at least one rule that can be executed by the rules engine. To do this click on New Rule from the context menu of the ruleset. Another option would be to click on the Overview tab of the ruleset and click on the New button in the Rules section.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 17

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

38. Give the rule a name (e.g. ApprovalNeededRule) and click on OK.

39. The rules editor opens. Here you can define if-then-else cascades. Click on the +-sign after the if-statement

40. Click once on Operation.isSuccessful() and select the Boolean value TRUE from the context dialog.

41. Next click on the Boolean value false after the Equals keyword. Another context dialog opens. Once again select the Boolean value TRUE. With that you have defined the condition under which the rule will be fired. As this equation is always true we made sure that the decision table will always be executed.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 18

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

42. Now click on the +-sign after the then-statement.

43. Expand the node EvaluateDecisionTable and choose ApprovalNeededDecisionTable . With that you define what should happen in case the ifclause is true (which is always the case in our example).

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 19

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

44. The final rule should look as shown. Now you can save, build, and deploy your rule.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 20

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

Step 2 Expose the Rule Project as a Web Service


Please refer to following resource to download the Web Service Generation tool and follow the description to generate the rules project to web service: https://www.sdn.sap.com/irj/sdn/nw-rules-management?rid=/webcontent/uuid/f066ec08-474b-2b104a97-b66d605de037 Web Service Generation Tool for Invoking Rules https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/11081 --> Example for how to generate web service

If you test the generated web service in web service navigator, you should get the result as the following screenshot.

Step 3 Define Logical Destination for the Generated Web Service in NetWeaver Administrator
Please refer to Guide1 Step 1 Configuration E. Define Logical Destination

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 21

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

Step 4 Integrate this Web Service via Automated Activity into Process
1. Open process composer and add automated activity Check Amount as the process step between Enter Purchase Request and Approve Purchase Request. Connect the Gateway as shown in the screenshot on the right side.

2. Navigate to Project Explorer and expand node process modeling service interfaces WSDL Files and right mouse click to select the context menu Import WSDL.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 22

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

3. Now please select option Remote Location / File System. (you can also select the option Service Registry, therefore you need first to publish this web service into Service Registry).

4. Enter the following URL into the required field: http://localhost:50000/approvalr uleset/approvalrulesetservice?w sdl

5. Leave the setting as it is and click on finish to import the WSDL into SAP NetWeaver Developer Studio.

6. Once the WSDL is imported, you are able to assign this Service to the automated activity. Please Open the properties window of Check Amount and assign the imported WSDL to this activity.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 23

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

7. Assign the logical destination which you have created in Step3 to this automated activity.

8. Now we need to enhance the field ApprovalNecessary into the XSD file which we already imported before. Approval Necessary is the outcome of the business rule which we defined, and we need this field for mapping purpose. To do so, please go to Project Explorer and open the already imported XSD file approvalprocess. 9. On the right side you will see the definition of this XSD file. Now please double click on the Type PurchaseOrder to open this complex Data Type.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 24

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

10. Right mouse click on the complex data type PurchaseOrder and select Add Element from the context menu.

11. Add the name approvalNecessary and set the type to boolean. Then dont forget to click on save button to save all these changes.

12. Open the property window of automated activity Check Amount again and navigate to the tab Input mapping. Please do the mapping as the screenshot shown on the right side.

13. Navigate to the tab Output Mapping and do the mapping as the screenshot shown on the right side.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 25

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

14. Now we need to define the condition line for the Gateway as the last step. Please navigate to the property window of condition Above Limit and set this Gateway as the default gateway. 15. Navigate to the property window of condition Under Limit and enter the condition as shown in the screenshot. Please save all changes which you made. For Details about how to edit the condition line, please refer to Exercise B Step 8. 16. Now you can build and Details Please refer to Guide 1 Step 9: Build and Deploy deploy this process again (details please refer to Exercise B) 17. Now you can start and run Details for start and run the process please refer to Guide 1 the process to see how the Step 10 and 11. business rule can control the process flow. Case 1: please enter the product quantity e.g. 1 within the task UI of human activity Enter Purchase Request. Youll see that the purchase order is created automatically without the manual approval. Case 2: please enter the product quantity e.g. 200. You will see that order total amount is above the limit based on the business rule, and purchase manager needs to approve this request manually.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 26

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

Related Content
Building a Composite Business Process from Scratch with SAP NetWeaver BPM - Guide 1 Building a Composite Business Process from Scratch with SAP NetWeaver BPM - Guide 2 Building a Composite Business Process from Scratch with SAP NetWeaver BPM Source files

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 27

Building a Composite Business Process from Scratch with SAP NetWeaver BPM Guide 3

Copyright
2008 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the 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, System i, System i5, System p, System p5, System x, System z, System z9, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli, Informix, i5/OS, POWER, POWER5, 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. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, 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. 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.

SAP COMMUNITY NETWORK 2008 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 28

Das könnte Ihnen auch gefallen