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 a string into 72 charaters each

Former Member
0 Likes
1,390

I have a string of length 6000 as an input. I need to divide the string into multiples of 72 and create a internal table. Is anybody could give some idea how to do it.

4 REPLIES 4
Read only

Former Member
0 Likes
1,142

Hi,

Use function module CONVERT_STRING_TO_TABLE.

Darren

Read only

Former Member
0 Likes
1,142

A possible solution and one you could have figured out yourself:

g_divided = 6000 div 72. "or is it MOD? I always mix DIV and MOD....

do g_divided  times.

 wa_string_72 = g_string_6000(72).
 append wa_string_72 to it_string_72.

 shift g_string_6000 left 72 places.

enddo.

edit:

Ha! was too late, but that function will do the trick as well!

Edited by: Maen Anachronos on Oct 7, 2008 1:11 PM

Read only

Former Member
0 Likes
1,142

Hi,

Try this method..

DATA: BEGIN OF T_TEMP OCCURS 16,

TEXT(3000),

END OF T_TEMP.

first read string into temp table

DO 25 TIMES.

READ TABLE T_TEMP INDEX SY-INDEX.

CASE SY-INDEX.

WHEN 1.

MOVE T_TEMP+0(72) TO GT_UNIX-test1.

WHEN 2.

MOVE T_TEMP+72(144) TO GT_UNIX-test2.

...............

..............

................

.................

endcase.

enddo.

Regds,

Paras

Read only

Former Member
0 Likes
1,142

Use FM 'IQAPI_WORD_WRAP'.

CALL FUNCTION 'IQAPI_WORD_WRAP'

EXPORTING

textline = w_string

outputlen = 72

TABLES

out_lines = outtab

EXCEPTIONS

outputlen_too_large = 1

OTHERS = 2.

Regards,

Aparna