Reprint and learn it, just use it, thank you.
DATA ts TYPE TABLE OF string.
ts = VALUE #( ( 'A' ) ).
The problem that will report an error is a type conflict.
So I re-understand char and string, several symbols of string operation.
First of all, ABAP defines string as: a text string literal, which is a deep structure. The char type is defined as A text field literal, which is a regular structure.
Let's analyze the difference between ``'' first, and we can know from the abap keyword document query:
Syntax | Name | Possible Characters |
'...' | Text field literal | String of any alphanumeric characters. The data type is c with the length of the enclosed characters (including trailing blanks). |
`...` | Text string literal | String of any alphanumeric characters. The data type is string. A text string literal can have a maximum of 255 characters. |
It can be seen from the above that the original meaning of '' is to create a c type, so our commonly used string = ''. In fact, it is not standardized, this is to create a C type forcibly assigned to string, the normal writing should be string = ``.
Of course, our requirements for the ABAP program have always been usable...
Next is ||. The test shows that || can be used to create it. What is ||?
Initially I just used || to concatenate strings (it's easy to use) instead of &, and I never considered deep things.
This time I checked it carefully. I saw this sentence: new syntax form of string template |{}|
From the string template, we know that the purpose of this thing is to construct a string
The purpose of a string template is to create a new character string out of literal texts and embedded expressions.
A simple translation is, this thing is to create a new string with text and embedded expressions ({variables}).
In summary, we can use these three symbols more reasonably, so that our program becomes more standardized and beautiful.