Skip to Content

Replace letters with zero in BP code

IN a crystal report I am trying to replace all letters in the Business Partner code with a zero. It has worked so far on my test database with the letter V using the following formula:

(Replace ({OCRD.CardCode}, 'V', '0'))

However, our clients have Business Partner codes with various letters and all these letters need to be replaced by a zero.

Can this be done in one formula or would it need to be 52 (upper and lower case letters) different formula's?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Dec 14, 2018 at 07:24 AM

    Hi Tansyn,

    Create a formula with this code:

    local stringvar s := {OCRD.CardCode};
    local numbervar i;
    local stringvar ns;
    for i := 1 to len(s) do
    (
        if UpperCase(s[i]) IN ["A" to "Z"] then
          ns := ns + '0'
        else
          ns := ns + s[i];
    );
    ns;

    -Abhilash

    Add comment
    10|10000 characters needed characters exceeded