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: 

comparison value of LIKE condition must be a character-type literal issue in ABAP CDS Views

durgaprasanth_vemula
Participant
0 Kudos
6,743

1) In the Below ABAP CDS View I have the column 'value' where i have some Data

2)In the below another ABAP CDS View I highlighted the column 'ItemText' which i have Data

3) Now My Requirement is that I need to develop another ABAP CDS View where I need to fetch only the records from the second ABAP CDS View which contains the data 'ItemText' column and the 'value ' column in the first ABAP CDS View and I cannot use the LIKE operator because I am getting error "comparison value of LIKE condition must be a character-type literal issue in ABAP CDS Views". please find the below screen shot and could any one please tell me how to handle this.

8 REPLIES 8

Sandra_Rossi
Active Contributor
0 Kudos
4,176

You probably used a STRING type for your Z column, right?

durgaprasanth_vemula
Participant
0 Kudos
4,176

Hi Sandra,

Please find the screen shot as i am using Data Type Char.

MateuszAdamus
Active Contributor
0 Kudos
4,176

Have you tried changing the condition columns' places? Like this:

JOIN zi_zdta_ruletext AS _sgtxt ON _sgtxt.bukrs = zacdoca.CompanyCode AND zacdoca.ItemText LIKE _sgtxt.value

Kind regards,
Mateusz

durgaprasanth_vemula
Participant
0 Kudos
4,176

Hi Sandra,

I have tried by changing the column but the issue is same

he same. please find the attached screen shot.

MateuszAdamus
Active Contributor
0 Kudos
4,176

I see.

In this case try putting the LIKE condition in the WHERE clause.


Kind regards,
Mateusz

durgaprasanth_vemula
Participant
0 Kudos
4,176

Hi,

I am getting the same issue in Where condition also

Jelena_Perfiljeva
Active Contributor
4,176

Please see answer to this question: https://answers.sap.com/questions/401634/how-can-one-select-data-similar-to-sql-where-like-.html

I found it by copy-pasting the message text from your post into Google search.

rowieforms
Participant
0 Kudos
4,176

Hi Durga,

you can't use LIKE in where condition in the view directly using parameters. It only allows literals (example below):

CHAR literal: 'example'

NUM literal: 456

To achieve your requirement you can create a table function and in the class implementation, you can put a nested select in the where condition.

Thanks,

Rowie