‎2020 Dec 07 5:54 AM
hi,
i have a string which has around 100 names concatenated and i have to write a query to identify the sub string.
1. I should consider it as substring even if the order of the names are different
2. I should consider it as substring only if all the names present in str2 are present in str1.
i can split all the names and add it to internal table and than comparing it using loop but it be a performance issue.
can anyone suggest other way.
CONCATENATE 'ram' 'viju' 'meera' INTO lv_string.
CONCATENATE 'viju' 'ram' INTO lv1_string.
IF lv1_string CA lv_string. (This is not working as it will satisfy even if it has 1 diff name)
write 'the lv1_string is a substring'.
ENDIF.
‎2020 Dec 07 8:24 AM
Hello vijayashri
Why would you look for another way? Splitting into internal table, LOOPing and comparing will be as fast as a lightning and will not be a performance issue in any way.
The only issue I can see in your example is that the names are not separated by any separator. How will you split them then?
Kind regards,‎2020 Dec 07 8:12 AM
Why do you think it's a performance issue for doing IF on 100 names?
It should take something like micro seconds, is it too much for you?
‎2020 Dec 07 8:24 AM
Hello vijayashri
Why would you look for another way? Splitting into internal table, LOOPing and comparing will be as fast as a lightning and will not be a performance issue in any way.
The only issue I can see in your example is that the names are not separated by any separator. How will you split them then?
Kind regards,‎2020 Dec 07 10:29 AM
Exactly how I would solve this. Simple, straightforward and fast.
‎2020 Dec 07 8:24 AM
i was thinking if there is any 7.5 syntax that can solve this issue
‎2020 Dec 07 7:51 PM
So, not really an issue... you just want to use a Constructor Expression (available since 7.40), for unknown reason...
‎2020 Dec 07 7:56 PM
By the way, I think that most of Constructor Expressions just use the same byte code as old ABAP. Consequently, it's rarely faster, it's just that when correctly used it can be much more legible ("functional" syntax). If anyone knows a link to a performance workbench blog post, I am interested 😉