Search code examples
abapdynpro

Formatting duration for display


In a SAP database there are values formatted as PxDTyH where x is the number of days and y is the number of hours. A value like P2DT0H is 2 days + 0 hours. I can see that via SE16:

Data in database, screenshot from SE16

Unfortunately, this is exactly displayed like that to the user, "3" corresponds to the index in the database (not seen in the screenshot above). Time displayed to user

I'd like to see it displayed

  • without the index (changing the options "show keys within drop-down lists" did not have an effect)
  • instead of the technical name P2DT0H I'd like to see "2 days and 0 hours" (or similar)

Is there a way to process the data before it gets displayed in the combo box? The developers can't change the format in the database because it would change the API.

FYI: I'm just a tester, I don't know how to code in ABAP, but from knowledge of other programming languages, I'd say that the data can be converted before it's displayed. I don't need a fully-fledged answer, just a pointer to a SAP hook or event which enables writing a conversion function.


Solution

  • Probably, conversion routines can be an option for you. What you should do is to:

    1. Take your domain (which is used for PxDTyH values) or create new one specially for this.
    2. Create FM with name CONVERSION_EXIT_%NAME%_OUTPUT, and put conversion logic in there. Mandatory parameters INPUT and OUTPUT should exist.
    3. Enter the %NAME% into Convers.routine field in domain properties.
    4. Enable Check conversion exits checkbox in user parameters.

    More info is here.