‎2016 May 18 8:29 PM
Is there any equivalent in ABAP CDS for string_agg function from HANA SQLScript?
Or there is a way using CDS to accomplish transformation of rows into a concatenated string?
I saw that there is a possibility to create a CDS table function implemented by an AMDP but i didn't see any example of calling this cds table function from another CDS view. Is this possible? Can somebody help me with an example?
Note:
string_agg - concatenates rows into a string separated by a delimiter
‎2016 Jul 28 8:38 PM
Hi Mustafa,
The only solution is to implement the query in a AMDP using string_agg.
This amdp method can be explosed by table function in CDS.
This table function can be called from a CDS view.
Here is an example:
AMDP:
METHOD GET_CONCAT BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING
/TABLE
RETURN
select
mandt,
key,
STRING_AGG( field) AS concat
from "TABLE"
group by mandt, key
ENDMETHOD.
CDS TABLE FUNCTION:
define table function tf_concat
returns {
mandt : syst_mandt;
key : raw
concat : abap.sstring( 1333 );
}
implemented by method
AMDP=>GET_CONCAT;
CDS VIEW:
define view v_concat
as select from tf_concat{
mandt,
key,
concat
};
Best regards,
Andrei
‎2016 Jul 28 12:15 AM
Hi Andrei;
i have the same issue. did u find any solution to this
thanks
‎2016 Jul 28 8:38 PM
Hi Mustafa,
The only solution is to implement the query in a AMDP using string_agg.
This amdp method can be explosed by table function in CDS.
This table function can be called from a CDS view.
Here is an example:
AMDP:
METHOD GET_CONCAT BY DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT OPTIONS READ-ONLY USING
/TABLE
RETURN
select
mandt,
key,
STRING_AGG( field) AS concat
from "TABLE"
group by mandt, key
ENDMETHOD.
CDS TABLE FUNCTION:
define table function tf_concat
returns {
mandt : syst_mandt;
key : raw
concat : abap.sstring( 1333 );
}
implemented by method
AMDP=>GET_CONCAT;
CDS VIEW:
define view v_concat
as select from tf_concat{
mandt,
key,
concat
};
Best regards,
Andrei
‎2016 Jul 28 9:26 PM