CONVERSION ROUTINES are also called as CONVERSION EXITS.
In some cases SAP displays values differently then they the way they are stored.
For example while creating a Sales order the input value for the filed Order Type VBAK-AUART is actually 'OR' that is on the screen. Similarly for Partner functions like Sold-to Party the value is (SP) and for Ship-to Party it is (SH). These are basically the screen values. These values are stored differently internally.
This can be easily seen while creating a sales order using a BAPI.
If you use the BAPI ‘BAPI_SALESORDER_CREATEFROMDAT1’ and try to pass ‘OR’ for the field VBAK-AUART ie order type or pass SP and SH to Sold-to Party and Ship-to party respectively then you will get an error message. Please note that this happens only when you are trying to pass the values for your code. If you test the BAPI using a transaction SE37 then an automatic conversion takes place and you can pass the screen values. This is basically the CONVERSION ROUTINE. We will now see the way of finding the conversion routines in SAP. Also in some scenarios for custom development you may have to write your own conversion routines.
- CONVERSION_EXIT_xxxxx_INPUT
- CONVERSION_EXIT_xxxxx_OUTPUT
The conversion routine is usually associated with a Domain for that field. So when you enter values on the screen, and save the values the conversion exit is triggered. Similarly, while displaying the values on the screen another conversion routine gets triggered. The conversion routine associated with the domain also triggers when outputting the data on the screen with the WRITE statement.
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.
As mentioned earlier for every field that needs conversion there will be 2 conversion routines. For example for the Partner Function filed KNVP-PARVW there are 2 conversion routines associated with it namely
CONVERSION_EXIT_PARVW_INPUT
CONVERSION_EXIT_PARVW_OUTPUT
One of the ways to find a conversion routine is as follows.
Run transaction SE11 give the table name eg. KNVP.
Once the table fields are displayed double click on the filed for which you need to find the conversion exit eg. KNVP-PARVW.
Once the data element is displayed double click on the data-element to display the domain.
You will find the Conversion Exit under output characteristics double click on the conversion exit to display the function modules.
The conversion exit function modules have 2 Parameters one for INPUT and the other for OUTPUT. 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.
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.