‎2009 May 25 10:19 AM
Hi All,
I want to concatenate two or more strings using the CONCATENATE statement so that they are joined at new lines. Example -
If the code is :-
v_str1 = 'first line'.
v_str2 = 'second line'.
v_str3 = 'third line'.
"Required statement to concatenate v_str1, v_str2 and v_str3 into v_str.
WRITE:/ v_str.
Then the output is :
first line
second line
third line
‎2009 May 25 10:26 AM
I dont think you can do that way.
Try this way.
types: begin of ty_string,
string type string,
end of ty_string.
data: wa_string type ty_string,
t_string type table of ty_string.
wa_string-string = 'first line'.
append wa_string to t_string.similarly for others.
loop at t_string into wa_string.
write:/wa_strin-string.
endloop.Regards,
Shailaja
‎2009 May 25 10:26 AM
I dont think you can do that way.
Try this way.
types: begin of ty_string,
string type string,
end of ty_string.
data: wa_string type ty_string,
t_string type table of ty_string.
wa_string-string = 'first line'.
append wa_string to t_string.similarly for others.
loop at t_string into wa_string.
write:/wa_strin-string.
endloop.Regards,
Shailaja
‎2009 May 25 10:37 AM
CONCATENATE abc def xyz .... into abcd
SEPARATED BY CL_ABAP_CHAR_UTILITIES=>NEWLINE.use this...
NEWLINE separates the elements by a new line.
‎2009 May 25 10:38 AM
Hi,
Thanks for your reply. But I do not want to display the concatenated string using the WRITE statement. I need to store the concatenated string in a variable (say v_str in this case) and then display the value of v_str as MESSAGE v_str TYPE 'I'.
‎2009 May 25 10:41 AM
‎2009 May 25 10:45 AM
‎2009 May 25 10:49 AM
use POPUP_TO_INFORM
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = 'This is title'
txt1 = 'first line'
txt2 = '2nd line'
TXT3 = '3rd line'
* TXT4 = ' '
.
‎2009 May 25 10:27 AM
Hi,
Instead of concatenation; append them in an internal table and then loop on it and write the data.
Concatenate will not be able to write in the required format.
Alternatively what you can do is concatenate separated by space and then split at space into an internal table oftype string and the write the data by looping on the table.
Regards,
Ankur Parab
‎2009 May 25 10:27 AM
You cannot do like this using concatenate statment...either you write three write statement or put all strings in table and print.
regards
vivek
‎2009 May 25 10:30 AM
Hi,
If you have to display all strings in new lines, then what is the use of concatenate statement? why can't you write like this.
WRITE:/ v_str1,
/ v_str2,
/ v_str3.Regards
Vishnu Gupta
‎2009 May 25 10:38 AM
Hi Anirban,
Use the below code.
data: v_str1 type string value 'first line',
v_str2 type string value 'second line',
v_str3 type string value 'third line',
v_str type string.
concatenate v_str1 v_str2 v_str3 into v_str separated by ','.
WRITE:/ v_str.
clear: v_str1, v_str2, v_str3.
split v_str at ',' into v_str1 v_str2 v_str3.
write:/5 v_str1,
/5 v_str2,
/5 v_str3.
Regards,
Kumar Bandanadham
‎2009 May 25 10:50 AM
Hi,
DATA: V_STR1 TYPE STRING,
V_STR2 TYPE STRING,
V_STR3 TYPE STRING,
V_STR TYPE STRING.
CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.
CONSTANTS: CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>NEWLINE.
V_STR1 = 'first line'.
V_STR2 = 'second line'.
V_STR3 = 'third line'.
CONCATENATE V_STR1 CON_CRET V_STR2 CON_CRET V_STR3 INTO V_STR.
WRITE:/ V_STR.
‎2009 May 25 11:08 AM
Hi,
data: v_str1 type string value 'first line',
v_str2 type string value 'second line',
v_str3 type string value 'third line',
v_str type string.
data: v_text like POPUPTEXT occurs 10 with header line.
data: v_ans type char1.
v_text-topofpage = 'X'.
append v_text.
clear v_text.
v_text-topofpage = 'X'.
v_text-text = 'You want to proceed or not?'.
append v_text.
clear v_text.
v_text-topofpage = 'X'.
append v_text.
clear v_text.
v_text-text = v_str1.
append v_text.
v_text-text = v_str2.
append v_text.
v_text-text = v_str3.
append v_text.
CALL FUNCTION 'DD_POPUP_WITH_LIST'
EXPORTING
TITEL = 'Information'
LISTTITEL = 'Strings'
START_COLUMN = 1
START_ROW = 1
END_COLUMN = 50
END_ROW = 20
IMPORTING
ANSWER = v_ans
TABLES
lines = v_text
.
if v_ans = 'N'.
write:/ 'cancelled'.
else.
write:/ 'Proceed'.
endif.