cancel
Showing results for 
Search instead for 
Did you mean: 

Function SUBSTRING: parameter at position 1 has incorrect data type LCHR - CDS view

04-29-2019 10:55 AM
10254 views 7 comments
0 Likes
SAP Managed Tags
Subscribe

Dear,

I would like to fetch the first 10 values from the field edid4.sdata from the segment

where b.segnam = 'E1BPMEPOHEADER' and a.mestyp = 'PORDCR1'

Getting an error message "Function SUBSTRING: parameter at position 1 has incorrect data type LCHR"

Can you please advice "how to extract the values from the sdata of EDID4 table with LCHAR.

Regards

Praveen G.

0 Likes

Accepted Solutions (0)

Answers (4)

Answers (4)

shanthi_bhaskar
Active Contributor

You cannot use the EDID4 in the CDS directly. You need to create Table function and call the SAP Standard Method there. and then use the table function in the CDS view

GET_EDID4_DATA

Thanks,

SB.

guna91
Explorer
0 Likes

Hi Shanti,

I have created a similar CDS table function. But when I join it with my CDS, it does not allow me to have multiple document numbers(invoice number, Sales Orders, PO etc). All these fields have been fetched using substring on Sdata field. Not sure why its not allowing me to display 3 documents. Can you please guide me here?

shanthi_bhaskar
Active Contributor

Use below code

substring(cast(B.sdata as abap.char( 1000 )), 1,10) as ApplicationData
srikanthnalluri
Active Participant
0 Likes

shanthi.bhaskar CAST is not supported for the type LCHAR.

I am on "SAP_ABA - Release 740 and SP-Level 0017", Does it support in any further releases.

marco_ignazzi002
Explorer
0 Likes

You are a genious and I hate CDS.

Sijin_Chandran
Active Contributor

Hi,

Can you use CAST SQL operation and convert the LCHR type to a String value and then try to use Substring operation ?

Thanks,

Sijin

MisaqTonse
Explorer
0 Likes

Hi Praveen,

This can be achieved with the help of table function.

As per SAP documentation we cannot use LCHR in cast function (ABAP CDS limitation).

https://launchpad.support.sap.com/#/notes/0002752176

I would definitely suggest trying table function to address this issue. We can use substr in the method.

return select A.mandt,
    A.docnum,
    A.idoctp,
    A.mestyp,
    B.dtint2,
    B.sdata,
    substr(B.sdata, 1,10 )  as SubStringData from  edidc A
left outer join edid4 B on A.docnum = B.docnum
and A.idoctp = B.segnam

Hope this help 🙂