0

On another forum I found this formula and it seems to work except that I keep getting 2 different errors

First Error
I get "A string is required here" error. I'm getting the error on line 8 (counting blank lines) of the code where it says

replace({ACCOUNT_CARD_DATA.CARD_NUMBER}," ","")

Second Error
If I add totext and make it say

replace(totext({ACCOUNT_CARD_DATA.CARD_NUMBER})," ","")

it will save with no errors but when I try to put it in the report it gives me a "The string is non-numeric" error. When I click ok it shows me the error in the code is on line 18 (counting blank lines) where it says

v_calc := tonumber(v_temp) * 2

I feel like I'm in a loop that can't be resolved...what am I doing wrong?

Thank you!

Entire Code

whileprintingrecords;
stringvar v_cc := "";
stringvar v_temp := "";
numbervar v_calc := 0;
numbervar v_result := 0;
numbervar v_counter := 0;

v_cc := replace({ACCOUNT_CARD_DATA.CARD_NUMBER}," ",""); //THIS IS THE 1ST PLACE I'M GETTING THE ERROR

// Double every other digit starting with the last digit.

numbervar v_counter := len(v_cc);

while v_counter > 0

do
(v_temp := mid(v_cc,v_counter,1);
v_calc := tonumber(v_temp) * 2; //THIS IS THE 2ND PLACE I'M GETTING THE ERROR

if v_calc >= 10 then v_calc := tonumber(left(totext(v_calc,"#",0),1))+ tonumber(right(totext(v_calc,"#",0),1))
else
v_calc;

v_result := v_result + v_calc;
v_counter := v_counter - 2);

// Add in the non-doubled digits
v_counter := len(v_cc) - 1;

while v_counter > 0

do
(v_temp := mid(v_cc,v_counter,1);
v_calc := tonumber(v_temp);
if v_calc >= 10 then v_calc := tonumber(left(totext(v_calc,"#",0),1)) + tonumber(right(totext(v_calc,"#",0),1))
else
v_calc;

v_result := v_result + v_calc;
v_counter := v_counter - 2);

// Calculate check digit
v_cc + right(totext(v_result * 9,"#",0),1)
  • Could it be null or empty? ({ACCOUNT_CARD_DATA.CARD_NUMBER}) Furthermore, i see you are trying to remove empty space, so, i understand it is not really a numeric field, right? – heringer Feb 07 '17 at 10:52
  • {ACCOUNT_CARD_DATA.CARD_NUMBER} this field has only numebers? or it has any letters – Siva Feb 08 '17 at 11:02

0 Answers0