Depending on the data type of the field, there is a conversion when the contents of a screen field are converted from display format to SAP-internal format and vice versa. If this standard conversion is not suitable, it can be overridden by defining a conversion routine in the underlying domain.
Conversion routines are identified by a five-place name and are stored as a group of two function modules. The function modules have a fixed naming convention. The following function modules are assigned to conversion routine xxxxx:
The INPUT module converts from display format to internal format, and the OUTPUT module converts from internal format to display format.
When is a Conversion Routine Executed?
If a screen field refers to a domain with a conversion routine, this conversion routine is executed automatically when entries are saved in this screen field or when values are displayed in this screen field. The conversion routine of the domain is also triggered when the field contents are output with the WRITE statement.
Table SPFLI in the
Field FLTIME refers to domain S_DURA, to which conversion routine SDURA is assigned. The value is thus converted by the two function modules CONVERSION_EXIT_SDURA_INPUT and CONVERSION_EXIT_SDURA_OUTPUT.
A conversion routine can also be triggered by specifying its five-place name in the attributes of a field in the Screen Painter or with the addition USING EDIT MASK <Name of conversion routine> in the WRITE command in the program. With the USING NO EDIT MASK addition in the WRITE statement, you can skip a conversion routine defined for a domain when outputting.
Parameters
The two function modules of a conversion routine must have precisely two parameters with the names INPUT and OUTPUT for the value to be converted and the converted value.
The INPUT parameter in the INPUT conversion and the OUTPUT parameter in the OUTPUT conversion should not have any reference fields because the value passed in the call could have a different length than that expected.
Programming Conversion Routines
ABAP statements that result in an interruption of processing (such as CALL SCREEN, CALL DIALOG, CALL TRANSACTION, SUBMIT, COMMIT WORK, ROLLBACK WORK, MESSAGE I, MESSAGE W) are not allowed in conversion routines.
Only A messages are meaningful in output conversion, but A, E and S messages can be triggered in input conversion (although S messages are not very meaningful here). E messages result in an error dialog. Exceptions are not intercepted in the call.
The output conversion is also triggered with WRITE and WRITE TO. The conversion routine may therefore occur very frequently with lists. The output conversion should therefore be programmed as efficiently as possible.
No external performs should be used in conversion routines. Programs that are called externally use the table work areas of the first calling main program. In conversion routines this can result in errors that cannot be easily analyzed since they are sometimes called at unpredictable times in the program flow.