Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  User Dialogs 

Conversion Routines

A conversion routine (also known as a conversion exit) uses a self-written implementation to override standard conversions (where values are passed from an ABAP data object to a dynpro field or from a dynpro field to an ABAP data object and in the formatting of data using the statements WRITE and WRITE TO).

Other versions: 7.31 | 7.40 | 7.54

Properties of Conversion Routines

A conversion routine has a five-character name, CNVRT, used to

  • specify the routine using the addition USING EDIT MASK of the WRITE statement.

From a technical perspective, a conversion routine consists of two function modules. The function modules are associated with the conversion routine using a naming convention:

  • A function module called CONVERSION_EXIT_CNVRT_INPUT performs the conversion from the display format to the ABAP representation, if CNVRT is the five-character name of the conversion routine.
  • A function module called CONVERSION_EXIT_CNVRT_OUTPUT performs the conversion from the ABAP representation to the display format, if CNVRT is the five-character name of the conversion routine.

Executing Conversion Routines

Conversion routines are executed as follows:

  • If a dynpro field is defined using a reference to a domain with a conversion routine or if a conversion routine is assigned to the field directly in its attributes, the INPUT function module is executed automatically when entries made in the associated screen field are passed to ABAP and the OUTPUT function module is executed automatically when ABAP output is passed to the screen field. In each case, the converted content is used.
  • If an ABAP data object is declared with reference to a domain with a conversion routine, the OUTPUT function module is executed by default when formatting the content using WRITE or WRITE TO and the converted content is produced or assigned. The default behavior can be overridden using the addition USING [NO] EDIT MASK.

The function modules can of course be called and tested in the usual way.

Function Modules for Conversion Routines

As well as the naming conventions, the function modules must meet the following requirements:

  • Both function modules must be implemented in the same function group and this group cannot contain further function modules.
  • Both functions must have the following mandatory parameters:
  • The input parameter INPUT for the value being converted
  • The output parameter OUTPUT for the converted value
Additional optional input parameters can also be specified. In the INPUT conversion, the parameter INPUT must be generic, and in the OUTPUT conversion, the parameter OUTPUT must be generic. This is because the type of the assigned dynpro field or ABAP field can change depending on how it is used.
  • Describe the effects of the conversion in the documentation.

Any exceptions raised in conversion routines always terminate the program. Conversion routines can only be debugged using the two-process debugger.


Notes

  • OUTPUT conversions needs to display very good performance, since an OUTPUT function modules can be called very often in list output.

  • Conversion routines are subject to the rule that no external subroutines can be called, since in this case their assigned to a program group cannot be identified.

Example

The function modules CONVERSION_EXIT_SDURA_INPUT and CONVERSION_EXIT_SDURA_OUTPUT of the conversion routine SDURA. In its output, this conversion routine transforms seconds to minutes or minutes to hours, and in its input minutes to seconds or hours to minutes.


This translation does not reflect the current version of the documentation.