You are on page 1of 30

BS-BOBF Basic Training

02 Transaction and Service Manager

BOPF Team
14 April 2010
Agenda

1. Introduction
2. Architecture Overview
3. Entities of the Transaction Layer
4. Transaction Cycle
5. Implementation
1. Interfaces
2. Example

© SAP 2007 / Page 2


Introduction
What is a „Transaction“?

Transaction Processing

Transaction 1 Transaction 2 Transaction 3

 Wikipedia
In computer science, transaction processing is information processing that is divided into
individual, indivisible operations, called transactions. Each transaction must succeed or fail
as a complete unit; it cannot remain in an intermediate state.
 Example
If a consumer books a trip, this booking must only be committed, if both the flight and a hotel
room is available.

© SAP 2007 / Page 3


Introduction
Transaction Controlling

(a) Save & Continue Transaction 1 Transaction 2

(b) Save & Exit Transaction 1

(c) Cleanup Transaction 1

A transaction might be controlled by the following commands:


 Save & Continue: Persists all changes, which are done so far in the current transaction.
Afterwards, a new transaction is automatically created.
 Save & Exit: Persist all changes, which are done so far in the current transaction.
Afterwards, no further commands will be executed.
 Cleanup: Remove all changes, which are done so far in the current transaction.

© SAP 2007 / Page 4


Transaction and Service Manager Concept

 In order to support transaction-based scenarios on business objects,


the Transaction and Service Manager (TSM) is exclusively available in the
Business Suite.
 Main tasks:
 Transaction Management
 Cross Business Object Calls

© SAP 2007 / Page 5


Agenda

1. Introduction
2. Architecture Overview
3. Entities of the Transaction Layer
4. Dynamic Overview
5. Implementation
1. Interfaces
2. Example

© SAP 2007 / Page 6


Architecture Overview

Business Suite

AP (a) (b)

 There are two possible ways to use the TSM concept


 Standalone Transaction Manager
Only one single comprehensive save method is provided.
 Master & Slave Transaction Manager (not part of these slides)
Enables the integration of foreign applications within the save process. Thereto, a more
fine-grained set of methods to control the save-process is provided by the slave
transaction manager and used by the master transaction manager.

© SAP 2007 / Page 7


Ensemble of Consumer, TSM and BOPF

Use Services
Consumer

(e.g. do_action)
Consumer

Create, Cleanup, Save


the transaction
Transaction Layer

Transaction
Manager

Service Manager Service Manager


Transaction BO 7
BO 4

Forward Service Forward Service


Requests Requests
(e.g. do_action) (e.g. do_action)
Use Services
(e.g. do_action)
BOPF

Service Layer Service Layer


BO 4 BO 7

© SAP 2007 / Page 8


Ensemble of Consumer, TSM and BOPF

Use Services
Consumer

(e.g. do_action)
Consumer

Create, Cleanup, Save


the transaction
Transaction Layer

Transaction
Manager

Service Manager Service Manager


Transaction BO 7
BO 4

Forward Service Forward Service


Requests Requests
(e.g. do_action) (e.g. do_action)
Use Services
(e.g. do_action)
BOPF

Service Layer Service Layer


BO 4 BO 7

© SAP 2007 / Page 9


Agenda

1. Introduction
2. Architecture Overview
3. Entities of the Transaction Layer
4. Dynamic Overview
5. Implementation
1. Interfaces
2. Example

© SAP 2007 / Page 10


Entities of the Transaction Layer

 Transaction Manager
 Provides methods to save & exit, save & continue or cleanup the current transaction
 Collects all changes, which are done within the current transaction
(thus the architectural layering must be strictly obeyed)
 Checks, if the cross business object calls are valid at all
(e.g. calling an action of BO2 out of a check implementation of BO1 is forbidden)
 Is only used by the consumer and never out of a BOPF entity implementation

 Service Manager
 Provides methods to access a business object‘s service layer methods
 Can be used both by the consumer and out of a BOPF entity implementation
(to access a foreign BO)

© SAP 2007 / Page 11


Entities of the Transaction Layer (2)

 Transaction Manager Factory


 Provides get_transaction_manager() to receive the transaction manager instance
(If this instance hasn‘t been created before, it will be automatically instantiated.)
 Ensures, that there exists always only one transaction manager instance.
 Is only used by the consumer and not out of a business object entity implementation.

 Service Manager Factory


 Provides get_service_manager( iv_bo_key ) to receive a service manager instance for a
certain business object
 Ensures, that there is always only one service manager instance for each business object
 Can be used both by the consumer and out of a BOPF entity implementation
(to access a foreign BO)

© SAP 2007 / Page 12


Agenda

1. Introduction
2. Architecture Overview
3. Entities of the Transaction Layer
4. Dynamic Overview
5. Implementation
1. Interfaces
2. Example

© SAP 2007 / Page 13


Transaction Patterns

 The Transaction Manager and the Service Managers


Consumer
interact by the help of services during the transaction.
Service Interface  The execution order of the service calls is restricted by
the help of transaction patterns. There are two inbuilt
Transaction transaction patterns available:
Manager
 Save & Continue
Service Interface
Persists all changes, which are done so far in the
current transaction. Afterwards, a new transaction is
Service Manager automatically created.
BO 4
 Save & Exit
Persist all changes, which are done so far in the
Service Layer current transaction. Afterwards, no further services
BO 4
can be executed.

© SAP 2007 / Page 14


States of a Transaction

1. After calling a service manager‘s


service, the transaction remains in
the interaction state.

2. As soon as the „save“ method of the


transaction manager ist called by the
consumer, the interaction state is finished.
All of the following states are processed
automatically by the transaction manager.

3. Difference between the both Transaction Patterns:


The Save & Continue creates a new transaction and
thereto forms a cycle.

© SAP 2007 / Page 15


Description of the Transaction Phases

 Interaction Phase
During this phase, the consumer can use all services, which are provided by the service
managers, to access the business objects functionality.
 Save Phase
During this phase, the following services are called on each business object, which takes part
at the current transaction.
1. Finalize: Perform late modifications in order to prepare the business objects for saving
(„Consistency Check“ Determinations, Status Consistency Groups, „Finalize“
Determinations)
2. Check_Before_Save: Check if a business object instance can be saved from a business
point of view. („Save“ Action Validations, Save Preventing Consistency Groups)
3. Adjust_Numbers: In this phase, unique numbers might be derived from a number range.
(„Draw Numbers“ Determinations)
4. On_Numbers_Adjusted: If the derieved unique numbers are referenced by other node
instances, these references must be updated during this phase. („Adopt Numbers“ Action)
5. Do_Save: The changes of the current transaction are made persistent. („Before Writing
Data“ Determinations)
 After_Successful_Save: Prepare the business object for the next transaction. („After
Commit“ Determinations)
 After_Failed_Save: Undo changes performed during the finalize in order to continue the
transaction. („After Failed Save Attempt“ Determinations)
 Cleanup Phase: All changes which are done so far in the transaction are made undone.
© SAP 2007 / Page 16
Agenda

1. Introduction
2. Architecture Overview
3. Entities of the Transaction Layer
4. Dynamic Overview
5. Implementation
1. Interfaces
2. Example

© SAP 2007 / Page 18


Interface Overview

Consumer
Transaction Manager Interface
/BOBF/IF_TRA_TRANSACTION_MANAGER

Transaction
Manager
Service Manager Interface
/BOBF/IF_TRA_SERVICE_MANAGER

Service Manager
BO 1

Service Layer
BO 1

 /BOBF/IF_TRA_TRANSACTION_MANAGER
Used by the consumer to control the whole transaction.
 /BOBF/IF_TRA_SERVICE_MANAGER
Used to access the core services of a business object (either by the consumer or by another
business object). These generic core services are provided by every business object.

© SAP 2007 / Page 19


Transaction Manager Interface
(/BOBF/IF_TRA_TRANSACTION_MANAGER)

 Transaction Control
 SAVE
Make all changes, which are done during the current transaction, persistent.
 CLEANUP
Make all changes, which are done during the current transaction, undone.
 Information
 GET_TRANSACTIONAL_CHANGES
Get all changes, which are done during the current transaction.

© SAP 2007 / Page 20


Core Service Approach vs. Object Orientation
Example of the Execution of an Action

Object Oriented Approach Core Service Approach


<< Business Object>>
Design Time Customer Invoice
Issue_Invoice()

Customer Invoice:23 Service Manager:56

Customer Invoice
Do_Action(„Issue_Invoice“, Service Layer:1
Issue_Invoice()
Run Time Bo-Instance=23)
Do_Action(…)

 The action of the object is  The action is called by the help of a


directly called. generic core service.
Service Manager Interface
(/BOBF/IF_TRA_SERVICE_MANAGER)

 Read Node Instance Data


 RETRIEVE
Read the data of node instances, which can be identified by their node instance key.
 RETRIEVE_BY_ASSOCIATION
Read the data of node instances, which can be identified by using a certain association.
 QUERY
Execution of a certain query in order to find node instances.

 Modification of Node Instance Data


 MODIFY
Create, update or delete node instances of a certain node.

© SAP 2007 / Page 22


Service Manager Interface
(/BOBF/IF_TRA_SERVICE_MANAGER)

 Action Execution
 CHECK_ACTION
Check whether an action of a business object can be performed or not.
 DO_ACTION
Executes an action of a business object.

 Consistency Checks
 CHECK_CONSISTENCY
Check, if the business object fulfills its own consistency criteria.
 CHECK_AND_DETERMINE
Check, if the business object fulfills its own consistency criteria and try to resolve existing
inconsistency.

 Alternative Keys
 CONVERT_ALTERN_KEY
Converts an (alternative) key to another alternative or primary key.

© SAP 2007 / Page 23


Service Manager Interface
(/BOBF/IF_TRA_SERVICE_MANAGER)

 Miscellaneous (mainly used by the user interface implementation)


 RETRIEVE_CODE_VALUE_SET
This method returns possible values for a certain entity, e.g. a node attribute.
By the help of this method, a F4 help can be provided by the user interface.
 RETRIEVE_PROPERTY
Returns the properties for certain entities. These properties give hints about the
representation of data in the user interface. For instance to decide, whether an node
attribute can be edited or not.
 RETRIEVE_DEFAULT_QUERY_PARAM
Returns the default parameter values of a certain query.
 RETRIEVE_DEFAULT_ACTION_PARAM
Retrieves the default parameter values of an action.
 RETRIEVE_DEFAULT_NODE_VALUES
This method returns the default node values of a node instance. Thus, if a user create a
new node instance, some of the node attributes can be already prefilled with default
values at the user interface.

© SAP 2007 / Page 24


Example of an Initialization Phase

 Only the returned transaction manager instance provides the save or cleanup
method regarding the whole current transaction.

© SAP 2007 / Page 25


Example of an Interaction Phase

© SAP 2007 / Page 26


Example of a Cross Business Object Call

© SAP 2007 / Page 27


Example of the Save Phase

 Assumption: Only BO1 has been changed within the current transaction.

© SAP 2007 / Page 28


Questions?

© SAP 2007 / Page 29


Thank you!

© SAP 2007 / Page 30


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.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, Duet, Business ByDesign, ByDesign, PartnerEdge 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 and
associated logos displayed 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. 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. SAP assumes no responsibility for errors or omissions in this document. SAP does not warrant the accuracy or completeness 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

Weitergabe und Vervielfältigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne die ausdrückliche schriftliche Genehmigung durch
SAP AG nicht gestattet. In dieser Publikation enthaltene Informationen können ohne vorherige Ankündigung geändert werden.
Einige von der SAP AG und deren Vertriebspartnern vertriebene Softwareprodukte können Softwarekomponenten umfassen, die Eigentum anderer Softwarehersteller sind.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, Duet, Business ByDesign, ByDesign, PartnerEdge und andere in diesem Dokument erwähnte SAP-Produkte und Services
sowie die dazugehörigen Logos sind Marken oder eingetragene Marken der SAP AG in Deutschland und in mehreren anderen Ländern weltweit. Alle anderen in diesem Dokument erwähnten
Namen von Produkten und Services sowie die damit verbundenen Firmenlogos sind Marken der jeweiligen Unternehmen. Die Angaben im Text sind unverbindlich und dienen lediglich zu
Informationszwecken. Produkte können länderspezifische Unterschiede aufweisen.

Die in diesem Dokument enthaltenen Informationen sind Eigentum von SAP. Dieses Dokument ist eine Vorabversion und unterliegt nicht Ihrer Lizenzvereinbarung oder einer anderen
Vereinbarung mit SAP. Dieses Dokument enthält nur vorgesehene Strategien, Entwicklungen und Funktionen des SAP®-Produkts und ist für SAP nicht bindend, einen bestimmten
Geschäftsweg, eine Produktstrategie bzw. -entwicklung einzuschlagen. SAP übernimmt keine Verantwortung für Fehler oder Auslassungen in diesen Materialien. SAP garantiert nicht die
Richtigkeit oder Vollständigkeit der Informationen, Texte, Grafiken, Links oder anderer in diesen Materialien enthaltenen Elemente. Diese Publikation wird ohne jegliche Gewähr, weder
ausdrücklich noch stillschweigend, bereitgestellt. Dies gilt u. a., aber nicht ausschließlich, hinsichtlich der Gewährleistung der Marktgängigkeit und der Eignung für einen bestimmten Zweck
sowie für die Gewährleistung der Nichtverletzung geltenden Rechts.
SAP übernimmt keine Haftung für Schäden jeglicher Art, einschließlich und ohne Einschränkung für direkte, spezielle, indirekte oder Folgeschäden im Zusammenhang mit der Verwendung
dieser Unterlagen. Diese Einschränkung gilt nicht bei Vorsatz oder grober Fahrlässigkeit.
Die gesetzliche Haftung bei Personenschäden oder die Produkthaftung bleibt unberührt. Die Informationen, auf die Sie möglicherweise über die in diesem Material enthaltenen Hotlinks
zugreifen, unterliegen nicht dem Einfluss von SAP, und SAP unterstützt nicht die Nutzung von Internetseiten Dritter durch Sie und gibt keinerlei Gewährleistungen oder Zusagen über
Internetseiten Dritter ab.
Alle Rechte vorbehalten.

© SAP 2007 / Page 31

You might also like