0% found this document useful (0 votes)
133 views

Getting Started With BOPF in Eclipse

Uploaded by

Ron Dijkstra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views

Getting Started With BOPF in Eclipse

Uploaded by

Ron Dijkstra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Getting Started with Business Object Processing

Framework in Eclipse

Summary
This tutorial aims to provide you with the basic knowledge
required for creating and testing a BOPF Business Object in
Eclipse. The resulting Business Object will consist of two
nodes and a simple piece of business logic, represented by
an action.

Level of complexity: Beginner


Time required for completion: 30 minutes

Author: Panneer Selvam


Company: SAP AG
Created on: 29 April 2014
Getting Started with Business Object Processing Framework in Eclipse

TABLE OF CONTENTS
BEFORE YOU START ................................................................................................................................ 3
Objectives .................................................................................................................................................. 3
Prerequisites .............................................................................................................................................. 3
Systems, Releases, and Authorizations ....................................................................................................... 3
Knowledge................................................................................................................................................... 3
CREATE A BUSINESS OBJECT ................................................................................................................ 4
Procedure................................................................................................................................................... 4
Launch the ABAP in Eclipse (AiE) IDE ......................................................................................................... 4
Create an ABAP project to the backend system ........................................................................................... 4
Start the Business Object Creation Wizard ................................................................................................... 4
Define Business Object Name and Description ............................................................................................ 5
Define the Root Node .................................................................................................................................. 5
Selection of Transport Request .................................................................................................................... 7
Result ........................................................................................................................................................10
ADD A SUBNODE......................................................................................................................................10
Prerequisites .............................................................................................................................................10
Procedure..................................................................................................................................................10
Start Node Creation Wizard ........................................................................................................................10
Create sub node .........................................................................................................................................11
Result ........................................................................................................................................................11
ADD AND IMPLEMENT AN ACTION .........................................................................................................13
Prerequisites .............................................................................................................................................13
Procedure..................................................................................................................................................14
Start Action Creation Wizard .......................................................................................................................14
Define the Implementing Class ....................................................................................................................14
Finishing the wizard ....................................................................................................................................15
Implement the Action ..................................................................................................................................15
Result ........................................................................................................................................................16
TEST THE BUSINESS OBJECT ................................................................................................................16
Prerequisites .............................................................................................................................................16
Procedure..................................................................................................................................................16
Start Business Object Test Environment .....................................................................................................16
Create, Save and Query Node Instances ....................................................................................................18
Execute the Action ......................................................................................................................................20
Result ........................................................................................................................................................21

2
Getting Started with Business Object Processing Framework in Eclipse

BEFORE YOU START

Objectives

By the end of this Getting Started document you will be able to


Create a business object, including the root node
Create a subnode
Create an action
Implement a simple action based on the BOPF API
Test the functions of the new business object

Fig. 1: Structure of the Business Object to be created

Prerequisites

Before you perform this tutorial, make sure the following prerequisites are fulfilled.

Systems, Releases, and Authorizations

BOPF in Eclipse is part of the Business Suite Foundation Layer and, therefore, included in the following
SAP Business Suite releases:
SAP Business Suite EHP7, SP04
To create a Business Object, your SAP user requires the developer authorization profile (S_DEVELOP
authorization object).
ABAP in Eclipse IDE(The minimum version required is 2.24) is installed

Knowledge

Basic knowledge in ABAP OO


Experience with DDIC tools.

3
Getting Started with Business Object Processing Framework in Eclipse

CREATE A BUSINESS OBJECT

In this step, you will create a sample Business Object (BO) “SALES_QUOTE”. This Business Object follows
the semantics of the sales quote based on the NetWeaver Enterprise Procurement Model (EPM).

Procedure

Launch the ABAP in Eclipse (AiE) IDE

ABAP in Eclipse IDE provides the design time for creation of custom business objects

Fig. 2: Welcome page of the ABAP in Eclipse IDE

Create an ABAP project to the backend system

1. Select "File > New > Project..." from the menu


2. In the creation wizard, select "ABAP Project"
3. Click Browse button and select a backend system (The system list is taken from SAPLogon, hence it
is necessary to add the system first into that list)
4. Provide the Logon details to this system and press Finish
5. The new project is now visible in the project explorer. Add any favorite package using the context
menu “Add a package…” in the “Favorite Packages” folder.

Start the Business Object Creation Wizard

Right click the Package in which the Business object has to be created. Select the option “New”->”Other
ABAP Repository Object”. Select BOPF Business Object from the dialog. New Business Object creation
wizard is started.

4
Getting Started with Business Object Processing Framework in Eclipse

Define Business Object Name and Description

In the first step you have to provide a name and description to the Business Object. The name should
contain either a registered namespace and/or a prefix. The project namespace will be used as a prefix not
only for the BO name but also for all other artifacts that belong to a BO.

.
Fig. 3. Editing the name and the description for the BO

In the input fields Name and Description you provide the name describing the semantics of the new BO and
a short text, respectively.

By default, the Package field is prefilled the package name from where the wizard is opened. Go to the next
wizard step by choosing Next.

Define the Root Node

The data model of a BO is represented as a hierarchical tree of nodes. The business object has exactly one
root node that, in turn, can have multiple subnodes. Each subnode again can have subnodes, and so on.

In this step you specify the ROOT node details of the BO. A short text for ROOT node can be provided.

5
Getting Started with Business Object Processing Framework in Eclipse

Fig. 4: Specifying the root node of the business object

A node consists of several attributes that are represented at the technical level by a Persistent and a
Transient Structure. The Persistent Structure defines the attributes that are stored in the database whereas
the attributes of the Transient Structure are calculated at runtime. Both structures are implemented as
regular DDIC structures and are created in the DDIC transaction SE11. For our demo, we want to work with
persistent node attributes only. Therefore we select Suggest Name to get a meaningful name for the
Persistent Structure.

Go to the next wizard step by choosing Next.

6
Getting Started with Business Object Processing Framework in Eclipse

Selection of Transport Request

If you had chosen the package $TMP, then you don’t have to select any transport request. For non-local
packages, select the appropriate transport request.

Fig. 4: Selection of Transport Request

To finish the BO creation, choose Finish. Several artifacts will now be generated in the background:
The BO configuration
The Constants Interface for the BO
Initial name is proposed for Combined Structure, Combined Table Type, and Database Table of the
ROOT node. These entities are generated at activation.
Select_All and Select_By_Elements Queries are added in the ROOT node

The BO editor will now be opened. The BO is initially in INACTIVE state.

7
Getting Started with Business Object Processing Framework in Eclipse

Fig. 6: BO with ROOT node and SELECT_ALL & SELECT_BY_ELEMENTS queries in editor view

Click on the Go to the ROOT node link. The ROOT node overview page will open.

Fig. 7: ROOT node overview page

8
Getting Started with Business Object Processing Framework in Eclipse

By clicking New button of the persistent structure you reach the DDIC transaction in a separate screen inside
Eclipse. There you define all the node attributes as you would do it for any other standard DDIC structure.
For our sales quote demo BO we define the following fields:
QUOTE_ID (/BOBF/S_SEPM_K_SOQ_ID or CHAR, Length 10)
QUOTE_STATUS (/BOBF/SEPM_SQ_STATUS or CHAR, Length 2)

Fig. 8: Creating a persistent structure in the ABAP Dictionary

After selecting an enhancement category for the structure (which is not relevant for our demo) and activating
it, we can go back to the Eclipse editor.

Now perform CHECK by clicking on the check button in the toolbar. Alternatively you can press Ctrl+F2

Fig. 9: CHECK of Business Object

If there is any problem with the BO model, the errors will be displayed in the Problems view. Otherwise the
you will get an information that ZD_SALES_QUOTE contains no errors

Fig. 10: Problems view

Activate the BO by clicking on the activate button in the toolbar. Alternatively you can press Ctrl+F3.

Fig. 11: Activation of Business Object

9
Getting Started with Business Object Processing Framework in Eclipse

Result

You are now finished. The created business object is now in ACTIVE state. You would be able to change or
delete the configuration, or even add further elements -- for instance, a sub node to the BO.

At this point, the new BO is already enabled to perform some generic operations such as create, read, and
update (CRUD) operations with the help of the generic services of BOPF. So that you can access persisted
root node data, the system has also generated Queries called SELECT_ALL and SELECT_BY_ELEMENTS.

ADD A SUBNODE

In the second step, we want to enhance the BO structure by adding a sub node to the already existing root
node.

Prerequisites

The created BO is opened in Eclipse.

Procedure

Start Node Creation Wizard

Go to the Nodes page of the Business Object. Click NEW to open the Node Creation Wizard.

Fig. 12: Nodes Table of Business Object

10
Getting Started with Business Object Processing Framework in Eclipse

Create sub node

Perform the wizard steps for a new sub node called ITEM, as described above for creating the root node.
The Persistent Structure name is suggested with ZDS_ITEM_D.

Fig. 13: New Node Creation Wizard

Result

You have created a sub node to the root node. By default, sub nodes have a cardinality of 0..n, which means
- for our example - that one root node instance can have zero or many ITEM node instances.

11
Getting Started with Business Object Processing Framework in Eclipse

Fig. 14: Nodes Table with ITEM node

In the nodes table, Ctrl+Click on the ITEM node name to go the overview page of the node.

Fig. 15: ITEM node overview page

12
Getting Started with Business Object Processing Framework in Eclipse

In the overview page, click on the NEW button next to the persistent structure to create the structure in the
DDIC

Create the structure with the following fields like you did for ROOT node.
ITEM_POS (CHAR, Length 10)
PRODUCT_ID (SNWD_PRODUCT_ID)
QUANTITY (INT4)
QUANTITY_UNIT (CHAR, Length 3)

Fig. 16: Creating a persistent structure for ITEM node in the ABAP Dictionary

After activating the DDIC structure, go back to the BO editor. You can now CHECK and ACTIVATE the
Business object

Let’s go to the next task where we want to implement some business logic.

ADD AND IMPLEMENT AN ACTION

BOPF knows several entities that can be used to define a specific behavior on the business object. An action
is one of these entities, describing an operation on a certain node. With the new action we want to set the
value of the QUOTE_STATUS attribute of the root node.

Prerequisites

The created BO is opened in the Eclipse. Navigate to ROOT node and go to Actions page

13
Getting Started with Business Object Processing Framework in Eclipse

Fig. 17: Actions Table in ROOT node

Procedure

Start Action Creation Wizard

Click the NEW… button in the Actions page to open Action Creation Wizard. You have to provide the action
name and you can define a short description.

The target of our action will be to set the value of the QUOTE_STATUS to ‘published’ in order to indicate that
the sales quote was created and sent to the business partner. Thus we name the Action PUBLISH.

Define the Implementing Class

At runtime, an action is represented by an ABAP class, implementing a certain interface. In this step you are
able to define the name of that class. In addition you have to select the Action Cardinality. This setting
indicates how many node instances the action can operate on. Due to performance reasons, we recommend
that action implementations should always be designed for running on multiple instances instead of single
instance only. To provide additional importing parameters for an action implementation, you have the option
to specify a parameter structure for this action.

You can either retain the class name proposed by the system or change the name. For this demo we won’t
change the proposed name and Action Cardinality settings.

14
Getting Started with Business Object Processing Framework in Eclipse

Fig. 58: New Action in ROOT node

Finishing the wizard

Finish the action creation by choosing Finish. Now activate the BO. After activation, the system generates
the implementing class of the action.

Implement the Action

The new action is now visible in the Actions table. Ctrl+Click on the name of the Implementation Class to
navigate to the Class editor in Eclipse. Open the empty implementation of method
/BOBF/IF_FRW_ACTION~EXECUTE and provide the following source code.

METHOD /bobf/if_frw_action~execute.
DATA lr_root TYPE REF TO zds_root. " Combined structure
DATA lt_changed_fields TYPE /bobf/t_frw_name.
DATA ls_key TYPE /bobf/s_frw_key.

" Prepare update information


CREATE DATA lr_root.
lr_root->quote_status = 'P'. "Published
APPEND zif_d_sales_quote_c=>sc_node_attribute-root-quote_status TO lt_changed_fields.

" Do update
LOOP AT it_key INTO ls_key.
io_modify->update(
EXPORTING
iv_node = zif_d_sales_quote_c=>sc_node-root
iv_key = ls_key-key
is_data = lr_root
it_changed_fields = lt_changed_fields ).

15
Getting Started with Business Object Processing Framework in Eclipse

ENDLOOP.
ENDMETHOD.

As a first step, we prepare the update information where we describe what should be changed in the affected
node instances. We create a data reference for the nodes combined table type and set the attribute
QUOTE_STATUS to ‘P’. This is the indicator that the node instance is set to status “Published”. In addition,
we populate the internal table LT_CHANGED_ATTRIBUTES to describe which attribute should be updated.
Like all other entity names, the attribute name, too, is available through the Constants Interface of the BO.
(Remember that you have to use the specific Constants Interface of your business object that you created in
the first task).

Next, the content of the importing parameter IT_KEY is processed within a LOOP. IT_KEY contains the keys
of all node instances that should be processed by the action. For each node instance we call the method
UPDATE from the Internal Access Object IO_MODIFY.

Note that there are also other variants of the implementation possible but for this demo I have tried to keep
things simple and easy to understand.

Activate your code and navigate back to the BO editor.

Result

You are now finished with the implementation of the first business logic. Let’s go to our last task, where we
want to test our business object.

TEST THE BUSINESS OBJECT

To test the functions of a Business Object, you can use the transaction Business Object Test Environment
(BOBT) inside Eclipse.

Prerequisites

You have completed task 1 (Create a Business Object) and task 2 (Add an Action).

Procedure

Start Business Object Test Environment

In the Project Explorer view of Eclipse, choose the Business Object ZD_SALES_QUOTE. Right click on this
BO and choose RunAs->Test Environment

16
Getting Started with Business Object Processing Framework in Eclipse

Fig. 19: Launching Test Environment BOBT

Fig. 20: Transaction BOBT inside Eclipse

17
Getting Started with Business Object Processing Framework in Eclipse

A new editor is opened inside eclipse showing the BO in transaction BOBT. BOBT is a generic test tool that
allows you to perform any function of your Business Object without writing code. By default, BOBT consists
of three panes:
Node Instance pane: Showing all node instances of the BO in a tree along the node structure
Node Instance Table pane: Showing all node instance of a particular node
Node Instance Editor pane: Shows the details of a particular node instance

Create, Save and Query Node Instances

In the Node Instance Table pane, select Add Node Instance from the toolbar.

Fig. 21: Create ROOT node instance

An empty ROOT node instance appears in the Node Instance Table pane and the Node Instance Editor
pane, allowing you to change the attributes by just entering values.

18
Getting Started with Business Object Processing Framework in Eclipse

Fig. 22: Created ROOT node instance

Navigate to the ITEM node by selecting the ITEM association from the Association button.

Fig.23: Navigate to ITEM node instance

The node Instance Table pane now shows the ITEM instances that are assigned to the ROOT node instance
that we have created before. Select Add Node Instance from the toolbar two times in order to create two
ITEM node instances. Enter some values as you did before for the ROOT node instance.

Fig.24: Created ITEM node instances

Finally you can save your BO data by choosing Save from the SAP toolbar. The data is saved to the
database table that is assigned to the nodes.

Fig. 25: Save BO instances

19
Getting Started with Business Object Processing Framework in Eclipse

You can remove the data from the transaction and the tool BOBT by choosing Clear Transaction from the
toolbar of the Node Instance pane.

Fig. 26: Save BO instances

In our last step, let’s read the data created from the database. Select the Search button right next to the BO
name. Choose the button Load Node Instances and select the entry By Query and ROOT –
SELECT_ALL. All ROOT node instances are loaded into the transaction and visible again in BOBT.

Execute the Action

As a final step, select the create node instance in the Node Instance Table pane and execute the action by
choosing PUBLISH in the application toolbar.

Fig. 27: Resulting ROOT node instance after action execution

As a result, you should see an update on the QUOTE_STATUS attribute in accordance with the action you
implemented in the previous step.

20
Getting Started with Business Object Processing Framework in Eclipse

Result

Within a few minutes we have verified that we have implemented the action correctly, without writing any test
code. Of course, this does not replace an automated test, but with the help of the Business Object Test
Environment you get direct feedback as to whether your Business Object works correctly or not.

We have now gone through the fundamentals of creating and testing a Business Object using Eclipse. I hope
you are motivated to try out more things with BOPF in Eclipse, as there is much more that can be
discovered. Stay tuned for further articles BOPF in Eclipse.

21
www.sap.com

© 2014 SAP AG. All rights reserved.

SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP


BusinessObjects Explorer, 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
and other countries.

Business Objects and the Business Objects logo, BusinessObjects,


Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and
other Business Objects products and services mentioned herein as
well as their respective logos are trademarks or registered trademarks
of Business Objects Software Ltd. Business Objects is an SAP
company.

Sybase and Adaptive Server, iAnywhere, Sybase 365, SQL


Anywhere, and other Sybase products and services mentioned herein
as well as their respective logos are trademarks or registered
trademarks of Sybase Inc. Sybase is an SAP company.

Crossgate, m@gic EDDY, B2B 360°, and B2B 360° Services are
registered trademarks of Crossgate AG in Germany and other
countries. Crossgate is an SAP company.

All other product and service names mentioned are the trademarks of
their respective companies. Data contained in this document serves
informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials


are provided by SAP AG and its affiliated companies ("SAP Group")
for informational purposes only, without representation or warranty of
any kind, and SAP Group shall not be liable for errors or omissions
with respect to the materials. The only warranties for SAP Group
products and services are those that are set forth in the express
warranty statements accompanying such products and services, if
any. Nothing herein should be construed as constituting an additional
warranty.

You might also like