ABAP Keyword Documentation →  ABAP - Reference →  Predefined types, data objects, and functions →  Predefined Data Types →  Predefined Types in ABAP Dictionary →  Use of Predefined Data Types from ABAP Dictionary → 

Quantity Fields

A quantity field is a component of a structure or database table of type QUAN which has been defined in the ABAP Dictionary, for the inclusion of a quantity in a specific unit. A quantity field must be linked to 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 which is defined in the ABAP Dictionary, and can contain a unit identification from database table T006.

Handling in the ABAP Dictionary

A data element of data type QUAN is treated 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 in the individual maintenance of the component as a reference field. This field is the unit key which determines the unit of the quantity.

Note

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 screen. In principal, it is independent of the number given for the quantity field of type QUAN.

Handling on Screens

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

In order 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 identification from the T006 database table. If the reference field is not found or there is no entry in the T006 database with the content of the field, the quantity field is displayed as a normal field of type DEC.

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

If the unit identification of the reference field is found in the MSEHI column of the T006 database table 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 normal field of type DEC.

Note

A display that matches the accuracy of a quantity field is only then achieved, 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 QUAN data type is p. An ABAP data object which is declared with reference to a dictionary type of type QUAN has the number of decimal places defined there. These decimal places are taken into account 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 UNIT addition of the WRITE [TO] statement.