Rashed Amini

The ara3n weblog

Archive for April, 2008

Barcode 128B

24th April 2008

Most Navision reports use the 3 of 9 Barcode to print barcodes in Navision and they use 3 of 9 font available on the net. For people who don’t know how 3 of 9 works, It basically is the same value but has a * at the begging and the end of what ever you are printing.

So For example Item 123 would print *123* with 3 of 9 font.

The same applies to Barcode 128. There are 3 version of if A B C.
Most people use 128B. Barcode 128 has a starting character, Ending character, and a checksum.

There is an example on mibuso for 128B barcode, unfortunately it doesn’t work here in US.

So I’ve created a function that that calcuates the checksum and returns the barcode 128B.

GetBarcode(rawData : Text[1000]) newCodeString : Text[1003]
offset := 32;
highAscii := 66;
newCodeString[1] := offset + highAscii + 104;
total := 104;

FOR stringCounter := 1 TO STRLEN(rawData) DO BEGIN
character := rawData[stringCounter];
ASCIIValue := character;
checkDigit := ((ASCIIValue - offset) * (stringCounter));
total += checkDigit;
newCodeString[stringCounter + 1] := ASCIIValue;
END;
check := total MOD 103;
holder := 0;

IF (check + offset >= 127) THEN
holder := check + offset + highAscii
ELSE
holder := check + offset;

newCodeString[STRLEN(newCodeString)+1] := holder;
holder := 106 + offset + highAscii;
newCodeString[STRLEN(newCodeString)+1] := holder;

FOR rCounter := 1 TO STRLEN(newCodeString) DO
IF(newCodeString[rCounter] = 32) THEN
newCodeString[rCounter] := 177;

EXIT(newCodeString);

Name DataType Subtype Length
offset Integer
highAscii Integer
total Integer
stringCounter Integer
holder Integer
check Integer
character Char
ASCIIValue Integer
checkDigit Integer
rCounter Integer

You can use the following Font128B with this function.

You can also download this barcode128B report as an example.

Posted in Dynamics NAV | No Comments »

Webservice with WinHTTP

24th April 2008

There are several howto on mibuso on how to consume webservices. Most of these examples for example
http://www.mibuso.com/forum/viewtopic.php?t=23618

You can also use WinHTTP
‘Microsoft WinHTTP Services, version 5.1′.WinHttpRequest

Why would you want to use WinHTTP, well it has a SetTimeouts function that allows you to stop waiting for a webservice. So navision doesn’t stop working if you don’t receive a message back.

WinHTTP.Open('POST','http://www.webservicex.net/CurrencyConvertor.asmx',0);
WinHTTP.SetRequestHeader('Content-type','text/xml');
WinHTTP.SetRequestHeader('SOAPAction','http://www.webserviceX.NET/ConversionRate');

WinHTTP.SetTimeouts(1000,1000,1000,1000);

WinHTTP.Send(XmlDoc);
WinHTTP.WaitForResponse(1000);

XmlDoc.async := FALSE;
XmlDoc.load(WinHTTP.ResponseBody);

IF WinHTTP.Status 200 THEN
ERROR('Http Error ' + ' ' + FORMAT(WinHTTP.Status) + ': ' + WinHTTP.StatusText);

Posted in Dynamics NAV | 1 Comment »