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

Issue with replace

Former Member
0 Likes
725

Hi experts,

In the following code, I am replacing the first digit of my value by 0 and the last digit by 0 also.

It's working fine for the first digit but not always for the last one and i don't see why:

    DATA:

          lgn TYPE i,

          antec TYPE /bic/oizbpn,

          antecid TYPE /bic/oizbpn.

    IF source_fields_rule-/bic/zbpntrans = 'XXX'.

      antec = source_fields_rule-/bic/zbpn.

      lgn = STRLEN( antec ) - 1.

      REPLACE antec+0(1) IN antec WITH '0'.

      REPLACE antec+lgn(1) IN antec WITH '0'.

      RESULT = antec.

    ELSE.

      RESULT = source_fields_rule-/bic/zbpn.

    ENDIF.

Thanks for your support.

Amine

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
680

Hi,

What you're code is doing is to replace the characters that are equal to your first and last character with 0.

You should change this lines:

REPLACE antec+0(1) IN antec WITH '0'.

REPLACE antec+lgn(1) IN antec WITH '0'.

And try with:

antec+0(1) = '0'.

antec+lgn(1) = '0'.

Martin

6 REPLIES 6
Read only

Former Member
0 Likes
680

What does it do for the final digit?

Neal

Read only

0 Likes
680

Hi Neal,

I have to replace the last digit by a 0.

Thanks.

Amine

Read only

0 Likes
680

Yes, but what does it actually do instaed?

Neal

Read only

0 Likes
680

The first letter is always replaced by 0, by the last one not always.

Amine

Read only

Former Member
0 Likes
681

Hi,

What you're code is doing is to replace the characters that are equal to your first and last character with 0.

You should change this lines:

REPLACE antec+0(1) IN antec WITH '0'.

REPLACE antec+lgn(1) IN antec WITH '0'.

And try with:

antec+0(1) = '0'.

antec+lgn(1) = '0'.

Martin

Read only

0 Likes
680

Worked better the replace.

Thanks.

Amine