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
Properties of Conversion Routines
A conversion routine has a five-character name, CNVRT, used to
- Assign the routine directly to a dynpro field in Screen Painter.
- Specify the routine using the addition
USING EDIT MASKof the
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 TOand 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
- An optional input parameter with the predefined name REFVAL can be created. When a dynpro field of the type
QUAN is converted, this parameter is given the value of a an associated reference field of the type
UNIT automatically If
WRITE USING EDIT MASKis used, the input parameter REFVAL is not filled.
- Other optional input parameters can also be used, but are not filled automatically.
- Statements that interrupt the program flow or terminate an SAP LUW cannot be executed in the function modules. In OUTPUT conversions, only termination messages are valid. In INPUT conversions, termination messages, error messages, and (less useful) status message can all be sent. Error messages produce in an error dialog.
- 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.
- OUTPUT conversions needs to display very good performance, since an OUTPUT function modules can be called very often in list output.
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.