5 Replies Latest reply: Mar 15, 2007 10:17 AM by Mijesh Mohan RSS

Conversion Routine

shinu mol
Currently Being Moderated

hi

wht is a conversion routine?

  • Re: Conversion Routine
    Sudheer Junnuthula
    Currently Being Moderated

    Hi,

    A conversion routine conv is represented by two function modules that adhere to the naming convention CONVERSION_EXIT_conv_INPUT|OUTPUT. In these function modules, no statements can be executed that interrupt the program flow or end a SAP LUW. A conversion routine can be assigned to a domain in the ABAP Dictionary. If a screen field refers to a domain with a conversion routine, the system automatically executes the function module ..._INPUT for every input in the relevant screen field and the function module ..._OUTPUT when values are displayed in this screen field and uses the converted content in each case. If a data object refers to such a domain, the function module ..._OUTPUT is executed for the output of the data object in a list and the converted content is displayed.

     

    Regards

    Sudheer

  • Re: Conversion Routine
    Ravi Shankar
    Currently Being Moderated

    Hi,

     

         Some of the data stored in SAP Tables will be in different format from the external data that we see. So to convert the external data into internal format we use conversion routines. Hope u got the answer. Pls reward points accordingly.

     

    Regards,

    Ravi

  • Re: Conversion Routine
    Kasinath Babu
    Currently Being Moderated

    Hi,

     

    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:

     

    CONVERSION_EXIT_xxxxx_INPUT

    CONVERSION_EXIT_xxxxx_OUTPUT

    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  flight model contains information about the flights offered by the carriers. The time for each flight is recorded in field FLTIME. Enter and display the time of the flight in input templates in the form HHH:MM (hours:minutes). Store the flight time entered in the database as an integer number (number of minutes of the flight). An entry 3:27 is therefore stored in the database as 207 (3 hours, 27 minutes = 207 minutes).

     

    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.

     

     

    Regards

    Kasinath.

  • Re: Conversion Routine
    Mijesh Mohan
    Currently Being Moderated

    This is an old document....But it could help you out..

     

    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:

     

    CONVERSION_EXIT_xxxxx_INPUT

    CONVERSION_EXIT_xxxxx_OUTPUT

    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 flight model contains information about the flights offered by the carriers. The time for each flight is recorded in field FLTIME. Enter and display the time of the flight in input templates in the form HHH:MM (hours:minutes). Store the flight time entered in the database as an integer number (number of minutes of the flight). An entry 3:27 is therefore stored in the database as 207 (3 hours, 27 minutes = 207 minutes).

     

    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.

Actions