Start of Content Area

Procedure documentation Unit 2: Creating Database Field Attributes  Locate the document in its SAP Library structure

Use

In this unit you create and implement the database field attribute document date. This attribute contains the document date as a field value as it is stored on the database.

The system helps you implement this attribute by generating source text automatically.

Procedure

  1. Position the cursor on the entry Attributes.
  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. Enter VBAK in the Table field.
  4. All database field attributes of an object type refer either to the table used to define its key fields or to a table with an identical key structure.

  5. Select the AUDAT field (document date) from the table fields displayed.
  6. Choose This graphic is explained in the accompanying text.
  7. The Create dialog box is then displayed.

  8. Check the proposed texts. You do not need to make any changes.
  9. Choose This graphic is explained in the accompanying text.

The attribute is transferred into the object type definition with the automatically-proposed name DocumentDate .

Implementing attributes in the implementation program

Check the definition made so far. To do so, choose This graphic is explained in the accompanying text.

The system detects that the database field attribute has not been implemented in the program of the object type and allows you to generate a template automatically for the missing source text.

Make sure you choose this option.

The automatic generation of the implementation program has satisfactory results for database field attributes so that no revision is necessary.

The system then automatically goes to the implementation program of the object type you created.

Here, you can see additional program components that control access to the table with the attributes.

Do not change this part of the implementation!

Database field attribute

Database field attributes are implemented between the macro commands GET_TABLE_PROPERTY <table name> and END_PROPERTY .

To program one access for all attributes that refer to a table, the tables are buffered initially in an internal table. This internal table is created from the database table in the subroutine FORM SELECT_TABLE_<table name> USING SUBRC LIKE SY-SUBRC .

Analyze the implementation program as it stands. You can use the implementation program in the appendix as a comparison.

Result

The object type must first be generated and released before it can be instantiated and tested.

  1. Choose This graphic is explained in the accompanying text.
  2. The system informs you if the object type still contains errors. Try to correct these errors in the error overview (Goto ® Error list).

  3. Choose Edit Change release status Object type ® To implemented.

The attributes created up to now can then be tested.

Testing the DocumentDate attribute

  1. Choose This graphic is explained in the accompanying text.
  2. The Test Object Type <Object Name>: No Instance screen appears.

  3. Choose This graphic is explained in the accompanying text Instance.
  4. Identify an object of the type sales order by entering the number of a sales order of your choice. Use the F4 input help if necessary.

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

The Test Object Type <Object Name> screen then appears, in which you can test your object type (execute methods, check attribute values).