It is the hardest suffering I had in this year, so I would like to share it.
First, forget bar code fonts (do not work for non-English countries, it is a deep Navision bug of what fonts it accept).
Use the BMP-generating download from the downloads.
You will need to print more than one barcode per item, so you will need a new table, with fields like Item No., Barcode, Barcode BMP (a BLOB), Quantity, Price, Description, etc. of which Barcode (f.e. Item Cross-References) and Quantity is important now - quantity is where users enter how much to print from a given item (and of course you need additional code that suggests to print the quantities on inventory or a receipt or manuf. document etc., but that's easy to do)
Create a directory C:\barcode. Of course you can create fields in some settings table, but for this example I will hardcode it.
the barcode generating and importing code (on a button, or something) will look something like:
fname:='c:\barcode\barcodetemp.bmp';
CLEAR(itemlabel);
CREATE(shl);
IF itemlabel.FIND('-') THEN REPEAT
bc:=itemlabel."Barcode No.";
IF STRLEN(bc)=13 THEN BEGIN
bc:=COPYSTR(bc,1,12);
zero:=0;
tru:=TRUE;
shl.Run('c:\barcode\NAVIBAR.exe ' + bc +'{01{120{60{'+fname,zero,tru);
itemlabel."Barcode BMP".IMPORT(fname);
itemlabel.MODIFY(TRUE);
FILE.ERASE(fname);
END ELSE BEGIN
itemlabel.DELETE(TRUE);
END;
UNTIL itemlabel.NEXT=0;
CLEAR(shl);
COMMIT;
rep.SETTABLEVIEW(itemlabel);
rep.RUN;
highlights:
- this is for EAN13. the STRLEN-tricks are to ensure only 13 digit barcodes will be printed, but we export only 12, because Navibar autocalculates the check digit, so even if it's wrong in Navision, it can print it. (Of course reading it will not be possible, as you don't have such code. Okay, it may be a bit clumsy solution, but I did not want to add error messages.)
shl is an Automation, "Windows Scripting Host Object Library.Shell
it is configured by the two variables, to hold up everything until the program finishes running. It is important, or else you try reading a file that is locked and that is not possible.
Then we run the report. The report will be the next post.
Comments
You can start with a report wizard, that at least can easily configure the layout.
You will need the record count in you OnPreDataItem>
First thing is to create an Integer data item, indented. You will need in the OnPreDataItem of integer. Do not forget to copy the OnPreSection!
OnAfterGetRecord of Integer for a 3-column report is something like:
I don't even try to explain it. Some of it is standard, wizard-generated code, the other is working around Navision's limitation that it cannot print a BMP from a variable, so we trick with record variables. OF course you need picture boxes with sourceexpr like il1."Barcode BMP", and so on.
There is a bug somewhere near the commented out code, it prints two extra labels, only with picture, no text. This is not a serious problem, I am tired now, but I will try making a 3-array of record variable instead of IL1, IL2, IL3 record variables, maybe that corrects that.
Maybe with this help barcode printing won't become a big nightmare for you.
Do It Yourself is they key. Standard code might work - your code surely works.