Skip to Content
0
Former Member
Oct 15, 2007 at 03:17 PM

How to write ABAP code to split a sentence into Word by Word and store them

1834 Views

Hi all,

I have to split a sentence into word by word and store them into separate columns. This sentence is nothing but a text description (TXTMD) from table TXXXX. The description will have 3 or more than 3 words and LAST word will be <b>always with %</b>'. The following is the sample input data:

KEY(ORD43) Description(TXTMD)

'AAAA' '1234 ABCD COMPANY USA 80%'

'BBBB' '4745 XYZ INC CANADA ABCD 70%'

For the first record:

'1234' should stored in to <b>Field 1</b>, 'ABCD COMPANY USA' into <b>Field 2</b> and

'80%' into <b>Filed 3</b>.

For the second record:

'4745' should stored in to <b>Field 1</b>, 'XYZ INC CANADA ABCD' into <b>Field 2</b> and 70%' into <b>Field 3</b>.

The first word into Field 1, the last word with % into Field 3 and all middle words into Field 2. The number of words in the sentence could be 3 or more than 3.

Could you please help in writing the ABAP for this requirement ????

Thanks in advance.

Regards,

Venkat.