Custom Conversion Routines in ALV Output

1
ALV

Conversion Routines are used to convert the values into internal or external format. In most of the cases Conversion Routines are assigned at Domain level. In this tutorial we will see how to create a custom Conversion Routine and use it to format the ALV output using ABAP code.

Let’s say we have a field ‘Creation_Date’ which is of type DATS in our global structure which we are using for ALV field catalog. Now by default this field will pick the users external date format and output the value in the ALV. With the help of Conversion Routine let’s see how can we can alter the output format of this field

Step – 1 Create a function group in custom namespace (Ex. Z_CONVERSION_EXITS)

Step – 2 Create 2 FM’s in this function group as below. Please follow the naming convention CONVERSION_EXIT_*****_INPUT or CONVERSION_EXIT_*****_OUTPUT . You can give any 5 Char name at the place of *’s. Ex. below:

CONVERSION_EXIT_ZDATE_INPUT

CONVERSION_EXIT_ZDATE_OUTPUT

Create 1 input parameter and 1 output in both the FM’s and write the logic as per your requirement.

Here is a sample logic to convert the date into DD/MM/YYYY format.

Now we have our Conversion Exit ZDATE ready.

STEP – 3 Use this exit in ABAP code to format the output.

In the code where we are generating the field catalog, we have to change the property CONVEXIT of the field ‘CREATION_DATE’ as below

That’s all. You have successfully created a custom conversion routine used it in your ABAP code to format the ALV output.

Leave a Reply

Your email address will not be published.

You may use these <abbr title="HyperText Markup Language">html</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

*