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

Spliting Problem

Former Member
0 Likes
821

Hi all,

I am entering one text like condition of type c of length 100.

Now i want to split it into two parts in the program like 50 in each...

but i also want to check that spliting should not occurs in betweeen word means my word should not split,spliting should occur after that word

Is that possible

thanks in advance....

7 REPLIES 7
Read only

Former Member
0 Likes
757

Hi Dhwani ,

All you need to do is check using offset what is the 50'th character , if it is space then split the text else check for the next character and so on.

Regards

Arun

Read only

0 Likes
757

Thanks for ur help

so i have to put loop?

Read only

0 Likes
757

Hi Dhwani ,

Here is a sample code which will help

data : name(20).

name = 'testtesttest 1234'.

data : index(2) type n ,

index2(2) type n,

temp .

data : name1(20) ,

name2(20).

index = 10.

temp = 'X'.

while temp ne space.

temp = name+index(1).

if temp = space.

name1 = name(index).

index2 = 20 - index - 1.

name2 = name+index(index2).

endif.

index = index + 1.

endwhile.

condense : name1 , name2.

write /: name1 ,

name2.

Regards

Arun

Read only

former_member150733
Contributor
0 Likes
757

g = space.

SPLIT field AT g INTO h1 ... hn.

h1 to hn are the fields or variables where the results are available

Read only

Former Member
0 Likes
757

You could do something like:

data: string(100) type c,

char(1) type c,

split1 type string,

split2 type string,

len type i.

len = strlen(string).

if strlen > 50.

char = string+50.

if char <> space.

split1 = string+50.

split2 = string+50(strlen).

endif.

endif.

the string split1 would contain the first 50 chars of your string as long as the 50th char was not a space. Split2 would contain the rest of the string.

Read only

Former Member
0 Likes
757

Hi,

Just use

CALL FUNCTION 'RKD_WORD_WRAP'

EXPORTING

textline = w_footer "Total string , in your case 100 ch

delimiter = ' '

outputlen = 50

IMPORTING

out_line1 = w_footer1 "Defined as 50 ch each

out_line2 = w_footer2 "Defined as 50 char each

out_line3 = w_footer3

  • TABLES

  • OUT_LINES =

EXCEPTIONS

outputlen_too_large = 1

OTHERS = 2

I hope this helps,

Regards

Raju Chitale

Read only

Former Member
0 Likes
757

PARAMETERS:text(100) TYPE c.

DATA:ln1 TYPE i.

DATA:text1(50) TYPE c,

text2(50) TYPE c,

ch TYPE c,

cl TYPE i VALUE 13,

ln TYPE i VALUE 1,

cl1(3) TYPE n.

ln1 = STRLEN( text ).

DO 10 TIMES.

cl1 = cl.

ch = text+cl1(ln).

IF ch = ' '.

text1 = text+0(cl1).

cl = cl + 1.

text2 = text+cl1(ln1).

EXIT.

ELSE.

cl = cl + 1.

ENDIF.

ENDDO.

WRITE:/ 'text1 = ',text1,'text2 = ',text2.