Today one of the member of our telegram group aked how to display the negative sign of a value at the beginning instead of at the end and keeping the possibility to make get total and subtotal of the column. I never had such kind of request, so I needed to investigate on how to solve this quest.
Request for the test:
- Find a way to display the negative sign in front of the value
- Make sure that decimal notation of the user will still work
Question and decision how to implement:
- Can it be solved using standard functions?
- No, neather fieldcatalog nor ALV layout can handle this request.
- Must be developed here?
- Yes, we need a conversion routine. This means we have to create a functiongroup and two functionmodules
Index of implementation steps
- Thinking about the requirement and the difficulties while implementing.
- Creating a conversion routine.
- Creating functiongroup
- Creating functionmodule internal -> display
- Creating functionmodule display -> internal
- Activating new functiongroup and functionmodules
- Implementing the conversion routine
- Demo report
- Result
Implementation steps
Info: I haven’t included popup with warning and package assignment. I ignored all warnings that happened in this sample and I assigned all objects to the local package $TMP.
- Thinking about the requirement and the difficulties while implementing.
- Creating a conversion routine.
- CONVERSION_EXIT_xxxxx_INPUT
- CONVERSION_EXIT_xxxxx_OUTPUT
- Creating functiongroup
- Creating functionmodule internal -> display
- Creating functionmodule display -> internal
- Activating new functiongroup and functionmodules
- Implementing the conversion routine
- Implementing conversion routine to domain
- Implementing at runtime to ALV
- Demo report
- Result
- The fourth column “Unrestricted” doesn’t have conversion routine set, so the negative sign is at the end
- The fifth column “Unrestricted” has conversion routine set, so the negative sign is at the beginning as expected
- The sixth column “Assembly level” is an integer field and has conversion routine set, so the negative sign is at the beginning as expected
When implementing a conversion routine we have to think about on how to keep the number notation that the user have in the settings (TAC:SU01/SU3). This means that we have to create flexible EDIT MASKS in the output conversion routine
A conversion routine is identified by its five-place name (custom conversion routine should start with Y or Z) 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:
To create the functiongroup, I use transaction SE37. Leave the Funtion Module field blank and navigate to menu->Goto->Function Groups->Create Group
Enter a name and the description for the group and Save.
Naviagte to the topinclude of the functiongroup and paste the code:
An error has occurred. Please try again later. |
In the initial screen of SE37 enter a name for the functionmodule “CONVERSION_EXIT_XXXXX_OUTPUT” replace XXXXX with the routine name you wish.
Assign the functionmodule to the new functiongroup, enter a Short text and Save.
It is needed to name one importing parameter INPUT.
It is needed to name one exporting parameter OUTPUT.
An error has occurred. Please try again later. |
An error has occurred. Please try again later. |
In the initial screen of SE37 enter a name for the functionmodule “CONVERSION_EXIT_XXXXX_INPUT” replace XXXXX with the routine name you wish.
Assign the functionmodule to the new functiongroup, enter a Short text and Save.
It is needed to name one importing parameter INPUT.
It is needed to name one exporting parameter OUTPUT.
For error handling if user enters a non numeric value it is needed to name the exception parameter ERROR_MESSAGE.
An error has occurred. Please try again later. |
An error has occurred. Please try again later. |
Now we need to activate the functiongroup and the functionmodules.
Create a new domain or copy an existing domain and assign the new conversion routine to it and activate it.
In the demo report you can find how you can implement the conversion routine at runtine to ALV.
Here is a small demo report on how you can use it.
An error has occurred. Please try again later. |
An error has occurred. Please try again later. |
Here you can see the result of the development.