Getting Started With BOPF in Eclipse
Getting Started With BOPF in Eclipse
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.
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
Objectives
Prerequisites
Before you perform this tutorial, make sure the following prerequisites are fulfilled.
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
3
Getting Started with Business Object Processing Framework in Eclipse
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
ABAP in Eclipse IDE provides the design time for creation of custom business objects
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
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.
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
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.
6
Getting Started with Business Object Processing Framework in Eclipse
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.
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
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.
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)
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
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
Activate the BO by clicking on the activate button in the toolbar. Alternatively you can press Ctrl+F3.
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
Procedure
Go to the Nodes page of the Business Object. Click NEW to open the Node Creation Wizard.
10
Getting Started with Business Object Processing Framework in Eclipse
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.
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
In the nodes table, Ctrl+Click on the ITEM node name to go the overview page of the node.
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.
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
Procedure
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.
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
Finish the action creation by choosing Finish. Now activate the BO. After activation, the system generates
the implementing class of 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.
" 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.
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.
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
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
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
In the Node Instance Table pane, select Add Node Instance from the toolbar.
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
Navigate to the ITEM node by selecting the ITEM association from the Association button.
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.
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.
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.
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.
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.
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
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.