04-19-2022 11:46 AM
I would like to create a CDS that provides a template for creating CDS from tables.
For this purpose, I would like to remove the spaces in database field dd04t.scrtext_l (long text of fields).
How can I do this?
The simple
replace( dd04t.scrtext_l, ' ', '' )
does not work. Maybe the "trailing spaces" in the second argument are removed.
Backquotes to preserve the space are not allowed.
Workarounds like the following also did not work:
Is there no way to do this in CDS? (Of course, I can always use ABAP.)
Update: I published the ABAP report for the task here:
Utility Report to provide the long field names when creating a new basic CDS | SAP Blogs
04-19-2022 3:44 PM
sandra.rossi :
1) would you mind explaining how exactly you searched ? I did not find anything related to removing spaces in core data services
2) the approach with char(32) did not work for me (syntax error). Did you mean
cast( '' as abap.char( 32 ) ) ,
?
That also did not work
04-19-2022 7:11 PM
I'm so sorry, I completely missed that your question was about CDS, and I was looking at SQL/SQLScript/AMDP (in SQL, replace also didn't work for removing spaces, the SQL function CHAR(32) worked), so please forget my previous comment. I just deleted it to not confuse future readers.
04-19-2022 8:19 PM
In fact, just thinking again, if we create a CDS Table Function whose AMDP does REPLACE( dd04t.scrtext_l, char(32), '' ) (here CHAR(32) OR NCHAR(32) will work, being a HANA SQL function), I think it should work.
04-22-2022 8:08 PM
Are you talking about leading or trailing spaces and other characters? What kind of value is it?
Try these keywords see which one fulfills your requirement- LTRIM or RTRIM, LEFT, RIGHT
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abensql_functions_string.htm
04-26-2022 2:20 PM