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

how to identify substring

Former Member
0 Likes
1,400

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.
1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
1,311

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,
Mateusz
6 REPLIES 6
Read only

Sandra_Rossi
Active Contributor
1,311

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?

Read only

MateuszAdamus
Active Contributor
1,312

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,
Mateusz
Read only

matt
Active Contributor
1,311

Exactly how I would solve this. Simple, straightforward and fast.

Read only

Former Member
0 Likes
1,311

i was thinking if there is any 7.5 syntax that can solve this issue

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,311

So, not really an issue... you just want to use a Constructor Expression (available since 7.40), for unknown reason...

Read only

Sandra_Rossi
Active Contributor
1,311

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 😉