Barcode Printing

Dear ,

I Have One Problem In Microsoft Nave 2013.

When I am Bar Code Printing Time Quantity is Not Coming Properly.May Be I Think My Coding Is Not Correct.

@@@My Coding

“P&PSetup”.RESET;

“P&PSetup”.FINDFIRST ;

IF (BarcodeNo <> ‘’) THEN

SETFILTER(“Barcode No.”,BarcodeNo)

ELSE

ERROR(‘Select Barcode No’);

IF Location = ‘’ THEN

ERROR(‘Please select Location code’);

IF NoOfCopies = 0 THEN

ERROR(‘Please select No Of Copies’);

IF Location = ‘016’ THEN

txtFileName:=’\xy-PC\GM\Barcode2.prn’

ELSE IF Location = ‘12’ THEN

txtFileName:=’\m-PC\GM\Barcode2.prn’

ELSE IF Location = ‘g11’ THEN

txtFileName:=’\st1-pc\GM\Barcode2.prn’

ELSE IF Location = ‘451’ THEN

txtFileName:=’\Ra1-pc\GM\Barcode2.prn’

ELSE IF Location = ‘R15’ THEN

txtFileName:=’\ty-pc\GM\Barcode2.prn’

ELSE IF Location = ‘k7’ THEN

txtFileName:=’\BACK-PC\GM\Barcode2.prn’

ELSE IF Location = ‘u6’ THEN

txtFileName:=’\ST3\GM\Barcode2.prn’

ELSE

txtFileName:=’\xym-PC\GM\Barcode2.prn’;

{

Filef.CREATEOUTSTREAM(MyOutStream);

END ELSE

BEGIN

Filef.CREATE(txtFileName);

Filef.OPEN(txtFileName);

Filef.ERASE(txtFilelines);

Filef.Delete(MyOutStreamlines)

Filef.CREATEOUTSTREAM(MyOutStream);

Filef.WRITEMODE(TRUE);

Filef.TEXTMODE(TRUE);

Filef.ERASEMODE (TRUE);

Filef.DeleteMODE(TRUE);

END;}

{IF NOT EXISTS(txtFileName)

Filef.CREATE(txtFileName);

Filef.OPEN(txtFileName);

Filef.ERASE(txtFilelines);

Filef.Delete(MyOutStreamlines)

Filef.CREATEOUTSTREAM(MyOutStream);

THEN BEGIN

Filef.WRITEMODE(TRUE);

Filef.TEXTMODE(TRUE);

Filef.ERASEMODE (TRUE);

Filef.DeleteMODE(TRUE);

END;}

//MESSAGE(‘Begin’);

Filef.WRITEMODE(TRUE);

Filef.TEXTMODE(TRUE);

Filef.CREATEOUTSTREAM(MyOutStream);

Barcodes - OnAfterGetRecord()

recItem.RESET;

recItem.SETRANGE(recItem.“No.”,“Item No.”);

IF recItem.FINDFIRST THEN BEGIN

recSalesPrice.RESET;

recSalesPrice.SETRANGE(recSalesPrice.“Item No.”,recItem.“No.”);

recSalesPrice.SETRANGE(recSalesPrice.“Sales Code”,Location);

recSalesPrice.SETRANGE(recSalesPrice.“Unit of Measure Code”,Barcodes.“Unit of Measure Code”);

IF recSalesPrice.FINDLAST THEN

Price:=recSalesPrice.“Unit Price Including VAT”;

END;

//itemcode := DELSTR(“No.”,1,4);

IF NOT EVALUATE(detInt,FORMAT(Price)) THEN

DecNo := TRUE

ELSE

DecNo := FALSE;

line1:=‘I8,A,001’;

line2:=’’;

line3:=’’;

line4:=‘Q213,024’;

line5:=‘q831’;

line6:=‘rN’;

line7:=‘S4’;

line8:=‘D8’;

line9:=‘ZT’;

line10:=‘JF’;

line11:=‘OD’;

line12:=‘R256,0’;

line13:=‘f100’;

line14:=‘N’;

IF DecNo THEN

line15:=‘A210,34,2,4,1,1,N,"’+FORMAT(Price)+’"’

ELSE

line15:=‘A138,34,2,4,1,1,N,"’+FORMAT(Price)+’.00’+’"’;

line16:=‘A297,158,2,1,1,1,N,"’+recItem.“Description 2”+’"’;

//line15:=‘B269,133,2,E30,2,B,"’+Barcodes.“Barcode No.”+’"’;

line17:=‘B287,138,2,1,2,6,48,B,"’+Barcodes.“Barcode No.”+’"’;

//line16:=‘A251,154,2,4,1,1,N,"’+Item.“Description 2”+’"’;

//line17:=‘A182,32,2,4,1,1,N,“QR”’;

line18:=‘P’+FORMAT(NoOfCopies);

MESSAGE(’%1’,Barcodes.“Barcode No.”);

Filef.OPEN(txtFileName);

//Filef.WRITE( line1);

//Filef.CLOSE;

MyOutStream.WRITETEXT(line1);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line2);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line3);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line4);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line5);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line6);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line7);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line8);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line9);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line10);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line11);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line12);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line13);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line14);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line15);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line16);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line17);

MyOutStream.WRITETEXT();

MyOutStream.WRITETEXT(line18);

MyOutStream.WRITETEXT();

//Filef.CLOSE;

//MESSAGE(‘Mid’);

Barcodes - OnPostDataItem()

Filef.CLOSE;

//Test.RUN;

IF Location = ‘x’ THEN

Path:=‘C:\GM\Barcode.bat’

ELSE IF Location = ‘y’ THEN

Path:=‘C:\GM\Barcode.bat’

ELSE IF Location = ‘z’ THEN

Path:=‘C:\GM\BarcodeR11.bat’

ELSE IF Location = ‘A’ THEN

Path:=‘C:\GM\Barcode.bat’

ELSE IF Location = ‘B’ THEN

Path:=‘C:\GM\Barcode.bat’

ELSE IF Location = ‘C’ THEN

Path:=‘C:\GM\Barcode.bat’

ELSE IF Location = ‘D’ THEN

Path:=‘C:\GM\Barcode.bat’

ELSE

Path:=‘C:\GM\Barcode.bat’;

runModally := FALSE;

dumm := 1;

CREATE(wShell,FALSE,TRUE);

wShell.Run(Path,dumm,runModally);

//MESSAGE(‘End’);

@@@ tXt file Showing

I8,A,001

Q213,024

q831

rN

S4

D8

ZT

JF

OD

R256,0

f100

N

A138,34,2,4,1,1,N,“0.00”

A297,158,2,1,1,1,N,“GEEPAS S/S KETTLE GK175”

B287,138,2,1,2,6,48,B,“6294001707509”

P100

P10

If Any Problem Your Guys Can Found Tell Me.
Thank You
Arshad

Hi Arshad,

Barcodes are a challenge, regardless of the program you’re working with. I’ve looked at your question and your code sample and, aside from any observations on style or NAV coding conventions, I have to say that I’m not sure what it is that you’re asking about. You mention Quantity and Time in your question, but I don’t see any reference to either in your code.

Could you be a bit more precise about the exact nature of the problem?

Hi,

Actually When I am Print First Time, When I Give 10 Copies It came Properly.Second Time I am Give 100 copies But Printing 110 Copies

@@ You Can Find My Text File

P100

P10

Total=110

  • If You have Idea Resolving Each Problem

It looks like the output file name is static, meaning that you are sending output to the same file name each time you run the process. This makes me wonder whether you might be writing one file on top of another? Try adding something to the output file name that will make it unique each time you run the process, like date and time. After you’ve done that, run the process several times and compare the contents of the individual output files.

One other observation, on the code sample you’ve provided … it looks like you might have a bug in the area of code where you’re trying to erase an existing file. Here’s your code:

Filef.CREATE(txtFileName);

Filef.OPEN(txtFileName);

Filef.ERASE(txtFilelines);

Do you see that, in the ERASE command, you’re using a different variable name to represent the name of the file that you’re trying to delete? Why wouldn’t you use ERASE(txtFileName) instead of ERASE(txtFilelines)?

Hi

Yes I can Understand. When I am Delete My Text File In My Pc. It Coming to Properly.That Is the main Reason I Try to Erase.

@@exampleI8,A,001

Q213,024

q831

rN

S4

D8

ZT

JF

OD

R256,0

f100

N

A138,34,2,4,1,1,N,“0.00”

A297,158,2,1,1,1,N,“GEEPAS S/S KETTLE GK175”

B287,138,2,1,2,6,48,B,“6294001707509”

P100

P10

@@@@ When I am Delete Each Text File In My Pc It Coming to Properly (no of Copies)

Well, you have two choices then, that I can see. Either create unique file names for your exports so that you never use the same name twice, or fix the bug in your code related to the ERASE statement that I noted earlier (you’re using a different file name variable for the ERASE method than you are for CREATE and OPEN.)

Hope that does it for you.