Start of Content Area

Procedure documentation Unit 1: Creating an Object Type in the Business Object Repository  Locate the document in its SAP Library structure

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

  1. Choose Tools Business Workflow Development Definition Tools ® Business Object Builder.
  2. Enter the name Z_BUS2032 of your new object type in the Object type field.
  3. Choose This graphic is explained in the accompanying text Create.
  4. The dialog box Create object type is displayed.

  5. Enter the following texts:
  6. Object name: Sales order

    Name: Sales order (mod.)

    Short description: Sales order (modification for tutorial)

  7. Enter Z_BUS2032 as the program name. This is the name of the implementation program of the object type.
  8. Enter Z as the code letter of your Application.
  9. Confirm your entries with This graphic is explained in the accompanying text.
  10. Save the object type you just created as a local object or with package in a transport request.

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.

  1. Position the cursor on the entry Key fields.
  2. Choose This graphic is explained in the accompanying text and answer the query Create with ABAP Dictionary field proposals? with Yes. This simplifies the entry of the data type reference.
  3. The dialog box Create with Data Dictionary field proposals is displayed.

  4. Enter the table VBAK .
  5. 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).

  6. Choose This graphic is explained in the accompanying text.
  7. The only key field VBELN of this table is now displayed.

  8. Select this field. (In the case of object types that have several key fields, you should of course select all the key fields.)
  9. Choose This graphic is explained in the accompanying text.
  10. You go to the dialog box Create with text proposals for the key field to be created.

  11. Check the proposed texts. Changes do not have to be made (but they could be made).
  12. Choose This graphic is explained in the accompanying text. This is final confirmation that you want to transfer this key field into the object type definition.
  13. The key field is created with the automatically-proposed name SalesDocument for the object type Z_BUS2032 .

  14. Choose This graphic is explained in the accompanying text.

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.

  1. Position the cursor on the entry Interfaces.
  2. Choose This graphic is explained in the accompanying text.
  3. The Insert Interface Type dialog box is then displayed.

  4. Enter IFCREATE as the Interface type and choose This graphic is explained in the accompanying text.
  5. Choose This graphic is explained in the accompanying text.
  6. Repeat this procedure for the interface types IFEDIT and IFFIND .

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

Note that the implementation program in the appendix already contains the complete implementation of object type Z_BUS2032 .

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.