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 statement at fixed intervals

Former Member
0 Kudos

I am using a SPLIT statement to break a string and throw it into an internal table.

Right now - the string is pipe delimited, so i m using

SPLIT string at ' |' into int_table.

Question: If there is no pipe delimited on the string and I want to split at a fiexed interval say after every 40 characters.

can this be done? IF yes then how ?

I tried SPLIT string at '+0(40)' into int_table - did not work

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

For fixed interval, Use this FM RKD_WORD_WRAP instead of the SPLIT.

Specify your fixed length in OUTPUTLEN parameter of FM.

Regards,

Naimesh Patel

5 REPLIES 5

Former Member
0 Kudos

If you know the position where you want to split, you can directly use offsets rather than a split statement.

string1 = string+0(40).

string2 = string+40(40). and so on.

naimesh_patel
Active Contributor
0 Kudos

For fixed interval, Use this FM RKD_WORD_WRAP instead of the SPLIT.

Specify your fixed length in OUTPUTLEN parameter of FM.

Regards,

Naimesh Patel

0 Kudos

Hello Naimesh,

Thanks for your response. This FM looks good but the only problem is that the input paramater TEXTLINE can take only 200 characters, whereas I will be passing a string which can have more than 200 chars. Is there any way around this ?

Thanks,

ND.

0 Kudos

Yes, it has limitation to take a variables upto only 256 characters.

Workaround would be, copying the FM and make the changes.

Or, if you are not worrying about the "broken" words than you can go like this:

Like:



L_LENGTH = 40

L_LEN = STRLEN( L_TEXT).
L_TIMES = L_LEN / L_LENGTH.
L_TIMES = L_TIMES + 1.

DO L_TIMES TIMES.
  L_STR = L_STR + L_LENGTH.
  ITAB-TEXT = L_TEXT+L_STR(L_LENGTH).
  APPPEND ITAB.
ENDDO.

Regards,

Naimesh Patel

0 Kudos

I don't think it's limitted to that. This seems to work:

REPORT ztest .

DATA: txt(666).

DATA: BEGIN OF itab OCCURS 0,
        f1(35),
      END OF itab.

DO 10 TIMES.
CONCATENATE txt 'one two three four five six seven eight' INTO txt
      SEPARATED BY space.
ENDDO.

CALL FUNCTION 'RKD_WORD_WRAP'
  EXPORTING
    textline  = txt
  TABLES
    out_lines = itab.

Rob