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: 

Hi there,

Former Member
0 Kudos

I would like to ask a question about an issue  that i need your help to success it

Firstly, assume that , I have a text like " Request the maintenance to perform at an object "

I want to shorten this sentence to   "REMAINTIPERFAOBJ"  otomatically.  --> The length of this Word  must be 16 or less.

How can i do that on ABAP ?

Is there anybody can tell me the method ?

P.S :  I just want to create a smart code according to long text.  Then, i'll  insert this short text to Z table.

1 REPLY 1

former_member183045
Contributor
0 Kudos

Well an interesting requirement, but lets give it a try 🙂

An idea would be to take the 2 first characters of each word. So you can "map" the first 8 words. Alternatively you could also take only the first character to map 16 words - or a different combination.

1. idea

One possibilty would be to manually loop through the string. Take the first character and append it to the output character, take the second and append, take the first character after the first blank and append it, take the second, ...

2. ideal

Or you could use a regular expression like (\s[A-Za-z]{2}){1} which gives you all first 2 characters in a result set. (For simplicity I omitted the selection of the leading two characters as here the regex has to start with ^ and not \n.

FIND ALL OCCURRENCES OF REGEX '\s[A-Za-z]{2}){1}'
  IN 'Request the maintenance ...'
RESULTS lt_result.

... then loop through result table lt_result and append each result to the output table.

3. idea which requires the fewest effort:

take the first 16 characters ignoring the spaces:

CONDENSE 'Request the maintenance ...' NO-GAPS

Hope I could help you,

Andreas