You are on page 1of 23

BOPF Basic Training

03 Implementation of BOPF Entities

ByDesign BOPF

Agenda

1.

Introduction

2.

Accessing Node Instance Data


1.
2.

Reading Node Instance Data


Writing Node Instance Data

3.

Message Concept

4.

BOPF Performance Guideline

SAP 2010 / Page 2

Introduction

What is a framework?

A software framework is an abstraction in which common code providing generic


functionality can be selectively overridden or specialized by user code providing specific
functionality.

Frameworks are similar to software libraries in that they are reuseable abstractions of code
wrapped in a well-defined API. Unlike libraries, however, the overall program's flow of control
is not dictated by the caller, but by the framework. This inversion of control is the
distinguishing feature of software frameworks.

(Source: Wikipedia.com)

SAP 2010 / Page 3

Introduction

An instance of the class


of the called action is
instantiated and their
execute-method
executed by the BOPF.

Inversion of control means for example, BOPF calls the action implementation, which
you have implemented, if this action is called by the consumer.
If you implement a BOPF entity (e.g. action or determination), the framework
provides you a context for model information and access objects to access the data
of business object node instances.

SAP 2010 / Page 4

Agenda

1.

Introduction

2.

Accessing Node Instance Data


1.
2.

Reading Node Instance Data


Writing Node Instance Data

3.

Message Concept

4.

BOPF Performance Guideline

SAP 2010 / Page 5

/BOPF/IF_FRW_READ Interface Methods

SAP 2010 / Page 6

Reading Data with Retrieve()

io_read->retrieve(
EXPORTING
iv_node
it_key
IMPORTING
et_data

= if_bopf_customer_invoice_19_c=>sc_node-item
= it_key
= lt_item_data ).

/BOPF/IF_FRW_READ~retrieve() provides access to the instance data of the


buffer. Some of its important parameters are listed below:

iv_node: Specified the business object node for which data shall be retrieved. In this
example we want the data from node ITEM.

it_key: Table of keys of business object instances which shall be read.

et_data: Internal table, which contains the node data for the requested instances. Table is
of the combined table type specified for the node in the BOPF model.

SAP 2010 / Page 7

Example of Retrieve()

BO Instance
(Test Shell)

BO Model
(CONF UI)

Input Parameter

IV_NODE
8003BAE58F691DEB9688BEFD50A1D616
IT_KEY
00000000000102DC9BAFC085F3AA808B
00000000000102DC9BAFC0EFD63940AA
00000000000102DC9BAFCA210B88410F

SAP 2010 / Page 8

Output Parameter

Table of combined structure of the node item with 3


lines, one for each of the Item instances.

Reading Data with Retrieve_By_Association()

io_read->retrieve_by_association(
EXPORTING
IV_NODE
= ZIF_CI00_BOPF_C=>sc_node-root
IT_KEY
= it_key
IV_ASSOCIATION = ZIF_CI00_BOPF_C=>SC_ASSOCIATION-root-item
IV_FILL_DATA
= abap_true
IMPORTING
ET_DATA
= lt_item_data ).

/BOPF/IF_FRW_READ~retrieve_by_association() provides the possibility to follow


an association and read the target instance keys or data:

iv_node: Node key of the associations source node.

Iv_association: Key of the association, which shall be followed.

it_key: Table of keys of node instances for which instances of the associations should be
used to get their corresponding target instance keys.
iv_filled_key: If it is true, then ET_DATA is exported and contains the instance data
(typed as the combined table structure of the target node of that association)

et_key_link: A table of pairs (source node instance, target node instance)

et_target_key: A table of keys from instances

SAP 2010 / Page 9

Example of Retrieve_By_Assocation()

BO Instance
(Test Shell)

BO Model
(CONF UI)

Input Parameter

IV_NODE

IV_ASSOCIATION

8003BAE58F691DEB9688BEFD50A1D616
8003BAE58F691DEB9688BF02187490BF

IT_KEY

00000000000102DC9BAE8CE2DD7D01B5

00000000000102DC9BAE8CF600FB01D1

Output Parameter

SAP 2010 / Page 10

ET_TARGET

00000000000102DC9BAFC085F3AA808B

00000000000102DC9BAFC0EFD63940AA

00000000000102DC9BAFCA210B88410F

00000000000102DC9BAFC9AA6DC2C0F3

ET_KEY_LINK

Sources:

Targets:

(00000000000102DC9BAE8CE2DD7D01B5, 00000000000102DC9BAFC085F3AA808B)

(00000000000102DC9BAE8CE2DD7D01B5, 00000000000102DC9BAFC0EFD63940AA)

(00000000000102DC9BAE8CE2DD7D01B5, 00000000000102DC9BAFCA210B88410F)

(00000000000102DC9BAE8CF600FB01D1, 00000000000102DC9BAFC9AA6DC2C0F3)

Agenda

1.

Introduction

2.

Accessing Node Instance Data


1.
2.

Reading Node Instance Data


Writing Node Instance Data

3.

Message Concept

4.

BOPF Performance Guideline

SAP 2010 / Page 11

/BOPF/IF_FRW_MODIFY Interface Methods

SAP 2010 / Page 12

Writing Node Instance Data with update()

io_modify->update(
EXPORTING
iv_node
= if_bopf_customer_invoice_19_c=>sc_node-item
iv_key
= ls_item_data->key
is_data
= ls_item_data ).

IF_FRW_MODIFY~>update() provides the possibility to modify instance data in the


buffer. Some of its important parameters are listed below:

iv_node: Specified the business object node for which data shall be updated. In this
example we want to update the data from node ITEM.
iv_key: Key of the instance to be updated
is_data: Reference to the data the instance shall be updated with. Reference has to point to
a variable typed with the combined structure type of the node.

SAP 2010 / Page 13

Example of Updating Node Instances

DATA: ls_item_data TYPE REF TO bopf_s_ci_item_19,

io_modify->update(
EXPORTING
iv_node = if_bopf_customer_invoice_19_c=>sc_node-item
iv_key = ls_item_data->key
is_data = ls_item_data ).

Model key of the ITEM node of


the BO customer_invoice_19
Key of the instance of the
ITEM node, which data is
desired to update.
Reference to a structure from
the type of the nodes
combined datatype, which
shall be written.

SAP 2010 / Page 14

Agenda

1.

Introduction

2.

Accessing Node Instance Data


1.
2.

Reading Node Instance Data


Writing Node Instance Data

3.

BOPF Message Concept

4.

BOPF Performance Guideline

SAP 2010 / Page 15

BOPF Message Concept

/BOPF/CM_FRW

CM_SCM_XYZ

CM_BOPF_TRAINING

Message Concept based on class-based Messages (CM-Classes)

Each message class should inherit from /BOPF/CM_FRW

SAP 2010 / Page 16

Instantiation of an BOPF Message Object

create object LM_...


exporting
TEXTID
SEVERITY
SYMPTOM
LIFETIME

MS_ORIGIN_LOCATION

MV_CURRENCY_CODE

SAP 2010 / Page 17

Key for identifying message text

Severity of that message (e.g. Error, Warning)


Needed to automatically determine how to
deal with the messages
Lifetime (State or Transition) can be
automatically set by BOPF

Key of the entity, which is affected by the message

Application specific attributes used in the


messages

Example of Message Creation

" 1. Clear message object at the beginning of the method implementation


METHOD /BOPF/IF_FRW_VALIDATION~EXECUTE.
CLEAR: et_failed_key, eo_message.
DATA:
ls_location
TYPE /bopf/s_frw_location,
lo_bopf_training
TYPE REF TO cm_bopf_training.

" 2. If there is a problem, create a new message


CREATE OBJECT lo_bopf_training
EXPORTING
textid
= CM_BOPF_TRAINING=>INVALID_CURRENCY
severity
= cm_bopf_training=>co_severity_info
lifetime
= /BOPF/IF_FRW_C=>SC_LIFETIME_SET_BY_BOPF
symptom
= if_esi_message_symptoms=>co_bo_inconsistency
ms_origin_location
= ls_location
mv_currency_code
= ls_item_data->currency_code.

" 3. Get message container or create one (but only, if it wasnt done before!)
IF eo_message IS NOT BOUND.
CALL METHOD /bopf/cl_frw_factory=>get_message
RECEIVING
eo_message
= eo_message.
ENDIF.

" 4. Add message to the message container


eo_message->add_cm( lo_bopf_training ).

SAP 2010 / Page 18

Agenda

1.

Introduction

2.

Accessing Node Instance Data


1.
2.

Reading Node Instance Data


Writing Node Instance Data

3.

BOPF Message Concept

4.

BOPF Performance Guideline

SAP 2010 / Page 19

BOPF Performance Guideline

The BOPF Performance Guideline contains hints, how you can speed up your
business object implementations

https://wiki.wdf.sap.corp/display/BOPF/BOPF+Performance+Guideline

Example

One io_read->retrieve() call for all keys before loops, instead of placing it into the loop
LOOP AT it_key INTO ls_key.
CLEAR lt_key.
APPEND ls_key TO lt_key.
io_read->retrieve(
EXPORTING it_key = lt_key
IMPORTING et_data = lt_node ).
...
ENDLOOP.

io_read->retrieve(
EXPORTING it_key = it_key
IMPORTING et_data = lt_node ).
LOOP AT lt_node INTO ls_node.
...
ENDLOOP.

In contradistinction, there is no performance impact if io_modfiy calls are done inside


loops, due to the not mass-enabled signatures. The framework takes care of queuing the
modifications and flushes the modification at once.

SAP 2010 / Page 20

Questions?

Thank you!

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 Vervielfltigung dieser Publikation oder von Teilen daraus sind, zu welchem Zweck und in welcher Form auch immer, ohne die ausdrckliche schriftliche Genehmigung durch
SAP AG nicht gestattet. In dieser Publikation enthaltene Informationen knnen ohne vorherige Ankndigung gendert werden.
Einige von der SAP AG und deren Vertriebspartnern vertriebene Softwareprodukte knnen 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 erwhnte SAP-Produkte und Services
sowie die dazugehrigen Logos sind Marken oder eingetragene Marken der SAP AG in Deutschland und in mehreren anderen Lndern weltweit. Alle anderen in diesem Dokument erwhnten
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 knnen lnderspezifische 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 enthlt nur vorgesehene Strategien, Entwicklungen und Funktionen des SAP-Produkts und ist fr SAP nicht bindend, einen bestimmten
Geschftsweg, eine Produktstrategie bzw. -entwicklung einzuschlagen. SAP bernimmt keine Verantwortung fr Fehler oder Auslassungen in diesen Materialien. SAP garantiert nicht die
Richtigkeit oder Vollstndigkeit der Informationen, Texte, Grafiken, Links oder anderer in diesen Materialien enthaltenen Elemente. Diese Publikation wird ohne jegliche Gewhr, weder
ausdrcklich noch stillschweigend, bereitgestellt. Dies gilt u. a., aber nicht ausschlielich, hinsichtlich der Gewhrleistung der Marktgngigkeit und der Eignung fr einen bestimmten Zweck
sowie fr die Gewhrleistung der Nichtverletzung geltenden Rechts.
SAP bernimmt keine Haftung fr Schden jeglicher Art, einschlielich und ohne Einschrnkung fr direkte, spezielle, indirekte oder Folgeschden im Zusammenhang mit der Verwendung
dieser Unterlagen. Diese Einschrnkung gilt nicht bei Vorsatz oder grober Fahrlssigkeit.
Die gesetzliche Haftung bei Personenschden oder die Produkthaftung bleibt unberhrt. Die Informationen, auf die Sie mglicherweise ber die in diesem Material enthaltenen Hotlinks
zugreifen, unterliegen nicht dem Einfluss von SAP, und SAP untersttzt nicht die Nutzung von Internetseiten Dritter durch Sie und gibt keinerlei Gewhrleistungen oder Zusagen ber
Internetseiten Dritter ab.
Alle Rechte vorbehalten.

SAP 2007 / Page 23

You might also like