You are on page 1of 27

Exercises - Solutions

SAP AG, 2012


Disclaimer

This presentation outlines our general product direction and should not be relied on in
making a purchase decision. This presentation is not subject to your license
agreement or any other agreement with SAP. SAP has no obligation to pursue any
course of business outlined in this presentation or to develop or release any
functionality mentioned in this presentation. This presentation and SAP's strategy and
possible future developments are subject to change and may be changed by SAP at
any time for any reason without notice. 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 assumes no responsibility for errors or omissions in this document, except if
such damages were caused by SAP intentionally or grossly negligent.

© 2012 SAP AG. All rights reserved. 2


Exercise: Validations - Questions

What is the main difference between a determination and a validation?

Could an action validation be joined to a consistency group?

Do action validations have request nodes?

Which options are there for preventing the saving of inconsistent business object
instances?

What is the difference between a save-preventing consistency group and an action


validation of the save action?

© 2012 SAP AG. All rights reserved. 3


Exercise: Validations - Answers

What is the main difference between a determination and a validation?


 Validations do not change any node instance data; determinations usually change node
instance data.

Could an action validation be joined to a validation group?


 No, a validation group never contains action validations.

Do action validations have request nodes?


 No, because action validations are only executed before their action is executed –
completely independently of any node.

Which options are there for preventing the saving of inconsistent business object
instances?
 Action validations on the action “save” or save-preventing consistency groups.

What is the difference between a save-preventing consistency group and an action


validation of the save action?
 The save action validation is executed only during saves, but the consistency validations
contained in the group can also run several times in the transaction (dependent on their
request nodes) - and not only during saves.
© 2012 SAP AG. All rights reserved. 4
Exercise: Implement an Action Validation

This invoice instance does not have a bill-to party defined.


An action validation detects this error and prevents the action INVOICE_ISSUED
from being executed.
© 2012 SAP AG. All rights reserved. 5
Exercise: Implement an Action Validation

Create an action validation that inhibits the execution of the action


INVOICE_ISSUED as long as there is no valid bill-to party specified.

 Create a validation with the name CHECK_BILLTO_PARTY as an action validation assigned


to the root node. You need one or more fields of type CHAR on the root node that hold(s) the
bill-to party.
 Implement a validation class with the name ZCL_CI_XX_V_BILLTO_PARTY (XX = group
name) and save it as local object.
 Configure the validation in such a way that the validation is executed before the execution of
action INVOICE_ISSUED.
 If one of the root instances does not have a bill-to party (or an incomplete party), a message
(create an appropriate CM-class) should be generated and ET_FAILED_KEY should be filled
too.
 Test your implementation using /BOBF/TEST_UI. First create an invoice and try to execute
the INVOICE_ISSUED action. A message should be displayed. Afterwards, fill the bill-to party
fields of this ROOT node instance and try to execute the INVOICE_ISSUED action again.

© 2012 SAP AG. All rights reserved. 6


Exercise: Implement an Action Validation

Transaction SE11

Add fields to the root node that


represent the bill-to party

© 2012 SAP AG. All rights reserved. 7


Exercise: Implement an Action Validation

Transaction SE91 to create the required message


1

© 2012 SAP AG. All rights reserved. 8


Exercise: Implement an Action Validation

Transaction SE24 to create the required CM class


2
1

5 Activate your class with messages

© 2012 SAP AG. All rights reserved. 9


Exercise: Implement an Action Validation
1 Switch to Change Mode
2
Use a right-click on “Validations“ beneath Node
Elements -> ROOT and choose “Create Validation ->
Action Validation“ from the context menu.

© 2012 SAP AG. All rights reserved. 10


Exercise: Implement an Action Validation

6 Double-click on the class/interface name

First part of implementation of method


/BOBF/IF_FRW_VALIDATION~EXECUTE
for validation CHECK_BILLTO_PARTY

© 2012 SAP AG. All rights reserved. 11


Exercise: Implement an Action Validation

Second part of implementation of method


/BOBF/IF_FRW_VALIDATION~EXECUTE
for validation CHECK_BILLTO_PARTY

Activate your class and regenerate the


constant interface 9

© 2012 SAP AG. All rights reserved. 12


Exercise: Implement an Action Validation

1 Mark both BO instances and


execute action INVOICE_ISSUED

© 2012 SAP AG. All rights reserved. 13


Exercise: Implement an Action Validation

After the bill-to party fields have been filled for both BO instances, you can execute the
action INVOICE_ISSUED.

© 2012 SAP AG. All rights reserved. 14


Exercise: Creation of a Consistency Validation

The implementation of the action validation in the previous exercise prevents the
execution of the action INVOICE_ISSUED.
Now we want to give the user the option of explicitly checking the currency of the
items.

© 2012 SAP AG. All rights reserved. 15


© SAP 2010 / Page 15
Exercise: Creation of a Consistency Validation

Create a consistency validation which checks whether the invoice instance is


consistent. In our case, the invoice instance is consistent whenever the price
currency of the items is “EUR” or “USD”.

 Create a consistency validation with the name CHECK_ITEM_CURRENCY_CODE as a


consistency validation assigned to the item node
 Configure the validation in such a way that the validation is executed if the consumer
requests a consistency check. Create the class ZCL_CI_XX_V_CHCK_ITM_CURRENCY,
which should ensure that the price currency is always “EUR” or “USD”. The name of the
currency fields depends on your business object.
 Check your implementation using /BOBF/TEST_UI. Create an invoice instance item with
another currency and press CHECK. What happens?

© 2012 SAP AG. All rights reserved. 16


© SAP 2010 / Page 16
Exercise: Creation of a Consistency Validation

Transaction SE91 to create the needed message (see exercise ‘Implement an Action
Validation‘)
1

© 2012 SAP AG. All rights reserved. 17


Exercise: Creation of a Consistency Validation

Transaction SE24 to add the new message to the CM class


(see exercise ‘Implement an Action Validation‘)
1

4 Activate your CM class with messages

© 2012 SAP AG. All rights reserved. 18


Exercise: Creation of a Consistency Validation

1 Switch to Change Mode


2
Use a right-click on “Validations“ beneath Node Elements -> ITEM
and choose “Create Validation -> Consistency Validation“ from the
context menu.

© 2012 SAP AG. All rights reserved. 19


Exercise: Creation of a Consistency Validation

6 Double-click on the class/interface name

First part of implementation of method


/BOBF/IF_FRW_VALIDATION~EXECUTE for
validation CHECK_ITEM_CURRENCY_CODE
7

© 2012 SAP AG. All rights reserved. 20


Exercise: Creation of a Consistency Validation

Second part of implementation of method


/BOBF/IF_FRW_VALIDATION~EXECUTE for
validation CHECK_ITEM_CURRENCY_CODE

Activate your class and regenerate the


constant interface 9

© 2012 SAP AG. All rights reserved. 21


Exercise: Creation of a Consistency Validation

When you check an item with currency code ‘SFR‘, the system displays the error message.

© 2012 SAP AG. All rights reserved. 22


Exercise: Creation of a Consistency Group

Create a consistency group to prevent the saving of inconsistent BO instances and


assign the consistency validation CHECK_ITEM_CURRENCY_CODE to it.

 Create a consistency group called ITEM_CONSISTENCY.


 Define the settings that make the consistency group inhibit the save.
 Assign the consistency validation CHECK_ITEM_CURRENCY_CODE.
 Test your work by using the /BOBF/TEST_UI. Create an item instance that uses ABC as
currency and try to save the transaction. What happens?

© 2012 SAP AG. All rights reserved. 23


© SAP 2010 / Page 23
Exercise: Creation of a Consistency Group

1 Switch to Change Mode


Use a right-click on “Groups“ and choose “Create Group ->
Consistency Group“ from the context menu

Save your BO and regenerate the


4 constant interface

© 2012 SAP AG. All rights reserved. 24


Exercise: Creation of a Consistency Group

© 2012 SAP AG. All rights reserved. 25


Thank you
© 2012 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purpose Google App Engine, Google Apps, Google Checkout, Google Data API, Google Maps,
without the express permission of SAP AG. The information contained herein may be Google Mobile Ads, Google Mobile Updater, Google Mobile, Google Store, Google Sync,
changed without prior notice. Google Updater, Google Voice, Google Mail, Gmail, YouTube, Dalvik and Android are
trademarks or registered trademarks of Google Inc.
Some software products marketed by SAP AG and its distributors contain proprietary
software components of other software vendors. INTERMEC is a registered trademark of Intermec Technologies Corporation.
Microsoft, Windows, Excel, Outlook, PowerPoint, Silverlight, and Visual Studio are Wi-Fi is a registered trademark of Wi-Fi Alliance.
registered trademarks of Microsoft Corporation.
Bluetooth is a registered trademark of Bluetooth SIG Inc.
IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x,
System z, System z10, z10, z/VM, z/OS, OS/390, zEnterprise, PowerVM, Power Motorola is a registered trademark of Motorola Trademark Holdings LLC.
Architecture, Power Systems, POWER7, POWER6+, POWER6, POWER, PowerHA, Computop is a registered trademark of Computop Wirtschaftsinformatik GmbH.
pureScale, PowerPC, BladeCenter, System Storage, Storwize, XIV, GPFS, HACMP,
RETAIN, DB2 Connect, RACF, Redbooks, OS/2, AIX, Intelligent Miner, WebSphere, Tivoli, SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP BusinessObjects Explorer,
Informix, and Smarter Planet are trademarks or registered trademarks of IBM Corporation. StreamWork, SAP HANA, and other SAP products and services mentioned herein as well
as their respective logos are trademarks or registered trademarks of SAP AG in Germany
Linux is the registered trademark of Linus Torvalds in the United States and other countries. and other countries.
Adobe, the Adobe logo, Acrobat, PostScript, and Reader are trademarks or registered Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal
trademarks of Adobe Systems Incorporated in the United States and other countries. Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services
Oracle and Java are registered trademarks of Oracle and its affiliates. mentioned herein as well as their respective logos are trademarks or registered trademarks
of Business Objects Software Ltd. Business Objects is an SAP company.
UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group.
Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL Anywhere, and other Sybase
Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin products and services mentioned herein as well as their respective logos are trademarks or
are trademarks or registered trademarks of Citrix Systems Inc. registered trademarks of Sybase Inc. Sybase is an SAP company.
HTML, XML, XHTML, and W3C are trademarks or registered trademarks of W3C®, Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are registered trademarks
World Wide Web Consortium, Massachusetts Institute of Technology. of Crossgate AG in Germany and other countries. Crossgate is an SAP company.
Apple, App Store, iBooks, iPad, iPhone, iPhoto, iPod, iTunes, Multi-Touch, Objective-C, All other product and service names mentioned are the trademarks of their respective
Retina, Safari, Siri, and Xcode are trademarks or registered trademarks of Apple Inc. companies. Data contained in this document serves informational purposes only. National
product specifications may vary.
IOS is a registered trademark of Cisco Systems Inc.
The information in this document is proprietary to SAP. No part of this document may be
RIM, BlackBerry, BBM, BlackBerry Curve, BlackBerry Bold, BlackBerry Pearl, BlackBerry reproduced, copied, or transmitted in any form or for any purpose without the express prior
Torch, BlackBerry Storm, BlackBerry Storm2, BlackBerry PlayBook, and BlackBerry App written permission of SAP AG.
World are trademarks or registered trademarks of Research in Motion Limited.

© 2012 SAP AG. All rights reserved. 27