Application Development 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: 

Concatenate in CDS

Former Member
0 Kudos

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

amol_samte
Contributor

Hi,

You do it by this way....

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

-Amol

6 REPLIES 6

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert

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

0 Kudos

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.

This would place a blank between Part_1 and Part_2:

REPLACE

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

0 Kudos

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

0 Kudos

Top Workaround!!

BR Bernd

amol_samte
Contributor

Hi,

You do it by this way....

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

-Amol