23
BOPF Basic Training 03 Implementation of BOPF Entities ByDesign BOPF

BOPF Basic Training - 03 Implementation of BOPF Entities

Embed Size (px)

Citation preview

Page 1: BOPF Basic Training - 03 Implementation of BOPF Entities

BOPF Basic Training

03 Implementation of BOPF Entities

ByDesign BOPF

Page 2: BOPF Basic Training - 03 Implementation of BOPF Entities

© SAP 2010 / Page 2

Agenda

1. Introduction

2. Accessing Node Instance Data1. Reading Node Instance Data

2. Writing Node Instance Data

3. Message Concept

4. BOPF Performance Guideline

Page 3: BOPF Basic Training - 03 Implementation of BOPF Entities

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

Page 4: BOPF Basic Training - 03 Implementation of BOPF Entities

Introduction

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.

An instance of the class

of the called action is

instantiated and their

“execute”-method

executed by the BOPF.

© SAP 2010 / Page 4

Page 5: BOPF Basic Training - 03 Implementation of BOPF Entities

Agenda

© SAP 2010 / Page 5

1. Introduction

2. Accessing Node Instance Data1. Reading Node Instance Data

2. Writing Node Instance Data

3. Message Concept

4. BOPF Performance Guideline

Page 6: BOPF Basic Training - 03 Implementation of BOPF Entities

/BOPF/IF_FRW_READ Interface Methods

© SAP 2010 / Page 6

Page 7: BOPF Basic Training - 03 Implementation of BOPF Entities

Reading Data with „Retrieve()“

„/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.

io_read->retrieve(

EXPORTING

iv_node = if_bopf_customer_invoice_19_c=>sc_node-item

it_key = it_key

IMPORTING

et_data = lt_item_data ).

© SAP 2010 / Page 7

Page 8: BOPF Basic Training - 03 Implementation of BOPF Entities

Example of „Retrieve()“

Input Parameter IV_NODE

8003BAE58F691DEB9688BEFD50A1D616

IT_KEY

00000000000102DC9BAFC085F3AA808B

00000000000102DC9BAFC0EFD63940AA

00000000000102DC9BAFCA210B88410F

BO Model

(CONF UI)

BO Instance

(Test Shell)

Output Parameter

Table of combined structure of the node item with 3

lines, one for each of the Item instances.

© SAP 2010 / Page 8

Page 9: BOPF Basic Training - 03 Implementation of BOPF Entities

Reading Data with „Retrieve_By_Association()“

„/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 association‟s 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

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 ).

© SAP 2010 / Page 9

Page 10: BOPF Basic Training - 03 Implementation of BOPF Entities

Example of „Retrieve_By_Assocation()“

Input Parameter IV_NODE

8003BAE58F691DEB9688BEFD50A1D616

IV_ASSOCIATION

8003BAE58F691DEB9688BF02187490BF

IT_KEY

00000000000102DC9BAE8CE2DD7D01B5

00000000000102DC9BAE8CF600FB01D1

Output Parameter ET_TARGET

00000000000102DC9BAFC085F3AA808B

00000000000102DC9BAFC0EFD63940AA

00000000000102DC9BAFCA210B88410F

00000000000102DC9BAFC9AA6DC2C0F3

ET_KEY_LINK Sources: Targets:

(00000000000102DC9BAE8CE2DD7D01B5, 00000000000102DC9BAFC085F3AA808B)

(00000000000102DC9BAE8CE2DD7D01B5, 00000000000102DC9BAFC0EFD63940AA)

(00000000000102DC9BAE8CE2DD7D01B5, 00000000000102DC9BAFCA210B88410F)

(00000000000102DC9BAE8CF600FB01D1, 00000000000102DC9BAFC9AA6DC2C0F3)

BO Model

(CONF UI)

BO Instance

(Test Shell)

© SAP 2010 / Page 10

Page 11: BOPF Basic Training - 03 Implementation of BOPF Entities

Agenda

1. Introduction

2. Accessing Node Instance Data1. Reading Node Instance Data

2. Writing Node Instance Data

3. Message Concept

4. BOPF Performance Guideline

© SAP 2010 / Page 11

Page 12: BOPF Basic Training - 03 Implementation of BOPF Entities

/BOPF/IF_FRW_MODIFY Interface Methods

© SAP 2010 / Page 12

Page 13: BOPF Basic Training - 03 Implementation of BOPF Entities

Writing Node Instance Data with „update()“

„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.

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 ).

© SAP 2010 / Page 13

Page 14: BOPF Basic Training - 03 Implementation of BOPF Entities

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 node„s

combined datatype, which

shall be written.

© SAP 2010 / Page 14

Page 15: BOPF Basic Training - 03 Implementation of BOPF Entities

Agenda

1. Introduction

2. Accessing Node Instance Data1. Reading Node Instance Data

2. Writing Node Instance Data

3. BOPF Message Concept

4. BOPF Performance Guideline

© SAP 2010 / Page 15

Page 16: BOPF Basic Training - 03 Implementation of BOPF Entities

BOPF Message Concept

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

Each message class should inherit from „/BOPF/CM_FRW“

/BOPF/CM_FRW

CM_SCM_XYZ … CM_BOPF_TRAINING

© SAP 2010 / Page 16

Page 17: BOPF Basic Training - 03 Implementation of BOPF Entities

Instantiation of an BOPF Message Object

create object LM_...

exporting

TEXTID

SEVERITY

SYMPTOM

LIFETIME

MS_ORIGIN_LOCATION

MV_CURRENCY_CODE

Needed to automatically determine how to

deal with the messages

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

Lifetime (State or Transition) can be

automatically set by BOPF

Key of the entity, which is affected by the message

Key for identifying message text

Application specific attributes used in the

messages

© SAP 2010 / Page 17

Page 18: BOPF Basic Training - 03 Implementation of BOPF Entities

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 wasn‘t 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

Page 19: BOPF Basic Training - 03 Implementation of BOPF Entities

Agenda

1. Introduction

2. Accessing Node Instance Data1. Reading Node Instance Data

2. Writing Node Instance Data

3. BOPF Message Concept

4. BOPF Performance Guideline

© SAP 2010 / Page 19

Page 20: BOPF Basic Training - 03 Implementation of BOPF Entities

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

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.

io_read->retrieve(

EXPORTING it_key = it_key

IMPORTING et_data = lt_node ).

LOOP AT lt_node INTO ls_node.

...

ENDLOOP.

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.

© SAP 2010 / Page 20

Page 21: BOPF Basic Training - 03 Implementation of BOPF Entities

Questions?

Page 22: BOPF Basic Training - 03 Implementation of BOPF Entities

Thank you!

Page 23: BOPF Basic Training - 03 Implementation of BOPF Entities

© SAP 2007 / Page 23

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.