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

split string into several lines, considering word borders

daniel_humberg
Advisor
Advisor
0 Likes
4,841

I have a string that I want to break into several lines.

The line length in my case shall be 72 characters.

Of course, I only want to break at the word borders (so only at a blank between two words).

Technically, I want to convert the string into a string table, and each string in the table shall only be longer that 72 characters, if there is no space in that part of the string.

Is there any function module or something like this for that?

1 ACCEPTED SOLUTION
Read only

ferry_lianto
Active Contributor
0 Likes
1,866

Hi,

Please check these FM.

STRING_SPLIT_AT_POSITION

SWA_STRING_SPLIT

Regards,

Ferry Lianto

4 REPLIES 4
Read only

ferry_lianto
Active Contributor
0 Likes
1,867

Hi,

Please check these FM.

STRING_SPLIT_AT_POSITION

SWA_STRING_SPLIT

Regards,

Ferry Lianto

Read only

former_member194669
Active Contributor
0 Likes
1,866

Hi,

Use fm RKD_WORD_WRAP

a®

Read only

Former Member
0 Likes
1,866

Hi,

Use SPLIT command -

SPLIT f AT g INTO TABLE itab.

Effect

Similar to variant 1

The sections of f are placed in the internal table itab. The sytsem creates a table row for each section of f.

Note: If f ends with the separator string g, the system does not create an empty table row at the end. This is in contrast to what happens when g occurs at the beginning of f.

Example

TYPES: BEGIN OF ITAB_TYPE,

WORD(20),

END OF ITAB_TYPE.

DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH

NON-UNIQUE DEFAULT KEY INITIAL SIZE 5.

SPLIT 'STOP Two STOP Three STOP ' AT 'STOP' INTO TABLE ITAB.

ITAB now has three rows. The first is empty, the second contains ' Two', and the third ' Three'.

Hope this helps.

ashish

Read only

daniel_humberg
Advisor
Advisor
0 Likes
1,866

FM SWA_STRING_SPLIT really solves the problem.

If I would work with character fields instead of strings, then 'RKD_WORD_WRAP' would also work.

Thx you all!