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

How to Convert String Data type to Table so I can use SAVE_TEXT Function

Former Member
0 Likes
11,532

Hello,  I have a requirement to take data stored in a string data type and then use the SAVE_TEXT function to store this data in a text object/id.  I know how to use the SAVE_TEXT function.  I just don't know how to take the data stored it in a string data type and convert it to the table format this function requires.

The String data is defined as:

user_comments TYPE STRING

The SAVE_TEXT_Function requires that the data be passed as a table with the TLINE structure data type.  The table has 2 fields:

- TDFORMAT   char2

-TDLINE           Char132

So somehow I need to break up the data in this user_comments field into 132 character pieces and store it in this table format.  There is probably an easy answer out their somewhere, but I have not been able to find it.  Does anyone have any suggestions/code examples?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,323

Try FM C14W_STRING_TO_TLINE

10 REPLIES 10
Read only

Former Member
0 Likes
7,323

Go to SE37 and look for FMs like *STRING*SPLIT* or *SPLIT*STRING*..

Rob

Read only

0 Likes
7,323

I previously looked at quite a few and some were obsolete, some would not run at all, some are more for Char types, some only split it into 2 lines etc. etc.

Read only

0 Likes
7,323

OK, if you can't find a FM, it should be fairly easy to do it yourself:

Start looking for a space at position 132 of the string and move back to the left until you find one. Positions 1 to the position of that space is your first line. Move the rest of the string to the left to position one and start again. You just have to be careful to stop once you reach the end.

Rob

Read only

0 Likes
7,323


thx Rob,  I had already thought of something like this and that will be my path forward if no one else has any ideas.  I was hoping to not have to do something like this though.  Surely there must be something out there in ABAP land.

Read only

0 Likes
7,323

I think you might be able call FM TEXT_SPLIT iteratively.

Rob

Read only

matt
Active Contributor
0 Likes
7,323

I've had to do this a few times and never found a better way than coding it myself.

Read only

VenkatRamesh_V
Active Contributor
7,323

Hi,

Try,

DATA: lv_data   type string value '123456#78910#11121315 ',

          lv_table  type table of string with header line initial size 0.

      

start-of-selection.

split  lv_data at  '#' into table lv_table.

Hope it  helpful.

Regards,

Venkat.

Read only

Former Member
7,323

Hi,

Try Function Module CONVERT_STREAM_TO_ITF_TEXT.

Do a where used and you will find examples of how to use it.

Regards,

Ron

Read only

Former Member
0 Likes
7,324

Try FM C14W_STRING_TO_TLINE

Read only

Former Member
0 Likes
7,323

thx to everyone for your replies.  My client has just changed his mind on a few things and this is no longer a requirement, so I won't need to explore this further.