2023 Feb 14 7:18 PM
Hi,
*Code for string concatenation.
DATA: S5, S6 TYPE STRING.
S5 = 'SAP'.
S6 = 'ABAP'.
WRITE / S5 && S6.
OUTPUT: SABAP
WHY ONLY FIRST CHARACTER OF STRING 'S5' IS CONCATINATED WITH STRING 'S6' ?
PLEASE EXPLAIN.
THANK YOU.
2023 Feb 14 7:43 PM
You'd better use the debugger. You would see that the issue is not with && but with DATA (how you used it).
You need to learn the effect of the comma and the effect of declaring a variable without an explicit type (implicit typing):
DATA: S5, S6 TYPE STRING.
2023 Feb 14 7:18 PM
Thank you for visiting SAP Community to get answers to your questions.
As you're looking to get most out of your community membership, please consider include a profile picture to increase user engagement & additional resources to your reference that can really benefit you:
I hope you find this advice useful, and we're happy to have you as part of SAP Community!
All the best,
Alex
2023 Feb 14 7:43 PM
You'd better use the debugger. You would see that the issue is not with && but with DATA (how you used it).
You need to learn the effect of the comma and the effect of declaring a variable without an explicit type (implicit typing):
DATA: S5, S6 TYPE STRING.
2023 Feb 15 6:26 AM
or use the good quote
data(S5) = `SAP`.<br>data(S6) = `ABAP`.<br>WRITE / S5 && S6.
2023 Feb 15 1:41 PM
2023 Feb 28 6:18 AM
Hi Sandra Rossi,
DATA: S5, S6 TYPE STRING.
Here Object S5 is not a STRING data type.
By default S5 is declared as a Character data type and hence S5 can store only single character.
This was the reason why I was getting the Warning: The VALUE specification is longer than the corresponding field. The VALUE specification will only be passed to the field length!
I thought that, I must declare S5 as a character array by specifying its length to store multiple characters such as:
DATA: S5(5), S6 TYPE STRING.
I corrected my mistake by self learning. If my understanding is still wrong, please correct me.
Thank You.
2023 Feb 28 12:23 PM
kk_india_2023 I'm glad to see that you have solved the issue. Yes you're right in everything you said. Congrats and thanks for the feedback 😄
For information, concerning S5(5), the trend is to avoid this short syntax form and to use the explicit longest one S5 TYPE C LENGTH 5.
(ABAP documentation says: "For reasons of legibility, it is best to include all information and always use the addition LENGTH instead of parentheses to specify the length len.")
2023 Feb 28 1:55 PM
Hi Sandra Rossi,
Yes I will follow the explicit longest syntax. Thanks a lot for correcting my mistakes. 😄
Best Regards,
KIRANKUMAR