33
8/11/2019 CD160_exercise.pdf http://slidepdf.com/reader/full/cd160exercisepdf 1/33  SAP NETWEAVER DECISION SERVICE MANAGEMENT  –  A PARADIGM SHIFT CD160 Exercises / Solutions  Alexander Held, SAP Deutschland AG & Co. KG Carsten Ziegler, SAP AG

CD160_exercise.pdf

Embed Size (px)

Citation preview

Page 1: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 1/33

 

SAP NETWEAVER DECISION SERVICE

MANAGEMENT  –  A PARADIGM SHIFT

CD160

Exercises / Solutions Alexander Held, SAP Deutschland AG & Co. KGCarsten Ziegler, SAP AG

Page 2: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 2/33

2

In these exercises, we want to set up a managed system and assign a sample application to it (Exercise 1).

This application derives the price of a product (Exercises 2 and 3), adds shipping costs of 5% but at least $2

if the price is under $100 (Exercise 4) and sends a notification mail if a product is not found in the price list

(Exercise 4). Then we want to simulate the application on the managed system (Exercise 5) before we

deploy it and call it from the managed system (Exercise 6). Finally, we will make a delta deployment with an

activation timestamp in the future (Exercise 7).

OGIN INFORMATION

Please log on to system TDI, client 001 Your user is CD160_US (TechEd LV) or CD160 (TechEd Amsterdam, Bangalore) The password is welcome

The system is an SAP NetWeaver 7.40 system with support package level 03

If the system TDI is not yet available in the SAP Logon, you need to create a connection

  To do so, choose the New icon    Connection

  Select User Specified System

  Choose Next 

  Enter the following valueso Description: TDI o Message Server: localhost 

o Instance Number: 00 o System ID: TDI 

  Choose Finish

Page 3: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 3/33

  3

EXERCISE 1

Create a Managed System and a BRFplus Application for your Business Rules

  Call SAP NetWeaver Decision Service Management  Create a managed system  Check further properties of the managed system  Create a new BRFplus application

Walkthrough

  Call SAP NetWeaver DecisionService Management

  Call the transaction DSM  inthe SAP backend systemor enter the link shownabove

   A browser window willappear and DecisionService Manager startsautomatically

Page 4: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 4/33

  4

  Create a managed system- Choose the New icon- A dialog box in which

you can specify theSystem Name (forexample CD160_MS),

Description (forexample <YourName>appears: HandsOnlecture CD160 DSM),the RFC-Connection tothe Managed System(select theRFC_Destination TDIusing the F4 Help )and the Documentation 

- The System Type fieldcan automatically bereceived from the

Managed System. Alternatively, you canalso enter the systemtype yourself (forexample DevelopmentSystem)

- Choose Add to createthe Managed System.Now a managedsystem has been

added to DecisionService Manager

  Choose the Save button. Asuccess message appears.

  Check further properties of theManaged System

  Select the ManagedSystem you created beforefrom the list shown in thetable Managed Systems

  Check the properties in thetabs Deployment, Applications and TechnicalInformation. On thedifferent tabs, you canaccess the informationrelevant to your managedsystem. On the

Deployment tab, you can

Page 5: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 5/33

  5

see all of the decisionservices that have beendeployed to the managedsystem. On the Applications tab, allBRFplus applications

assigned to this managedsystem are displayed.Currently the tab is emptybecause we haven'tcreated a BRFplusapplication yet. TheTechnical Information tabwill give you an overview ofsome technical figures ofthe managed system.

  Create a new BRFplus

application assigned to themanaged system

  Navigate to the Applications tab

  Choose New  

  In the Create Application dialog box, enter Name,Short Text, and Text , forexample TechEd_<yourname> (you can use thesame text string for allthree fields, if the text is

short enough (20characters). The Name field only allows ASCIIcharacters, numbers, andunderscores.

  Select the Create Local Application checkbox

  Choose Create. TheBRFplus application willautomatically be assignedto the managed system

  Choose Save 

  Change to Display  mode

Page 6: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 6/33

  6

EXERCISE 2

Create a Function and a Ruleset  Navigate from Decision Server Manager to the BRFplus Workbench

  Create a decision Service (BRFplus Function) assigned to the application created in exercise 1  Define the signature of the function

Input parameter is the product name

Output parameter is the price  Create a ruleset assigned to the function

Walkthrough  Navigate to the BRFplus

Workbench

  Choose the Open BRFplusWorkbench button to startthe BRFplus Workbench.You can also use thetransaction BRFplus (SAPGUI Transaction). A newbrowser window will openand the BRFplusWorkbench is displayed.

  Close the DSM browserwindow

Page 7: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 7/33

  7

  Choose the Personalize icon at the upper right ofthe screen and selectShow in Change Mode asViewing Mode

  Select the Show Technical Aspects checkbox

  Then choose Save. Bydoing so, you do not needto change to edit mode inevery single screen

  Create a BRFplus functionassigned to the Applicationcreated in Exercise 1

  Choose Search on theRepository  tab

  Enter the name of theapplication created inExercise 1 and choose theSearch button

  The application you’vecreated will be displayedon the Repository  Tab

  Click on the applicationand select ContainedObjects tab and choose

Create Object (make surefunction is selected)

Page 8: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 8/33

  8

  Enter Name (max. 30characters), Short Text  (max. 20 characters), andText  (max. 80 characters),such as Product Price.Choose Create And

Navigate To Object  

  Define the signature of thefunction

  Select the Signature tab

  Choose Add New DataObject    Add New DataObject  

  Select Element  Type

  Enter Name, Short Text,Text , such as Product  

  For Length, select areasonable text length forproduct names, such as 40

  Choose Create AndNavigate To Object  andchoose Yes to save yourentries

Page 9: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 9/33

  9

  Select the Domain Valuestab

  Choose Create Value 

Hint: In the Domain Value section we can definedomain values/constantsthat can later be used in avalue help when definingthe rules. When you bindyour input values to aDDIC attribute, the domainvalues will automatically bederived from the DDIC.DDIC values will beretrieved from themanaged system

automatically

Enter Name, Short Text, Text,and Value, such as TennisRacket  and choose Create 

  Repeat that previous stepfor additional products, forexample Baseball bar,Football, Golf club, Paddle,Paint Ball Gun.... Whenyou are done, you willhave a value list of

products that can be usedin your decision service

  Choose Back  and confirmby choosing Yes to returnto the function

Page 10: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 10/33

  10

  Make sure you are in thefunction editor

   At the Result Data Object  

choose the icon to the rightof the word Actions andselect Create...

  Select Element  Type

  Enter  Name, Short Textand Text, for example,Price 

  Select element type  Amount  

  Select Positive Values (price determination shouldalways return a positive

amount that has to be paidby the customer)

  Choose Create 

Page 11: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 11/33

  11

  You have now defined thedecision service ProductPrice. This service needs a

Product and based on thatthe Price (includingshipping costs) will bereturned. Now you need todefine the rules forcalculating the productprice. To do so, we firsthave to create a Ruleset(encapsulates the rules).

  Create a Ruleset assigned tothe function

  Select the AssignedRuleset tab

  Choose Create Ruleset  

  Enter Name, Short Textand Text , for example,Product Price 

  Choose Create AndNavigate To Object  andthen choose Yes toconfirm

Page 12: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 12/33

  12

  Choose Save 

You have now created the framework for your decision service. What is left is to create the rules themselves and to testthem and deploy them into the managed system. This will be part of the following exercises.

Page 13: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 13/33

  13

EXERCISE 3

Define a simple Rule  In the ruleset defined in Exercise 2, create a rule using a decision table  The decision table will return the price for a specific product

  If there are several entries for the same product, the first one is taken into consideration  If no matching entry is available, an initial value is returned

Walkthrough  In the ruleset defined in

Exercise 2, create a rule usinga decision table

  Ensure you are in theruleset editor for theruleset you created in thelast exercise

  Select Insert Rule  Create... 

Page 14: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 14/33

  14

  Enter a Description, forexample, Look up product price 

   At the Then branch,choose Add  Process

Expression  Create... 

  Select the Decision Tabletype 

  Enter Name, Short Text,and Text , for exampleProduct Prices 

  Select the Data ObjectPrice as Result DataObject (you created it inExercise 2 as the resultdata object of the decision

service)  Click Create And Navigate

To the Object  and confirmthe popup window withYes 

  Choose the Table Settings 

button to define thecondition columns for thedecision table

Page 15: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 15/33

  15

  Choose Insert Columnunder  Condition Columns From Context DataObjects ...

  Select Product  (the nameof the data element thatyou created above inExercise 2) and chooseOK  

  Choose OK  

  Choose Insert New Row

  Choose ... in the firstcolumn of the new row

  Enter a product name inthe empty field. You nowhave two options. Eitheryou can write the valuesdirectly into the empty fieldor you can use the valuehelp. In the value help, youwill see the domain valuesyou created earlier inExercise 2.

   After entering a value,choose OK  

Page 16: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 16/33

  16

  Choose ... in the secondcolumn of the same newrow

  Enter a price and acurrency, for example,USD for US Dollars (you

can select a valid currencyby clicking on the icon tothe right of the currencyfield) and choose OK. Weare using US Dollars in thisexample. If you are goingfor another currency, youneed to replace US Dollarswith that currency in alllater occurrences

  Repeat the last six steps(from “Choose Insert NewRow ”) for several products.

 Also include at least oneproduct more than oncewith different prices

  Choose Back  and confirmby choosing Yes (nowselect the ruleset youcreated earlier)

  Choose OK to close therule Look up product prices 

  Choose Save 

You have now created a complete BRFplus application. In the next exercise you will extend that application by adding

the shipping costs to a product that costs less than $100.

Page 17: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 17/33

  17

EXERCISE 4

Define more complex Rules  Add other rules to the existing ruleset using formulas and actions (such as sending an email)

  If the product was not found in the price list (price is set to initial value), trigger a notification email to a fixed

email address  If the product was found in the decision table, derive the shipping costs (5% but at least $2 if the price is under

$100, $0 if the price is $100 or more) by using a formula and add the costs to the price

Walkthrough  Add other rules to the

existing ruleset usingformulas and actions

  In the ruleset on theright side of the thatrule we alreadycreated, chooseOptions  Insert NextRule by ...  Create ... 

  Enter a Description,such as Product notvalid  Choose AssignCondition ...  UseValue Range From ...  Context   Price 

Page 18: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 18/33

  18

  Select condition isintial  

  Under the Then branchchoose Add   Perform Action  Create ... 

  Select type Send Email(Action) 

  Enter Name, ShortText, and Text , forexample, NotificationMail  

  Choose Create AndNavigate To Object  and confirm bychoosing Yes 

Page 19: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 19/33

  19

  In the Recipient(s) field, enter an arbitraryemail address (We arenot going to actuallysend a mail. Theaddress still needs to

be technically correct,however it does notneed to exist)

  Enter some Subject ,for example,Notification: Productnot available 

  Enter the body text,where you can replacethe product name by&1, for example, Hellocustomer, product &1does not exist.Regards, Your SalesTeam 

  Choose RefreshMessage Placeholders 

  Choose the icon to theright of Placeholder 1 and select Context   Parameters 

  Choose Back  andconfirm by choosingwith Yes (the ruleshould now be

selected)

  Choose OK  again

  In the ruleset on theright side of the rulethat you createdearlier, choose Options  Insert Next ExitCondition Use

Value Range from Context Price

Page 20: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 20/33

  20

  Select is initial ascondition

  In the ruleset on theright side of the exitcondition that youcreated before, choose Options  Insert NextRule Create ... 

  Enter a Description, for

example Add ShippingCosts 

  Choose AssignCondition ...  UseValue Range From ... Context Price

  Select is less than ascondition and insert100 USD in the valuefield

  In the THEN branch,choose Add   Process Expression  Create ... 

Page 21: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 21/33

  21

  Select Formula type

  Enter Name, ShortText, and Text , forexample,  AddShipping Costs 

  Select Price as theresult data object

  Choose Create AndNavigate To Object  and confirm bychoosing Yes 

  By using the context elements, operators, and formula function offered on the lower part of the screen, enterthe formula:

  Price + MAX ( 2_USD, Price * 0,05 ) for TechEd Amsterdam and Bangalore; for TechEd Las Vegas, pleaseuse 0.05 instead of 0,05.

  Choose the Check  button to make sure that the formula is consistent

  Choose Back  and confirm the dialog box by choosing Yes (the rule should now be selected)

  Choose OK . You should now be back in the ruleset

Page 22: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 22/33

  22

  You have now finished modelling your business rules! The next exercise will guide you through activating andtesting your rules on the managed system

Page 23: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 23/33

  23

EXERCISE 5

Simulate the Rules on the Managed System (Remote Simulation)  Activate all created objects

  Run the function in simulation mode on the managed system  Enter different products, including products that are not listed or are listed more than once, and watch the

results

  Check the intermediate results of rules processing

Walkthrough  Activate all of the created

objects

  If the repository treeis collapsed, expandit

  In the repository treeon the left, select theruleset you createdearlier

  Choose Activate 

Page 24: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 24/33

  24

  Make sure that theInclude ReferencedObjects checkbox isselected

  Confirm the dialog

box by choosing Yes 

  On the upper left of the screen, you should see the success message Objects activated and all of the objectsyou created should show a green icon in the repository tree, indicating that they are active

  Run the function insimulation mode on themanaged system

  In the repository treeon the left, select thefunction you createdearlier

  Choose StartSimulation. A dialogbox appears.

  Select Remote(Current Version) inthe Simulation Mode

section. This optionwill deploy yourdecision service intothe managed systemspecified in theManaged System 

section (decisionservice not active forproductive use).Please select themanaged system youcreated in Exercise1.

  Choose Continue 

Page 25: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 25/33

  25

  Enter a product  (youcan select productsyou created earlierby clicking on theicon to the right of

the input field)  Choose Execute and

Display ProcessingSteps 

  Notice the resulting price at the top of the screen

  When you are finished with the simulation of your Decision Service, choose Back to Workbench. 

Page 26: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 26/33

  26

EXERCISE 6

Deploy the Decision Service to the Managed System  Deploy the decision service into your managed system

  Select the managed system you created in Exercise 1

  Make a test deployment and then deploy the decision service  Execute your decision service in the managed system

  Implement an ABAP report that calls the deployed decision service

  Hint: The second part of the exercise is intended for people who are familiar with ABAP Programming

Walkthrough

  Deploy the decision service intoyour managed system

  Navigate from the BRFplusWorkbench directly to theDecision Service Manager.Click in the toolbar onWorkbench  OpenDecision Service Manager orenter the transaction DSM inthe SAP GUI. The DSMWorkbench will now open ina new browser session.

  Select the managed systemyou created in Exercise 1and on the Deployment  tab,choose the Deployment Testbutton

Page 27: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 27/33

  27

  Select the BRFplus functionyou created in Exercise 2.Enter the name of yourfunction, for example,Product*  and choose theSearch button

  Mark your function andchoose Run Test . DSM willnow check whether yourfunction can be deployed tothe managed system

   After the test deployment hasbeen performed, themessage Deployment testwas successful, do you wantto deploy now? will appear.Choose Yes to start thedeployment

  In the dialog box, pleaseenter some form ofdocumentation, such asInitial deployment of theDecision Service ProductPrice 

  Select IntermediateDeployment as the activationtime  and click on Deploy  

  In the upper part of thescreen, two successmessages are displayed. Onthe Deployment  tab, you willnow see that your functionhas been deployed to themanaged system. Click in thecolumn Documentation and

check the entries

  Congratulations! You have deployed your first decision service into a managed system. In the next step, we willexecute your decision service in the managed system.

Page 28: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 28/33

  28

  Execute your decision service inthe managed system

  Go to the Deployment tab

  Select the decision service,for example, Product Price.The BRFplus Workbench will

open

  Choose Create CodeTemplate

  Deselect the ShowComments checkbox

  Choose Apply  

  Copy the text

  Switch to the SAP GUI

  In the popup enter a tile and

choose the Executable program as type and TestProgram as Status and pressSave

  In the pop up choose LocalObject  

  Call the ABAP Editor(transaction SE38)

  Create a local report with thefollowing name‘ZZ_CALL_TECHED_EX_CD160 ’ 

  Paste the copied text into thereport

  Insert the variable ‘lv_price’of typeif_fdt_types=>element_amount to the Data-Statement

  Replace the text ‘[INSERTCONTEXT VALUE HEREOR DELETE THE LINE].’  with one of the products

Page 29: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 29/33

  29

   At the end of the report, include the following:

  Save, Activate, and Run the Report

  LO_PROCESSOR  will find the deployed code of the decision service and execute it

  The result should be the same as in the simulation in Exercise 5

Page 30: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 30/33

  30

EXERCISE 7

Change Rules in the Decision Service and make a Delta Deployment  Change the rules in the DSM System

  Go to the decision table PRODUCT_PRICES and adjust the price

  Simulate the function  Execute the report you created in Exercise 6 again. What do think will happen?

  Perform a delta deployment

  Deploy the decision service to the managed system as a future deployment (current time + 5 minutes)

  Execute the report created in Exercise 6

  Wait 5 minutes and run the report again

Walkthrough  Change the rules in the DSM

System

  Select Open BRFplusWorkbench in DecisionService Manager

  The BRFplus Workbenchappears in a new browserwindow. Choose Search 

and enter the name of theapplication you created in

Exercise 1. Choose Application as the ObjectType. Choose Search. Onthe left-hand side, in the

navigation area, theapplication you created is

displayed   Expand the repository tree

and navigate to Expression

  Decision Table   

Page 31: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 31/33

  31

Product Price

  Change the price for allproducts (click directly onthe price and table open.Change the price andchoose OK)

   Activate the decision table

  In the repository tree, go toyour function

  Choose Simulation andsimulate the function asexplained in Exercise 5.Select Remote (CurrentVersion) for the simulationmode. Select the managed

system you created inExercise 1 and chooseContinue 

  Enter a product whoseprice you change. Theprice should now becalculated based on yourchange

  Go to the SAP GUI and navigate to the report you created in Exercise 6 and execute it. (Make sure the productis the same as in your simulation).

  The prices calculated in the simulation and by the report are different. Since we only changed the prices in the

DSM system, the managed system will not be affected by those changes. So it would be possible to test allchanges in the rules before deploying them to the productive environment

  In the next step we will perform a delta deployment and distribute the new decision service to the managedsystem

  Perform a delta deployment

  Call transaction DSM fromSAP GUI

  Select the managedsystem you created inExercise 1 and click on theDeployment  tab, choose

Deploy button  Select the BRFplus

function you created inExercise 2. Enter the nameof your function, forexample, Price* andchoose Search 

Page 32: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 32/33

  32

  On the screen, pleaseenter a description, forexample, DeltaDeployment. PricesChanged for all products.Go Live of new rules will

be in 5 minutes....   Select As on Date/Time as

the activation time, definethe current time + 5minutes as timestamp andChoose Deploy  

  Check the valid from/validto timestamps on theDeployment  tab for yourdecision service. (Theservice deployedpreviously will be valid in 5minutes as long as the olddecision service isprocessed).

  Navigate to the report you created in the previous exercise. Execute it. You will get the same result as before.Please write down the result.

  Wait 5 minutes and then execute your report again. Compare the current result with the result you wrote down.The price should now be different from 5 minutes ago!

Page 33: CD160_exercise.pdf

8/11/2019 CD160_exercise.pdf

http://slidepdf.com/reader/full/cd160exercisepdf 33/33

 

© 2013 by SAP AG or an SAP affiliate company. 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. National product specificationsmay vary.

These materials are provided by SAP AG and its affiliated companies (“SAP Group”) for informational purposes only, without representation or warranty of any kind, andSAP 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 inthe express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.

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

Please seehttp://www.sap.com/corporate-en/legal/copyright/index.epx#trademarkfor additional trademark information and notices.