Let's concatenate
2015-01-05
We start with two variables:
DATA word1 TYPE string.
DATA word2 TYPE string.
DATA: phrase TYPE string.
word1 = ‘this’.
word2 = ‘that’.
And we want to concatenate them adding the word “plus” between them and, of course, separate them by space.
Form 1 (the classic):
CONCATENATE word1 ‘plus’ word2 INTO phrase SEPARATED BY space.
Form 2, which doesn’t leave a space between them:
phrase = word1 && ‘ ‘ && 'plus' && ‘ ‘ && word2.
Form 3, more far fetched but which separates the words:
phrase = word1 && ‘ALT+255‘ && 'plus' && ‘ALT+255‘ && word2.
(in which ALT+255 is really pressing ALT and then writing 255) (it isn’t really a space but it looks the same)
Forma 4, the state of the art in concatenation:
phrase = | { word1 } plus { word2 } |.
Actually, this last one even lets you invoke methods directly:
phrase = | { o_book->get_word( 1 ) } plus { o_book->get_word( 2 ) } |.
Thank you Ricardo Monteiro for the ALT+255 trick and Sérgio Fraga for showing us the future. Thank you halfrain for the photo.
Greetings from Abapinho.