Unit 1: Creating an Object Type in the Business Object Repository
Use
In this unit, you will learn how to create the object type sales order and how to maintain the key fields of this object type. You will see that the system supports you in the selection of key fields and the implementation in the program.
Procedure
Creating an Object Type
The dialog box Create object type is displayed.
Object name:
Sales orderName:
Sales order (mod.)Short description:
Sales order (modification for tutorial)The screen Change object type
Z_BUS2032 is displayed."Analyzing" the object type definition
First take a look at the "initial" object type definition. To do this, expand the hierarchies under the entries Interfaces, Attributes and Methods by clicking on the plus sign.
Interface IFSAP (SAP standard interface)
You see that your new object type already supports the
interface IFSAP (SAP standard interface). Every object type supports this interface as standard.The attribute and the two methods, which are also already in your object type, are defined for the interface IFSAP and are inherited from it. (The attribute and methods are therefore only there because the interface IFSAP is supported. If you were to delete the interface IFSAP , the attribute and the two methods would also "disappear" again.) The following object type components are inherited from the interface:
Method without dialog, which is called to check whether the object exists.
Method that displays the object in an object-specific way.
Attribute containing the type of the object.
The methods Display and ExistenceCheck still have to be implemented in the implementation program on an object-specific basis. This can also be seen by the background color. You will also do this in a later unit.
The implementation of the attribute ObjectType does not need to be changed.
Maintaining Key Fields
The next thing you have to do is create the
key fields of your new object type, so that the system knows how to uniquely identify objects of this type.The dialog box Create with Data Dictionary field proposals is displayed.
The table
VBAK ( Sales Document: Header Data) contains the data for a sales order. The only key field of this table, identifying a sales order, is the field VBELN (sales document).The only key field VBELN of this table is now displayed.
You go to the dialog box Create with text proposals for the key field to be created.
The key field is created with the automatically-proposed name SalesDocument for the object type Z_BUS2032 .
Adding Interfaces
In addition to the interface
IFSAP (SAP standard interface), which is automatically supported by the newly created object type, you have the option of assigning the object type additional interfaces with methods, attributes and events, which this object type must then support.The Insert Interface Type dialog box is then displayed.
You have now added three new interface types to the object type Z_BUS2032.
This interface adds the method Create to your object type.
Every object type that provides a function for creating should support the interface Create. Using the interface ensures that names are assigned in a standard manner, and makes it possible to set up a generic search help.
This interface adds the method Edit (change) to your object type.
Every object type that provides a function for changing should support the interface Create. Using the interface ensures that names are assigned in a standard manner, and makes it possible to set up a generic search help.
This interface adds the method Find to your object type.
This method determines an object which is available with this type and returns a reference to the object found.
Every object type should support the interface Find.
The implementation of the attributes and methods inherited from the interface is usually incomplete and not adapted to the current conditions of the object type. This will be discussed in a later unit.
Implementing the Object Type
At this point, go to the implementation program of the object type you have created.
Choose Program.
Since methods and attributes have not yet been implemented, the implementation program only contains the data declaration for the object key. This section is generated automatically from the information you have specified for the key fields of the object type.
Do not change this part of the implementation program!
Key fields in the implementation program
Analyze the implementation program of your object type as it stands. You can use the
implementation program in the appendix as a comparison.Note that the implementation program in the appendix already contains the complete implementation of object type
Some of the data declarations and program components there have not yet been included in your example, and are not required or created until the examples in the units still to come.
The key fields of the object type are declared in the program between the two macro commands
BEGIN_DATA OBJECT and END_DATA OBJECT .These macro commands, together with the commands in the implementation program, declare a structure for all key fields, which always starts with
OBJECT-KEY- and whose fields are derived from the defined key fields of the object type.The (only) key field of the object is hence available in the variable
OBJECT-KEY-SALESDOCUMENT in the program.