cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace double quotes with single quote in AMDP ?

BhargavaReddy
Active Participant
0 Kudos

Hello Folks,

How to replace double quotes " with single ' quotes in AMDP?

I tried this way SELECT REPLACE (:lv_String, '"', '''') "replace" FROM DUMMY; but it's not worked for me, getting below error.

String is '( Material EQ "RMME03" OR Material EQ "RM122" )'

Expecting result is `( Material EQ 'RMME03' OR Material EQ 'RM122' )`.

is there any ways? could you please help me on this?

Thanks & Kind Regards,

Bhargava

former_member362452
Participant
0 Kudos

Please look at this SAP HANA academy tutorial and use this with replace function to achieve your

https://www.youtube.com/watch?v=Oa1jMwnfjs8

Thanks

Abhishek Shanbhogue

Sandra_Rossi
Active Contributor

abhishek_s32 This video is about ESCAPE_SINGLE_QUOTES (' characters are doubled) and ESCAPE_DOUBLE_QUOTES (" characters are doubled), it's not about replacing " with '...

Sandra_Rossi
Active Contributor
0 Kudos

Adding the screenshot of the OP concerning the error:

Accepted Solutions (1)

Accepted Solutions (1)

Sandra_Rossi
Active Contributor

The error message doesn't say that you have an error with REPLACE, it says that the filter in APPLY_FILTER is invalid:

SQLScript APPLY_FILTER: Invalid filter: '( Mat EQ ''A'' OR Mat EQ ''B'' )'

Probably it's because EQ is invalid in SQL for HANA. Use = instead:

( Mat = 'A' OR Mat = 'B' )

Note that maybe you were distracted by the presence of consecutive single quotes in the error message which made you think that HANA considers two single quotes, but in fact I guess it's just doubled for the output of the error message because if you had used a literal instead of a variable for APPLY_FILTER, you would have entered with two consecutive single quotes, like this:

result = APPLY_FILTER( tablename, '( Mat = ''A'' OR Mat = ''B'' )' )
BhargavaReddy
Active Participant

Hi Rossi,

Yes, you are right.

I just found out that after my detailed debugging 😥.

Anyway thanks for the your response.

Thanks,

Bhargava

Answers (0)