Click here to load reader

Access SAP NetWeaver Business Rules Management from SAP NetWeaver

  • View
    0

  • Download
    0

Embed Size (px)

Text of Access SAP NetWeaver Business Rules Management from SAP NetWeaver

Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process IntegrationSAP NetWeaver Business Rules Management 7.2
Topic Area:
SOA Middleware
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.
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.
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.
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.
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.
Some components of this product are based on Java™. Any
code change in these components may cause unpredictable
and severe malfunctions and is therefore expressively
prohibited, as is any decompilation of these components.
Any Java™ Source Code delivered with this product is only
to be used by SAP’s Support Services and may not be
modified or altered in any way.
Document History
Typographic Conventions
from the screen. These
include field names, screen
titles, and table titles
their paths, messages,
words or characters that you
enter in the system exactly as
they appear in the
system.
example, F2 or ENTER.
4.2.1 Create a BRM Project ...................................................................................... 3
4.2.2 Import the XSD into the Project ....................................................................... 6
4.2.3 Add the XSD Elements to the BRM Project ..................................................... 8
4.2.4 Create a Ruleset ............................................................................................ 10
4.2.5 Create a Decision Table ................................................................................ 11
4.2.6 Create the Rule .............................................................................................. 18
4.2.7 Create a Web Service from the Rule ............................................................. 20
4.2.8 Build the Project ............................................................................................. 21
4.2.9 Deploy the Project .......................................................................................... 23
4.3 Testing the Rule using WSNavigator ......................................................................... 24
4.3.1 Use SOAMANAGER to Retrieve the WSDL of the Rule ............................... 24
4.3.2 Test the Web Service in WSNavigator .......................................................... 26
4.4 Configure PI to use the Rule from BRM ..................................................................... 27
4.4.1 Configure SOAP Communication Channel .................................................... 27
4.5 Develop Message Mapping in the Enterprise Services Repository ........................... 28
4.5.1 Message Types Used for Mapping ................................................................ 28
4.5.2 Create the User-Function to Call the Rule Web Service ............................... 29
4.5.3 Construct the Message Mapping ................................................................... 31
4.5.4 Test the Message Mapping............................................................................ 31
5. Appendix ............................................................................................................................ 33
5.1 Appendix A: Code example of the user-defined function calling a BRM Ruleset
web service ................................................................................................................. 33
5.2 Appendix B: How to obtain the structure of the XML Message used to call the web
service. ....................................................................................................................... 34
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 1
1. Business Scenario
SAP NetWeaver Business Rules Management (BRM) provides a powerful toolset covering all aspects
of rule handling in business applications. Message processing in SAP NetWeaver Process integration
(PI) can take advantage of those business rules in multiple ways.
2. Background Information
SAP NetWeaver PI can make use of rules in multiple ways:
Within routings, business rules may provide additional data in Extended Receiver
Determinations and Enhanced Interface Determinations
Within a mapping step, business rules information may enrich the original data providing lookup
and value mapping functionality
Within ccBPM, rules may also be used to enrich process data or to provide decision criteria for
conditions steps
This HowTo-Guide makes use of very simple message mapping scenario to highlight the steps that
are required to take advantage of SAP NetWeaver Business Rules Management in process
integration. The example provided here may also serve as role model for the usage of BRM in PI
routings and PI Integration Processes (ccBPM processes).
3. Prerequisites
This HowTo-Guide describes a scenario that has been implemented using a PI system version 7.1
EhP1 and a BRM system version 7.2.
Knowledge Required
Familiar with Business Rule Management System
Basic knowledge in PI 7.1
Familiar with Message Mapping in PI
Software Required
SAP NetWeaver Developer Studio 7.20, includes the Rules Composer perspective
SAP CE 7.20, and with it configured in the SAP NetWeaver Developer Studio
SAP PI 7.1 EhP1
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 2
4. Step-by-Step Procedure
In this guide we will create a rule to determine customer discounts based on their customer number
and which region the order came from. Then, we will use this rule in our PI message mapping. The
message mapping can be used to determine the total discounted cost of the order, which can be sent
to a backend system for fulfillment.
The steps of the exercise are as follow: ...
1. Create an XSD which can be used by BRM to create the rules. The XSD is created by
designing a Message Type in PI’s Enterprise Service Repository (ESR).
2. Create a BRM rule using NWDS:
a. Create a BRM project.
b. Import the XSD created from the Message Type.
c. Create a decision table using the elements of the XSD.
d. Create a rule to use the decision table.
3. Create a web service from the rule.
4. Build and deploy the project to a CE 7.2 system.
5. Test the web service.
6. In PI’s Integration Directory, create a SOAP adapter to use the web service.
7. In PI’s ESR, create a Message Mapping and a user-define function to use the web service.
8. Test the Message Mapping.
4.1 Create an XSD in the ESR ...
1. Create a Message Type with the following elements:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 3
2. In the XSD tab of the Message Type, we can copy or export the XSD to a local file.
4.2 Create a BRM Rule in NWDS
Tip
4.2.1 Create a BRM Project ...
1. Create a new project:
March 2010 4
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 5
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 6
4.2.2 Import the XSD into the Project ...
1. Expand “src” in the project and right-click on “wsdl” and select “Import”:
2. Select “XSD” for the import and click “Next”:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 7
3. Click “Next”:
4. Enter the location of the XSD file and click “Finish”:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 8
4.2.3 Add the XSD Elements to the BRM Project ...
1. Add the XSD by double-click on “Project Resources”, select the “Alias” tab and click on “Add”
and select “XSD Element”:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 9
2. Select the imported XSD and click “Finish”:
3. Select the XSD elements which will be used in the development of rule or decision table.
Expand the XSD structure and check the following elements to be used:
OrderDiscount_MT/CustNo
OrderDiscount_MT/Region
Note
Those elements designated as “= {something}”, such as Discount, is used for output. Those without it are used as input.
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 10
4.2.4 Create a Ruleset S...
1. Create a ruleset by right-click on “Rules Modeling” and select “New Ruleset”:
2. Name the ruleset: OrderDiscountRule
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 11
4.2.5 Create a Decision Table
The decision table will help to determine the customer discount. This is a very simple table, consisting
of using customer number and region as input, and providing the discount as the output. Create...
1. Create a new decision table by right-click on “Decision Table” and select “New Decision
Table…”:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 12
3. Select CustNo and Region as the conditions of the table. These are the inputs.
4. The following will result. Click “Next” to continue:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 13
5. Select the Action, which is “Discount”, for the decision table. This is the output.
6. The following screens will result:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 14
7. Enter value for the 1 st customer by right-click on “Default Value” of the first column, CustNo, and
select “Add Condition Values…”:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 15
9. Enter values for Region of the 1 st customer by repeating the above process in the 2
nd column:
10. Enter 3 values for Region: Americas, EMEA and APJ
11. The following table content should result:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 16
12. Create the rest of the customer values by right-click on the 1 st customer and select “Add
Condition Values…”:
13. Add CustNo values for the rest of the customers:
Tip
The reason we go through this process of creating the 1 st customer first, then creating
the remaining customers is that the template of the 1 st customer will be use for all the
other customers, e.g. all the regions names will all be included.
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 17
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 18
2. Name the new rule: OrderDiscountRule
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 19
3. In the Rule development screen, click “+” under the “If” condition. Replace the left-hand side
with “Boolean.TRUE” by clicking on “Operation.isSuccessful” and selecting “Boolean.TRUE”.
Repeat the same for the right-hand side of the Equals.
4. Assign the Decision Table.
Click on the “+” under the “Then” clause, and select the Decision Table “OrderDiscountTable”:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 20
4.2.7 Create a Web Service from the Rule ...
1. Create the Web Service:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 21
4.2.8 Build the Project ...
1. Build the project by right-click on the project, select:
Development Component Build
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 22
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 23
1. Deploy the project by right-click on the project, select:
Development Component Deploy…
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 24
4.3.1 Use SOAMANAGER to Retrieve the WSDL of the Rule ...
1. Go to NWA on the CE 7.20 system where the Rule has been deployed.
Select: SOA Management Application and Scenario Communication Single Service
Administration
a. Enter: “*discount*” in the Find field.
b. Click “Go”.
c. Select “OrderDiscountRulePortType”.
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 25
3. The web service can be displayed in the browser using the WSDL URL:
Important
Copy the location URL value in the WSDL to a Notepad. The URL will be used in the SOAP communication channel configuration in PI.
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 26
4.3.2 Test the Web Service in WSNavigator ...
1. Start WSNavigator and enter the WSDL URL obtained from the previous step and click “Next”:
2. Enter CustNo and Region values as test data:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 27
...
Important
This section will require the target URL you saved from Section 4.3.1, step 3
4.4.1 Configure SOAP Communication Channel
In order for Message Mapping to access the web service of the BRM rule, we will need to configure a
SOAP receiver communication channel. In the communication channel configuration, the target URL
location of the web service must be specified. This URL should have already been obtained in
Section 4.3.1, step 3.
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 28
Tip
...
Services Repository
4.5.1 Message Types Used for Mapping
1. To demonstrate the Message Mapping, two Message Types are created, as shown below:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 29
cust_no and region will be used to determine the values for discount and total_cost.
2. Select tab Signature and add a parameter of category Adapter, type SOAP to the list of
Parameters
4.5.2 Create the User-Function to Call the Rule Web Service
The following is user-function create to call the webservice: ...
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 30
1. Input variables:
2. User-function code:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 31
Tip
Appendix B shows how the XML message used for calling the rule web service can be obtained.
4.5.3 Construct the Message Mapping
The message mapping pertaining to the user-function is shown below:
4.5.4 Test the Message Mapping S...
1. Select the SOAP Communication Channel to use for the web service call.
2. Enter the source XML values and execute:
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 32
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 33
function calling a BRM Ruleset web service
public String calculateDiscount(String cust_no, String region, Channel
soapDiscount, Container container) throws StreamTransformationException{
SystemAccessor accessor = null;
accessor = LookupService.getSystemAccessor(soapDiscount);
+ "<ns0:Request-demo.sap.com-orderdiscount-OrderDiscountRule-
+ "<Discount>0</Discount> </ns1:OrderDiscount_MT>"
for (int n; (n = resPayload.getContent().read(b)) != -1;) {
sb.append(new String(b, 0, n));
int j =sb.indexOf("</Discount>");
discount = sb.substring(i, j);
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 34
if (accessor!=null) accessor.close();
5.2 Appendix B: How to obtain the structure of the
XML Message used to call the web service.
One way to obtain a sample XML message used to call the web service in ESR is to import the WSDL
of the web service as an external definition. Then, create a temporary mapping using the external
definition. In the test mode of the mapping, we can display the XML source, which can be used in the
user-defined function.
Obtaining the WSDL
A WSDL may import other WSDLs. When this is the case, we want to get the WSDL which defines
the structure of the message. This may require us to traverse multiple imports of the WSDL, as in this
case, to obtain the WSDL to use for external definition.
Copy the source of the WSDL to a local file.
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 35
Access SAP NetWeaver Business Rules Management from SAP NetWeaver Process Integration
March 2010 36
Create a temporary Message Mapping using the External Definition: Drag the External Definition to the source of the Message Mapping tool and select the request message.
Go to the test tab to obtain the source XML:
This is the XML message to be used with the web service.
www.sdn.sap.com/irj/sdn/howtoguides

Search related