Академический Документы
Профессиональный Документы
Культура Документы
Table of Contents
Transactional Events........................................................................................................................................................................... 29
API Adapter......................................................................................................................................................................................... 35
Reference ............................................................................................................................................................................................................. 38
Appendix............................................................................................................................................................................................................... 44
These applications are expected to represent the specified functions in a robust and
high-performing manner. However, the pace of change and the demand on flexibility is
continuously increasing.
These high expectations often complicate the application’s code base and subsequently
lead to increased maintenance efforts. XO counters this effect by providing a clearly
structured and easy-to-understand object model together with a very open and flexible
framework. This framework consists of generic components that can be reused and
refined at all levels.
A Simple Example
SAPLANE SPPLANE
Let’s use a simple example to familiarize ourselves with the framework.
MANDT MANDT
The following data model is based on the simple idea of airplanes. The database PLANETYPE PLANETYPE
SEATSMAX ANZ_NOTAUS
table SAPLANE is the root table of the data model. Each table entry represents a CONSUM ANZ_PERS
single airplane. CON_UNIT ANZ_SBER
TANKCAP
The additional tables SPPLANE and SCPLANE have a 1:1 relationship with the CAP_UNIT
root table. They contain details that are specific to the potential role of the WEIGHT
WEI_UNIT SCPLANE
airplane (“cargo plane” or “passenger plane”). SPAN
MANDT
SPAN_UNIT
PLANETYPE
LENG
CARGOMAX
LENG_UNIT
From an object-oriented point of view, the first idea would be an inheritance CAR_UNIT
OP_SPEED
between three types of airplane: the generic airplane, the passenger plane, and SPEED_UNIT
the cargo plane. PRODUCER
SEATSMAX_B
SEATSMAX_F
Airplane
However, it is also possible to have a third type of airplane, a multipurpose plane that can transport passengers and cargo. To add more details to our
model, we define three individual objects that represent the different types of details. The four airplane types then comprise the specific aspects that
define them.
1 1 1
SAPLANE SPPLANE SCPLANE
1 1 1Technical view
We are only one step away from our first XO
SAPLANE SPPLANE SCPLANE
application. First let’s take a look at the building
blocks provided by XO:
A Simple Plan
XO correspond to a plain model for implementing a business application, which expects a clear and well-defined interface between application provider
and application consumer. The providing application separates transactional behavior from the business object-specific logic, which in itself separates
from the connection to a persisting entity.
XO comprises nine elementary building blocks. These blocks are provided with a generic implementation and enable an XO user to individualize them
further. The blocks are bound together by a customizable model.
Business Object Type The business object type groups together all components that
are relevant for a software solution developed in XO. It acts like
a unique identifier for Customizing and the runtime instances.
Segment Objects Segment objects (SO) represent logical and semantic subnodes of
a business object. They either connect to a data memory (via
memory objects) or simply represent a specific feature or
behavior.
Memory Objects Memory objects (MO) represent the data in memory. They usually
refer to a database table and ensure that data is buffered, changes
collected, and that the persisting level is connected.
Persistence Objects Persistence objects (PO) retrieve or store data from the database.
They support mass data retrieval and optimized mass update
processes.
Validation Objects Validation objects (VO) carry out additional plausibility checks on a
business object or a specific segment object. These objects do not
overrule the standard object validations but also do not represent
a technical modification.
The technical
representation of the Memory 1 1 1Technical view
underlying data model at Object SAPLANE SPPLANE SCPLANE
runtime can be done with Level
the help of memory
objects.1
1
The name of the memory objects must match existing ABAP Dictionary structures. Furthermore, we recommend you use the name of the database table.
2
The XO-generic persistence object is already sufficient in this example since the memory objects are named according to their database tables.
XO comes with its own modeling shapes. Before we configure the new application in the system, let’s take a look at the corresponding XO model:
Business Objects
Root Link
SAPLANE SPPLANE SCPLANE
Memory Objects
generic
The model represents exactly what was illustrated earlier. The “root link” comes as an additional element. This will be explained later.
Now we are ready to implement our model. Let’s move to the XO Cockpit.
You can create all other XO components from the main screen.
You have two choices:
Finally, for our first application, let’s have a look at the memory
object (MO) screens.
Congratulations!
You have just completed your first
XO application!
(Don’t forget to save your settings.)
Individual implementations
of XO elements should
inherit from their XO
superclass. Redefinitions of
inherited methods enable
you to create your individual
implementation and change
the standard behavior of the
XO element.
XO element Superclass
Business Object XO_BUSINESS_OBJECT
Segment Object XO_SEGMENT_OBJECT
Memory Object XO_MEMORY_OBJECT
Persistence Object XO_PERSISTENCE_OBJECT
Instead of individual implementations of XO elements, if you define the business object type you
can use your own classes for the several XO elements. These classes will be the standard classes
for the generic implementation of the XO elements after you have assigned them to your business
object type.
Business Object
Type
1:n 0:n
Validation Object
Segment Object 1:n 0:n
0:n
Segment Object
Memory Object 1:n
0:1
[1]
0:n
1:n 0:1
Validation Object 0:1 0:1 0:1
Object Instantiation
All XO objects are instantiated using factory methods. Objects must not be created using the ABAP statement CREATE OBJECT.
The main factory class is XO_FACTORY. This class provides methods to retrieve single objects (business objects, segment objects, memory objects, and
so on) as well as more specific factory methods (business factory, segment factory, and so on).
- object instantiation
Note that when you add new data to the business object it doesn’t necessarily mean that these changes are saved to the database. To save the changes
to the database, you have to call the business objects method SAVE and raise the transactional events.
You can use GET_TABLE_DATA of the XO_MEMORY_FACTORY to trigger this kind of mass data read. The memory factory then buffers the data and uses
it later when it instantiates the XO business, segment or memory objects.
data:
lr_mem_factory type ref to xo_memory_factory,
lv_object_key type xo_object_key,
lr_bo_airplane type ref to if_xo_business_object,
lt_data_new type tty_xo_table_data.
lr_bo_airplane = lr_bo_factory->get_instance(
i_object_name = 'PASSENGER_PLANE'
i_object_key = lv_object_key
).
lr_bo_airplane->get_data_new(
exporting
i_table_name = 'SAPLANE'
importing
e_data = lt_data_new
).
* process lt_data_new ...
endloop.
Transactional Events
The XO framework uses internal events for its transactional logic. By default these events are not coupled to any external events, neither the ABAP
events raised by COMMIT or ROLLBACK WORK or to any other frameworks events. This may seem a disadvantage since you have to link your external
events to the XO events or trigger the XO events explicitly. For example, the end of a logical unit of work (LUW) means nothing to the XO frameworks.
No data is saved and no memories are cleared.
But in fact the lack of a hard-coded dependency to other transactional events is one of the strengths of the XO framework. It allows you to integrate
your XO business objects into any framework with its own transactional behavior. All you have to do is map and link the events of both frameworks. For
some scenarios, such as the BDT framework or regular (B)APIs, XO provides adapters that map and trigger the XO transactional events.
- FINALIZE. - ROLLBACK.
At this event, all XO objects complete their data. The XO This event should be used when the ABAP event ROLLBACK
default implementation calls the key generator and replaces WORK is raised. The XO business objects save a flag and the
temporary object keys (if used) with the final ones. object is locked. Since the ROLLBACK WORK releases all locks,
Furthermore, this event should be used to generate default this event should also be called to clear this flag.
values for your data and add any required administrative data
- CLEANUP.
(change user and timestamp).
This event clears all memory and buffers. It resets all XO
- COMMIT_START. object instances so that these instances can be reused
For technical reasons the event COMMIT is split into two (instance reuse). This event should be raised at the end of
steps. For the default behavior this allows you to first collect each LUW.
the changes of the single BOs and save them with a mass data method end_transaction.
access to the database. At COMMIT_START the XO memory data: lr_controller type ref to xo_controller.
objects submit their changes to their persistence objects. lr_controller = xo_factory=>get_controller( 'AIRPLANE' ).
lr_controller->raise_finalize( ).
- COMMIT_END. lr_controller->raise_commit_start( ).
lr_controller->raise_commit_end( ).
At COMMIT_END the XO persistence objects submit the lr_controller->raise_cleanup( ).
changes from all memory objects to the update function commit work and wait.
endmethod.
modules.
The new validation object must be assigned to the segment object using drag and
drop.
At business object type level you can activate or deactivate the use of
change documents for the whole business object regardless of the settings
for change documents for the XO memory objects.
The class for the listener object must implement the interface
IF_XO_LISTENER_OBJECT.
In the interface method LISTEN( ) you can activate the handler for
all events implemented in the XO element classes.
set handler:
on_commit_start for lr_controller activation true,
on_data_submitted_for_save for all instances activation true,
on_data_object_is_locked for all instances activation true.
In addition, the XO framework provides adapters to easily integrate your XO business objects into existing frameworks and with existing tools.
The BDT is a central control tool for maintaining master data and simple transaction data. In addition to dialog maintenance, it also supports
maintenance with direct input and function modules. The BDT also provides generic services for consistently recurring requirements that occur
in change document lists, field groupings, and the deletion program. It takes control over these objects as well as generic parts and calls the
applications using predefined interfaces (control tables and events). The applications themselves introduce application-specific enhancements,
such as writing and reading application tables.
SAP business objects are accessed through Business Application Programming Interfaces (BAPIs),
which are stable, standardized methods. SAP provided the first BAPIs for customers and external
providers in R/3 Release 3.1, enabling them to integrate their software components in an SAP system.
The number of BAPIs increases with each R/3 release and this also increases the possibility of object-
oriented access to an SAP system.
The change notification service enables you to create, store, and read change pointers. A change pointer is an object that records a change
made to a business object by an application. The service stores some information about the business object and its changes (such as date,
change type, images). A report deletes the used change pointers after a specified period. The change notification service also supports different
read mechanisms for the stored change pointers. You can choose whether to display the entire history of the changes, or only one change
pointer containing the most important information.
BDT Adapter
BDT applications have to provide several function modules for various BDT events, for example read data (ISDAT), complete and save data (DSAVC,
DSAVE), and initialize the memory (DLVE1, DLVE2). Since the implementation for these events is often similar, the XO framework provides a generic
implementation.
endfunction.
CNS Adapter
SAP Note 1298389 has redesigned the CNS connectivity of the XO framework (for NW
711 SP6 and later). In this document we’ll focus on the current design of the XO/CNS
integration. Note that you cannot use transaction XO_COCKPIT to maintain the
Customizing settings of the previous CNS integration. Instead you’ll find the button
Switch to Current Version.
The legacy CNS integration can still be used but you have to maintain the
configuration directly via Customizing tables (CEXO_CHANNEL_CNS and
CSXO_CNS_TYPE) using transaction SE16, for example.
Before you maintain your XO/ CNS configuration, you have to create the regular CNS configuration for your business object. You find the CNS
configuration in the SAP Customizing Implementation Guide under Cross-Application Components General Application Functions Change Pointer
Service. Here you define your CNS application ID, export object types and receivers. Note that XO supports only one CNS application ID per business
object type.
At runtime the XO CNS adapter checks which CNS export object types actually have active receivers. For performance reasons, the adapter tries to
create change pointers only if there are active users.
- EX001 – creates simple change pointers with the object key as CNS export object key and sets the change category to “I” (insert) or “U” (update)
depending on whether the object is new or not
- EX002 – creates change pointers such as EX001 but also fills the CNS info table with the list of changed segments
method if_xo_cns_handler~new_change_pointer.
data: lt_bo_data type tty_xo_memory_data.
" Decide based on actual data whether or not to create a Change Pointer
if [irrelevant change].
return. " don’t write a change pointer
else.
save_bo_snapshot( lt_bo_data ). " save snapshot of current BO state
super->if_xo_cns_handler~new_change_pointer(
i_bo = i_bo
i_appl_id = i_appl_id
i_expobjtype = i_expobjtype
).
endif.
endmethod.
37 XO – Extensible Objects | Cookbook
Reference
XO is located in software layer SAP_ABA and available in NetWeaver 7.01 SP 8, 7.02 SP5, 7.10 and newer releases.
0..* 0..*
0..* 0..* 0..*
xo_business_factory xo_segment_factory xo_memory_factory xo_persistence_factory xo_validation_factory
if_xo_listener_object
xo_key_generator 1 cl_aunit_assert
(from SAP_BASIS)
if_xo_key_generator
1
1 xo_controller 1 xo_services xo_enumerator xo_unit_test
1 xo_object
0..* +assigned_controller 1
xo_customizing 1
0..* 1
1
0..*
if_xo_validation_object if_xo_so_assigne if_xo_mo_assign
d_bo_behavior ed_bo_behavior
xo_so_assigned_bo_behavior xo_mo_assigned_bo_behavior
XO Sequence Diagram
Get a business object instance
: xo_factory : :
: Actor
xo_business_factory xo_customizing
get_business_object( )
get_business_factory( )
get_instance( )
:
if_xo_business_object
ENDIF
Alternative
call sequence
get_business_factory( )
get_instance( )
XO Sequence Diagram
Get existing business object instances
: xo_factory
: Actor
get_business_factory( )
:
xo_business_factory
get_buffered_instances( )
read from buffer
get_segment_object( )
get_data( table_name )
is_bo_connector( ) = FALSE
get_data( )
data
data
ENDLOOP
ELSE
get_data( )
is_bo_connector( ) = FALSE
get_used_tables( )
get_data( )
data
data ENDLOOP
ENDIF
data
XO Sequence Diagram
Set business object data
: : :
: Actor
if_xo_business_object if_xo_segment_object if_xo_memory_object
set_data_new( i_data_catalogue )
LOOP AT i_data_catalogue
LOOP AT segments
get_segment_object( )
is_table_used( )
TRUE
set_data_new( )
is_bo_connector( ) = FALSE
LOOP AT tables
get_table_object( )
set_data_new( )
ENDLOOP
ENDLOOP
ENDLOOP
cx_xo_root_dynamic
Interfaces with constants for the XO framework start with the prefix IF_XO_CONST_.
- IF_XO_CONST_ACTIVITY
- IF_XO_CONST_BOOLE
- IF_XO_CONST_CHANGE_INDICATORS
- IF_XO_CONST_COMPARE
- IF_XO_CONST_COMPONENTS
- IF_XO_CONST_DATE_PERIODICITY
- IF_XO_CONST_DEFAULT_OBJECTS
- IF_XO_CONST_DIRECTIONS
- IF_XO_CONST_MESSAGE
- IF_XO_CONST_TABLE_TYPES
- IF_XO_CONST_VALIDATION_TARGET
- IF_XO_CONST_WEEKDAYS