Application Development 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: 

split from a field into another 2 fields

Former Member
0 Kudos

hi forum,

say i have 1 field contains of 30 char.

now i need to split it into 2 fields with each 15 char.

when separate into 2 field, the word should not be broken.

say i have sentence like this "what a wonderful day". when split, field1 is "what a" whereas field2 is "wonderful day".

how to check the sentence with consideration of space as well so that can preserve the whole word when split.

thanks alot


3 REPLIES 3

former_member192854
Active Participant
0 Kudos

Hi, you could use something which looks likes:

DATA lv_char30 TYPE char30.

DATA lt_splitted TYPE char30.

SPLIT AT lv_char30 INTO TABLE lt_splitted AT space.

Now you have all words in a separate entry in lt_splitted. From here you can create logic to check the length of the word and start concatenating it into two separate fields.

Good luck!

Sander

Former Member
0 Kudos

You might like to check this post:

which mentions a function module 'RKD_WORD_WRAP' to do the work... the FM has a limit of three lines out I think.

Jonathan

former_member184569
Active Contributor
0 Kudos

Use FM RKD_WORD_WRAP. It preserves the word, and splits the string based on the size given in the importing parameter and exports output to the table.

data : input type string.

DATA: lines(132) OCCURS 0 WITH HEADER LINE.


  CALL FUNCTION 'RKD_WORD_WRAP'
         EXPORTING
           textline                  = input
          OUTPUTLEN                 = 10
        TABLES
          OUT_LINES                 = lines.