Friday 1 April 2022

Advanced String Manipulations with ABAP CDS Views

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.

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP

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.

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP

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

SAP ABAP CDS Views, SAP ABAP Exam Prep, SAP ABAP Career, SAP ABAP Skills, SAP ABAP Jobs, SAP ABAP

Source: sap.com

No comments:

Post a Comment