Skip to content

ABAP Keyword Documentation →  ABAP Dictionary →  Predefined Data Types in ABAP Dictionary →  Attributes of the Predefined Dictionary Types →  Special Dictionary Types 

Quantity Fields

A quantity field is a component of a structure or database table of type QUAN defined in ABAP Dictionary, used to include a quantity in a specific unit. A quantity field must be associated with a unit key of a structure or of a database table which determines the unit and the number of decimal places. A unit key is a component of a structure or a database table of type UNIT defined in ABAP Dictionary and can contain a unit ID from the database table T006.

Other versions: 7.31 | 7.40 | 7.54


Note

Quantities and units are handled as specified by the data saved in the database tables T006... in the package SZME. This data can be edited using the transaction CUNI.

Handling in ABAP Dictionary

A data element of data type QUAN is handled as a field of data type DEC and is stored in database tables in the BCD format. When creating a data element or a structure component of the data type QUAN in the ABAP Dictionary tool, any number of decimal places can be defined. The default value is no decimal places.

For every structure component of data type QUAN, a component of the same structure or of a different structure or database table which has the data type UNIT must be specified when editing the individual component as a reference field. This field is the unit key which determines the unit of the quantity. From a technical perspective, the data type UNIT is handled like a type CHAR with length 2.


Notes

  • The number of decimal places for the unit defined using the unit key of type UNIT only influences the formatting of a quantity field on a dynpro. In principal, it is independent of the number given for the quantity field of type QUAN.

Handling in Dynpros

For the display of an input/output field of type QUAN on a dynpro, the content is displayed as character-like and in accordance with a type-dependent template, as for all dynpro fields. The system tries to create a display which suits the unit of the quantity field.

To determine the unit, a search is made in the global data of the current ABAP program for the field's reference field for the unit key. The content of this field must be a valid unit ID from the database table T006. If the reference field is not found or if there is no entry in the database table T006 with the content of the field, the quantity field is displayed as a regular field of type DEC.

The reference field is either defined in the relevant structure in ABAP Dictionary or was determined using Screen Painter for the attributes of the dynpro field. It does not have to be present on the dynpro itself.

If the unit ID of the reference field is found in the column MSEHI of the database table T006 and the quantity field does not have any decimal places with a value other than 0, except the accuracy defined in the DECAN column, the quantity field is displayed with this accuracy. For a unit without decimal places, the decimal separator is suppressed. If the quantity field has decimal places with a value other than 0 outside of its accuracy, however, it is displayed as a regular field of type DEC.


Note

A display that matches the accuracy of a quantity field is only then possible if no information is lost. This allows average values instead of integer units to be displayed in a relevant quantity field, for example.

Handling in ABAP Programs

The ABAP type which corresponds to the data type QUAN is p. An ABAP data object declared with reference to a dictionary type of type QUAN has the number of decimal places defined there. These decimal places are respected for all operations and calculations, as for all packed numbers.

The unit defined for a quantity field only plays a part in ABAP programs if it is specified after the addition UNIT of the statement WRITE [TO].