‎2006 Dec 12 1:26 PM
Hello people,
Is there a function module to convert a string into the tabel TLINE of the function module SAVE_TEXT?
C14W_STRING_TO_TLINE converts a character into tline, but not a field of the type string.
thanks for any ideas.
maggie
‎2006 Dec 12 1:30 PM
Could you move your string into a very big TYPE C field?
report zrich_0001.
data: tline type table of tline with header line.
data: str(1000) type c.
str = 'This is the string that we pass to the function module'.
call function 'C14W_STRING_TO_TLINE'
exporting
i_string = str
tables
e_tline_tab = tline.
loop at tline.
write:/ tline.
endloop.
This works.
Regards,
Rich Heilman
‎2006 Dec 12 1:30 PM
Could you move your string into a very big TYPE C field?
report zrich_0001.
data: tline type table of tline with header line.
data: str(1000) type c.
str = 'This is the string that we pass to the function module'.
call function 'C14W_STRING_TO_TLINE'
exporting
i_string = str
tables
e_tline_tab = tline.
loop at tline.
write:/ tline.
endloop.
This works.
Regards,
Rich Heilman
‎2006 Dec 12 1:30 PM
hi Hans,
Declare a variable of type c and pass that string variable in to that char and pass that to the specified function module ..
i.e, data : v_char(100) type c,
v_str type string.
v_char = v_str.
‎2006 Dec 12 1:33 PM
I am not sure, but try FORMAT_TEXTLNES.
Else, you can simply write the logic to split at specific no, of characters and append to a line of the table.
LOOP.
LINE = STRING+M(N).
APPEND LINE.
M = M + N.
--- You just need to take care of the last part of the string so that it doesn't give you a short dump when M goes beyond the length of the string and that is when you exit out of the loop, other wise its a infinite loop.
Regards,
Ravi
Note - Please mark all the helpful answers
‎2006 Dec 12 1:34 PM
Hi hans,
1. String----> Internal table (of any kind, of any length)
2. use this fm
SCMS_STRING_TO_FTEXT
regards,
amit m.
‎2006 Dec 12 1:38 PM
Hi ,
I don't know a Function module,
but i alway go this way:
ls_line -tdformat = '*'.
ls_line-tdline = gs_data.
i_len = strlen( ls_line-tdline )
while i_len > 1.
append ls_line to lt_lines.
shift gs_data by 132 places.
ls_line -tdformat = '*'.
ls_line-tdline = gs_data.
i_len = strlen( ls_line-tdline )
endwhile.
br
Werner
‎2006 Dec 12 2:41 PM
Thanks for your help so far, but I want to keep the layout of the text, so just splitting the text at a certain length into a character is not good enough.
eg if my text looks like:
"
- text 1
- text 2
- text 3
"
I may not have as result "- text 1 - text 2 - text 3'.
I don't know how to detect a new begin of line when splitting the string into different characterfields in order to supply my tline table.
thanks again!
‎2011 Sep 13 6:09 PM
Function VB_CP_CONVERT_STRING_2_ITF is what you are looking for.
‎2012 Oct 22 7:54 AM
IMO Tim's answer (VB_CP_CONVERT_STRING_2_ITF) is the better answer because C14W_STRING_TO_TLINE does not produce lines formatted with * but keeps newlines inside single table lines so you get ## appearing. Also, Tim's function accepts a string directly - double bonus!
‎2020 Apr 07 8:39 AM
‎2022 Sep 22 3:27 PM
This will work but...
It will mask characters like & to <(>&<)>. So if your requirement is to have text without the masks it could be an issue.
Regards,
Ron