Select language:

Function documentationUnit of Measure Conversion

 

You use this function to convert quantities in data records, returned by a data provider into a given target unit of measure, using conversion factors.

Prerequisites

BCV allows unit of measure conversions if the following apply:

  • The result data contains at least one quantity column and a corresponding unit of measure column that are linked together.

  • You have specified a target unit of measure.

  • For units without dimension (EA, PAL, ROL, and so on) a conversion material is known.

  • Appropriate conversion factors from the original to the target unit of measure are available.

Note Note

The system triggers unit of measure conversions during query processing. Therefore, each request for a unit of measure conversion requires the re-execution of the query, including a new data retrieval from the data provider.

End of the note.

Note Note

The unit of measure conversion is executed in the system BCV is used in, and not necessarily the system the data is read from. If you have not set up the system landscape (automated update of the conversion factor table) properly, the conversion factors can differ between the different systems.

End of the note.

Features

Linking Quantity-Related Columns of Result Data

This graphic is explained in the accompanying text.

For each column of the result data there is one query field in the definition of the corresponding BCV query (with column ID = field ID). For more information, see Definition of Queries. Columns that contain quantities refer to query fields of data type QUAN. Columns that contain units of measure refer to query fields of data type UNIT. To allow unit conversions, you must link a a quantity column to the corresponding unit of measure column. You can do this when defining a search connector, or a BCV query, by assigning the respective UNIT field as reference field to the QUAN field, and setting the reference type to Unit of Measure. If the information about the conversion material (the material for which the conversion factor is defined) is also available in the result data, a link can be created, too.

Columns that contain conversion materials refer to query fields of textual data type. To provide the conversion material for currency conversions, you must link the unit of measure column to the corresponding conversion material column. You can do this when defining a search connector, or a BCV query, by assigning the respective textual field as reference field to the UNIT field and setting the reference type to Conversion Material.

For more information about BCV data types, see Data Types Used in BCV.

Specification of Target Unit of Measure

BCV automatically generates a system-defined input field into any BCV query that has at least one result field of data type QUAN that contains a unit of measure reference to a result field of data type UNIT.

Input Field ID

Data Type

Description

Example Values

/BCV/UNIT_OF_MEASURE

UNIT

Target Unit of Measure

KG, EA

The system uses this field to pass the conversion target to the BCV query. You can either set it to a fixed value in the query view definition (see Definition of Query Views) or let the system fill them from your input at runtime. To fill the field at runtime, choose   Functions  Change Input   in the view area. To trigger a unit of measure conversion, input field /BCV/UNIT_OF_MEASURE has to be filled.

Determination of Conversion Factors

To perform the unit of measure conversion, conversion factors from the original unit of measure to the target unit of measure must exist in the BCV system. For units without dimension (EA, PAL, ROL, and so on) that can only be converted in a material-dependent way, the conversion factors also depend on the conversion material. In such a case, a conversion factor for the respective material must exist.

By default, BCV uses conversion factors from database tables T006*. These tables only contain conversion factors for units with dimension (that is, for material-independent conversions). You can maintain the contents of these tables in Customizing, under   SAP NetWeaver  General Settings  Check Units of Measurement  .

Caution Caution

You are responsible for providing the conversion factors and for the completeness and correctness of this information.

End of the caution.

Note Note

If there is no active implementation of the Business Add-In (BAdI) BAdI: Unit Conversion (/BCV/FND_UNIT_CONV) in the system, BCV cannot perform material-dependent conversions.

End of the note.
Execution of the Unit of Measure Conversion

A unit of measure conversion is triggered when you execute a BCV query with a non-initial input field /BCV/UNIT_OF_MEASURE (target unit of measure).

The system performs the conversion after the search connector has returned the requested (raw) result data and performed the method CHANGE_RAW_DATA of BAdI: Processing of Query Results /BCV/QRM_QUERY_RESULT). This means that the system performs unit of measure conversion before formula calculations, grouping, aggregation, and sorting of the result data. In the result data, the system converts the values of all quantity columns that are linked to a corresponding unit of measure column. The only exceptions are quantity columns where you have selected the No Conversion checkbox in the corresponding query field.

When the conversion of a value was successful, the system replaces the original value of the quantity column with the converted value. Furthermore, it replaces the original unit of the corresponding unit of measure column with the target unit.

Note Note

Due to the unit of measure update logic described above, you cannot have two quantity columns linked to the same unit of measure column where one of the quantity columns has the No Conversion checkbox selected.

End of the note.
Handling of Conversion Failures

If the conversion of a quantity fails because of an invalid (unknown) original unit of measure, missing material information (for material-dependent conversions), or a missing appropriate conversion factor, the system raises an exception and the BCV query does not return any result data.

Business Add-In (BAdI) 'BAdI: Unit Conversion'

If you want to replace the unit of measure conversion function delivered by SAP, create an implementation of the BAdI BAdI: Unit Conversion (/BCV/FND_UNIT_CONV). In Customizing, choose   Cross-Application Components  Processes and Tools for Enterprise Applications  Business Context Viewer  Foundation, Monitoring  Business Add-Ins (BAdIs) for Foundation, Monitoring  BAdI: Unit Conversion  .

The BAdI has the filter APPLICATION defined for the application (PLM, ERP, SCM, and so on) in whose context key the system processes the current query. For more information about the use of the context key, see Context Key. At runtime, the system determines the active implementation of the BAdI whose filter value matches the current application. You can define which context key refers to which application in Customizing, under   Cross-Application Components  Processes and Tools for Enterprise Applications  Business Context Viewer  Foundation, Monitoring  Define Context Key  .

Depending on the source of conversion factors you used in the BAdI implementation, you have to provide appropriate conversion factor information at the respective place. If no active BAdI implementation exists, the system determines material-independent conversion factors from database tables T006*. For more information, see section Determination of Conversion Factors above.

Note Note

For each application, a maximum of one active BAdI implementation is allowed to exist in the BCV system.

End of the note.

Was this page helpful to you?

Related Content

The following content is not part of SAP product documentation. For more information, see the following disclaimer Information published on SAP site .