Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Concatenate in CDS

Former Member
0 Likes
59,476

Hi,

I am creating CDS view and i have requirement like below.

I have one field suppose 1200 and other field is TEXT

The output should be 1200-TEXT

I am using concat(1200, '-', TEXT) but its not accepting.

Thanks,

Charu

Message was edited by: Jasmin Gruschke

1 ACCEPTED SOLUTION
Read only

amol_samte
Contributor
30,143

Hi,

You do it by this way....

(1200, concat('-', TEXT) ) as Column_Name,

-Amol

6 REPLIES 6
Read only

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
30,143

Hi Charu,
please have a look at the ABAP Language Documentation (ABAP Keyword Documentation).

CONCAT(arg1, arg2) only takes two arguments, so you might need to use the function twice like CONCAT(arg1, CONCAT(arg2, arg3)).

Best,

Jasmin

Read only

0 Likes
30,143

hi Jasmin, on the concat function itself, is there anyway to get a space/blank character between string values?

e.g. this strips out the blank space, is there anyway to protect it/force it in?


concat(b.mc_name1,concat('  ',b.mc_name2)) as mc_fname

Even the replace function won't inject it below, the concat does add it in the '-' value, but the replace strips it out. Not sure if that's correct?


       replace(concat(b.mc_name1,concat('-',b.mc_name2)),'-',' ') as mc_fname

Thanks,

Sean.

Read only

30,143

This would place a blank between Part_1 and Part_2:

REPLACE

( CONCAT( CONCAT( 'Part_1', '- -' ), 'Part_2' ), '-', '' )

Read only

0 Likes
30,143

hi Christian, Yes.. it does. Nice workaround. Thank you for that.

It would be nice to see the pipe | for concat similar to what we have on the HANA db, more flexible that the two argument concat function in cds. But for now, this helps me out, so thanks again.

Sean

Read only

0 Likes
30,143

Top Workaround!!

BR Bernd

Read only

amol_samte
Contributor
30,144

Hi,

You do it by this way....

(1200, concat('-', TEXT) ) as Column_Name,

-Amol