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

String operation - change delimit

Former Member
0 Likes
781

Hello all,

I have a string which has a pipe delimited content like

|TEST1    |TEST2          |TEST3 |

I would like to change the pipe delimited content to fixed width delimit.

Any thoughts. Please let me know.

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
753

Replace all occurrences of '|' in lv_string with space.

condense lv_string.

For more details check the f1 help of condense statement.

6 REPLIES 6
Read only

Former Member
0 Likes
753

I tried

REPLACE ALL OCCURENCES OF '|' IN STRING WITH SPACE.

With this the pipe was gone but all the contents moved to left by one char. In fact I wanted to replace the pipe with actual space.

Any thoughts?

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
754

Replace all occurrences of '|' in lv_string with space.

condense lv_string.

For more details check the f1 help of condense statement.

Read only

0 Likes
753

I do not think condense would help me as it takes out all the blank spaces.

This is what I am trying to achieve.

|TEXT1  |TEXT2     |

In the above string, once I do the replace with space, TEXT1 moves left to the first position (which is OK) but TEXT2 moves left by two spaces since it replaced two |. Instead for the secnod | and subsequent onces, the | should be replaced with actual space meaning in the above example, TEXT2 should move left by only one space.

Experts please help.

Read only

0 Likes
753

This will work


data:lv_string type string.
lv_string = '|TEST1    |TEST2          |TEST3 |'.
replace ALL OCCURRENCES OF '|' in lv_string with ` `.
shift lv_string left DELETING LEADING space.

Read only

0 Likes
753

replace all occurrences of 'I' with space into.... in character mode.... That doesn't work?? Can't imagine why this is happening to you.... you're not doing anything else like shift or condense?

Read only

0 Likes
753

>

> replace all occurrences of 'I' with space into.... in character mode.... That doesn't work?? Can't imagine why this is happening to you.... you're not doing anything else like shift or condense?

Hi,

SPACE represents an empty single-character constant (technically ' ') which has got an no length.

But ` ` represnts a string literal with space which is has got length as 1. Hence the difference with space & ` ` while using REPLACE.

You can read more about character v/s string literals on Rainer's blog.

BR,

Suhas

PS: I have no idea how CONCATENATE ... SEPARATED BY space works