Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

From string to tline

Former Member
20,397

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

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
8,717

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

10 REPLIES 10
Read only

RichHeilman
Developer Advocate
Developer Advocate
8,718

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

Read only

Former Member
0 Likes
8,717

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.

Read only

Former Member
0 Likes
8,717

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

Read only

Former Member
0 Likes
8,717

Hi hans,

1. String----> Internal table (of any kind, of any length)

2. use this fm

SCMS_STRING_TO_FTEXT

regards,

amit m.

Read only

Former Member
0 Likes
8,717

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

Read only

Former Member
0 Likes
8,717

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!

Read only

Former Member
8,717

Function VB_CP_CONVERT_STRING_2_ITF is what you are looking for.

Read only

0 Likes
8,717

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!

Read only

0 Likes
8,717

Here's a good one - CONVERT_STREAM_TO_ITF_TEXT

Cheers.

Read only

0 Likes
8,717

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