Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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

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.

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question