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: 

Can you define "single quote" character as a constant

Former Member
0 Kudos

Hello all,

I want to do something like this:


CONSTANTS: q type c value ' .   " << thats a single quote character
DATA: final_string type string,
          VAL1(12) type c,
          VAL2(12) type c. 

concatenate q val1 '-' val2 q into final_string. . 

How can I define the single quote character as a constant?

Thanks

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Ed,

FAQ.

You can declare single quote as constant

If you are aware for single quote (') SAP uses an escape character which is the single quote itself('). Hence for every single quote you have to add an additional single quote.

CONSTANTS: q type c value ''''.

Suhas

7 REPLIES 7

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Ed,

FAQ.

You can declare single quote as constant

If you are aware for single quote (') SAP uses an escape character which is the single quote itself('). Hence for every single quote you have to add an additional single quote.

CONSTANTS: q type c value ''''.

Suhas

Former Member
0 Kudos

A more elegant and better looking way of declaring quotes


CONSTANTS: q type c value `'`.

Vikranth

0 Kudos

Hello Vik,

If you read Rainer's blog on character v/s string processing,

' ' => character processing, ` ` => string processing.

I forgot about this Anyways i have even more elegant solution,

Declare ' as a text-symbol 😄

Suhas

Former Member
0 Kudos

Yes.

A co-worker suggested this also ... shortly after I posted the question

I even got to do exactly what I wanted. like this:


data: q type char1. 
data: final_string type string, 
         val1 type string, 
         val2 type string. 

concatenate q val1 val2 q into final_string. 

Thanks to all for your replies.

Former Member
0 Kudos

egads. I left off the most important part

I set


q = text-q01

Former Member
0 Kudos

Hello Suhas,

could you give the URL to that blog of Rainer's? I haven't been able to find it.

Thanks,

Sebastian

0 Kudos

Hello Seb,

There you are : [/people/rainer.hbenthal/blog/2009/09/22/strings-chars-and-traps|/people/rainer.hbenthal/blog/2009/09/22/strings-chars-and-traps]

Also check Rainer's blog on ALV - SOS.

BR,

Suhas