Badi Enhancement Process
Badi Enhancement Process
Badi Enhancement Process
Example Words or characters quoted from the screen. These include field names, screen titles,
pushbuttons labels, menu names, menu paths, and menu options.
Textual cross-references to other documents.
EXAMPLE Technical names of system objects. These include report names, program names,
transaction codes, table names, and key concepts of a programming language when they
are surrounded by body text, for example, SELECT and INCLUDE.
Example Output on the screen. This includes file and directory names and their paths, messages,
names of variables and parameters, source text, and names of installation, upgrade and
database tools.
Example Exact user entry. These are words or characters that you enter in the system exactly as
they appear in the documentation.
<Example> Variable user entry. Angle brackets indicate that you replace these words and characters
with appropriate entries to make entries in the system.
Caution
Before you start the implementation, make sure that you have the latest version of this document
relevant for your release. You can always find the latest version on the SAP Help Portal at
http://help.sap.com/pobuilder.
1 Preface ................................................................................................................................ 6
1.4 Disclaimer.................................................................................................................................................. 7
2 Introduction ........................................................................................................................ 8
References ............................................................................................................................. 45
This guide explains how process object types (POTs) built with SAP Process Object Builder (POB) can be
enhanced by customers and partners. It also explains what aspects have to be addressed when developing POTs
that should be enhanceable.
This guide does not cover enhancements that require changes to a POT configuration, including:
New Details, Private Details, or Process Control Constraints (PCCs)
Introduction of new node types
Consumption of other back-end services than the already consumed ones
Customers and partners who want to extend POTs developed by SAP or other partners
Development teams who implement POTs that should allow for later enhancements
All referenced documents are listed in the References section of this guide.
This guide assumes that you have read the following documents:
Product documentation and developer's guide for SAP Process Object Builder
Instructions on how to enhance enterprise services in the Enterprise Services Enhancement Guide
The processes described in this guide are used as examples and merely serve to illustrate specific aspects of
process object types from a learning perspective. No claims are made as to the business validity of these sample
business processes. SAP assumes no responsibility for errors or omissions in this document.
Customers and partners may want to enhance a process object type for the following reasons:
To implement additional checks in the Check phase via BAdI
To add additional fields to existing Details, Private Details, and Process Control Constraints (PCCs)
To use additional fields of a (possibly enhanced) back-end service that is consumed by the POT
To fill the back-end service requests with different (default) values in the code slots
To display additional fields of the POT in the Editing UI
To use additional fields of the POT in the Archive Search UI
Note
In the context of this guide enhancement of a structure (ESR or DDIC data type) means adding an
additional, optional field at the end of this structure.
For details on the concept of enhancements in the context of enterprise services refer to the Enterprise
Services Enhancement Guide [ES].
The sample business process used in this guide is the same as in the POT Developer's Guide [DEV]. A company
employee needs to go on a business trip. To do so, the employee needs to book a flight ticket and up to two
shuttle transfers, one from his/her home address to the airport of departure, and another one from the airport of
arrival to the destination address.
Home Destination
Home Destination
Airport Airport
Figure 2-1: Sample Business Process – Travel Booking
In the context of this guide this process is enhanced by the possibility to request a VIP shuttle transfer. In chapter
3 we explain how the shuttle booking service has been extended by an additional field. This service serves as an
example of a standard service that has been enhanced by a customer. Chapter 4 describes what has to be done
by a POT developer to enable later enhancements of a POT. How the sample POT can be enhanced to incorporate
the optional VIP transfer is described in chapter 5.
The Enterprise Services Enhancement Guide [ES] lists the following reasons (amongst others) why a customer
may want to enhance an enterprise service:
Customers or partners have enhanced SAP‘s business functionality and want to offer additional elements in
existing services
A standard service does not expose all fields of a business object and additional fields are required in the
service signature
This document only gives a brief summary of the required steps in order to explain the enhancement of POTs later
on. For details on how to enhance enterprise services see the Enterprise Services Enhancement Guide [ES].
Figure 3-1 provides an overview of all steps that are required to enhance an enterprise service:
This chapter describes how we enhanced the shuttle booking service in the Enterprise Services Repository (ESR)
in order to motivate the enhancement of the sample POT in chapter 5.
The shuttle booking service is an asynchronous service. The request and the response message types are
displayed below:
Exemplarily, we enhanced the service signature with an indicator to request a VIP transfer. The enhanced data
types for the request and for the response are displayed below, with the enhancements being highlighted in
yellow:
Figure 3-5: Data Type for Business Object with Enhancement (Response)
The following tables show which code slots should be considered when making a POT enhanceable and which
enhancement spots and BAdIs should be created for which situation. Details will be described in the following
subchapters. Details about BAdIs that are generated as part of the POT generation can be found in the Application
Help [POB].
Create Phase Custom Enhancement Spot for One BAdI per service
BPON Phase Implementations operation and
request/response
Execute Phase Custom Enhancement Spot for One BAdI per service
BPON Phase Implementations operation and
request/response
Post Process Confirmation Custom Enhancement Spot for One BAdI per asynchronous
BPON Phase Implementations inbound service operation
4.1.2 Archiving
Archiving Write Report Custom Enhancement Spot for No BAdI but Enhancement
Archiving Sections
Archiving UI Search Result Custom Enhancement Spot for BAdI for Archiving UI
Archiving
Archiving Get Field Values Enhancement Spot for Archiving BAdI for additional fields for
residence time determination
Archiving Register Fields Enhancement Spot for Archiving BAdI for additional fields for
residence time determination
4.1.3 Editing UI
Mappings for Search and Search Custom Enhancement Spot BAdI for Editing UI
Result for Editing UI Search
Mappings for List and Form Feeders Custom Enhancement Spot One BAdI per Feeder
for Editing UI Class
GET_DATA
PROCESS_EVENT
SET_BUTTON_PARAMETER
4.1.4 Others
When creating a BAdI there are two important settings that you have to make:
Usability: Select Multiple Use
Instance Creation Mode: Select Newly Creating Instantiation
Usually, the guide suggests names for enhancement spots and BAdI definitions that you have to create. You can
choose different names if you like. However, always adhere to the naming conventions for custom artifacts to
make sure that these artifacts are not overwritten by the builder:
Caution
Make sure to comply with the naming convention <MLB>*_C_* for custom artifacts, with _C_ denoting a
custom artifact, when creating enhancement spots, BAdIs, class attributes etc.
For further details refer to the Developer's Guide [DEV], chapter 7.1 Custom Phase Implementation.
The enterprise services provided by a POT can be enhanced in the standard way (see chapter 3). You only have to
take care of the phase implementations of the POT:
1. Create an enhancement spot <MLB>_C_PIMPL_ENH for the phase implementation in the custom package
(<MLB>CUST) of the POT.
2. Create a BAdI definition and a corresponding interface for each node type. The interfaces should contain
methods for all back-end services of a node, one per phase and service call. For synchronous service calls
there should be one method per direction (request and response).
The following are examples for the method signatures of the BAdI methods.
Method signature for the request of a synchronous message:
Preconditions None
Exception X <MLB>CX_IM
Preconditions None
Exception X <MLB>CX_IM
Error! Reference source not found. contains naming suggestions for all artifacts concerned in the enhancement of
the phase implementations:
Instantiate the BAdIs in the INIT methods of the phase implementation classes (<MLB>CL_N_<NODE>_PIMPL):
In the code slots of the phase implementation classes insert a call to the corresponding BAdI methods before
(request) and after (response) each back-end service call.
Error! Reference source not found. shows the call of the BAdI method for the shuttle booking service in the code
slot of the Execute phase. As this service is an asynchronous one, the BAdI is only called before the back-end
service.
The enhancement options for archiving have to be covered by two enhancement spots, because two different
enhancement technologies come into play: ABAP source code enhancements and BAdIs. For details on both
technologies refer to [ENH].
The archiving write program can be made enhanceable to enable the possibility to enhance the selection by
provider IDs and / or reference IDs. Details about these possibilities in general can be found in [DEV].
To make the program enhanceable an enhancement spot and two enhancement sections have to be created (one
for each code slot). The enhancement spot can be created together with the first enhancement section.
The following example shows the steps to create an enhancement section for the selection screen of the archiving
write program:
1. Place the cursor inside the code slot and select Edit > Enhancement Operations > Create Option from the
menu.
2. Enter <MLB>_C_A_SELECTION as name for the enhancement section and <MLB>_C_A_ARCH_PROG_ENH as
name for the enhancement spot (it will be created if not yet existing). For Inclusion in Source Code select as
unconditional call.
Repeat the two steps to create another enhancement section <MLB>_C_A_MAPPING for the mapping code slot.
As described in [DEV] it is possible to define additional fields to determine the residence time based on any value
contained in the POT object model .For that a POT provides the class <MLB>CL_A_FVD_C with the two methods
GET_FIELD_VALUES and REGISTER_FIELDS.
Create a BAdI definition with the name <MLB>_C_A_FLDVAL. The BAdI should contain two methods with the same
name and the same signature as the methods of the mentioned class. In addition, you should add the data helper
(MR_DATA_HELPER of <MLB>CL_A_FVD_C) as importing parameter to the GET_FIELD_VALUES method. The
method should also raise the exception for archiving <MLB>CX_ARC.
The following examples show the BAdI calls in the code slots of the two methods:
The commented code is pre-generated into the code slots. Adapt it according to your requirements and insert the
BAdI calls at the indicated places.
The initialization of the instance variable MR_C_ARCH_FIELDS_BADI should be done in the INIT method of the
class.
To allow the enhancement of the archive search UI the code slots in class <MLB>CL_A_SEA_C should contain BAdI
calls that allow to adopt the standard mapping (see [DEV]).
Create a BAdI definition with the name <MLB>C_A_SEARCH. It should contain two methods with the same names
as the methods of the mentioned class:
MAP_SELECTION_TO_SEARCH
MAP_SEARCH_RESULT_TO_FEEDER
The initialization of the instance variable MR_C_ARCHIVE_SEARCH_BADI should be done in the INIT method of
the class.
The implementation of the Editing UI is described in detail in [DEV]. Based on the most common use cases the
following subchapters describe where enhancement options for the Editing UI should be implemented.
All BAdIs described here can be assigned to a single enhancement spot <MLB>_C_UI_ENH that is to be created in
the custom package (<MLB>CUST).
The custom feeder class for the search (<MLB>CL_FS_SBA_C) contains two code slot methods to map the feeder
data from the selection screen to the search structure (MAP_SELECTION_TO_SEARCH) and to map the search
result to the result feeder (MAP_SEARCH_RESULT_TO_FEEDER). To allow a customer to map fields in addition to
the fields provided by the standard implementation these two methods should be made enhanceable.
Create a BAdI with the name <MLB>_C_UI_SBA and a corresponding interface <MLB>IF_C_UI_SBA_BD within the
above mentioned enhancement spot. The BAdI should contain two methods that correspond to the methods of
the feeder class:
MAP_SELECTION_TO_SEARCH:
o The signature of the method should look similar to the signature of the method where it is called. A
changing parameter C_CUSTOM_SEARCH should be used instead of the returning parameter
R_CUSTOM_SEARCH.
MAP_SEARCH_RESULT_TO_FEEDER:
o The signature of the method should look like the signature of the method where it is called.
The BAdI methods should be called at the end of the corresponding code slot implementation.
The initialization of the instance variable MR_C_SEARCH_BADI should be done in the INIT method of the class:
A customer might want to add additional fields to a list or a form feeder of the Editing UI. Besides enhancing the
FPM UI configuration and the feeder structures he has to enhance the mappings "model to feeder" and "feeder to
model".
Every generated custom feeder class contains corresponding methods for each assignment of the feeder in the
object hierarchy. In each code slot within these methods a BAdI method has to be called.
1. Create a BAdI for each generated class using the following naming convention:
<MLB>_C_UI_<SUFFIX_OF_CORRESPONDING_FEEDER_WITHOUT_C>.
Examples (list feeder of Shuttle Booking node):
o Name of the feeder class: <MLB>CL_FL_SBOKL_C
o Name of the BAdI: <MLB>_C_UI_FL_SBOKL
o Name of the BAdI Interface: <MLB>IF_C_UI_FL_SBOKL_BD
2. In each BAdI interface create the same MAP_MODEL2FEEDER and MAP_FEEDER2MODEL methods as in the
corresponding feeder class. In the MAP_MODEL2FEEDER methods use a changing parameter C_FEEDER_DATA
instead of a returning parameter (R_FEEDER_DATA).
3. Call the BAdI at the end of the corresponding code slot.
The following examples are taken from the custom list feeder class (<MLB>CL_FL_SBOKL_C) of the Shuttle
Booking node:
The initialization of the instance variable MR_C_FEEDER_BADI should be done in the INITIALIZE method of the
feeder class.
In order to add new buttons to a UIBB a customer requires the possibility to define and handle new FPM actions.
To define a new action a BAdI method has to be called in method GET_DEFINITION of the feeder class. To change
an action (e.g. to disable it) a BAdI method has to be called in method GET_DATA. Finally, a BAdI method call is
required in method PROCESS_EVENT to handle the event.
Within the BAdIs for the feeder classes (see chapter 4.4.3) create the following methods:
GET_DEFINITION
GET_DATA
PROCESS_EVENT
The signatures of the methods should be exactly the same as for the corresponding methods in the feeder class.
Call the BAdI methods at the end of the corresponding code slot implementation.
The initialization of the instance variable MR_C_FEEDER_BADI should be done in the INITIALIZE method of the
feeder class.
The generated overview page of the Editing UI provides a standard set of buttons. A customer can add additional
buttons to the UIBB configuration. To implement the event handler for a button and to change its behavior during
runtime the following two methods of the custom application controller class <MLB>CL_FPM_ACC_C require a
BAdI method call. Create a BAdI with name <MLB>_C_UI_ACC and add the following methods to its interface:
HANDLE_EVENT:
The interface of the BAdI method should be similar to the interface of the corresponding application controller
method (including the exception).
SET_BUTTON_PARAMETER:
The interface of the BAdI method should be similar to the interface of the corresponding application controller
method (including the exception). However, use a changing parameter C_BUTTON_PARAMETER instead of the
returning parameter R_BUTTON_PARAMETER.
Call the BAdI methods at the end of the corresponding code slot implementation.
Note
Only actions with the prefixes PL1 (for generation actions) and CPL1 (for custom actions) are forwarded
to the custom application controller. Therefore define and document a naming convention for actions
defined as part of an enhancement. For example, you could use CPL1_Z as prefix for such actions.
The initialization of the instance variable MR_C_ACC_BADI should be done in the INIT method of the custom
controller class.
Caution
When you enhanced a POT and want to make changes to these enhancements after you used your POT
productively, keep in mind that the same rules as for changing the structure of a POT apply. In particular it
might not be possible to read old instances anymore.
When the POT developer has foreseen enhancements to the POT object model, these enhancements concern the
details of the root and child nodes (if details are available), the private details of the child nodes (if private details
are available), as well as the PCC of the root and child nodes (if PCC are available). Figure 5-1 shows the POT
object model template with possible enhancement options highlighted in yellow:
In step "Define Process Object Nodes" of the POB Modeling Wizard a POT developer can select for which nodes
(including the root node) a BAdI definition should be generated for the Check phase. If this was done for your POT
there will be an enhancement spot and a BAdI in the package <MLB>API for additional custom checks:
Enhancement spot: <MLB>ENH
BAdI definition: <MLB>CHK_BADI
BAdI interface:<MLB>IF_CHK_BADI
The BAdI interface contains one check method for each selected node.
A POT provides a BAdI for custom archivability checks. The enhancement spot and the BAdI can be found in the
API package <MLB>API:
Enhancement spot: <MLB>A_ENH
BAdI definition: <MLB>A_CHK
BAdI Interface: <MLB>IF_A_CHK_BD
The interface provides the method IS_ARCHIVABLE which is called per POT instance during the archiving run.
Within the implementation you can overrule the decision if an instance is archivable. However, you can only set
instances to not archivable which were set to archivable by the standard implementation. The implementation will
not be called for an instance that has been set to not archivable already by the standard implementation.
Apart from that the generated code for the POT archiving integration is not enhanceable. If your specific POT
provides additional BAdIs for enhancing the archiving write report, archiving search UI, or the additional fields for
residence time determination, you can enhance the functionality accordingly. Refer to the documentation of your
POT for further details.
5.1.4 Authorization
In step "Define Authorization Checks" of the POB Specification Wizard a POT developer can select to generate a
BAdI for custom authorization checks. If this was done for your POT you will find the following BAdI in the general
package <MLB>GENRL:
Enhancement spot: <MLB>ATH_ENH
BAdI definition: <MLB>ATH_CHK
BAdI interface: <MLB>IF_ATH_CHK_B
The interface contains the method CHECK_AUTHORIZATION:
Preconditions None
This method is called for every service call. If a user has no authorization an exception has to be thrown. With this
method the authorization checks of the standard can only be restricted further. So if the standard authorization
check fails the method will not be called.
5.1.5 Editing UI
The generated DDIC structures for the feeder classes are enhanceable. Apart from that, the generated code of the
Editing UI is not enhanceable as no BAdIs are generated to adopt the mapping between the UI model and the
feeder classes, to add new buttons to feeders or the overview page, or any other change of the UI behavior.
If your specific POT provides BAdIs for enhancing the Editing UI, you can enhance it accordingly. Refer to the
documentation of your POT for further details. For details on enhancing FPM configuration using the Application
Enhancement Tool (AET), please refer to [AET].
Caution
If you have the option to enhance the Editing UI of your specific POT and define actions for additional
buttons, make sure to adhere to the naming convention for additional actions described in the
documentation of your POT. Do not use the prefix PL1 as this prefix is reserved for the generated actions.
Enhancing a POT comprises similar steps as enhancing an enterprise service, because enhancing a POT first of all
means enhancing its services. Figure 5-2 depicts all steps that are required to enhance a POT. You might notice
that the diagram is very similar to the one showing the standard enhancement procedure for enterprise services
in chapter 3.2.
The steps highlighted in gray are considered a prerequisite and only the steps depicted in yellow will be described
in the following subsections.
The enhancement of a POT starts in the ESR. When you want to enhance the details of the process object itself,
you have to create an enhancement for the Details data type. When you want to enhance the details of a node, you
have to create an enhancement for the <Node>Details data type. Accordingly, when you want to enhance the
(<Node>)Process Control Constraints or <Node>PrivateDetails, you have to enhance the (<Node>)PCC or
<Node>PrivateDetails data type.
Table 2 contains the relationship between enhancements and corresponding data types:
Details <BPO><Version><Application>_BPO_Details
<Node>Details <BPO><Version><Application>_BPON_<Node>_Details
<Node>PrivateDetails <BPO><Version><Application>_BPON_<Node>_PrivateDetails
PCC <BPO><Version><Application>_BPO_PCC
<Node>PCC <BPO><Version><Application>_BPON_<Node>_PCC
In our example we enhance the details of the shuttle booking node. Figure 5-3 shows the corresponding data type
enhancement:
As a next step you have to generate the proxy structure for the enhancement using transaction SPROXY. After that
the enhancement is visible as an append structure of the enhanced proxy structure:
Internally, a POT uses so-called internal types instead of the generated proxy data types. Refer to chapter 7.4
Internal Types of the Developer's Guide for more details. Therefore, you also have to enhance the internal
equivalent of the enhanced proxy data type. The internal type is named like the proxy type with the proxy prefix
being replaced by the prefix for common internal types.
Caution
It is important that you give the components of the append structure exactly the same names as the
components of the enhancement proxy structure. Otherwise the mappings in the POT services do not
work.
In the example the name given by SPROXY is /PL9/FEXXVIPTRANSFER_INDICATOR. The same name is
used for the component of the internal type.
Figure 5-5 shows the internal types structure from our example together with its append structure:
Start transaction SPROXY, look up the enhanced proxy type and note down the proxy prefix (blue box in Figure
5-6):
Start transaction SE11, enter the name of the proxy type and replace the prefix with an asterisk (*). Press F4 and
select Search for Structures. You will get a list with two or three types that looks like the following:
In this case the type we are looking for is the first entry, because the second one is our enhancement and the third
one the proxy type we used for searching. In case you get more hits you can restrict the result by specifying a
package after pressing "New selection":
So far the additional data from the enhancement arrives in the code slots of the phase implementation classes.
Now you have to implement one or more BAdIs to map this data to the request types of the concerned back-end
services. To do so, create an enhancement implementation, a BAdI implementation and a corresponding BAdI
implementation class. For details on BAdI implementations refer to [BADI]. Then implement the required BAdI
methods and map the additional fields.
Figure 5-9 shows the implementation of the BAdI method for the call of the shuttle booking service in the Execute
phase:
In the example the POT was enhanced to make use of a field that had previously been added to the shuttle
booking back-end service by an enhancement itself.
When you enhanced an enterprise service (see chapter 3 for details) that is consumed by a POT and want to use
these enhancements in the POT, you have to enhance the corresponding counterpart services of the POT. The
procedure is the same as described in the previous chapter. The only difference is that the field name of the POT
enhancement cannot be chosen freely but has to match the field name of the enhancement of the enterprise
service.
Again, the enhancement starts in the ESR. In our example we want to use the enhancement of the shuttle booking
service from chapter 3.3 in our POT. In order to do this we have to enhance the counterpart services of the shuttle
booking back-end service.
Figure 5-10 shows the data type enhancement for the create request of the shuttle booking service:
Figure 5-11 shows the enhancement for the business object as contained in the service response:
As you can see, the enhancements exactly match the enhancements of the back-end service.
Next, you have to generate the proxy structures for the enhancements using transaction SPROXY.
After that the enhancements are visible as append structures of the enhanced proxy structures:
Next, you have to enhance the internal types that correspond to the enhanced proxy data types. The internal
types are named like the proxy types with the proxy prefix being replaced by the prefix for common internal types
(see chapter 5.2.3. for help on finding the corresponding internal type for a proxy type).
The following figures show the internal types structures from our example together with their append structures:
Finally, you have to fill the additional service fields in the phase implementation by implementing the
corresponding BAdI methods.
In our example we implement the BAdI method for the call of the shuttle booking service in the Execute phase. It is
the same implementation as in chapter 5.2.4:
5.4 Summary
You can enhance a POT in the following places, if the POT developer has foreseen the corresponding
enhancement points (BAdIs):
Services and object model