Introduction:
Conversion takes place when converting the contents of a screen field from display format to SAP-internal format and vice versa and when outputting with the ABAP statement WRITE, depending on the data type of the field.
If standard conversion is not suitable, it can be overridden by specifying a conversion routine in the underlying domain.
A conversion routine is identified by its five-place name and is 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:
CONVERSION_EXIT_xxxxx_INPUT
CONVERSION_EXIT_xxxxx_OUTPUT
The INPUT module performs the conversion from display format to internal format. The OUTPUT module performs the conversion from internal format to display format.
If a screen field refers to a domain with a conversion routine, this conversion routine is executed automatically each time an entry is made in this screen field or when values are displayed with this screen field.
Let’ say there is a date field and we want to display the date field 20121203 as 12/2012.
Here are the steps how this can be achieved.
Steps:
1. Assume that we have created domain for the date field ZCRDAT and we need to assign the custom conversion routine to this particular domain.
2. Go to the transaction code SE37, enter the function module name CONVERSION_EXIT_ZDATE_INPUT and click create.
3. Below screen will appear. Enter the function group, short text and click save.
4. Below screen will appear. Click continue.
5. Enter the import parameter INPUT.
6. Go to export tab and enter export parameter OUTPUT as below.
7. Save and activate the function module.
8. Similarly, create the function module CONVERSION_EXIT_ZDATE_OUTPUT.
9. Enter the function group, short text and click save.
10. Below pop up will appear.
11. Enter the INPUT import parameter.
12. Enter the OUTPUT export parameter.
13. Now go to the source code tab, enter appropriate code here and activate the function module.
14. Now go to the transaction SE11, enter domain name and click on “Change” button.
15. Enter the conversion routine ZDATE and activate the domain.
16. If you double click on conversion routine ZDATE, it will present you with two FM’s, we created earlier, as below.
Output:
Go to the table contents.
Go to Settings->User Parameters.
Check the conversion exits check box, as below.
The table contents would look like:
So this way, we can create custom conversion routine and assign it to the domain.
No comments:
Post a Comment