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

REPLACE : want to replace the string

Former Member
0 Likes
1,498

Hello All,

I need to replace a word(GO) in a sentence with another word(GONE). these words are stores in the variables var1(6) & var2(6) used the keyword REPLACE for this But I am getting some unwanted blank spaces. I used CONDENE keyword then also one blank space remains. I should not get any unwanted blank space. Please help me.

Data : var1(6) type c.

Data : var2(6) type c.

Data : var3(15) type c.

Data : len type i.

var1 = 'GO'.

var2 = 'GONE'.

var3 = 'ABCDGOEFGH'

len = strlen(var1).

REPLACE var1LENGTH len WITH var2 INTO var3.

Then the new sentence is coming like

ABCDGONE EFGH

I used CONDENSE then again it is coming like.

ABCDGONE EFGH

I need the sentence like ABCDGONEEFGH

Regards,

Lijo John

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,385

hi,

you have to use CONDENSE var3 NO-GAPS . (CONDENSE alone will reduce only to one space.)

hope this helps

ec

10 REPLIES 10
Read only

MilindMungaji
Participant
0 Likes
1,385

REPLACE ALL OCCURRENCES OF 'GO' in var3 WITH 'GONE'.

Read only

JozsefSzikszai
Active Contributor
0 Likes
1,386

hi,

you have to use CONDENSE var3 NO-GAPS . (CONDENSE alone will reduce only to one space.)

hope this helps

ec

Read only

Former Member
0 Likes
1,385

HI,

Plz try and Check the Code.

Condense (VAr1).

Condense(VAr2).

Replace Var1 withe Var2 into Var 3.

Regards

Sumit Agarwal

Read only

Former Member
0 Likes
1,385

hi,

check the data type length of variables..than it is coming right..

Data : var1(2) type c.

Data : var2(4) type c.

Data : var3(12) type c.

Data : len type i.

Regards,

Deepthi.

Read only

Former Member
0 Likes
1,385

Hello

Declare

Data : var2(4) type c.

Read only

0 Likes
1,385

Dear Friends,

I cannot restrict the variable length. The data length will be keep changing as per the situation.

eg.

va1 = 'Please raise the Travel Req'

var2 ='Please raise an Emergency Travel Req'

and some space should be there. I dont want to chage that spaces also.

Regards,

Lijo

Read only

0 Likes
1,385

Data : var1(3) type c.
Data : var2(12) type c.
Data : var3(40) type c.
Data : len type i.

var1 = 'the'.
var2 = 'an Emergency'.
var3 = 'Please raise the Travel Req'.
len = strlen( var1 ).
REPLACE var1 LENGTH len WITH var2 INTO var3.
Read only

Former Member
0 Likes
1,385

Hi,

I have changed the code written by you.

Check this-

Data : var1(6) type c.
Data : var2(6) type c.
Data : var3(15) type c.
Data : len type i.


var1 = 'GO'.
var2 = 'GONE'.

var3 = 'ABCDGOEFGH'.

len = strlen( var1 ).

REPLACE var1 LENGTH len WITH var2 INTO var3.

condense var3 no-gaps.
write:var3.

Read only

Former Member
0 Likes
1,385

Hi,

Plz check your variable declaration part :


Data : var1(2) type c.
Data : var2(4) type c.
Data : var3(12) type c.
Data : len type i.

or

Use

" CONDENSE  var3 No-GAPS. "

thanx.

Read only

Former Member
0 Likes
1,385

Hi,

Try this:

Data : var1(6) type c.

Data : var2(6) type c.

Data : var3(15) type c.

Data : len type i.

var1 = 'GO'.

var2 = 'GONE'.

var3 = 'ABCDGOEFGH'.

len = strlen( var1 ).

REPLACE var1 LENGTH len WITH var2 INTO var3.

condense var3 no-gaps.

write var3.

Regards,

Surinder