You are on page 1of 28

BOPF Basic Training

04 Actions

ByDesign BOPF
Agenda

1. Introduction

2. Creating an Action

3. Configuration of an Action

4. Implementation of an Action

5. Exercise
1. Questions
2. Implementation of the Action “INVOICE_PAID”

© SAP 2010 / Page 2


Introduction

Motivation
 Business objects provide specific functionality, which can be used by user or system.
 In this example, the status of an invoice business object can be changed by the action
„INVOICE_PAID“ into paid (code value 2).

© SAP 2010 / Page 3


Definition

Definition
 Actions are business logic entities assigned to a business object node
 Actions are called actively either by
 a service consumer
 another business object
 internally (e.g. by another action or by a determination)
 Actions can modify nodes of the own as well as nodes of other business objects
 Actions may have input parameters that are imported from the consumer

© SAP 2010 / Page 4


Agenda

1. Introduction

2. Creating an Action

3. Configuration of an Action

4. Implementation of an Action

5. Exercise
1. Questions
2. Implementation of the Action “INVOICE_PAID”

© SAP 2010 / Page 5


Action Categories

Framework Actions

MDRS Actions

In the BOPF configuration exists three action categories:


 MDRS Actions: Defined in MDRS and can be called by service consumers and other BOs
 Private Actions: Defined in BOPF and not known in the MDRS. Thus they can„t be called by
service consumers or other BOs - only used by the BO itself.
 Framework actions: Within BOPF the core-services create, update, delete, save, lock,
unlock and validate are created automatically and therefor have not to been implemented.

© SAP 2010 / Page 6


Creating an MDRS Action

MDRS Actions are automatically created (but not implemented) while importing a
model into the BOPF Workbench
1. Select the action
2. Maintain the action class which should contain the action implementation

© SAP 2010 / Page 7


Creating a Private Action

2
1

1. Choose „Create Action“ in the context menu of the node, to which this action should be
assigned
2. Follow the guided procudure to maintain all requied meta data

© SAP 2010 / Page 8


Showing Framwork Actions

The Framework Actions are automatically created, therefore no implementation is


required.
 Hint: These actions are not displayed in BOPF Workbench by default.
(Choose Menu „Utilities“ > „Settings“ > Tab „Business Object“ to set them visible)

© SAP 2010 / Page 9


Agenda

1. Introduction

2. Creating an Action

3. Configuration of an Action

4. Implementation of an Action

5. Exercise
1. Questions
2. Implementation of the Action “INVOICE_PAID”

© SAP 2010 / Page 10


Action Settings

 Node: The node, which the action is assigned to („Assigned Node“).


 Action Cardinality: Defines on how many node instance the action can be called at a time
 Change Mode (Rule of thumb):
 Persistent Action => „Exclusive write“ (default)
 Action on only transient fields => „Only Read Mode“
 Class/ Interface: Class, which implements this action

© SAP 2010 / Page 11


Agenda

1. Introduction

2. Creating an Action

3. Configuration of an Action

4. Implementation of an Action

5. Exercise
1. Questions
2. Implementation of the Action “INVOICE_PAID”

© SAP 2010 / Page 12


Overview of an Action Implementation

methods RETRIEVE_DEFAULT_PARAM
importing
IS_CTX type /BOPF/S_FRW_CTX_ACT
RETRIEVE_DEFAULT IT_KEY type /BOPF/T_FRW_KEY
IO_READ type ref to /BOPF/IF_FRW_READ
_PARAM changing
CS_PARAMETERS type ref to DATA
raising /BOPF/CX_FRW .

methods PREPARE
importing
IS_CTX type /BOPF/S_FRW_CTX_ACT
IO_READ type ref to /BOPF/IF_FRW_READ
IO_CHECK type ref to /BOPF/IF_FRW_CHECK
1. PREPARE IS_PARAMETERS type ref to DATA
exporting
EO_MESSAGE type ref to /BOPF/IF_FRW_MESSAGE
changing
CT_KEY type /BOPF/T_FRW_KEY
raising /BOPF/CX_FRW .
methods EXECUTE
importing
IS_CTX type /BOPF/S_FRW_CTX_ACT
IT_KEY type /BOPF/T_FRW_KEY
2. EXECUTE IO_READ type ref to /BOPF/IF_FRW_READ
IO_MODIFY type ref to /BOPF/IF_FRW_MODIFY
IS_PARAMETERS type ref to DATA
exporting
EO_MESSAGE type ref to /BOPF/IF_FRW_MESSAGE
ET_FAILED_KEY type /BOPF/T_FRW_KEY
raising /BOPF/CX_FRW .
Actions are classes implementing the /BOPF/IF_FRW_ACTION interface.
 Two of the three interface methods are executed sequentially and forward table of keys,
on which the action will be executed (Separation of concerns!).
© SAP 2010 / Page 13
RETRIEVE_DEFAULT_PARAM Method

methods RETRIEVE_DEFAULT_PARAM
importing
IS_CTX type /BOPF/S_FRW_CTX_ACT
IT_KEY type /BOPF/T_FRW_KEY
IO_READ type ref to /BOPF/IF_FRW_READ
changing
CS_PARAMETERS type ref to DATA
raising
/BOPF/CX_FRW .

Retrieves the default parameters of an action.


 IS_CTX: Context information about the Action
 IT_KEY: Table of keys of the instances of the assigned node of the Action
 IO_READ: Reference to an object implementing the read interface to read instance data.
 CS_PARAMETERS: Reference to the parameters of the Action

© SAP 2010 / Page 14


PREPARE Method

methods PREPARE
importing
IS_CTX type /BOPF/S_FRW_CTX_ACT
IO_READ type ref to /BOPF/IF_FRW_READ
IO_CHECK type ref to /BOPF/IF_FRW_CHECK
IS_PARAMETERS type ref to DATA
exporting
EO_MESSAGE type ref to /BOPF/IF_FRW_MESSAGE
changing
CT_KEY type /BOPF/T_FRW_KEY
raising
/BOPF/CX_FRW .

Extends the set of instance keys in CT_KEY by additional key, which are affected by
this action
 Example: Call check and determine to derive a current consistency status for action checks.

Parameters
 IS_PARAMETERS: Parameters of this Action call which were given by the consumer
 EO_MESSAGE: Message object, which contains information, error or warning messages
 CT_KEY: Table of keys of the „prepared“ instances

© SAP 2010 / Page 15


EXECUTE Method

methods EXECUTE
importing
IS_CTX type /BOPF/S_FRW_CTX_ACT
IT_KEY type /BOPF/T_FRW_KEY
IO_READ type ref to /BOPF/IF_FRW_READ
IO_MODIFY type ref to /BOPF/IF_FRW_MODIFY
IS_PARAMETERS type ref to DATA
exporting
EO_MESSAGE type ref to /BOPF/IF_FRW_MESSAGE
ET_FAILED_KEY type /BOPF/T_FRW_KEY
raising
/BOPF/CX_FRW .

Execution of the actual action logic


 IT_KEY: Table of keys of the instances the action shall operate on.
 IS_PARAMETERS: Reference to the action„s parameters supplied by the service
consumer.
 EO_MESSAGE: Message container
 ET_FAILED_KEY: Table of keys of node instances, for which the action execution was not
possible. This information is not evaluated by the framework and thus only useful if e.g.
Action1 calls Action2 and needs to get the failed keys. In future those keys will be exposed
via LCP.

© SAP 2010 / Page 16


Parameter Action Context (IS_CTX)

The Action Context („IS_CTX“) is input parameter of all action methods and provide
generic model information about the action.

Keys from the constant interface of the Business Object, which is parent of the action
in the model:
 BO_KEY: Key of the business object, in which the action is part of
 ROOT_NODE_KEY :Key of the root node of that business object
 NODE_KEY: Key of the node, to which the action is assigned to
 ACT_KEY: Key of this action
 ACT_CAT: Category of this action (e.g. „SC_ACTION_LOCK“, „SC_ACTION_DELETE“)
 FACADE: Local Client Proxy facade
 REFERENCE NODES: Table of BO node references (only relevant for
CREATE_WITH_REFERENCE Actions)

Attention: These information is only static from the BO model – there is no instance
relevant information!

© SAP 2010 / Page 17


Example of an Action Context

Customer_Invoice BO-Model
/BOPF/CUSTOMER_INVOICE
Action Context
(IS_CTX)
ROOT (232…)
BO_KEY BTD_REFERENCE (124…)
ROOT_NODE_KEY ITEM (232)
NODE_KEY INCREASE_QUANTITY
ACT_KEY ITEM_BTD_REFERENCE (232)
ACT_CAT ITEM_PRODUCT (232)
FACADE ITEM_PRODUCT_DESCRIPTION (232)
REFERENCE_NODES ITEM_TAX_TERMS (232)
PARTY (232)
TOTAL_AMOUNT (232)

© SAP 2010 / Page 18


Agenda

1. Introduction

2. Creating an Action

3. Configuration of an Action

4. Implementation of an Action

5. Exercise
1. Questions
2. Implementation of the Action “INVOICE_PAID”

© SAP 2010 / Page 19


Exercise 1: Questions

Is an action call possible?

Action type Proxy Action of BO Internal Action of BO Framework Action


„A“ „A“ of BO „A“
Service Consumer
UI
Determination of BO „A“
BO „B“

© SAP 2010 / Page 20


Exercise 1: Solutions

Is an action call possible?

Action type Proxy Action of BO Internal Action of Framework Action of


„A“ BO „A“ BO „A“
Service Consumer
UI X X
Determination of BO „A“ X X X
BO „B“ X X

© SAP 2010 / Page 21


How to use the ESF Test Shell

You can call actions via the ESF Test Shell

© SAP 2010 / Page 22


Exercise 2: Implementation of the Action
“INVOICE_PAID”

Extend your „customer_invoice“ BO by an action which sets the status of the


invoice to „paid“.
1. Create a new action „INVOICE_PAID “ for the node „ROOT“
2. Create a new implementation class („ZCL_CI_XX_A_INVOICE_PAID “, XX = group
number) for this action and implement the execute method of the action interface
3. Test your action with the ESF Test Shell (Transaction SESFTS)
Hint: Update each instance of the “ROOT” node by setting the attribute “payment_status”
with the constant “/bopf/cl_tst_sp_pay_exec_st_cd=>co_2“ and the attribute
“payment_received” with the current date („sy-datum“).
© SAP 2010 / Page 23
Exercise 2: Solution

1. Doubleclick on the action „INVOICE_PAID“


2. Input the name („ZCL_CIXX_A_INVOICE_PAID“, XX is the group number) of the new action
class and create it by forward navigation

© SAP 2010 / Page 24


Exercise 2: Solution (1)

CLASS ZCL_CI_19_A_INVOICE_PAID IMPLEMENTATION.

METHOD /BOPF/IF_FRW_ACTION~EXECUTE.
DATA:
ls_key TYPE REF TO /bopf/s_frw_key,
lt_root_data TYPE BOPF_T_CUSTOMER_INVOICE_00,
ls_root_data TYPE REF TO BOPF_S_CUSTOMER_INVOICE_00,
lv_ltimestamp TYPE timestampl.
“ get all root instance data
io_read->retrieve(
EXPORTING
iv_node = ZIF_CI00_BOPF_CUSTOMER_INVOI_C=>sc_node-root
it_key = it_key
IMPORTING
et_data = lt_root_data.

“ set the components PAYED and PAYMENT_RECEIVED for each instance


LOOP AT lt_root_data REFERENCE INTO ls_ROOT_DATA.
" update data
ls_root_data->payment_status = /bopf/cl_tst_sp_pay_exec_st_cd=>co_2.
" set payment date time stamp in long form (YYYYMMDDhhmmss,mmmuuu)
GET TIME STAMP FIELD lv_ltimestamp.
ls_root_data->payment_received = lv_ltimestamp .
" update data
io_modify->update(
EXPORTING
iv_node = ZIF_CI00_BOPF_CUSTOMER_INVOI_C=>sc_node-root
iv_key = ls_root_data->KEY
is_data = ls_root_data ).
ENDLOOP.

ENDMETHOD.

METHOD /BOPF/IF_FRW_ACTION~PREPARE.
ENDMETHOD.
A not existing method body leads to errors!
METHOD /BOPF/IF_FRW_ACTION~RETRIEVE_DEFAULT_PARAM.
ENDMETHOD.

ENDCLASS.

© SAP 2010 / Page 25


Exercise 2: Solution (2)

1 2
3

1. Start the ESF BO Test Shell (Transaction SESFTS) in a new window


2. Create a new instance of the BOPF_CUSTOMER_INVOICE_XX (xx = groupnumber)
3. Choose the action „INVOICE_PAID“
4. The field Payment/ReceivedDateTime will be set to the actual date and time.

© SAP 2010 / Page 26


Thank you!

© SAP 2007 / Page 27


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 28

You might also like