module 2: create a decision table using rules … soa...soa experience workshop module 2: create a...

22
SOA EXPERIENCE WORKSHOP MODULE 2: CREATE A DECISION TABLE USING RULES COMPOSER (BRM) Exercises / Solutions SAP NETWEAVER PRODUCT MANAGEMENT SOA

Upload: others

Post on 11-Mar-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

MODULE 2: CREATE A DECISION TABLE

USING RULES COMPOSER (BRM)

Exercises / Solutions

SAP NETWEAVER PRODUCT MANAGEMENT SOA

Page 2: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

1

Creating a decision table using the Rules Composer

In this guide you will learn how to create a decision table with the Rules Composer.

1. Launch the SAP NetWeaver

Developer Studio. Choose the

workspace assigned to you

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.

Page 3: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

2

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. Choose the

ZNWSOAWKS development

component. Click „Next‟

Page 4: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

3

5. Name the project

studentx_mod4_ex3.

Substitute „x‟ with your

student number. (This project

is used behind the scenes later

on by the approval process.)

Click „Finish‟.

6. Expand the Rules project and

choose import from the

context menu of the „wsdl‟

folder you‟ll find underneath

the „src‟ folder. In this step we

will import the XSD to be

used by the decision table.

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.

Page 5: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

4

7. 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.

Page 6: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

5

8. Choose the „File System‟

option and click „Next‟

9. Click on „Browse‟ and choose

the rulesdata.xsd file that

was provided to you (you can

find it in your download

folder for the SOA Experience

Workshop files, typically

D:\SOA_Experience_Works

hopFiles_needed). Click on

„Open‟.

10. Click „Finish‟.

Page 7: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

6

11. In order to make the data

types available to the Rules

Composer, you have to build

the project first. Simply right-

click on the project‟s name

and select „Development

Component Build…‟ from

the context menu.

12. Confirm the dialog that pops

up by clicking on „OK‟.

Page 8: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

7

13. From the Project Explorer

expand the „Rules Modeling‟

node and double click on

„Aliases‟.

In the majority of cases the

XSD could have complex

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.

14. On the right pane choose

„XSD Aliases‟

15. Click on „Add XSD Elements‟

Page 9: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

8

16. From the resulting pop up

choose Approval Request and

click Finish

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 don‟t need

that for our exercise.

17. Create a new ruleset by

choosing „New Ruleset‟ from

the context menu of the

„Rules Modeling‟ node (as is

shown in the screenshot)

18. 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.

Page 10: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

9

19. 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.

Page 11: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

10

20. Provide the decision table the

name

„ApprovalNeededDecisionTab

le‟ and click „Next‟.

Page 12: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

11

21. Here we define the input

condition. Choose

„ApprovalRequest/requestorC

ountry‟ from the top panel and

click on the arrow down

button as is shown in the

figure.

Page 13: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

12

22. Repeat the previous step to

include

„ApprovalRequest/orderTotal

Amount‟ 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.

Page 14: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

13

23. Next we select the

action/ouput. Choose the

attribute

„ApprovalRequest/approvalNe

cessary‟ and click on the

arrow down button.

Page 15: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

14

24. Then click Finish.

25. The first condition we want to

create should express, that an

approval is not necessary for

the EMEA region if the total

amount is less than 100000.

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 EMEA.

26. Next move to the

„orderTotalAmount‟ column

and double click on the field

containing „0‟. Enter

„<100000‟.

Page 16: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

15

27. Finally double click on the

first entry of the

„approvalNecessary‟ column

and select „false‟ from the

drop-down list. With that

you‟ve finished you first entry

in the decision table,

expressing that for the EMEA

region an approval is not

necessary, if the total amount

is below 100000.

28. Next we want to define what

should happen in case the

total amount exceeds 100000.

For this we have to define

another condition. Right-click

in the orderTotalAmount

column on the „<100000‟ field

and select „Add Condition

Values‟ from the context

menu.

29. In the dialog that pops up

enter the new condition

“>=100000”. Click on OK.

This dialog allows you to add

even more conditions if

needed.

30. What‟s left is to set the

appropriate

“approvalNecessary” field to

true (double-click the second

field in the

Page 17: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

16

„approvalNecessary‟ column

and select „true‟). This

indicates that an approval is

necessary in case the request

origins in the EMEA region

and exceeds 100000.

31. We can add more regions by

right-clicking in the EMEA

field and choosing „Add

Condition Values‟ from the

context menu.

32. In the dialog that pops up, add

as many regions as you need.

In our example we add „APJ‟

and „AMER‟ as additional

regions. Close the dialog by

clicking on OK.

33. As result you get a complete

decision table. You can adapt

values as you like by double-

clicking the appropriate field

in the table and adjusting its

contents to your needs.

Page 18: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

17

34. A final table might look

similar to the one depicted in

the figure to the right.

35. 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.

Alternately, click on the

„Overview‟ tab of the ruleset

and click on the „New…‟

button in the „Rules‟ section.

36. Give the rule a name (e.g.

ApprovalNeededRule) and

click on OK.

Page 19: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

18

37. The rules editor opens. Here

you can define if-then-else

cascades. Click on the „+‟-

sign after the „if‟-statement

38. Click once on the text

„Operation.isSuccessful()‟ and

select the Boolean value

„Boolean:TRUE‟ from the

context dialog.

39. 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.

Page 20: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

19

40. Now click on the „+‟-sign

after the „then‟-statement.

41. Expand the node „Evaluate-

DecisionTable‟ and choose

„ApprovalNeededDecisionTab

le‟. With that you define what

should happen in case the „if‟-

clause is true (which is always

the case in our example).

Page 21: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

20

42. The final rule should look as

shown.

Now you can save, build, and

deploy your rule.

Page 22: MODULE 2: CREATE A DECISION TABLE USING RULES … SOA...soa experience workshop module 2: create a decision table using rules composer (brm) exercises / solutions sap netweaver product

SOA EXPERIENCE WORKSHOP

21

Copyright 2007 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, Excel, 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.

The information in this document is proprietary to SAP. No part of this document may be reproduced, copied, or

transmitted in any form or for any purpose without the express prior written permission of SAP AG.

This document is a preliminary version and not subject to your license agreement or any other agreement with SAP.

This document contains only intended strategies, developments, and functionalities of the SAP® product and is not

intended to be binding upon SAP to any particular course of business, product strategy, and/or development. Please note

that this document is subject to change and may be changed by SAP at any time without notice.

SAP assumes no responsibility for errors or omissions in this document. SAP does not warrant the accuracy or

scompleteness of the information, text, graphics, links, or other items contained within this material. This document is

provided 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 have no liability for damages of any kind including without limitation direct, special, indirect, or

consequential damages that may result from the use of these materials. This limitation shall not apply in cases of intent

or gross negligence.

The statutory liability for personal injury and defective products is not affected. 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 assumes no responsibility for errors or omissions in these materials