Ansicht
Dokumentation

ABENCONVERSION_EXITS - CONVERSION EXITS

ABENCONVERSION_EXITS - CONVERSION EXITS

SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.
SAP E-Book

Conversion Routines

A conversion routine (also referred to as a conversion exit) uses a self-written implementation to override standard conversions that take place when 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.

Properties of Conversion Routines

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

  • Assign the routine directly to a dynpro field in the Screen Painter.
  • 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 the input in the associated screen field is 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 output 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

In addition to the naming conventions, the function modules must meet the following requirements:

  • Both function modules should be implemented in the same function pool and this group cannot contain further function modules.
  • Both functions must have the following mandatory parameters:
  • The input parameter INPUT for the value to be converted

  • The output parameter OUTPUT for the converted value

In the INPUT conversion, the parameter INPUT should be generic, and in the OUTPUT conversion, the parameter OUTPUT should generic because the type of the assigned dynpro field or ABAP field can change depending on how it is used.
  • An optional input parameter with the predefined name REFVAL can be created. When a dynpro field of the type CURR or QUAN is converted, this parameter is automatically given the value of a an associated reference field of the type CUKY or UNIT. If WRITE USING EDIT MASK is used, the input parameter REFVAL is not filled.
  • Other optional input parameters can also be used but are not filled automatically.
  • The effects of the conversion are described 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

  • It is important that OUTPUT conversions have good performance, since an OUTPUT function module 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 assignment 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.






CPI1466 during Backup   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 7439 Date: 20240420 Time: 073114     sap01-206 ( 105 ms )