Concatenate SAP construct in ABAP is used to combine multiple strings into one. There are several options for using this design in SAP systems. In this article I will tell you how to use the old version of string concatenation ABAP and what possibilities of using this construct have appeared in the new syntax ABAP 7.4.

Example Concatenate SAP in old syntax
Sometimes you need to modify old syntax and therefore you need to know how the Concatenate in SAP before 7.4 construct is implemented.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
DATA: lv_url TYPE string. " Old ABAP without space CONCATENATE 'ABAP' '-' 'BLOG' '.COM' INTO lv_url. WRITE:/ lv_url. " Result: ABAP-BLOG.COM DATA: lv_title TYPE string. " Old ABAP with space CONCATENATE 'BLOG' 'ABAP' 'FROM' 'ARTUR' INTO lv_title SEPARATED BY space. WRITE:/ lv_title. " Result: BLOG ABAP FROM ARTUR |
Concatenate in new ABAP 7.4
Next we will consider how the ABAP string concatenation design has changed in the new syntax and what new opportunities it gives us. The new ABAP syntax gives more possibilities and adds simplicity and beauty to the code. Whenever possible, I try and recommend using the new ABAP syntax. For example using Concatenate for adding lidding zeros.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
"New ABAP without space DATA(lv_url2) = |ABAP| & |-| & |BLOG| & |.COM| . WRITE:/ lv_url2. " Result: ABAP-BLOG.COM "New ABAP with space DATA(lv_title2) = |BLOG| & | ABAP | & |FROM| & | ARTUR| . WRITE:/ lv_title2. " Result: BLOG ABAP FROM ARTUR DATA(lv_title3) = |BLOG| & | | & |ABAP| & | | & |FROM| & | | & |ARTUR| . WRITE:/ lv_title3. " Result: BLOG ABAP FROM ARTUR " New ABAP syntax using variables DATA(lv_blog) = |BLOG|. DATA(lv_from) = |FROM|. DATA(lv_title4) = |{ lv_blog } ABAP { lv_from } ARTUR|. WRITE:/ lv_title4. " Result: BLOG ABAP FROM ARTUR DATA(lv_title5) = |{ lv_blog } | & |ABAP| & | { lv_from } | & |ARTUR|. WRITE:/ lv_title5. " Result: BLOG ABAP FROM ARTUR |
As a result, we see that using the new syntax is a more concise and understandable notation, the ability to declare a variable at the time of use, and the additional ability to combine spaces when using string concatenation.
Other articles related to this: