5

Advanced String Manipulations with ABAP CDS Views

 2 years ago
source link: https://blogs.sap.com/2022/03/31/advanced-string-manipulations-with-abap-cds-views/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
March 31, 2022 1 minute read

Advanced String Manipulations with ABAP CDS Views

0 4 564

ABAP CDS views provide a set of string functions and also support regular expressions from release 7.55. But sometimes your string manipulation requirements go beyond aforesaid capabilities. In this case my blog is for you.

Below is a perfect example, when CDPOS values which are saved as a plain text need to be properly formatted.

Advanced-String-Manipulations-with-ABAP-CDS-Views.png

Number, percentage and date values need to be identified as such and formatted accordingly. What makes it even more challenging is a requirement to format numbers and dates as per user settings. All above can easily be done using data element casting.

Advanced-String-Manipulations-with-ABAP-CDS-Views-2.png

Advanced-String-Manipulations-with-ABAP-CDS-Views-3.png

Advanced-String-Manipulations-with-ABAP-CDS-Views-4.png

Advanced-String-Manipulations-with-ABAP-CDS-Views-5.png

Advanced-String-Manipulations-with-ABAP-CDS-Views-7.png

Below function module does the trick. If identifies amounts, percentage and date values using regular expressions and format them according to user settings.

Advanced-String-Manipulations-with-ABAP-CDS-Views-6.png


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK