Create Integer with leading zero's

I need to create an AllPay Bar code to calculate CheckDigit, Our account Number starts with 0. To Make CRN number we have to add a constant number (562812) + Account number to make 5628120005620000 which is then used to perform checkdigit calculation, unfortunately I need this as an Integer and when I convert to integer, it gives me 0.

% @(1,1,10) = 0005620000
define(&nb1,string,(trimright(@(1,2,10))))
define(&nbstr,string,‘562812’)
define(&nb2,string,&nbstr+&nb1)
define(&barcode,integer,0)
&barcode:=(strtoint(&nb2))
show(inttostr(&barcode))
% required integer result is 5628120005620000
% but result I get is 0 (zero)

Kamlesh,

Silly question… why are you trying to work with integers at all? If you’re doing barcodes you’re going to use a string anyways, and concatenating strings (“123456” + “789012”, which is “12345678901”) works much better than trying to do the same with integers (123456 + 789012, which is 912468)…

So why not just do show(&nb2) instead? Is there a reason you convert it to int and back without any other action?

The biggest integer value is 2147483647. So when you try to convert 5628120005620000 to integer, it doesn’t work.

In your data mapper select the field you need to add leading zeros and scroll down to your Field Definition and change to javascript.

Paste this code (‘000000’+ data.extract(‘FieldName’,0)).slice(-6); //Change the number of zeros and the -6 as needed

For XML use this code

(‘000000’+data.extract(‘./RecordNode/FieldName’).slice(-6));

Many thanks all; I was under the impression calculations can only be done on a field which is integer, but it worked ok with string field.