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

insert a space in a string in automatic basis after every 2 characters

maherkhalaf
Discoverer
0 Likes
1,712

Hi experts,

I have a string which is returning a value with different length for each system

and I need to return that value in a report with a better layout for that I need to insert a space in between every 2 characters, how can I do that?

example: original string value = D2F2G1V0E0M5B3

how I need to return it = D2 F2 G1 V0 E0 M5 B3

the problem is: the length of the original string is different for each system

thanks in advance and best regards,

1 ACCEPTED SOLUTION
Read only

Sathya_Gunasekaran
Contributor
1,582

You can build your own logic. Eg.,

Hi experts,

I have a string which is returning a value with different length for each system

and I need to return that value in a report with a better layout for that I need to insert a space in between every 2 characters, how can I do that?

example: original string value = D2F2G1V0E0M5B3

how I need to return it = D2 F2 G1 V0 E0 M5 B3

the problem is: the length of the original string is different for each system

thanks in advance and best regards,

3 REPLIES 3
Read only

Sathya_Gunasekaran
Contributor
1,583

You can build your own logic. Eg.,

Read only

retired_member
Product and Topic Expert
Product and Topic Expert
Read only

Sandra_Rossi
Active Contributor
0 Likes
1,582

Many possibilities:

DATA lv_data TYPE string VALUE 'D2F2G1V0E0M5B3'.
lv_data = replace( val = lv_data regex = '(..)' with = `$1 ` occ = 0 ).
ASSERT lv_data = `D2 F2 G1 V0 E0 M5 B3 `.