You must defineattributes for an object type when you want to query particular properties, statuses or values at runtime.
Attributes have various sources of information. You can split attributes according to the following sources:
The information is not determined until runtime, for example by calculation.
The information is the content of a database field.
The information is an object status.
The attribute information is returned in two different data type references:
After definition of an attribute, you can add source text to the implementation program automatically. To do this, select the attribute in the list and choose Program.
To create an attribute, position the cursor on the component name Attributes (blue background), and select . Bear in mind therules for naming object type components.
Database field attribute
Always create an attribute of this kind with a reference to a field of the ABAP Dictionary. Answer YES to the question Create with ABAP Dictionary field proposals?, and have the system make proposals for the fields.
With a database field attribute that provides the information as a field or structure reference, choose the table and field. Define whether it as a mandatory attribute.
With a database field attribute that provides the information as an object reference, choose the table, the field as source and the object type for the data type reference. Define whether it as a mandatory attribute.
The object type for the object reference can only have one key field and must be identifiable using the field. If these conditions are not met, you must define a virtual attribute.
If the attribute is derived from a field in a table whose key fields do not correspond to or only correspond partly to the key fields of the object type, the extensions in the implementation program are not sufficient. The source text contains question marks (?????????? ) at the relevant points. Revise the source text at these points. Otherwise, the source text created is complete. For further information, refer to Programming Database Field Attributes.
With virtual attributes, it is not worth having the system make ABAP Dictionary field proposals. Answer the question with NO. A dialog box with the attribute data is displayed.
Select the indicator Virtual and give the attribute an ID and texts. Define the other attribute properties and enter a data type reference. If you use the ABAP Dictionary as data type reference, only the data type of the field specified is evaluated.
Multiline attributes and attributes with a data type reference to an object type with several key fields must be implemented as virtual attributes.
The extensions in the implementation program are not sufficient. For further information, refer toImplementation Program for a Virtual Attribute.
Object status attribute
You can only define an object status attribute if the object type supports theinterface Status management. It is not worth having the system make ABAP Dictionary field proposals. Answer the question with NO. A dialog box with the attribute data is displayed.
Select the indicator Object status and give the attribute an ID and texts. Define the other attribute properties and the object status. The system enters the fieldOBJSTATUS from the table SWCEDITOR as data type reference. The source text created in the implementation program is complete.
Relationships between two object types are described using attributes, which return their information as object references to the other object type. In the field Inverse attribute, enter the attribute of the other object type, which contains the object reference to this object type.
Before the attribute is used, you must change itsrelease status. To check the attribute you must generate the object type, after which you can test it. For further information, refer to Processing Object Types.
You can use macros to access the attribute. For further information, refer toMacro Instructions for Accessing Objects, Attributes and Methods