Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
uladzislau_pralat
Contributor
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.


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.






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


 

 
5 Comments
shanthi_bhaskar
Active Contributor
Good one, Thanks documenting.
Yes, really good idea to use conversion exit to format string using CDS views!!!
NooruBohra
Participant
0 Kudos

I think it's the feature of ALV and not the CDS View. I tried to display the data in Data explorer it didn't work.

I'm on 1909 and I'm in similar situation. While in ABAP the conversion exit is triggering but in CDS it's not.

define view zprep_message1
as select from zprep_message
{
msgnr,
text,
msg,
case when msgnr = '022'
then cast( ltrim(msg, ' ') as zde_message_text )
else cast( ltrim(msg, ' ') as zde_message_text ) end as Message
}

 

 

PabloAmburi
Explorer
0 Kudos
Hi!

This is a good idea, but unfortunately when you publish the CDS to use it as an OData service, it doesn´t work, not only the conversion is not executed but also when retrieving the metadata it returns an error. Please consider before using it for string manipulation in FIORI apps.

Thanks!
uladzislau_pralat
Contributor
Hi Pablo,

thank you for interest in my blog. Fiori apps of use of CDS view string manipulation is beyond the scope of the blog. If you find a solution to your requirement, please share with SAP community.

Regards, Uladzislau
Labels in this area