When you convert a screen field from display format to SAP internal format and vice-versa, and output data with the ABAP/4 statement WRITE, type conversion is automatic. To perform a non-standard conversion, you have to specify the conversion name (e.g. ALPHA) in the attributes of one of the fields in the Screen Painter or use the addition USING EDIT MASK '==ALPHA' (see example) in the WRITE statement. This kind of conversion is performed automatically if the field has a Dictionary reference and you specify the conversion in its domain.
If you want to implement non-standard conversions from display format to SAP internal format and vice-versa,
you use conversion exits. These are written in ABAP/4 and stored as function modules. Two ABAP/4 function modules are assigned to the conversion xxxxx. These are:
The INPUT module converts from display format to internal format, while the OUTPUT module performs the reverse operation. You are recommended to assign both modules for input and output conversion to a function group. The effect of the conversion should be described in the documentation. If necessary, you can introduce new conversions. The function modules you create for these must only satisfy the above name requirements and conform to the conventions listed below.
Both functions must have precisely two parameters (although other optional input parameters are also allowed). The names of the obligatory parameters are INPUT for the value to be converted and OUTPUT for the converted value. It is important that the INPUT parameter in the INPUT conversion and the OUTPUT parameter in the OUTPUT conversion have no reference fields, since the screen or ABAP/4 field assigned during the call can have a different length than expected. This is because matchcode entry is possible.
The output conversion may include A messages. The input conversion can have A, E and S messages (although S messages are of little use). E messages result in an error dialog. Exceptions are not detected when the function is called and lead to termination.
Any ABAP/4 statements which interrupt the processing are not allowed in conversion exits. These include:
If you use a function module as a conversion exit, you cannot interrupt the processing, so debugging is not possible. However, you can force a termination by (for example) including a divide by zero operation. You can then analyze the current contents, types and lengths of fields at the point of termination.
Since the WRITE and WRITE-TO statements can trigger output conversions very often with lists, you should try to keep these conversions efficient.
Do not use external PERFORMs in conversion functions because externally called programs use the table work areas of the first calling main program. With conversion exits, this could result in undetectable errors since conversion exits often occur at unexpected points in the program flow.